@arcblock/did-connect-react 3.1.0

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.
Files changed (183) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +134 -0
  3. package/lib/Address/index.js +4 -0
  4. package/lib/Avatar/index.js +4 -0
  5. package/lib/Button/index.js +17 -0
  6. package/lib/Connect/assets/locale.js +143 -0
  7. package/lib/Connect/assets/login-bg.png +0 -0
  8. package/lib/Connect/assets/login-slogan.js +9 -0
  9. package/lib/Connect/components/action-button.js +26 -0
  10. package/lib/Connect/components/app-tips.js +132 -0
  11. package/lib/Connect/components/auto-height.js +31 -0
  12. package/lib/Connect/components/back-button.js +24 -0
  13. package/lib/Connect/components/connect-status.js +263 -0
  14. package/lib/Connect/components/did-connect-title.js +126 -0
  15. package/lib/Connect/components/download-tips.js +52 -0
  16. package/lib/Connect/components/loading.js +26 -0
  17. package/lib/Connect/components/login-item/connect-choose-list.js +249 -0
  18. package/lib/Connect/components/login-item/login-method-item.js +129 -0
  19. package/lib/Connect/components/login-item/mobile-login-item.js +114 -0
  20. package/lib/Connect/components/login-item/passkey-login-item.js +44 -0
  21. package/lib/Connect/components/login-item/web-login-item.js +97 -0
  22. package/lib/Connect/components/mask-overlay.js +34 -0
  23. package/lib/Connect/components/refresh-overlay.js +57 -0
  24. package/lib/Connect/components/switch-app.js +70 -0
  25. package/lib/Connect/contexts/state.js +142 -0
  26. package/lib/Connect/fullpage.js +5 -0
  27. package/lib/Connect/hooks/auth-url.js +23 -0
  28. package/lib/Connect/hooks/method-list.js +46 -0
  29. package/lib/Connect/hooks/page-show.js +17 -0
  30. package/lib/Connect/hooks/security.js +27 -0
  31. package/lib/Connect/hooks/token.js +305 -0
  32. package/lib/Connect/hooks/use-apps.js +19 -0
  33. package/lib/Connect/hooks/use-quick-connect.js +97 -0
  34. package/lib/Connect/index.js +498 -0
  35. package/lib/Connect/landing-page.js +5 -0
  36. package/lib/Connect/plugins/email/index.js +62 -0
  37. package/lib/Connect/plugins/email/list-item.js +28 -0
  38. package/lib/Connect/plugins/email/placeholder.js +283 -0
  39. package/lib/Connect/plugins/index.js +4 -0
  40. package/lib/Connect/use-connect.js +164 -0
  41. package/lib/Connect/with-blocklet.js +15 -0
  42. package/lib/Connect/with-bridge-call.js +108 -0
  43. package/lib/Federated/context.js +61 -0
  44. package/lib/Federated/index.js +7 -0
  45. package/lib/Logo/index.js +4 -0
  46. package/lib/OAuth/context.js +234 -0
  47. package/lib/OAuth/guest.svg.js +5 -0
  48. package/lib/OAuth/index.js +7 -0
  49. package/lib/OAuth/passport-switcher.js +114 -0
  50. package/lib/Passkey/actions.js +165 -0
  51. package/lib/Passkey/constants.js +4 -0
  52. package/lib/Passkey/context.js +266 -0
  53. package/lib/Passkey/dialog.js +277 -0
  54. package/lib/Passkey/icon.js +13 -0
  55. package/lib/Passkey/index.js +9 -0
  56. package/lib/Service/index.js +62 -0
  57. package/lib/Session/assets/did-spaces-guide-cover.svg.js +135 -0
  58. package/lib/Session/assets/did-spaces-guide-icon.svg.js +9 -0
  59. package/lib/Session/context.js +5 -0
  60. package/lib/Session/did-spaces-guide.js +136 -0
  61. package/lib/Session/hooks/use-federated.js +64 -0
  62. package/lib/Session/hooks/use-mobile.js +8 -0
  63. package/lib/Session/hooks/use-protected-routes.js +11 -0
  64. package/lib/Session/hooks/use-session-token.js +169 -0
  65. package/lib/Session/hooks/use-verify.js +45 -0
  66. package/lib/Session/index.js +896 -0
  67. package/lib/Session/libs/constants.js +15 -0
  68. package/lib/Session/libs/did-spaces.js +10 -0
  69. package/lib/Session/libs/federated.js +42 -0
  70. package/lib/Session/libs/index.js +15 -0
  71. package/lib/Session/libs/locales.js +161 -0
  72. package/lib/Session/libs/login-mobile.js +55 -0
  73. package/lib/Session/window-focus-aware.js +17 -0
  74. package/lib/SessionManager/index.js +4 -0
  75. package/lib/Storage/engine/cookie.js +21 -0
  76. package/lib/Storage/engine/local-storage.js +36 -0
  77. package/lib/Storage/index.js +23 -0
  78. package/lib/User/index.js +6 -0
  79. package/lib/User/use-did.js +59 -0
  80. package/lib/User/wrap-did.js +13 -0
  81. package/lib/WebWalletSWKeeper/index.js +5 -0
  82. package/lib/constant.js +22 -0
  83. package/lib/error.js +8 -0
  84. package/lib/hooks/use-locale.js +7 -0
  85. package/lib/index.js +33 -0
  86. package/lib/locales/en.js +17 -0
  87. package/lib/locales/index.js +10 -0
  88. package/lib/locales/zh.js +17 -0
  89. package/lib/package.json.js +7 -0
  90. package/lib/types.d.ts +355 -0
  91. package/lib/utils.js +214 -0
  92. package/package.json +84 -0
  93. package/src/Address/index.jsx +2 -0
  94. package/src/Avatar/index.jsx +2 -0
  95. package/src/Button/Button.stories.jsx +7 -0
  96. package/src/Button/index.jsx +21 -0
  97. package/src/Connect/Connect.stories.jsx +34 -0
  98. package/src/Connect/assets/locale.js +145 -0
  99. package/src/Connect/assets/login-bg.png +0 -0
  100. package/src/Connect/assets/login-slogan.js +7 -0
  101. package/src/Connect/components/action-button.jsx +22 -0
  102. package/src/Connect/components/app-tips.jsx +156 -0
  103. package/src/Connect/components/auto-height.jsx +38 -0
  104. package/src/Connect/components/back-button.jsx +23 -0
  105. package/src/Connect/components/connect-status.jsx +259 -0
  106. package/src/Connect/components/did-connect-title.jsx +106 -0
  107. package/src/Connect/components/download-tips.jsx +55 -0
  108. package/src/Connect/components/loading.jsx +25 -0
  109. package/src/Connect/components/login-item/connect-choose-list.jsx +304 -0
  110. package/src/Connect/components/login-item/login-method-item.jsx +118 -0
  111. package/src/Connect/components/login-item/mobile-login-item.jsx +179 -0
  112. package/src/Connect/components/login-item/passkey-login-item.jsx +52 -0
  113. package/src/Connect/components/login-item/web-login-item.jsx +149 -0
  114. package/src/Connect/components/mask-overlay.jsx +32 -0
  115. package/src/Connect/components/refresh-overlay.jsx +52 -0
  116. package/src/Connect/components/switch-app.jsx +69 -0
  117. package/src/Connect/contexts/state.jsx +219 -0
  118. package/src/Connect/fullpage.jsx +3 -0
  119. package/src/Connect/hooks/auth-url.js +31 -0
  120. package/src/Connect/hooks/method-list.js +121 -0
  121. package/src/Connect/hooks/page-show.js +24 -0
  122. package/src/Connect/hooks/security.js +40 -0
  123. package/src/Connect/hooks/token.js +639 -0
  124. package/src/Connect/hooks/use-apps.js +69 -0
  125. package/src/Connect/hooks/use-quick-connect.js +130 -0
  126. package/src/Connect/index.jsx +600 -0
  127. package/src/Connect/landing-page.jsx +3 -0
  128. package/src/Connect/plugins/email/index.jsx +82 -0
  129. package/src/Connect/plugins/email/list-item.jsx +31 -0
  130. package/src/Connect/plugins/email/placeholder.jsx +365 -0
  131. package/src/Connect/plugins/index.js +2 -0
  132. package/src/Connect/use-connect.jsx +321 -0
  133. package/src/Connect/with-blocklet.jsx +26 -0
  134. package/src/Connect/with-bridge-call.jsx +138 -0
  135. package/src/Federated/context.jsx +93 -0
  136. package/src/Federated/index.jsx +1 -0
  137. package/src/Logo/index.jsx +2 -0
  138. package/src/OAuth/context.jsx +346 -0
  139. package/src/OAuth/guest.svg +20 -0
  140. package/src/OAuth/index.jsx +1 -0
  141. package/src/OAuth/passport-switcher.jsx +133 -0
  142. package/src/Passkey/actions.jsx +212 -0
  143. package/src/Passkey/constants.js +2 -0
  144. package/src/Passkey/context.jsx +381 -0
  145. package/src/Passkey/dialog.jsx +391 -0
  146. package/src/Passkey/icon.jsx +10 -0
  147. package/src/Passkey/index.jsx +2 -0
  148. package/src/Service/index.jsx +96 -0
  149. package/src/Session/assets/did-spaces-guide-cover.svg +128 -0
  150. package/src/Session/assets/did-spaces-guide-icon.svg +7 -0
  151. package/src/Session/context.jsx +7 -0
  152. package/src/Session/did-spaces-guide.jsx +173 -0
  153. package/src/Session/hooks/use-federated.js +88 -0
  154. package/src/Session/hooks/use-mobile.jsx +6 -0
  155. package/src/Session/hooks/use-protected-routes.js +16 -0
  156. package/src/Session/hooks/use-session-token.js +365 -0
  157. package/src/Session/hooks/use-verify.jsx +76 -0
  158. package/src/Session/index.jsx +1687 -0
  159. package/src/Session/libs/constants.js +14 -0
  160. package/src/Session/libs/did-spaces.js +38 -0
  161. package/src/Session/libs/federated.js +79 -0
  162. package/src/Session/libs/index.js +5 -0
  163. package/src/Session/libs/locales.js +160 -0
  164. package/src/Session/libs/login-mobile.js +80 -0
  165. package/src/Session/window-focus-aware.jsx +28 -0
  166. package/src/SessionManager/index.jsx +2 -0
  167. package/src/Storage/engine/cookie.js +23 -0
  168. package/src/Storage/engine/local-storage.js +55 -0
  169. package/src/Storage/index.js +25 -0
  170. package/src/User/index.js +4 -0
  171. package/src/User/use-did.js +80 -0
  172. package/src/User/wrap-did.jsx +18 -0
  173. package/src/WebWalletSWKeeper/index.jsx +3 -0
  174. package/src/constant.js +26 -0
  175. package/src/error.js +6 -0
  176. package/src/hooks/use-locale.jsx +6 -0
  177. package/src/index.js +43 -0
  178. package/src/locales/en.jsx +15 -0
  179. package/src/locales/index.jsx +13 -0
  180. package/src/locales/zh.jsx +15 -0
  181. package/src/types.d.ts +355 -0
  182. package/src/utils.js +395 -0
  183. package/vite.config.mjs +29 -0
@@ -0,0 +1,57 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import i from "prop-types";
3
+ import { useTheme as a, Box as r } from "@mui/material";
4
+ import { Icon as c } from "@iconify/react";
5
+ import f from "@iconify-icons/material-symbols/refresh-rounded";
6
+ function l({ onRefresh: n, ...e }) {
7
+ const { palette: t } = a();
8
+ return /* @__PURE__ */ o(
9
+ r,
10
+ {
11
+ ...e,
12
+ onClick: (s) => {
13
+ s.stopPropagation(), n();
14
+ },
15
+ sx: {
16
+ position: "absolute",
17
+ top: 0,
18
+ bottom: 0,
19
+ left: 0,
20
+ right: 0,
21
+ display: "flex",
22
+ justifyContent: "center",
23
+ alignItems: "center",
24
+ backgroundColor: "rgba(255, 255, 255, 0.75)",
25
+ cursor: "pointer",
26
+ ...e.sx
27
+ },
28
+ children: /* @__PURE__ */ o(
29
+ r,
30
+ {
31
+ sx: {
32
+ backgroundColor: "secondary.main",
33
+ borderRadius: "100%",
34
+ fontSize: 0
35
+ },
36
+ children: /* @__PURE__ */ o(
37
+ c,
38
+ {
39
+ icon: f,
40
+ fontSize: 52,
41
+ style: {
42
+ transform: "scale(0.7)",
43
+ color: t.secondary.contrastText
44
+ }
45
+ }
46
+ )
47
+ }
48
+ )
49
+ }
50
+ );
51
+ }
52
+ l.propTypes = {
53
+ onRefresh: i.func.isRequired
54
+ };
55
+ export {
56
+ l as default
57
+ };
@@ -0,0 +1,70 @@
1
+ import { jsxs as u, Fragment as f, jsx as r } from "react/jsx-runtime";
2
+ import { useRef as m } from "react";
3
+ import { Box as x, Menu as l, MenuItem as d } from "@mui/material";
4
+ import { useReactive as h } from "ahooks";
5
+ import { mergeSx as P } from "@arcblock/ux/lib/Util/style";
6
+ import t from "prop-types";
7
+ import { AppInfoItem as A } from "@arcblock/ux/lib/DIDConnect";
8
+ import { useStateContext as y } from "../contexts/state.js";
9
+ function S({ sx: s = {}, children: i }) {
10
+ const { appInfoList: p, extraParams: c, connectState: a } = y(), n = m(null), e = h({
11
+ open: !1
12
+ });
13
+ return p.length <= 1 ? null : /* @__PURE__ */ u(f, { children: [
14
+ /* @__PURE__ */ r(
15
+ x,
16
+ {
17
+ component: "span",
18
+ ref: n,
19
+ sx: P(
20
+ {
21
+ color: "text.secondary",
22
+ cursor: "pointer"
23
+ },
24
+ s
25
+ ),
26
+ onClick: () => {
27
+ e.open = !0;
28
+ },
29
+ children: i
30
+ }
31
+ ),
32
+ /* @__PURE__ */ r(
33
+ l,
34
+ {
35
+ anchorEl: n.current,
36
+ open: e.open,
37
+ onClose: () => {
38
+ e.open = !1;
39
+ },
40
+ slotProps: {
41
+ paper: {
42
+ variant: "outlined",
43
+ sx: {
44
+ border: 0,
45
+ boxShadow: ({ palette: o }) => `0px 4px 8px 0px ${o.grey[100]}, 0px 0px 0px 1px ${o.grey[100]}`,
46
+ borderRadius: 1
47
+ }
48
+ }
49
+ },
50
+ children: p.map((o) => /* @__PURE__ */ r(
51
+ d,
52
+ {
53
+ onClick: () => {
54
+ e.open = !1, a.sourceAppPid = o.sourceAppPid;
55
+ },
56
+ children: /* @__PURE__ */ r(A, { appInfo: o, active: o.sourceAppPid === c?.sourceAppPid })
57
+ },
58
+ o.appPid
59
+ ))
60
+ }
61
+ )
62
+ ] });
63
+ }
64
+ S.propTypes = {
65
+ sx: t.object,
66
+ children: t.any.isRequired
67
+ };
68
+ export {
69
+ S as default
70
+ };
@@ -0,0 +1,142 @@
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import r from "prop-types";
3
+ import { createContext as K, useState as x, use as O, useRef as D, useEffect as Q } from "react";
4
+ import V from "@arcblock/react-hooks/lib/useBrowser";
5
+ import { useUpdate as X, useCreation as s, useMemoizedFn as S, useLatest as Y, useReactive as Z, useSize as _ } from "ahooks";
6
+ import E from "lodash/isUndefined";
7
+ import $ from "lodash/noop";
8
+ import { Box as ee } from "@mui/material";
9
+ import { translate as te } from "@arcblock/ux/lib/Locale/util";
10
+ import { getMaster as R, getCurrentApp as oe } from "@arcblock/ux/lib/Util/federated";
11
+ import { getDIDMotifInfo as re } from "@arcblock/did-motif";
12
+ import { isEthereumDid as ne, getDIDColor as ie } from "@arcblock/ux/lib/Util";
13
+ import se from "../hooks/use-apps.js";
14
+ import { SessionContext as pe } from "../../Session/context.js";
15
+ import ce from "../assets/locale.js";
16
+ const T = K({
17
+ isWalletWebview: !1,
18
+ isMobile: !1,
19
+ matchSmallScreen: !1,
20
+ blocklet: null
21
+ }), { Provider: ue, Consumer: Ie } = T;
22
+ function de({
23
+ children: W,
24
+ blocklet: p,
25
+ masterBlocklet: h = void 0,
26
+ action: d,
27
+ extraParams: t = {},
28
+ locale: a = "en",
29
+ testOnlyBorderColor: f = void 0,
30
+ ...j
31
+ }) {
32
+ const P = X(), [l, q] = x([]), [m, z] = x(""), J = s(() => new Map(l.map((e) => [e.name, e])), [l]), N = S((e) => J.get(e)), U = Y(m), k = S((e, i = {}) => te(ce, e, a, "en", i)), g = O(pe), o = Z({
33
+ sourceAppPid: void 0,
34
+ status: "created",
35
+ autoActiveWebview: !0,
36
+ deeplink: void 0,
37
+ chooseMethod: "",
38
+ retryConnect: $
39
+ }), B = D({
40
+ cancelCount: 0
41
+ }), n = V(), { appInfoList: w, autoGenerateSourceAppPid: A, canSwitchApp: b } = se({
42
+ blocklet: p,
43
+ connectState: o,
44
+ action: d,
45
+ sourceAppPid: t?.sourceAppPid,
46
+ enableSwitchApp: t?.forceSwitch || t?.enableSwitchApp
47
+ }), v = D(null), C = _(v), M = s(() => (C?.width || 0) < 500, [C?.width]), c = s(() => {
48
+ if (b)
49
+ return {
50
+ ...t,
51
+ sourceAppPid: E(o.sourceAppPid) ? A : o.sourceAppPid
52
+ };
53
+ const e = R(p)?.appPid, i = R(globalThis.blocklet)?.appPid;
54
+ return g?.session?.user && (e === i || !e) ? E(t?.sourceAppPid) ? {
55
+ ...t,
56
+ sourceAppPid: g.session.user?.sourceAppPid
57
+ } : t : {
58
+ ...t,
59
+ sourceAppPid: A
60
+ };
61
+ }, [
62
+ b,
63
+ t,
64
+ o.sourceAppPid,
65
+ d,
66
+ A,
67
+ g?.session?.user
68
+ ]), L = s(() => {
69
+ const e = window?.navigator?.userAgent;
70
+ return e.indexOf("Edge") > -1 || e.indexOf("Edg") > -1 ? "edge" : e.indexOf("Chrome") > -1 ? "chrome" : "unknown";
71
+ }, []);
72
+ Q(() => {
73
+ o.sourceAppPid = c.sourceAppPid;
74
+ }, [c.sourceAppPid]);
75
+ const F = S((e) => {
76
+ o.status = e || "created";
77
+ }), u = globalThis.blocklet ? oe(p) : globalThis.env, y = s(() => {
78
+ if (f)
79
+ return f;
80
+ const e = u.appPid, i = ne(e), H = i ? void 0 : re(e);
81
+ return i ? ie(e) : H.color;
82
+ }, [u.appId, f]), G = s(() => ({
83
+ isWalletWebview: n.wallet || n.arcSphere,
84
+ isMobile: n.mobile.any,
85
+ matchSmallScreen: M,
86
+ connectState: o,
87
+ staticState: B,
88
+ reactiveState: o,
89
+ appInfoList: w,
90
+ extraParams: c,
91
+ blocklet: p,
92
+ masterBlocklet: h,
93
+ browserBrand: L,
94
+ currentAppInfo: u,
95
+ currentAppColor: y,
96
+ t: k,
97
+ locale: a,
98
+ action: d,
99
+ changeStatus: F,
100
+ getPlugin: N,
101
+ latestActivePlugin: U,
102
+ plugins: l,
103
+ setPlugins: q,
104
+ selectedPlugin: m,
105
+ setSelectedPlugin: z,
106
+ forceUpdate: P
107
+ }), [
108
+ n.wallet,
109
+ n.arcSphere,
110
+ n.mobile.any,
111
+ M,
112
+ JSON.stringify(o),
113
+ JSON.stringify(w),
114
+ JSON.stringify(c),
115
+ p,
116
+ h,
117
+ a,
118
+ m,
119
+ P,
120
+ u,
121
+ y
122
+ ]);
123
+ return /* @__PURE__ */ I(ue, { value: G, children: /* @__PURE__ */ I(ee, { ...j, ref: v, children: W }) });
124
+ }
125
+ de.propTypes = {
126
+ children: r.any.isRequired,
127
+ blocklet: r.object.isRequired,
128
+ masterBlocklet: r.object,
129
+ action: r.string.isRequired,
130
+ extraParams: r.object,
131
+ locale: r.string,
132
+ testOnlyBorderColor: r.string
133
+ };
134
+ function xe() {
135
+ return O(T);
136
+ }
137
+ export {
138
+ Ie as StateConsumer,
139
+ T as StateContext,
140
+ de as StateProvider,
141
+ xe as useStateContext
142
+ };
@@ -0,0 +1,5 @@
1
+ import "@arcblock/ux/lib/DIDConnect/landing-page";
2
+ import { default as f } from "@arcblock/ux/lib/DIDConnect/landing-page";
3
+ export {
4
+ f as default
5
+ };
@@ -0,0 +1,23 @@
1
+ import { useCreation as p } from "ahooks";
2
+ import { useStateContext as l } from "../contexts/state.js";
3
+ import m from "./security.js";
4
+ import "../../utils.js";
5
+ import { getVisitorId as d } from "@arcblock/ux/lib/Util";
6
+ function A({ disableSwitchApp: c, tokenState: t }) {
7
+ const { appInfoList: o, connectState: s } = l(), { encryptKey: i } = m();
8
+ return p(() => {
9
+ if (!t.url)
10
+ return "";
11
+ const u = !c && o.length > 1, e = new URL(t.url || "https://www.didwallet.io"), a = e.searchParams.get("url");
12
+ if (a && u) {
13
+ const r = new URL(decodeURIComponent(a));
14
+ r.searchParams.set("_ek_", i);
15
+ const n = d();
16
+ n && r.searchParams.set("vid", n), s?.sourceAppPid && r.searchParams.set("spid", s?.sourceAppPid), e.searchParams.set("url", r.toString());
17
+ }
18
+ return e.toString();
19
+ }, [t.url, o.length, s?.sourceAppPid, i]);
20
+ }
21
+ export {
22
+ A as default
23
+ };
@@ -0,0 +1,46 @@
1
+ import { useBrowser as R } from "@arcblock/react-hooks";
2
+ import { detectWalletExtension as v } from "@arcblock/ux/lib/Util";
3
+ import { useRequest as D, useCreation as r } from "ahooks";
4
+ import W from "lodash/intersection";
5
+ import { OAUTH_PROVIDER as x } from "@arcblock/ux/lib/Util/constant";
6
+ import { useOAuth as C } from "../../OAuth/context.js";
7
+ import "../../utils.js";
8
+ import { checkSameProtocol as I, getWebWalletUrl as M } from "@arcblock/ux/lib/Util/wallet";
9
+ function F({
10
+ enabledConnectTypes: o = [],
11
+ allowWallet: n = !0,
12
+ passkeyBehavior: g = "none",
13
+ webWalletUrl: L = M(),
14
+ action: e,
15
+ sourceAppPid: f,
16
+ mode: c = "dialog",
17
+ blocklet: u = globalThis.blocklet,
18
+ isSmallView: d = !1
19
+ }) {
20
+ const s = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], { getOAuthConfigList: w } = C(), i = R(), a = v(), { data: m = [] } = D(
21
+ async () => await w({ sourceAppPid: f }),
22
+ { refreshDeps: [f] }
23
+ ), l = r(() => {
24
+ const t = W(Object.keys(x), o);
25
+ return m.filter((P) => t.includes(P.provider));
26
+ }, [m, o]), O = r(() => s.includes(e) ? l.length > 0 : !1, [l, e]), h = r(() => {
27
+ let t = n;
28
+ return s.includes(e) || (t = !0), t && o.includes("mobile");
29
+ }, [n, o, e]), b = I(L), p = r(() => {
30
+ let t = n;
31
+ return s.includes(e) || (t = !0), t && o.includes("web") && (b || a) && (!i.mobile.any || a);
32
+ }, [n, o, i?.mobile?.any, e]), _ = r(() => g !== "none" && !i.wallet && !i.arcSphere, [e]), A = r(() => !s.includes(e) || !["true", void 0, null].includes(u?.DID_CONNECT_ALLOW_EMAIL) ? !1 : u?.settings?.notification?.email?.enabled ?? !1, [e, u]), E = r(() => !1);
33
+ return {
34
+ hideQRCode: r(() => !!(c === "drawer" || d && i.mobile.any || s.includes(e) && !h), [c, d]),
35
+ hideChooseList: E,
36
+ showOAuthLogin: O,
37
+ showMobileLogin: h,
38
+ showWebLogin: p,
39
+ showPasskeyLogin: _,
40
+ showEmailLogin: A,
41
+ oauthProviderList: l
42
+ };
43
+ }
44
+ export {
45
+ F as default
46
+ };
@@ -0,0 +1,17 @@
1
+ import { useRef as c, useEffect as i } from "react";
2
+ function u(e) {
3
+ const t = c(e);
4
+ i(() => {
5
+ t.current = e;
6
+ }, [e]), i(() => {
7
+ const n = (r) => {
8
+ !document.hidden && t.current && t.current(r);
9
+ };
10
+ return document.addEventListener("visibilitychange", n), () => {
11
+ document.removeEventListener("visibilitychange", n);
12
+ };
13
+ }, []);
14
+ }
15
+ export {
16
+ u as default
17
+ };
@@ -0,0 +1,27 @@
1
+ import l from "tweetnacl";
2
+ import { useLocalStorageState as a } from "ahooks";
3
+ import { useEffect as s } from "react";
4
+ import { encodeKey as t, encrypt as d, decrypt as u } from "../../utils.js";
5
+ const r = l.box.keyPair();
6
+ function z() {
7
+ const [c, i] = a("__encKey", {
8
+ defaultValue: t(r.publicKey),
9
+ deserializer: (e) => e,
10
+ serializer: (e) => e
11
+ }), [o, p] = a("__decKey", {
12
+ defaultValue: t(r.secretKey),
13
+ deserializer: (e) => e,
14
+ serializer: (e) => e
15
+ });
16
+ return s(() => {
17
+ localStorage.getItem("__encKey") || i(t(r.publicKey)), localStorage.getItem("__decKey") || p(t(r.secretKey));
18
+ }, []), {
19
+ encryptKey: c,
20
+ decryptKey: o,
21
+ decrypt: (e, y = c, n = o) => u(e, y, n),
22
+ encrypt: (e, y = c) => d(e, y)
23
+ };
24
+ }
25
+ export {
26
+ z as default
27
+ };