@ckb-ccc/joy-id 0.0.5-alpha.1 → 0.0.5-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/btc/index.d.ts +1 -2
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +1 -4
- package/dist/ckb/index.d.ts +4 -1
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +41 -15
- package/dist/evm/index.d.ts +1 -2
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +1 -4
- package/dist/signerFactory/index.d.ts.map +1 -1
- package/dist/signerFactory/index.js +7 -5
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +40 -19
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/btc/index.d.ts +22 -16
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +99 -76
- package/dist.commonjs/ckb/index.d.ts +33 -23
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +204 -135
- package/dist.commonjs/common/index.d.ts +34 -21
- package/dist.commonjs/common/index.js +50 -45
- package/dist.commonjs/connectionsStorage/index.d.ts +23 -14
- package/dist.commonjs/connectionsStorage/index.js +28 -25
- package/dist.commonjs/evm/index.d.ts +21 -16
- package/dist.commonjs/evm/index.d.ts.map +1 -1
- package/dist.commonjs/evm/index.js +89 -70
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +40 -19
- package/dist.commonjs/signerFactory/index.d.ts +6 -2
- package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
- package/dist.commonjs/signerFactory/index.js +39 -26
- package/package.json +3 -3
- package/src/btc/index.ts +1 -12
- package/src/ckb/index.ts +55 -22
- package/src/evm/index.ts +1 -11
- package/src/signerFactory/index.ts +14 -5
- package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
package/dist/btc/index.d.ts
CHANGED
|
@@ -9,12 +9,11 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
9
9
|
private connection?;
|
|
10
10
|
private assertConnection;
|
|
11
11
|
constructor(client: ccc.Client, name: string, icon: string, addressType?: "auto" | "p2wpkh" | "p2tr", appUri?: string, connectionsRepo?: ConnectionsRepo);
|
|
12
|
-
replaceClient(client: ccc.Client): Promise<BitcoinSigner>;
|
|
13
12
|
private getConfig;
|
|
14
13
|
getBtcAccount(): Promise<string>;
|
|
15
14
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
16
15
|
connect(): Promise<void>;
|
|
17
16
|
isConnected(): Promise<boolean>;
|
|
18
|
-
|
|
17
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/btc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;IAa5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhBlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAChD,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;IAa5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhBlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAChD,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;IAKvF,OAAO,CAAC,SAAS;IAUX,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAKnC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+BxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAY/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBvE"}
|
package/dist/btc/index.js
CHANGED
|
@@ -17,9 +17,6 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
17
17
|
this.appUri = appUri;
|
|
18
18
|
this.connectionsRepo = connectionsRepo;
|
|
19
19
|
}
|
|
20
|
-
async replaceClient(client) {
|
|
21
|
-
return new BitcoinSigner(client, this.name, this.icon, this.addressType, this.appUri, this.connectionsRepo);
|
|
22
|
-
}
|
|
23
20
|
getConfig() {
|
|
24
21
|
return {
|
|
25
22
|
redirectURL: location.href,
|
|
@@ -69,7 +66,7 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
69
66
|
});
|
|
70
67
|
return this.connection !== undefined;
|
|
71
68
|
}
|
|
72
|
-
async
|
|
69
|
+
async signMessageRaw(message) {
|
|
73
70
|
const { address } = this.assertConnection();
|
|
74
71
|
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
75
72
|
const config = this.getConfig();
|
package/dist/ckb/index.d.ts
CHANGED
|
@@ -6,21 +6,24 @@ export declare class CkbSigner extends ccc.Signer {
|
|
|
6
6
|
private readonly _appUri?;
|
|
7
7
|
private readonly _aggregatorUri?;
|
|
8
8
|
private readonly connectionsRepo;
|
|
9
|
+
get type(): ccc.SignerType;
|
|
10
|
+
get signType(): ccc.SignerSignType;
|
|
9
11
|
private connection?;
|
|
10
12
|
private assertConnection;
|
|
11
13
|
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
12
|
-
replaceClient(client: ccc.Client): Promise<CkbSigner>;
|
|
13
14
|
private getConfig;
|
|
14
15
|
private getAggregatorUri;
|
|
15
16
|
connect(): Promise<void>;
|
|
16
17
|
disconnect(): Promise<void>;
|
|
17
18
|
isConnected(): Promise<boolean>;
|
|
18
19
|
getInternalAddress(): Promise<string>;
|
|
20
|
+
getIdentity(): Promise<string>;
|
|
19
21
|
getAddressObj(): Promise<ccc.Address>;
|
|
20
22
|
getAddressObjs(): Promise<ccc.Address[]>;
|
|
21
23
|
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
22
24
|
private prepareTransactionForSubKey;
|
|
23
25
|
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
26
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
24
27
|
private saveConnection;
|
|
25
28
|
private restoreConnection;
|
|
26
29
|
}
|
package/dist/ckb/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;IAqBrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAxBlC,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAEzB;IAED,IAAI,QAAQ,IAAI,GAAG,CAAC,cAAc,CAEjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAa;YAElB,gBAAgB;gBAS5B,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,oBAAQ,EAChB,cAAc,CAAC,oBAAQ,EACvB,eAAe,GAAE,eAAmD;IAKvF,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,gBAAgB;IAUlB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ9B,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAOrC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAIxC,kBAAkB,CACtB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;YAkBb,2BAA2B;IAuCnC,mBAAmB,CACvB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAyBrB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;YA2BxD,cAAc;YAUd,iBAAiB;CAMhC"}
|
package/dist/ckb/index.js
CHANGED
|
@@ -4,6 +4,12 @@ import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
|
4
4
|
import { createPopup } from "../common";
|
|
5
5
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage";
|
|
6
6
|
export class CkbSigner extends ccc.Signer {
|
|
7
|
+
get type() {
|
|
8
|
+
return ccc.SignerType.CKB;
|
|
9
|
+
}
|
|
10
|
+
get signType() {
|
|
11
|
+
return ccc.SignerSignType.JoyId;
|
|
12
|
+
}
|
|
7
13
|
async assertConnection() {
|
|
8
14
|
if (!(await this.isConnected()) || !this.connection) {
|
|
9
15
|
throw new Error("Not connected");
|
|
@@ -18,30 +24,26 @@ export class CkbSigner extends ccc.Signer {
|
|
|
18
24
|
this._aggregatorUri = _aggregatorUri;
|
|
19
25
|
this.connectionsRepo = connectionsRepo;
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
return new CkbSigner(client, this.name, this.icon, this._appUri, this._aggregatorUri, this.connectionsRepo);
|
|
23
|
-
}
|
|
24
|
-
async getConfig() {
|
|
27
|
+
getConfig() {
|
|
25
28
|
return {
|
|
26
29
|
redirectURL: location.href,
|
|
27
|
-
joyidAppURL: this._appUri ??
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: "https://testnet.joyid.dev"),
|
|
30
|
+
joyidAppURL: this._appUri ?? this.client.addressPrefix === "ckb"
|
|
31
|
+
? "https://app.joy.id"
|
|
32
|
+
: "https://testnet.joyid.dev",
|
|
31
33
|
name: this.name,
|
|
32
34
|
logo: this.icon,
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
getAggregatorUri() {
|
|
36
38
|
if (this._aggregatorUri) {
|
|
37
39
|
return this._aggregatorUri;
|
|
38
40
|
}
|
|
39
|
-
return
|
|
41
|
+
return this.client.addressPrefix === "ckb"
|
|
40
42
|
? "https://cota.nervina.dev/mainnet-aggregator"
|
|
41
43
|
: "https://cota.nervina.dev/aggregator";
|
|
42
44
|
}
|
|
43
45
|
async connect() {
|
|
44
|
-
const config =
|
|
46
|
+
const config = this.getConfig();
|
|
45
47
|
const res = await createPopup(buildJoyIDURL(config, "popup", "/auth"), {
|
|
46
48
|
...config,
|
|
47
49
|
type: DappRequestType.Auth,
|
|
@@ -67,6 +69,13 @@ export class CkbSigner extends ccc.Signer {
|
|
|
67
69
|
async getInternalAddress() {
|
|
68
70
|
return (await this.assertConnection()).address;
|
|
69
71
|
}
|
|
72
|
+
async getIdentity() {
|
|
73
|
+
const connection = await this.assertConnection();
|
|
74
|
+
return JSON.stringify({
|
|
75
|
+
keyType: connection.keyType,
|
|
76
|
+
publicKey: connection.publicKey.slice(2),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
70
79
|
async getAddressObj() {
|
|
71
80
|
return await ccc.Address.fromString(await this.getInternalAddress(), this.client);
|
|
72
81
|
}
|
|
@@ -82,7 +91,8 @@ export class CkbSigner extends ccc.Signer {
|
|
|
82
91
|
const witness = tx.getWitnessArgsAt(position) ?? ccc.WitnessArgs.from({});
|
|
83
92
|
witness.lock = "0x";
|
|
84
93
|
await this.prepareTransactionForSubKey(tx, witness);
|
|
85
|
-
|
|
94
|
+
tx.setWitnessArgsAt(position, witness);
|
|
95
|
+
return tx;
|
|
86
96
|
}
|
|
87
97
|
async prepareTransactionForSubKey(tx, witness) {
|
|
88
98
|
if (this.connection?.keyType !== "sub_key") {
|
|
@@ -115,7 +125,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
115
125
|
async signOnlyTransaction(txLike) {
|
|
116
126
|
const tx = ccc.Transaction.from(txLike);
|
|
117
127
|
const { script } = await this.getAddressObj();
|
|
118
|
-
const config =
|
|
128
|
+
const config = this.getConfig();
|
|
119
129
|
const res = await createPopup(buildJoyIDURL({
|
|
120
130
|
...config,
|
|
121
131
|
tx: JSON.parse(tx.stringify()),
|
|
@@ -127,15 +137,31 @@ export class CkbSigner extends ccc.Signer {
|
|
|
127
137
|
});
|
|
128
138
|
return ccc.Transaction.from(res.tx);
|
|
129
139
|
}
|
|
140
|
+
async signMessageRaw(message) {
|
|
141
|
+
const { address } = await this.assertConnection();
|
|
142
|
+
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
143
|
+
const config = this.getConfig();
|
|
144
|
+
const res = await createPopup(buildJoyIDURL({
|
|
145
|
+
...config,
|
|
146
|
+
challenge,
|
|
147
|
+
isData: typeof message !== "string",
|
|
148
|
+
address,
|
|
149
|
+
}, "popup", "/sign-message"), { ...config, type: DappRequestType.SignMessage });
|
|
150
|
+
return JSON.stringify({
|
|
151
|
+
signature: res.signature,
|
|
152
|
+
alg: res.alg,
|
|
153
|
+
message: res.message,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
130
156
|
async saveConnection() {
|
|
131
157
|
return this.connectionsRepo.set({
|
|
132
|
-
uri:
|
|
158
|
+
uri: this.getConfig().joyidAppURL,
|
|
133
159
|
addressType: "ckb",
|
|
134
160
|
}, this.connection);
|
|
135
161
|
}
|
|
136
162
|
async restoreConnection() {
|
|
137
163
|
this.connection = await this.connectionsRepo.get({
|
|
138
|
-
uri:
|
|
164
|
+
uri: this.getConfig().joyidAppURL,
|
|
139
165
|
addressType: "ckb",
|
|
140
166
|
});
|
|
141
167
|
}
|
package/dist/evm/index.d.ts
CHANGED
|
@@ -8,12 +8,11 @@ export declare class EvmSigner extends ccc.SignerEvm {
|
|
|
8
8
|
private connection?;
|
|
9
9
|
private assertConnection;
|
|
10
10
|
constructor(client: ccc.Client, name: string, icon: string, appUri?: string, connectionsRepo?: ConnectionsRepo);
|
|
11
|
-
replaceClient(client: ccc.Client): Promise<EvmSigner>;
|
|
12
11
|
private getConfig;
|
|
13
12
|
getEvmAccount(): Promise<string>;
|
|
14
13
|
connect(): Promise<void>;
|
|
15
14
|
isConnected(): Promise<boolean>;
|
|
16
|
-
|
|
15
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<ccc.Hex>;
|
|
17
16
|
private saveConnection;
|
|
18
17
|
private restoreConnection;
|
|
19
18
|
}
|
package/dist/evm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;IAaxC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAflC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,SAAS;IAaxC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAflC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;IAKvF,OAAO,CAAC,SAAS;IAUX,aAAa;IAIb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQ/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;YAuBzD,cAAc;YAUd,iBAAiB;CAMhC"}
|
package/dist/evm/index.js
CHANGED
|
@@ -16,9 +16,6 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
16
16
|
this.appUri = appUri;
|
|
17
17
|
this.connectionsRepo = connectionsRepo;
|
|
18
18
|
}
|
|
19
|
-
async replaceClient(client) {
|
|
20
|
-
return new EvmSigner(client, this.name, this.icon, this.appUri, this.connectionsRepo);
|
|
21
|
-
}
|
|
22
19
|
getConfig() {
|
|
23
20
|
return {
|
|
24
21
|
redirectURL: location.href,
|
|
@@ -51,7 +48,7 @@ export class EvmSigner extends ccc.SignerEvm {
|
|
|
51
48
|
await this.restoreConnection();
|
|
52
49
|
return this.connection !== undefined;
|
|
53
50
|
}
|
|
54
|
-
async
|
|
51
|
+
async signMessageRaw(message) {
|
|
55
52
|
const { address } = this.assertConnection();
|
|
56
53
|
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
57
54
|
const config = this.getConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signerFactory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMpC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,UAAU,EAAE,CAoClB"}
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
|
+
import { isStandaloneBrowser } from "@joyid/common";
|
|
2
3
|
import { BitcoinSigner } from "../btc";
|
|
3
4
|
import { CkbSigner } from "../ckb";
|
|
4
5
|
import { EvmSigner } from "../evm";
|
|
5
6
|
export function getJoyIdSigners(client, name, icon) {
|
|
7
|
+
if (isStandaloneBrowser() || ccc.isWebview(window.navigator.userAgent)) {
|
|
8
|
+
return [ccc.SignerType.CKB, ccc.SignerType.EVM, ccc.SignerType.BTC].map((type) => ({
|
|
9
|
+
name: type,
|
|
10
|
+
signer: new ccc.SignerAlwaysError(client, type, "JoyID can only be used with standard browsers"),
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
6
13
|
return [
|
|
7
14
|
{
|
|
8
|
-
type: ccc.SignerType.CKB,
|
|
9
15
|
name: "CKB",
|
|
10
16
|
signer: new CkbSigner(client, name, icon),
|
|
11
17
|
},
|
|
12
18
|
{
|
|
13
|
-
type: ccc.SignerType.BTC,
|
|
14
19
|
name: "BTC",
|
|
15
20
|
signer: new BitcoinSigner(client, name, icon),
|
|
16
21
|
},
|
|
17
22
|
{
|
|
18
|
-
type: ccc.SignerType.EVM,
|
|
19
23
|
name: "EVM",
|
|
20
24
|
signer: new EvmSigner(client, name, icon),
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
|
-
type: ccc.SignerType.BTC,
|
|
24
27
|
name: "BTC (P2WPKH)",
|
|
25
28
|
signer: new BitcoinSigner(client, name, icon, "p2wpkh"),
|
|
26
29
|
},
|
|
27
30
|
{
|
|
28
|
-
type: ccc.SignerType.BTC,
|
|
29
31
|
name: "BTC (P2TR)",
|
|
30
32
|
signer: new BitcoinSigner(client, name, icon, "p2tr"),
|
|
31
33
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as JoyIdA from "./advancedBarrel";
|
|
2
|
-
//# sourceMappingURL=advanced.d.ts.map
|
|
2
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __setModuleDefault =
|
|
26
|
+
(this && this.__setModuleDefault) ||
|
|
27
|
+
(Object.create
|
|
28
|
+
? function (o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}
|
|
31
|
+
: function (o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar =
|
|
35
|
+
(this && this.__importStar) ||
|
|
36
|
+
function (mod) {
|
|
19
37
|
if (mod && mod.__esModule) return mod;
|
|
20
38
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
39
|
+
if (mod != null)
|
|
40
|
+
for (var k in mod)
|
|
41
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
+
__createBinding(result, mod, k);
|
|
22
43
|
__setModuleDefault(result, mod);
|
|
23
44
|
return result;
|
|
24
|
-
};
|
|
45
|
+
};
|
|
25
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
47
|
exports.JoyIdA = void 0;
|
|
27
48
|
exports.JoyIdA = __importStar(require("./advancedBarrel"));
|
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __exportStar =
|
|
26
|
+
(this && this.__exportStar) ||
|
|
27
|
+
function (m, exports) {
|
|
28
|
+
for (var p in m)
|
|
29
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
+
__createBinding(exports, m, p);
|
|
31
|
+
};
|
|
16
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
33
|
__exportStar(require("./common"), exports);
|
|
18
34
|
__exportStar(require("./connectionsStorage"), exports);
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __exportStar =
|
|
26
|
+
(this && this.__exportStar) ||
|
|
27
|
+
function (m, exports) {
|
|
28
|
+
for (var p in m)
|
|
29
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
+
__createBinding(exports, m, p);
|
|
31
|
+
};
|
|
16
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
33
|
__exportStar(require("./btc"), exports);
|
|
18
34
|
__exportStar(require("./ckb"), exports);
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
3
|
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
private readonly name;
|
|
5
|
+
private readonly icon;
|
|
6
|
+
private readonly addressType;
|
|
7
|
+
private readonly appUri;
|
|
8
|
+
private readonly connectionsRepo;
|
|
9
|
+
private connection?;
|
|
10
|
+
private assertConnection;
|
|
11
|
+
constructor(
|
|
12
|
+
client: ccc.Client,
|
|
13
|
+
name: string,
|
|
14
|
+
icon: string,
|
|
15
|
+
addressType?: "auto" | "p2wpkh" | "p2tr",
|
|
16
|
+
appUri?: string,
|
|
17
|
+
connectionsRepo?: ConnectionsRepo,
|
|
18
|
+
);
|
|
19
|
+
private getConfig;
|
|
20
|
+
getBtcAccount(): Promise<string>;
|
|
21
|
+
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
22
|
+
connect(): Promise<void>;
|
|
23
|
+
isConnected(): Promise<boolean>;
|
|
24
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
19
25
|
}
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;IAa5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhBlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAChD,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/btc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;IAa5C,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAhBlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,OAAO,CAAC,gBAAgB;gBAStB,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAM,GAAG,QAAQ,GAAG,MAAe,EAChD,MAAM,SAAuB,EAC7B,eAAe,GAAE,eAAmD;IAKvF,OAAO,CAAC,SAAS;IAUX,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAKnC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+BxB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAY/B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBvE"}
|