@ckb-ccc/joy-id 0.0.9-alpha.2 → 0.0.10-alpha.4

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.
Files changed (43) hide show
  1. package/dist/btc/index.d.ts +0 -1
  2. package/dist/btc/index.d.ts.map +1 -1
  3. package/dist/btc/index.js +0 -7
  4. package/dist/ckb/index.d.ts +0 -1
  5. package/dist/ckb/index.d.ts.map +1 -1
  6. package/dist/ckb/index.js +0 -7
  7. package/dist/evm/index.d.ts +2 -3
  8. package/dist/evm/index.d.ts.map +1 -1
  9. package/dist/evm/index.js +1 -8
  10. package/dist/nostr/index.d.ts +0 -1
  11. package/dist/nostr/index.d.ts.map +1 -1
  12. package/dist/nostr/index.js +0 -7
  13. package/dist.commonjs/advanced.d.ts +1 -1
  14. package/dist.commonjs/advanced.js +40 -19
  15. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  16. package/dist.commonjs/advancedBarrel.js +30 -14
  17. package/dist.commonjs/barrel.d.ts +1 -1
  18. package/dist.commonjs/barrel.js +30 -14
  19. package/dist.commonjs/btc/index.d.ts +67 -60
  20. package/dist.commonjs/btc/index.d.ts.map +1 -1
  21. package/dist.commonjs/btc/index.js +176 -148
  22. package/dist.commonjs/ckb/index.d.ts +122 -116
  23. package/dist.commonjs/ckb/index.d.ts.map +1 -1
  24. package/dist.commonjs/ckb/index.js +312 -262
  25. package/dist.commonjs/common/index.d.ts +34 -21
  26. package/dist.commonjs/common/index.js +50 -45
  27. package/dist.commonjs/connectionsStorage/index.d.ts +53 -44
  28. package/dist.commonjs/connectionsStorage/index.js +49 -44
  29. package/dist.commonjs/evm/index.d.ts +68 -63
  30. package/dist.commonjs/evm/index.d.ts.map +1 -1
  31. package/dist.commonjs/evm/index.js +143 -127
  32. package/dist.commonjs/index.d.ts +1 -1
  33. package/dist.commonjs/index.js +40 -19
  34. package/dist.commonjs/nostr/index.d.ts +59 -54
  35. package/dist.commonjs/nostr/index.d.ts.map +1 -1
  36. package/dist.commonjs/nostr/index.js +127 -114
  37. package/dist.commonjs/signerFactory/index.d.ts +7 -2
  38. package/dist.commonjs/signerFactory/index.js +54 -31
  39. package/package.json +3 -3
  40. package/src/btc/index.ts +0 -8
  41. package/src/ckb/index.ts +0 -8
  42. package/src/evm/index.ts +3 -11
  43. package/src/nostr/index.ts +0 -8
@@ -12,276 +12,326 @@ const connectionsStorage_1 = require("../connectionsStorage");
12
12
  * @extends {ccc.Signer}
13
13
  */
14
14
  class CkbSigner extends core_1.ccc.Signer {
15
- /**
16
- * Gets the signer type.
17
- * @returns {ccc.SignerType} The type of the signer.
18
- */
19
- get type() {
20
- return core_1.ccc.SignerType.CKB;
15
+ /**
16
+ * Gets the signer type.
17
+ * @returns {ccc.SignerType} The type of the signer.
18
+ */
19
+ get type() {
20
+ return core_1.ccc.SignerType.CKB;
21
+ }
22
+ /**
23
+ * Gets the sign type.
24
+ * @returns {ccc.SignerSignType} The sign type.
25
+ */
26
+ get signType() {
27
+ return core_1.ccc.SignerSignType.JoyId;
28
+ }
29
+ /**
30
+ * Ensures that the signer is connected and returns the connection.
31
+ * @private
32
+ * @throws Will throw an error if not connected.
33
+ * @returns {Promise<Connection>} A promise that resolves to the current connection.
34
+ */
35
+ async assertConnection() {
36
+ if (!(await this.isConnected()) || !this.connection) {
37
+ throw new Error("Not connected");
21
38
  }
22
- /**
23
- * Gets the sign type.
24
- * @returns {ccc.SignerSignType} The sign type.
25
- */
26
- get signType() {
27
- return core_1.ccc.SignerSignType.JoyId;
39
+ return this.connection;
40
+ }
41
+ /**
42
+ * Creates an instance of CkbSigner.
43
+ * @param {ccc.Client} client - The client instance.
44
+ * @param {string} name - The name of the signer.
45
+ * @param {string} icon - The icon URL of the signer.
46
+ * @param {string} [_appUri] - The application URI.
47
+ * @param {string} [_aggregatorUri] - The aggregator URI.
48
+ * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
49
+ */
50
+ constructor(
51
+ client,
52
+ name,
53
+ icon,
54
+ _appUri,
55
+ _aggregatorUri,
56
+ connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage(),
57
+ ) {
58
+ super(client);
59
+ this.name = name;
60
+ this.icon = icon;
61
+ this._appUri = _appUri;
62
+ this._aggregatorUri = _aggregatorUri;
63
+ this.connectionsRepo = connectionsRepo;
64
+ }
65
+ /**
66
+ * Gets the configuration for JoyID.
67
+ * @private
68
+ * @returns The configuration object.
69
+ */
70
+ getConfig() {
71
+ return {
72
+ redirectURL: location.href,
73
+ joyidAppURL:
74
+ this._appUri ?? this.client.addressPrefix === "ckb"
75
+ ? "https://app.joy.id"
76
+ : "https://testnet.joyid.dev",
77
+ name: this.name,
78
+ logo: this.icon,
79
+ };
80
+ }
81
+ /**
82
+ * Gets the aggregator URI.
83
+ * @private
84
+ * @returns {string} The aggregator URI.
85
+ */
86
+ getAggregatorUri() {
87
+ if (this._aggregatorUri) {
88
+ return this._aggregatorUri;
28
89
  }
29
- /**
30
- * Ensures that the signer is connected and returns the connection.
31
- * @private
32
- * @throws Will throw an error if not connected.
33
- * @returns {Promise<Connection>} A promise that resolves to the current connection.
34
- */
35
- async assertConnection() {
36
- if (!(await this.isConnected()) || !this.connection) {
37
- throw new Error("Not connected");
38
- }
39
- return this.connection;
40
- }
41
- /**
42
- * Creates an instance of CkbSigner.
43
- * @param {ccc.Client} client - The client instance.
44
- * @param {string} name - The name of the signer.
45
- * @param {string} icon - The icon URL of the signer.
46
- * @param {string} [_appUri] - The application URI.
47
- * @param {string} [_aggregatorUri] - The aggregator URI.
48
- * @param {ConnectionsRepo} [connectionsRepo=new ConnectionsRepoLocalStorage()] - The connections repository.
49
- */
50
- constructor(client, name, icon, _appUri, _aggregatorUri, connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage()) {
51
- super(client);
52
- this.name = name;
53
- this.icon = icon;
54
- this._appUri = _appUri;
55
- this._aggregatorUri = _aggregatorUri;
56
- this.connectionsRepo = connectionsRepo;
90
+ return this.client.addressPrefix === "ckb"
91
+ ? "https://cota.nervina.dev/mainnet-aggregator"
92
+ : "https://cota.nervina.dev/aggregator";
93
+ }
94
+ /**
95
+ * Connects to the provider by requesting authentication.
96
+ * @returns {Promise<void>} A promise that resolves when the connection is established.
97
+ */
98
+ async connect() {
99
+ const config = this.getConfig();
100
+ const res = await (0, common_2.createPopup)(
101
+ (0, common_1.buildJoyIDURL)(config, "popup", "/auth"),
102
+ {
103
+ ...config,
104
+ type: common_1.DappRequestType.Auth,
105
+ },
106
+ );
107
+ this.connection = {
108
+ address: res.address,
109
+ publicKey: core_1.ccc.hexFrom(res.pubkey),
110
+ keyType: res.keyType,
111
+ };
112
+ await this.saveConnection();
113
+ }
114
+ async disconnect() {
115
+ await super.disconnect();
116
+ this.connection = undefined;
117
+ await this.saveConnection();
118
+ }
119
+ /**
120
+ * Checks if the signer is connected.
121
+ * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
122
+ */
123
+ async isConnected() {
124
+ if (this.connection) {
125
+ return true;
57
126
  }
58
- async replaceClient(client) {
59
- if (!(await super.replaceClient(client))) {
60
- return false;
61
- }
62
- this.connection = undefined;
63
- return true;
127
+ await this.restoreConnection();
128
+ return this.connection !== undefined;
129
+ }
130
+ /**
131
+ * Gets the internal address.
132
+ * @returns {Promise<string>} A promise that resolves to the internal address.
133
+ */
134
+ async getInternalAddress() {
135
+ return (await this.assertConnection()).address;
136
+ }
137
+ /**
138
+ * Gets the identity of the signer.
139
+ * @returns {Promise<string>} A promise that resolves to the identity.
140
+ */
141
+ async getIdentity() {
142
+ const connection = await this.assertConnection();
143
+ return JSON.stringify({
144
+ keyType: connection.keyType,
145
+ publicKey: connection.publicKey.slice(2),
146
+ });
147
+ }
148
+ /**
149
+ * Gets the address object.
150
+ * @returns {Promise<ccc.Address>} A promise that resolves to the address object.
151
+ */
152
+ async getAddressObj() {
153
+ return await core_1.ccc.Address.fromString(
154
+ await this.getInternalAddress(),
155
+ this.client,
156
+ );
157
+ }
158
+ /**
159
+ * Gets the address objects.
160
+ * @returns {Promise<ccc.Address[]>} A promise that resolves to an array of address objects.
161
+ */
162
+ async getAddressObjs() {
163
+ return [await this.getAddressObj()];
164
+ }
165
+ /**
166
+ * Prepares a transaction.
167
+ * @param {ccc.TransactionLike} txLike - The transaction-like object.
168
+ * @returns {Promise<ccc.Transaction>} A promise that resolves to the prepared transaction.
169
+ */
170
+ async prepareTransaction(txLike) {
171
+ const tx = core_1.ccc.Transaction.from(txLike);
172
+ await tx.addCellDepsOfKnownScripts(
173
+ this.client,
174
+ core_1.ccc.KnownScript.JoyId,
175
+ );
176
+ const position = await tx.findInputIndexByLock(
177
+ (await this.getAddressObj()).script,
178
+ this.client,
179
+ );
180
+ if (position === undefined) {
181
+ return tx;
64
182
  }
65
- /**
66
- * Gets the configuration for JoyID.
67
- * @private
68
- * @returns The configuration object.
69
- */
70
- getConfig() {
71
- return {
72
- redirectURL: location.href,
73
- joyidAppURL: this._appUri ?? this.client.addressPrefix === "ckb"
74
- ? "https://app.joy.id"
75
- : "https://testnet.joyid.dev",
76
- name: this.name,
77
- logo: this.icon,
78
- };
79
- }
80
- /**
81
- * Gets the aggregator URI.
82
- * @private
83
- * @returns {string} The aggregator URI.
84
- */
85
- getAggregatorUri() {
86
- if (this._aggregatorUri) {
87
- return this._aggregatorUri;
88
- }
89
- return this.client.addressPrefix === "ckb"
90
- ? "https://cota.nervina.dev/mainnet-aggregator"
91
- : "https://cota.nervina.dev/aggregator";
183
+ const witness =
184
+ tx.getWitnessArgsAt(position) ?? core_1.ccc.WitnessArgs.from({});
185
+ witness.lock = core_1.ccc.hexFrom("00".repeat(1000));
186
+ await this.prepareTransactionForSubKey(tx, witness);
187
+ tx.setWitnessArgsAt(position, witness);
188
+ return tx;
189
+ }
190
+ /**
191
+ * Prepares a transaction for a sub key.
192
+ * @private
193
+ * @param tx - The transaction object.
194
+ * @param witness - The witness arguments.
195
+ * @throws Will throw an error if no COTA cells are found for the sub key wallet.
196
+ */
197
+ async prepareTransactionForSubKey(tx, witness) {
198
+ if (this.connection?.keyType !== "sub_key") {
199
+ return [];
92
200
  }
93
- /**
94
- * Connects to the provider by requesting authentication.
95
- * @returns {Promise<void>} A promise that resolves when the connection is established.
96
- */
97
- async connect() {
98
- const config = this.getConfig();
99
- const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
100
- ...config,
101
- type: common_1.DappRequestType.Auth,
102
- });
103
- this.connection = {
104
- address: res.address,
105
- publicKey: core_1.ccc.hexFrom(res.pubkey),
106
- keyType: res.keyType,
107
- };
108
- await this.saveConnection();
201
+ const pubkeyHash = core_1.ccc
202
+ .hashCkb(this.connection.publicKey)
203
+ .substring(0, 42);
204
+ const lock = (await this.getAddressObj()).script;
205
+ const aggregator = new ckb_1.Aggregator(this.getAggregatorUri());
206
+ const { unlock_entry: unlockEntry } =
207
+ await aggregator.generateSubkeyUnlockSmt({
208
+ alg_index: 1,
209
+ pubkey_hash: pubkeyHash,
210
+ lock_script: core_1.ccc.hexFrom(lock.toBytes()),
211
+ });
212
+ witness.outputType = core_1.ccc.hexFrom(unlockEntry);
213
+ const cotaDeps = [];
214
+ for await (const cell of this.client.findCellsByLockAndType(
215
+ lock,
216
+ await core_1.ccc.Script.fromKnownScript(
217
+ this.client,
218
+ core_1.ccc.KnownScript.COTA,
219
+ "0x",
220
+ ),
221
+ )) {
222
+ cotaDeps.push(
223
+ core_1.ccc.CellDep.from({
224
+ depType: "code",
225
+ outPoint: cell.outPoint,
226
+ }),
227
+ );
109
228
  }
110
- async disconnect() {
111
- await super.disconnect();
112
- this.connection = undefined;
113
- await this.saveConnection();
229
+ if (cotaDeps.length === 0) {
230
+ throw new Error("No COTA cells for sub key wallet");
114
231
  }
115
- /**
116
- * Checks if the signer is connected.
117
- * @returns {Promise<boolean>} A promise that resolves to true if connected, false otherwise.
118
- */
119
- async isConnected() {
120
- if (this.connection) {
121
- return true;
232
+ tx.cellDeps.unshift(...cotaDeps);
233
+ }
234
+ /**
235
+ * Signs a transaction.
236
+ * @param {ccc.TransactionLike} txLike - The transaction-like object.
237
+ * @returns {Promise<ccc.Transaction>} A promise that resolves to the signed transaction.
238
+ */
239
+ async signOnlyTransaction(txLike) {
240
+ const tx = core_1.ccc.Transaction.from(txLike);
241
+ const { script } = await this.getAddressObj();
242
+ const witnessIndexes = await core_1.ccc.reduceAsync(
243
+ tx.inputs,
244
+ async (acc, input, i) => {
245
+ await input.completeExtraInfos(this.client);
246
+ if (!input.cellOutput) {
247
+ throw new Error("Unable to complete input");
122
248
  }
123
- await this.restoreConnection();
124
- return this.connection !== undefined;
125
- }
126
- /**
127
- * Gets the internal address.
128
- * @returns {Promise<string>} A promise that resolves to the internal address.
129
- */
130
- async getInternalAddress() {
131
- return (await this.assertConnection()).address;
132
- }
133
- /**
134
- * Gets the identity of the signer.
135
- * @returns {Promise<string>} A promise that resolves to the identity.
136
- */
137
- async getIdentity() {
138
- const connection = await this.assertConnection();
139
- return JSON.stringify({
140
- keyType: connection.keyType,
141
- publicKey: connection.publicKey.slice(2),
142
- });
143
- }
144
- /**
145
- * Gets the address object.
146
- * @returns {Promise<ccc.Address>} A promise that resolves to the address object.
147
- */
148
- async getAddressObj() {
149
- return await core_1.ccc.Address.fromString(await this.getInternalAddress(), this.client);
150
- }
151
- /**
152
- * Gets the address objects.
153
- * @returns {Promise<ccc.Address[]>} A promise that resolves to an array of address objects.
154
- */
155
- async getAddressObjs() {
156
- return [await this.getAddressObj()];
157
- }
158
- /**
159
- * Prepares a transaction.
160
- * @param {ccc.TransactionLike} txLike - The transaction-like object.
161
- * @returns {Promise<ccc.Transaction>} A promise that resolves to the prepared transaction.
162
- */
163
- async prepareTransaction(txLike) {
164
- const tx = core_1.ccc.Transaction.from(txLike);
165
- await tx.addCellDepsOfKnownScripts(this.client, core_1.ccc.KnownScript.JoyId);
166
- const position = await tx.findInputIndexByLock((await this.getAddressObj()).script, this.client);
167
- if (position === undefined) {
168
- return tx;
249
+ if (input.cellOutput.lock.eq(script)) {
250
+ acc.push(i);
169
251
  }
170
- const witness = tx.getWitnessArgsAt(position) ?? core_1.ccc.WitnessArgs.from({});
171
- witness.lock = core_1.ccc.hexFrom("00".repeat(1000));
172
- await this.prepareTransactionForSubKey(tx, witness);
173
- tx.setWitnessArgsAt(position, witness);
174
- return tx;
175
- }
176
- /**
177
- * Prepares a transaction for a sub key.
178
- * @private
179
- * @param tx - The transaction object.
180
- * @param witness - The witness arguments.
181
- * @throws Will throw an error if no COTA cells are found for the sub key wallet.
182
- */
183
- async prepareTransactionForSubKey(tx, witness) {
184
- if (this.connection?.keyType !== "sub_key") {
185
- return [];
186
- }
187
- const pubkeyHash = core_1.ccc.hashCkb(this.connection.publicKey).substring(0, 42);
188
- const lock = (await this.getAddressObj()).script;
189
- const aggregator = new ckb_1.Aggregator(this.getAggregatorUri());
190
- const { unlock_entry: unlockEntry } = await aggregator.generateSubkeyUnlockSmt({
191
- alg_index: 1,
192
- pubkey_hash: pubkeyHash,
193
- lock_script: core_1.ccc.hexFrom(lock.toBytes()),
194
- });
195
- witness.outputType = core_1.ccc.hexFrom(unlockEntry);
196
- const cotaDeps = [];
197
- for await (const cell of this.client.findCellsByLockAndType(lock, await core_1.ccc.Script.fromKnownScript(this.client, core_1.ccc.KnownScript.COTA, "0x"))) {
198
- cotaDeps.push(core_1.ccc.CellDep.from({
199
- depType: "code",
200
- outPoint: cell.outPoint,
201
- }));
202
- }
203
- if (cotaDeps.length === 0) {
204
- throw new Error("No COTA cells for sub key wallet");
205
- }
206
- tx.cellDeps.unshift(...cotaDeps);
207
- }
208
- /**
209
- * Signs a transaction.
210
- * @param {ccc.TransactionLike} txLike - The transaction-like object.
211
- * @returns {Promise<ccc.Transaction>} A promise that resolves to the signed transaction.
212
- */
213
- async signOnlyTransaction(txLike) {
214
- const tx = core_1.ccc.Transaction.from(txLike);
215
- const { script } = await this.getAddressObj();
216
- const witnessIndexes = await core_1.ccc.reduceAsync(tx.inputs, async (acc, input, i) => {
217
- await input.completeExtraInfos(this.client);
218
- if (!input.cellOutput) {
219
- throw new Error("Unable to complete input");
220
- }
221
- if (input.cellOutput.lock.eq(script)) {
222
- acc.push(i);
223
- }
224
- }, []);
225
- // Trim unnecessary fields to reduce tx size
226
- await tx.prepareSighashAllWitness(script, 0, this.client);
227
- tx.inputs.forEach((i) => {
228
- i.cellOutput = undefined;
229
- i.outputData = undefined;
230
- });
231
- const config = this.getConfig();
232
- const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
233
- ...config,
234
- tx: JSON.parse(tx.stringify()),
235
- signerAddress: (await this.assertConnection()).address,
236
- witnessIndexes,
237
- }, "popup", "/sign-ckb-raw-tx"), {
238
- ...config,
239
- type: common_1.DappRequestType.SignCkbRawTx,
240
- });
241
- return core_1.ccc.Transaction.from(res.tx);
242
- }
243
- /**
244
- * Signs a raw message with the account.
245
- * @param {string | ccc.BytesLike} message - The message to sign.
246
- * @returns {Promise<string>} A promise that resolves to the signed message.
247
- */
248
- async signMessageRaw(message) {
249
- const { address } = await this.assertConnection();
250
- const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
251
- const config = this.getConfig();
252
- const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
253
- ...config,
254
- challenge,
255
- isData: typeof message !== "string",
256
- address,
257
- }, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
258
- return JSON.stringify({
259
- signature: res.signature,
260
- alg: res.alg,
261
- message: res.message,
262
- });
263
- }
264
- /**
265
- * Saves the current connection.
266
- * @private
267
- * @returns {Promise<void>}
268
- */
269
- async saveConnection() {
270
- return this.connectionsRepo.set({
271
- uri: this.getConfig().joyidAppURL,
272
- addressType: "ckb",
273
- }, this.connection);
274
- }
275
- /**
276
- * Restores the previous connection.
277
- * @private
278
- * @returns {Promise<void>}
279
- */
280
- async restoreConnection() {
281
- this.connection = await this.connectionsRepo.get({
282
- uri: this.getConfig().joyidAppURL,
283
- addressType: "ckb",
284
- });
285
- }
252
+ },
253
+ [],
254
+ );
255
+ // Trim unnecessary fields to reduce tx size
256
+ await tx.prepareSighashAllWitness(script, 0, this.client);
257
+ tx.inputs.forEach((i) => {
258
+ i.cellOutput = undefined;
259
+ i.outputData = undefined;
260
+ });
261
+ const config = this.getConfig();
262
+ const res = await (0, common_2.createPopup)(
263
+ (0, common_1.buildJoyIDURL)(
264
+ {
265
+ ...config,
266
+ tx: JSON.parse(tx.stringify()),
267
+ signerAddress: (await this.assertConnection()).address,
268
+ witnessIndexes,
269
+ },
270
+ "popup",
271
+ "/sign-ckb-raw-tx",
272
+ ),
273
+ {
274
+ ...config,
275
+ type: common_1.DappRequestType.SignCkbRawTx,
276
+ },
277
+ );
278
+ return core_1.ccc.Transaction.from(res.tx);
279
+ }
280
+ /**
281
+ * Signs a raw message with the account.
282
+ * @param {string | ccc.BytesLike} message - The message to sign.
283
+ * @returns {Promise<string>} A promise that resolves to the signed message.
284
+ */
285
+ async signMessageRaw(message) {
286
+ const { address } = await this.assertConnection();
287
+ const challenge =
288
+ typeof message === "string"
289
+ ? message
290
+ : core_1.ccc.hexFrom(message).slice(2);
291
+ const config = this.getConfig();
292
+ const res = await (0, common_2.createPopup)(
293
+ (0, common_1.buildJoyIDURL)(
294
+ {
295
+ ...config,
296
+ challenge,
297
+ isData: typeof message !== "string",
298
+ address,
299
+ },
300
+ "popup",
301
+ "/sign-message",
302
+ ),
303
+ { ...config, type: common_1.DappRequestType.SignMessage },
304
+ );
305
+ return JSON.stringify({
306
+ signature: res.signature,
307
+ alg: res.alg,
308
+ message: res.message,
309
+ });
310
+ }
311
+ /**
312
+ * Saves the current connection.
313
+ * @private
314
+ * @returns {Promise<void>}
315
+ */
316
+ async saveConnection() {
317
+ return this.connectionsRepo.set(
318
+ {
319
+ uri: this.getConfig().joyidAppURL,
320
+ addressType: "ckb",
321
+ },
322
+ this.connection,
323
+ );
324
+ }
325
+ /**
326
+ * Restores the previous connection.
327
+ * @private
328
+ * @returns {Promise<void>}
329
+ */
330
+ async restoreConnection() {
331
+ this.connection = await this.connectionsRepo.get({
332
+ uri: this.getConfig().joyidAppURL,
333
+ addressType: "ckb",
334
+ });
335
+ }
286
336
  }
287
337
  exports.CkbSigner = CkbSigner;
@@ -1,26 +1,36 @@
1
- import { AuthResponseData, DappRequestType, EvmWeb2LoginResponse, PopupConfigOptions, SignCkbTxResponseData, SignCotaNFTResponseData, SignEvmTxResponseData, SignMessageResponseData, SignNostrEventData } from "@joyid/common";
1
+ import {
2
+ AuthResponseData,
3
+ DappRequestType,
4
+ EvmWeb2LoginResponse,
5
+ PopupConfigOptions,
6
+ SignCkbTxResponseData,
7
+ SignCotaNFTResponseData,
8
+ SignEvmTxResponseData,
9
+ SignMessageResponseData,
10
+ SignNostrEventData,
11
+ } from "@joyid/common";
2
12
  /**
3
13
  * Interface representing the return type for various Dapp request types.
4
14
  * @interface
5
15
  */
6
16
  export interface PopupReturnType {
7
- [DappRequestType.Auth]: AuthResponseData;
8
- [DappRequestType.SignMessage]: SignMessageResponseData;
9
- [DappRequestType.SignEvm]: SignEvmTxResponseData;
10
- [DappRequestType.SignPsbt]: SignEvmTxResponseData;
11
- [DappRequestType.BatchSignPsbt]: {
12
- psbts: string[];
13
- };
14
- [DappRequestType.SignCkbTx]: SignCkbTxResponseData;
15
- [DappRequestType.SignCotaNFT]: SignCotaNFTResponseData;
16
- [DappRequestType.SignCkbRawTx]: SignCkbTxResponseData;
17
- [DappRequestType.SignNostrEvent]: SignNostrEventData;
18
- [DappRequestType.EncryptNostrMessage]: any;
19
- [DappRequestType.DecryptNostrMessage]: any;
20
- [DappRequestType.AuthMiniApp]: any;
21
- [DappRequestType.SignMiniAppEvm]: any;
22
- [DappRequestType.SignMiniAppMessage]: any;
23
- [DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
17
+ [DappRequestType.Auth]: AuthResponseData;
18
+ [DappRequestType.SignMessage]: SignMessageResponseData;
19
+ [DappRequestType.SignEvm]: SignEvmTxResponseData;
20
+ [DappRequestType.SignPsbt]: SignEvmTxResponseData;
21
+ [DappRequestType.BatchSignPsbt]: {
22
+ psbts: string[];
23
+ };
24
+ [DappRequestType.SignCkbTx]: SignCkbTxResponseData;
25
+ [DappRequestType.SignCotaNFT]: SignCotaNFTResponseData;
26
+ [DappRequestType.SignCkbRawTx]: SignCkbTxResponseData;
27
+ [DappRequestType.SignNostrEvent]: SignNostrEventData;
28
+ [DappRequestType.EncryptNostrMessage]: any;
29
+ [DappRequestType.DecryptNostrMessage]: any;
30
+ [DappRequestType.AuthMiniApp]: any;
31
+ [DappRequestType.SignMiniAppEvm]: any;
32
+ [DappRequestType.SignMiniAppMessage]: any;
33
+ [DappRequestType.EvmWeb2Login]: EvmWeb2LoginResponse;
24
34
  }
25
35
  /**
26
36
  * Creates a popup window for JoyID Dapp requests.
@@ -31,7 +41,10 @@ export interface PopupReturnType {
31
41
  * @throws {PopupCancelledError} If the popup is closed by the user.
32
42
  * @throws {PopupTimeoutError} If the popup operation times out.
33
43
  */
34
- export declare function createPopup<T extends DappRequestType>(url: string, config: PopupConfigOptions<T> & {
44
+ export declare function createPopup<T extends DappRequestType>(
45
+ url: string,
46
+ config: PopupConfigOptions<T> & {
35
47
  joyidAppURL: string;
36
- }): Promise<PopupReturnType[T]>;
37
- //# sourceMappingURL=index.d.ts.map
48
+ },
49
+ ): Promise<PopupReturnType[T]>;
50
+ //# sourceMappingURL=index.d.ts.map