@arcblock/forge-wallet
Advanced tools
Comparing version 0.26.0 to 0.26.10
// Generate by [js2dts@0.3.2](https://github.com/whxaxes/js2dts#readme) | ||
declare function fromSecretKey(sk: any, _type: any): _Lib.T102; | ||
declare function fromPublicKey(pk: any, _type: any): _Lib.T102; | ||
declare function fromRandom(_type: any): _Lib.T102; | ||
declare function fromAddress(address: any): _Lib.T102; | ||
declare function fromJSON(json: any): _Lib.T102; | ||
declare function Wallet(keyPair: any, type: any): _Lib.T102; | ||
declare function WalletType(type: any): _Lib.T103; | ||
declare const _Lib: _Lib.T104; | ||
/** | ||
* Generate a wallet from secretKey | ||
* | ||
* @public | ||
* @static | ||
* @param {string} sk - the secret key, `hex encoded string` | ||
* @param {WalletTypeObject} type - wallet type | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
* @example | ||
* const assert = require('assert'); | ||
* const { fromSecretKey } = require('@arcblock/forge-wallet'); | ||
* | ||
* const sk = | ||
* '0xD67C071B6F51D2B61180B9B1AA9BE0DD0704619F0E30453AB4A592B036EDE644E4852B7091317E3622068E62A5127D1FB0D4AE2FC50213295E10652D2F0ABFC7'; | ||
* const sig = | ||
* '0x08a102851c38c072e42756c1cc70938b5499c8e9358dfe5f383823f56cdb282ffda60fcd581a02c6c673069e5afc0bf09abbe3639b61b84d64fd58ef9f083003'; | ||
* | ||
* const wallet = fromSecretKey(sk, type); | ||
* const message = 'data to sign'; | ||
* const signature = wallet.sign(message); | ||
* assert.equal(signature, sig, "signature should match"); | ||
* assert.ok(wallet.verify(message, signature), "signature should be verified"); | ||
*/ | ||
declare function fromSecretKey(sk: string, _type: any): WalletObject; | ||
/** | ||
* Generate a wallet from publicKey | ||
* | ||
* @public | ||
* @static | ||
* @param {string} pk - the public key, `hex encoded string` | ||
* @param {WalletTypeObject} type - wallet type | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
*/ | ||
declare function fromPublicKey(pk: string, _type: any): WalletObject; | ||
/** | ||
* Generate a wallet by generating a random secretKey | ||
* | ||
* @public | ||
* @static | ||
* @param {WalletTypeObject} type - wallet type | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
* @example | ||
* const { fromRandom } = require('@arcblock/forge-wallet'); | ||
* const wallet = fromRandom(type); | ||
* // Do something with wallet | ||
*/ | ||
declare function fromRandom(_type: any): WalletObject; | ||
/** | ||
* Generate a wallet from address (did) | ||
* | ||
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying | ||
* | ||
* @public | ||
* @static | ||
* @param {string} address - the wallet address | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
* @example | ||
* const assert = require('assert'); | ||
* const { fromAddress } = require('@arcblock/forge-wallet'); | ||
* | ||
* const address = 'zNKtCNqYWLYWYW3gWRA1vnRykfCBZYHZvzKr'; | ||
* const wallet = fromAddress(address); | ||
* console.log(wallet.toJSON()); | ||
*/ | ||
declare function fromAddress(address: string): WalletObject; | ||
/** | ||
* Generating a wallet from a serialized json presentation of another wallet | ||
* | ||
* @public | ||
* @static | ||
* @param {object} json - json presentation of a wallet | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
* @example | ||
* const { fromJSON, fromRandom } = require('@arcblock/forge-wallet'); | ||
* const wallet = fromRandom(type); | ||
* const wallet2 = fromJSON(wallet.toJSON()); | ||
* // wallet2 is identical to wallet | ||
*/ | ||
declare function fromJSON(json: any): WalletObject; | ||
/** | ||
* @public | ||
* @static | ||
* @global | ||
* @name WalletObject | ||
* @typedef WalletObject | ||
* @prop {WalletTypeObject} type - Indicates the wallet type | ||
* @prop {secretKey} secretKey - Wallet secretKey | ||
* @prop {publicKey} publicKey - Wallet publicKey | ||
* @prop {function} sign - Sign `data`, data is hashed using the `HashType` defined in type before signing | ||
* @prop {function} verify - Verify `signature`, data is hashed using the `HashType` defined in type before verifying | ||
* @prop {function} toAddress - Get wallet address without `did:abt:` prefix | ||
* @prop {function} toJSON - Serialize wallet to json object, checkout {@link fromJSON} for deserialisation | ||
*/ | ||
/** | ||
* Generate an wallet instance that can be used to sign a message or verify a signature | ||
* | ||
* @public | ||
* @static | ||
* @param {object} keyPair - the key pair | ||
* @param {string} keyPair.sk - the secretKey | ||
* @param {string} keyPair.pk - the wallet publicKey | ||
* @param {WalletTypeObject} type - wallet type | ||
* @returns {WalletObject} wallet object that can be used to sign/verify/getAddress | ||
*/ | ||
declare function Wallet(keyPair: _Lib.T100, type: WalletTypeObject): WalletObject; | ||
/** | ||
* The structure of a forge wallet type | ||
* | ||
* @public | ||
* @static | ||
* @global | ||
* @typedef {Object} WalletTypeObject | ||
* @prop {number} role - Enum field to identify wallet role type | ||
* @prop {number} pk - Crypto algorithm to derive publicKey from the secretKey | ||
* @prop {number} hash - Hash algorithm used to hash data before sign them | ||
*/ | ||
/** | ||
* Create an wallet type object that be used as param to create a new wallet | ||
* | ||
* @public | ||
* @static | ||
* @param {WalletTypeObject} type | ||
* @returns {object} | ||
* @example | ||
* const assert = require('assert'); | ||
* const { WalletType } = require('@arcblock/forge-wallet'); | ||
* const { types } = require('@arcblock/mcrypto'); | ||
* | ||
* const type = WalletType({ | ||
* role: types.RoleType.ROLE_APPLICATION, | ||
* pk: types.KeyType.ED25519, | ||
* hash: types.HashType.SHA3, | ||
* }); | ||
*/ | ||
declare function WalletType(type: WalletTypeObject): any; | ||
declare const _Lib: _Lib.T102; | ||
declare namespace _Lib { | ||
export interface WalletTypeObject { | ||
role: number; | ||
pk: number; | ||
hash: number; | ||
} | ||
export interface WalletObject { | ||
type: WalletTypeObject; | ||
secretKey: any; | ||
publicKey: any; | ||
sign: (...args: any[]) => any; | ||
verify: (...args: any[]) => any; | ||
toAddress: (...args: any[]) => any; | ||
toJSON: (...args: any[]) => any; | ||
} | ||
export interface T100 { | ||
[key: string]: any; | ||
sk: string; | ||
pk: string; | ||
} | ||
export interface T101 { | ||
type: _Lib.T100; | ||
sk: any; | ||
pk: any; | ||
address: any; | ||
[key: string]: any; | ||
} | ||
export interface T102 { | ||
type: any; | ||
secretKey: any; | ||
publicKey: any; | ||
sign(data: any): any; | ||
verify(data: any, signature: any): any; | ||
toAddress(): any; | ||
toJSON(): _Lib.T101; | ||
} | ||
export interface T103 { | ||
role: any; | ||
pk: any; | ||
hash: any; | ||
address: number; | ||
} | ||
export interface T104 { | ||
fromSecretKey: typeof fromSecretKey; | ||
@@ -38,0 +165,0 @@ fromPublicKey: typeof fromPublicKey; |
{ | ||
"name": "@arcblock/forge-wallet", | ||
"version": "0.26.0", | ||
"version": "0.26.10", | ||
"description": "Utility function to create and use an forge compatible crypto wallet", | ||
@@ -36,2 +36,3 @@ "keywords": [ | ||
"generate-docs": "jsdoc2md lib/index.js > docs/README.md", | ||
"generate-dts": "j2d lib/index.js", | ||
"format-docs": "remark . -o", | ||
@@ -47,6 +48,6 @@ "precommit": "CI=1 yarn test", | ||
"dependencies": { | ||
"@arcblock/did": "^0.26.0", | ||
"@arcblock/mcrypto": "^0.26.0" | ||
"@arcblock/did": "^0.26.10", | ||
"@arcblock/mcrypto": "^0.26.10" | ||
}, | ||
"gitHead": "24cf584797dd865d86517a400d9b2c08c138e793" | ||
"gitHead": "c9300e0f82d22e20a0e32d3fb4beb761b6e37023" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16853
409
Updated@arcblock/did@^0.26.10
Updated@arcblock/mcrypto@^0.26.10