@subwallet/extension-base 0.6.7-1wr → 0.6.7-2

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 (67) hide show
  1. package/background/KoniTypes.d.ts +64 -53
  2. package/background/KoniTypes.js +13 -23
  3. package/background/RequestBytesSign.js +1 -2
  4. package/background/RequestExtrinsicSign.js +1 -2
  5. package/background/handlers/Extension.js +28 -122
  6. package/background/handlers/State.js +28 -71
  7. package/background/handlers/Tabs.js +9 -45
  8. package/background/handlers/helpers.js +1 -1
  9. package/background/handlers/index.js +4 -2
  10. package/background/handlers/subscriptions.js +5 -2
  11. package/bundle.js +1 -0
  12. package/cjs/background/KoniTypes.js +15 -24
  13. package/cjs/background/RequestBytesSign.js +1 -6
  14. package/cjs/background/RequestExtrinsicSign.js +1 -4
  15. package/cjs/background/handlers/Extension.js +27 -174
  16. package/cjs/background/handlers/State.js +28 -82
  17. package/cjs/background/handlers/Tabs.js +9 -60
  18. package/cjs/background/handlers/helpers.js +1 -2
  19. package/cjs/background/handlers/index.js +4 -10
  20. package/cjs/background/handlers/subscriptions.js +5 -4
  21. package/cjs/bundle.js +0 -1
  22. package/cjs/defaults.js +2 -3
  23. package/cjs/detectOther.js +0 -4
  24. package/cjs/detectPackage.js +2 -4
  25. package/cjs/errors/SubWalletProviderError.js +1 -3
  26. package/cjs/index.js +0 -2
  27. package/cjs/packageInfo.js +3 -1
  28. package/cjs/page/Accounts.js +3 -6
  29. package/cjs/page/Injected.js +1 -8
  30. package/cjs/page/Metadata.js +1 -5
  31. package/cjs/page/PostMessageProvider.js +22 -38
  32. package/cjs/page/Signer.js +11 -11
  33. package/cjs/page/index.js +6 -13
  34. package/cjs/signers/substrates/LedgerSigner.js +1 -7
  35. package/cjs/signers/substrates/QrSigner.js +1 -10
  36. package/cjs/signers/web3/QrSigner.js +1 -12
  37. package/cjs/stores/Accounts.js +1 -8
  38. package/cjs/stores/Base.js +1 -15
  39. package/cjs/stores/Metadata.js +1 -6
  40. package/cjs/stores/index.js +0 -3
  41. package/cjs/utils/canDerive.js +1 -1
  42. package/cjs/utils/getId.js +1 -3
  43. package/cjs/utils/index.js +0 -1
  44. package/defaults.d.ts +1 -2
  45. package/defaults.js +2 -2
  46. package/detectOther.js +1 -0
  47. package/detectPackage.js +2 -0
  48. package/errors/SubWalletProviderError.js +1 -1
  49. package/index.js +2 -0
  50. package/package.json +5 -5
  51. package/packageInfo.js +3 -1
  52. package/page/Accounts.js +3 -4
  53. package/page/Injected.js +1 -1
  54. package/page/Metadata.js +1 -3
  55. package/page/PostMessageProvider.js +22 -33
  56. package/page/Signer.js +11 -9
  57. package/page/index.js +8 -6
  58. package/signers/substrates/LedgerSigner.js +1 -3
  59. package/signers/substrates/QrSigner.js +1 -5
  60. package/signers/web3/QrSigner.js +1 -5
  61. package/stores/Accounts.js +1 -3
  62. package/stores/Base.js +1 -13
  63. package/stores/Metadata.js +1 -1
  64. package/stores/index.js +1 -0
  65. package/utils/canDerive.js +1 -0
  66. package/utils/getId.js +1 -0
  67. package/utils/index.js +1 -0
@@ -1,44 +1,34 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = exports.SEED_LENGTHS = exports.SEED_DEFAULT_LENGTH = exports.ETH_DERIVE_DEFAULT = void 0;
9
8
  exports.getSuri = getSuri;
10
-
11
9
  var _defaults = require("@subwallet/extension-base/defaults");
12
-
13
10
  var _types = require("@polkadot/types");
14
-
15
11
  var _uiKeyring = _interopRequireDefault(require("@polkadot/ui-keyring"));
16
-
17
12
  var _accounts = require("@polkadot/ui-keyring/observable/accounts");
18
-
19
13
  var _util = require("@polkadot/util");
20
-
21
14
  var _utilCrypto = require("@polkadot/util-crypto");
22
-
23
15
  var _helpers = require("./helpers");
24
-
25
16
  var _subscriptions = require("./subscriptions");
26
-
27
17
  // Copyright 2019-2022 @polkadot/extension authors & contributors
28
18
  // SPDX-License-Identifier: Apache-2.0
19
+
29
20
  const SEED_DEFAULT_LENGTH = 12;
30
21
  exports.SEED_DEFAULT_LENGTH = SEED_DEFAULT_LENGTH;
31
22
  const SEED_LENGTHS = [12, 15, 18, 21, 24];
32
23
  exports.SEED_LENGTHS = SEED_LENGTHS;
33
- const ETH_DERIVE_DEFAULT = '/m/44\'/60\'/0\'/0/0'; // a global registry to use internally
24
+ const ETH_DERIVE_DEFAULT = '/m/44\'/60\'/0\'/0/0';
34
25
 
26
+ // a global registry to use internally
35
27
  exports.ETH_DERIVE_DEFAULT = ETH_DERIVE_DEFAULT;
36
28
  const registry = new _types.TypeRegistry();
37
-
38
29
  function getSuri(seed, type) {
39
30
  return type === 'ethereum' ? `${seed}${ETH_DERIVE_DEFAULT}` : seed;
40
31
  }
41
-
42
32
  function transformAccounts(accounts) {
43
33
  return Object.values(accounts).map(_ref => {
44
34
  let {
@@ -55,35 +45,28 @@ function transformAccounts(accounts) {
55
45
  };
56
46
  });
57
47
  }
58
-
59
48
  function isJsonPayload(value) {
60
49
  return value.genesisHash !== undefined;
61
50
  }
62
-
63
51
  class Extension {
64
52
  #cachedUnlocks;
65
53
  #state;
66
-
67
54
  constructor(state) {
68
55
  this.#cachedUnlocks = {};
69
56
  this.#state = state;
70
57
  }
71
-
72
58
  accountsCreateExternal(_ref2) {
73
59
  let {
74
60
  address,
75
61
  genesisHash,
76
62
  name
77
63
  } = _ref2;
78
-
79
64
  _uiKeyring.default.addExternal(address, {
80
65
  genesisHash,
81
66
  name
82
67
  });
83
-
84
68
  return true;
85
69
  }
86
-
87
70
  accountsCreateHardware(_ref3) {
88
71
  let {
89
72
  accountIndex,
@@ -93,17 +76,14 @@ class Extension {
93
76
  hardwareType,
94
77
  name
95
78
  } = _ref3;
96
-
97
79
  _uiKeyring.default.addHardware(address, hardwareType, {
98
80
  accountIndex,
99
81
  addressOffset,
100
82
  genesisHash,
101
83
  name
102
84
  });
103
-
104
85
  return true;
105
86
  }
106
-
107
87
  accountsCreateSuri(_ref4) {
108
88
  let {
109
89
  genesisHash,
@@ -112,58 +92,44 @@ class Extension {
112
92
  suri,
113
93
  type
114
94
  } = _ref4;
115
-
116
95
  _uiKeyring.default.addUri(getSuri(suri, type), password, {
117
96
  genesisHash,
118
97
  name
119
98
  }, type);
120
-
121
99
  return true;
122
100
  }
123
-
124
101
  accountsChangePassword(_ref5) {
125
102
  let {
126
103
  address,
127
104
  newPass,
128
105
  oldPass
129
106
  } = _ref5;
130
-
131
107
  const pair = _uiKeyring.default.getPair(address);
132
-
133
108
  (0, _util.assert)(pair, 'Unable to find pair');
134
-
135
109
  try {
136
110
  if (!pair.isLocked) {
137
111
  pair.lock();
138
112
  }
139
-
140
113
  pair.decodePkcs8(oldPass);
141
114
  } catch (error) {
142
115
  throw new Error('oldPass is invalid');
143
116
  }
144
-
145
117
  _uiKeyring.default.encryptAccount(pair, newPass);
146
-
147
118
  return true;
148
119
  }
149
-
150
120
  accountsEdit(_ref6) {
151
121
  let {
152
122
  address,
153
123
  name
154
124
  } = _ref6;
155
-
156
125
  const pair = _uiKeyring.default.getPair(address);
157
-
158
126
  (0, _util.assert)(pair, 'Unable to find pair');
159
-
160
- _uiKeyring.default.saveAccountMeta(pair, { ...pair.meta,
127
+ _uiKeyring.default.saveAccountMeta(pair, {
128
+ ...pair.meta,
161
129
  name
162
130
  });
163
-
164
131
  return true;
165
132
  }
166
-
167
133
  accountsExport(_ref7) {
168
134
  let {
169
135
  address,
@@ -172,101 +138,83 @@ class Extension {
172
138
  return {
173
139
  exportedJson: _uiKeyring.default.backupAccount(_uiKeyring.default.getPair(address), password)
174
140
  };
175
- } // private async accountsBatchExport ({ addresses, password }: RequestAccountBatchExport): Promise<ResponseAccountsExport> {
141
+ }
142
+
143
+ // private async accountsBatchExport ({ addresses, password }: RequestAccountBatchExport): Promise<ResponseAccountsExport> {
176
144
  // return {
177
145
  // exportedJson: await keyring.backupAccounts(addresses, password)
178
146
  // };
179
147
  // }
180
148
 
181
-
182
149
  accountsForget(_ref8) {
183
150
  let {
184
151
  address
185
152
  } = _ref8;
186
-
187
153
  _uiKeyring.default.forgetAccount(address);
188
-
189
154
  return true;
190
155
  }
191
-
192
156
  refreshAccountPasswordCache(pair) {
193
157
  const {
194
158
  address
195
159
  } = pair;
196
160
  const savedExpiry = this.#cachedUnlocks[address] || 0;
197
161
  const remainingTime = savedExpiry - Date.now();
198
-
199
162
  if (remainingTime < 0) {
200
163
  this.#cachedUnlocks[address] = 0;
201
164
  pair.lock();
202
165
  return 0;
203
166
  }
204
-
205
167
  return remainingTime;
206
168
  }
207
-
208
169
  accountsShow(_ref9) {
209
170
  let {
210
171
  address,
211
172
  isShowing
212
173
  } = _ref9;
213
-
214
174
  const pair = _uiKeyring.default.getPair(address);
215
-
216
175
  (0, _util.assert)(pair, 'Unable to find pair');
217
-
218
- _uiKeyring.default.saveAccountMeta(pair, { ...pair.meta,
176
+ _uiKeyring.default.saveAccountMeta(pair, {
177
+ ...pair.meta,
219
178
  isHidden: !isShowing
220
179
  });
221
-
222
180
  return true;
223
181
  }
224
-
225
182
  accountsTie(_ref10) {
226
183
  let {
227
184
  address,
228
185
  genesisHash
229
186
  } = _ref10;
230
-
231
187
  const pair = _uiKeyring.default.getPair(address);
232
-
233
188
  (0, _util.assert)(pair, 'Unable to find pair');
234
-
235
- _uiKeyring.default.saveAccountMeta(pair, { ...pair.meta,
189
+ _uiKeyring.default.saveAccountMeta(pair, {
190
+ ...pair.meta,
236
191
  genesisHash
237
192
  });
238
-
239
193
  return true;
240
194
  }
241
-
242
195
  accountsValidate(_ref11) {
243
196
  let {
244
197
  address,
245
198
  password
246
199
  } = _ref11;
247
-
248
200
  try {
249
201
  _uiKeyring.default.backupAccount(_uiKeyring.default.getPair(address), password);
250
-
251
202
  return true;
252
203
  } catch (e) {
253
204
  return false;
254
205
  }
255
- } // FIXME This looks very much like what we have in Tabs
256
-
206
+ }
257
207
 
208
+ // FIXME This looks very much like what we have in Tabs
258
209
  accountsSubscribe(id, port) {
259
210
  const cb = (0, _subscriptions.createSubscription)(id, port);
260
-
261
211
  const subscription = _accounts.accounts.subject.subscribe(accounts => cb(transformAccounts(accounts)));
262
-
263
212
  port.onDisconnect.addListener(() => {
264
213
  (0, _subscriptions.unsubscribe)(id);
265
214
  subscription.unsubscribe();
266
215
  });
267
216
  return true;
268
217
  }
269
-
270
218
  authorizeApprove(_ref12) {
271
219
  let {
272
220
  id
@@ -279,13 +227,11 @@ class Extension {
279
227
  resolve(true);
280
228
  return true;
281
229
  }
282
-
283
230
  getAuthList() {
284
231
  return {
285
232
  list: this.#state.authUrls
286
233
  };
287
234
  }
288
-
289
235
  authorizeReject(_ref13) {
290
236
  let {
291
237
  id
@@ -297,9 +243,9 @@ class Extension {
297
243
  } = queued;
298
244
  reject(new Error('Rejected'));
299
245
  return true;
300
- } // FIXME This looks very much like what we have in accounts
301
-
246
+ }
302
247
 
248
+ // FIXME This looks very much like what we have in accounts
303
249
  authorizeSubscribe(id, port) {
304
250
  const cb = (0, _subscriptions.createSubscription)(id, port);
305
251
  const subscription = this.#state.authSubject.subscribe(requests => cb(requests));
@@ -309,7 +255,6 @@ class Extension {
309
255
  });
310
256
  return true;
311
257
  }
312
-
313
258
  metadataApprove(_ref14) {
314
259
  let {
315
260
  id
@@ -324,15 +269,12 @@ class Extension {
324
269
  resolve(true);
325
270
  return true;
326
271
  }
327
-
328
272
  metadataGet(genesisHash) {
329
273
  return this.#state.knownMetadata.find(result => result.genesisHash === genesisHash) || null;
330
274
  }
331
-
332
275
  metadataList() {
333
276
  return this.#state.knownMetadata;
334
277
  }
335
-
336
278
  metadataReject(_ref15) {
337
279
  let {
338
280
  id
@@ -345,7 +287,6 @@ class Extension {
345
287
  reject(new Error('Rejected'));
346
288
  return true;
347
289
  }
348
-
349
290
  metadataSubscribe(id, port) {
350
291
  const cb = (0, _subscriptions.createSubscription)(id, port);
351
292
  const subscription = this.#state.metaSubject.subscribe(requests => cb(requests));
@@ -355,33 +296,28 @@ class Extension {
355
296
  });
356
297
  return true;
357
298
  }
358
-
359
299
  jsonRestore(_ref16) {
360
300
  let {
361
301
  file,
362
302
  password
363
303
  } = _ref16;
364
-
365
304
  try {
366
305
  _uiKeyring.default.restoreAccount(file, password);
367
306
  } catch (error) {
368
307
  throw new Error(error.message);
369
308
  }
370
309
  }
371
-
372
310
  batchRestore(_ref17) {
373
311
  let {
374
312
  file,
375
313
  password
376
314
  } = _ref17;
377
-
378
315
  try {
379
316
  _uiKeyring.default.restoreAccounts(file, password);
380
317
  } catch (error) {
381
318
  throw new Error(error.message);
382
319
  }
383
320
  }
384
-
385
321
  jsonGetAccountInfo(json) {
386
322
  try {
387
323
  const {
@@ -392,7 +328,6 @@ class Extension {
392
328
  },
393
329
  type
394
330
  } = _uiKeyring.default.createFromJson(json);
395
-
396
331
  return {
397
332
  address,
398
333
  genesisHash,
@@ -404,22 +339,18 @@ class Extension {
404
339
  throw new Error(e.message);
405
340
  }
406
341
  }
407
-
408
342
  seedCreate(_ref18) {
409
343
  let {
410
344
  length = SEED_DEFAULT_LENGTH,
411
345
  seed: _seed,
412
346
  type
413
347
  } = _ref18;
414
-
415
348
  const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
416
-
417
349
  return {
418
350
  address: _uiKeyring.default.createFromUri(getSuri(seed, type), {}, type).address,
419
351
  seed
420
352
  };
421
353
  }
422
-
423
354
  seedValidate(_ref19) {
424
355
  let {
425
356
  suri,
@@ -428,7 +359,6 @@ class Extension {
428
359
  const {
429
360
  phrase
430
361
  } = (0, _utilCrypto.keyExtractSuri)(suri);
431
-
432
362
  if ((0, _util.isHex)(phrase)) {
433
363
  (0, _util.assert)((0, _util.isHex)(phrase, 256), 'Hex seed needs to be 256-bits');
434
364
  } else {
@@ -436,13 +366,11 @@ class Extension {
436
366
  (0, _util.assert)(SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
437
367
  (0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), 'Not a valid mnemonic seed');
438
368
  }
439
-
440
369
  return {
441
370
  address: _uiKeyring.default.createFromUri(getSuri(suri, type), {}, type).address,
442
371
  suri
443
372
  };
444
373
  }
445
-
446
374
  signingApprovePassword(_ref20) {
447
375
  let {
448
376
  id,
@@ -456,61 +384,52 @@ class Extension {
456
384
  request,
457
385
  resolve
458
386
  } = queued;
387
+ const pair = _uiKeyring.default.getPair(queued.account.address);
459
388
 
460
- const pair = _uiKeyring.default.getPair(queued.account.address); // unlike queued.account.address the following
389
+ // unlike queued.account.address the following
461
390
  // address is encoded with the default prefix
462
391
  // which what is used for password caching mapping
463
-
464
-
465
392
  const {
466
393
  address
467
394
  } = pair;
468
-
469
395
  if (!pair) {
470
396
  reject(new Error('Unable to find pair'));
471
397
  return false;
472
398
  }
399
+ this.refreshAccountPasswordCache(pair);
473
400
 
474
- this.refreshAccountPasswordCache(pair); // if the keyring pair is locked, the password is needed
475
-
401
+ // if the keyring pair is locked, the password is needed
476
402
  if (pair.isLocked && !password) {
477
403
  reject(new Error('Password needed to unlock the account'));
478
404
  }
479
-
480
405
  if (pair.isLocked) {
481
406
  pair.decodePkcs8(password);
482
407
  }
483
-
484
408
  const {
485
409
  payload
486
410
  } = request;
487
-
488
411
  if (isJsonPayload(payload)) {
489
412
  // Get the metadata for the genesisHash
490
- const currentMetadata = this.#state.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash); // set the registry before calling the sign function
413
+ const currentMetadata = this.#state.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
491
414
 
415
+ // set the registry before calling the sign function
492
416
  registry.setSignedExtensions(payload.signedExtensions, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.userExtensions);
493
-
494
417
  if (currentMetadata) {
495
418
  registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
496
419
  }
497
420
  }
498
-
499
421
  const result = request.sign(registry, pair);
500
-
501
422
  if (savePass) {
502
423
  this.#cachedUnlocks[address] = Date.now() + _defaults.PASSWORD_EXPIRY_MS;
503
424
  } else {
504
425
  pair.lock();
505
426
  }
506
-
507
427
  resolve({
508
428
  id,
509
429
  ...result
510
430
  });
511
431
  return true;
512
432
  }
513
-
514
433
  signingApproveSignature(_ref21) {
515
434
  let {
516
435
  id,
@@ -527,7 +446,6 @@ class Extension {
527
446
  });
528
447
  return true;
529
448
  }
530
-
531
449
  signingCancel(_ref22) {
532
450
  let {
533
451
  id
@@ -540,7 +458,6 @@ class Extension {
540
458
  reject(new Error('Cancelled'));
541
459
  return true;
542
460
  }
543
-
544
461
  signingIsLocked(_ref23) {
545
462
  let {
546
463
  id
@@ -548,9 +465,7 @@ class Extension {
548
465
  const queued = this.#state.getSignRequest(id);
549
466
  (0, _util.assert)(queued, 'Unable to find request');
550
467
  const address = queued.request.payload.address;
551
-
552
468
  const pair = _uiKeyring.default.getPair(address);
553
-
554
469
  (0, _util.assert)(pair, 'Unable to find pair');
555
470
  const remainingTime = this.refreshAccountPasswordCache(pair);
556
471
  return {
@@ -558,14 +473,11 @@ class Extension {
558
473
  remainingTime
559
474
  };
560
475
  }
561
-
562
476
  qrIsLocked(_ref24) {
563
477
  let {
564
478
  address
565
479
  } = _ref24;
566
-
567
480
  const pair = _uiKeyring.default.getPair(address);
568
-
569
481
  (0, _util.assert)(pair, 'Unable to find pair');
570
482
  const remainingTime = this.refreshAccountPasswordCache(pair);
571
483
  return {
@@ -573,7 +485,6 @@ class Extension {
573
485
  remainingTime
574
486
  };
575
487
  }
576
-
577
488
  qrSignSubstrate(_ref25) {
578
489
  let {
579
490
  address,
@@ -581,15 +492,11 @@ class Extension {
581
492
  password,
582
493
  savePass
583
494
  } = _ref25;
584
-
585
495
  const pair = _uiKeyring.default.getPair(address);
586
-
587
496
  (0, _util.assert)(pair, 'Unable to find pair');
588
-
589
497
  if (pair.isLocked && !password) {
590
498
  throw new Error('Password needed to unlock the account');
591
499
  }
592
-
593
500
  if (pair.isLocked) {
594
501
  try {
595
502
  pair.decodePkcs8(password);
@@ -597,22 +504,19 @@ class Extension {
597
504
  throw new Error('invalid password');
598
505
  }
599
506
  }
600
-
601
507
  const signed = (0, _util.u8aToHex)(pair.sign(message));
602
508
  const _address = pair.address;
603
-
604
509
  if (savePass) {
605
510
  this.#cachedUnlocks[_address] = Date.now() + _defaults.PASSWORD_EXPIRY_MS;
606
511
  } else {
607
512
  pair.lock();
608
513
  }
609
-
610
514
  return {
611
515
  signature: signed
612
516
  };
613
- } // FIXME This looks very much like what we have in authorization
614
-
517
+ }
615
518
 
519
+ // FIXME This looks very much like what we have in authorization
616
520
  signingSubscribe(id, port) {
617
521
  const cb = (0, _subscriptions.createSubscription)(id, port);
618
522
  const subscription = this.#state.signSubject.subscribe(requests => cb(requests));
@@ -622,37 +526,30 @@ class Extension {
622
526
  });
623
527
  return true;
624
528
  }
625
-
626
529
  windowOpen(path) {
627
530
  const url = `${chrome.extension.getURL('index.html')}#${path}`;
628
-
629
531
  if (!_defaults.ALLOWED_PATH.includes(path)) {
630
532
  console.error('Not allowed to open the url:', url);
631
533
  return false;
632
534
  }
633
-
634
535
  (0, _helpers.withErrorLog)(() => chrome.tabs.create({
635
536
  url
636
537
  }));
637
538
  return true;
638
539
  }
639
-
640
540
  derive(parentAddress, suri, password, metadata) {
641
541
  const parentPair = _uiKeyring.default.getPair(parentAddress);
642
-
643
542
  try {
644
543
  parentPair.decodePkcs8(password);
645
544
  } catch (e) {
646
545
  throw new Error('invalid password');
647
546
  }
648
-
649
547
  try {
650
548
  return parentPair.derive(suri, metadata);
651
549
  } catch (err) {
652
550
  throw new Error(`"${suri}" is not a valid derivation path`);
653
551
  }
654
552
  }
655
-
656
553
  derivationValidate(_ref26) {
657
554
  let {
658
555
  parentAddress,
@@ -665,7 +562,6 @@ class Extension {
665
562
  suri
666
563
  };
667
564
  }
668
-
669
565
  derivationCreate(_ref27) {
670
566
  let {
671
567
  genesisHash,
@@ -681,143 +577,100 @@ class Extension {
681
577
  parentAddress,
682
578
  suri
683
579
  });
684
-
685
580
  _uiKeyring.default.addPair(childPair, password);
686
-
687
581
  return true;
688
582
  }
689
-
690
583
  toggleAuthorization(url) {
691
584
  return {
692
585
  list: this.#state.toggleAuthorization(url)
693
586
  };
694
- } // Weird thought, the eslint override is not needed in Tabs
695
- // eslint-disable-next-line @typescript-eslint/require-await
696
-
587
+ }
697
588
 
589
+ // Weird thought, the eslint override is not needed in Tabs
590
+ // eslint-disable-next-line @typescript-eslint/require-await
698
591
  async handle(id, type, request, port) {
699
592
  switch (type) {
700
593
  case 'pri(authorize.approve)':
701
594
  return this.authorizeApprove(request);
702
-
703
595
  case 'pri(authorize.list)':
704
596
  return this.getAuthList();
705
-
706
597
  case 'pri(authorize.reject)':
707
598
  return this.authorizeReject(request);
708
-
709
599
  case 'pri(authorize.toggle)':
710
600
  return this.toggleAuthorization(request);
711
-
712
601
  case 'pri(authorize.requests)':
713
602
  return this.authorizeSubscribe(id, port);
714
-
715
603
  case 'pri(accounts.create.external)':
716
604
  return this.accountsCreateExternal(request);
717
-
718
605
  case 'pri(accounts.create.hardware)':
719
606
  return this.accountsCreateHardware(request);
720
-
721
607
  case 'pri(accounts.create.suri)':
722
608
  return this.accountsCreateSuri(request);
723
-
724
609
  case 'pri(accounts.changePassword)':
725
610
  return this.accountsChangePassword(request);
726
-
727
611
  case 'pri(accounts.edit)':
728
612
  return this.accountsEdit(request);
729
-
730
613
  case 'pri(accounts.export)':
731
614
  return this.accountsExport(request);
732
-
733
615
  case 'pri(accounts.batchExport)':
734
616
  // return this.accountsBatchExport(request as RequestAccountBatchExport);
735
617
  // Disable export all util use master password
736
618
  return null;
737
-
738
619
  case 'pri(accounts.forget)':
739
620
  return this.accountsForget(request);
740
-
741
621
  case 'pri(accounts.show)':
742
622
  return this.accountsShow(request);
743
-
744
623
  case 'pri(accounts.subscribe)':
745
624
  return this.accountsSubscribe(id, port);
746
-
747
625
  case 'pri(accounts.tie)':
748
626
  return this.accountsTie(request);
749
-
750
627
  case 'pri(accounts.validate)':
751
628
  return this.accountsValidate(request);
752
-
753
629
  case 'pri(metadata.approve)':
754
630
  return this.metadataApprove(request);
755
-
756
631
  case 'pri(metadata.get)':
757
632
  return this.metadataGet(request);
758
-
759
633
  case 'pri(metadata.list)':
760
634
  return this.metadataList();
761
-
762
635
  case 'pri(metadata.reject)':
763
636
  return this.metadataReject(request);
764
-
765
637
  case 'pri(metadata.requests)':
766
638
  return this.metadataSubscribe(id, port);
767
-
768
639
  case 'pri(derivation.create)':
769
640
  return this.derivationCreate(request);
770
-
771
641
  case 'pri(derivation.validate)':
772
642
  return this.derivationValidate(request);
773
-
774
643
  case 'pri(json.restore)':
775
644
  return this.jsonRestore(request);
776
-
777
645
  case 'pri(json.batchRestore)':
778
646
  return this.batchRestore(request);
779
-
780
647
  case 'pri(json.account.info)':
781
648
  return this.jsonGetAccountInfo(request);
782
-
783
649
  case 'pri(seed.create)':
784
650
  return this.seedCreate(request);
785
-
786
651
  case 'pri(seed.validate)':
787
652
  return this.seedValidate(request);
788
-
789
653
  case 'pri(settings.notification)':
790
654
  return this.#state.setNotification(request);
791
-
792
655
  case 'pri(signing.approve.password)':
793
656
  return this.signingApprovePassword(request);
794
-
795
657
  case 'pri(signing.approve.signature)':
796
658
  return this.signingApproveSignature(request);
797
-
798
659
  case 'pri(signing.cancel)':
799
660
  return this.signingCancel(request);
800
-
801
661
  case 'pri(signing.isLocked)':
802
662
  return this.signingIsLocked(request);
803
-
804
663
  case 'pri(qr.isLocked)':
805
664
  return this.qrIsLocked(request);
806
-
807
665
  case 'pri(qr.sign.substrate)':
808
666
  return this.qrSignSubstrate(request);
809
-
810
667
  case 'pri(signing.requests)':
811
668
  return this.signingSubscribe(id, port);
812
-
813
669
  case 'pri(window.open)':
814
670
  return this.windowOpen(request);
815
-
816
671
  default:
817
672
  throw new Error(`Unable to handle message of type ${type}`);
818
673
  }
819
674
  }
820
-
821
675
  }
822
-
823
676
  exports.default = Extension;