@onekeyfe/onekey-private-provider 1.1.58-alpha.1 → 1.1.58
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/dist/ProviderPrivate.d.ts +0 -27
- package/dist/ProviderPrivate.js +4 -15
- package/dist/cjs/ProviderPrivate.js +3 -14
- package/package.json +6 -6
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
import { IInjectedProviderNamesStrings } from '@onekeyfe/cross-inpage-provider-types';
|
|
2
2
|
import { IInpageProviderConfig, ProviderBase } from '@onekeyfe/cross-inpage-provider-core';
|
|
3
|
-
export interface IOneKeyWalletInfo {
|
|
4
|
-
enableExtContentScriptReloadButton?: boolean;
|
|
5
|
-
platform?: string;
|
|
6
|
-
version?: string;
|
|
7
|
-
buildNumber?: string;
|
|
8
|
-
disableExt: boolean;
|
|
9
|
-
isDefaultWallet?: boolean;
|
|
10
|
-
excludedDappList: string[];
|
|
11
|
-
isLegacy: boolean;
|
|
12
|
-
platformEnv: {
|
|
13
|
-
isRuntimeBrowser?: boolean;
|
|
14
|
-
isRuntimeChrome?: boolean;
|
|
15
|
-
isRuntimeFirefox?: boolean;
|
|
16
|
-
isWeb?: boolean;
|
|
17
|
-
isNative?: boolean;
|
|
18
|
-
isNativeIOS?: boolean;
|
|
19
|
-
isNativeAndroid?: boolean;
|
|
20
|
-
isExtension?: boolean;
|
|
21
|
-
isExtChrome?: boolean;
|
|
22
|
-
isExtFirefox?: boolean;
|
|
23
|
-
isDesktop?: boolean;
|
|
24
|
-
isDesktopWin?: boolean;
|
|
25
|
-
isDesktopLinux?: boolean;
|
|
26
|
-
isDesktopMac?: boolean;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
3
|
declare class ProviderPrivate extends ProviderBase {
|
|
30
4
|
constructor(props: IInpageProviderConfig);
|
|
31
5
|
private _registerEvents;
|
|
32
6
|
protected providerName: IInjectedProviderNamesStrings;
|
|
33
7
|
request(data: unknown): Promise<unknown>;
|
|
34
|
-
notifyDefaultWalletChanged(params: IOneKeyWalletInfo): void;
|
|
35
8
|
}
|
|
36
9
|
export { ProviderPrivate };
|
package/dist/ProviderPrivate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IInjectedProviderNames, } from '@onekeyfe/cross-inpage-provider-types';
|
|
2
|
-
import { ProviderBase
|
|
2
|
+
import { ProviderBase } from '@onekeyfe/cross-inpage-provider-core';
|
|
3
3
|
import { consts } from '@onekeyfe/cross-inpage-provider-core';
|
|
4
|
-
const {
|
|
4
|
+
const { WALLET_INFO_LOACAL_KEY } = consts;
|
|
5
5
|
const PROVIDER_EVENTS = {
|
|
6
6
|
'message_low_level': 'message_low_level',
|
|
7
7
|
};
|
|
@@ -17,7 +17,6 @@ class ProviderPrivate extends ProviderBase {
|
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
console.error(error);
|
|
20
|
-
console.log('======>>>>>>>Private API');
|
|
21
20
|
}
|
|
22
21
|
try {
|
|
23
22
|
void this.sendSiteMetadataDomReady();
|
|
@@ -30,7 +29,7 @@ class ProviderPrivate extends ProviderBase {
|
|
|
30
29
|
_registerEvents() {
|
|
31
30
|
try {
|
|
32
31
|
// platform check
|
|
33
|
-
const walletInfoLocalStr = localStorage.getItem(
|
|
32
|
+
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
34
33
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
35
34
|
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
36
35
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -40,9 +39,7 @@ class ProviderPrivate extends ProviderBase {
|
|
|
40
39
|
const { method, params } = payload;
|
|
41
40
|
if (method === METHODS.wallet_events_ext_switch_changed) {
|
|
42
41
|
try {
|
|
43
|
-
|
|
44
|
-
localStorage.setItem(WALLET_INFO_LOACAL_KEY_V5, JSON.stringify(params));
|
|
45
|
-
this.notifyDefaultWalletChanged(params);
|
|
42
|
+
localStorage.setItem(WALLET_INFO_LOACAL_KEY, JSON.stringify(params));
|
|
46
43
|
}
|
|
47
44
|
catch (e) {
|
|
48
45
|
console.error(e);
|
|
@@ -58,13 +55,5 @@ class ProviderPrivate extends ProviderBase {
|
|
|
58
55
|
request(data) {
|
|
59
56
|
return this.bridgeRequest(data);
|
|
60
57
|
}
|
|
61
|
-
notifyDefaultWalletChanged(params) {
|
|
62
|
-
let isDefaultWallet = !!params.isDefaultWallet;
|
|
63
|
-
if (isDefaultWallet) {
|
|
64
|
-
const isExcludedWebsite = params.excludedDappList.some(i => i.startsWith(window.location.origin));
|
|
65
|
-
isDefaultWallet = !isExcludedWebsite;
|
|
66
|
-
}
|
|
67
|
-
switchDefaultWalletNotification(isDefaultWallet);
|
|
68
|
-
}
|
|
69
58
|
}
|
|
70
59
|
export { ProviderPrivate };
|
|
@@ -4,7 +4,7 @@ exports.ProviderPrivate = void 0;
|
|
|
4
4
|
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
5
5
|
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
6
6
|
const cross_inpage_provider_core_2 = require("@onekeyfe/cross-inpage-provider-core");
|
|
7
|
-
const {
|
|
7
|
+
const { WALLET_INFO_LOACAL_KEY } = cross_inpage_provider_core_2.consts;
|
|
8
8
|
const PROVIDER_EVENTS = {
|
|
9
9
|
'message_low_level': 'message_low_level',
|
|
10
10
|
};
|
|
@@ -20,7 +20,6 @@ class ProviderPrivate extends cross_inpage_provider_core_1.ProviderBase {
|
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
22
|
console.error(error);
|
|
23
|
-
console.log('======>>>>>>>Private API');
|
|
24
23
|
}
|
|
25
24
|
try {
|
|
26
25
|
void this.sendSiteMetadataDomReady();
|
|
@@ -33,7 +32,7 @@ class ProviderPrivate extends cross_inpage_provider_core_1.ProviderBase {
|
|
|
33
32
|
_registerEvents() {
|
|
34
33
|
try {
|
|
35
34
|
// platform check
|
|
36
|
-
const walletInfoLocalStr = localStorage.getItem(
|
|
35
|
+
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
37
36
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
38
37
|
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
39
38
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -43,9 +42,7 @@ class ProviderPrivate extends cross_inpage_provider_core_1.ProviderBase {
|
|
|
43
42
|
const { method, params } = payload;
|
|
44
43
|
if (method === METHODS.wallet_events_ext_switch_changed) {
|
|
45
44
|
try {
|
|
46
|
-
|
|
47
|
-
localStorage.setItem(WALLET_INFO_LOACAL_KEY_V5, JSON.stringify(params));
|
|
48
|
-
this.notifyDefaultWalletChanged(params);
|
|
45
|
+
localStorage.setItem(WALLET_INFO_LOACAL_KEY, JSON.stringify(params));
|
|
49
46
|
}
|
|
50
47
|
catch (e) {
|
|
51
48
|
console.error(e);
|
|
@@ -61,13 +58,5 @@ class ProviderPrivate extends cross_inpage_provider_core_1.ProviderBase {
|
|
|
61
58
|
request(data) {
|
|
62
59
|
return this.bridgeRequest(data);
|
|
63
60
|
}
|
|
64
|
-
notifyDefaultWalletChanged(params) {
|
|
65
|
-
let isDefaultWallet = !!params.isDefaultWallet;
|
|
66
|
-
if (isDefaultWallet) {
|
|
67
|
-
const isExcludedWebsite = params.excludedDappList.some(i => i.startsWith(window.location.origin));
|
|
68
|
-
isDefaultWallet = !isExcludedWebsite;
|
|
69
|
-
}
|
|
70
|
-
(0, cross_inpage_provider_core_1.switchDefaultWalletNotification)(isDefaultWallet);
|
|
71
|
-
}
|
|
72
61
|
}
|
|
73
62
|
exports.ProviderPrivate = ProviderPrivate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-private-provider",
|
|
3
|
-
"version": "1.1.58
|
|
3
|
+
"version": "1.1.58",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.58
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.58
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.58
|
|
34
|
-
"@onekeyfe/extension-bridge-injected": "1.1.58
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.58",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.58",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.58",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "1.1.58"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "975b254f7617940021ff9848163c1e1c84947d6c"
|
|
37
37
|
}
|