@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 CHANGED
@@ -1,52 +1,54 @@
1
- import { EncodingType, BytesType } from '@ocap/util';
2
- import { DidType, DIDType, DIDTypeStr, DIDTypeArg } from '@arcblock/did';
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
- sk?: T;
5
- pk?: T;
6
- address?: string;
6
+ sk?: T;
7
+ pk?: T;
8
+ address?: string;
7
9
  };
8
- export type SerializedWallet = {
9
- type: DIDTypeStr;
10
- pk: string;
11
- sk: string;
12
- address: string;
10
+ type SerializedWallet = {
11
+ type: DIDTypeStr;
12
+ pk: string;
13
+ sk: string;
14
+ address: string;
13
15
  };
14
- export interface WalletObject<T extends BytesType = string> {
15
- type: DIDType;
16
- secretKey: T;
17
- publicKey: T;
18
- address: string;
19
- hash(data: BytesType, round?: number, encoding?: 'hex'): string;
20
- hash(data: BytesType, round?: number, encoding?: 'base16'): string;
21
- hash(data: BytesType, round?: number, encoding?: 'base58'): string;
22
- hash(data: BytesType, round?: number, encoding?: 'base64'): string;
23
- hash(data: BytesType, round?: number, encoding?: 'buffer'): Buffer;
24
- hash(data: BytesType, round?: number, encoding?: 'Uint8Array'): Uint8Array;
25
- hash(data: BytesType, round?: number, encoding?: EncodingType): BytesType;
26
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'hex'): Promise<string>;
27
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base16'): Promise<string>;
28
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base58'): Promise<string>;
29
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base64'): Promise<string>;
30
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'buffer'): Promise<Buffer>;
31
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'Uint8Array'): Promise<Uint8Array>;
32
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: EncodingType): Promise<BytesType>;
33
- verify(data: BytesType, signature: BytesType, hashBeforeVerify?: boolean, extra?: any): Promise<boolean>;
34
- ethHash(data: string): string;
35
- ethSign(data: string, hashBeforeSign?: boolean): Promise<string>;
36
- ethVerify(data: string, signature: string, hashBeforeVerify?: boolean): Promise<boolean>;
37
- signETH(data: string, hashBeforeSign?: boolean): Promise<string>;
38
- signJWT(payload?: any, doSign?: boolean, version?: string): Promise<string>;
39
- toJSON(): SerializedWallet;
40
- /**
41
- * @deprecated ES6: use `wallet.address` instead
42
- */
43
- toAddress(): string;
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
- export declare const WalletType: typeof DidType;
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
- export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
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
- export declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
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
- export declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
91
- export {};
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 '@ocap/util';
2
- import { getSigner, getHasher } from '@ocap/mcrypto';
3
- import { toAddress, fromPublicKey as DIDFromPublicKey, toTypeInfo, DidType, } from '@arcblock/did';
4
- import * as JWT from '@arcblock/jwt';
5
- export const WalletType = DidType;
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
- * Generate an wallet instance that can be used to sign a message or verify a signature
8
- */
9
- export function Wallet(keyPair, t = 'default') {
10
- const type = DidType(t);
11
- const signer = getSigner(type.pk);
12
- const hasher = getHasher(type.hash);
13
- return {
14
- type,
15
- secretKey: keyPair.sk,
16
- publicKey: keyPair.pk,
17
- address: keyPair.pk ? DIDFromPublicKey(keyPair.pk, type) : keyPair.address,
18
- // @ts-ignore
19
- hash(data, round = 1, encoding = 'hex') {
20
- return hasher(data, round, encoding);
21
- },
22
- // @ts-ignore
23
- // eslint-disable-next-line require-await
24
- async sign(data, hashBeforeSign = true, encoding = 'hex') {
25
- if (!keyPair.sk) {
26
- throw new Error('Cannot sign data without a secretKey');
27
- }
28
- if (hashBeforeSign) {
29
- const hash = hasher(data, 1);
30
- return signer.sign(hash, keyPair.sk, encoding);
31
- }
32
- return signer.sign(data, keyPair.sk, encoding);
33
- },
34
- // eslint-disable-next-line require-await
35
- async verify(data, signature, hashBeforeVerify = true, extra) {
36
- if (!keyPair.pk) {
37
- throw new Error('Cannot verify data without a publicKey');
38
- }
39
- const hash = hashBeforeVerify ? hasher(data, 1) : data;
40
- return signer.verify(hash, signature, keyPair.pk, extra);
41
- },
42
- ethHash(data) {
43
- if (typeof signer.ethHash !== 'function') {
44
- throw new Error('ethHash is not supported by signer');
45
- }
46
- return signer.ethHash(data);
47
- },
48
- // eslint-disable-next-line require-await
49
- async signETH(data, hashBeforeSign = true) {
50
- if (!keyPair.sk) {
51
- throw new Error('Cannot sign data without a secretKey');
52
- }
53
- if (typeof signer.ethHash !== 'function') {
54
- throw new Error('ethSign is not supported by signer');
55
- }
56
- if (hashBeforeSign) {
57
- return signer.ethSign(signer.ethHash(data), toHex(keyPair.sk));
58
- }
59
- return signer.ethSign(data, toHex(keyPair.sk));
60
- },
61
- ethSign(data, hashBeforeSign = true) {
62
- return this.signETH(data, hashBeforeSign);
63
- },
64
- // eslint-disable-next-line require-await
65
- async ethVerify(data, signature, hashBeforeVerify = true) {
66
- if (typeof signer.ethHash !== 'function') {
67
- throw new Error('ethVerify is not supported by signer');
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
- * Generate a wallet from secretKey
95
- *
96
- * @example
97
- * const assert = require('assert');
98
- * const { fromSecretKey } = require('@ocap/wallet');
99
- *
100
- * const sk =
101
- * '0xD67C071B6F51D2B61180B9B1AA9BE0DD0704619F0E30453AB4A592B036EDE644E4852B7091317E3622068E62A5127D1FB0D4AE2FC50213295E10652D2F0ABFC7';
102
- * const sig =
103
- * '0x08a102851c38c072e42756c1cc70938b5499c8e9358dfe5f383823f56cdb282ffda60fcd581a02c6c673069e5afc0bf09abbe3639b61b84d64fd58ef9f083003';
104
- *
105
- * const wallet = fromSecretKey(sk, type);
106
- * const message = 'data to sign';
107
- * const signature = wallet.sign(message);
108
- * assert.equal(signature, sig, "signature should match");
109
- * assert.ok(wallet.verify(message, signature), "signature should be verified");
110
- */
111
- export function fromSecretKey(sk, _type = 'default') {
112
- const type = DidType(_type);
113
- const keyPair = { sk, pk: getSigner(type.pk).getPublicKey(sk) };
114
- return Wallet(keyPair, type);
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
- * Generate a wallet from publicKey
118
- */
119
- export function fromPublicKey(pk, _type = 'default') {
120
- return Wallet({ pk }, DidType(_type));
97
+ * Generate a wallet from publicKey
98
+ */
99
+ function fromPublicKey(pk, _type = "default") {
100
+ return Wallet({ pk }, DidType(_type));
121
101
  }
122
102
  /**
123
- * Generate a wallet from address (did)
124
- *
125
- * Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
126
- */
127
- export function fromAddress(address) {
128
- return Wallet({ address: toAddress(address) }, toTypeInfo(address));
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
- * Generate a wallet by generating a random secretKey
132
- */
133
- export function fromRandom(_type = 'default') {
134
- const type = DidType(_type);
135
- const signer = getSigner(type.pk);
136
- const keyPair = signer.genKeyPair();
137
- return Wallet({ sk: keyPair.secretKey, pk: keyPair.publicKey }, type);
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
- * Generating a wallet from a serialized json presentation of another wallet
141
- */
142
- export function fromJSON(json) {
143
- const type = DidType.fromJSON(json.type);
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
- * Check if an object is valid wallet object
149
- */
150
- export function isValid(wallet, canSign = true) {
151
- if (!wallet || typeof wallet !== 'object') {
152
- return false;
153
- }
154
- if (typeof wallet.verify !== 'function') {
155
- return false;
156
- }
157
- if (typeof wallet.toAddress !== 'function') {
158
- return false;
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 { EncodingType, BytesType } from '@ocap/util';
2
- import { DidType, DIDType, DIDTypeStr, DIDTypeArg } from '@arcblock/did';
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
- sk?: T;
5
- pk?: T;
6
- address?: string;
6
+ sk?: T;
7
+ pk?: T;
8
+ address?: string;
7
9
  };
8
- export type SerializedWallet = {
9
- type: DIDTypeStr;
10
- pk: string;
11
- sk: string;
12
- address: string;
10
+ type SerializedWallet = {
11
+ type: DIDTypeStr;
12
+ pk: string;
13
+ sk: string;
14
+ address: string;
13
15
  };
14
- export interface WalletObject<T extends BytesType = string> {
15
- type: DIDType;
16
- secretKey: T;
17
- publicKey: T;
18
- address: string;
19
- hash(data: BytesType, round?: number, encoding?: 'hex'): string;
20
- hash(data: BytesType, round?: number, encoding?: 'base16'): string;
21
- hash(data: BytesType, round?: number, encoding?: 'base58'): string;
22
- hash(data: BytesType, round?: number, encoding?: 'base64'): string;
23
- hash(data: BytesType, round?: number, encoding?: 'buffer'): Buffer;
24
- hash(data: BytesType, round?: number, encoding?: 'Uint8Array'): Uint8Array;
25
- hash(data: BytesType, round?: number, encoding?: EncodingType): BytesType;
26
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'hex'): Promise<string>;
27
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base16'): Promise<string>;
28
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base58'): Promise<string>;
29
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'base64'): Promise<string>;
30
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'buffer'): Promise<Buffer>;
31
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: 'Uint8Array'): Promise<Uint8Array>;
32
- sign(data: BytesType, hashBeforeSign?: boolean, encoding?: EncodingType): Promise<BytesType>;
33
- verify(data: BytesType, signature: BytesType, hashBeforeVerify?: boolean, extra?: any): Promise<boolean>;
34
- ethHash(data: string): string;
35
- ethSign(data: string, hashBeforeSign?: boolean): Promise<string>;
36
- ethVerify(data: string, signature: string, hashBeforeVerify?: boolean): Promise<boolean>;
37
- signETH(data: string, hashBeforeSign?: boolean): Promise<string>;
38
- signJWT(payload?: any, doSign?: boolean, version?: string): Promise<string>;
39
- toJSON(): SerializedWallet;
40
- /**
41
- * @deprecated ES6: use `wallet.address` instead
42
- */
43
- toAddress(): string;
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
- export declare const WalletType: typeof DidType;
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
- export declare function Wallet<T extends BytesType = string>(keyPair: KeyPairType<T>, t?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromSecretKey<T extends BytesType = string>(sk: T, _type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromPublicKey<T extends BytesType = string>(pk: T, _type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromAddress<T extends BytesType = string>(address: string): WalletObject<T>;
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
- export declare function fromRandom<T extends BytesType = string>(_type?: DIDTypeArg): WalletObject<T>;
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
- export declare function fromJSON<T extends BytesType = string>(json: SerializedWallet): WalletObject<T>;
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
- export declare function isValid(wallet: WalletObject, canSign?: boolean): boolean;
91
- export {};
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
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
- * Generate an wallet instance that can be used to sign a message or verify a signature
41
- */
42
- function Wallet(keyPair, t = 'default') {
43
- const type = (0, did_1.DidType)(t);
44
- const signer = (0, mcrypto_1.getSigner)(type.pk);
45
- const hasher = (0, mcrypto_1.getHasher)(type.hash);
46
- return {
47
- type,
48
- secretKey: keyPair.sk,
49
- publicKey: keyPair.pk,
50
- address: keyPair.pk ? (0, did_1.fromPublicKey)(keyPair.pk, type) : keyPair.address,
51
- // @ts-ignore
52
- hash(data, round = 1, encoding = 'hex') {
53
- return hasher(data, round, encoding);
54
- },
55
- // @ts-ignore
56
- // eslint-disable-next-line require-await
57
- async sign(data, hashBeforeSign = true, encoding = 'hex') {
58
- if (!keyPair.sk) {
59
- throw new Error('Cannot sign data without a secretKey');
60
- }
61
- if (hashBeforeSign) {
62
- const hash = hasher(data, 1);
63
- return signer.sign(hash, keyPair.sk, encoding);
64
- }
65
- return signer.sign(data, keyPair.sk, encoding);
66
- },
67
- // eslint-disable-next-line require-await
68
- async verify(data, signature, hashBeforeVerify = true, extra) {
69
- if (!keyPair.pk) {
70
- throw new Error('Cannot verify data without a publicKey');
71
- }
72
- const hash = hashBeforeVerify ? hasher(data, 1) : data;
73
- return signer.verify(hash, signature, keyPair.pk, extra);
74
- },
75
- ethHash(data) {
76
- if (typeof signer.ethHash !== 'function') {
77
- throw new Error('ethHash is not supported by signer');
78
- }
79
- return signer.ethHash(data);
80
- },
81
- // eslint-disable-next-line require-await
82
- async signETH(data, hashBeforeSign = true) {
83
- if (!keyPair.sk) {
84
- throw new Error('Cannot sign data without a secretKey');
85
- }
86
- if (typeof signer.ethHash !== 'function') {
87
- throw new Error('ethSign is not supported by signer');
88
- }
89
- if (hashBeforeSign) {
90
- return signer.ethSign(signer.ethHash(data), (0, util_1.toHex)(keyPair.sk));
91
- }
92
- return signer.ethSign(data, (0, util_1.toHex)(keyPair.sk));
93
- },
94
- ethSign(data, hashBeforeSign = true) {
95
- return this.signETH(data, hashBeforeSign);
96
- },
97
- // eslint-disable-next-line require-await
98
- async ethVerify(data, signature, hashBeforeVerify = true) {
99
- if (typeof signer.ethHash !== 'function') {
100
- throw new Error('ethVerify is not supported by signer');
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
- * Generate a wallet from secretKey
128
- *
129
- * @example
130
- * const assert = require('assert');
131
- * const { fromSecretKey } = require('@ocap/wallet');
132
- *
133
- * const sk =
134
- * '0xD67C071B6F51D2B61180B9B1AA9BE0DD0704619F0E30453AB4A592B036EDE644E4852B7091317E3622068E62A5127D1FB0D4AE2FC50213295E10652D2F0ABFC7';
135
- * const sig =
136
- * '0x08a102851c38c072e42756c1cc70938b5499c8e9358dfe5f383823f56cdb282ffda60fcd581a02c6c673069e5afc0bf09abbe3639b61b84d64fd58ef9f083003';
137
- *
138
- * const wallet = fromSecretKey(sk, type);
139
- * const message = 'data to sign';
140
- * const signature = wallet.sign(message);
141
- * assert.equal(signature, sig, "signature should match");
142
- * assert.ok(wallet.verify(message, signature), "signature should be verified");
143
- */
144
- function fromSecretKey(sk, _type = 'default') {
145
- const type = (0, did_1.DidType)(_type);
146
- const keyPair = { sk, pk: (0, mcrypto_1.getSigner)(type.pk).getPublicKey(sk) };
147
- return Wallet(keyPair, type);
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
- * Generate a wallet from publicKey
151
- */
152
- function fromPublicKey(pk, _type = 'default') {
153
- return Wallet({ pk }, (0, did_1.DidType)(_type));
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
- * Generate a wallet from address (did)
157
- *
158
- * Since we do not know the publicKey and secretKey, this kind of wallet cannot be used for signing and verifying
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
- return Wallet({ address: (0, did_1.toAddress)(address) }, (0, did_1.toTypeInfo)(address));
110
+ return Wallet({ address: (0, _arcblock_did.toAddress)(address) }, (0, _arcblock_did.toTypeInfo)(address));
162
111
  }
163
112
  /**
164
- * Generate a wallet by generating a random secretKey
165
- */
166
- function fromRandom(_type = 'default') {
167
- const type = (0, did_1.DidType)(_type);
168
- const signer = (0, mcrypto_1.getSigner)(type.pk);
169
- const keyPair = signer.genKeyPair();
170
- return Wallet({ sk: keyPair.secretKey, pk: keyPair.publicKey }, type);
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
- * Generating a wallet from a serialized json presentation of another wallet
174
- */
124
+ * Generating a wallet from a serialized json presentation of another wallet
125
+ */
175
126
  function fromJSON(json) {
176
- const type = did_1.DidType.fromJSON(json.type);
177
- // @ts-ignore
178
- return Wallet(json, type);
127
+ return Wallet(json, _arcblock_did.DidType.fromJSON(json.type));
179
128
  }
180
129
  /**
181
- * Check if an object is valid wallet object
182
- */
130
+ * Check if an object is valid wallet object
131
+ */
183
132
  function isValid(wallet, canSign = true) {
184
- if (!wallet || typeof wallet !== 'object') {
185
- return false;
186
- }
187
- if (typeof wallet.verify !== 'function') {
188
- return false;
189
- }
190
- if (typeof wallet.toAddress !== 'function') {
191
- return false;
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.27.15",
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
- "types": "./lib/index.d.ts",
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.27.15",
47
- "@arcblock/jwt": "1.27.15",
48
- "@ocap/mcrypto": "1.27.15",
49
- "@ocap/util": "1.27.15"
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
- "clean": "rm -fr lib esm",
57
- "prebuild": "npm run clean",
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
  }