@ocap/wallet 1.27.15 → 1.28.0
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/esm/index.d.ts +52 -49
- package/esm/index.js +129 -158
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/index.d.ts +52 -49
- package/lib/index.js +135 -188
- package/package.json +23 -12
package/esm/index.d.ts
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BytesType, EncodingType } from "@ocap/util";
|
|
2
|
+
import { DIDType, DIDTypeArg, DIDTypeStr, DidType } from "@arcblock/did";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
3
5
|
type KeyPairType<T extends BytesType = string> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
sk?: T;
|
|
7
|
+
pk?: T;
|
|
8
|
+
address?: string;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
type SerializedWallet = {
|
|
11
|
+
type: DIDTypeStr;
|
|
12
|
+
pk: string;
|
|
13
|
+
sk: string;
|
|
14
|
+
address: string;
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
interface WalletObject<T extends BytesType = string> {
|
|
17
|
+
type: DIDType;
|
|
18
|
+
secretKey: T;
|
|
19
|
+
publicKey: T;
|
|
20
|
+
address: string;
|
|
21
|
+
hash(data: BytesType, round?: number, encoding?: 'hex'): string;
|
|
22
|
+
hash(data: BytesType, round?: number, encoding?: 'base16'): string;
|
|
23
|
+
hash(data: BytesType, round?: number, encoding?: 'base58'): string;
|
|
24
|
+
hash(data: BytesType, round?: number, encoding?: 'base64'): string;
|
|
25
|
+
hash(data: BytesType, round?: number, encoding?: 'buffer'): Buffer;
|
|
26
|
+
hash(data: BytesType, round?: number, encoding?: 'Uint8Array'): Uint8Array;
|
|
27
|
+
hash(data: BytesType, round?: number, encoding?: EncodingType): BytesType;
|
|
28
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'hex'): Promise<string>;
|
|
29
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base16'): Promise<string>;
|
|
30
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base58'): Promise<string>;
|
|
31
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base64'): Promise<string>;
|
|
32
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'buffer'): Promise<Buffer>;
|
|
33
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'Uint8Array'): Promise<Uint8Array>;
|
|
34
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: EncodingType): Promise<BytesType>;
|
|
35
|
+
verify(data: BytesType, signature: BytesType, hashBeforeVerify?: boolean, extra?: any): Promise<boolean>;
|
|
36
|
+
ethHash(data: string): string;
|
|
37
|
+
ethSign(data: string, hashBeforeSign?: boolean): Promise<string>;
|
|
38
|
+
ethVerify(data: string, signature: string, hashBeforeVerify?: boolean): Promise<boolean>;
|
|
39
|
+
signETH(data: string, hashBeforeSign?: boolean): Promise<string>;
|
|
40
|
+
signJWT(payload?: any, doSign?: boolean, version?: string): Promise<string>;
|
|
41
|
+
toJSON(): SerializedWallet;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated ES6: use `wallet.address` instead
|
|
44
|
+
*/
|
|
45
|
+
toAddress(): string;
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
declare const WalletType: typeof DidType;
|
|
46
48
|
/**
|
|
47
49
|
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
48
50
|
*/
|
|
49
|
-
|
|
51
|
+
declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
|
|
50
52
|
/**
|
|
51
53
|
* Generate a wallet from secretKey
|
|
52
54
|
*
|
|
@@ -65,27 +67,28 @@ export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairTyp
|
|
|
65
67
|
* assert.equal(signature, sig, "signature should match");
|
|
66
68
|
* assert.ok(wallet.verify(message, signature), "signature should be verified");
|
|
67
69
|
*/
|
|
68
|
-
|
|
70
|
+
declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
|
|
69
71
|
/**
|
|
70
72
|
* Generate a wallet from publicKey
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
|
|
73
75
|
/**
|
|
74
76
|
* Generate a wallet from address (did)
|
|
75
77
|
*
|
|
76
78
|
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
|
|
77
79
|
*/
|
|
78
|
-
|
|
80
|
+
declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
|
|
79
81
|
/**
|
|
80
82
|
* Generate a wallet by generating a random secretKey
|
|
81
83
|
*/
|
|
82
|
-
|
|
84
|
+
declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
|
|
83
85
|
/**
|
|
84
86
|
* Generating a wallet from a serialized json presentation of another wallet
|
|
85
87
|
*/
|
|
86
|
-
|
|
88
|
+
declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
|
|
87
89
|
/**
|
|
88
90
|
* Check if an object is valid wallet object
|
|
89
91
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { SerializedWallet, Wallet, WalletObject, WalletType, fromAddress, fromJSON, fromPublicKey, fromRandom, fromSecretKey, isValid };
|
package/esm/index.js
CHANGED
|
@@ -1,172 +1,143 @@
|
|
|
1
|
-
import { toHex } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as JWT from
|
|
5
|
-
|
|
1
|
+
import { toHex } from "@ocap/util";
|
|
2
|
+
import { getHasher, getSigner } from "@ocap/mcrypto";
|
|
3
|
+
import { DidType, fromPublicKey as fromPublicKey$1, toAddress, toTypeInfo } from "@arcblock/did";
|
|
4
|
+
import * as JWT from "@arcblock/jwt";
|
|
5
|
+
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const WalletType = DidType;
|
|
6
8
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
70
|
-
return signer.ethRecover(hash, signature) === this.address;
|
|
71
|
-
},
|
|
72
|
-
// eslint-disable-next-line require-await
|
|
73
|
-
async signJWT(payload = {}, doSign = true, version = '1.0.0') {
|
|
74
|
-
if (!keyPair.sk) {
|
|
75
|
-
throw new Error('Cannot sign JWT without a secretKey');
|
|
76
|
-
}
|
|
77
|
-
return JWT.sign(this.address, keyPair.sk, payload, doSign, version);
|
|
78
|
-
},
|
|
79
|
-
// deprecated
|
|
80
|
-
toAddress() {
|
|
81
|
-
return keyPair.pk ? DIDFromPublicKey(keyPair.pk, type) : keyPair.address;
|
|
82
|
-
},
|
|
83
|
-
toJSON() {
|
|
84
|
-
return {
|
|
85
|
-
type: DidType.toJSON(type),
|
|
86
|
-
sk: toHex(keyPair.sk),
|
|
87
|
-
pk: toHex(keyPair.pk),
|
|
88
|
-
address: this.address,
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
};
|
|
9
|
+
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
10
|
+
*/
|
|
11
|
+
function Wallet(keyPair, t = "default") {
|
|
12
|
+
const type = DidType(t);
|
|
13
|
+
const signer = getSigner(type.pk);
|
|
14
|
+
const hasher = getHasher(type.hash);
|
|
15
|
+
return {
|
|
16
|
+
type,
|
|
17
|
+
secretKey: keyPair.sk,
|
|
18
|
+
publicKey: keyPair.pk,
|
|
19
|
+
address: keyPair.pk ? fromPublicKey$1(keyPair.pk, type) : keyPair.address,
|
|
20
|
+
hash(data, round = 1, encoding = "hex") {
|
|
21
|
+
return hasher(data, round, encoding);
|
|
22
|
+
},
|
|
23
|
+
async sign(data, hashBeforeSign = true, encoding = "hex") {
|
|
24
|
+
if (!keyPair.sk) throw new Error("Cannot sign data without a secretKey");
|
|
25
|
+
if (hashBeforeSign) {
|
|
26
|
+
const hash = hasher(data, 1);
|
|
27
|
+
return signer.sign(hash, keyPair.sk, encoding);
|
|
28
|
+
}
|
|
29
|
+
return signer.sign(data, keyPair.sk, encoding);
|
|
30
|
+
},
|
|
31
|
+
async verify(data, signature, hashBeforeVerify = true, extra) {
|
|
32
|
+
if (!keyPair.pk) throw new Error("Cannot verify data without a publicKey");
|
|
33
|
+
const hash = hashBeforeVerify ? hasher(data, 1) : data;
|
|
34
|
+
return signer.verify(hash, signature, keyPair.pk, extra);
|
|
35
|
+
},
|
|
36
|
+
ethHash(data) {
|
|
37
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethHash is not supported by signer");
|
|
38
|
+
return signer.ethHash(data);
|
|
39
|
+
},
|
|
40
|
+
async signETH(data, hashBeforeSign = true) {
|
|
41
|
+
if (!keyPair.sk) throw new Error("Cannot sign data without a secretKey");
|
|
42
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethSign is not supported by signer");
|
|
43
|
+
if (hashBeforeSign) return signer.ethSign(signer.ethHash(data), toHex(keyPair.sk));
|
|
44
|
+
return signer.ethSign(data, toHex(keyPair.sk));
|
|
45
|
+
},
|
|
46
|
+
ethSign(data, hashBeforeSign = true) {
|
|
47
|
+
return this.signETH(data, hashBeforeSign);
|
|
48
|
+
},
|
|
49
|
+
async ethVerify(data, signature, hashBeforeVerify = true) {
|
|
50
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethVerify is not supported by signer");
|
|
51
|
+
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
52
|
+
return signer.ethRecover(hash, signature) === this.address;
|
|
53
|
+
},
|
|
54
|
+
async signJWT(payload = {}, doSign = true, version = "1.0.0") {
|
|
55
|
+
if (!keyPair.sk) throw new Error("Cannot sign JWT without a secretKey");
|
|
56
|
+
return JWT.sign(this.address, keyPair.sk, payload, doSign, version);
|
|
57
|
+
},
|
|
58
|
+
toAddress() {
|
|
59
|
+
return keyPair.pk ? fromPublicKey$1(keyPair.pk, type) : keyPair.address;
|
|
60
|
+
},
|
|
61
|
+
toJSON() {
|
|
62
|
+
return {
|
|
63
|
+
type: DidType.toJSON(type),
|
|
64
|
+
sk: toHex(keyPair.sk),
|
|
65
|
+
pk: toHex(keyPair.pk),
|
|
66
|
+
address: this.address
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
92
70
|
}
|
|
93
71
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
72
|
+
* Generate a wallet from secretKey
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const assert = require('assert');
|
|
76
|
+
* const { fromSecretKey } = require('@ocap/wallet');
|
|
77
|
+
*
|
|
78
|
+
* const sk =
|
|
79
|
+
* '0xD67C071B6F51D2B61180B9B1AA9BE0DD0704619F0E30453AB4A592B036EDE644E4852B7091317E3622068E62A5127D1FB0D4AE2FC50213295E10652D2F0ABFC7';
|
|
80
|
+
* const sig =
|
|
81
|
+
* '0x08a102851c38c072e42756c1cc70938b5499c8e9358dfe5f383823f56cdb282ffda60fcd581a02c6c673069e5afc0bf09abbe3639b61b84d64fd58ef9f083003';
|
|
82
|
+
*
|
|
83
|
+
* const wallet = fromSecretKey(sk, type);
|
|
84
|
+
* const message = 'data to sign';
|
|
85
|
+
* const signature = wallet.sign(message);
|
|
86
|
+
* assert.equal(signature, sig, "signature should match");
|
|
87
|
+
* assert.ok(wallet.verify(message, signature), "signature should be verified");
|
|
88
|
+
*/
|
|
89
|
+
function fromSecretKey(sk, _type = "default") {
|
|
90
|
+
const type = DidType(_type);
|
|
91
|
+
return Wallet({
|
|
92
|
+
sk,
|
|
93
|
+
pk: getSigner(type.pk).getPublicKey(sk)
|
|
94
|
+
}, type);
|
|
115
95
|
}
|
|
116
96
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
97
|
+
* Generate a wallet from publicKey
|
|
98
|
+
*/
|
|
99
|
+
function fromPublicKey(pk, _type = "default") {
|
|
100
|
+
return Wallet({ pk }, DidType(_type));
|
|
121
101
|
}
|
|
122
102
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
103
|
+
* Generate a wallet from address (did)
|
|
104
|
+
*
|
|
105
|
+
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
|
|
106
|
+
*/
|
|
107
|
+
function fromAddress(address) {
|
|
108
|
+
return Wallet({ address: toAddress(address) }, toTypeInfo(address));
|
|
129
109
|
}
|
|
130
110
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
111
|
+
* Generate a wallet by generating a random secretKey
|
|
112
|
+
*/
|
|
113
|
+
function fromRandom(_type = "default") {
|
|
114
|
+
const type = DidType(_type);
|
|
115
|
+
const keyPair = getSigner(type.pk).genKeyPair();
|
|
116
|
+
return Wallet({
|
|
117
|
+
sk: keyPair.secretKey,
|
|
118
|
+
pk: keyPair.publicKey
|
|
119
|
+
}, type);
|
|
138
120
|
}
|
|
139
121
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// @ts-ignore
|
|
145
|
-
return Wallet(json, type);
|
|
122
|
+
* Generating a wallet from a serialized json presentation of another wallet
|
|
123
|
+
*/
|
|
124
|
+
function fromJSON(json) {
|
|
125
|
+
return Wallet(json, DidType.fromJSON(json.type));
|
|
146
126
|
}
|
|
147
127
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (typeof wallet.toJSON !== 'function') {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
if (!wallet.type || !wallet.publicKey) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
if (canSign) {
|
|
167
|
-
if (typeof wallet.sign !== 'function') {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return true;
|
|
128
|
+
* Check if an object is valid wallet object
|
|
129
|
+
*/
|
|
130
|
+
function isValid(wallet, canSign = true) {
|
|
131
|
+
if (!wallet || typeof wallet !== "object") return false;
|
|
132
|
+
if (typeof wallet.verify !== "function") return false;
|
|
133
|
+
if (typeof wallet.toAddress !== "function") return false;
|
|
134
|
+
if (typeof wallet.toJSON !== "function") return false;
|
|
135
|
+
if (!wallet.type || !wallet.publicKey) return false;
|
|
136
|
+
if (canSign) {
|
|
137
|
+
if (typeof wallet.sign !== "function") return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
172
140
|
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
export { Wallet, WalletType, fromAddress, fromJSON, fromPublicKey, fromRandom, fromSecretKey, isValid };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BytesType, EncodingType } from "@ocap/util";
|
|
2
|
+
import { DIDType, DIDTypeArg, DIDTypeStr, DidType } from "@arcblock/did";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
3
5
|
type KeyPairType<T extends BytesType = string> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
sk?: T;
|
|
7
|
+
pk?: T;
|
|
8
|
+
address?: string;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
type SerializedWallet = {
|
|
11
|
+
type: DIDTypeStr;
|
|
12
|
+
pk: string;
|
|
13
|
+
sk: string;
|
|
14
|
+
address: string;
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
interface WalletObject<T extends BytesType = string> {
|
|
17
|
+
type: DIDType;
|
|
18
|
+
secretKey: T;
|
|
19
|
+
publicKey: T;
|
|
20
|
+
address: string;
|
|
21
|
+
hash(data: BytesType, round?: number, encoding?: 'hex'): string;
|
|
22
|
+
hash(data: BytesType, round?: number, encoding?: 'base16'): string;
|
|
23
|
+
hash(data: BytesType, round?: number, encoding?: 'base58'): string;
|
|
24
|
+
hash(data: BytesType, round?: number, encoding?: 'base64'): string;
|
|
25
|
+
hash(data: BytesType, round?: number, encoding?: 'buffer'): Buffer;
|
|
26
|
+
hash(data: BytesType, round?: number, encoding?: 'Uint8Array'): Uint8Array;
|
|
27
|
+
hash(data: BytesType, round?: number, encoding?: EncodingType): BytesType;
|
|
28
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'hex'): Promise<string>;
|
|
29
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base16'): Promise<string>;
|
|
30
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base58'): Promise<string>;
|
|
31
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base64'): Promise<string>;
|
|
32
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'buffer'): Promise<Buffer>;
|
|
33
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'Uint8Array'): Promise<Uint8Array>;
|
|
34
|
+
sign(data: BytesType, hashBeforeSign?: boolean, encoding?: EncodingType): Promise<BytesType>;
|
|
35
|
+
verify(data: BytesType, signature: BytesType, hashBeforeVerify?: boolean, extra?: any): Promise<boolean>;
|
|
36
|
+
ethHash(data: string): string;
|
|
37
|
+
ethSign(data: string, hashBeforeSign?: boolean): Promise<string>;
|
|
38
|
+
ethVerify(data: string, signature: string, hashBeforeVerify?: boolean): Promise<boolean>;
|
|
39
|
+
signETH(data: string, hashBeforeSign?: boolean): Promise<string>;
|
|
40
|
+
signJWT(payload?: any, doSign?: boolean, version?: string): Promise<string>;
|
|
41
|
+
toJSON(): SerializedWallet;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated ES6: use `wallet.address` instead
|
|
44
|
+
*/
|
|
45
|
+
toAddress(): string;
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
declare const WalletType: typeof DidType;
|
|
46
48
|
/**
|
|
47
49
|
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
48
50
|
*/
|
|
49
|
-
|
|
51
|
+
declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
|
|
50
52
|
/**
|
|
51
53
|
* Generate a wallet from secretKey
|
|
52
54
|
*
|
|
@@ -65,27 +67,28 @@ export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairTyp
|
|
|
65
67
|
* assert.equal(signature, sig, "signature should match");
|
|
66
68
|
* assert.ok(wallet.verify(message, signature), "signature should be verified");
|
|
67
69
|
*/
|
|
68
|
-
|
|
70
|
+
declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
|
|
69
71
|
/**
|
|
70
72
|
* Generate a wallet from publicKey
|
|
71
73
|
*/
|
|
72
|
-
|
|
74
|
+
declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
|
|
73
75
|
/**
|
|
74
76
|
* Generate a wallet from address (did)
|
|
75
77
|
*
|
|
76
78
|
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
|
|
77
79
|
*/
|
|
78
|
-
|
|
80
|
+
declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
|
|
79
81
|
/**
|
|
80
82
|
* Generate a wallet by generating a random secretKey
|
|
81
83
|
*/
|
|
82
|
-
|
|
84
|
+
declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
|
|
83
85
|
/**
|
|
84
86
|
* Generating a wallet from a serialized json presentation of another wallet
|
|
85
87
|
*/
|
|
86
|
-
|
|
88
|
+
declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
|
|
87
89
|
/**
|
|
88
90
|
* Check if an object is valid wallet object
|
|
89
91
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { SerializedWallet, Wallet, WalletObject, WalletType, fromAddress, fromJSON, fromPublicKey, fromRandom, fromSecretKey, isValid };
|
package/lib/index.js
CHANGED
|
@@ -1,205 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.WalletType = void 0;
|
|
27
|
-
exports.Wallet = Wallet;
|
|
28
|
-
exports.fromSecretKey = fromSecretKey;
|
|
29
|
-
exports.fromPublicKey = fromPublicKey;
|
|
30
|
-
exports.fromAddress = fromAddress;
|
|
31
|
-
exports.fromRandom = fromRandom;
|
|
32
|
-
exports.fromJSON = fromJSON;
|
|
33
|
-
exports.isValid = isValid;
|
|
34
|
-
const util_1 = require("@ocap/util");
|
|
35
|
-
const mcrypto_1 = require("@ocap/mcrypto");
|
|
36
|
-
const did_1 = require("@arcblock/did");
|
|
37
|
-
const JWT = __importStar(require("@arcblock/jwt"));
|
|
38
|
-
exports.WalletType = did_1.DidType;
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
let _ocap_util = require("@ocap/util");
|
|
3
|
+
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
4
|
+
let _arcblock_did = require("@arcblock/did");
|
|
5
|
+
let _arcblock_jwt = require("@arcblock/jwt");
|
|
6
|
+
_arcblock_jwt = require_rolldown_runtime.__toESM(_arcblock_jwt);
|
|
7
|
+
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
const WalletType = _arcblock_did.DidType;
|
|
39
10
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function Wallet(keyPair, t =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
103
|
-
return signer.ethRecover(hash, signature) === this.address;
|
|
104
|
-
},
|
|
105
|
-
// eslint-disable-next-line require-await
|
|
106
|
-
async signJWT(payload = {}, doSign = true, version = '1.0.0') {
|
|
107
|
-
if (!keyPair.sk) {
|
|
108
|
-
throw new Error('Cannot sign JWT without a secretKey');
|
|
109
|
-
}
|
|
110
|
-
return JWT.sign(this.address, keyPair.sk, payload, doSign, version);
|
|
111
|
-
},
|
|
112
|
-
// deprecated
|
|
113
|
-
toAddress() {
|
|
114
|
-
return keyPair.pk ? (0, did_1.fromPublicKey)(keyPair.pk, type) : keyPair.address;
|
|
115
|
-
},
|
|
116
|
-
toJSON() {
|
|
117
|
-
return {
|
|
118
|
-
type: did_1.DidType.toJSON(type),
|
|
119
|
-
sk: (0, util_1.toHex)(keyPair.sk),
|
|
120
|
-
pk: (0, util_1.toHex)(keyPair.pk),
|
|
121
|
-
address: this.address,
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
};
|
|
11
|
+
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
12
|
+
*/
|
|
13
|
+
function Wallet(keyPair, t = "default") {
|
|
14
|
+
const type = (0, _arcblock_did.DidType)(t);
|
|
15
|
+
const signer = (0, _ocap_mcrypto.getSigner)(type.pk);
|
|
16
|
+
const hasher = (0, _ocap_mcrypto.getHasher)(type.hash);
|
|
17
|
+
return {
|
|
18
|
+
type,
|
|
19
|
+
secretKey: keyPair.sk,
|
|
20
|
+
publicKey: keyPair.pk,
|
|
21
|
+
address: keyPair.pk ? (0, _arcblock_did.fromPublicKey)(keyPair.pk, type) : keyPair.address,
|
|
22
|
+
hash(data, round = 1, encoding = "hex") {
|
|
23
|
+
return hasher(data, round, encoding);
|
|
24
|
+
},
|
|
25
|
+
async sign(data, hashBeforeSign = true, encoding = "hex") {
|
|
26
|
+
if (!keyPair.sk) throw new Error("Cannot sign data without a secretKey");
|
|
27
|
+
if (hashBeforeSign) {
|
|
28
|
+
const hash = hasher(data, 1);
|
|
29
|
+
return signer.sign(hash, keyPair.sk, encoding);
|
|
30
|
+
}
|
|
31
|
+
return signer.sign(data, keyPair.sk, encoding);
|
|
32
|
+
},
|
|
33
|
+
async verify(data, signature, hashBeforeVerify = true, extra) {
|
|
34
|
+
if (!keyPair.pk) throw new Error("Cannot verify data without a publicKey");
|
|
35
|
+
const hash = hashBeforeVerify ? hasher(data, 1) : data;
|
|
36
|
+
return signer.verify(hash, signature, keyPair.pk, extra);
|
|
37
|
+
},
|
|
38
|
+
ethHash(data) {
|
|
39
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethHash is not supported by signer");
|
|
40
|
+
return signer.ethHash(data);
|
|
41
|
+
},
|
|
42
|
+
async signETH(data, hashBeforeSign = true) {
|
|
43
|
+
if (!keyPair.sk) throw new Error("Cannot sign data without a secretKey");
|
|
44
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethSign is not supported by signer");
|
|
45
|
+
if (hashBeforeSign) return signer.ethSign(signer.ethHash(data), (0, _ocap_util.toHex)(keyPair.sk));
|
|
46
|
+
return signer.ethSign(data, (0, _ocap_util.toHex)(keyPair.sk));
|
|
47
|
+
},
|
|
48
|
+
ethSign(data, hashBeforeSign = true) {
|
|
49
|
+
return this.signETH(data, hashBeforeSign);
|
|
50
|
+
},
|
|
51
|
+
async ethVerify(data, signature, hashBeforeVerify = true) {
|
|
52
|
+
if (typeof signer.ethHash !== "function") throw new Error("ethVerify is not supported by signer");
|
|
53
|
+
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
54
|
+
return signer.ethRecover(hash, signature) === this.address;
|
|
55
|
+
},
|
|
56
|
+
async signJWT(payload = {}, doSign = true, version = "1.0.0") {
|
|
57
|
+
if (!keyPair.sk) throw new Error("Cannot sign JWT without a secretKey");
|
|
58
|
+
return _arcblock_jwt.sign(this.address, keyPair.sk, payload, doSign, version);
|
|
59
|
+
},
|
|
60
|
+
toAddress() {
|
|
61
|
+
return keyPair.pk ? (0, _arcblock_did.fromPublicKey)(keyPair.pk, type) : keyPair.address;
|
|
62
|
+
},
|
|
63
|
+
toJSON() {
|
|
64
|
+
return {
|
|
65
|
+
type: _arcblock_did.DidType.toJSON(type),
|
|
66
|
+
sk: (0, _ocap_util.toHex)(keyPair.sk),
|
|
67
|
+
pk: (0, _ocap_util.toHex)(keyPair.pk),
|
|
68
|
+
address: this.address
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
125
72
|
}
|
|
126
73
|
/**
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
function fromSecretKey(sk, _type =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
74
|
+
* Generate a wallet from secretKey
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const assert = require('assert');
|
|
78
|
+
* const { fromSecretKey } = require('@ocap/wallet');
|
|
79
|
+
*
|
|
80
|
+
* const sk =
|
|
81
|
+
* '0xD67C071B6F51D2B61180B9B1AA9BE0DD0704619F0E30453AB4A592B036EDE644E4852B7091317E3622068E62A5127D1FB0D4AE2FC50213295E10652D2F0ABFC7';
|
|
82
|
+
* const sig =
|
|
83
|
+
* '0x08a102851c38c072e42756c1cc70938b5499c8e9358dfe5f383823f56cdb282ffda60fcd581a02c6c673069e5afc0bf09abbe3639b61b84d64fd58ef9f083003';
|
|
84
|
+
*
|
|
85
|
+
* const wallet = fromSecretKey(sk, type);
|
|
86
|
+
* const message = 'data to sign';
|
|
87
|
+
* const signature = wallet.sign(message);
|
|
88
|
+
* assert.equal(signature, sig, "signature should match");
|
|
89
|
+
* assert.ok(wallet.verify(message, signature), "signature should be verified");
|
|
90
|
+
*/
|
|
91
|
+
function fromSecretKey(sk, _type = "default") {
|
|
92
|
+
const type = (0, _arcblock_did.DidType)(_type);
|
|
93
|
+
return Wallet({
|
|
94
|
+
sk,
|
|
95
|
+
pk: (0, _ocap_mcrypto.getSigner)(type.pk).getPublicKey(sk)
|
|
96
|
+
}, type);
|
|
148
97
|
}
|
|
149
98
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
function fromPublicKey(pk, _type =
|
|
153
|
-
|
|
99
|
+
* Generate a wallet from publicKey
|
|
100
|
+
*/
|
|
101
|
+
function fromPublicKey(pk, _type = "default") {
|
|
102
|
+
return Wallet({ pk }, (0, _arcblock_did.DidType)(_type));
|
|
154
103
|
}
|
|
155
104
|
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
105
|
+
* Generate a wallet from address (did)
|
|
106
|
+
*
|
|
107
|
+
* Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
|
|
108
|
+
*/
|
|
160
109
|
function fromAddress(address) {
|
|
161
|
-
|
|
110
|
+
return Wallet({ address: (0, _arcblock_did.toAddress)(address) }, (0, _arcblock_did.toTypeInfo)(address));
|
|
162
111
|
}
|
|
163
112
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
function fromRandom(_type =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
113
|
+
* Generate a wallet by generating a random secretKey
|
|
114
|
+
*/
|
|
115
|
+
function fromRandom(_type = "default") {
|
|
116
|
+
const type = (0, _arcblock_did.DidType)(_type);
|
|
117
|
+
const keyPair = (0, _ocap_mcrypto.getSigner)(type.pk).genKeyPair();
|
|
118
|
+
return Wallet({
|
|
119
|
+
sk: keyPair.secretKey,
|
|
120
|
+
pk: keyPair.publicKey
|
|
121
|
+
}, type);
|
|
171
122
|
}
|
|
172
123
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
124
|
+
* Generating a wallet from a serialized json presentation of another wallet
|
|
125
|
+
*/
|
|
175
126
|
function fromJSON(json) {
|
|
176
|
-
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
return Wallet(json, type);
|
|
127
|
+
return Wallet(json, _arcblock_did.DidType.fromJSON(json.type));
|
|
179
128
|
}
|
|
180
129
|
/**
|
|
181
|
-
|
|
182
|
-
|
|
130
|
+
* Check if an object is valid wallet object
|
|
131
|
+
*/
|
|
183
132
|
function isValid(wallet, canSign = true) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (typeof wallet.toJSON !== 'function') {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
if (!wallet.type || !wallet.publicKey) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
if (canSign) {
|
|
200
|
-
if (typeof wallet.sign !== 'function') {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return true;
|
|
133
|
+
if (!wallet || typeof wallet !== "object") return false;
|
|
134
|
+
if (typeof wallet.verify !== "function") return false;
|
|
135
|
+
if (typeof wallet.toAddress !== "function") return false;
|
|
136
|
+
if (typeof wallet.toJSON !== "function") return false;
|
|
137
|
+
if (!wallet.type || !wallet.publicKey) return false;
|
|
138
|
+
if (canSign) {
|
|
139
|
+
if (typeof wallet.sign !== "function") return false;
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
205
142
|
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
exports.Wallet = Wallet;
|
|
146
|
+
exports.WalletType = WalletType;
|
|
147
|
+
exports.fromAddress = fromAddress;
|
|
148
|
+
exports.fromJSON = fromJSON;
|
|
149
|
+
exports.fromPublicKey = fromPublicKey;
|
|
150
|
+
exports.fromRandom = fromRandom;
|
|
151
|
+
exports.fromSecretKey = fromSecretKey;
|
|
152
|
+
exports.isValid = isValid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/wallet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "Utility function to create and use an forge compatible crypto wallet",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crypto",
|
|
@@ -20,8 +20,22 @@
|
|
|
20
20
|
],
|
|
21
21
|
"homepage": "https://www.arcblock.io/docs/blockchain-utils",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
|
+
"sideEffects": false,
|
|
23
24
|
"main": "./lib/index.js",
|
|
24
|
-
"
|
|
25
|
+
"module": "./esm/index.js",
|
|
26
|
+
"types": "./esm/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./esm/index.d.ts",
|
|
31
|
+
"default": "./esm/index.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./lib/index.d.ts",
|
|
35
|
+
"default": "./lib/index.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
25
39
|
"files": [
|
|
26
40
|
"lib",
|
|
27
41
|
"esm"
|
|
@@ -33,6 +47,7 @@
|
|
|
33
47
|
"eslint": "^8.57.0",
|
|
34
48
|
"jest": "^29.7.0",
|
|
35
49
|
"ts-jest": "^29.2.5",
|
|
50
|
+
"tsdown": "^0.18.4",
|
|
36
51
|
"typescript": "^5.6.2"
|
|
37
52
|
},
|
|
38
53
|
"repository": {
|
|
@@ -43,21 +58,17 @@
|
|
|
43
58
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
44
59
|
},
|
|
45
60
|
"dependencies": {
|
|
46
|
-
"@arcblock/did": "1.
|
|
47
|
-
"@arcblock/jwt": "1.
|
|
48
|
-
"@ocap/mcrypto": "1.
|
|
49
|
-
"@ocap/util": "1.
|
|
61
|
+
"@arcblock/did": "1.28.0",
|
|
62
|
+
"@arcblock/jwt": "1.28.0",
|
|
63
|
+
"@ocap/mcrypto": "1.28.0",
|
|
64
|
+
"@ocap/util": "1.28.0"
|
|
50
65
|
},
|
|
51
66
|
"scripts": {
|
|
52
67
|
"lint": "eslint tests src",
|
|
53
68
|
"lint:fix": "eslint --fix tests src",
|
|
54
69
|
"test": "jest --forceExit --detectOpenHandles",
|
|
55
70
|
"coverage": "npm run test -- --coverage",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
59
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
60
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
61
|
-
"build:watch": "npm run build -- -w"
|
|
71
|
+
"build": "tsdown",
|
|
72
|
+
"build:watch": "tsdown --watch"
|
|
62
73
|
}
|
|
63
74
|
}
|