@onekeyfe/inpage-providers-hub 2.1.7 → 2.1.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.
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.detectWebsiteRiskLevel = void 0;
12
+ exports.listenPageFocus = exports.detectWebsiteRiskLevel = void 0;
13
13
  /* eslint-disable @typescript-eslint/no-unsafe-call */
14
14
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
15
+ const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
15
16
  const style_1 = require("./style");
16
17
  var EHostSecurityLevel;
17
18
  (function (EHostSecurityLevel) {
@@ -140,3 +141,29 @@ function detectWebsiteRiskLevel() {
140
141
  });
141
142
  }
142
143
  exports.detectWebsiteRiskLevel = detectWebsiteRiskLevel;
144
+ function listenPageFocus() {
145
+ // Notify the frontend of the last focused URL when the function is called
146
+ try {
147
+ void window.$onekey.$private.request({
148
+ method: "wallet_lastFocusUrl",
149
+ });
150
+ }
151
+ catch (_a) {
152
+ // ignore
153
+ }
154
+ // Add a focus event listener to the window
155
+ window.addEventListener('focus', () => {
156
+ try {
157
+ if ((0, cross_inpage_provider_core_1.isInSameOriginIframe)()) {
158
+ return;
159
+ }
160
+ void window.$onekey.$private.request({
161
+ method: "wallet_lastFocusUrl",
162
+ });
163
+ }
164
+ catch (error) {
165
+ console.error('Error notifying frontend of page focus:', error);
166
+ }
167
+ });
168
+ }
169
+ exports.listenPageFocus = listenPageFocus;
@@ -194,6 +194,7 @@ function injectWeb3Provider() {
194
194
  setTimeout(() => {
195
195
  void (0, detectRiskWebsite_1.detectWebsiteRiskLevel)();
196
196
  void (0, connectButtonHack_1.hackAllConnectButtons)();
197
+ void (0, detectRiskWebsite_1.listenPageFocus)();
197
198
  }, 1000);
198
199
  return $onekey;
199
200
  }
@@ -1 +1,2 @@
1
1
  export declare function detectWebsiteRiskLevel(): Promise<void>;
2
+ export declare function listenPageFocus(): void;
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  /* eslint-disable @typescript-eslint/no-unsafe-call */
11
11
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
12
+ import { isInSameOriginIframe } from '@onekeyfe/cross-inpage-provider-core';
12
13
  import { styleContent } from "./style";
13
14
  var EHostSecurityLevel;
14
15
  (function (EHostSecurityLevel) {
@@ -136,3 +137,28 @@ export function detectWebsiteRiskLevel() {
136
137
  }
137
138
  });
138
139
  }
140
+ export function listenPageFocus() {
141
+ // Notify the frontend of the last focused URL when the function is called
142
+ try {
143
+ void window.$onekey.$private.request({
144
+ method: "wallet_lastFocusUrl",
145
+ });
146
+ }
147
+ catch (_a) {
148
+ // ignore
149
+ }
150
+ // Add a focus event listener to the window
151
+ window.addEventListener('focus', () => {
152
+ try {
153
+ if (isInSameOriginIframe()) {
154
+ return;
155
+ }
156
+ void window.$onekey.$private.request({
157
+ method: "wallet_lastFocusUrl",
158
+ });
159
+ }
160
+ catch (error) {
161
+ console.error('Error notifying frontend of page focus:', error);
162
+ }
163
+ });
164
+ }
@@ -19,7 +19,7 @@ import { ProviderNostr } from '@onekeyfe/onekey-nostr-provider';
19
19
  import { ProviderBtc, ProviderBtcWallet } from '@onekeyfe/onekey-btc-provider';
20
20
  import { ProviderAlgo } from '@onekeyfe/onekey-algo-provider';
21
21
  import { hackAllConnectButtons } from './connectButtonHack';
22
- import { detectWebsiteRiskLevel } from './detectRiskWebsite';
22
+ import { detectWebsiteRiskLevel, listenPageFocus } from './detectRiskWebsite';
23
23
  import { WALLET_CONNECT_INFO } from './connectButtonHack/consts';
24
24
  function injectWeb3Provider() {
25
25
  var _a, _b;
@@ -191,6 +191,7 @@ function injectWeb3Provider() {
191
191
  setTimeout(() => {
192
192
  void detectWebsiteRiskLevel();
193
193
  void hackAllConnectButtons();
194
+ void listenPageFocus();
194
195
  }, 1000);
195
196
  return $onekey;
196
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/inpage-providers-hub",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -30,26 +30,26 @@
30
30
  "start": "tsc --watch"
31
31
  },
32
32
  "dependencies": {
33
- "@onekeyfe/cross-inpage-provider-core": "2.1.7",
34
- "@onekeyfe/cross-inpage-provider-types": "2.1.7",
35
- "@onekeyfe/onekey-algo-provider": "2.1.7",
36
- "@onekeyfe/onekey-alph-provider": "2.1.7",
37
- "@onekeyfe/onekey-aptos-provider": "2.1.7",
38
- "@onekeyfe/onekey-btc-provider": "2.1.7",
39
- "@onekeyfe/onekey-cardano-provider": "2.1.7",
40
- "@onekeyfe/onekey-conflux-provider": "2.1.7",
41
- "@onekeyfe/onekey-cosmos-provider": "2.1.7",
42
- "@onekeyfe/onekey-eth-provider": "2.1.7",
43
- "@onekeyfe/onekey-nostr-provider": "2.1.7",
44
- "@onekeyfe/onekey-polkadot-provider": "2.1.7",
45
- "@onekeyfe/onekey-private-external-account-provider": "2.1.7",
46
- "@onekeyfe/onekey-private-provider": "2.1.7",
47
- "@onekeyfe/onekey-scdo-provider": "2.1.7",
48
- "@onekeyfe/onekey-solana-provider": "2.1.7",
49
- "@onekeyfe/onekey-sui-provider": "2.1.7",
50
- "@onekeyfe/onekey-ton-provider": "2.1.7",
51
- "@onekeyfe/onekey-tron-provider": "2.1.7",
52
- "@onekeyfe/onekey-webln-provider": "2.1.7",
33
+ "@onekeyfe/cross-inpage-provider-core": "2.1.8",
34
+ "@onekeyfe/cross-inpage-provider-types": "2.1.8",
35
+ "@onekeyfe/onekey-algo-provider": "2.1.8",
36
+ "@onekeyfe/onekey-alph-provider": "2.1.8",
37
+ "@onekeyfe/onekey-aptos-provider": "2.1.8",
38
+ "@onekeyfe/onekey-btc-provider": "2.1.8",
39
+ "@onekeyfe/onekey-cardano-provider": "2.1.8",
40
+ "@onekeyfe/onekey-conflux-provider": "2.1.8",
41
+ "@onekeyfe/onekey-cosmos-provider": "2.1.8",
42
+ "@onekeyfe/onekey-eth-provider": "2.1.8",
43
+ "@onekeyfe/onekey-nostr-provider": "2.1.8",
44
+ "@onekeyfe/onekey-polkadot-provider": "2.1.8",
45
+ "@onekeyfe/onekey-private-external-account-provider": "2.1.8",
46
+ "@onekeyfe/onekey-private-provider": "2.1.8",
47
+ "@onekeyfe/onekey-scdo-provider": "2.1.8",
48
+ "@onekeyfe/onekey-solana-provider": "2.1.8",
49
+ "@onekeyfe/onekey-sui-provider": "2.1.8",
50
+ "@onekeyfe/onekey-ton-provider": "2.1.8",
51
+ "@onekeyfe/onekey-tron-provider": "2.1.8",
52
+ "@onekeyfe/onekey-webln-provider": "2.1.8",
53
53
  "web3": "^1.7.3"
54
54
  },
55
55
  "devDependencies": {
@@ -57,5 +57,5 @@
57
57
  "@types/node": "^20.12.7",
58
58
  "playwright": "^1.43.1"
59
59
  },
60
- "gitHead": "d8462873a90d725108eb462ff1676ecfd53a9514"
60
+ "gitHead": "40fd9b618f62b24870523282fa47da5c2ca33d66"
61
61
  }