Skip to content

Commit

Permalink
Merge pull request #793 from particle-iot/bug/sc-133701/tachyon-setup…
Browse files Browse the repository at this point in the history
…-is-rehashing-an-already-hashed

Bug/sc 133701/tachyon setup is rehashing an already hashed
  • Loading branch information
hugomontero authored Feb 11, 2025
2 parents 3570ae1 + 2c0e8c4 commit 93b4bab
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmd/setup-tachyon.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {

async setup({ skip_flashing_os: skipFlashingOs, version, load_config: loadConfig, save_config: saveConfig }) {
try {
const loadedFromFile = !!loadConfig;
this._showWelcomeMessage();
this._formatAndDisplaySteps("Okay—first up! Checking if you're logged in...", 1);

Expand Down Expand Up @@ -98,7 +99,11 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {
const { path: configBlobPath, configBlob } = await this._runStepWithTiming(
'Creating the configuration file to write to the Tachyon device...',
6,
() => this._createConfigBlob({ registrationCode, ...config })
() => this._createConfigBlob({
loadedFromFile,
registrationCode,
...config
})
);
const xmlPath = await this._createXmlFile(configBlobPath);
// Save the config file if requested
Expand All @@ -118,7 +123,7 @@ module.exports = class SetupTachyonCommands extends CLICommandBase {
() => this._flash({
files: [packagePath, xmlPath],
skipFlashingOs,
silent: !!loadConfig
silent: loadedFromFile
})
);

Expand Down Expand Up @@ -405,7 +410,7 @@ Welcome to the Particle Tachyon setup! This interactive command:
}
];
const res = await this.ui.prompt(questions);
const { password } = await this.ui.promptPasswordWithConfirmation({
const password = await this.ui.promptPasswordWithConfirmation({
customMessage: 'Enter your WiFi password:',
customConfirmationMessage: 'Re-enter your WiFi password:'
});
Expand Down Expand Up @@ -453,11 +458,11 @@ Welcome to the Particle Tachyon setup! This interactive command:
return data.registration_code;
}

async _createConfigBlob({ registrationCode, systemPassword, wifi, sshPublicKey, productId }) {
async _createConfigBlob({ loadedFromFile = false, registrationCode, systemPassword, wifi, sshPublicKey, productId }) {
// Format the config and registration code into a config blob (JSON file, prefixed by the file size)
const config = {
registrationCode: registrationCode,
systemPassword : this._generateShadowCompatibleHash(systemPassword),
systemPassword : loadedFromFile ? systemPassword : this._generateShadowCompatibleHash(systemPassword)
};

if (wifi) {
Expand Down

0 comments on commit 93b4bab

Please sign in to comment.