@ocap/wallet 1.28.9 → 1.29.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/README.md +0 -1
- package/esm/index.d.mts +2 -2
- package/esm/index.mjs +4 -4
- package/lib/index.cjs +4 -4
- package/lib/index.d.cts +2 -2
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
[](https://github.com/prettier/prettier)
|
|
4
3
|
[](https://docs.arcblock.io)
|
|
5
4
|
[](https://gitter.im/ArcBlock/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
6
5
|
|
package/esm/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DIDType, DIDTypeArg, DIDTypeStr
|
|
1
|
+
import { DIDType, DIDTypeArg, DIDTypeStr } from "@arcblock/did";
|
|
2
2
|
import { BytesType, EncodingType } from "@ocap/util";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
@@ -44,7 +44,7 @@ interface WalletObject<T extends BytesType = string> {
|
|
|
44
44
|
*/
|
|
45
45
|
toAddress(): string;
|
|
46
46
|
}
|
|
47
|
-
declare const WalletType:
|
|
47
|
+
declare const WalletType: any;
|
|
48
48
|
/**
|
|
49
49
|
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
50
50
|
*/
|
package/esm/index.mjs
CHANGED
|
@@ -39,7 +39,7 @@ function Wallet(keyPair, t = "default") {
|
|
|
39
39
|
},
|
|
40
40
|
async signETH(data, hashBeforeSign = true) {
|
|
41
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");
|
|
42
|
+
if (typeof signer.ethHash !== "function" || typeof signer.ethSign !== "function") throw new Error("ethSign is not supported by signer");
|
|
43
43
|
if (hashBeforeSign) return signer.ethSign(signer.ethHash(data), toHex(keyPair.sk));
|
|
44
44
|
return signer.ethSign(data, toHex(keyPair.sk));
|
|
45
45
|
},
|
|
@@ -47,7 +47,7 @@ function Wallet(keyPair, t = "default") {
|
|
|
47
47
|
return this.signETH(data, hashBeforeSign);
|
|
48
48
|
},
|
|
49
49
|
async ethVerify(data, signature, hashBeforeVerify = true) {
|
|
50
|
-
if (typeof signer.ethHash !== "function") throw new Error("ethVerify is not supported by signer");
|
|
50
|
+
if (typeof signer.ethHash !== "function" || typeof signer.ethRecover !== "function") throw new Error("ethVerify is not supported by signer");
|
|
51
51
|
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
52
52
|
return signer.ethRecover(hash, signature) === this.address;
|
|
53
53
|
},
|
|
@@ -61,8 +61,8 @@ function Wallet(keyPair, t = "default") {
|
|
|
61
61
|
toJSON() {
|
|
62
62
|
return {
|
|
63
63
|
type: DidType.toJSON(type),
|
|
64
|
-
sk: toHex(keyPair.sk),
|
|
65
|
-
pk: toHex(keyPair.pk),
|
|
64
|
+
sk: keyPair.sk ? toHex(keyPair.sk) : "",
|
|
65
|
+
pk: keyPair.pk ? toHex(keyPair.pk) : "",
|
|
66
66
|
address: this.address
|
|
67
67
|
};
|
|
68
68
|
}
|
package/lib/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function Wallet(keyPair, t = "default") {
|
|
|
41
41
|
},
|
|
42
42
|
async signETH(data, hashBeforeSign = true) {
|
|
43
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");
|
|
44
|
+
if (typeof signer.ethHash !== "function" || typeof signer.ethSign !== "function") throw new Error("ethSign is not supported by signer");
|
|
45
45
|
if (hashBeforeSign) return signer.ethSign(signer.ethHash(data), (0, _ocap_util.toHex)(keyPair.sk));
|
|
46
46
|
return signer.ethSign(data, (0, _ocap_util.toHex)(keyPair.sk));
|
|
47
47
|
},
|
|
@@ -49,7 +49,7 @@ function Wallet(keyPair, t = "default") {
|
|
|
49
49
|
return this.signETH(data, hashBeforeSign);
|
|
50
50
|
},
|
|
51
51
|
async ethVerify(data, signature, hashBeforeVerify = true) {
|
|
52
|
-
if (typeof signer.ethHash !== "function") throw new Error("ethVerify is not supported by signer");
|
|
52
|
+
if (typeof signer.ethHash !== "function" || typeof signer.ethRecover !== "function") throw new Error("ethVerify is not supported by signer");
|
|
53
53
|
const hash = hashBeforeVerify ? signer.ethHash(data) : data;
|
|
54
54
|
return signer.ethRecover(hash, signature) === this.address;
|
|
55
55
|
},
|
|
@@ -63,8 +63,8 @@ function Wallet(keyPair, t = "default") {
|
|
|
63
63
|
toJSON() {
|
|
64
64
|
return {
|
|
65
65
|
type: _arcblock_did.DidType.toJSON(type),
|
|
66
|
-
sk: (0, _ocap_util.toHex)(keyPair.sk),
|
|
67
|
-
pk: (0, _ocap_util.toHex)(keyPair.pk),
|
|
66
|
+
sk: keyPair.sk ? (0, _ocap_util.toHex)(keyPair.sk) : "",
|
|
67
|
+
pk: keyPair.pk ? (0, _ocap_util.toHex)(keyPair.pk) : "",
|
|
68
68
|
address: this.address
|
|
69
69
|
};
|
|
70
70
|
}
|
package/lib/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DIDType, DIDTypeArg, DIDTypeStr
|
|
1
|
+
import { DIDType, DIDTypeArg, DIDTypeStr } from "@arcblock/did";
|
|
2
2
|
import { BytesType, EncodingType } from "@ocap/util";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
@@ -44,7 +44,7 @@ interface WalletObject<T extends BytesType = string> {
|
|
|
44
44
|
*/
|
|
45
45
|
toAddress(): string;
|
|
46
46
|
}
|
|
47
|
-
declare const WalletType:
|
|
47
|
+
declare const WalletType: any;
|
|
48
48
|
/**
|
|
49
49
|
* Generate an wallet instance that can be used to sign a message or verify a signature
|
|
50
50
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/wallet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility function to create and use an forge compatible crypto wallet",
|
|
6
6
|
"keywords": [
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.7.5",
|
|
41
|
-
"tsdown": "^0.18.4"
|
|
42
|
-
"typescript": "^5.6.2"
|
|
41
|
+
"tsdown": "^0.18.4"
|
|
43
42
|
},
|
|
44
43
|
"repository": {
|
|
45
44
|
"type": "git",
|
|
@@ -57,9 +56,9 @@
|
|
|
57
56
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
58
57
|
},
|
|
59
58
|
"dependencies": {
|
|
60
|
-
"@arcblock/did": "1.
|
|
61
|
-
"@arcblock/jwt": "1.
|
|
62
|
-
"@ocap/mcrypto": "1.
|
|
63
|
-
"@ocap/util": "1.
|
|
59
|
+
"@arcblock/did": "1.29.0",
|
|
60
|
+
"@arcblock/jwt": "1.29.0",
|
|
61
|
+
"@ocap/mcrypto": "1.29.0",
|
|
62
|
+
"@ocap/util": "1.29.0"
|
|
64
63
|
}
|
|
65
64
|
}
|