New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jwallet-web-keystore

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwallet-web-keystore - npm Package Compare versions

Comparing version

to
0.5.0

4

lib/Keystore.js

@@ -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()
})
})