@pezkuwi/extension-base 0.62.14 → 0.62.18

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 (160) hide show
  1. package/package.json +16 -470
  2. package/src/background/RequestBytesSign.ts +28 -0
  3. package/src/background/RequestExtrinsicSign.ts +22 -0
  4. package/src/background/handlers/Extension.spec.ts +478 -0
  5. package/src/background/handlers/Extension.ts +690 -0
  6. package/src/background/handlers/State.ts +664 -0
  7. package/src/background/handlers/Tabs.ts +289 -0
  8. package/src/background/handlers/helpers.ts +14 -0
  9. package/src/background/handlers/index.ts +60 -0
  10. package/src/background/handlers/subscriptions.ts +32 -0
  11. package/src/background/index.ts +4 -0
  12. package/src/background/types.ts +432 -0
  13. package/src/bundle.ts +4 -0
  14. package/{defaults.js → src/defaults.ts} +15 -2
  15. package/src/index.ts +7 -0
  16. package/{packageDetect.js → src/packageDetect.ts} +8 -0
  17. package/src/packageInfo.ts +6 -0
  18. package/src/page/Accounts.ts +33 -0
  19. package/src/page/Injected.ts +33 -0
  20. package/src/page/Metadata.ts +22 -0
  21. package/src/page/PostMessageProvider.ts +182 -0
  22. package/src/page/Signer.ts +45 -0
  23. package/src/page/index.ts +89 -0
  24. package/src/page/types.ts +10 -0
  25. package/src/stores/Accounts.ts +28 -0
  26. package/src/stores/Base.ts +93 -0
  27. package/src/stores/Metadata.ts +17 -0
  28. package/{stores/index.js → src/stores/index.ts} +3 -0
  29. package/src/types.ts +12 -0
  30. package/src/utils/canDerive.ts +8 -0
  31. package/src/utils/getId.ts +10 -0
  32. package/src/utils/index.ts +4 -0
  33. package/src/utils/portUtils.ts +65 -0
  34. package/tsconfig.build.json +16 -0
  35. package/tsconfig.build.tsbuildinfo +1 -0
  36. package/tsconfig.spec.json +18 -0
  37. package/tsconfig.spec.tsbuildinfo +1 -0
  38. package/LICENSE +0 -201
  39. package/background/RequestBytesSign.d.ts +0 -12
  40. package/background/RequestBytesSign.js +0 -12
  41. package/background/RequestExtrinsicSign.d.ts +0 -12
  42. package/background/RequestExtrinsicSign.js +0 -11
  43. package/background/handlers/Extension.d.ts +0 -49
  44. package/background/handlers/Extension.js +0 -489
  45. package/background/handlers/State.js +0 -478
  46. package/background/handlers/Tabs.d.ts +0 -25
  47. package/background/handlers/Tabs.js +0 -195
  48. package/background/handlers/helpers.js +0 -11
  49. package/background/handlers/index.d.ts +0 -3
  50. package/background/handlers/index.js +0 -40
  51. package/background/handlers/subscriptions.d.ts +0 -3
  52. package/background/handlers/subscriptions.js +0 -18
  53. package/background/index.d.ts +0 -1
  54. package/background/index.js +0 -1
  55. package/background/types.js +0 -1
  56. package/bundle.d.ts +0 -1
  57. package/bundle.js +0 -1
  58. package/cjs/background/RequestBytesSign.d.ts +0 -12
  59. package/cjs/background/RequestBytesSign.js +0 -15
  60. package/cjs/background/RequestExtrinsicSign.d.ts +0 -12
  61. package/cjs/background/RequestExtrinsicSign.js +0 -14
  62. package/cjs/background/handlers/Extension.d.ts +0 -49
  63. package/cjs/background/handlers/Extension.js +0 -492
  64. package/cjs/background/handlers/State.d.ts +0 -96
  65. package/cjs/background/handlers/State.js +0 -482
  66. package/cjs/background/handlers/Tabs.d.ts +0 -25
  67. package/cjs/background/handlers/Tabs.js +0 -199
  68. package/cjs/background/handlers/helpers.d.ts +0 -1
  69. package/cjs/background/handlers/helpers.js +0 -14
  70. package/cjs/background/handlers/index.d.ts +0 -3
  71. package/cjs/background/handlers/index.js +0 -46
  72. package/cjs/background/handlers/subscriptions.d.ts +0 -3
  73. package/cjs/background/handlers/subscriptions.js +0 -22
  74. package/cjs/background/index.d.ts +0 -1
  75. package/cjs/background/index.js +0 -7
  76. package/cjs/background/types.d.ts +0 -343
  77. package/cjs/background/types.js +0 -2
  78. package/cjs/bundle.d.ts +0 -1
  79. package/cjs/bundle.js +0 -5
  80. package/cjs/defaults.js +0 -16
  81. package/cjs/index.d.ts +0 -1
  82. package/cjs/index.js +0 -4
  83. package/cjs/package.json +0 -3
  84. package/cjs/packageDetect.d.ts +0 -1
  85. package/cjs/packageDetect.js +0 -8
  86. package/cjs/packageInfo.d.ts +0 -6
  87. package/cjs/packageInfo.js +0 -4
  88. package/cjs/page/Accounts.d.ts +0 -7
  89. package/cjs/page/Accounts.js +0 -24
  90. package/cjs/page/Injected.d.ts +0 -13
  91. package/cjs/page/Injected.js +0 -25
  92. package/cjs/page/Metadata.d.ts +0 -7
  93. package/cjs/page/Metadata.js +0 -15
  94. package/cjs/page/PostMessageProvider.d.ts +0 -63
  95. package/cjs/page/PostMessageProvider.js +0 -135
  96. package/cjs/page/Signer.d.ts +0 -8
  97. package/cjs/page/Signer.js +0 -29
  98. package/cjs/page/index.d.ts +0 -16
  99. package/cjs/page/index.js +0 -52
  100. package/cjs/page/types.d.ts +0 -6
  101. package/cjs/page/types.js +0 -2
  102. package/cjs/stores/Accounts.js +0 -21
  103. package/cjs/stores/Base.js +0 -70
  104. package/cjs/stores/Metadata.js +0 -13
  105. package/cjs/stores/index.js +0 -8
  106. package/cjs/types.js +0 -2
  107. package/cjs/utils/canDerive.d.ts +0 -2
  108. package/cjs/utils/canDerive.js +0 -6
  109. package/cjs/utils/getId.js +0 -8
  110. package/cjs/utils/index.d.ts +0 -1
  111. package/cjs/utils/index.js +0 -5
  112. package/cjs/utils/portUtils.d.ts +0 -13
  113. package/cjs/utils/portUtils.js +0 -49
  114. package/defaults.d.ts +0 -9
  115. package/index.d.ts +0 -1
  116. package/index.js +0 -1
  117. package/packageDetect.d.ts +0 -1
  118. package/packageInfo.d.ts +0 -6
  119. package/packageInfo.js +0 -1
  120. package/page/Accounts.d.ts +0 -7
  121. package/page/Accounts.js +0 -21
  122. package/page/Injected.d.ts +0 -13
  123. package/page/Injected.js +0 -21
  124. package/page/Metadata.d.ts +0 -7
  125. package/page/Metadata.js +0 -12
  126. package/page/PostMessageProvider.d.ts +0 -63
  127. package/page/PostMessageProvider.js +0 -132
  128. package/page/Signer.d.ts +0 -8
  129. package/page/Signer.js +0 -26
  130. package/page/index.d.ts +0 -16
  131. package/page/index.js +0 -45
  132. package/page/types.d.ts +0 -6
  133. package/page/types.js +0 -1
  134. package/stores/Accounts.d.ts +0 -6
  135. package/stores/Accounts.js +0 -17
  136. package/stores/Base.d.ts +0 -9
  137. package/stores/Base.js +0 -67
  138. package/stores/Metadata.d.ts +0 -5
  139. package/stores/Metadata.js +0 -9
  140. package/stores/index.d.ts +0 -2
  141. package/types.d.ts +0 -9
  142. package/types.js +0 -1
  143. package/utils/canDerive.d.ts +0 -2
  144. package/utils/canDerive.js +0 -3
  145. package/utils/getId.d.ts +0 -1
  146. package/utils/getId.js +0 -5
  147. package/utils/index.d.ts +0 -1
  148. package/utils/index.js +0 -1
  149. package/utils/portUtils.d.ts +0 -13
  150. package/utils/portUtils.js +0 -43
  151. /package/{background → src/background}/handlers/State.d.ts +0 -0
  152. /package/{background → src/background}/handlers/helpers.d.ts +0 -0
  153. /package/{background → src/background}/types.d.ts +0 -0
  154. /package/{cjs → src}/defaults.d.ts +0 -0
  155. /package/{cjs → src}/stores/Accounts.d.ts +0 -0
  156. /package/{cjs → src}/stores/Base.d.ts +0 -0
  157. /package/{cjs → src}/stores/Metadata.d.ts +0 -0
  158. /package/{cjs → src}/stores/index.d.ts +0 -0
  159. /package/{cjs → src}/types.d.ts +0 -0
  160. /package/{cjs → src}/utils/getId.d.ts +0 -0
@@ -1,489 +0,0 @@
1
- import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@pezkuwi/extension-base/defaults';
2
- import { metadataExpand } from '@pezkuwi/extension-chains';
3
- import { TypeRegistry } from '@pezkuwi/types';
4
- import { keyring } from '@pezkuwi/ui-keyring';
5
- import { accounts as accountsObservable } from '@pezkuwi/ui-keyring/observable/accounts';
6
- import { assert, isHex } from '@pezkuwi/util';
7
- import { keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@pezkuwi/util-crypto';
8
- import { withErrorLog } from './helpers.js';
9
- import { createSubscription, unsubscribe } from './subscriptions.js';
10
- const SEED_DEFAULT_LENGTH = 12;
11
- const SEED_LENGTHS = [12, 15, 18, 21, 24];
12
- const ETH_DERIVE_DEFAULT = "/m/44'/60'/0'/0/0";
13
- function getSuri(seed, type) {
14
- return type === 'ethereum'
15
- ? `${seed}${ETH_DERIVE_DEFAULT}`
16
- : seed;
17
- }
18
- function isJsonPayload(value) {
19
- return value.genesisHash !== undefined;
20
- }
21
- export default class Extension {
22
- #cachedUnlocks;
23
- #state;
24
- constructor(state) {
25
- this.#cachedUnlocks = {};
26
- this.#state = state;
27
- }
28
- transformAccounts(accounts) {
29
- return Object.values(accounts).map(({ json: { address, meta }, type }) => ({
30
- address,
31
- isDefaultAuthSelected: this.#state.defaultAuthAccountSelection.includes(address),
32
- ...meta,
33
- type
34
- }));
35
- }
36
- accountsCreateExternal({ address, genesisHash, name }) {
37
- keyring.addExternal(address, { genesisHash, name });
38
- return true;
39
- }
40
- accountsCreateHardware({ accountIndex, address, addressOffset, genesisHash, hardwareType, name, type }) {
41
- keyring.addHardware(address, hardwareType, { accountIndex, addressOffset, genesisHash, name, type });
42
- return true;
43
- }
44
- accountsCreateSuri({ genesisHash, name, password, suri, type }) {
45
- keyring.addUri(getSuri(suri, type), password, { genesisHash, name }, type);
46
- return true;
47
- }
48
- accountsChangePassword({ address, newPass, oldPass }) {
49
- const pair = keyring.getPair(address);
50
- assert(pair, 'Unable to find pair');
51
- try {
52
- if (!pair.isLocked) {
53
- pair.lock();
54
- }
55
- pair.decodePkcs8(oldPass);
56
- }
57
- catch {
58
- throw new Error('oldPass is invalid');
59
- }
60
- keyring.encryptAccount(pair, newPass);
61
- return true;
62
- }
63
- accountsEdit({ address, name }) {
64
- const pair = keyring.getPair(address);
65
- assert(pair, 'Unable to find pair');
66
- keyring.saveAccountMeta(pair, { ...pair.meta, name });
67
- return true;
68
- }
69
- accountsExport({ address, password }) {
70
- return { exportedJson: keyring.backupAccount(keyring.getPair(address), password) };
71
- }
72
- async accountsBatchExport({ addresses, password }) {
73
- return {
74
- exportedJson: await keyring.backupAccounts(addresses, password)
75
- };
76
- }
77
- async accountsForget({ address }) {
78
- const authorizedAccountsDiff = [];
79
- // cycle through authUrls and prepare the array of diff
80
- Object.entries(this.#state.authUrls).forEach(([url, urlInfo]) => {
81
- // Note that urlInfo.authorizedAccounts may be undefined if this website entry
82
- // was created before the "account authorization per website" functionality was introduced
83
- if (urlInfo.authorizedAccounts?.includes(address)) {
84
- authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter((previousAddress) => previousAddress !== address)]);
85
- }
86
- });
87
- await this.#state.updateAuthorizedAccounts(authorizedAccountsDiff);
88
- // cycle through default account selection for auth and remove any occurrence of the account
89
- const newDefaultAuthAccounts = this.#state.defaultAuthAccountSelection.filter((defaultSelectionAddress) => defaultSelectionAddress !== address);
90
- await this.#state.updateDefaultAuthAccounts(newDefaultAuthAccounts);
91
- keyring.forgetAccount(address);
92
- return true;
93
- }
94
- refreshAccountPasswordCache(pair) {
95
- const { address } = pair;
96
- const savedExpiry = this.#cachedUnlocks[address] || 0;
97
- const remainingTime = savedExpiry - Date.now();
98
- if (remainingTime < 0) {
99
- this.#cachedUnlocks[address] = 0;
100
- pair.lock();
101
- return 0;
102
- }
103
- return remainingTime;
104
- }
105
- accountsShow({ address, isShowing }) {
106
- const pair = keyring.getPair(address);
107
- assert(pair, 'Unable to find pair');
108
- keyring.saveAccountMeta(pair, { ...pair.meta, isHidden: !isShowing });
109
- return true;
110
- }
111
- accountsTie({ address, genesisHash }) {
112
- const pair = keyring.getPair(address);
113
- assert(pair, 'Unable to find pair');
114
- keyring.saveAccountMeta(pair, { ...pair.meta, genesisHash });
115
- return true;
116
- }
117
- accountsValidate({ address, password }) {
118
- try {
119
- keyring.backupAccount(keyring.getPair(address), password);
120
- return true;
121
- }
122
- catch {
123
- return false;
124
- }
125
- }
126
- accountsSubscribe(id, port) {
127
- const cb = createSubscription(id, port);
128
- const subscription = accountsObservable.subject.subscribe((accounts) => cb(this.transformAccounts(accounts)));
129
- port.onDisconnect.addListener(() => {
130
- unsubscribe(id);
131
- subscription.unsubscribe();
132
- });
133
- return true;
134
- }
135
- authorizeApprove({ authorizedAccounts, id }) {
136
- const queued = this.#state.getAuthRequest(id);
137
- assert(queued, 'Unable to find request');
138
- const { resolve } = queued;
139
- resolve({ authorizedAccounts, result: true });
140
- return true;
141
- }
142
- async authorizeUpdate({ authorizedAccounts, url }) {
143
- return await this.#state.updateAuthorizedAccounts([[url, authorizedAccounts]]);
144
- }
145
- getAuthList() {
146
- return { list: this.#state.authUrls };
147
- }
148
- // FIXME This looks very much like what we have in accounts
149
- authorizeSubscribe(id, port) {
150
- const cb = createSubscription(id, port);
151
- const subscription = this.#state.authSubject.subscribe((requests) => cb(requests));
152
- port.onDisconnect.addListener(() => {
153
- unsubscribe(id);
154
- subscription.unsubscribe();
155
- });
156
- return true;
157
- }
158
- async metadataApprove({ id }) {
159
- const queued = this.#state.getMetaRequest(id);
160
- assert(queued, 'Unable to find request');
161
- const { request, resolve } = queued;
162
- await this.#state.saveMetadata(request);
163
- resolve(true);
164
- return true;
165
- }
166
- metadataGet(genesisHash) {
167
- return this.#state.knownMetadata.find((result) => result.genesisHash === genesisHash) || null;
168
- }
169
- metadataList() {
170
- return this.#state.knownMetadata;
171
- }
172
- metadataReject({ id }) {
173
- const queued = this.#state.getMetaRequest(id);
174
- assert(queued, 'Unable to find request');
175
- const { reject } = queued;
176
- reject(new Error('Rejected'));
177
- return true;
178
- }
179
- metadataSubscribe(id, port) {
180
- const cb = createSubscription(id, port);
181
- const subscription = this.#state.metaSubject.subscribe((requests) => cb(requests));
182
- port.onDisconnect.addListener(() => {
183
- unsubscribe(id);
184
- subscription.unsubscribe();
185
- });
186
- return true;
187
- }
188
- jsonRestore({ file, password }) {
189
- try {
190
- keyring.restoreAccount(file, password);
191
- }
192
- catch (error) {
193
- throw new Error(error.message);
194
- }
195
- }
196
- batchRestore({ file, password }) {
197
- try {
198
- keyring.restoreAccounts(file, password);
199
- }
200
- catch (error) {
201
- throw new Error(error.message);
202
- }
203
- }
204
- jsonGetAccountInfo(json) {
205
- try {
206
- const { address, meta: { genesisHash, name }, type } = keyring.createFromJson(json);
207
- return {
208
- address,
209
- genesisHash,
210
- name,
211
- type
212
- };
213
- }
214
- catch (e) {
215
- console.error(e);
216
- throw new Error(e.message);
217
- }
218
- }
219
- seedCreate({ length = SEED_DEFAULT_LENGTH, seed: _seed, type }) {
220
- const seed = _seed || mnemonicGenerate(length);
221
- return {
222
- address: keyring.createFromUri(getSuri(seed, type), {}, type).address,
223
- seed
224
- };
225
- }
226
- seedValidate({ suri, type }) {
227
- const { phrase } = keyExtractSuri(suri);
228
- if (isHex(phrase)) {
229
- assert(isHex(phrase, 256), 'Hex seed needs to be 256-bits');
230
- }
231
- else {
232
- // sadly isHex detects as string, so we need a cast here
233
- assert(SEED_LENGTHS.includes((phrase).split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
234
- assert(mnemonicValidate(phrase), 'Not a valid mnemonic seed');
235
- }
236
- return {
237
- address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
238
- suri
239
- };
240
- }
241
- signingApprovePassword({ id, password, savePass }) {
242
- const queued = this.#state.getSignRequest(id);
243
- assert(queued, 'Unable to find request');
244
- const { reject, request, resolve } = queued;
245
- const pair = keyring.getPair(queued.account.address);
246
- if (!pair) {
247
- reject(new Error('Unable to find pair'));
248
- return false;
249
- }
250
- this.refreshAccountPasswordCache(pair);
251
- // if the keyring pair is locked, the password is needed
252
- if (pair.isLocked && !password) {
253
- reject(new Error('Password needed to unlock the account'));
254
- }
255
- if (pair.isLocked) {
256
- pair.decodePkcs8(password);
257
- }
258
- // construct a new registry (avoiding pollution), between requests
259
- let registry;
260
- const { payload } = request;
261
- if (isJsonPayload(payload)) {
262
- // Get the metadata for the genesisHash
263
- const metadata = this.#state.knownMetadata.find(({ genesisHash }) => genesisHash === payload.genesisHash);
264
- if (metadata) {
265
- // we have metadata, expand it and extract the info/registry
266
- const expanded = metadataExpand(metadata, false);
267
- registry = expanded.registry;
268
- registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions);
269
- }
270
- else {
271
- // we have no metadata, create a new registry
272
- registry = new TypeRegistry();
273
- registry.setSignedExtensions(payload.signedExtensions);
274
- }
275
- }
276
- else {
277
- // for non-payload, just create a registry to use
278
- registry = new TypeRegistry();
279
- }
280
- const result = request.sign(registry, pair);
281
- if (savePass) {
282
- // unlike queued.account.address the following
283
- // address is encoded with the default prefix
284
- // which what is used for password caching mapping
285
- this.#cachedUnlocks[pair.address] = Date.now() + PASSWORD_EXPIRY_MS;
286
- }
287
- else {
288
- pair.lock();
289
- }
290
- resolve({
291
- id,
292
- ...result
293
- });
294
- return true;
295
- }
296
- signingApproveSignature({ id, signature, signedTransaction }) {
297
- const queued = this.#state.getSignRequest(id);
298
- assert(queued, 'Unable to find request');
299
- const { resolve } = queued;
300
- resolve({ id, signature, signedTransaction });
301
- return true;
302
- }
303
- signingCancel({ id }) {
304
- const queued = this.#state.getSignRequest(id);
305
- assert(queued, 'Unable to find request');
306
- const { reject } = queued;
307
- reject(new Error('Cancelled'));
308
- return true;
309
- }
310
- signingIsLocked({ id }) {
311
- const queued = this.#state.getSignRequest(id);
312
- assert(queued, 'Unable to find request');
313
- const address = queued.request.payload.address;
314
- const pair = keyring.getPair(address);
315
- assert(pair, 'Unable to find pair');
316
- const remainingTime = this.refreshAccountPasswordCache(pair);
317
- return {
318
- isLocked: pair.isLocked,
319
- remainingTime
320
- };
321
- }
322
- // FIXME This looks very much like what we have in authorization
323
- signingSubscribe(id, port) {
324
- const cb = createSubscription(id, port);
325
- const subscription = this.#state.signSubject.subscribe((requests) => cb(requests));
326
- port.onDisconnect.addListener(() => {
327
- unsubscribe(id);
328
- subscription.unsubscribe();
329
- });
330
- return true;
331
- }
332
- windowOpen(path) {
333
- const url = `${chrome.runtime.getURL('index.html')}#${path}`;
334
- if (!ALLOWED_PATH.includes(path)) {
335
- console.error('Not allowed to open the url:', url);
336
- return false;
337
- }
338
- withErrorLog(() => chrome.tabs.create({ url }));
339
- return true;
340
- }
341
- derive(parentAddress, suri, password, metadata) {
342
- const parentPair = keyring.getPair(parentAddress);
343
- try {
344
- parentPair.decodePkcs8(password);
345
- }
346
- catch {
347
- throw new Error('invalid password');
348
- }
349
- try {
350
- return parentPair.derive(suri, metadata);
351
- }
352
- catch {
353
- throw new Error(`"${suri}" is not a valid derivation path`);
354
- }
355
- }
356
- derivationValidate({ parentAddress, parentPassword, suri }) {
357
- const childPair = this.derive(parentAddress, suri, parentPassword, {});
358
- return {
359
- address: childPair.address,
360
- suri
361
- };
362
- }
363
- derivationCreate({ genesisHash, name, parentAddress, parentPassword, password, suri }) {
364
- const childPair = this.derive(parentAddress, suri, parentPassword, {
365
- genesisHash,
366
- name,
367
- parentAddress,
368
- suri
369
- });
370
- keyring.addPair(childPair, password);
371
- return true;
372
- }
373
- async removeAuthorization(url) {
374
- const remAuth = await this.#state.removeAuthorization(url);
375
- return { list: remAuth };
376
- }
377
- // Reject the authorization request and add the URL to the authorized list with no keys.
378
- // The site will not prompt for re-authorization on future visits.
379
- rejectAuthRequest(id) {
380
- const queued = this.#state.getAuthRequest(id);
381
- assert(queued, 'Unable to find request');
382
- const { reject } = queued;
383
- reject(new Error('Rejected'));
384
- }
385
- // Cancel the authorization request and do not add the URL to the authorized list.
386
- // The site will prompt for authorization on future visits.
387
- cancelAuthRequest(id) {
388
- const queued = this.#state.getAuthRequest(id);
389
- assert(queued, 'Unable to find request');
390
- const { reject } = queued;
391
- reject(new Error('Cancelled'));
392
- }
393
- updateCurrentTabs({ urls }) {
394
- this.#state.updateCurrentTabsUrl(urls);
395
- }
396
- getConnectedTabsUrl() {
397
- return this.#state.getConnectedTabsUrl();
398
- }
399
- // Weird thought, the eslint override is not needed in Tabs
400
- // eslint-disable-next-line @typescript-eslint/require-await
401
- async handle(id, type, request, port) {
402
- switch (type) {
403
- case 'pri(authorize.approve)':
404
- return this.authorizeApprove(request);
405
- case 'pri(authorize.list)':
406
- return this.getAuthList();
407
- case 'pri(authorize.remove)':
408
- return this.removeAuthorization(request);
409
- case 'pri(authorize.reject)':
410
- return this.rejectAuthRequest(request);
411
- case 'pri(authorize.cancel)':
412
- return this.cancelAuthRequest(request);
413
- case 'pri(authorize.requests)':
414
- return port && this.authorizeSubscribe(id, port);
415
- case 'pri(authorize.update)':
416
- return this.authorizeUpdate(request);
417
- case 'pri(accounts.create.external)':
418
- return this.accountsCreateExternal(request);
419
- case 'pri(accounts.create.hardware)':
420
- return this.accountsCreateHardware(request);
421
- case 'pri(accounts.create.suri)':
422
- return this.accountsCreateSuri(request);
423
- case 'pri(accounts.changePassword)':
424
- return this.accountsChangePassword(request);
425
- case 'pri(accounts.edit)':
426
- return this.accountsEdit(request);
427
- case 'pri(accounts.export)':
428
- return this.accountsExport(request);
429
- case 'pri(accounts.batchExport)':
430
- return this.accountsBatchExport(request);
431
- case 'pri(accounts.forget)':
432
- return this.accountsForget(request);
433
- case 'pri(accounts.show)':
434
- return this.accountsShow(request);
435
- case 'pri(accounts.subscribe)':
436
- return port && this.accountsSubscribe(id, port);
437
- case 'pri(accounts.tie)':
438
- return this.accountsTie(request);
439
- case 'pri(accounts.validate)':
440
- return this.accountsValidate(request);
441
- case 'pri(metadata.approve)':
442
- return await this.metadataApprove(request);
443
- case 'pri(metadata.get)':
444
- return this.metadataGet(request);
445
- case 'pri(metadata.list)':
446
- return this.metadataList();
447
- case 'pri(metadata.reject)':
448
- return this.metadataReject(request);
449
- case 'pri(metadata.requests)':
450
- return port && this.metadataSubscribe(id, port);
451
- case 'pri(activeTabsUrl.update)':
452
- return this.updateCurrentTabs(request);
453
- case 'pri(connectedTabsUrl.get)':
454
- return this.getConnectedTabsUrl();
455
- case 'pri(derivation.create)':
456
- return this.derivationCreate(request);
457
- case 'pri(derivation.validate)':
458
- return this.derivationValidate(request);
459
- case 'pri(json.restore)':
460
- return this.jsonRestore(request);
461
- case 'pri(json.batchRestore)':
462
- return this.batchRestore(request);
463
- case 'pri(json.account.info)':
464
- return this.jsonGetAccountInfo(request);
465
- case 'pri(ping)':
466
- return Promise.resolve(true);
467
- case 'pri(seed.create)':
468
- return this.seedCreate(request);
469
- case 'pri(seed.validate)':
470
- return this.seedValidate(request);
471
- case 'pri(settings.notification)':
472
- return this.#state.setNotification(request);
473
- case 'pri(signing.approve.password)':
474
- return this.signingApprovePassword(request);
475
- case 'pri(signing.approve.signature)':
476
- return this.signingApproveSignature(request);
477
- case 'pri(signing.cancel)':
478
- return this.signingCancel(request);
479
- case 'pri(signing.isLocked)':
480
- return this.signingIsLocked(request);
481
- case 'pri(signing.requests)':
482
- return port && this.signingSubscribe(id, port);
483
- case 'pri(window.open)':
484
- return this.windowOpen(request);
485
- default:
486
- throw new Error(`Unable to handle message of type ${type}`);
487
- }
488
- }
489
- }