@polkadot/extension-base 0.44.6 → 0.44.8
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/RequestBytesSign.js +2 -3
- package/background/RequestExtrinsicSign.js +2 -3
- package/background/handlers/Extension.d.ts +4 -1
- package/background/handlers/Extension.js +80 -147
- package/background/handlers/State.d.ts +8 -3
- package/background/handlers/State.js +61 -68
- package/background/handlers/Tabs.d.ts +1 -1
- package/background/handlers/Tabs.js +18 -58
- package/background/handlers/helpers.js +2 -2
- package/background/handlers/index.d.ts +1 -1
- package/background/handlers/index.js +7 -5
- package/background/handlers/subscriptions.js +6 -3
- package/background/types.d.ts +33 -25
- package/bundle.js +2 -1
- package/cjs/background/RequestBytesSign.js +2 -7
- package/cjs/background/RequestExtrinsicSign.js +2 -5
- package/cjs/background/handlers/Extension.js +96 -208
- package/cjs/background/handlers/State.js +61 -83
- package/cjs/background/handlers/Tabs.js +18 -71
- package/cjs/background/handlers/helpers.js +2 -3
- package/cjs/background/handlers/index.js +7 -13
- package/cjs/background/handlers/subscriptions.js +6 -4
- package/cjs/bundle.js +0 -1
- package/cjs/defaults.js +17 -9
- package/cjs/detectOther.js +1 -5
- package/cjs/detectPackage.js +3 -5
- package/cjs/index.js +0 -2
- package/cjs/packageInfo.js +4 -2
- package/cjs/page/Accounts.js +2 -6
- package/cjs/page/Injected.js +7 -9
- package/cjs/page/Metadata.js +2 -6
- package/cjs/page/PostMessageProvider.js +26 -39
- package/cjs/page/Signer.js +13 -13
- package/cjs/page/index.js +9 -15
- package/cjs/stores/Accounts.js +3 -10
- package/cjs/stores/Base.js +2 -15
- package/cjs/stores/Metadata.js +3 -8
- package/cjs/stores/index.js +0 -3
- package/cjs/utils/canDerive.js +2 -2
- package/cjs/utils/getId.js +2 -4
- package/cjs/utils/index.js +0 -1
- package/defaults.d.ts +2 -2
- package/defaults.js +15 -6
- package/detectOther.js +2 -1
- package/detectPackage.js +3 -1
- package/index.js +3 -1
- package/package.json +16 -16
- package/packageInfo.js +4 -2
- package/page/Accounts.js +2 -4
- package/page/Injected.js +7 -2
- package/page/Metadata.js +2 -4
- package/page/PostMessageProvider.d.ts +2 -1
- package/page/PostMessageProvider.js +26 -34
- package/page/Signer.js +13 -11
- package/page/index.d.ts +1 -1
- package/page/index.js +12 -8
- package/stores/Accounts.js +3 -5
- package/stores/Base.js +2 -13
- package/stores/Metadata.js +3 -3
- package/stores/index.js +2 -1
- package/utils/canDerive.js +2 -1
- package/utils/getId.js +2 -1
- package/utils/index.js +2 -1
|
@@ -1,111 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
11
|
-
|
|
12
9
|
var _util = require("@polkadot/util");
|
|
13
|
-
|
|
14
|
-
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
10
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
15
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
16
13
|
const l = (0, _util.logger)('PostMessageProvider');
|
|
17
14
|
// External to class, this.# is not private enough (yet)
|
|
18
15
|
let sendRequest;
|
|
16
|
+
|
|
19
17
|
/**
|
|
20
18
|
* @name PostMessageProvider
|
|
21
19
|
*
|
|
22
20
|
* @description Extension provider to be used by dapps
|
|
23
21
|
*/
|
|
24
|
-
|
|
25
22
|
class PostMessageProvider {
|
|
26
|
-
#eventemitter;
|
|
23
|
+
#eventemitter;
|
|
24
|
+
|
|
25
|
+
// Whether or not the actual extension background provider is connected
|
|
26
|
+
#isConnected = false;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// Subscription IDs are (historically) not guaranteed to be globally unique;
|
|
29
29
|
// only unique for a given subscription method; which is why we identify
|
|
30
30
|
// the subscriptions based on subscription id + type
|
|
31
|
-
|
|
32
31
|
#subscriptions = {}; // {[(type,subscriptionId)]: callback}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* @param {function} sendRequest The function to be called to send requests to the node
|
|
36
35
|
* @param {function} subscriptionNotificationHandler Channel for receiving subscription messages
|
|
37
36
|
*/
|
|
38
|
-
|
|
39
37
|
constructor(_sendRequest) {
|
|
40
38
|
this.#eventemitter = new _eventemitter.default();
|
|
41
39
|
sendRequest = _sendRequest;
|
|
42
40
|
}
|
|
41
|
+
get isClonable() {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
43
45
|
/**
|
|
44
46
|
* @description Returns a clone of the object
|
|
45
47
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
48
|
clone() {
|
|
49
49
|
return new PostMessageProvider(sendRequest);
|
|
50
50
|
}
|
|
51
|
+
|
|
51
52
|
/**
|
|
52
53
|
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
53
54
|
*/
|
|
54
55
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
55
|
-
|
|
56
|
-
|
|
57
56
|
async connect() {
|
|
58
57
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
59
58
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
60
59
|
}
|
|
60
|
+
|
|
61
61
|
/**
|
|
62
62
|
* @description Manually disconnect from the connection, clearing autoconnect logic
|
|
63
63
|
*/
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
65
|
-
|
|
66
|
-
|
|
67
65
|
async disconnect() {
|
|
68
66
|
// FIXME This should see if the extension's state's provider can disconnect
|
|
69
67
|
console.error('PostMessageProvider.disconnect() is not implemented.');
|
|
70
68
|
}
|
|
69
|
+
|
|
71
70
|
/**
|
|
72
71
|
* @summary `true` when this provider supports subscriptions
|
|
73
72
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
73
|
get hasSubscriptions() {
|
|
77
74
|
// FIXME This should see if the extension's state's provider has subscriptions
|
|
78
75
|
return true;
|
|
79
76
|
}
|
|
77
|
+
|
|
80
78
|
/**
|
|
81
79
|
* @summary Whether the node is connected or not.
|
|
82
80
|
* @return {boolean} true if connected
|
|
83
81
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
82
|
get isConnected() {
|
|
87
83
|
return this.#isConnected;
|
|
88
84
|
}
|
|
89
|
-
|
|
90
85
|
listProviders() {
|
|
91
86
|
return sendRequest('pub(rpc.listProviders)', undefined);
|
|
92
87
|
}
|
|
88
|
+
|
|
93
89
|
/**
|
|
94
90
|
* @summary Listens on events after having subscribed using the [[subscribe]] function.
|
|
95
91
|
* @param {ProviderInterfaceEmitted} type Event
|
|
96
92
|
* @param {ProviderInterfaceEmitCb} sub Callback
|
|
97
93
|
* @return unsubscribe function
|
|
98
94
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
95
|
on(type, sub) {
|
|
102
96
|
this.#eventemitter.on(type, sub);
|
|
103
97
|
return () => {
|
|
104
98
|
this.#eventemitter.removeListener(type, sub);
|
|
105
99
|
};
|
|
106
|
-
}
|
|
107
|
-
|
|
100
|
+
}
|
|
108
101
|
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
103
|
async send(method, params, _, subscription) {
|
|
110
104
|
if (subscription) {
|
|
111
105
|
const {
|
|
@@ -122,63 +116,56 @@ class PostMessageProvider {
|
|
|
122
116
|
this.#subscriptions[`${type}::${id}`] = callback;
|
|
123
117
|
return id;
|
|
124
118
|
}
|
|
125
|
-
|
|
126
119
|
return sendRequest('pub(rpc.send)', {
|
|
127
120
|
method,
|
|
128
121
|
params
|
|
129
122
|
});
|
|
130
123
|
}
|
|
124
|
+
|
|
131
125
|
/**
|
|
132
126
|
* @summary Spawn a provider on the extension background.
|
|
133
127
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
128
|
async startProvider(key) {
|
|
137
129
|
// Disconnect from the previous provider
|
|
138
130
|
this.#isConnected = false;
|
|
139
131
|
this.#eventemitter.emit('disconnected');
|
|
140
|
-
const meta = await sendRequest('pub(rpc.startProvider)', key);
|
|
132
|
+
const meta = await sendRequest('pub(rpc.startProvider)', key);
|
|
141
133
|
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
142
135
|
sendRequest('pub(rpc.subscribeConnected)', null, connected => {
|
|
143
136
|
this.#isConnected = connected;
|
|
144
|
-
|
|
145
137
|
if (connected) {
|
|
146
138
|
this.#eventemitter.emit('connected');
|
|
147
139
|
} else {
|
|
148
140
|
this.#eventemitter.emit('disconnected');
|
|
149
141
|
}
|
|
150
|
-
|
|
151
142
|
return true;
|
|
152
143
|
});
|
|
153
144
|
return meta;
|
|
154
145
|
}
|
|
155
|
-
|
|
156
146
|
subscribe(type, method, params, callback) {
|
|
157
147
|
return this.send(method, params, false, {
|
|
158
148
|
callback,
|
|
159
149
|
type
|
|
160
150
|
});
|
|
161
151
|
}
|
|
152
|
+
|
|
162
153
|
/**
|
|
163
154
|
* @summary Allows unsubscribing to subscriptions made with [[subscribe]].
|
|
164
155
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
156
|
async unsubscribe(type, method, id) {
|
|
168
|
-
const subscription = `${type}::${id}`;
|
|
157
|
+
const subscription = `${type}::${id}`;
|
|
158
|
+
|
|
159
|
+
// FIXME This now could happen with re-subscriptions. The issue is that with a re-sub
|
|
169
160
|
// the assigned id now does not match what the API user originally received. It has
|
|
170
161
|
// a slight complication in solving - since we cannot rely on the send id, but rather
|
|
171
162
|
// need to find the actual subscription id to map it
|
|
172
|
-
|
|
173
163
|
if ((0, _util.isUndefined)(this.#subscriptions[subscription])) {
|
|
174
164
|
l.debug(() => `Unable to find active subscription=${subscription}`);
|
|
175
165
|
return false;
|
|
176
166
|
}
|
|
177
|
-
|
|
178
167
|
delete this.#subscriptions[subscription];
|
|
179
168
|
return this.send(method, [id]);
|
|
180
169
|
}
|
|
181
|
-
|
|
182
170
|
}
|
|
183
|
-
|
|
184
171
|
exports.default = PostMessageProvider;
|
package/cjs/page/Signer.js
CHANGED
|
@@ -4,41 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
// Copyright 2019-
|
|
7
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
9
10
|
// External to class, this.# is not private enough (yet)
|
|
10
11
|
let sendRequest;
|
|
11
12
|
let nextId = 0;
|
|
12
|
-
|
|
13
13
|
class Signer {
|
|
14
14
|
constructor(_sendRequest) {
|
|
15
15
|
sendRequest = _sendRequest;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
async signPayload(payload) {
|
|
19
18
|
const id = ++nextId;
|
|
20
|
-
const result = await sendRequest('pub(extrinsic.sign)', payload);
|
|
19
|
+
const result = await sendRequest('pub(extrinsic.sign)', payload);
|
|
20
|
+
|
|
21
|
+
// we add an internal id (number) - should have a mapping from the
|
|
21
22
|
// extension id (string) -> internal id (number) if we wish to provide
|
|
22
23
|
// updated via the update functionality (noop at this point)
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
return {
|
|
25
|
+
...result,
|
|
25
26
|
id
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
|
|
29
29
|
async signRaw(payload) {
|
|
30
30
|
const id = ++nextId;
|
|
31
31
|
const result = await sendRequest('pub(bytes.sign)', payload);
|
|
32
|
-
return {
|
|
32
|
+
return {
|
|
33
|
+
...result,
|
|
33
34
|
id
|
|
34
35
|
};
|
|
35
|
-
}
|
|
36
|
-
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// NOTE We don't listen to updates at all, if we do we can interpret the
|
|
39
|
+
// result as provided by the API here
|
|
37
40
|
// public update (id: number, status: Hash | SubmittableResult): void {
|
|
38
41
|
// // ignore
|
|
39
42
|
// }
|
|
40
|
-
|
|
41
|
-
|
|
42
43
|
}
|
|
43
|
-
|
|
44
44
|
exports.default = Signer;
|
package/cjs/page/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,16 +8,15 @@ exports.enable = enable;
|
|
|
9
8
|
exports.handleResponse = handleResponse;
|
|
10
9
|
exports.redirectIfPhishing = redirectIfPhishing;
|
|
11
10
|
exports.sendMessage = sendMessage;
|
|
12
|
-
|
|
13
11
|
var _defaults = require("../defaults");
|
|
14
|
-
|
|
15
12
|
var _getId = require("../utils/getId");
|
|
16
|
-
|
|
17
13
|
var _Injected = _interopRequireDefault(require("./Injected"));
|
|
18
|
-
|
|
19
|
-
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
14
|
+
// Copyright 2019-2023 @polkadot/extension authors & contributors
|
|
20
15
|
// SPDX-License-Identifier: Apache-2.0
|
|
21
|
-
|
|
16
|
+
|
|
17
|
+
const handlers = {};
|
|
18
|
+
|
|
19
|
+
// a generic message sender that creates an event, returning a promise that will
|
|
22
20
|
// resolve once the event is resolved (by the response listener just below this)
|
|
23
21
|
|
|
24
22
|
function sendMessage(message, request, subscriber) {
|
|
@@ -37,34 +35,30 @@ function sendMessage(message, request, subscriber) {
|
|
|
37
35
|
};
|
|
38
36
|
window.postMessage(transportRequestMessage, '*');
|
|
39
37
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
38
|
+
}
|
|
42
39
|
|
|
40
|
+
// the enable function, called by the dapp to allow access
|
|
43
41
|
async function enable(origin) {
|
|
44
42
|
await sendMessage('pub(authorize.tab)', {
|
|
45
43
|
origin
|
|
46
44
|
});
|
|
47
45
|
return new _Injected.default(sendMessage);
|
|
48
|
-
}
|
|
49
|
-
|
|
46
|
+
}
|
|
50
47
|
|
|
48
|
+
// redirect users if this page is considered as phishing, otherwise return false
|
|
51
49
|
async function redirectIfPhishing() {
|
|
52
50
|
const res = await sendMessage('pub(phishing.redirectIfDenied)');
|
|
53
51
|
return res;
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
function handleResponse(data) {
|
|
57
54
|
const handler = handlers[data.id];
|
|
58
|
-
|
|
59
55
|
if (!handler) {
|
|
60
56
|
console.error(`Unknown response: ${JSON.stringify(data)}`);
|
|
61
57
|
return;
|
|
62
58
|
}
|
|
63
|
-
|
|
64
59
|
if (!handler.subscriber) {
|
|
65
60
|
delete handlers[data.id];
|
|
66
61
|
}
|
|
67
|
-
|
|
68
62
|
if (data.subscription) {
|
|
69
63
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
70
64
|
handler.subscriber(data.subscription);
|
package/cjs/stores/Accounts.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _defaults = require("../defaults");
|
|
11
|
-
|
|
12
9
|
var _Base = _interopRequireDefault(require("./Base"));
|
|
13
|
-
|
|
14
|
-
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
10
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
15
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
16
13
|
class AccountsStore extends _Base.default {
|
|
17
14
|
constructor() {
|
|
18
|
-
super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}accounts` : null);
|
|
15
|
+
super(_defaults.EXTENSION_PREFIX && _defaults.EXTENSION_PREFIX !== 'polkadot{.js}' ? `${_defaults.EXTENSION_PREFIX}accounts` : null);
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
set(key, value, update) {
|
|
22
18
|
// shortcut, don't save testing accounts in extension storage
|
|
23
19
|
if (key.startsWith('account:') && value.meta && value.meta.isTesting) {
|
|
24
20
|
update && update();
|
|
25
21
|
return;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
super.set(key, value, update);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
exports.default = AccountsStore;
|
package/cjs/stores/Base.js
CHANGED
|
@@ -4,24 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
7
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
9
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
10
|
const lastError = type => {
|
|
11
11
|
const error = chrome.runtime.lastError;
|
|
12
|
-
|
|
13
12
|
if (error) {
|
|
14
13
|
console.error(`BaseStore.${type}:: runtime.lastError:`, error);
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
class BaseStore {
|
|
19
17
|
#prefix;
|
|
20
|
-
|
|
21
18
|
constructor(prefix) {
|
|
22
19
|
this.#prefix = prefix ? `${prefix}:` : '';
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
all(update) {
|
|
26
22
|
this.allMap(map => {
|
|
27
23
|
Object.entries(map).forEach(_ref => {
|
|
@@ -30,25 +26,20 @@ class BaseStore {
|
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
allMap(update) {
|
|
35
30
|
chrome.storage.local.get(null, result => {
|
|
36
31
|
lastError('all');
|
|
37
32
|
const entries = Object.entries(result);
|
|
38
33
|
const map = {};
|
|
39
|
-
|
|
40
34
|
for (let i = 0; i < entries.length; i++) {
|
|
41
35
|
const [key, value] = entries[i];
|
|
42
|
-
|
|
43
36
|
if (key.startsWith(this.#prefix)) {
|
|
44
37
|
map[key.replace(this.#prefix, '')] = value;
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
update(map);
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
get(_key, update) {
|
|
53
44
|
const key = `${this.#prefix}${_key}`;
|
|
54
45
|
chrome.storage.local.get([key], result => {
|
|
@@ -56,7 +47,6 @@ class BaseStore {
|
|
|
56
47
|
update(result[key]);
|
|
57
48
|
});
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
remove(_key, update) {
|
|
61
51
|
const key = `${this.#prefix}${_key}`;
|
|
62
52
|
chrome.storage.local.remove(key, () => {
|
|
@@ -64,7 +54,6 @@ class BaseStore {
|
|
|
64
54
|
update && update();
|
|
65
55
|
});
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
set(_key, value, update) {
|
|
69
58
|
const key = `${this.#prefix}${_key}`;
|
|
70
59
|
chrome.storage.local.set({
|
|
@@ -74,7 +63,5 @@ class BaseStore {
|
|
|
74
63
|
update && update();
|
|
75
64
|
});
|
|
76
65
|
}
|
|
77
|
-
|
|
78
66
|
}
|
|
79
|
-
|
|
80
67
|
exports.default = BaseStore;
|
package/cjs/stores/Metadata.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _defaults = require("../defaults");
|
|
11
|
-
|
|
12
9
|
var _Base = _interopRequireDefault(require("./Base"));
|
|
13
|
-
|
|
14
|
-
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
10
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
15
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
16
13
|
class MetadataStore extends _Base.default {
|
|
17
14
|
constructor() {
|
|
18
|
-
super(`${_defaults.EXTENSION_PREFIX}metadata`);
|
|
15
|
+
super(_defaults.EXTENSION_PREFIX && _defaults.EXTENSION_PREFIX !== 'polkadot{.js}' ? `${_defaults.EXTENSION_PREFIX}metadata` : 'metadata');
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
exports.default = MetadataStore;
|
package/cjs/stores/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -17,7 +16,5 @@ Object.defineProperty(exports, "MetadataStore", {
|
|
|
17
16
|
return _Metadata.default;
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
var _Accounts = _interopRequireDefault(require("./Accounts"));
|
|
22
|
-
|
|
23
20
|
var _Metadata = _interopRequireDefault(require("./Metadata"));
|
package/cjs/utils/canDerive.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.canDerive = canDerive;
|
|
7
|
-
|
|
8
|
-
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
7
|
+
// Copyright 2019-2023 @polkadot/extension authors & contributors
|
|
9
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
10
|
function canDerive(type) {
|
|
11
11
|
return !!type && ['ed25519', 'sr25519', 'ecdsa', 'ethereum'].includes(type);
|
|
12
12
|
}
|
package/cjs/utils/getId.js
CHANGED
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getId = getId;
|
|
7
|
-
|
|
8
7
|
var _defaults = require("../defaults");
|
|
9
|
-
|
|
10
|
-
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
8
|
+
// Copyright 2019-2023 @polkadot/extension authors & contributors
|
|
11
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
let counter = 0;
|
|
13
10
|
|
|
11
|
+
let counter = 0;
|
|
14
12
|
function getId() {
|
|
15
13
|
return `${_defaults.EXTENSION_PREFIX}.${Date.now()}.${++counter}`;
|
|
16
14
|
}
|
package/cjs/utils/index.js
CHANGED
package/defaults.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json"];
|
|
2
|
-
declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
3
1
|
declare const EXTENSION_PREFIX: string;
|
|
4
2
|
declare const PORT_CONTENT: string;
|
|
5
3
|
declare const PORT_EXTENSION: string;
|
|
6
4
|
declare const MESSAGE_ORIGIN_PAGE: string;
|
|
7
5
|
declare const MESSAGE_ORIGIN_CONTENT: string;
|
|
6
|
+
declare const ALLOWED_PATH: readonly ["/", "/account/import-ledger", "/account/restore-json"];
|
|
7
|
+
declare const PHISHING_PAGE_REDIRECT = "/phishing-page-detected";
|
|
8
8
|
declare const PASSWORD_EXPIRY_MIN = 15;
|
|
9
9
|
declare const PASSWORD_EXPIRY_MS: number;
|
|
10
10
|
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
package/defaults.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
// Copyright 2019-
|
|
1
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// this _must_ be changed for each extension
|
|
5
|
+
const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
|
|
6
|
+
if (!EXTENSION_PREFIX && !process.env.PORT_PREFIX) {
|
|
7
|
+
throw new Error('CRITICAL: The extension does not define an own EXTENSION_PREFIX environment variable as part of the build, this is required to ensure that messages are not shared between extensions. Failure to do so will yield messages sent to multiple extensions.');
|
|
8
|
+
}
|
|
9
|
+
const PORT_PREFIX = `${EXTENSION_PREFIX || 'unknown'}-${process.env.PORT_PREFIX || 'unknown'}`;
|
|
10
|
+
const PORT_CONTENT = `${PORT_PREFIX}-content`;
|
|
11
|
+
const PORT_EXTENSION = `${PORT_PREFIX}-extension`;
|
|
12
|
+
const MESSAGE_ORIGIN_PAGE = `${PORT_PREFIX}-page`;
|
|
13
|
+
const MESSAGE_ORIGIN_CONTENT = `${PORT_PREFIX}-content`;
|
|
3
14
|
const ALLOWED_PATH = ['/', '/account/import-ledger', '/account/restore-json'];
|
|
4
15
|
const PHISHING_PAGE_REDIRECT = '/phishing-page-detected';
|
|
5
|
-
const EXTENSION_PREFIX = process.env.EXTENSION_PREFIX || '';
|
|
6
|
-
const PORT_CONTENT = `${EXTENSION_PREFIX}content`;
|
|
7
|
-
const PORT_EXTENSION = `${EXTENSION_PREFIX}extension`;
|
|
8
|
-
const MESSAGE_ORIGIN_PAGE = `${EXTENSION_PREFIX}page`;
|
|
9
|
-
const MESSAGE_ORIGIN_CONTENT = `${EXTENSION_PREFIX}content`;
|
|
10
16
|
const PASSWORD_EXPIRY_MIN = 15;
|
|
11
17
|
const PASSWORD_EXPIRY_MS = PASSWORD_EXPIRY_MIN * 60 * 1000;
|
|
18
|
+
|
|
19
|
+
// console.log(`Extension is sending and receiving messages on ${PORT_PREFIX}-*`);
|
|
20
|
+
|
|
12
21
|
export { ALLOWED_PATH, PASSWORD_EXPIRY_MIN, PASSWORD_EXPIRY_MS, PHISHING_PAGE_REDIRECT, EXTENSION_PREFIX, PORT_CONTENT, PORT_EXTENSION, MESSAGE_ORIGIN_PAGE, MESSAGE_ORIGIN_CONTENT };
|
package/detectOther.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// Copyright 2017-
|
|
1
|
+
// Copyright 2017-2023 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
import { packageInfo as chainsInfo } from '@polkadot/extension-chains/packageInfo';
|
|
4
5
|
import { packageInfo as dappInfo } from '@polkadot/extension-dapp/packageInfo';
|
|
5
6
|
import { packageInfo as injectInfo } from '@polkadot/extension-inject/packageInfo';
|
package/detectPackage.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
// Copyright 2017-
|
|
1
|
+
// Copyright 2017-2023 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
+
|
|
4
6
|
import { detectPackage } from '@polkadot/util';
|
|
5
7
|
import others from "./detectOther.js";
|
|
6
8
|
import { packageInfo } from "./packageInfo.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
// Copyright 2019-
|
|
1
|
+
// Copyright 2019-2023 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
// Since we inject into pages, we skip this
|
|
4
5
|
// import './detectPackage';
|
|
6
|
+
|
|
5
7
|
export * from "./bundle.js";
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "0.44.
|
|
20
|
+
"version": "0.44.8",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -182,21 +182,21 @@
|
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
"dependencies": {
|
|
185
|
-
"@babel/runtime": "^7.
|
|
186
|
-
"@polkadot/api": "^9.
|
|
187
|
-
"@polkadot/extension-chains": "^0.44.
|
|
188
|
-
"@polkadot/extension-dapp": "^0.44.
|
|
189
|
-
"@polkadot/extension-inject": "^0.44.
|
|
190
|
-
"@polkadot/keyring": "^10.
|
|
191
|
-
"@polkadot/networks": "^10.
|
|
192
|
-
"@polkadot/phishing": "^0.18.
|
|
193
|
-
"@polkadot/rpc-provider": "^9.
|
|
194
|
-
"@polkadot/types": "^9.
|
|
195
|
-
"@polkadot/ui-keyring": "^2.9.
|
|
196
|
-
"@polkadot/ui-settings": "^2.9.
|
|
197
|
-
"@polkadot/util": "^10.
|
|
198
|
-
"@polkadot/util-crypto": "^10.
|
|
185
|
+
"@babel/runtime": "^7.20.7",
|
|
186
|
+
"@polkadot/api": "^9.11.1",
|
|
187
|
+
"@polkadot/extension-chains": "^0.44.8",
|
|
188
|
+
"@polkadot/extension-dapp": "^0.44.8",
|
|
189
|
+
"@polkadot/extension-inject": "^0.44.8",
|
|
190
|
+
"@polkadot/keyring": "^10.2.3",
|
|
191
|
+
"@polkadot/networks": "^10.2.3",
|
|
192
|
+
"@polkadot/phishing": "^0.18.13",
|
|
193
|
+
"@polkadot/rpc-provider": "^9.11.1",
|
|
194
|
+
"@polkadot/types": "^9.11.1",
|
|
195
|
+
"@polkadot/ui-keyring": "^2.9.15",
|
|
196
|
+
"@polkadot/ui-settings": "^2.9.15",
|
|
197
|
+
"@polkadot/util": "^10.2.3",
|
|
198
|
+
"@polkadot/util-crypto": "^10.2.3",
|
|
199
199
|
"eventemitter3": "^4.0.7",
|
|
200
|
-
"rxjs": "^7.
|
|
200
|
+
"rxjs": "^7.8.0"
|
|
201
201
|
}
|
|
202
202
|
}
|
package/packageInfo.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
// Copyright 2017-
|
|
1
|
+
// Copyright 2017-2023 @polkadot/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
+
|
|
4
6
|
export const packageInfo = {
|
|
5
7
|
name: '@polkadot/extension-base',
|
|
6
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
9
|
type: 'esm',
|
|
8
|
-
version: '0.44.
|
|
10
|
+
version: '0.44.8'
|
|
9
11
|
};
|