{"id":26357521,"url":"https://github.com/jibrelnetwork/jwallet-web-keystore","last_synced_at":"2025-03-16T14:16:57.432Z","repository":{"id":54133547,"uuid":"105136125","full_name":"jibrelnetwork/jwallet-web-keystore","owner":"jibrelnetwork","description":"Keystore manager for the jwallet web app","archived":false,"fork":false,"pushed_at":"2022-11-15T22:58:34.000Z","size":375,"stargazers_count":4,"open_issues_count":3,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-15T07:37:43.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jibrelnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-28T10:40:15.000Z","updated_at":"2021-09-10T09:28:13.000Z","dependencies_parsed_at":"2023-01-22T01:46:00.841Z","dependency_job_id":null,"html_url":"https://github.com/jibrelnetwork/jwallet-web-keystore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjwallet-web-keystore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjwallet-web-keystore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjwallet-web-keystore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jibrelnetwork%2Fjwallet-web-keystore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jibrelnetwork","download_url":"https://codeload.github.com/jibrelnetwork/jwallet-web-keystore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701307,"owners_count":20333616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-16T14:16:56.837Z","updated_at":"2025-03-16T14:16:57.413Z","avatar_url":"https://github.com/jibrelnetwork.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jwallet-web-keystore\n\nLibrary for ethereum blockchain wallets management.\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/jwallet-web-keystore\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/jwallet-web-keystore.svg?style=flat-square\" alt=\"NPM version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/jwallet-web-keystore\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/jwallet-web-keystore.svg?style=flat-square\" alt=\"NPM downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/jwallet-web-keystore\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/jwallet-web-keystore.svg?style=flat-square\" alt=\"MIT License\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/jwallet-web-keystore\"\u003e\u003cimg src=\"https://img.shields.io/david/jibrelnetwork/jwallet-web-keystore.svg?style=flat-square\" alt=\"Dependecies\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\nKeystore can hold `read only` / `full access` wallets of two types:\n* `privateKey` / `address`\n* `mnemonic` / `bip32XPublicKey`\n\nAlso Keystore API provides several [utility methods](#static-methods) for working with mnemonics / hashes / passwords.\n\n## Get Started\n\n```\nnpm install jwallet-web-keystore\n```\n\n```javascript\nconst Keystore = require('jwallet-web-keystore')\n\nconst keystore = new Keystore(props)\n```\n\n### Available npm scripts:\n\n  * `lint`: check code-style errors\n  * `test`: run mocha tests\n  * `clean`: clean `./lib` dir\n  * `compile`: `clean`, then compile library\n  * `build`: `lint` \u0026 `compile` \u0026 `test`\n\n### Wallet properties\n\n| Property             | Type    | Description                                               |\n| -------------------- | ------- | --------------------------------------------------------- |\n| id                   | String  | Unique ID of wallet                                       |\n| type                 | String  | Type of wallet  (`mnemonic` / `address`)                  |\n| name                 | String  | Wallet name                                               |\n| salt                 | String  | Salt for enforcing of password                            |\n| address              | String  | Address of wallet                                         |\n| customType           | String  | User-friendly type of wallet                              |\n| isReadOnly           | Boolean | Read-only flag of wallet                                  |\n| addressIndex         | Number  | Current index of address of `mnemonic` wallet             |\n| derivationPath       | String  | Derivation path for generating of addresses from mnemonic |\n| bip32XPublicKey      | String  | BIP32 Extended Public Key                                 |\n| encrypted            | Object  | Container of encrypted data                               |\n| encrypted.privateKey | Object  | Encrypted private key                                     |\n| encrypted.mnemonic   | Object  | Encrypted mnemonic                                        |\n\n**Notes:**\n  * `isReadOnly` - flag means that wallet can be used only for balance / transactions checking\n  * `bip32XPublicKey` - `xpub...` key that used for deriving of public keys (addresses)\n\n## Public API definitions\n\nSee [mocha tests](https://github.com/jibrelnetwork/jwallet-web-keystore/tree/master/test) for examples of usage.\n\n### new Keystore(props)\n\nInstantiates `Keystore` object with provided `props`.\n\n##### Parameters\n\n| Param                          | Type   | Default                    | Description                   |\n| ------------------------------ | ------ | -------------------------- | ----------------------------- |\n| props                          | Object | {}                         | Constructor properties        |\n| props.defaultDerivationPath    | String | \"m/44'/60'/0'/0\"           | Default derivation path for new `Mnemonic` wallets |\n| props.defaultEncryptionType    | String | 'nacl.secretbox'           | Default encryption type. Currently `nacl.secretbox` is only one supported |\n| props.paddedMnemonicLength     | Number | 120                        | Mnemonic will be padded left with this size before encryption |\n| props.saltByteCount            | Number | 32                         | Count of bytes of generated salt for password strength |\n| props.scryptParams             | Object | { N: 2 ** 18, r: 8, p: 1 } | Scrypt params for key deriving |\n| props.derivedKeyLength         | String | 32                         | Derived key length            |\n| props.passwordConfig           | Object | {}                         | Options to test password strength |\n\n##### Returns\n\nNew instance of `Keystore` class.\n\n##### Example\n\n```javascript\nconst keystore = new Keystore({ defaultDerivationPath: \"m/44'/61'/0'/0\" })\n```\n\n### Instance methods\n\n#### getWallets()\n\n##### Returns\n\nWallets list presented in keystore.\n\n##### Example\n\n```javascript\nconst wallets = keystore.getWallets()\n```\n\n#### getWallet(walletId)\n\n##### Parameters\n\nWallet ID.\n\n##### Returns\n\nWallet found by its ID.\n\n##### Example\n\n```javascript\nconst wallet = keystore.getWallet('JHJ23jG^*DGHj667s')\n```\n\n#### createWallet(props)\n\n##### Parameters\n\nwallet properties([Wallet properties](#wallet-properties)):\n* `type`\n* `name`\n* `address`\n* `mnemonic`\n* `isReadOnly`\n* `privateKey`\n* `derivationPath`\n* `bip32XPublicKey`\n\n##### Returns\n\nUnique ID of created wallet\n\n##### Example\n\n```javascript\nconst walletId = keystore.createWallet({\n  type: 'address',\n  name: 'My wallet',\n  isReadonly: false,\n  password: 'JHJ23jG^*DGHj667s',\n  privateKey: '0x8a02a99cc7a801da6996a2dacc406ffa5190dc9c8a02a99cc7a801da6996a2da',\n})\n```\n\n#### removeWallet(walletId)\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| walletId | String | Unique ID of wallet |\n\n##### Returns\n\nRemoved wallet data.\n\n##### Example\n\n```javascript\nconst removedWallet = keystore.removeWallet('110ec58a-a0f2-4ac4-8393-c977d813b8d1') // data\n```\n\n#### removeWallets()\n\n##### Example\n\n```javascript\nkeystore.removeWallets() // ok, wallets were removed\n```\n\n#### setWalletName(walletId, newName)\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| walletId | String | Unique ID of wallet |\n| newName  | String | New wallet name     |\n\n##### Returns\n\nUpdated wallet.\n\n##### Example\n\n```javascript\nconst updatedWallet = keystore.setWalletName('110ec58a-a0f2-4ac4-8393-c977d813b8d1', 'New wallet name')\n```\n\n#### getPrivateKey(password, walletId)\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| password | String | Wallet password     |\n| walletId | String | Unique ID of wallet |\n\n##### Returns\n\nDecrypted private key.\n\n##### Example\n\n```javascript\nconst privateKey = keystore.getPrivateKey('JHJ23jG^*DGHj667s', '110ec58a-a0f2-4ac4-8393-c977d813b8d1')\n```\n\n#### setDerivationPath(password, walletId, newDerivationPath)\n\n**Note: used only for `mnemonic` wallets.**\n\n##### Parameters\n\n| Param             | Type   | Description         |\n| ----------------- | ------ | ------------------- |\n| password          | String | Wallet password     |\n| walletId          | String | Unique ID of wallet |\n| newDerivationPath | String | New derivation path |\n\n**Note: default derivation path that will be assigned to all new created wallets can be managed by `defaultDerivationPath` constructor parameter.**\n\n##### Returns\n\nUpdated wallet.\n\n##### Example\n\n```javascript\nconst updatedWallet = keystore.setDerivationPath('JHJ23jG^*DGHj667s', '110ec58a-a0f2-4ac4-8393-c977d813b8d1', \"m/44'/61'/0'/0\")\n```\n\n#### getMnemonic(password, walletId)\n\n**Note: used only for `mnemonic` wallets.**\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| password | String | Wallet password     |\n| walletId | String | Unique ID of wallet |\n\n##### Returns\n\nDecrypted mnemonic.\n\n##### Example\n\n```javascript\nconst mnemonic = keystore.getMnemonic('JHJ23jG^*DGHj667s', '110ec58a-a0f2-4ac4-8393-c977d813b8d1')\n```\n\n#### getAddressesFromMnemonic(walletId, iteration, limit)\n\n**Note: used only for `mnemonic` wallets.**\n\n##### Parameters\n\n| Param     | Type   | Description                                                              |\n| --------- | ------ | ------------------------------------------------------------------------ |\n| walletId  | String | Unique ID of wallet                                                      |\n| iteration | Number | Iteration index (aka page for pagination) to generate bunch of addresses |\n| limit     | Number | Count of addresses to generate from mnemonic per one page / iteration    |\n\n##### Returns\n\nList of generated addresses.\n\n##### Example\n\n```javascript\nconst addresses = keystore.getAddressesFromMnemonic('110ec58a-a0f2-4ac4-8393-c977d813b8d1', 3, 10)\n```\n\n#### getAddress(walletId, addressIndex)\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| walletId | String | Unique ID of wallet |\n\n##### Returns\n\nCurrent address of wallet.\n\n##### Example\n\n```javascript\nconst address = keystore.getAddress('110ec58a-a0f2-4ac4-8393-c977d813b8d1')\n```\n\n#### setAddressIndex(walletId, addressIndex)\n\n**Note: used only for `mnemonic` wallets.**\n\n##### Parameters\n\n| Param        | Type   | Description                                                    |\n| ------------ | ------ | -------------------------------------------------------------- |\n| walletId     | String | Unique ID of wallet                                            |\n| addressIndex | String | Index of address to derive from `mnemonic` / `bip32XPublicKey` |\n\n##### Returns\n\nUpdated wallet.\n\n##### Example\n\n```javascript\nconst updatedWallet = keystore.setAddress('110ec58a-a0f2-4ac4-8393-c977d813b8d1', 5)\n```\n\n#### serialize()\n\n##### Returns\n\nSerialized keystore data for backup.\n\n##### Example\n\n```javascript\nconst keystoreSerializedData = keystore.serialize()\n```\n\n#### deserialize(backupData)\n\n##### Parameters\n\n| Param      | Type   | Description              |\n| ---------- | ------ | ------------------------ |\n| backupData | String | Keystore serialized data |\n\n##### Example\n\n```javascript\nconst backupData = '{\"wallets\":[{\"type\":\"mnemonic\",\"id\":\"2e820ddb-a9ce-43e1-b7ec-dbed59eec7e9\",...'\nkeystore.deserialize(backupData)\n```\n\n#### getDecryptedWallet(password, walletId)\n\n##### Parameters\n\n| Param    | Type   | Description         |\n| -------- | ------ | ------------------- |\n| password | String | Wallet password     |\n| walletId | String | Unique ID of wallet |\n\n#### Returns\n\nWallet with decrypted data.\n\n##### Example\n\n```javascript\nconst decryptedWallet = keystore.getDecryptedWallets('JHJ23jG^*DGHj667s', '110ec58a-a0f2-4ac4-8393-c977d813b8d1')\n```\n\n#### setPassword(password, newPassword, walletId)\n\n##### Parameters\n\n| Param       | Type   | Description           |\n| ----------- | ------ | --------------------- |\n| password    | String | Wallet password       |\n| newPassword | String | New keystore password |\n| walletId    | String | Unique ID of wallet   |\n\n##### Example\n\n```javascript\nkeystore.setPassword('JHJ23jG^*DGHj667s', 'Tw5E^g7djfd(29j', '110ec58a-a0f2-4ac4-8393-c977d813b8d1')\n```\n\n### Static methods\n\n#### generateMnemonic(entropy, randomBufferLength)\n\n| Param               | Type   | Description                                         |\n| ------------------- | ------ | --------------------------------------------------- |\n| entropy             | String | Entropy for mnemonic initialisation (see [new Mnemonic](https://bitcore.io/api/mnemonic#new_Mnemonic_new)) |\n| randomBufferLength  | Number | Buffer length (if `entropy` param is used) |\n\n##### Returns\n\nMnemonic - 12 English words splited by space.\n\n##### Example\n\n```javascript\nconst mnemonic = Keystore.generateMnemonic()\n```\n\n#### isMnemonicValid(mnemonic)\n\n##### Parameters\n\n| Param    | Type   | Description       |\n| -------- | ------ | ----------------- |\n| mnemonic | String | Mnemonic to check |\n\n##### Returns\n\n`true` if mnemonic is valid and `false` otherwise.\n\n##### Example\n\n```javascript\nconst mnemonic = 'come average primary sunny profit eager toy pulp struggle hazard tourist round'\nconst isValid = Keystore.isMnemonicValid(mnemonic) // true\n```\n\n#### isBip32XPublicKeyValid(bip32XPublicKey)\n\n| Param           | Type   | Description               |\n| --------------- | ------ | ------------------------- |\n| bip32XPublicKey | String | BIP32 Extended Public Key |\n\n##### Returns\n\n`true` if bip32XPublicKey is valid and `false` otherwise.\n\n##### Example\n\n```javascript\nconst isValid = Keystore.isBip32XPublicKeyValid('xpub...')\n```\n\n#### isAddressValid(address)\n\n| Param     | Type   | Description                                         |\n| --------- | ------ | --------------------------------------------------- |\n| address   | String | Address to check. Accepts checksummed addresses too |\n\n##### Returns\n\n`true` if address is valid and `false` otherwise.\n\n##### Example\n\n```javascript\nconst isValid = Keystore.isAddressValid('0x8a02a99ee7a801da6996a2dacc406ffa5190dc9c')\n```\n\n#### isPrivateKeyValid(privateKey)\n\n| Param      | Type   | Description          |\n| ---------- | ------ | -------------------- |\n| privateKey | String | Private Key to check |\n\n##### Returns\n\n`true` if privateKey is valid and `false` otherwise.\n\n##### Example\n\n```javascript\nconst pk = '0xa7fcb4efc392d2c8983cbfe64063f994f85120e60843407af95907d905d0dc9f'\nconst isValid = Keystore.isPrivateKeyValid(pk)\n```\n\n#### isDerivationPathValid(derivationPath)\n\n| Param          | Type   | Description     |\n| -------------- | ------ | --------------- |\n| derivationPath | String | Derivation path |\n\n##### Returns\n\n`true` if derivationPath is valid and `false` otherwise.\n\n##### Example\n\n```javascript\nconst isValid = Keystore.isDerivationPathValid(\"m/44'/60'/0'/0\")\n```\n\n#### testPassword(password, passwordConfig)\n\n| Param                    | Type   | Default | Description                |\n| ------------------------ | ------ | ------- | -------------------------- |\n| password                 | String |         | Wallet password            |\n| passwordConfig           | Object | {}      | Password options container |\n| passwordConfig.minLength | Number | 10      | Min length for password    |\n| passwordConfig.minLength | Number | 128     | Max length for password    |\n\n##### Returns\n\nObject that contains following fields:\n\n  * errors - error messages array\n  * failedTests - failed test names array\n  * passedTests - passed test names array\n\n##### Example\n\n```javascript\nconst result = Keystore.testPassword('JHJ23jG^*DGHj667s')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibrelnetwork%2Fjwallet-web-keystore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjibrelnetwork%2Fjwallet-web-keystore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjibrelnetwork%2Fjwallet-web-keystore/lists"}