Skip to content

Commit

Permalink
added validation for current pin parameter in change pin
Browse files Browse the repository at this point in the history
  • Loading branch information
SDargarh committed Aug 28, 2023
1 parent 00a675f commit 5e8fbea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,6 @@

* Updated the logs for label update & delete account
* Removed unused encryption key parameter in get accounts
* Added validation for pin parameter in export private key, restore keyring state
* Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin
* Added validation for encryption key in add account, sign message, delete account, get vault details & update label
* Sync the pin validation steps with other methods in import wallet
13 changes: 13 additions & 0 deletions src/lib/keyring.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ class Keyring {
}

async changePin(currentPin, newPin, encryptionKey) {

if (!Number.isInteger(currentPin) || currentPin < 0) {
throw ERROR_MESSAGE.INCORRECT_PIN_TYPE
}
Expand All @@ -832,6 +833,18 @@ class Keyring {
throw ERROR_MESSAGE.INCORRECT_PIN_TYPE
}

const response = await this.validatePin(currentPin);

if (response.response == false || response.error) {
return { error: ERROR_MESSAGE.INCORRECT_PIN };
};

const err = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey));

if (err.error) {
return { error : err.error }
}

const { error, response: mnemonic }= await this.exportMnemonic(currentPin);

if (error) {
Expand Down

0 comments on commit 5e8fbea

Please sign in to comment.