jwallet-web-keystore
Advanced tools
Comparing version
@@ -87,3 +87,5 @@ 'use strict'; | ||
value: function removeAccounts(password) { | ||
this._checkPassword(password); | ||
if (password) { | ||
this._checkPassword(password); | ||
} | ||
@@ -90,0 +92,0 @@ this.accounts = []; |
{ | ||
"name": "jwallet-web-keystore", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "Library for ethereum blockchain accounts management", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -162,9 +162,9 @@ # jwallet-web-keystore | ||
#### removeAccounts(password) | ||
#### removeAccounts([password]) | ||
##### Parameters | ||
| Param | Type | Description | | ||
| --------- | ------ | ----------------- | | ||
| password | String | Keystore password | | ||
| Param | Type | Description | | ||
| --------- | ------ | -------------------------------------------- | | ||
| password | String | Keystore password. The parameter is optional | | ||
@@ -175,2 +175,4 @@ ##### Example | ||
keystore.removeAccounts('JHJ23jG^*DGHj667s') // all keystore accounts were removed | ||
keystore.removeAccounts('123') // failed, password is invalid | ||
keystore.removeAccounts() // ok, accounts were removed | ||
``` | ||
@@ -177,0 +179,0 @@ |
@@ -7,2 +7,3 @@ const should = require('should') | ||
const newPassword = 'Tw5E^g7djfd(29j' | ||
const invalidPassword = 'wrOng pa$$w0rd' | ||
const accountName = 'address account' | ||
@@ -192,3 +193,16 @@ const anotherAccountName = 'another address account' | ||
it('removeAccounts() should remove all accounts', function(done) { | ||
it('removeAccounts() should throw error (incorrect password)', function(done) { | ||
try { | ||
keystore.removeAccounts(invalidPassword) | ||
done(new Error('Exception not thrown')) | ||
} catch (e) { | ||
e.should.be.an.Object() | ||
e.message.should.be.equal('Password is incorrect') | ||
done() | ||
} | ||
}) | ||
it('removeAccounts() should remove all accounts (with password param)', function(done) { | ||
keystore.removeAccounts(newPassword) | ||
@@ -203,2 +217,25 @@ | ||
}) | ||
it('removeAccounts() should remove all accounts (without params)', function(done) { | ||
keystore.createAccount({ | ||
password, | ||
accountName, | ||
type: 'address', | ||
privateKey: privateKeyAddressPair.privateKey, | ||
}) | ||
const accountsBeforeRemove = keystore.getAccounts() | ||
accountsBeforeRemove.should.be.an.Array() | ||
accountsBeforeRemove.length.should.be.equal(1) | ||
keystore.removeAccounts() | ||
const accountsAfterRemove = keystore.getAccounts() | ||
accountsAfterRemove.should.be.an.Array() | ||
accountsAfterRemove.length.should.be.equal(0) | ||
done() | ||
}) | ||
}) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
82152
1.48%1637
1.8%494
0.41%0
-100%