@polkadot/extension-base 0.44.6 → 0.44.7

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 (63) hide show
  1. package/background/RequestBytesSign.js +1 -2
  2. package/background/RequestExtrinsicSign.js +1 -2
  3. package/background/handlers/Extension.d.ts +4 -1
  4. package/background/handlers/Extension.js +79 -146
  5. package/background/handlers/State.d.ts +8 -3
  6. package/background/handlers/State.js +60 -67
  7. package/background/handlers/Tabs.d.ts +1 -1
  8. package/background/handlers/Tabs.js +17 -57
  9. package/background/handlers/helpers.js +1 -1
  10. package/background/handlers/index.d.ts +1 -1
  11. package/background/handlers/index.js +6 -4
  12. package/background/handlers/subscriptions.js +5 -2
  13. package/background/types.d.ts +33 -25
  14. package/bundle.js +1 -0
  15. package/cjs/background/RequestBytesSign.js +1 -6
  16. package/cjs/background/RequestExtrinsicSign.js +1 -4
  17. package/cjs/background/handlers/Extension.js +95 -207
  18. package/cjs/background/handlers/State.js +60 -82
  19. package/cjs/background/handlers/Tabs.js +17 -70
  20. package/cjs/background/handlers/helpers.js +1 -2
  21. package/cjs/background/handlers/index.js +6 -12
  22. package/cjs/background/handlers/subscriptions.js +5 -3
  23. package/cjs/bundle.js +0 -1
  24. package/cjs/defaults.js +16 -8
  25. package/cjs/detectOther.js +0 -4
  26. package/cjs/detectPackage.js +2 -4
  27. package/cjs/index.js +0 -2
  28. package/cjs/packageInfo.js +3 -1
  29. package/cjs/page/Accounts.js +1 -5
  30. package/cjs/page/Injected.js +6 -8
  31. package/cjs/page/Metadata.js +1 -5
  32. package/cjs/page/PostMessageProvider.js +25 -38
  33. package/cjs/page/Signer.js +12 -12
  34. package/cjs/page/index.js +8 -14
  35. package/cjs/stores/Accounts.js +2 -9
  36. package/cjs/stores/Base.js +1 -14
  37. package/cjs/stores/Metadata.js +2 -7
  38. package/cjs/stores/index.js +0 -3
  39. package/cjs/utils/canDerive.js +1 -1
  40. package/cjs/utils/getId.js +1 -3
  41. package/cjs/utils/index.js +0 -1
  42. package/defaults.d.ts +2 -2
  43. package/defaults.js +14 -5
  44. package/detectOther.js +1 -0
  45. package/detectPackage.js +2 -0
  46. package/index.js +2 -0
  47. package/package.json +16 -16
  48. package/packageInfo.js +3 -1
  49. package/page/Accounts.js +1 -3
  50. package/page/Injected.js +6 -1
  51. package/page/Metadata.js +1 -3
  52. package/page/PostMessageProvider.d.ts +2 -1
  53. package/page/PostMessageProvider.js +25 -33
  54. package/page/Signer.js +12 -10
  55. package/page/index.d.ts +1 -1
  56. package/page/index.js +11 -7
  57. package/stores/Accounts.js +2 -4
  58. package/stores/Base.js +1 -12
  59. package/stores/Metadata.js +2 -2
  60. package/stores/index.js +1 -0
  61. package/utils/canDerive.js +1 -0
  62. package/utils/getId.js +1 -0
  63. package/utils/index.js +1 -0
@@ -1,16 +1,15 @@
1
1
  // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+
3
4
  import { wrapBytes } from '@polkadot/extension-dapp/wrapBytes';
4
5
  import { u8aToHex } from '@polkadot/util';
5
6
  export default class RequestBytesSign {
6
7
  constructor(payload) {
7
8
  this.payload = payload;
8
9
  }
9
-
10
10
  sign(_registry, pair) {
11
11
  return {
12
12
  signature: u8aToHex(pair.sign(wrapBytes(this.payload.data)))
13
13
  };
14
14
  }
15
-
16
15
  }
@@ -1,14 +1,13 @@
1
1
  // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+
3
4
  export default class RequestExtrinsicSign {
4
5
  constructor(payload) {
5
6
  this.payload = payload;
6
7
  }
7
-
8
8
  sign(registry, pair) {
9
9
  return registry.createType('ExtrinsicPayload', this.payload, {
10
10
  version: this.payload.version
11
11
  }).sign(pair);
12
12
  }
13
-
14
13
  }
@@ -4,6 +4,7 @@ import State from './State';
4
4
  export default class Extension {
5
5
  #private;
6
6
  constructor(state: State);
7
+ private transformAccounts;
7
8
  private accountsCreateExternal;
8
9
  private accountsCreateHardware;
9
10
  private accountsCreateSuri;
@@ -42,5 +43,7 @@ export default class Extension {
42
43
  private derivationCreate;
43
44
  private removeAuthorization;
44
45
  private deleteAuthRequest;
45
- handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
46
+ private updateCurrentTabs;
47
+ private getConnectedTabsUrl;
48
+ handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port?: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
46
49
  }
@@ -1,6 +1,8 @@
1
1
  // Copyright 2019-2022 @polkadot/extension authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+
3
4
  import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@polkadot/extension-base/defaults';
5
+ import { metadataExpand } from '@polkadot/extension-chains';
4
6
  import { TypeRegistry } from '@polkadot/types';
5
7
  import keyring from '@polkadot/ui-keyring';
6
8
  import { accounts as accountsObservable } from '@polkadot/ui-keyring/observable/accounts';
@@ -10,41 +12,34 @@ import { withErrorLog } from "./helpers.js";
10
12
  import { createSubscription, unsubscribe } from "./subscriptions.js";
11
13
  const SEED_DEFAULT_LENGTH = 12;
12
14
  const SEED_LENGTHS = [12, 15, 18, 21, 24];
13
- const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0"; // a global registry to use internally
14
-
15
- const registry = new TypeRegistry();
16
-
15
+ const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0";
17
16
  function getSuri(seed, type) {
18
17
  return type === 'ethereum' ? `${seed}${ETH_DERIVE_DEFAULT}` : seed;
19
18
  }
20
-
21
- function transformAccounts(accounts) {
22
- return Object.values(accounts).map(({
23
- json: {
24
- address,
25
- meta
26
- },
27
- type
28
- }) => ({
29
- address,
30
- ...meta,
31
- type
32
- }));
33
- }
34
-
35
19
  function isJsonPayload(value) {
36
20
  return value.genesisHash !== undefined;
37
21
  }
38
-
39
22
  export default class Extension {
40
23
  #cachedUnlocks;
41
24
  #state;
42
-
43
25
  constructor(state) {
44
26
  this.#cachedUnlocks = {};
45
27
  this.#state = state;
46
28
  }
47
-
29
+ transformAccounts(accounts) {
30
+ return Object.values(accounts).map(({
31
+ json: {
32
+ address,
33
+ meta
34
+ },
35
+ type
36
+ }) => ({
37
+ address,
38
+ isDefaultAuthSelected: this.#state.defaultAuthAccountSelection.includes(address),
39
+ ...meta,
40
+ type
41
+ }));
42
+ }
48
43
  accountsCreateExternal({
49
44
  address,
50
45
  genesisHash,
@@ -56,7 +51,6 @@ export default class Extension {
56
51
  });
57
52
  return true;
58
53
  }
59
-
60
54
  accountsCreateHardware({
61
55
  accountIndex,
62
56
  address,
@@ -73,7 +67,6 @@ export default class Extension {
73
67
  });
74
68
  return true;
75
69
  }
76
-
77
70
  accountsCreateSuri({
78
71
  genesisHash,
79
72
  name,
@@ -87,7 +80,6 @@ export default class Extension {
87
80
  }, type);
88
81
  return true;
89
82
  }
90
-
91
83
  accountsChangePassword({
92
84
  address,
93
85
  newPass,
@@ -95,33 +87,29 @@ export default class Extension {
95
87
  }) {
96
88
  const pair = keyring.getPair(address);
97
89
  assert(pair, 'Unable to find pair');
98
-
99
90
  try {
100
91
  if (!pair.isLocked) {
101
92
  pair.lock();
102
93
  }
103
-
104
94
  pair.decodePkcs8(oldPass);
105
95
  } catch (error) {
106
96
  throw new Error('oldPass is invalid');
107
97
  }
108
-
109
98
  keyring.encryptAccount(pair, newPass);
110
99
  return true;
111
100
  }
112
-
113
101
  accountsEdit({
114
102
  address,
115
103
  name
116
104
  }) {
117
105
  const pair = keyring.getPair(address);
118
106
  assert(pair, 'Unable to find pair');
119
- keyring.saveAccountMeta(pair, { ...pair.meta,
107
+ keyring.saveAccountMeta(pair, {
108
+ ...pair.meta,
120
109
  name
121
110
  });
122
111
  return true;
123
112
  }
124
-
125
113
  accountsExport({
126
114
  address,
127
115
  password
@@ -130,7 +118,6 @@ export default class Extension {
130
118
  exportedJson: keyring.backupAccount(keyring.getPair(address), password)
131
119
  };
132
120
  }
133
-
134
121
  async accountsBatchExport({
135
122
  addresses,
136
123
  password
@@ -139,64 +126,63 @@ export default class Extension {
139
126
  exportedJson: await keyring.backupAccounts(addresses, password)
140
127
  };
141
128
  }
142
-
143
129
  accountsForget({
144
130
  address
145
131
  }) {
146
- const authorizedAccountsDiff = []; // cycle through authUrls and prepare the array of diff
132
+ const authorizedAccountsDiff = [];
147
133
 
134
+ // cycle through authUrls and prepare the array of diff
148
135
  Object.entries(this.#state.authUrls).forEach(([url, urlInfo]) => {
149
136
  if (!urlInfo.authorizedAccounts.includes(address)) {
150
137
  return;
151
138
  }
152
-
153
139
  authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter(previousAddress => previousAddress !== address)]);
154
140
  });
155
141
  this.#state.updateAuthorizedAccounts(authorizedAccountsDiff);
142
+
143
+ // cycle through default account selection for auth and remove any occurence of the account
144
+ const newDefaultAuthAccounts = this.#state.defaultAuthAccountSelection.filter(defaultSelectionAddress => defaultSelectionAddress !== address);
145
+ this.#state.updateDefaultAuthAccounts(newDefaultAuthAccounts);
156
146
  keyring.forgetAccount(address);
157
147
  return true;
158
148
  }
159
-
160
149
  refreshAccountPasswordCache(pair) {
161
150
  const {
162
151
  address
163
152
  } = pair;
164
153
  const savedExpiry = this.#cachedUnlocks[address] || 0;
165
154
  const remainingTime = savedExpiry - Date.now();
166
-
167
155
  if (remainingTime < 0) {
168
156
  this.#cachedUnlocks[address] = 0;
169
157
  pair.lock();
170
158
  return 0;
171
159
  }
172
-
173
160
  return remainingTime;
174
161
  }
175
-
176
162
  accountsShow({
177
163
  address,
178
164
  isShowing
179
165
  }) {
180
166
  const pair = keyring.getPair(address);
181
167
  assert(pair, 'Unable to find pair');
182
- keyring.saveAccountMeta(pair, { ...pair.meta,
168
+ keyring.saveAccountMeta(pair, {
169
+ ...pair.meta,
183
170
  isHidden: !isShowing
184
171
  });
185
172
  return true;
186
173
  }
187
-
188
174
  accountsTie({
189
175
  address,
190
176
  genesisHash
191
177
  }) {
192
178
  const pair = keyring.getPair(address);
193
179
  assert(pair, 'Unable to find pair');
194
- keyring.saveAccountMeta(pair, { ...pair.meta,
180
+ keyring.saveAccountMeta(pair, {
181
+ ...pair.meta,
195
182
  genesisHash
196
183
  });
197
184
  return true;
198
185
  }
199
-
200
186
  accountsValidate({
201
187
  address,
202
188
  password
@@ -208,17 +194,15 @@ export default class Extension {
208
194
  return false;
209
195
  }
210
196
  }
211
-
212
197
  accountsSubscribe(id, port) {
213
198
  const cb = createSubscription(id, port);
214
- const subscription = accountsObservable.subject.subscribe(accounts => cb(transformAccounts(accounts)));
199
+ const subscription = accountsObservable.subject.subscribe(accounts => cb(this.transformAccounts(accounts)));
215
200
  port.onDisconnect.addListener(() => {
216
201
  unsubscribe(id);
217
202
  subscription.unsubscribe();
218
203
  });
219
204
  return true;
220
205
  }
221
-
222
206
  authorizeApprove({
223
207
  authorizedAccounts,
224
208
  id
@@ -234,21 +218,19 @@ export default class Extension {
234
218
  });
235
219
  return true;
236
220
  }
237
-
238
221
  authorizeUpdate({
239
222
  authorizedAccounts,
240
223
  url
241
224
  }) {
242
225
  return this.#state.updateAuthorizedAccounts([[url, authorizedAccounts]]);
243
226
  }
244
-
245
227
  getAuthList() {
246
228
  return {
247
229
  list: this.#state.authUrls
248
230
  };
249
- } // FIXME This looks very much like what we have in accounts
250
-
231
+ }
251
232
 
233
+ // FIXME This looks very much like what we have in accounts
252
234
  authorizeSubscribe(id, port) {
253
235
  const cb = createSubscription(id, port);
254
236
  const subscription = this.#state.authSubject.subscribe(requests => cb(requests));
@@ -258,7 +240,6 @@ export default class Extension {
258
240
  });
259
241
  return true;
260
242
  }
261
-
262
243
  metadataApprove({
263
244
  id
264
245
  }) {
@@ -272,15 +253,12 @@ export default class Extension {
272
253
  resolve(true);
273
254
  return true;
274
255
  }
275
-
276
256
  metadataGet(genesisHash) {
277
257
  return this.#state.knownMetadata.find(result => result.genesisHash === genesisHash) || null;
278
258
  }
279
-
280
259
  metadataList() {
281
260
  return this.#state.knownMetadata;
282
261
  }
283
-
284
262
  metadataReject({
285
263
  id
286
264
  }) {
@@ -292,7 +270,6 @@ export default class Extension {
292
270
  reject(new Error('Rejected'));
293
271
  return true;
294
272
  }
295
-
296
273
  metadataSubscribe(id, port) {
297
274
  const cb = createSubscription(id, port);
298
275
  const subscription = this.#state.metaSubject.subscribe(requests => cb(requests));
@@ -302,7 +279,6 @@ export default class Extension {
302
279
  });
303
280
  return true;
304
281
  }
305
-
306
282
  jsonRestore({
307
283
  file,
308
284
  password
@@ -313,7 +289,6 @@ export default class Extension {
313
289
  throw new Error(error.message);
314
290
  }
315
291
  }
316
-
317
292
  batchRestore({
318
293
  file,
319
294
  password
@@ -324,7 +299,6 @@ export default class Extension {
324
299
  throw new Error(error.message);
325
300
  }
326
301
  }
327
-
328
302
  jsonGetAccountInfo(json) {
329
303
  try {
330
304
  const {
@@ -346,20 +320,17 @@ export default class Extension {
346
320
  throw new Error(e.message);
347
321
  }
348
322
  }
349
-
350
323
  seedCreate({
351
324
  length = SEED_DEFAULT_LENGTH,
352
325
  seed: _seed,
353
326
  type
354
327
  }) {
355
328
  const seed = _seed || mnemonicGenerate(length);
356
-
357
329
  return {
358
330
  address: keyring.createFromUri(getSuri(seed, type), {}, type).address,
359
331
  seed
360
332
  };
361
333
  }
362
-
363
334
  seedValidate({
364
335
  suri,
365
336
  type
@@ -367,7 +338,6 @@ export default class Extension {
367
338
  const {
368
339
  phrase
369
340
  } = keyExtractSuri(suri);
370
-
371
341
  if (isHex(phrase)) {
372
342
  assert(isHex(phrase, 256), 'Hex seed needs to be 256-bits');
373
343
  } else {
@@ -375,13 +345,11 @@ export default class Extension {
375
345
  assert(SEED_LENGTHS.includes(phrase.split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
376
346
  assert(mnemonicValidate(phrase), 'Not a valid mnemonic seed');
377
347
  }
378
-
379
348
  return {
380
349
  address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
381
350
  suri
382
351
  };
383
352
  }
384
-
385
353
  signingApprovePassword({
386
354
  id,
387
355
  password,
@@ -394,59 +362,60 @@ export default class Extension {
394
362
  request,
395
363
  resolve
396
364
  } = queued;
397
- const pair = keyring.getPair(queued.account.address); // unlike queued.account.address the following
398
- // address is encoded with the default prefix
399
- // which what is used for password caching mapping
400
-
401
- const {
402
- address
403
- } = pair;
404
-
365
+ const pair = keyring.getPair(queued.account.address);
405
366
  if (!pair) {
406
367
  reject(new Error('Unable to find pair'));
407
368
  return false;
408
369
  }
370
+ this.refreshAccountPasswordCache(pair);
409
371
 
410
- this.refreshAccountPasswordCache(pair); // if the keyring pair is locked, the password is needed
411
-
372
+ // if the keyring pair is locked, the password is needed
412
373
  if (pair.isLocked && !password) {
413
374
  reject(new Error('Password needed to unlock the account'));
414
375
  }
415
-
416
376
  if (pair.isLocked) {
417
377
  pair.decodePkcs8(password);
418
378
  }
419
379
 
380
+ // construct a new registry (avoiding pollution), between requests
381
+ let registry;
420
382
  const {
421
383
  payload
422
384
  } = request;
423
-
424
385
  if (isJsonPayload(payload)) {
425
386
  // Get the metadata for the genesisHash
426
- const currentMetadata = this.#state.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash); // set the registry before calling the sign function
427
-
428
- registry.setSignedExtensions(payload.signedExtensions, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.userExtensions);
429
-
430
- if (currentMetadata) {
431
- registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
387
+ const metadata = this.#state.knownMetadata.find(({
388
+ genesisHash
389
+ }) => genesisHash === payload.genesisHash);
390
+ if (metadata) {
391
+ // we have metadata, expand it and extract the info/registry
392
+ const expanded = metadataExpand(metadata, false);
393
+ registry = expanded.registry;
394
+ registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions);
395
+ } else {
396
+ // we have no metadata, create a new registry
397
+ registry = new TypeRegistry();
398
+ registry.setSignedExtensions(payload.signedExtensions);
432
399
  }
400
+ } else {
401
+ // for non-payload, just create a registry to use
402
+ registry = new TypeRegistry();
433
403
  }
434
-
435
404
  const result = request.sign(registry, pair);
436
-
437
405
  if (savePass) {
438
- this.#cachedUnlocks[address] = Date.now() + PASSWORD_EXPIRY_MS;
406
+ // unlike queued.account.address the following
407
+ // address is encoded with the default prefix
408
+ // which what is used for password caching mapping
409
+ this.#cachedUnlocks[pair.address] = Date.now() + PASSWORD_EXPIRY_MS;
439
410
  } else {
440
411
  pair.lock();
441
412
  }
442
-
443
413
  resolve({
444
414
  id,
445
415
  ...result
446
416
  });
447
417
  return true;
448
418
  }
449
-
450
419
  signingApproveSignature({
451
420
  id,
452
421
  signature
@@ -462,7 +431,6 @@ export default class Extension {
462
431
  });
463
432
  return true;
464
433
  }
465
-
466
434
  signingCancel({
467
435
  id
468
436
  }) {
@@ -474,7 +442,6 @@ export default class Extension {
474
442
  reject(new Error('Cancelled'));
475
443
  return true;
476
444
  }
477
-
478
445
  signingIsLocked({
479
446
  id
480
447
  }) {
@@ -488,9 +455,9 @@ export default class Extension {
488
455
  isLocked: pair.isLocked,
489
456
  remainingTime
490
457
  };
491
- } // FIXME This looks very much like what we have in authorization
492
-
458
+ }
493
459
 
460
+ // FIXME This looks very much like what we have in authorization
494
461
  signingSubscribe(id, port) {
495
462
  const cb = createSubscription(id, port);
496
463
  const subscription = this.#state.signSubject.subscribe(requests => cb(requests));
@@ -500,37 +467,30 @@ export default class Extension {
500
467
  });
501
468
  return true;
502
469
  }
503
-
504
470
  windowOpen(path) {
505
471
  const url = `${chrome.extension.getURL('index.html')}#${path}`;
506
-
507
472
  if (!ALLOWED_PATH.includes(path)) {
508
473
  console.error('Not allowed to open the url:', url);
509
474
  return false;
510
475
  }
511
-
512
476
  withErrorLog(() => chrome.tabs.create({
513
477
  url
514
478
  }));
515
479
  return true;
516
480
  }
517
-
518
481
  derive(parentAddress, suri, password, metadata) {
519
482
  const parentPair = keyring.getPair(parentAddress);
520
-
521
483
  try {
522
484
  parentPair.decodePkcs8(password);
523
485
  } catch (e) {
524
486
  throw new Error('invalid password');
525
487
  }
526
-
527
488
  try {
528
489
  return parentPair.derive(suri, metadata);
529
490
  } catch (err) {
530
491
  throw new Error(`"${suri}" is not a valid derivation path`);
531
492
  }
532
493
  }
533
-
534
494
  derivationValidate({
535
495
  parentAddress,
536
496
  parentPassword,
@@ -542,7 +502,6 @@ export default class Extension {
542
502
  suri
543
503
  };
544
504
  }
545
-
546
505
  derivationCreate({
547
506
  genesisHash,
548
507
  name,
@@ -560,135 +519,109 @@ export default class Extension {
560
519
  keyring.addPair(childPair, password);
561
520
  return true;
562
521
  }
563
-
564
522
  removeAuthorization(url) {
565
523
  return {
566
524
  list: this.#state.removeAuthorization(url)
567
525
  };
568
526
  }
569
-
570
527
  deleteAuthRequest(requestId) {
571
528
  return this.#state.deleteAuthRequest(requestId);
572
- } // Weird thought, the eslint override is not needed in Tabs
573
- // eslint-disable-next-line @typescript-eslint/require-await
574
-
529
+ }
530
+ updateCurrentTabs({
531
+ urls
532
+ }) {
533
+ this.#state.udateCurrentTabsUrl(urls);
534
+ }
535
+ getConnectedTabsUrl() {
536
+ return this.#state.getConnectedTabsUrl();
537
+ }
575
538
 
539
+ // Weird thought, the eslint override is not needed in Tabs
540
+ // eslint-disable-next-line @typescript-eslint/require-await
576
541
  async handle(id, type, request, port) {
577
542
  switch (type) {
578
543
  case 'pri(authorize.approve)':
579
544
  return this.authorizeApprove(request);
580
-
581
545
  case 'pri(authorize.list)':
582
546
  return this.getAuthList();
583
-
584
547
  case 'pri(authorize.remove)':
585
548
  return this.removeAuthorization(request);
586
-
587
549
  case 'pri(authorize.delete.request)':
588
550
  return this.deleteAuthRequest(request);
589
-
590
551
  case 'pri(authorize.requests)':
591
- return this.authorizeSubscribe(id, port);
592
-
552
+ return port && this.authorizeSubscribe(id, port);
593
553
  case 'pri(authorize.update)':
594
554
  return this.authorizeUpdate(request);
595
-
596
555
  case 'pri(accounts.create.external)':
597
556
  return this.accountsCreateExternal(request);
598
-
599
557
  case 'pri(accounts.create.hardware)':
600
558
  return this.accountsCreateHardware(request);
601
-
602
559
  case 'pri(accounts.create.suri)':
603
560
  return this.accountsCreateSuri(request);
604
-
605
561
  case 'pri(accounts.changePassword)':
606
562
  return this.accountsChangePassword(request);
607
-
608
563
  case 'pri(accounts.edit)':
609
564
  return this.accountsEdit(request);
610
-
611
565
  case 'pri(accounts.export)':
612
566
  return this.accountsExport(request);
613
-
614
567
  case 'pri(accounts.batchExport)':
615
568
  return this.accountsBatchExport(request);
616
-
617
569
  case 'pri(accounts.forget)':
618
570
  return this.accountsForget(request);
619
-
620
571
  case 'pri(accounts.show)':
621
572
  return this.accountsShow(request);
622
-
623
573
  case 'pri(accounts.subscribe)':
624
- return this.accountsSubscribe(id, port);
625
-
574
+ return port && this.accountsSubscribe(id, port);
626
575
  case 'pri(accounts.tie)':
627
576
  return this.accountsTie(request);
628
-
629
577
  case 'pri(accounts.validate)':
630
578
  return this.accountsValidate(request);
631
-
632
579
  case 'pri(metadata.approve)':
633
580
  return this.metadataApprove(request);
634
-
635
581
  case 'pri(metadata.get)':
636
582
  return this.metadataGet(request);
637
-
638
583
  case 'pri(metadata.list)':
639
584
  return this.metadataList();
640
-
641
585
  case 'pri(metadata.reject)':
642
586
  return this.metadataReject(request);
643
-
644
587
  case 'pri(metadata.requests)':
645
- return this.metadataSubscribe(id, port);
646
-
588
+ return port && this.metadataSubscribe(id, port);
589
+ case 'pri(activeTabsUrl.update)':
590
+ return this.updateCurrentTabs(request);
591
+ case 'pri(connectedTabsUrl.get)':
592
+ return this.getConnectedTabsUrl();
647
593
  case 'pri(derivation.create)':
648
594
  return this.derivationCreate(request);
649
-
650
595
  case 'pri(derivation.validate)':
651
596
  return this.derivationValidate(request);
652
-
653
597
  case 'pri(json.restore)':
654
598
  return this.jsonRestore(request);
655
-
656
599
  case 'pri(json.batchRestore)':
657
600
  return this.batchRestore(request);
658
-
659
601
  case 'pri(json.account.info)':
660
602
  return this.jsonGetAccountInfo(request);
661
-
603
+ case 'pri(ping)':
604
+ return Promise.resolve(true);
662
605
  case 'pri(seed.create)':
663
606
  return this.seedCreate(request);
664
-
665
607
  case 'pri(seed.validate)':
666
608
  return this.seedValidate(request);
667
-
668
609
  case 'pri(settings.notification)':
669
610
  return this.#state.setNotification(request);
670
-
671
611
  case 'pri(signing.approve.password)':
672
612
  return this.signingApprovePassword(request);
673
-
674
613
  case 'pri(signing.approve.signature)':
675
614
  return this.signingApproveSignature(request);
676
-
677
615
  case 'pri(signing.cancel)':
678
616
  return this.signingCancel(request);
679
-
680
617
  case 'pri(signing.isLocked)':
681
618
  return this.signingIsLocked(request);
682
-
683
619
  case 'pri(signing.requests)':
684
- return this.signingSubscribe(id, port);
685
-
620
+ return port && this.signingSubscribe(id, port);
686
621
  case 'pri(window.open)':
687
622
  return this.windowOpen(request);
688
-
689
623
  default:
690
624
  throw new Error(`Unable to handle message of type ${type}`);
691
625
  }
692
626
  }
693
-
694
627
  }