@pezkuwi/extension-base 0.62.10 → 0.62.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/background/RequestBytesSign.js +6 -9
- package/background/RequestExtrinsicSign.js +6 -9
- package/background/handlers/Extension.js +304 -460
- package/background/handlers/State.js +365 -619
- package/background/handlers/Tabs.js +155 -273
- package/background/handlers/helpers.js +1 -3
- package/background/handlers/index.js +17 -22
- package/background/handlers/subscriptions.js +5 -9
- package/background/index.js +0 -2
- package/background/types.js +0 -2
- package/bundle.js +0 -2
- package/cjs/background/RequestBytesSign.d.ts +12 -0
- package/cjs/background/RequestBytesSign.js +15 -0
- package/cjs/background/RequestExtrinsicSign.d.ts +12 -0
- package/cjs/background/RequestExtrinsicSign.js +14 -0
- package/cjs/background/handlers/Extension.d.ts +49 -0
- package/cjs/background/handlers/Extension.js +492 -0
- package/cjs/background/handlers/State.d.ts +96 -0
- package/cjs/background/handlers/State.js +482 -0
- package/cjs/background/handlers/Tabs.d.ts +25 -0
- package/cjs/background/handlers/Tabs.js +199 -0
- package/cjs/background/handlers/helpers.d.ts +1 -0
- package/cjs/background/handlers/helpers.js +14 -0
- package/cjs/background/handlers/index.d.ts +3 -0
- package/cjs/background/handlers/index.js +46 -0
- package/cjs/background/handlers/subscriptions.d.ts +3 -0
- package/cjs/background/handlers/subscriptions.js +22 -0
- package/cjs/background/index.d.ts +1 -0
- package/cjs/background/index.js +7 -0
- package/cjs/background/types.d.ts +343 -0
- package/cjs/background/types.js +2 -0
- package/cjs/bundle.d.ts +1 -0
- package/cjs/bundle.js +5 -0
- package/cjs/defaults.d.ts +9 -0
- package/cjs/defaults.js +16 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +4 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.d.ts +1 -0
- package/cjs/packageDetect.js +8 -0
- package/cjs/packageInfo.d.ts +6 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/page/Accounts.d.ts +7 -0
- package/cjs/page/Accounts.js +24 -0
- package/cjs/page/Injected.d.ts +13 -0
- package/cjs/page/Injected.js +25 -0
- package/cjs/page/Metadata.d.ts +7 -0
- package/cjs/page/Metadata.js +15 -0
- package/cjs/page/PostMessageProvider.d.ts +63 -0
- package/cjs/page/PostMessageProvider.js +135 -0
- package/cjs/page/Signer.d.ts +8 -0
- package/cjs/page/Signer.js +29 -0
- package/cjs/page/index.d.ts +16 -0
- package/cjs/page/index.js +52 -0
- package/cjs/page/types.d.ts +6 -0
- package/cjs/page/types.js +2 -0
- package/cjs/stores/Accounts.d.ts +6 -0
- package/cjs/stores/Accounts.js +21 -0
- package/cjs/stores/Base.d.ts +9 -0
- package/cjs/stores/Base.js +70 -0
- package/cjs/stores/Metadata.d.ts +5 -0
- package/cjs/stores/Metadata.js +13 -0
- package/cjs/stores/index.d.ts +2 -0
- package/cjs/stores/index.js +8 -0
- package/cjs/types.d.ts +9 -0
- package/cjs/types.js +2 -0
- package/cjs/utils/canDerive.d.ts +2 -0
- package/cjs/utils/canDerive.js +6 -0
- package/cjs/utils/getId.d.ts +1 -0
- package/cjs/utils/getId.js +8 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +5 -0
- package/cjs/utils/portUtils.d.ts +13 -0
- package/cjs/utils/portUtils.js +49 -0
- package/defaults.js +10 -14
- package/index.js +0 -4
- package/package.json +464 -10
- package/packageDetect.js +0 -4
- package/packageInfo.js +1 -4
- package/page/Accounts.js +13 -18
- package/page/Injected.js +10 -10
- package/page/Metadata.js +8 -13
- package/page/PostMessageProvider.js +90 -192
- package/page/Signer.js +24 -90
- package/page/index.js +15 -72
- package/page/types.js +0 -2
- package/stores/Accounts.js +14 -80
- package/stores/Base.js +57 -240
- package/stores/Metadata.js +6 -26
- package/stores/index.js +0 -2
- package/types.js +0 -2
- package/utils/canDerive.js +0 -2
- package/utils/getId.js +2 -4
- package/utils/index.js +0 -2
- package/utils/portUtils.d.ts +0 -1
- package/utils/portUtils.js +31 -94
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
// Copyright 2019-2025 @pezkuwi/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
25
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
-
function step(op) {
|
|
28
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
30
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
-
switch (op[0]) {
|
|
33
|
-
case 0: case 1: t = op; break;
|
|
34
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
-
default:
|
|
38
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
-
if (t[2]) _.ops.pop();
|
|
43
|
-
_.trys.pop(); continue;
|
|
44
|
-
}
|
|
45
|
-
op = body.call(thisArg, _);
|
|
46
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
51
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
52
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
53
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
54
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
55
|
-
};
|
|
56
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
57
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
58
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
59
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
60
|
-
};
|
|
61
|
-
var _Extension_cachedUnlocks, _Extension_state;
|
|
62
1
|
import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@pezkuwi/extension-base/defaults';
|
|
63
2
|
import { metadataExpand } from '@pezkuwi/extension-chains';
|
|
64
3
|
import { TypeRegistry } from '@pezkuwi/types';
|
|
@@ -68,49 +7,46 @@ import { assert, isHex } from '@pezkuwi/util';
|
|
|
68
7
|
import { keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@pezkuwi/util-crypto';
|
|
69
8
|
import { withErrorLog } from './helpers.js';
|
|
70
9
|
import { createSubscription, unsubscribe } from './subscriptions.js';
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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";
|
|
74
13
|
function getSuri(seed, type) {
|
|
75
14
|
return type === 'ethereum'
|
|
76
|
-
?
|
|
15
|
+
? `${seed}${ETH_DERIVE_DEFAULT}`
|
|
77
16
|
: seed;
|
|
78
17
|
}
|
|
79
18
|
function isJsonPayload(value) {
|
|
80
19
|
return value.genesisHash !== undefined;
|
|
81
20
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
keyring.addExternal(address, { genesisHash
|
|
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 });
|
|
99
38
|
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
keyring.addHardware(address, hardwareType, { accountIndex: accountIndex, addressOffset: addressOffset, genesisHash: genesisHash, name: name, type: type });
|
|
39
|
+
}
|
|
40
|
+
accountsCreateHardware({ accountIndex, address, addressOffset, genesisHash, hardwareType, name, type }) {
|
|
41
|
+
keyring.addHardware(address, hardwareType, { accountIndex, addressOffset, genesisHash, name, type });
|
|
104
42
|
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
keyring.addUri(getSuri(suri, type), password, { genesisHash: genesisHash, name: name }, type);
|
|
43
|
+
}
|
|
44
|
+
accountsCreateSuri({ genesisHash, name, password, suri, type }) {
|
|
45
|
+
keyring.addUri(getSuri(suri, type), password, { genesisHash, name }, type);
|
|
109
46
|
return true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var pair = keyring.getPair(address);
|
|
47
|
+
}
|
|
48
|
+
accountsChangePassword({ address, newPass, oldPass }) {
|
|
49
|
+
const pair = keyring.getPair(address);
|
|
114
50
|
assert(pair, 'Unable to find pair');
|
|
115
51
|
try {
|
|
116
52
|
if (!pair.isLocked) {
|
|
@@ -118,257 +54,195 @@ var Extension = /** @class */ (function () {
|
|
|
118
54
|
}
|
|
119
55
|
pair.decodePkcs8(oldPass);
|
|
120
56
|
}
|
|
121
|
-
catch
|
|
57
|
+
catch {
|
|
122
58
|
throw new Error('oldPass is invalid');
|
|
123
59
|
}
|
|
124
60
|
keyring.encryptAccount(pair, newPass);
|
|
125
61
|
return true;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var pair = keyring.getPair(address);
|
|
62
|
+
}
|
|
63
|
+
accountsEdit({ address, name }) {
|
|
64
|
+
const pair = keyring.getPair(address);
|
|
130
65
|
assert(pair, 'Unable to find pair');
|
|
131
|
-
keyring.saveAccountMeta(pair,
|
|
66
|
+
keyring.saveAccountMeta(pair, { ...pair.meta, name });
|
|
132
67
|
return true;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var address = _a.address, password = _a.password;
|
|
68
|
+
}
|
|
69
|
+
accountsExport({ address, password }) {
|
|
136
70
|
return { exportedJson: keyring.backupAccount(keyring.getPair(address), password) };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
Extension.prototype.accountsForget = function (_a) {
|
|
154
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
|
155
|
-
var authorizedAccountsDiff, newDefaultAuthAccounts;
|
|
156
|
-
var address = _b.address;
|
|
157
|
-
return __generator(this, function (_c) {
|
|
158
|
-
switch (_c.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
authorizedAccountsDiff = [];
|
|
161
|
-
// cycle through authUrls and prepare the array of diff
|
|
162
|
-
Object.entries(__classPrivateFieldGet(this, _Extension_state, "f").authUrls).forEach(function (_a) {
|
|
163
|
-
var _b;
|
|
164
|
-
var url = _a[0], urlInfo = _a[1];
|
|
165
|
-
// Note that urlInfo.authorizedAccounts may be undefined if this website entry
|
|
166
|
-
// was created before the "account authorization per website" functionality was introduced
|
|
167
|
-
if ((_b = urlInfo.authorizedAccounts) === null || _b === void 0 ? void 0 : _b.includes(address)) {
|
|
168
|
-
authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter(function (previousAddress) { return previousAddress !== address; })]);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
return [4 /*yield*/, __classPrivateFieldGet(this, _Extension_state, "f").updateAuthorizedAccounts(authorizedAccountsDiff)];
|
|
172
|
-
case 1:
|
|
173
|
-
_c.sent();
|
|
174
|
-
newDefaultAuthAccounts = __classPrivateFieldGet(this, _Extension_state, "f").defaultAuthAccountSelection.filter(function (defaultSelectionAddress) { return defaultSelectionAddress !== address; });
|
|
175
|
-
return [4 /*yield*/, __classPrivateFieldGet(this, _Extension_state, "f").updateDefaultAuthAccounts(newDefaultAuthAccounts)];
|
|
176
|
-
case 2:
|
|
177
|
-
_c.sent();
|
|
178
|
-
keyring.forgetAccount(address);
|
|
179
|
-
return [2 /*return*/, true];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
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
|
+
}
|
|
182
86
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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();
|
|
188
98
|
if (remainingTime < 0) {
|
|
189
|
-
|
|
99
|
+
this.#cachedUnlocks[address] = 0;
|
|
190
100
|
pair.lock();
|
|
191
101
|
return 0;
|
|
192
102
|
}
|
|
193
103
|
return remainingTime;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var pair = keyring.getPair(address);
|
|
104
|
+
}
|
|
105
|
+
accountsShow({ address, isShowing }) {
|
|
106
|
+
const pair = keyring.getPair(address);
|
|
198
107
|
assert(pair, 'Unable to find pair');
|
|
199
|
-
keyring.saveAccountMeta(pair,
|
|
108
|
+
keyring.saveAccountMeta(pair, { ...pair.meta, isHidden: !isShowing });
|
|
200
109
|
return true;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
var pair = keyring.getPair(address);
|
|
110
|
+
}
|
|
111
|
+
accountsTie({ address, genesisHash }) {
|
|
112
|
+
const pair = keyring.getPair(address);
|
|
205
113
|
assert(pair, 'Unable to find pair');
|
|
206
|
-
keyring.saveAccountMeta(pair,
|
|
114
|
+
keyring.saveAccountMeta(pair, { ...pair.meta, genesisHash });
|
|
207
115
|
return true;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
var address = _a.address, password = _a.password;
|
|
116
|
+
}
|
|
117
|
+
accountsValidate({ address, password }) {
|
|
211
118
|
try {
|
|
212
119
|
keyring.backupAccount(keyring.getPair(address), password);
|
|
213
120
|
return true;
|
|
214
121
|
}
|
|
215
|
-
catch
|
|
122
|
+
catch {
|
|
216
123
|
return false;
|
|
217
124
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return cb(_this.transformAccounts(accounts));
|
|
224
|
-
});
|
|
225
|
-
port.onDisconnect.addListener(function () {
|
|
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(() => {
|
|
226
130
|
unsubscribe(id);
|
|
227
131
|
subscription.unsubscribe();
|
|
228
132
|
});
|
|
229
133
|
return true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getAuthRequest(id);
|
|
134
|
+
}
|
|
135
|
+
authorizeApprove({ authorizedAccounts, id }) {
|
|
136
|
+
const queued = this.#state.getAuthRequest(id);
|
|
234
137
|
assert(queued, 'Unable to find request');
|
|
235
|
-
|
|
236
|
-
resolve({ authorizedAccounts
|
|
138
|
+
const { resolve } = queued;
|
|
139
|
+
resolve({ authorizedAccounts, result: true });
|
|
237
140
|
return true;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
};
|
|
250
|
-
Extension.prototype.getAuthList = function () {
|
|
251
|
-
return { list: __classPrivateFieldGet(this, _Extension_state, "f").authUrls };
|
|
252
|
-
};
|
|
141
|
+
}
|
|
142
|
+
async authorizeUpdate({ authorizedAccounts, url }) {
|
|
143
|
+
return await this.#state.updateAuthorizedAccounts([[url, authorizedAccounts]]);
|
|
144
|
+
}
|
|
145
|
+
getAuthList() {
|
|
146
|
+
return { list: this.#state.authUrls };
|
|
147
|
+
}
|
|
253
148
|
// FIXME This looks very much like what we have in accounts
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
});
|
|
259
|
-
port.onDisconnect.addListener(function () {
|
|
149
|
+
authorizeSubscribe(id, port) {
|
|
150
|
+
const cb = createSubscription(id, port);
|
|
151
|
+
const subscription = this.#state.authSubject.subscribe((requests) => cb(requests));
|
|
152
|
+
port.onDisconnect.addListener(() => {
|
|
260
153
|
unsubscribe(id);
|
|
261
154
|
subscription.unsubscribe();
|
|
262
155
|
});
|
|
263
156
|
return true;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
var queued, request, resolve;
|
|
268
|
-
var id = _b.id;
|
|
269
|
-
return __generator(this, function (_c) {
|
|
270
|
-
switch (_c.label) {
|
|
271
|
-
case 0:
|
|
272
|
-
queued = __classPrivateFieldGet(this, _Extension_state, "f").getMetaRequest(id);
|
|
273
|
-
assert(queued, 'Unable to find request');
|
|
274
|
-
request = queued.request, resolve = queued.resolve;
|
|
275
|
-
return [4 /*yield*/, __classPrivateFieldGet(this, _Extension_state, "f").saveMetadata(request)];
|
|
276
|
-
case 1:
|
|
277
|
-
_c.sent();
|
|
278
|
-
resolve(true);
|
|
279
|
-
return [2 /*return*/, true];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
Extension.prototype.metadataGet = function (genesisHash) {
|
|
285
|
-
return __classPrivateFieldGet(this, _Extension_state, "f").knownMetadata.find(function (result) { return result.genesisHash === genesisHash; }) || null;
|
|
286
|
-
};
|
|
287
|
-
Extension.prototype.metadataList = function () {
|
|
288
|
-
return __classPrivateFieldGet(this, _Extension_state, "f").knownMetadata;
|
|
289
|
-
};
|
|
290
|
-
Extension.prototype.metadataReject = function (_a) {
|
|
291
|
-
var id = _a.id;
|
|
292
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getMetaRequest(id);
|
|
157
|
+
}
|
|
158
|
+
async metadataApprove({ id }) {
|
|
159
|
+
const queued = this.#state.getMetaRequest(id);
|
|
293
160
|
assert(queued, 'Unable to find request');
|
|
294
|
-
|
|
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;
|
|
295
176
|
reject(new Error('Rejected'));
|
|
296
177
|
return true;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
});
|
|
303
|
-
port.onDisconnect.addListener(function () {
|
|
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(() => {
|
|
304
183
|
unsubscribe(id);
|
|
305
184
|
subscription.unsubscribe();
|
|
306
185
|
});
|
|
307
186
|
return true;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
var file = _a.file, password = _a.password;
|
|
187
|
+
}
|
|
188
|
+
jsonRestore({ file, password }) {
|
|
311
189
|
try {
|
|
312
190
|
keyring.restoreAccount(file, password);
|
|
313
191
|
}
|
|
314
192
|
catch (error) {
|
|
315
193
|
throw new Error(error.message);
|
|
316
194
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
var file = _a.file, password = _a.password;
|
|
195
|
+
}
|
|
196
|
+
batchRestore({ file, password }) {
|
|
320
197
|
try {
|
|
321
198
|
keyring.restoreAccounts(file, password);
|
|
322
199
|
}
|
|
323
200
|
catch (error) {
|
|
324
201
|
throw new Error(error.message);
|
|
325
202
|
}
|
|
326
|
-
}
|
|
327
|
-
|
|
203
|
+
}
|
|
204
|
+
jsonGetAccountInfo(json) {
|
|
328
205
|
try {
|
|
329
|
-
|
|
206
|
+
const { address, meta: { genesisHash, name }, type } = keyring.createFromJson(json);
|
|
330
207
|
return {
|
|
331
|
-
address
|
|
332
|
-
genesisHash
|
|
333
|
-
name
|
|
334
|
-
type
|
|
208
|
+
address,
|
|
209
|
+
genesisHash,
|
|
210
|
+
name,
|
|
211
|
+
type
|
|
335
212
|
};
|
|
336
213
|
}
|
|
337
214
|
catch (e) {
|
|
338
215
|
console.error(e);
|
|
339
216
|
throw new Error(e.message);
|
|
340
217
|
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
var seed = _seed || mnemonicGenerate(length);
|
|
218
|
+
}
|
|
219
|
+
seedCreate({ length = SEED_DEFAULT_LENGTH, seed: _seed, type }) {
|
|
220
|
+
const seed = _seed || mnemonicGenerate(length);
|
|
345
221
|
return {
|
|
346
222
|
address: keyring.createFromUri(getSuri(seed, type), {}, type).address,
|
|
347
|
-
seed
|
|
223
|
+
seed
|
|
348
224
|
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
var phrase = keyExtractSuri(suri).phrase;
|
|
225
|
+
}
|
|
226
|
+
seedValidate({ suri, type }) {
|
|
227
|
+
const { phrase } = keyExtractSuri(suri);
|
|
353
228
|
if (isHex(phrase)) {
|
|
354
229
|
assert(isHex(phrase, 256), 'Hex seed needs to be 256-bits');
|
|
355
230
|
}
|
|
356
231
|
else {
|
|
357
232
|
// sadly isHex detects as string, so we need a cast here
|
|
358
|
-
assert(SEED_LENGTHS.includes((phrase).split(' ').length),
|
|
233
|
+
assert(SEED_LENGTHS.includes((phrase).split(' ').length), `Mnemonic needs to contain ${SEED_LENGTHS.join(', ')} words`);
|
|
359
234
|
assert(mnemonicValidate(phrase), 'Not a valid mnemonic seed');
|
|
360
235
|
}
|
|
361
236
|
return {
|
|
362
237
|
address: keyring.createFromUri(getSuri(suri, type), {}, type).address,
|
|
363
|
-
suri
|
|
238
|
+
suri
|
|
364
239
|
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getSignRequest(id);
|
|
240
|
+
}
|
|
241
|
+
signingApprovePassword({ id, password, savePass }) {
|
|
242
|
+
const queued = this.#state.getSignRequest(id);
|
|
369
243
|
assert(queued, 'Unable to find request');
|
|
370
|
-
|
|
371
|
-
|
|
244
|
+
const { reject, request, resolve } = queued;
|
|
245
|
+
const pair = keyring.getPair(queued.account.address);
|
|
372
246
|
if (!pair) {
|
|
373
247
|
reject(new Error('Unable to find pair'));
|
|
374
248
|
return false;
|
|
@@ -382,17 +256,14 @@ var Extension = /** @class */ (function () {
|
|
|
382
256
|
pair.decodePkcs8(password);
|
|
383
257
|
}
|
|
384
258
|
// construct a new registry (avoiding pollution), between requests
|
|
385
|
-
|
|
386
|
-
|
|
259
|
+
let registry;
|
|
260
|
+
const { payload } = request;
|
|
387
261
|
if (isJsonPayload(payload)) {
|
|
388
262
|
// Get the metadata for the genesisHash
|
|
389
|
-
|
|
390
|
-
var genesisHash = _a.genesisHash;
|
|
391
|
-
return genesisHash === payload.genesisHash;
|
|
392
|
-
});
|
|
263
|
+
const metadata = this.#state.knownMetadata.find(({ genesisHash }) => genesisHash === payload.genesisHash);
|
|
393
264
|
if (metadata) {
|
|
394
265
|
// we have metadata, expand it and extract the info/registry
|
|
395
|
-
|
|
266
|
+
const expanded = metadataExpand(metadata, false);
|
|
396
267
|
registry = expanded.registry;
|
|
397
268
|
registry.setSignedExtensions(payload.signedExtensions, expanded.definition.userExtensions);
|
|
398
269
|
}
|
|
@@ -406,240 +277,213 @@ var Extension = /** @class */ (function () {
|
|
|
406
277
|
// for non-payload, just create a registry to use
|
|
407
278
|
registry = new TypeRegistry();
|
|
408
279
|
}
|
|
409
|
-
|
|
280
|
+
const result = request.sign(registry, pair);
|
|
410
281
|
if (savePass) {
|
|
411
282
|
// unlike queued.account.address the following
|
|
412
283
|
// address is encoded with the default prefix
|
|
413
284
|
// which what is used for password caching mapping
|
|
414
|
-
|
|
285
|
+
this.#cachedUnlocks[pair.address] = Date.now() + PASSWORD_EXPIRY_MS;
|
|
415
286
|
}
|
|
416
287
|
else {
|
|
417
288
|
pair.lock();
|
|
418
289
|
}
|
|
419
|
-
resolve(
|
|
290
|
+
resolve({
|
|
291
|
+
id,
|
|
292
|
+
...result
|
|
293
|
+
});
|
|
420
294
|
return true;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getSignRequest(id);
|
|
295
|
+
}
|
|
296
|
+
signingApproveSignature({ id, signature, signedTransaction }) {
|
|
297
|
+
const queued = this.#state.getSignRequest(id);
|
|
425
298
|
assert(queued, 'Unable to find request');
|
|
426
|
-
|
|
427
|
-
resolve({ id
|
|
299
|
+
const { resolve } = queued;
|
|
300
|
+
resolve({ id, signature, signedTransaction });
|
|
428
301
|
return true;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getSignRequest(id);
|
|
302
|
+
}
|
|
303
|
+
signingCancel({ id }) {
|
|
304
|
+
const queued = this.#state.getSignRequest(id);
|
|
433
305
|
assert(queued, 'Unable to find request');
|
|
434
|
-
|
|
306
|
+
const { reject } = queued;
|
|
435
307
|
reject(new Error('Cancelled'));
|
|
436
308
|
return true;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
var queued = __classPrivateFieldGet(this, _Extension_state, "f").getSignRequest(id);
|
|
309
|
+
}
|
|
310
|
+
signingIsLocked({ id }) {
|
|
311
|
+
const queued = this.#state.getSignRequest(id);
|
|
441
312
|
assert(queued, 'Unable to find request');
|
|
442
|
-
|
|
443
|
-
|
|
313
|
+
const address = queued.request.payload.address;
|
|
314
|
+
const pair = keyring.getPair(address);
|
|
444
315
|
assert(pair, 'Unable to find pair');
|
|
445
|
-
|
|
316
|
+
const remainingTime = this.refreshAccountPasswordCache(pair);
|
|
446
317
|
return {
|
|
447
318
|
isLocked: pair.isLocked,
|
|
448
|
-
remainingTime
|
|
319
|
+
remainingTime
|
|
449
320
|
};
|
|
450
|
-
}
|
|
321
|
+
}
|
|
451
322
|
// FIXME This looks very much like what we have in authorization
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
});
|
|
457
|
-
port.onDisconnect.addListener(function () {
|
|
323
|
+
signingSubscribe(id, port) {
|
|
324
|
+
const cb = createSubscription(id, port);
|
|
325
|
+
const subscription = this.#state.signSubject.subscribe((requests) => cb(requests));
|
|
326
|
+
port.onDisconnect.addListener(() => {
|
|
458
327
|
unsubscribe(id);
|
|
459
328
|
subscription.unsubscribe();
|
|
460
329
|
});
|
|
461
330
|
return true;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
331
|
+
}
|
|
332
|
+
windowOpen(path) {
|
|
333
|
+
const url = `${chrome.runtime.getURL('index.html')}#${path}`;
|
|
465
334
|
if (!ALLOWED_PATH.includes(path)) {
|
|
466
335
|
console.error('Not allowed to open the url:', url);
|
|
467
336
|
return false;
|
|
468
337
|
}
|
|
469
|
-
withErrorLog(
|
|
338
|
+
withErrorLog(() => chrome.tabs.create({ url }));
|
|
470
339
|
return true;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
340
|
+
}
|
|
341
|
+
derive(parentAddress, suri, password, metadata) {
|
|
342
|
+
const parentPair = keyring.getPair(parentAddress);
|
|
474
343
|
try {
|
|
475
344
|
parentPair.decodePkcs8(password);
|
|
476
345
|
}
|
|
477
|
-
catch
|
|
346
|
+
catch {
|
|
478
347
|
throw new Error('invalid password');
|
|
479
348
|
}
|
|
480
349
|
try {
|
|
481
350
|
return parentPair.derive(suri, metadata);
|
|
482
351
|
}
|
|
483
|
-
catch
|
|
484
|
-
throw new Error("
|
|
352
|
+
catch {
|
|
353
|
+
throw new Error(`"${suri}" is not a valid derivation path`);
|
|
485
354
|
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
var childPair = this.derive(parentAddress, suri, parentPassword, {});
|
|
355
|
+
}
|
|
356
|
+
derivationValidate({ parentAddress, parentPassword, suri }) {
|
|
357
|
+
const childPair = this.derive(parentAddress, suri, parentPassword, {});
|
|
490
358
|
return {
|
|
491
359
|
address: childPair.address,
|
|
492
|
-
suri
|
|
360
|
+
suri
|
|
493
361
|
};
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
suri: suri
|
|
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
|
|
502
369
|
});
|
|
503
370
|
keyring.addPair(childPair, password);
|
|
504
371
|
return true;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
switch (_a.label) {
|
|
511
|
-
case 0: return [4 /*yield*/, __classPrivateFieldGet(this, _Extension_state, "f").removeAuthorization(url)];
|
|
512
|
-
case 1:
|
|
513
|
-
remAuth = _a.sent();
|
|
514
|
-
return [2 /*return*/, { list: remAuth }];
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
});
|
|
518
|
-
};
|
|
372
|
+
}
|
|
373
|
+
async removeAuthorization(url) {
|
|
374
|
+
const remAuth = await this.#state.removeAuthorization(url);
|
|
375
|
+
return { list: remAuth };
|
|
376
|
+
}
|
|
519
377
|
// Reject the authorization request and add the URL to the authorized list with no keys.
|
|
520
378
|
// The site will not prompt for re-authorization on future visits.
|
|
521
|
-
|
|
522
|
-
|
|
379
|
+
rejectAuthRequest(id) {
|
|
380
|
+
const queued = this.#state.getAuthRequest(id);
|
|
523
381
|
assert(queued, 'Unable to find request');
|
|
524
|
-
|
|
382
|
+
const { reject } = queued;
|
|
525
383
|
reject(new Error('Rejected'));
|
|
526
|
-
}
|
|
384
|
+
}
|
|
527
385
|
// Cancel the authorization request and do not add the URL to the authorized list.
|
|
528
386
|
// The site will prompt for authorization on future visits.
|
|
529
|
-
|
|
530
|
-
|
|
387
|
+
cancelAuthRequest(id) {
|
|
388
|
+
const queued = this.#state.getAuthRequest(id);
|
|
531
389
|
assert(queued, 'Unable to find request');
|
|
532
|
-
|
|
390
|
+
const { reject } = queued;
|
|
533
391
|
reject(new Error('Cancelled'));
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
};
|
|
392
|
+
}
|
|
393
|
+
updateCurrentTabs({ urls }) {
|
|
394
|
+
this.#state.updateCurrentTabsUrl(urls);
|
|
395
|
+
}
|
|
396
|
+
getConnectedTabsUrl() {
|
|
397
|
+
return this.#state.getConnectedTabsUrl();
|
|
398
|
+
}
|
|
542
399
|
// Weird thought, the eslint override is not needed in Tabs
|
|
543
400
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
case 39: return [2 /*return*/, this.signingCancel(request)];
|
|
634
|
-
case 40: return [2 /*return*/, this.signingIsLocked(request)];
|
|
635
|
-
case 41: return [2 /*return*/, port && this.signingSubscribe(id, port)];
|
|
636
|
-
case 42: return [2 /*return*/, this.windowOpen(request)];
|
|
637
|
-
case 43: throw new Error("Unable to handle message of type ".concat(type));
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
});
|
|
641
|
-
};
|
|
642
|
-
return Extension;
|
|
643
|
-
}());
|
|
644
|
-
_Extension_cachedUnlocks = new WeakMap(), _Extension_state = new WeakMap();
|
|
645
|
-
export default Extension;
|
|
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
|
+
}
|