@onekeyfe/inpage-providers-hub 2.2.32 → 2.2.33

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.
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.MediumRisk = exports.HighRisk = exports.Logo = void 0;
14
+ exports.VerifiedIcon = exports.MediumRisk = exports.HighRisk = exports.Logo = void 0;
15
15
  exports.Image = Image;
16
16
  const jsx_runtime_1 = require("preact/jsx-runtime");
17
17
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
@@ -25,3 +25,5 @@ const HighRisk = ({ style }) => ((0, jsx_runtime_1.jsx)(Image, { style: style, s
25
25
  exports.HighRisk = HighRisk;
26
26
  const MediumRisk = ({ style }) => ((0, jsx_runtime_1.jsx)(Image, { style: style, src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB8AAAAfCAYAAAAfrhY5AAABk0lEQVRIDe2XPU7DQBCF3zqRaEgukAuEAyS0AaWhA1qkhJ5cAA6DZEu0IaKhAQ4QDoAvkAvEDRTx8mbJILceJyshsZK1uyPNfLMz+zN2qLSrM3TbnzhHgn5FvLOh93insWX2hpUYdWr5eoR+mSDlvKuyPfUCvqMDywCfnKJHwZzfvsFhPd6hcB4Xicw4uYkFFh7BHXazAOdkKMLIbRDghErYY7eewmODA88M5z7JNwc4ppWxjC3em+HcJ9nDM9ZyZmUcFc4L4/ci4soHFrie8w+LMqFL0bOelrYFqjpWqOpbcz5lro/ko6F4G845vMq9rN5H3XAlMJTXT+FN+tphZ547rS/MJyOMm4BFtzZ8C+xRUx6HRs0KbwRV5X+4RiJq/zfD7iq7XY6fJWTmu730mE1PfpB8YKQGrN3McFktobe1iRUFzfm6Ios2VHgRjbgFeSBX+CI2PEnwGODtQ6TMn6kINDq9Sl+QBfj9U/h9mdFQjAgsWPVeitOhhqt6L281n0wtDnfyM+FaWPsNCkJzqXiV9w3zlWKqZDoCQAAAAABJRU5ErkJggg==" }));
27
27
  exports.MediumRisk = MediumRisk;
28
+ const VerifiedIcon = ({ style }) => ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: style, children: (0, jsx_runtime_1.jsx)("path", { width: "16", height: "16", viewBox: "0 0 24 24", d: "M10.4673 2.69869C11.2767 1.76711 12.7232 1.7671 13.5326 2.69868L14.8908 4.26193C14.8977 4.26983 14.9082 4.27364 14.9185 4.272L16.9638 3.94755C18.1827 3.7542 19.2907 4.68395 19.3119 5.91786L19.3476 7.98845C19.3478 7.99891 19.3533 8.00854 19.3623 8.01393L21.1377 9.08009C22.1956 9.71544 22.4468 11.1399 21.6699 12.0988L20.3663 13.7079C20.3597 13.716 20.3578 13.7269 20.3612 13.7368L21.0359 15.6947C21.4379 16.8615 20.7147 18.1142 19.5032 18.3493L17.4703 18.744C17.46 18.746 17.4515 18.7531 17.4478 18.7629L16.7061 20.6964C16.2641 21.8487 14.9049 22.3434 13.8257 21.7448L12.0147 20.7404C12.0055 20.7353 11.9944 20.7353 11.9852 20.7404L10.1742 21.7448C9.09503 22.3434 7.73582 21.8487 7.29383 20.6964L6.55216 18.7629C6.54841 18.7531 6.53989 18.746 6.52962 18.744L4.49668 18.3493C3.2852 18.1142 2.56198 16.8615 2.96404 15.6947L3.63873 13.7368C3.64214 13.7269 3.64021 13.716 3.63362 13.7079L2.32998 12.0988C1.55311 11.1399 1.80428 9.71544 2.86226 9.08009L4.63762 8.01393C4.64659 8.00854 4.65215 7.99891 4.65233 7.98845L4.68797 5.91786C4.70921 4.68395 5.81725 3.7542 7.0361 3.94755L9.08142 4.272C9.09176 4.27364 9.10221 4.26983 9.10907 4.26193L10.4673 2.69869ZM15.2071 11.2071C15.5976 10.8166 15.5976 10.1834 15.2071 9.79289C14.8166 9.40237 14.1834 9.40237 13.7929 9.79289L11 12.5858L10.2071 11.7929C9.81655 11.4024 9.18339 11.4024 8.79286 11.7929C8.40234 12.1834 8.40234 12.8166 8.79286 13.2071L9.93931 14.3536C10.5251 14.9393 11.4748 14.9393 12.0606 14.3536L15.2071 11.2071Z", fill: "#006B3B", fillOpacity: "0.906" }) }));
29
+ exports.VerifiedIcon = VerifiedIcon;
@@ -34,6 +34,20 @@ const textStyle = {
34
34
  marginLeft: '8px',
35
35
  };
36
36
  const containerId = 'onekey-floating-widget';
37
+ const SECURITY_INFO = {
38
+ [type_1.EHostSecurityLevel.Security]: {
39
+ titleId: 'verifiedSite',
40
+ icon: (0, jsx_runtime_1.jsx)(images_1.VerifiedIcon, { style: { width: 16, height: 16 } }),
41
+ },
42
+ [type_1.EHostSecurityLevel.High]: {
43
+ titleId: 'maliciousSiteWarning',
44
+ icon: ((0, jsx_runtime_1.jsx)(images_1.HighRisk, { style: { width: 16, height: 16 } })),
45
+ },
46
+ [type_1.EHostSecurityLevel.Medium]: {
47
+ titleId: 'suspectedMaliciousBehavior',
48
+ icon: ((0, jsx_runtime_1.jsx)(images_1.MediumRisk, { style: { width: 16, height: 16 } })),
49
+ },
50
+ };
37
51
  const removeIcon = () => {
38
52
  var _a;
39
53
  (_a = document.getElementById(containerId)) === null || _a === void 0 ? void 0 : _a.remove();
@@ -99,7 +113,7 @@ function CloseDialog({ onClose, side }) {
99
113
  lineHeight: '16px',
100
114
  }, children: i18n.canBeReEnabledInSettings })] })] })] }));
101
115
  }
102
- function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDragging, showCloseDialog, side, }) {
116
+ function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDragging, showCloseDialog, side, riskLevel, }) {
103
117
  const [showCloseButton, setIsShowCloseButton] = (0, hooks_1.useState)(false);
104
118
  return ((0, jsx_runtime_1.jsxs)("div", { style: {
105
119
  display: 'flex',
@@ -118,7 +132,17 @@ function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDrag
118
132
  }
119
133
  setIsShowCloseButton(false);
120
134
  onClick();
121
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', padding: '8px', flexDirection: side === 'left' ? 'row-reverse' : 'row' }, children: [(0, jsx_runtime_1.jsx)(images_1.Logo, { style: logoStyle }), !dataLoaded && (0, jsx_runtime_1.jsx)("span", { style: textStyle, children: isExpanded ? i18n.fetchingDAppInfo : '' })] }), isDragging ? null : ((0, jsx_runtime_1.jsx)("div", { style: {
135
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', padding: '8px', flexDirection: side === 'left' ? 'row-reverse' : 'row' }, children: [(0, jsx_runtime_1.jsx)(images_1.Logo, { style: logoStyle }), (0, jsx_runtime_1.jsx)("div", { style: {
136
+ position: 'absolute',
137
+ height: '18px',
138
+ width: '18px',
139
+ display: 'flex',
140
+ alignItems: 'center',
141
+ background: '#fff',
142
+ borderRadius: '6px',
143
+ bottom: '2px',
144
+ left: '24px',
145
+ }, children: riskLevel && riskLevel !== type_1.EHostSecurityLevel.Unknown ? SECURITY_INFO[riskLevel].icon : null }), !dataLoaded && (0, jsx_runtime_1.jsx)("span", { style: textStyle, children: isExpanded ? i18n.fetchingDAppInfo : '' })] }), isDragging ? null : ((0, jsx_runtime_1.jsx)("div", { style: {
122
146
  display: 'flex',
123
147
  padding: '$4',
124
148
  position: 'absolute',
@@ -147,20 +171,6 @@ function SecurityInfoRow({ title, children }) {
147
171
  lineHeight: '16px',
148
172
  }, children: title }), children] }));
149
173
  }
150
- const SECURITY_INFO = {
151
- [type_1.EHostSecurityLevel.Security]: {
152
- titleId: 'verifiedSite',
153
- icon: ((0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { width: "16", height: "16", viewBox: "0 0 24 24", d: "M10.4673 2.69869C11.2767 1.76711 12.7232 1.7671 13.5326 2.69868L14.8908 4.26193C14.8977 4.26983 14.9082 4.27364 14.9185 4.272L16.9638 3.94755C18.1827 3.7542 19.2907 4.68395 19.3119 5.91786L19.3476 7.98845C19.3478 7.99891 19.3533 8.00854 19.3623 8.01393L21.1377 9.08009C22.1956 9.71544 22.4468 11.1399 21.6699 12.0988L20.3663 13.7079C20.3597 13.716 20.3578 13.7269 20.3612 13.7368L21.0359 15.6947C21.4379 16.8615 20.7147 18.1142 19.5032 18.3493L17.4703 18.744C17.46 18.746 17.4515 18.7531 17.4478 18.7629L16.7061 20.6964C16.2641 21.8487 14.9049 22.3434 13.8257 21.7448L12.0147 20.7404C12.0055 20.7353 11.9944 20.7353 11.9852 20.7404L10.1742 21.7448C9.09503 22.3434 7.73582 21.8487 7.29383 20.6964L6.55216 18.7629C6.54841 18.7531 6.53989 18.746 6.52962 18.744L4.49668 18.3493C3.2852 18.1142 2.56198 16.8615 2.96404 15.6947L3.63873 13.7368C3.64214 13.7269 3.64021 13.716 3.63362 13.7079L2.32998 12.0988C1.55311 11.1399 1.80428 9.71544 2.86226 9.08009L4.63762 8.01393C4.64659 8.00854 4.65215 7.99891 4.65233 7.98845L4.68797 5.91786C4.70921 4.68395 5.81725 3.7542 7.0361 3.94755L9.08142 4.272C9.09176 4.27364 9.10221 4.26983 9.10907 4.26193L10.4673 2.69869ZM15.2071 11.2071C15.5976 10.8166 15.5976 10.1834 15.2071 9.79289C14.8166 9.40237 14.1834 9.40237 13.7929 9.79289L11 12.5858L10.2071 11.7929C9.81655 11.4024 9.18339 11.4024 8.79286 11.7929C8.40234 12.1834 8.40234 12.8166 8.79286 13.2071L9.93931 14.3536C10.5251 14.9393 11.4748 14.9393 12.0606 14.3536L15.2071 11.2071Z", fill: "#006B3B", fillOpacity: "0.906" }) })),
154
- },
155
- [type_1.EHostSecurityLevel.High]: {
156
- titleId: 'maliciousSiteWarning',
157
- icon: ((0, jsx_runtime_1.jsx)(images_1.HighRisk, { style: { width: 16, height: 16 } })),
158
- },
159
- [type_1.EHostSecurityLevel.Medium]: {
160
- titleId: 'suspectedMaliciousBehavior',
161
- icon: ((0, jsx_runtime_1.jsx)(images_1.MediumRisk, { style: { width: 16, height: 16 } })),
162
- },
163
- };
164
174
  function SecurityRiskDetectionRow({ securityInfo }) {
165
175
  const { securityElement, securityStatus } = (0, hooks_1.useMemo)(() => {
166
176
  if (securityInfo.level === type_1.EHostSecurityLevel.Unknown) {
@@ -300,19 +310,25 @@ function App() {
300
310
  const handleShowCloseDialog = (0, hooks_1.useCallback)(() => {
301
311
  setIsShowCloseDialog(true);
302
312
  }, []);
313
+ const fetchSecurityInfo = (0, hooks_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
314
+ if (!securityInfo) {
315
+ const result = yield window.$onekey.$private.request({
316
+ method: 'wallet_detectRiskLevel',
317
+ params: { url: window.location.origin },
318
+ });
319
+ setSecurityInfo(result.securityInfo);
320
+ }
321
+ }), [securityInfo]);
322
+ (0, hooks_1.useEffect)(() => {
323
+ void fetchSecurityInfo();
324
+ }, [fetchSecurityInfo]);
303
325
  const handleClick = (0, hooks_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
304
326
  if (!isDraggingRef.current) {
305
- setIsExpanded(!isExpanded);
327
+ setIsExpanded((prev) => !prev);
306
328
  setIsShowSecurityInfo(true);
307
- if (!securityInfo) {
308
- const result = yield window.$onekey.$private.request({
309
- method: 'wallet_detectRiskLevel',
310
- params: { url: window.location.origin },
311
- });
312
- setSecurityInfo(result.securityInfo);
313
- }
329
+ yield fetchSecurityInfo();
314
330
  }
315
- }), [isExpanded, securityInfo]);
331
+ }), [fetchSecurityInfo]);
316
332
  const handleMouseDown = (0, hooks_1.useCallback)((e) => {
317
333
  if (isExpanded) {
318
334
  return;
@@ -422,7 +438,7 @@ function App() {
422
438
  }, onMouseDown: handleMouseDown, children: [showSecurityInfo && securityInfo ? ((0, jsx_runtime_1.jsx)(SecurityInfo, { securityInfo: securityInfo, onClose: () => {
423
439
  setIsExpanded(false);
424
440
  setIsShowSecurityInfo(false);
425
- } })) : ((0, jsx_runtime_1.jsx)(IconButton, { onClick: handleClick, side: side, isExpanded: isExpanded, isShowCloseDialog: showCloseDialog, isDragging: isDragging, showCloseDialog: handleShowCloseDialog, dataLoaded: !!securityInfo })), !isExpanded && showCloseDialog && ((0, jsx_runtime_1.jsx)(CloseDialog, { side: side, onClose: () => {
441
+ } })) : ((0, jsx_runtime_1.jsx)(IconButton, { onClick: handleClick, side: side, isExpanded: isExpanded, isShowCloseDialog: showCloseDialog, isDragging: isDragging, showCloseDialog: handleShowCloseDialog, dataLoaded: !!securityInfo, riskLevel: securityInfo === null || securityInfo === void 0 ? void 0 : securityInfo.level })), !isExpanded && showCloseDialog && ((0, jsx_runtime_1.jsx)(CloseDialog, { side: side, onClose: () => {
426
442
  setIsShowCloseDialog(false);
427
443
  } }))] }));
428
444
  }
@@ -8,3 +8,6 @@ export declare const HighRisk: ({ style }: {
8
8
  export declare const MediumRisk: ({ style }: {
9
9
  style: any;
10
10
  }) => import("preact").JSX.Element;
11
+ export declare const VerifiedIcon: ({ style }: {
12
+ style: any;
13
+ }) => import("preact").JSX.Element;
@@ -18,3 +18,4 @@ export function Image(_a) {
18
18
  export const Logo = ({ style }) => (_jsx(Image, { alt: "OneKey Logo", style: style, src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAA3lBMVEUAAABF1i1E1yxQ3zBE1SxI1zBE1ixE1ixE1i1E1yxF1i1D1StF1ixF1y1E1SxAzzBF1S1F1ixF1S1G1i1D1CxF1y1E1itF2itE1i5F1TBD1ytD1i1F1StG1i1A1yhE1i1E1ixD2StE1StE1S1D1ytF2CxG2S1C1StE1iwAAAARNgsiaxY8uycJGwYzoCEneRlAySkVQw4aURErhhweXhQrhRwFDgMIGwUEDQMWQw4eXhMqhRtAySoNKQgNKAkaUBEvkx4meBk4riQneBkZUBAvkh8ZURAWRA43rSQqhhtHwN7UAAAAKHRSTlMA30AQgCDvv+9/oJ+QYM8QYM+fj5CfcDBwMJ9QMFAgj69fsK9fb1BgeiEMiQAABBhJREFUeF7Fm9d24zgMQEF1F7nEEyeZlJntoIp7SZ269f9/aF8mgz1eSTYgibyPfsE1CIISYQMX9+I29nq9cKyUwm9ESoXh+4kXOxcutIfrXPbGER4hCieXTvMad3FPIYPx2ciHxnAmFJwl4TQTPUIxqq6D2xlgTdTIrxE+wiY4kym475CorWDp2xMd4OEobBh1ayn7xMSFE7lS2ArqxEr4OcKWCKZwAh1skQ4jviWDc2yZM0v5JzqM+MYNfkEj/AAl+BEaIbiAQlyFhlAuFPEOjTGBAq7RIE6BgELCxiJ00CgeHOCjWYLDFJyhYSY1EpDtD/mIfFx5Aub6kAT5ePIKeCkTkFfBCBlkuhEB9KQ9YN6QwJgEHMEK1BdAR1aCmW5KoC9bgXVjAoFsBZLGBNARdcHVK0lNAVqDAYqY1RZQ1IXsCOAddSE7AiMqATsCb6kEjAtQEQzRigCdyY4dAeoEU5sCUwB4Y0eAqjC0I0BHcmBTIKBNYEcAXbiyK3ABjl2BX2FkV2AEnl0BD97YFXgLP9kWCO0KhDUEsvQ7W5QyBoVWUfYFAtsCKOZ5Nl8tkyTZzGcoRywwS3aaWK4NC6xzfUC+Nijw5YMuIM9MCcx1CakZgUddysaEwO+6glX7AqkmmlgFbidc6yMwN0PAFMhyTehdsknTTaL/y/2i1bNgpYld+vzNapuLy0DBQHpD9vhMXotHTcxafB5YlVZbKkxBCF1BAig+kcqq4EfoirbAx6rru8+sizKPIfCXfiWrSg9neuCxXkzyqhCUgpwhMOJM6xb6lT+wgH/0K4wicOBK8hyeVZfo35yX06FEAAvZCTqBCxAwBKoXec8XCABgwBe4bywDIQCjEXyprrKFoBn3Wdd0WfUu+CTYBVPWuIJyvKw8KO55I4uhoBPeL6rys2SOT5VgYLeqOim3zMldV9AK9bpcTmd4KufcgUVSarDWkrMo5o5sZmXPv3PZE5HPHhsmhW+Ds0RzE0AlwLsvz3aa0Ply/vQ0X9FnvArAc8Hg8qs+wmfJ8DhgGPypK3nkjw25M4tEV/ABGZzLxveLB13KwzN3YCQa3qZ18k8oIDxksc11AfkMWcRADANksUhJgd4UkYcP/BQQ2fZFEzr5SuHZJSgdn2afNkmy3788bJ4oOjsBtBPNQgmgKjCLDwd4ln/OB0OFBlHwfxw0yC0QNuqwD0UMbf+sF24CNELkQwkxGmEKpXiGdqBVAw8q6WLLdOEInqX8E56l+MRlgC0R/QYn4StsBXUFJzJspSv3XTid68aToBw4wGgtRp4LXPyugewbUKBvL8GPFdZkTOFlON0aDlGfSq+WwwAFqCai01rwJFQvvmvjz+/9MDqa9UGP/vzeBu6NE3v992Go1HcZpdQg7PW8+PqGHfpfvMttNhJbFlgAAAAASUVORK5CYII=" }));
19
19
  export const HighRisk = ({ style }) => (_jsx(Image, { style: style, src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAgCAYAAACYTcH3AAACrElEQVRYCe1XvW5TMRT+fFMCBNGBNQ8AL8CAxERLB6ZIzJGY6QO0UmekdkViBqkrAxNDaF+AvkBfAEYGQgsq3GvOZ/cqvonta1uRWPAS/xyf893j7/wE+D/8HlD+7bTdEwwnDaqJgn54feNc5sfbuPqQpqErVQzmE4b7gJp21bUrffwUV4ftKvW3ShV05eiRMBBKqqmVcW/1z7M98xH3Noe4eK+BcUy9hpr/wWjnGb59j8m5Z9me2cDFtA8IDQh37lLWNdY3z/LMKW6PGzSzPqXtOb0zgHq+hZ9f2r3Yb5ZnNPTLmLLlM3qnhn61vB9aJ4MhIQWMEDdvMOxPMGpDP3o5GYywIMsrrtUGdZJ3ksDMcCuJtC4Ady7EHM9wc9fd8817wZC0FXQwKhqor79x51GFakcMnPuM2D01ZVoInwO9YEjaWCgP0LxhLmHEsBSEjJHMN/Aj+tRRMPRKCWlDgGxmDpM5CkajeRtWXHYieSrInSAYG8rxlF8Cx4Y6a9vq8IKxRCsP5VUz3R1pO/Z9ZPaCSa0/XRPpK5LZV7dWwJC0kheirHfNSqQ9WKyrpExr5dWUthZ3gQ13wXlu/WGESFI0gORuMhh6pwaYmV/QLkfHM6X1R5QwxyT3Lda0aTM6dWvJM/mkVRgcbOPS9LwsiBr1u9ZYyu913WL2XnimpP6wX2mBUJnMz+R7szzk1i3zTH31h4Z8g+/uktDOdbT++PSQdwx180zSAD0hQr9gfLeWLC1ePaKUZOy9uLT/lB9V4XJiwCgoiQIJ0oJhP0K/5tUyDdaoALlvnkmQzQtwrPWKtCKbBkwT7UPWajOorII6NWBG+CWhmRcFQa0FB2zQ5HXODJjHwFwmB/8CENOD5KpD25w5X8LQZDmQZ9siw52jtU8tCP1Z2tWj9n/VX19Qwam7VmWvAAAAAElFTkSuQmCC" }));
20
20
  export const MediumRisk = ({ style }) => (_jsx(Image, { style: style, src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB8AAAAfCAYAAAAfrhY5AAABk0lEQVRIDe2XPU7DQBCF3zqRaEgukAuEAyS0AaWhA1qkhJ5cAA6DZEu0IaKhAQ4QDoAvkAvEDRTx8mbJILceJyshsZK1uyPNfLMz+zN2qLSrM3TbnzhHgn5FvLOh93insWX2hpUYdWr5eoR+mSDlvKuyPfUCvqMDywCfnKJHwZzfvsFhPd6hcB4Xicw4uYkFFh7BHXazAOdkKMLIbRDghErYY7eewmODA88M5z7JNwc4ppWxjC3em+HcJ9nDM9ZyZmUcFc4L4/ci4soHFrie8w+LMqFL0bOelrYFqjpWqOpbcz5lro/ko6F4G845vMq9rN5H3XAlMJTXT+FN+tphZ547rS/MJyOMm4BFtzZ8C+xRUx6HRs0KbwRV5X+4RiJq/zfD7iq7XY6fJWTmu730mE1PfpB8YKQGrN3McFktobe1iRUFzfm6Ios2VHgRjbgFeSBX+CI2PEnwGODtQ6TMn6kINDq9Sl+QBfj9U/h9mdFQjAgsWPVeitOhhqt6L281n0wtDnfyM+FaWPsNCkJzqXiV9w3zlWKqZDoCQAAAAABJRU5ErkJggg==" }));
21
+ export const VerifiedIcon = ({ style }) => (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: style, children: _jsx("path", { width: "16", height: "16", viewBox: "0 0 24 24", d: "M10.4673 2.69869C11.2767 1.76711 12.7232 1.7671 13.5326 2.69868L14.8908 4.26193C14.8977 4.26983 14.9082 4.27364 14.9185 4.272L16.9638 3.94755C18.1827 3.7542 19.2907 4.68395 19.3119 5.91786L19.3476 7.98845C19.3478 7.99891 19.3533 8.00854 19.3623 8.01393L21.1377 9.08009C22.1956 9.71544 22.4468 11.1399 21.6699 12.0988L20.3663 13.7079C20.3597 13.716 20.3578 13.7269 20.3612 13.7368L21.0359 15.6947C21.4379 16.8615 20.7147 18.1142 19.5032 18.3493L17.4703 18.744C17.46 18.746 17.4515 18.7531 17.4478 18.7629L16.7061 20.6964C16.2641 21.8487 14.9049 22.3434 13.8257 21.7448L12.0147 20.7404C12.0055 20.7353 11.9944 20.7353 11.9852 20.7404L10.1742 21.7448C9.09503 22.3434 7.73582 21.8487 7.29383 20.6964L6.55216 18.7629C6.54841 18.7531 6.53989 18.746 6.52962 18.744L4.49668 18.3493C3.2852 18.1142 2.56198 16.8615 2.96404 15.6947L3.63873 13.7368C3.64214 13.7269 3.64021 13.716 3.63362 13.7079L2.32998 12.0988C1.55311 11.1399 1.80428 9.71544 2.86226 9.08009L4.63762 8.01393C4.64659 8.00854 4.65215 7.99891 4.65233 7.98845L4.68797 5.91786C4.70921 4.68395 5.81725 3.7542 7.0361 3.94755L9.08142 4.272C9.09176 4.27364 9.10221 4.26983 9.10907 4.26193L10.4673 2.69869ZM15.2071 11.2071C15.5976 10.8166 15.5976 10.1834 15.2071 9.79289C14.8166 9.40237 14.1834 9.40237 13.7929 9.79289L11 12.5858L10.2071 11.7929C9.81655 11.4024 9.18339 11.4024 8.79286 11.7929C8.40234 12.1834 8.40234 12.8166 8.79286 13.2071L9.93931 14.3536C10.5251 14.9393 11.4748 14.9393 12.0606 14.3536L15.2071 11.2071Z", fill: "#006B3B", fillOpacity: "0.906" }) }));
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-ru
11
11
  import { render } from 'preact';
12
12
  import { useEffect, useMemo, useCallback, useRef, useState } from 'preact/hooks';
13
13
  import { EHostSecurityLevel } from './type';
14
- import { HighRisk, Logo, MediumRisk, Image } from './images';
14
+ import { HighRisk, VerifiedIcon, Logo, MediumRisk, Image } from './images';
15
15
  import { throttle } from 'lodash';
16
16
  let isInjected = false;
17
17
  let i18n = {};
@@ -31,6 +31,20 @@ const textStyle = {
31
31
  marginLeft: '8px',
32
32
  };
33
33
  const containerId = 'onekey-floating-widget';
34
+ const SECURITY_INFO = {
35
+ [EHostSecurityLevel.Security]: {
36
+ titleId: 'verifiedSite',
37
+ icon: _jsx(VerifiedIcon, { style: { width: 16, height: 16 } }),
38
+ },
39
+ [EHostSecurityLevel.High]: {
40
+ titleId: 'maliciousSiteWarning',
41
+ icon: (_jsx(HighRisk, { style: { width: 16, height: 16 } })),
42
+ },
43
+ [EHostSecurityLevel.Medium]: {
44
+ titleId: 'suspectedMaliciousBehavior',
45
+ icon: (_jsx(MediumRisk, { style: { width: 16, height: 16 } })),
46
+ },
47
+ };
34
48
  const removeIcon = () => {
35
49
  var _a;
36
50
  (_a = document.getElementById(containerId)) === null || _a === void 0 ? void 0 : _a.remove();
@@ -96,7 +110,7 @@ function CloseDialog({ onClose, side }) {
96
110
  lineHeight: '16px',
97
111
  }, children: i18n.canBeReEnabledInSettings })] })] })] }));
98
112
  }
99
- function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDragging, showCloseDialog, side, }) {
113
+ function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDragging, showCloseDialog, side, riskLevel, }) {
100
114
  const [showCloseButton, setIsShowCloseButton] = useState(false);
101
115
  return (_jsxs("div", { style: {
102
116
  display: 'flex',
@@ -115,7 +129,17 @@ function IconButton({ isExpanded, onClick, dataLoaded, isShowCloseDialog, isDrag
115
129
  }
116
130
  setIsShowCloseButton(false);
117
131
  onClick();
118
- }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', padding: '8px', flexDirection: side === 'left' ? 'row-reverse' : 'row' }, children: [_jsx(Logo, { style: logoStyle }), !dataLoaded && _jsx("span", { style: textStyle, children: isExpanded ? i18n.fetchingDAppInfo : '' })] }), isDragging ? null : (_jsx("div", { style: {
132
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', padding: '8px', flexDirection: side === 'left' ? 'row-reverse' : 'row' }, children: [_jsx(Logo, { style: logoStyle }), _jsx("div", { style: {
133
+ position: 'absolute',
134
+ height: '18px',
135
+ width: '18px',
136
+ display: 'flex',
137
+ alignItems: 'center',
138
+ background: '#fff',
139
+ borderRadius: '6px',
140
+ bottom: '2px',
141
+ left: '24px',
142
+ }, children: riskLevel && riskLevel !== EHostSecurityLevel.Unknown ? SECURITY_INFO[riskLevel].icon : null }), !dataLoaded && _jsx("span", { style: textStyle, children: isExpanded ? i18n.fetchingDAppInfo : '' })] }), isDragging ? null : (_jsx("div", { style: {
119
143
  display: 'flex',
120
144
  padding: '$4',
121
145
  position: 'absolute',
@@ -144,20 +168,6 @@ function SecurityInfoRow({ title, children }) {
144
168
  lineHeight: '16px',
145
169
  }, children: title }), children] }));
146
170
  }
147
- const SECURITY_INFO = {
148
- [EHostSecurityLevel.Security]: {
149
- titleId: 'verifiedSite',
150
- icon: (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { width: "16", height: "16", viewBox: "0 0 24 24", d: "M10.4673 2.69869C11.2767 1.76711 12.7232 1.7671 13.5326 2.69868L14.8908 4.26193C14.8977 4.26983 14.9082 4.27364 14.9185 4.272L16.9638 3.94755C18.1827 3.7542 19.2907 4.68395 19.3119 5.91786L19.3476 7.98845C19.3478 7.99891 19.3533 8.00854 19.3623 8.01393L21.1377 9.08009C22.1956 9.71544 22.4468 11.1399 21.6699 12.0988L20.3663 13.7079C20.3597 13.716 20.3578 13.7269 20.3612 13.7368L21.0359 15.6947C21.4379 16.8615 20.7147 18.1142 19.5032 18.3493L17.4703 18.744C17.46 18.746 17.4515 18.7531 17.4478 18.7629L16.7061 20.6964C16.2641 21.8487 14.9049 22.3434 13.8257 21.7448L12.0147 20.7404C12.0055 20.7353 11.9944 20.7353 11.9852 20.7404L10.1742 21.7448C9.09503 22.3434 7.73582 21.8487 7.29383 20.6964L6.55216 18.7629C6.54841 18.7531 6.53989 18.746 6.52962 18.744L4.49668 18.3493C3.2852 18.1142 2.56198 16.8615 2.96404 15.6947L3.63873 13.7368C3.64214 13.7269 3.64021 13.716 3.63362 13.7079L2.32998 12.0988C1.55311 11.1399 1.80428 9.71544 2.86226 9.08009L4.63762 8.01393C4.64659 8.00854 4.65215 7.99891 4.65233 7.98845L4.68797 5.91786C4.70921 4.68395 5.81725 3.7542 7.0361 3.94755L9.08142 4.272C9.09176 4.27364 9.10221 4.26983 9.10907 4.26193L10.4673 2.69869ZM15.2071 11.2071C15.5976 10.8166 15.5976 10.1834 15.2071 9.79289C14.8166 9.40237 14.1834 9.40237 13.7929 9.79289L11 12.5858L10.2071 11.7929C9.81655 11.4024 9.18339 11.4024 8.79286 11.7929C8.40234 12.1834 8.40234 12.8166 8.79286 13.2071L9.93931 14.3536C10.5251 14.9393 11.4748 14.9393 12.0606 14.3536L15.2071 11.2071Z", fill: "#006B3B", fillOpacity: "0.906" }) })),
151
- },
152
- [EHostSecurityLevel.High]: {
153
- titleId: 'maliciousSiteWarning',
154
- icon: (_jsx(HighRisk, { style: { width: 16, height: 16 } })),
155
- },
156
- [EHostSecurityLevel.Medium]: {
157
- titleId: 'suspectedMaliciousBehavior',
158
- icon: (_jsx(MediumRisk, { style: { width: 16, height: 16 } })),
159
- },
160
- };
161
171
  function SecurityRiskDetectionRow({ securityInfo }) {
162
172
  const { securityElement, securityStatus } = useMemo(() => {
163
173
  if (securityInfo.level === EHostSecurityLevel.Unknown) {
@@ -297,19 +307,25 @@ function App() {
297
307
  const handleShowCloseDialog = useCallback(() => {
298
308
  setIsShowCloseDialog(true);
299
309
  }, []);
310
+ const fetchSecurityInfo = useCallback(() => __awaiter(this, void 0, void 0, function* () {
311
+ if (!securityInfo) {
312
+ const result = yield window.$onekey.$private.request({
313
+ method: 'wallet_detectRiskLevel',
314
+ params: { url: window.location.origin },
315
+ });
316
+ setSecurityInfo(result.securityInfo);
317
+ }
318
+ }), [securityInfo]);
319
+ useEffect(() => {
320
+ void fetchSecurityInfo();
321
+ }, [fetchSecurityInfo]);
300
322
  const handleClick = useCallback(() => __awaiter(this, void 0, void 0, function* () {
301
323
  if (!isDraggingRef.current) {
302
- setIsExpanded(!isExpanded);
324
+ setIsExpanded((prev) => !prev);
303
325
  setIsShowSecurityInfo(true);
304
- if (!securityInfo) {
305
- const result = yield window.$onekey.$private.request({
306
- method: 'wallet_detectRiskLevel',
307
- params: { url: window.location.origin },
308
- });
309
- setSecurityInfo(result.securityInfo);
310
- }
326
+ yield fetchSecurityInfo();
311
327
  }
312
- }), [isExpanded, securityInfo]);
328
+ }), [fetchSecurityInfo]);
313
329
  const handleMouseDown = useCallback((e) => {
314
330
  if (isExpanded) {
315
331
  return;
@@ -419,7 +435,7 @@ function App() {
419
435
  }, onMouseDown: handleMouseDown, children: [showSecurityInfo && securityInfo ? (_jsx(SecurityInfo, { securityInfo: securityInfo, onClose: () => {
420
436
  setIsExpanded(false);
421
437
  setIsShowSecurityInfo(false);
422
- } })) : (_jsx(IconButton, { onClick: handleClick, side: side, isExpanded: isExpanded, isShowCloseDialog: showCloseDialog, isDragging: isDragging, showCloseDialog: handleShowCloseDialog, dataLoaded: !!securityInfo })), !isExpanded && showCloseDialog && (_jsx(CloseDialog, { side: side, onClose: () => {
438
+ } })) : (_jsx(IconButton, { onClick: handleClick, side: side, isExpanded: isExpanded, isShowCloseDialog: showCloseDialog, isDragging: isDragging, showCloseDialog: handleShowCloseDialog, dataLoaded: !!securityInfo, riskLevel: securityInfo === null || securityInfo === void 0 ? void 0 : securityInfo.level })), !isExpanded && showCloseDialog && (_jsx(CloseDialog, { side: side, onClose: () => {
423
439
  setIsShowCloseDialog(false);
424
440
  } }))] }));
425
441
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/inpage-providers-hub",
3
- "version": "2.2.32",
3
+ "version": "2.2.33",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -27,27 +27,27 @@
27
27
  "start": "tsc --watch"
28
28
  },
29
29
  "dependencies": {
30
- "@onekeyfe/cross-inpage-provider-core": "2.2.32",
31
- "@onekeyfe/cross-inpage-provider-types": "2.2.32",
32
- "@onekeyfe/onekey-algo-provider": "2.2.32",
33
- "@onekeyfe/onekey-alph-provider": "2.2.32",
34
- "@onekeyfe/onekey-aptos-provider": "2.2.32",
35
- "@onekeyfe/onekey-bfc-provider": "2.2.32",
36
- "@onekeyfe/onekey-btc-provider": "2.2.32",
37
- "@onekeyfe/onekey-cardano-provider": "2.2.32",
38
- "@onekeyfe/onekey-conflux-provider": "2.2.32",
39
- "@onekeyfe/onekey-cosmos-provider": "2.2.32",
40
- "@onekeyfe/onekey-eth-provider": "2.2.32",
41
- "@onekeyfe/onekey-neo-provider": "2.2.32",
42
- "@onekeyfe/onekey-nostr-provider": "2.2.32",
43
- "@onekeyfe/onekey-polkadot-provider": "2.2.32",
44
- "@onekeyfe/onekey-private-provider": "2.2.32",
45
- "@onekeyfe/onekey-scdo-provider": "2.2.32",
46
- "@onekeyfe/onekey-solana-provider": "2.2.32",
47
- "@onekeyfe/onekey-sui-provider": "2.2.32",
48
- "@onekeyfe/onekey-ton-provider": "2.2.32",
49
- "@onekeyfe/onekey-tron-provider": "2.2.32",
50
- "@onekeyfe/onekey-webln-provider": "2.2.32",
30
+ "@onekeyfe/cross-inpage-provider-core": "2.2.33",
31
+ "@onekeyfe/cross-inpage-provider-types": "2.2.33",
32
+ "@onekeyfe/onekey-algo-provider": "2.2.33",
33
+ "@onekeyfe/onekey-alph-provider": "2.2.33",
34
+ "@onekeyfe/onekey-aptos-provider": "2.2.33",
35
+ "@onekeyfe/onekey-bfc-provider": "2.2.33",
36
+ "@onekeyfe/onekey-btc-provider": "2.2.33",
37
+ "@onekeyfe/onekey-cardano-provider": "2.2.33",
38
+ "@onekeyfe/onekey-conflux-provider": "2.2.33",
39
+ "@onekeyfe/onekey-cosmos-provider": "2.2.33",
40
+ "@onekeyfe/onekey-eth-provider": "2.2.33",
41
+ "@onekeyfe/onekey-neo-provider": "2.2.33",
42
+ "@onekeyfe/onekey-nostr-provider": "2.2.33",
43
+ "@onekeyfe/onekey-polkadot-provider": "2.2.33",
44
+ "@onekeyfe/onekey-private-provider": "2.2.33",
45
+ "@onekeyfe/onekey-scdo-provider": "2.2.33",
46
+ "@onekeyfe/onekey-solana-provider": "2.2.33",
47
+ "@onekeyfe/onekey-sui-provider": "2.2.33",
48
+ "@onekeyfe/onekey-ton-provider": "2.2.33",
49
+ "@onekeyfe/onekey-tron-provider": "2.2.33",
50
+ "@onekeyfe/onekey-webln-provider": "2.2.33",
51
51
  "lodash-es": "^4.17.21",
52
52
  "preact": "^10.25.1",
53
53
  "web3": "^1.7.3"
@@ -56,5 +56,8 @@
56
56
  "@types/lodash-es": "^4.17.12",
57
57
  "@types/node": "^20.12.7"
58
58
  },
59
- "gitHead": "1daa0a175d6a15ccb32a68cfb394b49f53cc8cb4"
59
+ "resolutions": {
60
+ "pbkdf2": "^3.1.3"
61
+ },
62
+ "gitHead": "ca6a011d6488461a132d0c5d5fddc68bdf9ceb3a"
60
63
  }