@polkadot/extension-base 0.39.4-7 → 0.40.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.cjs +3 -0
- package/background/handlers/Extension.js +3 -0
- package/background/handlers/State.cjs +35 -6
- package/background/handlers/State.d.ts +6 -0
- package/background/handlers/State.js +30 -5
- package/background/types.d.ts +1 -0
- package/package.json +7 -7
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
|
@@ -720,6 +720,9 @@ class Extension {
|
|
|
720
720
|
case 'pri(seed.validate)':
|
|
721
721
|
return this.seedValidate(request);
|
|
722
722
|
|
|
723
|
+
case 'pri(settings.notification)':
|
|
724
|
+
return (0, _classPrivateFieldLooseBase2.default)(this, _state)[_state].setNotification(request);
|
|
725
|
+
|
|
723
726
|
case 'pri(signing.approve.password)':
|
|
724
727
|
return this.signingApprovePassword(request);
|
|
725
728
|
|
|
@@ -678,6 +678,9 @@ export default class Extension {
|
|
|
678
678
|
case 'pri(seed.validate)':
|
|
679
679
|
return this.seedValidate(request);
|
|
680
680
|
|
|
681
|
+
case 'pri(settings.notification)':
|
|
682
|
+
return _classPrivateFieldLooseBase(this, _state)[_state].setNotification(request);
|
|
683
|
+
|
|
681
684
|
case 'pri(signing.approve.password)':
|
|
682
685
|
return this.signingApprovePassword(request);
|
|
683
686
|
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.NotificationOptions = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
@@ -19,6 +19,8 @@ var _extensionChains = require("@polkadot/extension-chains");
|
|
|
19
19
|
|
|
20
20
|
var _chrome = _interopRequireDefault(require("@polkadot/extension-inject/chrome"));
|
|
21
21
|
|
|
22
|
+
var _uiSettings = _interopRequireDefault(require("@polkadot/ui-settings"));
|
|
23
|
+
|
|
22
24
|
var _util = require("@polkadot/util");
|
|
23
25
|
|
|
24
26
|
var _index = require("../../stores/index.cjs");
|
|
@@ -28,16 +30,32 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
28
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
31
|
|
|
30
32
|
let idCounter = 0;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
const NOTIFICATION_URL = _chrome.default.extension.getURL('notification.html');
|
|
35
|
+
|
|
36
|
+
const POPUP_WINDOW_OPTS = {
|
|
37
|
+
focused: true,
|
|
34
38
|
height: 621,
|
|
35
39
|
left: 150,
|
|
36
40
|
top: 150,
|
|
37
41
|
type: 'popup',
|
|
38
|
-
url:
|
|
42
|
+
url: NOTIFICATION_URL,
|
|
39
43
|
width: 560
|
|
40
44
|
};
|
|
45
|
+
const NORMAL_WINDOW_OPTS = {
|
|
46
|
+
focused: true,
|
|
47
|
+
type: 'normal',
|
|
48
|
+
url: NOTIFICATION_URL
|
|
49
|
+
};
|
|
50
|
+
let NotificationOptions;
|
|
51
|
+
exports.NotificationOptions = NotificationOptions;
|
|
52
|
+
|
|
53
|
+
(function (NotificationOptions) {
|
|
54
|
+
NotificationOptions[NotificationOptions["None"] = 0] = "None";
|
|
55
|
+
NotificationOptions[NotificationOptions["Normal"] = 1] = "Normal";
|
|
56
|
+
NotificationOptions[NotificationOptions["PopUp"] = 2] = "PopUp";
|
|
57
|
+
})(NotificationOptions || (exports.NotificationOptions = NotificationOptions = {}));
|
|
58
|
+
|
|
41
59
|
const AUTH_URLS_KEY = 'authUrls';
|
|
42
60
|
|
|
43
61
|
function getId() {
|
|
@@ -54,6 +72,8 @@ var _injectedProviders = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("
|
|
|
54
72
|
|
|
55
73
|
var _metaRequests = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("metaRequests");
|
|
56
74
|
|
|
75
|
+
var _notification = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("notification");
|
|
76
|
+
|
|
57
77
|
var _providers = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("providers");
|
|
58
78
|
|
|
59
79
|
var _signRequests = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("signRequests");
|
|
@@ -84,6 +104,10 @@ class State {
|
|
|
84
104
|
writable: true,
|
|
85
105
|
value: {}
|
|
86
106
|
});
|
|
107
|
+
Object.defineProperty(this, _notification, {
|
|
108
|
+
writable: true,
|
|
109
|
+
value: _uiSettings.default.notification
|
|
110
|
+
});
|
|
87
111
|
Object.defineProperty(this, _providers, {
|
|
88
112
|
writable: true,
|
|
89
113
|
value: void 0
|
|
@@ -250,7 +274,7 @@ class State {
|
|
|
250
274
|
}
|
|
251
275
|
|
|
252
276
|
popupOpen() {
|
|
253
|
-
_chrome.default.windows.create(
|
|
277
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _notification)[_notification] !== 'extension' && _chrome.default.windows.create((0, _classPrivateFieldLooseBase2.default)(this, _notification)[_notification] === 'window' ? NORMAL_WINDOW_OPTS : POPUP_WINDOW_OPTS, window => {
|
|
254
278
|
if (window) {
|
|
255
279
|
(0, _classPrivateFieldLooseBase2.default)(this, _windows)[_windows].push(window.id || 0);
|
|
256
280
|
}
|
|
@@ -437,6 +461,11 @@ class State {
|
|
|
437
461
|
(0, _extensionChains.addMetadata)(meta);
|
|
438
462
|
}
|
|
439
463
|
|
|
464
|
+
setNotification(notification) {
|
|
465
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _notification)[_notification] = notification;
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
|
|
440
469
|
sign(url, request, account) {
|
|
441
470
|
const id = getId();
|
|
442
471
|
return new Promise((resolve, reject) => {
|
|
@@ -36,6 +36,11 @@ interface SignRequest extends Resolver<ResponseSigning> {
|
|
|
36
36
|
request: RequestSign;
|
|
37
37
|
url: string;
|
|
38
38
|
}
|
|
39
|
+
export declare enum NotificationOptions {
|
|
40
|
+
None = 0,
|
|
41
|
+
Normal = 1,
|
|
42
|
+
PopUp = 2
|
|
43
|
+
}
|
|
39
44
|
export default class State {
|
|
40
45
|
#private;
|
|
41
46
|
readonly authSubject: BehaviorSubject<AuthorizeRequest[]>;
|
|
@@ -75,6 +80,7 @@ export default class State {
|
|
|
75
80
|
rpcSubscribeConnected(_request: null, cb: ProviderInterfaceCallback, port: chrome.runtime.Port): void;
|
|
76
81
|
rpcUnsubscribe(request: RequestRpcUnsubscribe, port: chrome.runtime.Port): Promise<boolean>;
|
|
77
82
|
saveMetadata(meta: MetadataDef): void;
|
|
83
|
+
setNotification(notification: string): boolean;
|
|
78
84
|
sign(url: string, request: RequestSign, account: AccountJson): Promise<ResponseSigning>;
|
|
79
85
|
}
|
|
80
86
|
export {};
|
|
@@ -11,19 +11,33 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
11
11
|
import { BehaviorSubject } from 'rxjs';
|
|
12
12
|
import { addMetadata, knownMetadata } from '@polkadot/extension-chains';
|
|
13
13
|
import chrome from '@polkadot/extension-inject/chrome';
|
|
14
|
+
import settings from '@polkadot/ui-settings';
|
|
14
15
|
import { assert } from '@polkadot/util';
|
|
15
16
|
import { MetadataStore } from "../../stores/index.js";
|
|
16
17
|
let idCounter = 0;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
|
|
19
|
+
const POPUP_WINDOW_OPTS = {
|
|
20
|
+
focused: true,
|
|
20
21
|
height: 621,
|
|
21
22
|
left: 150,
|
|
22
23
|
top: 150,
|
|
23
24
|
type: 'popup',
|
|
24
|
-
url:
|
|
25
|
+
url: NOTIFICATION_URL,
|
|
25
26
|
width: 560
|
|
26
27
|
};
|
|
28
|
+
const NORMAL_WINDOW_OPTS = {
|
|
29
|
+
focused: true,
|
|
30
|
+
type: 'normal',
|
|
31
|
+
url: NOTIFICATION_URL
|
|
32
|
+
};
|
|
33
|
+
export let NotificationOptions;
|
|
34
|
+
|
|
35
|
+
(function (NotificationOptions) {
|
|
36
|
+
NotificationOptions[NotificationOptions["None"] = 0] = "None";
|
|
37
|
+
NotificationOptions[NotificationOptions["Normal"] = 1] = "Normal";
|
|
38
|
+
NotificationOptions[NotificationOptions["PopUp"] = 2] = "PopUp";
|
|
39
|
+
})(NotificationOptions || (NotificationOptions = {}));
|
|
40
|
+
|
|
27
41
|
const AUTH_URLS_KEY = 'authUrls';
|
|
28
42
|
|
|
29
43
|
function getId() {
|
|
@@ -40,6 +54,8 @@ var _injectedProviders = /*#__PURE__*/_classPrivateFieldLooseKey("injectedProvid
|
|
|
40
54
|
|
|
41
55
|
var _metaRequests = /*#__PURE__*/_classPrivateFieldLooseKey("metaRequests");
|
|
42
56
|
|
|
57
|
+
var _notification = /*#__PURE__*/_classPrivateFieldLooseKey("notification");
|
|
58
|
+
|
|
43
59
|
var _providers = /*#__PURE__*/_classPrivateFieldLooseKey("providers");
|
|
44
60
|
|
|
45
61
|
var _signRequests = /*#__PURE__*/_classPrivateFieldLooseKey("signRequests");
|
|
@@ -70,6 +86,10 @@ export default class State {
|
|
|
70
86
|
writable: true,
|
|
71
87
|
value: {}
|
|
72
88
|
});
|
|
89
|
+
Object.defineProperty(this, _notification, {
|
|
90
|
+
writable: true,
|
|
91
|
+
value: settings.notification
|
|
92
|
+
});
|
|
73
93
|
Object.defineProperty(this, _providers, {
|
|
74
94
|
writable: true,
|
|
75
95
|
value: void 0
|
|
@@ -236,7 +256,7 @@ export default class State {
|
|
|
236
256
|
}
|
|
237
257
|
|
|
238
258
|
popupOpen() {
|
|
239
|
-
chrome.windows.create(
|
|
259
|
+
_classPrivateFieldLooseBase(this, _notification)[_notification] !== 'extension' && chrome.windows.create(_classPrivateFieldLooseBase(this, _notification)[_notification] === 'window' ? NORMAL_WINDOW_OPTS : POPUP_WINDOW_OPTS, window => {
|
|
240
260
|
if (window) {
|
|
241
261
|
_classPrivateFieldLooseBase(this, _windows)[_windows].push(window.id || 0);
|
|
242
262
|
}
|
|
@@ -423,6 +443,11 @@ export default class State {
|
|
|
423
443
|
addMetadata(meta);
|
|
424
444
|
}
|
|
425
445
|
|
|
446
|
+
setNotification(notification) {
|
|
447
|
+
_classPrivateFieldLooseBase(this, _notification)[_notification] = notification;
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
|
|
426
451
|
sign(url, request, account) {
|
|
427
452
|
const id = getId();
|
|
428
453
|
return new Promise((resolve, reject) => {
|
package/background/types.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export interface RequestSignatures {
|
|
|
86
86
|
'pri(metadata.list)': [null, MetadataDef[]];
|
|
87
87
|
'pri(seed.create)': [RequestSeedCreate, ResponseSeedCreate];
|
|
88
88
|
'pri(seed.validate)': [RequestSeedValidate, ResponseSeedValidate];
|
|
89
|
+
'pri(settings.notification)': [string, boolean];
|
|
89
90
|
'pri(signing.approve.password)': [RequestSigningApprovePassword, boolean];
|
|
90
91
|
'pri(signing.approve.signature)': [RequestSigningApproveSignature, boolean];
|
|
91
92
|
'pri(signing.cancel)': [RequestSigningCancel, boolean];
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polkadot/extension-base",
|
|
3
3
|
"description": "Functions, classes and other utilities used in @polkadot/extension",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.40.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
|
7
7
|
"license": "Apache-2",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@babel/runtime": "^7.15.
|
|
12
|
-
"@polkadot/api": "^5.
|
|
13
|
-
"@polkadot/extension-dapp": "^0.
|
|
14
|
-
"@polkadot/extension-inject": "^0.
|
|
11
|
+
"@babel/runtime": "^7.15.4",
|
|
12
|
+
"@polkadot/api": "^5.9.2-7",
|
|
13
|
+
"@polkadot/extension-dapp": "^0.40.2",
|
|
14
|
+
"@polkadot/extension-inject": "^0.40.2",
|
|
15
15
|
"@polkadot/keyring": "^7.3.1",
|
|
16
|
-
"@polkadot/phishing": "^0.6.
|
|
17
|
-
"@polkadot/ui-keyring": "^0.85.3"
|
|
16
|
+
"@polkadot/phishing": "^0.6.294",
|
|
17
|
+
"@polkadot/ui-keyring": "^0.85.4-3"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED