@ocap/wallet 1.18.8 → 1.18.9
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/index.d.ts +12 -12
- package/lib/index.js +2 -1
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { EncodingType, BytesType } from '@ocap/util';
|
3
3
|
import { DidType, DIDType, DIDTypeStr, DIDTypeArg } from '@arcblock/did';
|
4
|
-
declare type KeyPairType = {
|
5
|
-
sk?:
|
6
|
-
pk?:
|
4
|
+
declare type KeyPairType<T extends BytesType = string> = {
|
5
|
+
sk?: T;
|
6
|
+
pk?: T;
|
7
7
|
address?: string;
|
8
8
|
};
|
9
9
|
export declare type SerializedWallet = {
|
@@ -12,10 +12,10 @@ export declare type SerializedWallet = {
|
|
12
12
|
sk: string;
|
13
13
|
address: string;
|
14
14
|
};
|
15
|
-
export interface WalletObject {
|
15
|
+
export interface WalletObject<T extends BytesType = string> {
|
16
16
|
type: DIDType;
|
17
|
-
secretKey:
|
18
|
-
publicKey:
|
17
|
+
secretKey: T;
|
18
|
+
publicKey: T;
|
19
19
|
address: string;
|
20
20
|
hash(data: BytesType, round?: number, encoding?: 'hex'): string;
|
21
21
|
hash(data: BytesType, round?: number, encoding?: 'base16'): string;
|
@@ -45,7 +45,7 @@ export declare const WalletType: typeof DidType;
|
|
45
45
|
/**
|
46
46
|
* Generate an wallet instance that can be used to sign a message or verify a signature
|
47
47
|
*/
|
48
|
-
export declare function Wallet(keyPair: KeyPairType
|
48
|
+
export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
|
49
49
|
/**
|
50
50
|
* Generate a wallet from secretKey
|
51
51
|
*
|
@@ -64,25 +64,25 @@ export declare function Wallet(keyPair: KeyPairType, t?: DIDTypeArg): WalletObje
|
|
64
64
|
* assert.equal(signature, sig, "signature should match");
|
65
65
|
* assert.ok(wallet.verify(message, signature), "signature should be verified");
|
66
66
|
*/
|
67
|
-
export declare function fromSecretKey(sk:
|
67
|
+
export declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
|
68
68
|
/**
|
69
69
|
* Generate a wallet from publicKey
|
70
70
|
*/
|
71
|
-
export declare function fromPublicKey(pk:
|
71
|
+
export declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
|
72
72
|
/**
|
73
73
|
* Generate a wallet from address (did)
|
74
74
|
*
|
75
75
|
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
|
76
76
|
*/
|
77
|
-
export declare function fromAddress(address: string): WalletObject
|
77
|
+
export declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
|
78
78
|
/**
|
79
79
|
* Generate a wallet by generating a random secretKey
|
80
80
|
*/
|
81
|
-
export declare function fromRandom(_type?: DIDTypeArg): WalletObject
|
81
|
+
export declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
|
82
82
|
/**
|
83
83
|
* Generating a wallet from a serialized json presentation of another wallet
|
84
84
|
*/
|
85
|
-
export declare function fromJSON(json: SerializedWallet): WalletObject
|
85
|
+
export declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
|
86
86
|
/**
|
87
87
|
* Check if an object is valid wallet object
|
88
88
|
*/
|
package/lib/index.js
CHANGED
@@ -28,7 +28,7 @@ function Wallet(keyPair, t = 'default') {
|
|
28
28
|
}
|
29
29
|
if (hashBeforeSign) {
|
30
30
|
const hash = hasher(data, 1);
|
31
|
-
return signer.sign(hash, keyPair.sk);
|
31
|
+
return signer.sign(hash, keyPair.sk, encoding);
|
32
32
|
}
|
33
33
|
return signer.sign(data, keyPair.sk, encoding);
|
34
34
|
},
|
@@ -134,6 +134,7 @@ exports.fromRandom = fromRandom;
|
|
134
134
|
*/
|
135
135
|
function fromJSON(json) {
|
136
136
|
const type = did_1.DidType.fromJSON(json.type);
|
137
|
+
// @ts-ignore
|
137
138
|
return Wallet(json, type);
|
138
139
|
}
|
139
140
|
exports.fromJSON = fromJSON;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ocap/wallet",
|
3
|
-
"version": "1.18.
|
3
|
+
"version": "1.18.9",
|
4
4
|
"description": "Utility function to create and use an forge compatible crypto wallet",
|
5
5
|
"keywords": [
|
6
6
|
"crypto",
|
@@ -52,9 +52,9 @@
|
|
52
52
|
"url": "https://github.com/ArcBlock/asset-chain/issues"
|
53
53
|
},
|
54
54
|
"dependencies": {
|
55
|
-
"@arcblock/did": "1.18.
|
56
|
-
"@ocap/mcrypto": "1.18.
|
57
|
-
"@ocap/util": "1.18.
|
55
|
+
"@arcblock/did": "1.18.9",
|
56
|
+
"@ocap/mcrypto": "1.18.9",
|
57
|
+
"@ocap/util": "1.18.9"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "5e2aecc96fd09adfc96516f8bc99d7e4f2a57f5a"
|
60
60
|
}
|