@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-alpha.8
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/dist/address/index.d.ts +1 -1
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +4 -4
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.d.ts +1 -1
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +1 -1
- package/dist/client/clientPublicTestnet.d.ts +1 -1
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +1 -1
- package/dist/client/jsonRpc/index.d.ts +3 -3
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +4 -4
- package/dist/signer/btc/index.d.ts +1 -0
- package/dist/signer/btc/index.d.ts.map +1 -1
- package/dist/signer/btc/index.js +1 -0
- package/dist/signer/btc/signerBtc.d.ts +9 -1
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +16 -2
- package/dist/signer/btc/verify.d.ts +3 -0
- package/dist/signer/btc/verify.d.ts.map +1 -0
- package/dist/signer/btc/verify.js +6 -0
- package/dist/signer/ckb/index.d.ts +1 -0
- package/dist/signer/ckb/index.d.ts.map +1 -1
- package/dist/signer/ckb/index.js +1 -0
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -2
- package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist/signer/ckb/verifyJoyId.js +12 -0
- package/dist/signer/dummy/alwaysError.d.ts +10 -0
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist/signer/dummy/alwaysError.js +13 -0
- package/dist/signer/dummy/dummy.d.ts +12 -0
- package/dist/signer/dummy/dummy.d.ts.map +1 -0
- package/dist/signer/dummy/dummy.js +19 -0
- package/dist/signer/dummy/index.d.ts +4 -0
- package/dist/signer/dummy/index.d.ts.map +1 -0
- package/dist/signer/dummy/index.js +3 -0
- package/dist/signer/dummy/openLink.d.ts +10 -0
- package/dist/signer/dummy/openLink.d.ts.map +1 -0
- package/dist/signer/dummy/openLink.js +13 -0
- package/dist/signer/evm/index.d.ts +1 -0
- package/dist/signer/evm/index.d.ts.map +1 -1
- package/dist/signer/evm/index.js +1 -0
- package/dist/signer/evm/signerEvm.d.ts +3 -1
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +8 -2
- package/dist/signer/evm/verify.d.ts +3 -0
- package/dist/signer/evm/verify.d.ts.map +1 -0
- package/dist/signer/evm/verify.js +6 -0
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/dist/signer/{signer.d.ts → signer/index.d.ts} +67 -21
- package/dist/signer/signer/index.d.ts.map +1 -0
- package/dist/signer/{signer.js → signer/index.js} +95 -16
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist.commonjs/address/index.d.ts +1 -1
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +4 -4
- package/dist.commonjs/client/client.d.ts +2 -2
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts +1 -1
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +1 -1
- package/dist.commonjs/client/clientPublicTestnet.d.ts +1 -1
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +1 -1
- package/dist.commonjs/client/jsonRpc/index.d.ts +3 -3
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +4 -4
- package/dist.commonjs/signer/btc/index.d.ts +1 -0
- package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/index.js +1 -0
- package/dist.commonjs/signer/btc/signerBtc.d.ts +9 -1
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +15 -1
- package/dist.commonjs/signer/btc/verify.d.ts +3 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/btc/verify.js +10 -0
- package/dist.commonjs/signer/ckb/index.d.ts +1 -0
- package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/index.js +1 -0
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +3 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +7 -1
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +3 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
- package/dist.commonjs/signer/ckb/verifyJoyId.js +16 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +10 -0
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/alwaysError.js +17 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
- package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/dummy.js +23 -0
- package/dist.commonjs/signer/dummy/index.d.ts +4 -0
- package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/index.js +19 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts +10 -0
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
- package/dist.commonjs/signer/dummy/openLink.js +17 -0
- package/dist.commonjs/signer/evm/index.d.ts +1 -0
- package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/index.js +1 -0
- package/dist.commonjs/signer/evm/signerEvm.d.ts +3 -1
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +7 -1
- package/dist.commonjs/signer/evm/verify.d.ts +3 -0
- package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/evm/verify.js +10 -0
- package/dist.commonjs/signer/index.d.ts +1 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +1 -0
- package/dist.commonjs/signer/{signer.d.ts → signer/index.d.ts} +67 -21
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
- package/dist.commonjs/signer/{signer.js → signer/index.js} +97 -17
- package/dist.commonjs/utils/index.d.ts +1 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +5 -1
- package/package.json +6 -3
- package/src/address/index.ts +4 -7
- package/src/client/client.ts +2 -2
- package/src/client/clientPublicMainnet.ts +1 -1
- package/src/client/clientPublicTestnet.ts +1 -1
- package/src/client/jsonRpc/index.ts +3 -3
- package/src/signer/btc/index.ts +1 -0
- package/src/signer/btc/signerBtc.ts +19 -2
- package/src/signer/btc/verify.ts +14 -0
- package/src/signer/ckb/index.ts +1 -0
- package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -2
- package/src/signer/ckb/verifyJoyId.ts +20 -0
- package/src/signer/dummy/alwaysError.ts +21 -0
- package/src/signer/dummy/dummy.ts +28 -0
- package/src/signer/dummy/index.ts +3 -0
- package/src/signer/dummy/openLink.ts +21 -0
- package/src/signer/evm/index.ts +1 -0
- package/src/signer/evm/signerEvm.ts +10 -2
- package/src/signer/evm/verify.ts +16 -0
- package/src/signer/index.ts +1 -0
- package/src/signer/{signer.ts → signer/index.ts} +131 -21
- package/src/utils/index.ts +4 -0
- package/dist/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/signer/signer.d.ts.map +0 -1
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { ScriptLike } from "../../ckb";
|
|
3
3
|
import { Client } from "../../client";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* A class extending Signer that provides read-only access to a CKB script.
|
|
7
7
|
* This class does not support signing operations.
|
|
8
8
|
*/
|
|
9
9
|
export declare class SignerCkbScriptReadonly extends Signer {
|
|
10
|
+
get type(): SignerType;
|
|
11
|
+
get signType(): SignerSignType;
|
|
10
12
|
private readonly script;
|
|
11
13
|
/**
|
|
12
14
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerCkbScriptReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbScriptReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,MAAM;IACjD,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAM9C;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIrE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;;;;;;OASG;IAEG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -9,6 +9,12 @@ const signer_1 = require("../signer");
|
|
|
9
9
|
* This class does not support signing operations.
|
|
10
10
|
*/
|
|
11
11
|
class SignerCkbScriptReadonly extends signer_1.Signer {
|
|
12
|
+
get type() {
|
|
13
|
+
return signer_1.SignerType.CKB;
|
|
14
|
+
}
|
|
15
|
+
get signType() {
|
|
16
|
+
return signer_1.SignerSignType.Unknown;
|
|
17
|
+
}
|
|
12
18
|
/**
|
|
13
19
|
* Creates an instance of SignerCkbScriptReadonly.
|
|
14
20
|
*
|
|
@@ -65,7 +71,7 @@ class SignerCkbScriptReadonly extends signer_1.Signer {
|
|
|
65
71
|
* ```
|
|
66
72
|
*/
|
|
67
73
|
async getAddressObjs() {
|
|
68
|
-
return [
|
|
74
|
+
return [address_1.Address.fromScript(this.script, this.client)];
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
exports.SignerCkbScriptReadonly = SignerCkbScriptReadonly;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyJoyId.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/verifyJoyId.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageJoyId = void 0;
|
|
4
|
+
const ckb_1 = require("@joyid/ckb");
|
|
5
|
+
const hex_1 = require("../../hex");
|
|
6
|
+
function verifyMessageJoyId(message, signature, identity) {
|
|
7
|
+
const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
|
|
8
|
+
const { publicKey, keyType } = JSON.parse(identity);
|
|
9
|
+
return (0, ckb_1.verifySignature)({
|
|
10
|
+
challenge,
|
|
11
|
+
pubkey: publicKey,
|
|
12
|
+
keyType,
|
|
13
|
+
...JSON.parse(signature),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.verifyMessageJoyId = verifyMessageJoyId;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Client } from "../../client";
|
|
2
|
+
import { SignerType } from "../signer";
|
|
3
|
+
import { SignerDummy } from "./dummy";
|
|
4
|
+
export declare class SignerAlwaysError extends SignerDummy {
|
|
5
|
+
private readonly message;
|
|
6
|
+
constructor(client: Client, type: SignerType, message: string);
|
|
7
|
+
replaceClient(client: Client): Promise<SignerAlwaysError>;
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=alwaysError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alwaysError.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/alwaysError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,iBAAkB,SAAQ,WAAW;IAI9C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFxB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EACC,OAAO,EAAE,MAAM;IAK5B,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIzD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerAlwaysError = void 0;
|
|
4
|
+
const dummy_1 = require("./dummy");
|
|
5
|
+
class SignerAlwaysError extends dummy_1.SignerDummy {
|
|
6
|
+
constructor(client, type, message) {
|
|
7
|
+
super(client, type);
|
|
8
|
+
this.message = message;
|
|
9
|
+
}
|
|
10
|
+
async replaceClient(client) {
|
|
11
|
+
return new SignerAlwaysError(client, this.type, this.message);
|
|
12
|
+
}
|
|
13
|
+
async connect() {
|
|
14
|
+
throw new Error(this.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SignerAlwaysError = SignerAlwaysError;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { Client } from "../../client";
|
|
3
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
4
|
+
export declare abstract class SignerDummy extends Signer {
|
|
5
|
+
readonly type: SignerType;
|
|
6
|
+
get signType(): SignerSignType;
|
|
7
|
+
constructor(client: Client, type: SignerType);
|
|
8
|
+
isConnected(): Promise<boolean>;
|
|
9
|
+
getInternalAddress(): Promise<string>;
|
|
10
|
+
getAddressObjs(): Promise<Address[]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=dummy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dummy.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/dummy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D,8BAAsB,WAAY,SAAQ,MAAM;aAO5B,IAAI,EAAE,UAAU;IANlC,IAAI,QAAQ,IAAI,cAAc,CAE7B;gBAGC,MAAM,EAAE,MAAM,EACE,IAAI,EAAE,UAAU;IAK5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAG3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerDummy = void 0;
|
|
4
|
+
const signer_1 = require("../signer");
|
|
5
|
+
class SignerDummy extends signer_1.Signer {
|
|
6
|
+
get signType() {
|
|
7
|
+
return signer_1.SignerSignType.Unknown;
|
|
8
|
+
}
|
|
9
|
+
constructor(client, type) {
|
|
10
|
+
super(client);
|
|
11
|
+
this.type = type;
|
|
12
|
+
}
|
|
13
|
+
async isConnected() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
async getInternalAddress() {
|
|
17
|
+
throw new Error("Can't get address from SignerDummy");
|
|
18
|
+
}
|
|
19
|
+
async getAddressObjs() {
|
|
20
|
+
throw new Error("Can't get addresses from SignerDummy");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SignerDummy = SignerDummy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./alwaysError"), exports);
|
|
18
|
+
__exportStar(require("./dummy"), exports);
|
|
19
|
+
__exportStar(require("./openLink"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Client } from "../../client";
|
|
2
|
+
import { SignerType } from "../signer";
|
|
3
|
+
import { SignerDummy } from "./dummy";
|
|
4
|
+
export declare class SignerOpenLink extends SignerDummy {
|
|
5
|
+
private readonly link;
|
|
6
|
+
constructor(client: Client, type: SignerType, link: string);
|
|
7
|
+
replaceClient(client: Client): Promise<SignerOpenLink>;
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=openLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openLink.d.ts","sourceRoot":"","sources":["../../../src/signer/dummy/openLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,cAAe,SAAQ,WAAW;IAI3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAFrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EACC,IAAI,EAAE,MAAM;IAKzB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAItD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignerOpenLink = void 0;
|
|
4
|
+
const dummy_1 = require("./dummy");
|
|
5
|
+
class SignerOpenLink extends dummy_1.SignerDummy {
|
|
6
|
+
constructor(client, type, link) {
|
|
7
|
+
super(client, type);
|
|
8
|
+
this.link = link;
|
|
9
|
+
}
|
|
10
|
+
async replaceClient(client) {
|
|
11
|
+
return new SignerOpenLink(client, this.type, this.link);
|
|
12
|
+
}
|
|
13
|
+
async connect() {
|
|
14
|
+
window.open(this.link, "_blank")?.focus();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SignerOpenLink = SignerOpenLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC"}
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./signerEvm"), exports);
|
|
18
18
|
__exportStar(require("./signerEvmAddressReadonly"), exports);
|
|
19
|
+
__exportStar(require("./verify"), exports);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Address } from "../../address";
|
|
2
2
|
import { BytesLike } from "../../bytes";
|
|
3
3
|
import { Script, Transaction, TransactionLike } from "../../ckb";
|
|
4
|
-
import { Signer } from "../signer";
|
|
4
|
+
import { Signer, SignerSignType, SignerType } from "../signer";
|
|
5
5
|
/**
|
|
6
6
|
* An abstract class extending Signer for Ethereum Virtual Machine (EVM) based signing operations.
|
|
7
7
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class SignerEvm extends Signer {
|
|
10
|
+
get type(): SignerType;
|
|
11
|
+
get signType(): SignerSignType;
|
|
10
12
|
/**
|
|
11
13
|
* Gets the EVM account associated with the signer.
|
|
12
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signerEvm.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/signerEvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAA0B,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAQpC,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5D,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAYvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAsBlE,iCAAiC,CACrC,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAC9C,OAAO,CAAC,WAAW,CAAC;CA6BxB"}
|
|
@@ -13,6 +13,12 @@ const signer_1 = require("../signer");
|
|
|
13
13
|
* This class provides methods to get EVM account, internal address, and signing transactions.
|
|
14
14
|
*/
|
|
15
15
|
class SignerEvm extends signer_1.Signer {
|
|
16
|
+
get type() {
|
|
17
|
+
return signer_1.SignerType.EVM;
|
|
18
|
+
}
|
|
19
|
+
get signType() {
|
|
20
|
+
return signer_1.SignerSignType.EvmPersonal;
|
|
21
|
+
}
|
|
16
22
|
/**
|
|
17
23
|
* Gets the internal address, which is the EVM account in this case.
|
|
18
24
|
*
|
|
@@ -69,7 +75,7 @@ class SignerEvm extends signer_1.Signer {
|
|
|
69
75
|
if (!info) {
|
|
70
76
|
return tx;
|
|
71
77
|
}
|
|
72
|
-
const signature = (0, bytes_1.bytesFrom)(await this.
|
|
78
|
+
const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(messageTransformer(info.message)));
|
|
73
79
|
if (signature[signature.length - 1] >= 27) {
|
|
74
80
|
signature[signature.length - 1] -= 27;
|
|
75
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/evm/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,aAAa,CAAC;AAEnD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAQT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyMessageEvmPersonal = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const bytes_1 = require("../../bytes");
|
|
6
|
+
function verifyMessageEvmPersonal(message, signature, address) {
|
|
7
|
+
return (address.toLowerCase() ===
|
|
8
|
+
(0, ethers_1.verifyMessage)(typeof message === "string" ? message : (0, bytes_1.bytesFrom)(message), signature).toLowerCase());
|
|
9
|
+
}
|
|
10
|
+
exports.verifyMessageEvmPersonal = verifyMessageEvmPersonal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
|
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./btc"), exports);
|
|
18
18
|
__exportStar(require("./ckb"), exports);
|
|
19
|
+
__exportStar(require("./dummy"), exports);
|
|
19
20
|
__exportStar(require("./evm"), exports);
|
|
20
21
|
__exportStar(require("./signer"), exports);
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { Address } from "
|
|
2
|
-
import { BytesLike } from "
|
|
3
|
-
import { Transaction, TransactionLike } from "
|
|
4
|
-
import { Client } from "
|
|
5
|
-
import { Hex } from "
|
|
6
|
-
import { Num } from "
|
|
1
|
+
import { Address } from "../../address";
|
|
2
|
+
import { BytesLike } from "../../bytes";
|
|
3
|
+
import { Transaction, TransactionLike } from "../../ckb";
|
|
4
|
+
import { Client } from "../../client";
|
|
5
|
+
import { Hex } from "../../hex";
|
|
6
|
+
import { Num } from "../../num";
|
|
7
|
+
export declare enum SignerSignType {
|
|
8
|
+
Unknown = "Unknown",
|
|
9
|
+
BtcEcdsa = "BtcEcdsa",
|
|
10
|
+
EvmPersonal = "EvmPersonal",
|
|
11
|
+
JoyId = "JoyId"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An enumeration of signer display types in wallet.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum SignerType {
|
|
17
|
+
EVM = "EVM",
|
|
18
|
+
BTC = "BTC",
|
|
19
|
+
CKB = "CKB"
|
|
20
|
+
}
|
|
21
|
+
export declare class Signature {
|
|
22
|
+
signature: string;
|
|
23
|
+
identity: string;
|
|
24
|
+
signType: SignerSignType;
|
|
25
|
+
constructor(signature: string, identity: string, signType: SignerSignType);
|
|
26
|
+
}
|
|
7
27
|
/**
|
|
8
28
|
* An abstract class representing a generic signer.
|
|
9
29
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -11,7 +31,10 @@ import { Num } from "../num";
|
|
|
11
31
|
export declare abstract class Signer {
|
|
12
32
|
protected client_: Client;
|
|
13
33
|
constructor(client_: Client);
|
|
34
|
+
abstract get type(): SignerType;
|
|
35
|
+
abstract get signType(): SignerSignType;
|
|
14
36
|
get client(): Client;
|
|
37
|
+
static verifyMessage(message: string | BytesLike, signature: Signature): Promise<boolean>;
|
|
15
38
|
/**
|
|
16
39
|
* Construct a new signer with the client replaced.
|
|
17
40
|
*
|
|
@@ -42,6 +65,12 @@ export declare abstract class Signer {
|
|
|
42
65
|
* @returns A promise that resolves to a string representing the internal address.
|
|
43
66
|
*/
|
|
44
67
|
abstract getInternalAddress(): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the identity for verifying signature, usually it's address
|
|
70
|
+
*
|
|
71
|
+
* @returns A promise that resolves to a string representing the identity
|
|
72
|
+
*/
|
|
73
|
+
getIdentity(): Promise<string>;
|
|
45
74
|
/**
|
|
46
75
|
* Gets an array of Address objects associated with the signer.
|
|
47
76
|
*
|
|
@@ -75,13 +104,39 @@ export declare abstract class Signer {
|
|
|
75
104
|
*/
|
|
76
105
|
getBalance(): Promise<Num>;
|
|
77
106
|
/**
|
|
78
|
-
* Signs a message.
|
|
107
|
+
* Signs a message.
|
|
108
|
+
*
|
|
109
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
110
|
+
* @returns A promise that resolves to the signature info.
|
|
111
|
+
* @throws Will throw an error if not implemented.
|
|
112
|
+
*/
|
|
113
|
+
signMessage(message: string | BytesLike): Promise<Signature>;
|
|
114
|
+
/**
|
|
115
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
79
116
|
*
|
|
80
117
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
81
|
-
* @returns A promise that resolves to the
|
|
118
|
+
* @returns A promise that resolves to the signature as a string.
|
|
119
|
+
* @throws Will throw an error if not implemented.
|
|
120
|
+
*/
|
|
121
|
+
signMessageRaw(_: string | BytesLike): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Verify a signature.
|
|
124
|
+
*
|
|
125
|
+
* @param _ - The original message.
|
|
126
|
+
* @param _ - The signature to verify.
|
|
127
|
+
* @returns A promise that resolves to the verification result.
|
|
128
|
+
* @throws Will throw an error if not implemented.
|
|
129
|
+
*/
|
|
130
|
+
verifyMessage(message: string | BytesLike, signature: string | Signature): Promise<boolean>;
|
|
131
|
+
/**
|
|
132
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
133
|
+
*
|
|
134
|
+
* @param _0 - The original message.
|
|
135
|
+
* @param _1 - The signature to verify.
|
|
136
|
+
* @returns A promise that resolves to the verification result.
|
|
82
137
|
* @throws Will throw an error if not implemented.
|
|
83
138
|
*/
|
|
84
|
-
|
|
139
|
+
verifyMessageRaw(_0: string | BytesLike, _1: string): Promise<boolean>;
|
|
85
140
|
/**
|
|
86
141
|
* Sends a transaction after signing it.
|
|
87
142
|
*
|
|
@@ -105,7 +160,7 @@ export declare abstract class Signer {
|
|
|
105
160
|
*/
|
|
106
161
|
prepareTransaction(_: TransactionLike): Promise<Transaction>;
|
|
107
162
|
/**
|
|
108
|
-
* Signs a transaction without
|
|
163
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
109
164
|
*
|
|
110
165
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
111
166
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -113,22 +168,13 @@ export declare abstract class Signer {
|
|
|
113
168
|
*/
|
|
114
169
|
signOnlyTransaction(_: TransactionLike): Promise<Transaction>;
|
|
115
170
|
}
|
|
116
|
-
/**
|
|
117
|
-
* An enumeration of signer types.
|
|
118
|
-
*/
|
|
119
|
-
export declare enum SignerType {
|
|
120
|
-
EVM = "EVM",
|
|
121
|
-
BTC = "BTC",
|
|
122
|
-
CKB = "CKB"
|
|
123
|
-
}
|
|
124
171
|
/**
|
|
125
172
|
* A class representing information about a signer, including its type and the signer instance.
|
|
126
173
|
*/
|
|
127
174
|
export declare class SignerInfo {
|
|
128
175
|
name: string;
|
|
129
|
-
type: SignerType;
|
|
130
176
|
signer: Signer;
|
|
131
|
-
constructor(name: string,
|
|
177
|
+
constructor(name: string, signer: Signer);
|
|
132
178
|
}
|
|
133
179
|
/**
|
|
134
180
|
* Represents a wallet with a name, icon, and an array of signer information.
|
|
@@ -137,4 +183,4 @@ export type Wallet = {
|
|
|
137
183
|
name: string;
|
|
138
184
|
icon: string;
|
|
139
185
|
};
|
|
140
|
-
//# sourceMappingURL=
|
|
186
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerInfo = exports.SignerType = exports.
|
|
3
|
+
exports.SignerInfo = exports.Signer = exports.Signature = exports.SignerType = exports.SignerSignType = void 0;
|
|
4
|
+
const btc_1 = require("../btc");
|
|
5
|
+
const verifyJoyId_1 = require("../ckb/verifyJoyId");
|
|
6
|
+
const verify_1 = require("../evm/verify");
|
|
7
|
+
var SignerSignType;
|
|
8
|
+
(function (SignerSignType) {
|
|
9
|
+
SignerSignType["Unknown"] = "Unknown";
|
|
10
|
+
SignerSignType["BtcEcdsa"] = "BtcEcdsa";
|
|
11
|
+
SignerSignType["EvmPersonal"] = "EvmPersonal";
|
|
12
|
+
SignerSignType["JoyId"] = "JoyId";
|
|
13
|
+
})(SignerSignType || (exports.SignerSignType = SignerSignType = {}));
|
|
14
|
+
/**
|
|
15
|
+
* An enumeration of signer display types in wallet.
|
|
16
|
+
*/
|
|
17
|
+
var SignerType;
|
|
18
|
+
(function (SignerType) {
|
|
19
|
+
SignerType["EVM"] = "EVM";
|
|
20
|
+
SignerType["BTC"] = "BTC";
|
|
21
|
+
SignerType["CKB"] = "CKB";
|
|
22
|
+
})(SignerType || (exports.SignerType = SignerType = {}));
|
|
23
|
+
class Signature {
|
|
24
|
+
constructor(signature, identity, signType) {
|
|
25
|
+
this.signature = signature;
|
|
26
|
+
this.identity = identity;
|
|
27
|
+
this.signType = signType;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Signature = Signature;
|
|
4
31
|
/**
|
|
5
32
|
* An abstract class representing a generic signer.
|
|
6
33
|
* This class provides methods to connect, get addresses, and sign transactions.
|
|
@@ -12,12 +39,32 @@ class Signer {
|
|
|
12
39
|
get client() {
|
|
13
40
|
return this.client_;
|
|
14
41
|
}
|
|
42
|
+
static async verifyMessage(message, signature) {
|
|
43
|
+
switch (signature.signType) {
|
|
44
|
+
case SignerSignType.EvmPersonal:
|
|
45
|
+
return (0, verify_1.verifyMessageEvmPersonal)(message, signature.signature, signature.identity);
|
|
46
|
+
case SignerSignType.BtcEcdsa:
|
|
47
|
+
return (0, btc_1.verifyMessageBtcEcdsa)(message, signature.signature, signature.identity);
|
|
48
|
+
case SignerSignType.JoyId:
|
|
49
|
+
return (0, verifyJoyId_1.verifyMessageJoyId)(message, signature.signature, signature.identity);
|
|
50
|
+
case SignerSignType.Unknown:
|
|
51
|
+
throw new Error("Unknown signer sign type");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
15
54
|
/**
|
|
16
55
|
* Disconnects to the signer.
|
|
17
56
|
*
|
|
18
57
|
* @returns A promise that resolves when disconnected.
|
|
19
58
|
*/
|
|
20
59
|
async disconnect() { }
|
|
60
|
+
/**
|
|
61
|
+
* Gets the identity for verifying signature, usually it's address
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise that resolves to a string representing the identity
|
|
64
|
+
*/
|
|
65
|
+
async getIdentity() {
|
|
66
|
+
return this.getInternalAddress();
|
|
67
|
+
}
|
|
21
68
|
/**
|
|
22
69
|
* Gets the recommended Address object for the signer.
|
|
23
70
|
*
|
|
@@ -53,14 +100,57 @@ class Signer {
|
|
|
53
100
|
return this.client.getBalance((await this.getAddressObjs()).map(({ script }) => script));
|
|
54
101
|
}
|
|
55
102
|
/**
|
|
56
|
-
* Signs a message.
|
|
103
|
+
* Signs a message.
|
|
57
104
|
*
|
|
58
105
|
* @param _ - The message to sign, as a string or BytesLike object.
|
|
59
|
-
* @returns A promise that resolves to the
|
|
106
|
+
* @returns A promise that resolves to the signature info.
|
|
60
107
|
* @throws Will throw an error if not implemented.
|
|
61
108
|
*/
|
|
62
|
-
signMessage(
|
|
63
|
-
|
|
109
|
+
async signMessage(message) {
|
|
110
|
+
return {
|
|
111
|
+
signature: await this.signMessageRaw(message),
|
|
112
|
+
identity: await this.getIdentity(),
|
|
113
|
+
signType: this.signType,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Signs a message and returns signature only. This method is not implemented and should be overridden by subclasses.
|
|
118
|
+
*
|
|
119
|
+
* @param _ - The message to sign, as a string or BytesLike object.
|
|
120
|
+
* @returns A promise that resolves to the signature as a string.
|
|
121
|
+
* @throws Will throw an error if not implemented.
|
|
122
|
+
*/
|
|
123
|
+
signMessageRaw(_) {
|
|
124
|
+
throw Error("Signer.signMessageRaw not implemented");
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Verify a signature.
|
|
128
|
+
*
|
|
129
|
+
* @param _ - The original message.
|
|
130
|
+
* @param _ - The signature to verify.
|
|
131
|
+
* @returns A promise that resolves to the verification result.
|
|
132
|
+
* @throws Will throw an error if not implemented.
|
|
133
|
+
*/
|
|
134
|
+
async verifyMessage(message, signature) {
|
|
135
|
+
if (typeof signature === "string") {
|
|
136
|
+
return this.verifyMessageRaw(message, signature);
|
|
137
|
+
}
|
|
138
|
+
if (signature.identity !== (await this.getIdentity()) ||
|
|
139
|
+
![SignerSignType.Unknown, this.signType].includes(signature.signType)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return this.verifyMessageRaw(message, signature.signature);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Verify a string signature. This method is not implemented and should be overridden by subclasses.
|
|
146
|
+
*
|
|
147
|
+
* @param _0 - The original message.
|
|
148
|
+
* @param _1 - The signature to verify.
|
|
149
|
+
* @returns A promise that resolves to the verification result.
|
|
150
|
+
* @throws Will throw an error if not implemented.
|
|
151
|
+
*/
|
|
152
|
+
verifyMessageRaw(_0, _1) {
|
|
153
|
+
throw Error("Signer.verifyMessageRaw not implemented");
|
|
64
154
|
}
|
|
65
155
|
/**
|
|
66
156
|
* Sends a transaction after signing it.
|
|
@@ -92,7 +182,7 @@ class Signer {
|
|
|
92
182
|
throw Error("Signer.prepareTransaction not implemented");
|
|
93
183
|
}
|
|
94
184
|
/**
|
|
95
|
-
* Signs a transaction without
|
|
185
|
+
* Signs a transaction without preparing information for it. This method is not implemented and should be overridden by subclasses.
|
|
96
186
|
*
|
|
97
187
|
* @param _ - The transaction to sign, represented as a TransactionLike object.
|
|
98
188
|
* @returns A promise that resolves to the signed Transaction object.
|
|
@@ -103,22 +193,12 @@ class Signer {
|
|
|
103
193
|
}
|
|
104
194
|
}
|
|
105
195
|
exports.Signer = Signer;
|
|
106
|
-
/**
|
|
107
|
-
* An enumeration of signer types.
|
|
108
|
-
*/
|
|
109
|
-
var SignerType;
|
|
110
|
-
(function (SignerType) {
|
|
111
|
-
SignerType["EVM"] = "EVM";
|
|
112
|
-
SignerType["BTC"] = "BTC";
|
|
113
|
-
SignerType["CKB"] = "CKB";
|
|
114
|
-
})(SignerType || (exports.SignerType = SignerType = {}));
|
|
115
196
|
/**
|
|
116
197
|
* A class representing information about a signer, including its type and the signer instance.
|
|
117
198
|
*/
|
|
118
199
|
class SignerInfo {
|
|
119
|
-
constructor(name,
|
|
200
|
+
constructor(name, signer) {
|
|
120
201
|
this.name = name;
|
|
121
|
-
this.type = type;
|
|
122
202
|
this.signer = signer;
|
|
123
203
|
}
|
|
124
204
|
}
|
|
@@ -4,4 +4,5 @@ export declare function apply<T, R>(transformer: (val: T) => R, value: T): R;
|
|
|
4
4
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | undefined): R | undefined;
|
|
5
5
|
export declare function apply<T, R>(transformer: (val: T) => R, value: T | null): R | null;
|
|
6
6
|
export declare function apply<T, R>(transformer: (val: T) => R, value: undefined | null): undefined | null;
|
|
7
|
+
export declare function isWebview(userAgent: string): boolean;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;AAC3E,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,SAAS,GACnB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,IAAI,GACd,CAAC,GAAG,IAAI,CAAC;AACZ,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,SAAS,GAAG,IAAI,CAAC;AAYpB,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|