@ocap/wallet 1.18.8 → 1.18.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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?: BytesType;
6
- pk?: BytesType;
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: BytesType;
18
- publicKey: BytesType;
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, t?: DIDTypeArg): WalletObject;
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: BytesType, _type?: DIDTypeArg): WalletObject;
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: BytesType, _type?: DIDTypeArg): WalletObject;
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.8",
3
+ "version": "1.18.10",
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.8",
56
- "@ocap/mcrypto": "1.18.8",
57
- "@ocap/util": "1.18.8"
55
+ "@arcblock/did": "1.18.10",
56
+ "@ocap/mcrypto": "1.18.10",
57
+ "@ocap/util": "1.18.10"
58
58
  },
59
- "gitHead": "8482e912fdeb7b52529f0add5632c62fc202d825"
59
+ "gitHead": "1c857951c380626c02c423d00a7b7e8c0a63faa2"
60
60
  }