@onekeyfe/inpage-providers-hub 2.1.7 → 2.1.9

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,7 @@ 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;
13
- /* eslint-disable @typescript-eslint/no-unsafe-call */
14
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
12
+ exports.listenPageFocus = exports.detectWebsiteRiskLevel = void 0;
15
13
  const style_1 = require("./style");
16
14
  var EHostSecurityLevel;
17
15
  (function (EHostSecurityLevel) {
@@ -140,3 +138,30 @@ function detectWebsiteRiskLevel() {
140
138
  });
141
139
  }
142
140
  exports.detectWebsiteRiskLevel = detectWebsiteRiskLevel;
141
+ function listenPageFocus() {
142
+ // Notify the frontend of the last focused URL when the function is called
143
+ const notifyToBackground = () => {
144
+ if (window.top !== window.self) {
145
+ return;
146
+ }
147
+ void window.$onekey.$private.request({
148
+ method: "wallet_lastFocusUrl",
149
+ });
150
+ };
151
+ try {
152
+ notifyToBackground();
153
+ }
154
+ catch (_a) {
155
+ // ignore
156
+ }
157
+ // Add a focus event listener to the window
158
+ window.addEventListener('focus', () => {
159
+ try {
160
+ notifyToBackground();
161
+ }
162
+ catch (error) {
163
+ console.error('Error notifying frontend of page focus:', error);
164
+ }
165
+ });
166
+ }
167
+ 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;
@@ -7,8 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- /* eslint-disable @typescript-eslint/no-unsafe-call */
11
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
12
10
  import { styleContent } from "./style";
13
11
  var EHostSecurityLevel;
14
12
  (function (EHostSecurityLevel) {
@@ -136,3 +134,29 @@ export function detectWebsiteRiskLevel() {
136
134
  }
137
135
  });
138
136
  }
137
+ export function listenPageFocus() {
138
+ // Notify the frontend of the last focused URL when the function is called
139
+ const notifyToBackground = () => {
140
+ if (window.top !== window.self) {
141
+ return;
142
+ }
143
+ void window.$onekey.$private.request({
144
+ method: "wallet_lastFocusUrl",
145
+ });
146
+ };
147
+ try {
148
+ notifyToBackground();
149
+ }
150
+ catch (_a) {
151
+ // ignore
152
+ }
153
+ // Add a focus event listener to the window
154
+ window.addEventListener('focus', () => {
155
+ try {
156
+ notifyToBackground();
157
+ }
158
+ catch (error) {
159
+ console.error('Error notifying frontend of page focus:', error);
160
+ }
161
+ });
162
+ }
@@ -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.9",
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.9",
34
+ "@onekeyfe/cross-inpage-provider-types": "2.1.9",
35
+ "@onekeyfe/onekey-algo-provider": "2.1.9",
36
+ "@onekeyfe/onekey-alph-provider": "2.1.9",
37
+ "@onekeyfe/onekey-aptos-provider": "2.1.9",
38
+ "@onekeyfe/onekey-btc-provider": "2.1.9",
39
+ "@onekeyfe/onekey-cardano-provider": "2.1.9",
40
+ "@onekeyfe/onekey-conflux-provider": "2.1.9",
41
+ "@onekeyfe/onekey-cosmos-provider": "2.1.9",
42
+ "@onekeyfe/onekey-eth-provider": "2.1.9",
43
+ "@onekeyfe/onekey-nostr-provider": "2.1.9",
44
+ "@onekeyfe/onekey-polkadot-provider": "2.1.9",
45
+ "@onekeyfe/onekey-private-external-account-provider": "2.1.9",
46
+ "@onekeyfe/onekey-private-provider": "2.1.9",
47
+ "@onekeyfe/onekey-scdo-provider": "2.1.9",
48
+ "@onekeyfe/onekey-solana-provider": "2.1.9",
49
+ "@onekeyfe/onekey-sui-provider": "2.1.9",
50
+ "@onekeyfe/onekey-ton-provider": "2.1.9",
51
+ "@onekeyfe/onekey-tron-provider": "2.1.9",
52
+ "@onekeyfe/onekey-webln-provider": "2.1.9",
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": "dd6a7ac0873030af3f1e589a7d963200f4295a48"
61
61
  }