@polkadot/extension-base 0.47.6 → 0.48.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.
- package/background/handlers/Extension.js +5 -4
- package/background/handlers/State.js +1 -1
- package/background/handlers/Tabs.js +1 -1
- package/cjs/background/handlers/Extension.js +29 -29
- package/cjs/background/handlers/State.js +2 -3
- package/cjs/background/handlers/Tabs.js +2 -2
- package/cjs/packageInfo.js +1 -1
- package/package.json +8 -8
- package/packageInfo.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ALLOWED_PATH, PASSWORD_EXPIRY_MS } from '@polkadot/extension-base/defaults';
|
|
2
2
|
import { metadataExpand } from '@polkadot/extension-chains';
|
|
3
3
|
import { TypeRegistry } from '@polkadot/types';
|
|
4
|
-
import keyring from '@polkadot/ui-keyring';
|
|
4
|
+
import { keyring } from '@polkadot/ui-keyring';
|
|
5
5
|
import { accounts as accountsObservable } from '@polkadot/ui-keyring/observable/accounts';
|
|
6
6
|
import { assert, isHex } from '@polkadot/util';
|
|
7
7
|
import { keyExtractSuri, mnemonicGenerate, mnemonicValidate } from '@polkadot/util-crypto';
|
|
@@ -78,10 +78,11 @@ export default class Extension {
|
|
|
78
78
|
const authorizedAccountsDiff = [];
|
|
79
79
|
// cycle through authUrls and prepare the array of diff
|
|
80
80
|
Object.entries(this.__internal__state.authUrls).forEach(([url, urlInfo]) => {
|
|
81
|
-
|
|
82
|
-
|
|
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)]);
|
|
83
85
|
}
|
|
84
|
-
authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter((previousAddress) => previousAddress !== address)]);
|
|
85
86
|
});
|
|
86
87
|
this.__internal__state.updateAuthorizedAccounts(authorizedAccountsDiff);
|
|
87
88
|
// cycle through default account selection for auth and remove any occurrence of the account
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
2
|
import { addMetadata, knownMetadata } from '@polkadot/extension-chains';
|
|
3
3
|
import { knownGenesis } from '@polkadot/networks/defaults';
|
|
4
|
-
import settings from '@polkadot/ui-settings';
|
|
4
|
+
import { settings } from '@polkadot/ui-settings';
|
|
5
5
|
import { assert } from '@polkadot/util';
|
|
6
6
|
import { MetadataStore } from '../../stores/index.js';
|
|
7
7
|
import { getId } from '../../utils/getId.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkIfDenied } from '@polkadot/phishing';
|
|
2
|
-
import keyring from '@polkadot/ui-keyring';
|
|
2
|
+
import { keyring } from '@polkadot/ui-keyring';
|
|
3
3
|
import { accounts as accountsObservable } from '@polkadot/ui-keyring/observable/accounts';
|
|
4
4
|
import { assert, isNumber } from '@polkadot/util';
|
|
5
5
|
import { PHISHING_PAGE_REDIRECT } from '../../defaults.js';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const defaults_1 = require("@polkadot/extension-base/defaults");
|
|
5
4
|
const extension_chains_1 = require("@polkadot/extension-chains");
|
|
6
5
|
const types_1 = require("@polkadot/types");
|
|
7
|
-
const ui_keyring_1 =
|
|
6
|
+
const ui_keyring_1 = require("@polkadot/ui-keyring");
|
|
8
7
|
const accounts_1 = require("@polkadot/ui-keyring/observable/accounts");
|
|
9
8
|
const util_1 = require("@polkadot/util");
|
|
10
9
|
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
@@ -37,19 +36,19 @@ class Extension {
|
|
|
37
36
|
}));
|
|
38
37
|
}
|
|
39
38
|
accountsCreateExternal({ address, genesisHash, name }) {
|
|
40
|
-
ui_keyring_1.
|
|
39
|
+
ui_keyring_1.keyring.addExternal(address, { genesisHash, name });
|
|
41
40
|
return true;
|
|
42
41
|
}
|
|
43
42
|
accountsCreateHardware({ accountIndex, address, addressOffset, genesisHash, hardwareType, name }) {
|
|
44
|
-
ui_keyring_1.
|
|
43
|
+
ui_keyring_1.keyring.addHardware(address, hardwareType, { accountIndex, addressOffset, genesisHash, name });
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
47
46
|
accountsCreateSuri({ genesisHash, name, password, suri, type }) {
|
|
48
|
-
ui_keyring_1.
|
|
47
|
+
ui_keyring_1.keyring.addUri(getSuri(suri, type), password, { genesisHash, name }, type);
|
|
49
48
|
return true;
|
|
50
49
|
}
|
|
51
50
|
accountsChangePassword({ address, newPass, oldPass }) {
|
|
52
|
-
const pair = ui_keyring_1.
|
|
51
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
53
52
|
(0, util_1.assert)(pair, 'Unable to find pair');
|
|
54
53
|
try {
|
|
55
54
|
if (!pair.isLocked) {
|
|
@@ -60,37 +59,38 @@ class Extension {
|
|
|
60
59
|
catch {
|
|
61
60
|
throw new Error('oldPass is invalid');
|
|
62
61
|
}
|
|
63
|
-
ui_keyring_1.
|
|
62
|
+
ui_keyring_1.keyring.encryptAccount(pair, newPass);
|
|
64
63
|
return true;
|
|
65
64
|
}
|
|
66
65
|
accountsEdit({ address, name }) {
|
|
67
|
-
const pair = ui_keyring_1.
|
|
66
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
68
67
|
(0, util_1.assert)(pair, 'Unable to find pair');
|
|
69
|
-
ui_keyring_1.
|
|
68
|
+
ui_keyring_1.keyring.saveAccountMeta(pair, { ...pair.meta, name });
|
|
70
69
|
return true;
|
|
71
70
|
}
|
|
72
71
|
accountsExport({ address, password }) {
|
|
73
|
-
return { exportedJson: ui_keyring_1.
|
|
72
|
+
return { exportedJson: ui_keyring_1.keyring.backupAccount(ui_keyring_1.keyring.getPair(address), password) };
|
|
74
73
|
}
|
|
75
74
|
async accountsBatchExport({ addresses, password }) {
|
|
76
75
|
return {
|
|
77
|
-
exportedJson: await ui_keyring_1.
|
|
76
|
+
exportedJson: await ui_keyring_1.keyring.backupAccounts(addresses, password)
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
79
|
accountsForget({ address }) {
|
|
81
80
|
const authorizedAccountsDiff = [];
|
|
82
81
|
// cycle through authUrls and prepare the array of diff
|
|
83
82
|
Object.entries(this.__internal__state.authUrls).forEach(([url, urlInfo]) => {
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
// Note that urlInfo.authorizedAccounts may be undefined if this website entry
|
|
84
|
+
// was created before the "account authorization per website" functionality was introduced
|
|
85
|
+
if (urlInfo.authorizedAccounts?.includes(address)) {
|
|
86
|
+
authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter((previousAddress) => previousAddress !== address)]);
|
|
86
87
|
}
|
|
87
|
-
authorizedAccountsDiff.push([url, urlInfo.authorizedAccounts.filter((previousAddress) => previousAddress !== address)]);
|
|
88
88
|
});
|
|
89
89
|
this.__internal__state.updateAuthorizedAccounts(authorizedAccountsDiff);
|
|
90
90
|
// cycle through default account selection for auth and remove any occurrence of the account
|
|
91
91
|
const newDefaultAuthAccounts = this.__internal__state.defaultAuthAccountSelection.filter((defaultSelectionAddress) => defaultSelectionAddress !== address);
|
|
92
92
|
this.__internal__state.updateDefaultAuthAccounts(newDefaultAuthAccounts);
|
|
93
|
-
ui_keyring_1.
|
|
93
|
+
ui_keyring_1.keyring.forgetAccount(address);
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
96
96
|
refreshAccountPasswordCache(pair) {
|
|
@@ -105,20 +105,20 @@ class Extension {
|
|
|
105
105
|
return remainingTime;
|
|
106
106
|
}
|
|
107
107
|
accountsShow({ address, isShowing }) {
|
|
108
|
-
const pair = ui_keyring_1.
|
|
108
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
109
109
|
(0, util_1.assert)(pair, 'Unable to find pair');
|
|
110
|
-
ui_keyring_1.
|
|
110
|
+
ui_keyring_1.keyring.saveAccountMeta(pair, { ...pair.meta, isHidden: !isShowing });
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
accountsTie({ address, genesisHash }) {
|
|
114
|
-
const pair = ui_keyring_1.
|
|
114
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
115
115
|
(0, util_1.assert)(pair, 'Unable to find pair');
|
|
116
|
-
ui_keyring_1.
|
|
116
|
+
ui_keyring_1.keyring.saveAccountMeta(pair, { ...pair.meta, genesisHash });
|
|
117
117
|
return true;
|
|
118
118
|
}
|
|
119
119
|
accountsValidate({ address, password }) {
|
|
120
120
|
try {
|
|
121
|
-
ui_keyring_1.
|
|
121
|
+
ui_keyring_1.keyring.backupAccount(ui_keyring_1.keyring.getPair(address), password);
|
|
122
122
|
return true;
|
|
123
123
|
}
|
|
124
124
|
catch {
|
|
@@ -189,7 +189,7 @@ class Extension {
|
|
|
189
189
|
}
|
|
190
190
|
jsonRestore({ file, password }) {
|
|
191
191
|
try {
|
|
192
|
-
ui_keyring_1.
|
|
192
|
+
ui_keyring_1.keyring.restoreAccount(file, password);
|
|
193
193
|
}
|
|
194
194
|
catch (error) {
|
|
195
195
|
throw new Error(error.message);
|
|
@@ -197,7 +197,7 @@ class Extension {
|
|
|
197
197
|
}
|
|
198
198
|
batchRestore({ file, password }) {
|
|
199
199
|
try {
|
|
200
|
-
ui_keyring_1.
|
|
200
|
+
ui_keyring_1.keyring.restoreAccounts(file, password);
|
|
201
201
|
}
|
|
202
202
|
catch (error) {
|
|
203
203
|
throw new Error(error.message);
|
|
@@ -205,7 +205,7 @@ class Extension {
|
|
|
205
205
|
}
|
|
206
206
|
jsonGetAccountInfo(json) {
|
|
207
207
|
try {
|
|
208
|
-
const { address, meta: { genesisHash, name }, type } = ui_keyring_1.
|
|
208
|
+
const { address, meta: { genesisHash, name }, type } = ui_keyring_1.keyring.createFromJson(json);
|
|
209
209
|
return {
|
|
210
210
|
address,
|
|
211
211
|
genesisHash,
|
|
@@ -221,7 +221,7 @@ class Extension {
|
|
|
221
221
|
seedCreate({ length = SEED_DEFAULT_LENGTH, seed: _seed, type }) {
|
|
222
222
|
const seed = _seed || (0, util_crypto_1.mnemonicGenerate)(length);
|
|
223
223
|
return {
|
|
224
|
-
address: ui_keyring_1.
|
|
224
|
+
address: ui_keyring_1.keyring.createFromUri(getSuri(seed, type), {}, type).address,
|
|
225
225
|
seed
|
|
226
226
|
};
|
|
227
227
|
}
|
|
@@ -236,7 +236,7 @@ class Extension {
|
|
|
236
236
|
(0, util_1.assert)((0, util_crypto_1.mnemonicValidate)(phrase), 'Not a valid mnemonic seed');
|
|
237
237
|
}
|
|
238
238
|
return {
|
|
239
|
-
address: ui_keyring_1.
|
|
239
|
+
address: ui_keyring_1.keyring.createFromUri(getSuri(suri, type), {}, type).address,
|
|
240
240
|
suri
|
|
241
241
|
};
|
|
242
242
|
}
|
|
@@ -244,7 +244,7 @@ class Extension {
|
|
|
244
244
|
const queued = this.__internal__state.getSignRequest(id);
|
|
245
245
|
(0, util_1.assert)(queued, 'Unable to find request');
|
|
246
246
|
const { reject, request, resolve } = queued;
|
|
247
|
-
const pair = ui_keyring_1.
|
|
247
|
+
const pair = ui_keyring_1.keyring.getPair(queued.account.address);
|
|
248
248
|
if (!pair) {
|
|
249
249
|
reject(new Error('Unable to find pair'));
|
|
250
250
|
return false;
|
|
@@ -313,7 +313,7 @@ class Extension {
|
|
|
313
313
|
const queued = this.__internal__state.getSignRequest(id);
|
|
314
314
|
(0, util_1.assert)(queued, 'Unable to find request');
|
|
315
315
|
const address = queued.request.payload.address;
|
|
316
|
-
const pair = ui_keyring_1.
|
|
316
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
317
317
|
(0, util_1.assert)(pair, 'Unable to find pair');
|
|
318
318
|
const remainingTime = this.refreshAccountPasswordCache(pair);
|
|
319
319
|
return {
|
|
@@ -341,7 +341,7 @@ class Extension {
|
|
|
341
341
|
return true;
|
|
342
342
|
}
|
|
343
343
|
derive(parentAddress, suri, password, metadata) {
|
|
344
|
-
const parentPair = ui_keyring_1.
|
|
344
|
+
const parentPair = ui_keyring_1.keyring.getPair(parentAddress);
|
|
345
345
|
try {
|
|
346
346
|
parentPair.decodePkcs8(password);
|
|
347
347
|
}
|
|
@@ -369,7 +369,7 @@ class Extension {
|
|
|
369
369
|
parentAddress,
|
|
370
370
|
suri
|
|
371
371
|
});
|
|
372
|
-
ui_keyring_1.
|
|
372
|
+
ui_keyring_1.keyring.addPair(childPair, password);
|
|
373
373
|
return true;
|
|
374
374
|
}
|
|
375
375
|
removeAuthorization(url) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const rxjs_1 = require("rxjs");
|
|
6
5
|
const extension_chains_1 = require("@polkadot/extension-chains");
|
|
7
6
|
const defaults_1 = require("@polkadot/networks/defaults");
|
|
8
|
-
const ui_settings_1 =
|
|
7
|
+
const ui_settings_1 = require("@polkadot/ui-settings");
|
|
9
8
|
const util_1 = require("@polkadot/util");
|
|
10
9
|
const index_js_1 = require("../../stores/index.js");
|
|
11
10
|
const getId_js_1 = require("../../utils/getId.js");
|
|
@@ -71,7 +70,7 @@ class State {
|
|
|
71
70
|
// Map of providers currently injected in tabs
|
|
72
71
|
__internal__injectedProviders = new Map();
|
|
73
72
|
__internal__metaRequests = {};
|
|
74
|
-
__internal__notification = ui_settings_1.
|
|
73
|
+
__internal__notification = ui_settings_1.settings.notification;
|
|
75
74
|
// Map of all providers exposed by the extension, they are retrievable by key
|
|
76
75
|
__internal__providers;
|
|
77
76
|
__internal__signRequests = {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const phishing_1 = require("@polkadot/phishing");
|
|
5
|
-
const ui_keyring_1 =
|
|
5
|
+
const ui_keyring_1 = require("@polkadot/ui-keyring");
|
|
6
6
|
const accounts_1 = require("@polkadot/ui-keyring/observable/accounts");
|
|
7
7
|
const util_1 = require("@polkadot/util");
|
|
8
8
|
const defaults_js_1 = require("../../defaults.js");
|
|
@@ -70,7 +70,7 @@ class Tabs {
|
|
|
70
70
|
return true;
|
|
71
71
|
}
|
|
72
72
|
getSigningPair(address) {
|
|
73
|
-
const pair = ui_keyring_1.
|
|
73
|
+
const pair = ui_keyring_1.keyring.getPair(address);
|
|
74
74
|
(0, util_1.assert)(pair, 'Unable to find keypair');
|
|
75
75
|
return pair;
|
|
76
76
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@polkadot/extension-base', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/extension-base', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.48.2' };
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/packageDetect.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "0.
|
|
21
|
+
"version": "0.48.2",
|
|
22
22
|
"main": "./cjs/index.js",
|
|
23
23
|
"module": "./index.js",
|
|
24
24
|
"types": "./index.d.ts",
|
|
@@ -217,15 +217,15 @@
|
|
|
217
217
|
}
|
|
218
218
|
},
|
|
219
219
|
"dependencies": {
|
|
220
|
-
"@polkadot/api": "^
|
|
221
|
-
"@polkadot/extension-chains": "0.
|
|
222
|
-
"@polkadot/extension-dapp": "0.
|
|
223
|
-
"@polkadot/extension-inject": "0.
|
|
220
|
+
"@polkadot/api": "^12.0.2",
|
|
221
|
+
"@polkadot/extension-chains": "0.48.2",
|
|
222
|
+
"@polkadot/extension-dapp": "0.48.2",
|
|
223
|
+
"@polkadot/extension-inject": "0.48.2",
|
|
224
224
|
"@polkadot/keyring": "^12.6.2",
|
|
225
225
|
"@polkadot/networks": "^12.6.2",
|
|
226
|
-
"@polkadot/phishing": "^0.22.
|
|
227
|
-
"@polkadot/rpc-provider": "^
|
|
228
|
-
"@polkadot/types": "^
|
|
226
|
+
"@polkadot/phishing": "^0.22.10",
|
|
227
|
+
"@polkadot/rpc-provider": "^12.0.2",
|
|
228
|
+
"@polkadot/types": "^12.0.2",
|
|
229
229
|
"@polkadot/ui-keyring": "^3.6.6",
|
|
230
230
|
"@polkadot/ui-settings": "^3.6.6",
|
|
231
231
|
"@polkadot/util": "^12.6.2",
|
package/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@polkadot/extension-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.
|
|
1
|
+
export const packageInfo = { name: '@polkadot/extension-base', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.48.2' };
|