@ckb-ccc/joy-id 0.0.5-alpha.8 → 0.0.7-alpha.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/dist/btc/index.d.ts +46 -1
- package/dist/btc/index.d.ts.map +1 -1
- package/dist/btc/index.js +46 -3
- package/dist/ckb/index.d.ts +94 -2
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +115 -14
- package/dist/common/index.d.ts +13 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +9 -0
- package/dist/connectionsStorage/index.d.ts +58 -0
- package/dist/connectionsStorage/index.d.ts.map +1 -1
- package/dist/connectionsStorage/index.js +30 -0
- package/dist/evm/index.d.ts +51 -1
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +52 -4
- package/dist/nostr/index.d.ts +51 -0
- package/dist/nostr/index.d.ts.map +1 -0
- package/dist/nostr/index.js +106 -0
- package/dist/signerFactory/index.d.ts +9 -0
- package/dist/signerFactory/index.d.ts.map +1 -1
- package/dist/signerFactory/index.js +14 -0
- 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 +68 -16
- package/dist.commonjs/btc/index.d.ts.map +1 -1
- package/dist.commonjs/btc/index.js +145 -76
- package/dist.commonjs/ckb/index.d.ts +126 -27
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +312 -154
- package/dist.commonjs/common/index.d.ts +47 -21
- package/dist.commonjs/common/index.d.ts.map +1 -1
- package/dist.commonjs/common/index.js +59 -45
- package/dist.commonjs/connectionsStorage/index.d.ts +81 -14
- package/dist.commonjs/connectionsStorage/index.d.ts.map +1 -1
- package/dist.commonjs/connectionsStorage/index.js +58 -25
- package/dist.commonjs/evm/index.d.ts +72 -16
- package/dist.commonjs/evm/index.d.ts.map +1 -1
- package/dist.commonjs/evm/index.js +140 -70
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +40 -19
- package/dist.commonjs/nostr/index.d.ts +57 -0
- package/dist.commonjs/nostr/index.d.ts.map +1 -0
- package/dist.commonjs/nostr/index.js +129 -0
- package/dist.commonjs/signerFactory/index.d.ts +15 -2
- package/dist.commonjs/signerFactory/index.d.ts.map +1 -1
- package/dist.commonjs/signerFactory/index.js +52 -27
- package/package.json +5 -5
- package/src/btc/index.ts +47 -12
- package/src/ckb/index.ts +127 -25
- package/src/common/index.ts +13 -0
- package/src/connectionsStorage/index.ts +64 -2
- package/src/evm/index.ts +56 -15
- package/src/nostr/index.ts +135 -0
- package/src/signerFactory/index.ts +14 -0
package/dist/btc/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.SignerBtc}
|
|
7
|
+
*/
|
|
3
8
|
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
4
9
|
private readonly name;
|
|
5
10
|
private readonly icon;
|
|
@@ -7,14 +12,54 @@ export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
|
7
12
|
private readonly appUri;
|
|
8
13
|
private readonly connectionsRepo;
|
|
9
14
|
private connection?;
|
|
15
|
+
/**
|
|
16
|
+
* Ensures that the signer is connected and returns the connection.
|
|
17
|
+
* @private
|
|
18
|
+
* @throws Will throw an error if not connected.
|
|
19
|
+
* @returns {Connection} The current connection.
|
|
20
|
+
*/
|
|
10
21
|
private assertConnection;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of BitcoinSigner.
|
|
24
|
+
* @param {ccc.Client} client - The client instance.
|
|
25
|
+
* @param {string} name - The name of the signer.
|
|
26
|
+
* @param {string} icon - The icon URL of the signer.
|
|
27
|
+
* @param {"auto" | "p2wpkh" | "p2tr"} [addressType="auto"] - The address type.
|
|
28
|
+
* @param {string} [appUri="https://app.joy.id"] - The application URI.
|
|
29
|
+
* @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
|
|
30
|
+
*/
|
|
11
31
|
constructor(client: ccc.Client, name: string, icon: string, addressType?: "auto" | "p2wpkh" | "p2tr", appUri?: string, connectionsRepo?: ConnectionsRepo);
|
|
12
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Gets the configuration for JoyID.
|
|
34
|
+
* @private
|
|
35
|
+
* @returns {object} The configuration object.
|
|
36
|
+
*/
|
|
13
37
|
private getConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the Bitcoin account address.
|
|
40
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
41
|
+
*/
|
|
14
42
|
getBtcAccount(): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the Bitcoin public key.
|
|
45
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
46
|
+
*/
|
|
15
47
|
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
48
|
+
/**
|
|
49
|
+
* Connects to the provider by requesting authentication.
|
|
50
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
51
|
+
*/
|
|
16
52
|
connect(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Checks if the signer is connected.
|
|
55
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
56
|
+
*/
|
|
17
57
|
isConnected(): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Signs a raw message with the Bitcoin account.
|
|
60
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
61
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
62
|
+
*/
|
|
18
63
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
19
64
|
}
|
|
20
65
|
//# 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;
|
|
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;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,GAAG,CAAC,SAAS;IA4B5C,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;IA/BlC,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;OAQG;gBAED,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;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAUjB;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtC;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAKzC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAYrC;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAsBvE"}
|
package/dist/btc/index.js
CHANGED
|
@@ -2,13 +2,33 @@ import { ccc } from "@ckb-ccc/core";
|
|
|
2
2
|
import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
3
3
|
import { createPopup } from "../common";
|
|
4
4
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage";
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Bitcoin signer that extends SignerBtc from @ckb-ccc/core.
|
|
7
|
+
* @class
|
|
8
|
+
* @extends {ccc.SignerBtc}
|
|
9
|
+
*/
|
|
5
10
|
export class BitcoinSigner extends ccc.SignerBtc {
|
|
11
|
+
/**
|
|
12
|
+
* Ensures that the signer is connected and returns the connection.
|
|
13
|
+
* @private
|
|
14
|
+
* @throws Will throw an error if not connected.
|
|
15
|
+
* @returns {Connection} The current connection.
|
|
16
|
+
*/
|
|
6
17
|
assertConnection() {
|
|
7
18
|
if (!this.isConnected() || !this.connection) {
|
|
8
19
|
throw new Error("Not connected");
|
|
9
20
|
}
|
|
10
21
|
return this.connection;
|
|
11
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of BitcoinSigner.
|
|
25
|
+
* @param {ccc.Client} client - The client instance.
|
|
26
|
+
* @param {string} name - The name of the signer.
|
|
27
|
+
* @param {string} icon - The icon URL of the signer.
|
|
28
|
+
* @param {"auto" | "p2wpkh" | "p2tr"} [addressType="auto"] - The address type.
|
|
29
|
+
* @param {string} [appUri="https://app.joy.id"] - The application URI.
|
|
30
|
+
* @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
|
|
31
|
+
*/
|
|
12
32
|
constructor(client, name, icon, addressType = "auto", appUri = "https://app.joy.id", connectionsRepo = new ConnectionsRepoLocalStorage()) {
|
|
13
33
|
super(client);
|
|
14
34
|
this.name = name;
|
|
@@ -17,9 +37,11 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
17
37
|
this.appUri = appUri;
|
|
18
38
|
this.connectionsRepo = connectionsRepo;
|
|
19
39
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Gets the configuration for JoyID.
|
|
42
|
+
* @private
|
|
43
|
+
* @returns {object} The configuration object.
|
|
44
|
+
*/
|
|
23
45
|
getConfig() {
|
|
24
46
|
return {
|
|
25
47
|
redirectURL: location.href,
|
|
@@ -29,14 +51,26 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
29
51
|
logo: this.icon,
|
|
30
52
|
};
|
|
31
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the Bitcoin account address.
|
|
56
|
+
* @returns {Promise<string>} A promise that resolves to the Bitcoin account address.
|
|
57
|
+
*/
|
|
32
58
|
async getBtcAccount() {
|
|
33
59
|
const { address } = this.assertConnection();
|
|
34
60
|
return address;
|
|
35
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the Bitcoin public key.
|
|
64
|
+
* @returns {Promise<ccc.Hex>} A promise that resolves to the Bitcoin public key.
|
|
65
|
+
*/
|
|
36
66
|
async getBtcPublicKey() {
|
|
37
67
|
const { publicKey } = this.assertConnection();
|
|
38
68
|
return publicKey;
|
|
39
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Connects to the provider by requesting authentication.
|
|
72
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
73
|
+
*/
|
|
40
74
|
async connect() {
|
|
41
75
|
const config = this.getConfig();
|
|
42
76
|
const res = await createPopup(buildJoyIDURL(config, "popup", "/auth"), {
|
|
@@ -59,6 +93,10 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
59
93
|
this.connectionsRepo.set({ uri: this.appUri, addressType: "btc-auto" }, this.connection),
|
|
60
94
|
]);
|
|
61
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Checks if the signer is connected.
|
|
98
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
99
|
+
*/
|
|
62
100
|
async isConnected() {
|
|
63
101
|
if (this.connection) {
|
|
64
102
|
return true;
|
|
@@ -69,6 +107,11 @@ export class BitcoinSigner extends ccc.SignerBtc {
|
|
|
69
107
|
});
|
|
70
108
|
return this.connection !== undefined;
|
|
71
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Signs a raw message with the Bitcoin account.
|
|
112
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
113
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
114
|
+
*/
|
|
72
115
|
async signMessageRaw(message) {
|
|
73
116
|
const { address } = this.assertConnection();
|
|
74
117
|
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
package/dist/ckb/index.d.ts
CHANGED
|
@@ -1,31 +1,123 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
|
+
/**
|
|
4
|
+
* Class representing a CKB signer that extends Signer from @ckb-ccc/core.
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {ccc.Signer}
|
|
7
|
+
*/
|
|
3
8
|
export declare class CkbSigner extends ccc.Signer {
|
|
4
9
|
private readonly name;
|
|
5
10
|
private readonly icon;
|
|
6
11
|
private readonly _appUri?;
|
|
7
12
|
private readonly _aggregatorUri?;
|
|
8
13
|
private readonly connectionsRepo;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the signer type.
|
|
16
|
+
* @returns {ccc.SignerType} The type of the signer.
|
|
17
|
+
*/
|
|
9
18
|
get type(): ccc.SignerType;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the sign type.
|
|
21
|
+
* @returns {ccc.SignerSignType} The sign type.
|
|
22
|
+
*/
|
|
10
23
|
get signType(): ccc.SignerSignType;
|
|
11
24
|
private connection?;
|
|
25
|
+
/**
|
|
26
|
+
* Ensures that the signer is connected and returns the connection.
|
|
27
|
+
* @private
|
|
28
|
+
* @throws Will throw an error if not connected.
|
|
29
|
+
* @returns {Promise<Connection>} A promise that resolves to the current connection.
|
|
30
|
+
*/
|
|
12
31
|
private assertConnection;
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of CkbSigner.
|
|
34
|
+
* @param {ccc.Client} client - The client instance.
|
|
35
|
+
* @param {string} name - The name of the signer.
|
|
36
|
+
* @param {string} icon - The icon URL of the signer.
|
|
37
|
+
* @param {string} [_appUri] - The application URI.
|
|
38
|
+
* @param {string} [_aggregatorUri] - The aggregator URI.
|
|
39
|
+
* @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
|
|
40
|
+
*/
|
|
13
41
|
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
14
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Gets the configuration for JoyID.
|
|
44
|
+
* @private
|
|
45
|
+
* @returns {object} The configuration object.
|
|
46
|
+
*/
|
|
15
47
|
private getConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the aggregator URI.
|
|
50
|
+
* @private
|
|
51
|
+
* @returns {string} The aggregator URI.
|
|
52
|
+
*/
|
|
16
53
|
private getAggregatorUri;
|
|
54
|
+
/**
|
|
55
|
+
* Connects to the provider by requesting authentication.
|
|
56
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
57
|
+
*/
|
|
17
58
|
connect(): Promise<void>;
|
|
18
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Checks if the signer is connected.
|
|
61
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
62
|
+
*/
|
|
19
63
|
isConnected(): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the internal address.
|
|
66
|
+
* @returns {Promise<string>} A promise that resolves to the internal address.
|
|
67
|
+
*/
|
|
20
68
|
getInternalAddress(): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the identity of the signer.
|
|
71
|
+
* @returns {Promise<string>} A promise that resolves to the identity.
|
|
72
|
+
*/
|
|
21
73
|
getIdentity(): Promise<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the address object.
|
|
76
|
+
* @returns {Promise<ccc.Address>} A promise that resolves to the address object.
|
|
77
|
+
*/
|
|
22
78
|
getAddressObj(): Promise<ccc.Address>;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the address objects.
|
|
81
|
+
* @returns {Promise<ccc.Address[]>} A promise that resolves to an array of address objects.
|
|
82
|
+
*/
|
|
23
83
|
getAddressObjs(): Promise<ccc.Address[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Prepares a transaction.
|
|
86
|
+
* @param {ccc.TransactionLike} txLike - The transaction-like object.
|
|
87
|
+
* @returns {Promise<ccc.Transaction>} A promise that resolves to the prepared transaction.
|
|
88
|
+
*/
|
|
24
89
|
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
90
|
+
/**
|
|
91
|
+
* Prepares a transaction for a sub key.
|
|
92
|
+
* @private
|
|
93
|
+
* @param tx - The transaction object.
|
|
94
|
+
* @param witness - The witness arguments.
|
|
95
|
+
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
96
|
+
*/
|
|
25
97
|
private prepareTransactionForSubKey;
|
|
98
|
+
/**
|
|
99
|
+
* Signs a transaction.
|
|
100
|
+
* @param {ccc.TransactionLike} txLike - The transaction-like object.
|
|
101
|
+
* @returns {Promise<ccc.Transaction>} A promise that resolves to the signed transaction.
|
|
102
|
+
*/
|
|
26
103
|
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
104
|
+
/**
|
|
105
|
+
* Signs a raw message with the account.
|
|
106
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
107
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
108
|
+
*/
|
|
27
109
|
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Saves the current connection.
|
|
112
|
+
* @private
|
|
113
|
+
* @returns {Promise<void>}
|
|
114
|
+
*/
|
|
28
115
|
private saveConnection;
|
|
116
|
+
/**
|
|
117
|
+
* Restores the previous connection.
|
|
118
|
+
* @private
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
*/
|
|
29
121
|
private restoreConnection;
|
|
30
122
|
}
|
|
31
123
|
//# sourceMappingURL=index.d.ts.map
|
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;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;IA4CrC,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;IA/ClC;;;OAGG;IACH,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAEzB;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,GAAG,CAAC,cAAc,CAEjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC;;;;;OAKG;YACW,gBAAgB;IAQ9B;;;;;;;;OAQG;gBAED,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;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAYjB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB9B;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAQrC;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAQpC;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAO3C;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAI9C;;;;OAIG;IACG,kBAAkB,CACtB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAmB3B;;;;;;OAMG;YACW,2BAA2B;IAuCzC;;;;OAIG;IACG,mBAAmB,CACvB,MAAM,EAAE,GAAG,CAAC,eAAe,GAC1B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IA8C3B;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BtE;;;;OAIG;YACW,cAAc;IAU5B;;;;OAIG;YACW,iBAAiB;CAMhC"}
|
package/dist/ckb/index.js
CHANGED
|
@@ -3,19 +3,47 @@ import { Aggregator } from "@joyid/ckb";
|
|
|
3
3
|
import { DappRequestType, buildJoyIDURL } from "@joyid/common";
|
|
4
4
|
import { createPopup } from "../common";
|
|
5
5
|
import { ConnectionsRepoLocalStorage, } from "../connectionsStorage";
|
|
6
|
+
/**
|
|
7
|
+
* Class representing a CKB signer that extends Signer from @ckb-ccc/core.
|
|
8
|
+
* @class
|
|
9
|
+
* @extends {ccc.Signer}
|
|
10
|
+
*/
|
|
6
11
|
export class CkbSigner extends ccc.Signer {
|
|
12
|
+
/**
|
|
13
|
+
* Gets the signer type.
|
|
14
|
+
* @returns {ccc.SignerType} The type of the signer.
|
|
15
|
+
*/
|
|
7
16
|
get type() {
|
|
8
17
|
return ccc.SignerType.CKB;
|
|
9
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the sign type.
|
|
21
|
+
* @returns {ccc.SignerSignType} The sign type.
|
|
22
|
+
*/
|
|
10
23
|
get signType() {
|
|
11
24
|
return ccc.SignerSignType.JoyId;
|
|
12
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Ensures that the signer is connected and returns the connection.
|
|
28
|
+
* @private
|
|
29
|
+
* @throws Will throw an error if not connected.
|
|
30
|
+
* @returns {Promise<Connection>} A promise that resolves to the current connection.
|
|
31
|
+
*/
|
|
13
32
|
async assertConnection() {
|
|
14
33
|
if (!(await this.isConnected()) || !this.connection) {
|
|
15
34
|
throw new Error("Not connected");
|
|
16
35
|
}
|
|
17
36
|
return this.connection;
|
|
18
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates an instance of CkbSigner.
|
|
40
|
+
* @param {ccc.Client} client - The client instance.
|
|
41
|
+
* @param {string} name - The name of the signer.
|
|
42
|
+
* @param {string} icon - The icon URL of the signer.
|
|
43
|
+
* @param {string} [_appUri] - The application URI.
|
|
44
|
+
* @param {string} [_aggregatorUri] - The aggregator URI.
|
|
45
|
+
* @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
|
|
46
|
+
*/
|
|
19
47
|
constructor(client, name, icon, _appUri, _aggregatorUri, connectionsRepo = new ConnectionsRepoLocalStorage()) {
|
|
20
48
|
super(client);
|
|
21
49
|
this.name = name;
|
|
@@ -24,9 +52,11 @@ export class CkbSigner extends ccc.Signer {
|
|
|
24
52
|
this._aggregatorUri = _aggregatorUri;
|
|
25
53
|
this.connectionsRepo = connectionsRepo;
|
|
26
54
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Gets the configuration for JoyID.
|
|
57
|
+
* @private
|
|
58
|
+
* @returns {object} The configuration object.
|
|
59
|
+
*/
|
|
30
60
|
getConfig() {
|
|
31
61
|
return {
|
|
32
62
|
redirectURL: location.href,
|
|
@@ -37,6 +67,11 @@ export class CkbSigner extends ccc.Signer {
|
|
|
37
67
|
logo: this.icon,
|
|
38
68
|
};
|
|
39
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the aggregator URI.
|
|
72
|
+
* @private
|
|
73
|
+
* @returns {string} The aggregator URI.
|
|
74
|
+
*/
|
|
40
75
|
getAggregatorUri() {
|
|
41
76
|
if (this._aggregatorUri) {
|
|
42
77
|
return this._aggregatorUri;
|
|
@@ -45,6 +80,10 @@ export class CkbSigner extends ccc.Signer {
|
|
|
45
80
|
? "https://cota.nervina.dev/mainnet-aggregator"
|
|
46
81
|
: "https://cota.nervina.dev/aggregator";
|
|
47
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Connects to the provider by requesting authentication.
|
|
85
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established.
|
|
86
|
+
*/
|
|
48
87
|
async connect() {
|
|
49
88
|
const config = this.getConfig();
|
|
50
89
|
const res = await createPopup(buildJoyIDURL(config, "popup", "/auth"), {
|
|
@@ -58,10 +97,10 @@ export class CkbSigner extends ccc.Signer {
|
|
|
58
97
|
};
|
|
59
98
|
await this.saveConnection();
|
|
60
99
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Checks if the signer is connected.
|
|
102
|
+
* @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
|
|
103
|
+
*/
|
|
65
104
|
async isConnected() {
|
|
66
105
|
if (this.connection) {
|
|
67
106
|
return true;
|
|
@@ -69,9 +108,17 @@ export class CkbSigner extends ccc.Signer {
|
|
|
69
108
|
await this.restoreConnection();
|
|
70
109
|
return this.connection !== undefined;
|
|
71
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the internal address.
|
|
113
|
+
* @returns {Promise<string>} A promise that resolves to the internal address.
|
|
114
|
+
*/
|
|
72
115
|
async getInternalAddress() {
|
|
73
116
|
return (await this.assertConnection()).address;
|
|
74
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets the identity of the signer.
|
|
120
|
+
* @returns {Promise<string>} A promise that resolves to the identity.
|
|
121
|
+
*/
|
|
75
122
|
async getIdentity() {
|
|
76
123
|
const connection = await this.assertConnection();
|
|
77
124
|
return JSON.stringify({
|
|
@@ -79,23 +126,45 @@ export class CkbSigner extends ccc.Signer {
|
|
|
79
126
|
publicKey: connection.publicKey.slice(2),
|
|
80
127
|
});
|
|
81
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Gets the address object.
|
|
131
|
+
* @returns {Promise<ccc.Address>} A promise that resolves to the address object.
|
|
132
|
+
*/
|
|
82
133
|
async getAddressObj() {
|
|
83
134
|
return await ccc.Address.fromString(await this.getInternalAddress(), this.client);
|
|
84
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets the address objects.
|
|
138
|
+
* @returns {Promise<ccc.Address[]>} A promise that resolves to an array of address objects.
|
|
139
|
+
*/
|
|
85
140
|
async getAddressObjs() {
|
|
86
141
|
return [await this.getAddressObj()];
|
|
87
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Prepares a transaction.
|
|
145
|
+
* @param {ccc.TransactionLike} txLike - The transaction-like object.
|
|
146
|
+
* @returns {Promise<ccc.Transaction>} A promise that resolves to the prepared transaction.
|
|
147
|
+
*/
|
|
88
148
|
async prepareTransaction(txLike) {
|
|
89
149
|
const tx = ccc.Transaction.from(txLike);
|
|
150
|
+
await tx.addCellDepsOfKnownScripts(this.client, ccc.KnownScript.JoyId);
|
|
90
151
|
const position = await tx.findInputIndexByLock((await this.getAddressObj()).script, this.client);
|
|
91
152
|
if (position === undefined) {
|
|
92
153
|
return tx;
|
|
93
154
|
}
|
|
94
155
|
const witness = tx.getWitnessArgsAt(position) ?? ccc.WitnessArgs.from({});
|
|
95
|
-
witness.lock = "
|
|
156
|
+
witness.lock = ccc.hexFrom("00".repeat(1000));
|
|
96
157
|
await this.prepareTransactionForSubKey(tx, witness);
|
|
97
|
-
|
|
158
|
+
tx.setWitnessArgsAt(position, witness);
|
|
159
|
+
return tx;
|
|
98
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Prepares a transaction for a sub key.
|
|
163
|
+
* @private
|
|
164
|
+
* @param tx - The transaction object.
|
|
165
|
+
* @param witness - The witness arguments.
|
|
166
|
+
* @throws Will throw an error if no COTA cells are found for the sub key wallet.
|
|
167
|
+
*/
|
|
99
168
|
async prepareTransactionForSubKey(tx, witness) {
|
|
100
169
|
if (this.connection?.keyType !== "sub_key") {
|
|
101
170
|
return [];
|
|
@@ -110,10 +179,7 @@ export class CkbSigner extends ccc.Signer {
|
|
|
110
179
|
});
|
|
111
180
|
witness.outputType = ccc.hexFrom(unlockEntry);
|
|
112
181
|
const cotaDeps = [];
|
|
113
|
-
for await (const cell of this.client.findCellsByLockAndType(lock, {
|
|
114
|
-
...(await this.client.getKnownScript(ccc.KnownScript.COTA)),
|
|
115
|
-
args: "0x",
|
|
116
|
-
})) {
|
|
182
|
+
for await (const cell of this.client.findCellsByLockAndType(lock, await ccc.Script.fromKnownScript(this.client, ccc.KnownScript.COTA, "0x"))) {
|
|
117
183
|
cotaDeps.push(ccc.CellDep.from({
|
|
118
184
|
depType: "code",
|
|
119
185
|
outPoint: cell.outPoint,
|
|
@@ -124,21 +190,46 @@ export class CkbSigner extends ccc.Signer {
|
|
|
124
190
|
}
|
|
125
191
|
tx.cellDeps.unshift(...cotaDeps);
|
|
126
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Signs a transaction.
|
|
195
|
+
* @param {ccc.TransactionLike} txLike - The transaction-like object.
|
|
196
|
+
* @returns {Promise<ccc.Transaction>} A promise that resolves to the signed transaction.
|
|
197
|
+
*/
|
|
127
198
|
async signOnlyTransaction(txLike) {
|
|
128
199
|
const tx = ccc.Transaction.from(txLike);
|
|
129
200
|
const { script } = await this.getAddressObj();
|
|
201
|
+
const witnessIndexes = await ccc.reduceAsync(tx.inputs, async (acc, input, i) => {
|
|
202
|
+
await input.completeExtraInfos(this.client);
|
|
203
|
+
if (!input.cellOutput) {
|
|
204
|
+
throw new Error("Unable to complete input");
|
|
205
|
+
}
|
|
206
|
+
if (input.cellOutput.lock.eq(script)) {
|
|
207
|
+
acc.push(i);
|
|
208
|
+
}
|
|
209
|
+
}, []);
|
|
210
|
+
// Trim unnecessary fields to reduce tx size
|
|
211
|
+
await tx.prepareSighashAllWitness(script, 0, this.client);
|
|
212
|
+
tx.inputs.forEach((i) => {
|
|
213
|
+
i.cellOutput = undefined;
|
|
214
|
+
i.outputData = undefined;
|
|
215
|
+
});
|
|
130
216
|
const config = this.getConfig();
|
|
131
217
|
const res = await createPopup(buildJoyIDURL({
|
|
132
218
|
...config,
|
|
133
219
|
tx: JSON.parse(tx.stringify()),
|
|
134
220
|
signerAddress: (await this.assertConnection()).address,
|
|
135
|
-
|
|
221
|
+
witnessIndexes,
|
|
136
222
|
}, "popup", "/sign-ckb-raw-tx"), {
|
|
137
223
|
...config,
|
|
138
224
|
type: DappRequestType.SignCkbRawTx,
|
|
139
225
|
});
|
|
140
226
|
return ccc.Transaction.from(res.tx);
|
|
141
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Signs a raw message with the account.
|
|
230
|
+
* @param {string | ccc.BytesLike} message - The message to sign.
|
|
231
|
+
* @returns {Promise<string>} A promise that resolves to the signed message.
|
|
232
|
+
*/
|
|
142
233
|
async signMessageRaw(message) {
|
|
143
234
|
const { address } = await this.assertConnection();
|
|
144
235
|
const challenge = typeof message === "string" ? message : ccc.hexFrom(message).slice(2);
|
|
@@ -155,12 +246,22 @@ export class CkbSigner extends ccc.Signer {
|
|
|
155
246
|
message: res.message,
|
|
156
247
|
});
|
|
157
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Saves the current connection.
|
|
251
|
+
* @private
|
|
252
|
+
* @returns {Promise<void>}
|
|
253
|
+
*/
|
|
158
254
|
async saveConnection() {
|
|
159
255
|
return this.connectionsRepo.set({
|
|
160
256
|
uri: this.getConfig().joyidAppURL,
|
|
161
257
|
addressType: "ckb",
|
|
162
258
|
}, this.connection);
|
|
163
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Restores the previous connection.
|
|
262
|
+
* @private
|
|
263
|
+
* @returns {Promise<void>}
|
|
264
|
+
*/
|
|
164
265
|
async restoreConnection() {
|
|
165
266
|
this.connection = await this.connectionsRepo.get({
|
|
166
267
|
uri: this.getConfig().joyidAppURL,
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { AuthResponseData, DappRequestType, EvmWeb2LoginResponse, PopupConfigOptions, SignCkbTxResponseData, SignCotaNFTResponseData, SignEvmTxResponseData, SignMessageResponseData, SignNostrEventData } from "@joyid/common";
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing the return type for various Dapp request types.
|
|
4
|
+
* @interface
|
|
5
|
+
*/
|
|
2
6
|
export interface PopupReturnType {
|
|
3
7
|
[DappRequestType.Auth]: AuthResponseData;
|
|
4
8
|
[DappRequestType.SignMessage]: SignMessageResponseData;
|
|
@@ -18,6 +22,15 @@ export interface PopupReturnType {
|
|
|
18
22
|
[DappRequestType.SignMiniAppMessage]: any;
|
|
19
23
|
[DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
|
|
20
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a popup window for JoyID Dapp requests.
|
|
27
|
+
* @param {string} url - The URL to open in the popup.
|
|
28
|
+
* @param {PopupConfigOptions<T> & { joyidAppURL: string }} config - The popup configuration options.
|
|
29
|
+
* @returns {Promise<PopupReturnType[T]>} A promise that resolves to the response data of the requested type.
|
|
30
|
+
* @throws {PopupNotSupportedError} If popups are not supported in the current browser.
|
|
31
|
+
* @throws {PopupCancelledError} If the popup is closed by the user.
|
|
32
|
+
* @throws {PopupTimeoutError} If the popup operation times out.
|
|
33
|
+
*/
|
|
21
34
|
export declare function createPopup<T extends DappRequestType>(url: string, config: PopupConfigOptions<T> & {
|
|
22
35
|
joyidAppURL: string;
|
|
23
36
|
}): Promise<PopupReturnType[T]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,kBAAkB,EAGlB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,eAAe;IAC9B,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACzC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IACjD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAClD,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE;QAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;IACF,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IACnD,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACtD,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACrD,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IACnC,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IACtC,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,GAAG,CAAC;IAC1C,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACtD;AAED,wBAAsB,WAAW,CAAC,CAAC,SAAS,eAAe,EACzD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CA0D7B"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EAEpB,kBAAkB,EAGlB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACzC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IACjD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAClD,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE;QAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;IACF,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IACnD,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACvD,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACtD,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACrD,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC3C,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IACnC,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IACtC,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,GAAG,CAAC;IAC1C,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACtD;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,eAAe,EACzD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CA0D7B"}
|
package/dist/common/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { DappRequestType, PopupCancelledError, PopupNotSupportedError, PopupTimeoutError, createBlockDialog, isStandaloneBrowser, openPopup, } from "@joyid/common";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a popup window for JoyID Dapp requests.
|
|
4
|
+
* @param {string} url - The URL to open in the popup.
|
|
5
|
+
* @param {PopupConfigOptions<T> & { joyidAppURL: string }} config - The popup configuration options.
|
|
6
|
+
* @returns {Promise<PopupReturnType[T]>} A promise that resolves to the response data of the requested type.
|
|
7
|
+
* @throws {PopupNotSupportedError} If popups are not supported in the current browser.
|
|
8
|
+
* @throws {PopupCancelledError} If the popup is closed by the user.
|
|
9
|
+
* @throws {PopupTimeoutError} If the popup operation times out.
|
|
10
|
+
*/
|
|
2
11
|
export async function createPopup(url, config) {
|
|
3
12
|
if (config.popup == null) {
|
|
4
13
|
config.popup = openPopup("");
|