@arcblock/did-connect-react 3.5.2 → 4.0.0-beta.1

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 (171) hide show
  1. package/dist/ConnectContext.d.ts +13 -0
  2. package/dist/ConnectContext.d.ts.map +1 -0
  3. package/dist/ConnectContext.js +14 -0
  4. package/dist/ConnectContext.js.map +1 -0
  5. package/dist/ConnectProvider.d.ts +11 -0
  6. package/dist/ConnectProvider.d.ts.map +1 -0
  7. package/dist/ConnectProvider.js +23 -0
  8. package/dist/ConnectProvider.js.map +1 -0
  9. package/dist/compat/SessionProvider.d.ts +22 -0
  10. package/dist/compat/SessionProvider.d.ts.map +1 -0
  11. package/dist/compat/SessionProvider.js +17 -0
  12. package/dist/compat/SessionProvider.js.map +1 -0
  13. package/dist/compat/index.d.ts +4 -0
  14. package/dist/compat/index.d.ts.map +1 -0
  15. package/dist/compat/index.js +3 -0
  16. package/dist/compat/index.js.map +1 -0
  17. package/dist/compat/useSessionContext.d.ts +14 -0
  18. package/dist/compat/useSessionContext.d.ts.map +1 -0
  19. package/dist/compat/useSessionContext.js +20 -0
  20. package/dist/compat/useSessionContext.js.map +1 -0
  21. package/dist/components/LoginPage.d.ts +15 -0
  22. package/dist/components/LoginPage.d.ts.map +1 -0
  23. package/dist/components/LoginPage.js +33 -0
  24. package/dist/components/LoginPage.js.map +1 -0
  25. package/dist/components/UserAvatar.d.ts +19 -0
  26. package/dist/components/UserAvatar.d.ts.map +1 -0
  27. package/dist/components/UserAvatar.js +45 -0
  28. package/dist/components/UserAvatar.js.map +1 -0
  29. package/dist/hooks/index.d.ts +11 -0
  30. package/dist/hooks/index.d.ts.map +1 -0
  31. package/dist/hooks/index.js +6 -0
  32. package/dist/hooks/index.js.map +1 -0
  33. package/dist/hooks/useConnect.d.ts +15 -0
  34. package/dist/hooks/useConnect.d.ts.map +1 -0
  35. package/dist/hooks/useConnect.js +19 -0
  36. package/dist/hooks/useConnect.js.map +1 -0
  37. package/dist/hooks/useEmail.d.ts +11 -0
  38. package/dist/hooks/useEmail.d.ts.map +1 -0
  39. package/dist/hooks/useEmail.js +47 -0
  40. package/dist/hooks/useEmail.js.map +1 -0
  41. package/dist/hooks/useOAuth.d.ts +12 -0
  42. package/dist/hooks/useOAuth.d.ts.map +1 -0
  43. package/dist/hooks/useOAuth.js +75 -0
  44. package/dist/hooks/useOAuth.js.map +1 -0
  45. package/dist/hooks/usePasskey.d.ts +14 -0
  46. package/dist/hooks/usePasskey.d.ts.map +1 -0
  47. package/dist/hooks/usePasskey.js +35 -0
  48. package/dist/hooks/usePasskey.js.map +1 -0
  49. package/dist/hooks/useSession.d.ts +12 -0
  50. package/dist/hooks/useSession.d.ts.map +1 -0
  51. package/dist/hooks/useSession.js +30 -0
  52. package/dist/hooks/useSession.js.map +1 -0
  53. package/dist/index.d.ts +13 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +11 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/internals/blocklet-config.d.ts +22 -0
  58. package/dist/internals/blocklet-config.d.ts.map +1 -0
  59. package/dist/internals/blocklet-config.js +26 -0
  60. package/dist/internals/blocklet-config.js.map +1 -0
  61. package/dist/internals/local-storage-adapter.d.ts +12 -0
  62. package/dist/internals/local-storage-adapter.d.ts.map +1 -0
  63. package/dist/internals/local-storage-adapter.js +32 -0
  64. package/dist/internals/local-storage-adapter.js.map +1 -0
  65. package/dist/internals/use-sync-state.d.ts +18 -0
  66. package/dist/internals/use-sync-state.d.ts.map +1 -0
  67. package/dist/internals/use-sync-state.js +38 -0
  68. package/dist/internals/use-sync-state.js.map +1 -0
  69. package/package.json +33 -79
  70. package/LICENSE +0 -13
  71. package/README.md +0 -134
  72. package/dist/standalone/did-connect-react.css +0 -1
  73. package/dist/standalone/index.js +0 -136774
  74. package/lib/Address/index.js +0 -4
  75. package/lib/Avatar/index.js +0 -4
  76. package/lib/Button/index.js +0 -17
  77. package/lib/Connect/assets/locale.js +0 -147
  78. package/lib/Connect/assets/login-bg.png +0 -0
  79. package/lib/Connect/assets/login-slogan.js +0 -9
  80. package/lib/Connect/components/action-button.js +0 -26
  81. package/lib/Connect/components/app-tips.js +0 -132
  82. package/lib/Connect/components/auto-height.js +0 -31
  83. package/lib/Connect/components/back-button.js +0 -25
  84. package/lib/Connect/components/connect-status.js +0 -263
  85. package/lib/Connect/components/did-connect-title.js +0 -127
  86. package/lib/Connect/components/download-tips.js +0 -52
  87. package/lib/Connect/components/loading.js +0 -26
  88. package/lib/Connect/components/login-item/connect-choose-list.js +0 -257
  89. package/lib/Connect/components/login-item/connect-provider-list.js +0 -345
  90. package/lib/Connect/components/login-item/login-method-item.js +0 -147
  91. package/lib/Connect/components/login-item/mobile-login-item.js +0 -116
  92. package/lib/Connect/components/login-item/passkey-login-item.js +0 -44
  93. package/lib/Connect/components/login-item/wallet-login-options.js +0 -114
  94. package/lib/Connect/components/login-item/web-login-item.js +0 -104
  95. package/lib/Connect/components/mask-overlay.js +0 -34
  96. package/lib/Connect/components/refresh-overlay.js +0 -57
  97. package/lib/Connect/components/switch-app.js +0 -70
  98. package/lib/Connect/connect.js +0 -505
  99. package/lib/Connect/contexts/state.js +0 -156
  100. package/lib/Connect/fallback-connect.js +0 -53
  101. package/lib/Connect/fullpage.js +0 -5
  102. package/lib/Connect/hooks/auth-url.js +0 -23
  103. package/lib/Connect/hooks/method-list.js +0 -46
  104. package/lib/Connect/hooks/page-show.js +0 -17
  105. package/lib/Connect/hooks/provider-list.js +0 -69
  106. package/lib/Connect/hooks/security.js +0 -27
  107. package/lib/Connect/hooks/token.js +0 -296
  108. package/lib/Connect/hooks/use-apps.js +0 -19
  109. package/lib/Connect/hooks/use-quick-connect.js +0 -86
  110. package/lib/Connect/index.js +0 -16
  111. package/lib/Connect/landing-page.js +0 -5
  112. package/lib/Connect/plugins/email/index.js +0 -65
  113. package/lib/Connect/plugins/email/list-item.js +0 -31
  114. package/lib/Connect/plugins/email/placeholder.js +0 -284
  115. package/lib/Connect/plugins/index.js +0 -4
  116. package/lib/Connect/use-connect.js +0 -164
  117. package/lib/Connect/with-blocklet.js +0 -15
  118. package/lib/Connect/with-bridge-call.js +0 -108
  119. package/lib/Federated/context.js +0 -61
  120. package/lib/Federated/index.js +0 -7
  121. package/lib/Logo/index.js +0 -4
  122. package/lib/OAuth/bind-conflict-alert.js +0 -29
  123. package/lib/OAuth/context.js +0 -277
  124. package/lib/OAuth/guest.svg.js +0 -5
  125. package/lib/OAuth/index.js +0 -7
  126. package/lib/OAuth/passport-switcher.js +0 -5
  127. package/lib/Passkey/actions.js +0 -170
  128. package/lib/Passkey/constants.js +0 -4
  129. package/lib/Passkey/context.js +0 -281
  130. package/lib/Passkey/dialog.js +0 -280
  131. package/lib/Passkey/icon.js +0 -13
  132. package/lib/Passkey/index.js +0 -9
  133. package/lib/Service/index.js +0 -62
  134. package/lib/Session/assets/did-spaces-guide-cover.svg.js +0 -111
  135. package/lib/Session/assets/did-spaces-guide-icon.svg.js +0 -9
  136. package/lib/Session/context.js +0 -5
  137. package/lib/Session/did-spaces-guide.js +0 -136
  138. package/lib/Session/handler.js +0 -55
  139. package/lib/Session/hooks/use-federated.js +0 -64
  140. package/lib/Session/hooks/use-mobile.js +0 -8
  141. package/lib/Session/hooks/use-protected-routes.js +0 -11
  142. package/lib/Session/hooks/use-session-token.js +0 -181
  143. package/lib/Session/hooks/use-verify.js +0 -45
  144. package/lib/Session/index.js +0 -941
  145. package/lib/Session/libs/constants.js +0 -18
  146. package/lib/Session/libs/did-spaces.js +0 -10
  147. package/lib/Session/libs/federated.js +0 -42
  148. package/lib/Session/libs/index.js +0 -15
  149. package/lib/Session/libs/locales.js +0 -161
  150. package/lib/Session/libs/login-mobile.js +0 -55
  151. package/lib/Session/window-focus-aware.js +0 -17
  152. package/lib/SessionManager/index.js +0 -4
  153. package/lib/Storage/engine/cookie.js +0 -22
  154. package/lib/Storage/engine/local-storage.js +0 -37
  155. package/lib/Storage/index.js +0 -23
  156. package/lib/User/index.js +0 -6
  157. package/lib/User/use-did.js +0 -59
  158. package/lib/User/wrap-did.js +0 -13
  159. package/lib/WebWalletSWKeeper/index.js +0 -5
  160. package/lib/components/PassportSwitcher.js +0 -128
  161. package/lib/constant.js +0 -23
  162. package/lib/error.js +0 -8
  163. package/lib/hooks/use-locale.js +0 -7
  164. package/lib/index.js +0 -111
  165. package/lib/locales/en.js +0 -17
  166. package/lib/locales/index.js +0 -10
  167. package/lib/locales/zh.js +0 -17
  168. package/lib/node_modules/@blocklet/js-sdk/dist/index.js +0 -512
  169. package/lib/packages/did-connect/package.json.js +0 -7
  170. package/lib/types.d.ts +0 -355
  171. package/lib/utils.js +0 -225
@@ -1,505 +0,0 @@
1
- import { jsx as t, jsxs as b, Fragment as Ge } from "react/jsx-runtime";
2
- import { use as Ye, useRef as ae, useState as Ke, useEffect as le } from "react";
3
- import e from "prop-types";
4
- import { Box as i, Skeleton as Qe, Divider as Xe } from "@mui/material";
5
- import { useUpdate as Je, useMemoizedFn as S, useSize as Ze, useCreation as d, useMount as ue, useDebounceFn as $e, usePrevious as et, useUpdateEffect as tt } from "ahooks";
6
- import w from "lodash/noop";
7
- import ot from "lodash/isUndefined";
8
- import rt from "@arcblock/ux/lib/CloseButton";
9
- import { WALLET_LOGIN_METHOD as nt, LAST_USED_LOGIN_METHOD as st, DID_CONNECT_MEDIUM_WIDTH as F, LOGIN_PROVIDER_NAME as it, DID_CONNECT_SMALL_WIDTH as ct, OAUTH_PROVIDER as j, LOGIN_PROVIDER as at } from "@arcblock/ux/lib/Util/constant";
10
- import lt from "@arcblock/ux/lib/QRCode";
11
- import { DIDConnectFooter as ut } from "@arcblock/ux/lib/DIDConnect";
12
- import { useTheme as dt } from "@arcblock/ux/lib/Theme";
13
- import ft from "@arcblock/ux/lib/DIDConnect/provider-icon";
14
- import "@fontsource/lexend/400.css";
15
- import "@fontsource/lexend/600.css";
16
- import { SessionContext as mt } from "../Session/context.js";
17
- import { StateProvider as pt, useStateContext as ht } from "./contexts/state.js";
18
- import gt from "./components/login-item/connect-provider-list.js";
19
- import bt from "./components/auto-height.js";
20
- import xt from "./hooks/token.js";
21
- import { useOAuth as Ct } from "../OAuth/context.js";
22
- import St from "./components/connect-status.js";
23
- import { usePasskey as wt } from "../Passkey/context.js";
24
- import { CHECK_STATUS_INTERVAL as yt, API_DID_PREFIX as kt, BUSY_STATUS as I, DEFAULT_TIMEOUT as It } from "../constant.js";
25
- import "../utils.js";
26
- import _t from "./components/did-connect-title.js";
27
- import Tt from "./components/download-tips.js";
28
- import Dt from "./hooks/provider-list.js";
29
- import Ot from "./hooks/auth-url.js";
30
- import { getWalletDid as vt } from "../User/use-did.js";
31
- import Pt from "./fallback-connect.js";
32
- import { getWebWalletUrl as Rt } from "@arcblock/ux/lib/Util/wallet";
33
- function de({
34
- hideCloseButton: y = !1,
35
- mode: h = "dialog",
36
- action: _,
37
- baseUrl: x = "",
38
- checkFn: T,
39
- checkInterval: D = yt,
40
- checkTimeout: O = It * 1e3,
41
- prefix: v = kt,
42
- tokenKey: B = "_t_",
43
- locale: q = "en",
44
- encKey: fe = "_ek_",
45
- autoConnect: me = !0,
46
- forceConnected: H = !0,
47
- saveConnect: pe = !0,
48
- useSocket: he = !0,
49
- allowWallet: V = !0,
50
- provider: ge = "",
51
- messages: f = {},
52
- passkeyBehavior: G = "none",
53
- webWalletUrl: be = Rt(),
54
- enabledConnectTypes: xe = ["web", "mobile", ...Object.keys(j)],
55
- extraContent: Y = null,
56
- disableSwitchApp: P = !1,
57
- magicToken: K = void 0,
58
- customItems: Ce = [],
59
- onClose: R = w,
60
- onError: Q = w,
61
- onSuccess: A = w,
62
- onRecreateSession: Se = w,
63
- setColor: we = w
64
- }) {
65
- const W = dt(), X = Je(), ye = Ye(mt), ke = vt(ye?.session?.user), {
66
- t: J,
67
- staticState: Ie,
68
- connectState: n,
69
- extraParams: _e,
70
- currentAppInfo: Te,
71
- currentAppColor: E,
72
- // 插件相关
73
- selectedPlugin: c,
74
- blocklet: Z,
75
- masterBlocklet: De,
76
- showWalletOptions: m,
77
- setShowWalletOptions: Oe,
78
- lastLoginMethod: ve
79
- } = ht(), Pe = S((...g) => {
80
- const u = n.walletMethod || nt.SCAN;
81
- return localStorage.setItem(st, u), A(...g);
82
- }), { state: o, generate: $, cancelWhenScanned: Re } = xt({
83
- action: _,
84
- baseUrl: x,
85
- checkFn: T,
86
- checkInterval: D,
87
- checkTimeout: O,
88
- extraParams: _e,
89
- prefix: v,
90
- onError: Q,
91
- onSuccess: Pe,
92
- locale: q,
93
- tokenKey: B,
94
- encKey: fe,
95
- autoConnect: me,
96
- forceConnected: H === !0 ? ke || !0 : H,
97
- saveConnect: pe,
98
- useSocket: he,
99
- provider: ge
100
- }), L = ae(!1), ee = ae(null), C = Ze(ee), te = d(() => C ? C.width < F - 50 : !0, [C, C?.width]), [oe, Ae] = Ke(!1);
101
- ue(() => {
102
- Ae(C?.width < F - 50);
103
- });
104
- const { oauthState: a, setBaseUrl: We } = Ct(), { passkeyState: l, setTargetAppPid: Ee } = wt();
105
- ue(() => {
106
- We(x), Ee(Z?.appPid), o.reset(), a.reset(), l.reset();
107
- }), le(() => {
108
- we(E);
109
- }, [E]);
110
- const Le = d(() => ({
111
- confirm: f.confirm,
112
- success: f.success,
113
- error: c?.state?.error || o.error || l.error || a.error || ""
114
- }), [
115
- f.confirm,
116
- f.success,
117
- o.error,
118
- a.error,
119
- l.error,
120
- c?.state?.error
121
- ]), k = d(() => I.includes(l.status) || I.includes(a.status) || I.includes(o.status) || I.includes(c?.state?.computedStatus), [o.status, a.status, l.status, c?.state?.computedStatus]), re = S(() => {
122
- n.chooseMethod = "wallet", n.walletMethod = "", Se();
123
- }), ne = S(async () => {
124
- re(), a.reset(), l.reset(), await $(!1);
125
- }), Me = S(() => {
126
- n?.retryConnect();
127
- }), ze = S(() => {
128
- re(), a.reset(), l.reset(), c?.state?.reset(), Ie.current.cancelCount++, Re();
129
- }), { run: Ne } = $e(
130
- () => {
131
- L.current || o.status === "timeout" && (L.current = !0, o.reset(), ne(), L.current = !1);
132
- },
133
- { leading: !0, trailing: !1 }
134
- );
135
- le(Ne, [o.status]);
136
- const Ue = d(() => it[n.chooseMethod] || "DID Wallet", [n.chooseMethod]), { providerList: Fe, hideQRCode: p, hideChooseList: r, loadingProviderList: je } = Dt({
137
- action: o.action,
138
- sourceAppPid: n?.sourceAppPid,
139
- allowWallet: V,
140
- passkeyBehavior: G,
141
- mode: h,
142
- blocklet: n?.sourceAppPid ? De : Z,
143
- isSmallView: te,
144
- lastLoginMethod: ve
145
- }), Be = et(n?.sourceAppPid);
146
- tt(() => {
147
- ot(Be) || $();
148
- }, [n?.sourceAppPid]);
149
- const s = (g) => {
150
- const u = W.spacing(g);
151
- return parseInt(u, 10);
152
- }, qe = d(() => y ? null : /* @__PURE__ */ t(
153
- rt,
154
- {
155
- onClose: R,
156
- sx: {
157
- position: "absolute",
158
- right: 14,
159
- top: 14
160
- }
161
- }
162
- ), [y, R]), He = /* @__PURE__ */ t(
163
- i,
164
- {
165
- sx: {
166
- flex: 1,
167
- display: k ? "flex" : "none",
168
- alignItems: "center",
169
- justifyContent: "center"
170
- },
171
- children: /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
172
- St,
173
- {
174
- status: c?.state?.computedStatus || a.status || l.status || o.status,
175
- nextWorkflow: o.nextWorkflow,
176
- mfaCode: o.mfaCode,
177
- onCancel: ze,
178
- onRetry: Me,
179
- onClose: R,
180
- messages: Le,
181
- locale: q,
182
- className: "did-connect__auth-status auth-status",
183
- loadingIcon: n.chooseMethod ? /* @__PURE__ */ t(ft, { provider: n.chooseMethod, sx: { color: "text.primary" } }) : null,
184
- chooseMethod: Ue,
185
- hideRetry: n.chooseMethod === "email",
186
- hideBack: !!K
187
- }
188
- ) })
189
- }
190
- ), se = Ot({ disableSwitchApp: P, tokenState: o }), M = d(() => {
191
- const g = W.mode === "dark" ? W.palette.grey[600] : "white";
192
- let u = r ? 240 - s(3) * 2 : 196 - s(2) * 2, U = r ? 3 : 2;
193
- return m && (U = 1, u += s(U) * 2), /* @__PURE__ */ t(
194
- i,
195
- {
196
- className: "did-connect__qrcode",
197
- sx: {
198
- p: U,
199
- width: (r ? 240 : 196) + s(1) * 2,
200
- height: (r ? 240 : 196) + s(1) * 2
201
- },
202
- children: o.url ? /* @__PURE__ */ t(
203
- lt,
204
- {
205
- data: se,
206
- size: u,
207
- sx: {
208
- width: u + s(1) * 2,
209
- height: u + s(1) * 2,
210
- flex: 1,
211
- backgroundColor: g,
212
- p: 1,
213
- fontSize: 0,
214
- textAlign: "center",
215
- boxSizing: "border-box",
216
- borderRadius: 1,
217
- border: "1px solid",
218
- borderColor: "divider"
219
- },
220
- config: {
221
- backgroundOptions: {
222
- color: g
223
- }
224
- }
225
- }
226
- ) : /* @__PURE__ */ t(
227
- Qe,
228
- {
229
- animation: "wave",
230
- variant: "rectangular",
231
- sx: {
232
- position: "absolute",
233
- left: s(2) + 1,
234
- right: s(2) + 1,
235
- top: s(2) + 1,
236
- bottom: s(2) + 1,
237
- borderRadius: 1,
238
- zIndex: 1,
239
- width: "auto",
240
- height: "auto"
241
- }
242
- }
243
- )
244
- }
245
- );
246
- }, [se, r, m]), Ve = d(() => r ? "column-reverse" : !p && oe ? "column" : "row", [r, oe, p]), ie = d(() => M ? /* @__PURE__ */ t(
247
- i,
248
- {
249
- sx: {
250
- display: "flex",
251
- alignItems: "center",
252
- overflowX: "auto",
253
- overflowY: "visible",
254
- maxWidth: "100%",
255
- margin: "auto"
256
- },
257
- children: /* @__PURE__ */ b(
258
- i,
259
- {
260
- sx: {
261
- fontSize: 0,
262
- position: "relative",
263
- ...m ? {
264
- mt: r ? 4 : 2.5,
265
- mb: 0
266
- } : {
267
- mb: r ? 4 : 2.5,
268
- mt: 0
269
- }
270
- },
271
- children: [
272
- M,
273
- /* @__PURE__ */ b(
274
- i,
275
- {
276
- sx: {
277
- position: "absolute",
278
- color: "text.secondary",
279
- fontSize: 12,
280
- zIndex: 1,
281
- whiteSpace: "nowrap",
282
- ...m ? {
283
- top: r ? -8 : -4,
284
- transform: "translateY(-100%)"
285
- } : {
286
- bottom: r ? -8 : -4,
287
- transform: "translateY(100%)"
288
- },
289
- left: 0,
290
- right: 0,
291
- textAlign: "center"
292
- },
293
- children: [
294
- J("scanWithWallet1"),
295
- " ",
296
- /* @__PURE__ */ t(Tt, {}),
297
- " ",
298
- J("scanWithWallet2")
299
- ]
300
- }
301
- )
302
- ]
303
- }
304
- )
305
- }
306
- ) : null, [M, r, m]), z = /* @__PURE__ */ b(
307
- i,
308
- {
309
- className: "did-connect__body",
310
- sx: {
311
- display: "flex",
312
- flexDirection: Ve,
313
- justifyContent: "center",
314
- alignItems: "stretch",
315
- flex: 1,
316
- gap: !p && te ? 0 : 1.5,
317
- overflow: "visible",
318
- px: r ? 2 : 0
319
- },
320
- children: [
321
- !k && !p ? /* @__PURE__ */ b(Ge, { children: [
322
- ie,
323
- r ? null : /* @__PURE__ */ t(i, { children: /* @__PURE__ */ t(
324
- Xe,
325
- {
326
- orientation: "vertical",
327
- sx: {
328
- fontSize: 12,
329
- color: "text.hint",
330
- "&::before, &::after": {
331
- borderColor: "divider"
332
- }
333
- },
334
- children: "or"
335
- }
336
- ) })
337
- ] }) : null,
338
- /* @__PURE__ */ b(
339
- i,
340
- {
341
- sx: {
342
- display: "flex",
343
- flex: 1
344
- },
345
- children: [
346
- He,
347
- /* @__PURE__ */ t(
348
- gt,
349
- {
350
- slotProps: {
351
- root: {
352
- sx: [k ? { display: "none" } : {}]
353
- }
354
- },
355
- allowWallet: V,
356
- size: p && h !== "dialog" ? "normal" : "small",
357
- tokenState: o,
358
- hideQRCode: p,
359
- messages: f,
360
- tokenKey: B,
361
- onSuccess: A,
362
- passkeyBehavior: G,
363
- webWalletUrl: be,
364
- extraContent: Y,
365
- enabledConnectTypes: xe,
366
- onReset: ne,
367
- disableSwitchApp: P,
368
- forceUpdate: X,
369
- magicToken: K,
370
- baseUrl: x,
371
- customItems: Ce,
372
- providerList: Fe,
373
- qrcode: ie
374
- }
375
- )
376
- ]
377
- }
378
- )
379
- ]
380
- }
381
- );
382
- let N = z;
383
- c ? N = c.renderPlaceholder({
384
- fallback: z,
385
- forceUpdate: X,
386
- onSuccess: A,
387
- onError: Q
388
- }) : N = z;
389
- const ce = p || k ? ct : F;
390
- return je ? /* @__PURE__ */ t(Pt, {}) : /* @__PURE__ */ b(
391
- i,
392
- {
393
- ref: ee,
394
- className: "did-connect__root",
395
- sx: {
396
- backgroundColor: "background.default",
397
- display: "flex",
398
- flexDirection: "column",
399
- height: "100%",
400
- position: "relative",
401
- maxWidth: "100%",
402
- width: (
403
- // eslint-disable-next-line no-nested-ternary
404
- h === "drawer" ? "100%" : m ? ce - 20 : ce
405
- ),
406
- transition: "width 0.2s ease-in-out",
407
- margin: "auto",
408
- p: 3,
409
- pb: 0,
410
- gap: 2.5
411
- },
412
- children: [
413
- /* @__PURE__ */ t(i, { "data-did-auth-url": o.url, sx: { display: "none" } }),
414
- /* @__PURE__ */ t(
415
- _t,
416
- {
417
- title: f.title,
418
- description: f.scan,
419
- extraContent: Y,
420
- disableSwitchApp: P,
421
- showWalletOptions: m,
422
- onBack: () => Oe(!1)
423
- }
424
- ),
425
- /* @__PURE__ */ t(bt, { initHeight: 72, children: N }),
426
- /* @__PURE__ */ t(ut, { currentAppInfo: Te, currentAppColor: E }),
427
- qe
428
- ]
429
- }
430
- );
431
- }
432
- de.propTypes = {
433
- mode: e.oneOf(["dialog", "drawer", "page"]),
434
- action: e.string.isRequired,
435
- baseUrl: e.string,
436
- checkFn: e.func.isRequired,
437
- checkInterval: e.number,
438
- checkTimeout: e.number,
439
- // extraParams: PropTypes.object, // 需要使用 useStateContext 中导出的
440
- prefix: e.string,
441
- messages: e.object,
442
- tokenKey: e.string,
443
- locale: e.oneOf(["en", "zh", ""]),
444
- encKey: e.string,
445
- autoConnect: e.bool,
446
- forceConnected: e.oneOfType([e.bool, e.string]),
447
- saveConnect: e.bool,
448
- useSocket: e.bool,
449
- extraContent: e.any,
450
- passkeyBehavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
451
- enabledConnectTypes: e.arrayOf(e.oneOf(["web", "mobile", ...Object.keys(j)])),
452
- webWalletUrl: e.string,
453
- allowWallet: e.bool,
454
- provider: e.oneOf([at.WALLET, ...Object.keys(j), ""]),
455
- hideCloseButton: e.bool,
456
- disableSwitchApp: e.bool,
457
- onClose: e.func,
458
- onError: e.func,
459
- onSuccess: e.func,
460
- onRecreateSession: e.func,
461
- setColor: e.func,
462
- magicToken: e.string,
463
- customItems: e.arrayOf(e.node)
464
- };
465
- function At({ testOnlyBorderColor: y = void 0, ...h }) {
466
- const { checkFn: _, extraParams: x = {}, blocklet: T, masterBlocklet: D, action: O, locale: v = "en" } = h;
467
- if (typeof _ != "function")
468
- throw new Error("Cannot initialize did connect component without a fetchFn");
469
- return /* @__PURE__ */ t(
470
- pt,
471
- {
472
- blocklet: T,
473
- masterBlocklet: D,
474
- action: O,
475
- locale: v,
476
- extraParams: x,
477
- testOnlyBorderColor: y,
478
- sx: {
479
- position: "relative",
480
- width: "100%",
481
- height: "100%",
482
- lineHeight: 1.2,
483
- color: "grey.700",
484
- "&, & *, & *:before, & *:after": {
485
- fontFamily: "Lexend",
486
- // 保持跟 DID Wallet 一致
487
- boxSizing: "border-box"
488
- }
489
- },
490
- children: /* @__PURE__ */ t(de, { ...h })
491
- }
492
- );
493
- }
494
- At.propTypes = {
495
- checkFn: e.func.isRequired,
496
- extraParams: e.object,
497
- blocklet: e.object.isRequired,
498
- masterBlocklet: e.object,
499
- action: e.string.isRequired,
500
- locale: e.string,
501
- testOnlyBorderColor: e.string
502
- };
503
- export {
504
- At as default
505
- };
@@ -1,156 +0,0 @@
1
- import { jsx as O } from "react/jsx-runtime";
2
- import r from "prop-types";
3
- import { useState as h, use as W, useRef as D, useEffect as V, createContext as X } from "react";
4
- import Y from "@arcblock/react-hooks/lib/useBrowser";
5
- import { useUpdate as Z, useCreation as n, useMemoizedFn as A, useLatest as $, useReactive as ee, useSize as te } from "ahooks";
6
- import E from "lodash/isUndefined";
7
- import oe from "lodash/noop";
8
- import { Box as re } from "@mui/material";
9
- import { translate as ne } from "@arcblock/ux/lib/Locale/util";
10
- import { getMaster as T, getCurrentApp as se } from "@arcblock/ux/lib/Util/federated";
11
- import { getDIDMotifInfo as ie } from "@arcblock/did-motif";
12
- import { isEthereumDid as ce, getDIDColor as pe } from "@arcblock/ux/lib/Util";
13
- import { LAST_USED_LOGIN_METHOD as ue } from "@arcblock/ux/lib/Util/constant";
14
- import ae from "../hooks/use-apps.js";
15
- import { SessionContext as de } from "../../Session/context.js";
16
- import le from "../assets/locale.js";
17
- const x = X({
18
- isWalletWebview: !1,
19
- isMobile: !1,
20
- matchSmallScreen: !1,
21
- blocklet: null
22
- }), { Provider: fe, Consumer: We } = x;
23
- function me({
24
- children: R,
25
- blocklet: c,
26
- masterBlocklet: P = void 0,
27
- action: a,
28
- extraParams: t = {},
29
- locale: d = "en",
30
- testOnlyBorderColor: l = void 0,
31
- ...L
32
- }) {
33
- const w = Z(), [f, j] = h([]), [N, U] = h(!1), [m, q] = h(""), z = n(() => new Map(f.map((e) => [e.name, e])), [f]), J = A((e) => z.get(e)), _ = $(m), k = A((e, i = {}) => ne(le, e, d, "en", i)), g = W(de), o = ee({
34
- sourceAppPid: void 0,
35
- status: "created",
36
- autoActiveWebview: !0,
37
- deeplink: void 0,
38
- chooseMethod: "",
39
- walletMethod: "",
40
- // 细分的 wallet 登录方式,如 wallet-ext, wallet-web, wallet-scan 等
41
- retryConnect: oe
42
- }), B = D({
43
- cancelCount: 0
44
- }), s = Y(), { appInfoList: b, autoGenerateSourceAppPid: S, canSwitchApp: v } = ae({
45
- blocklet: c,
46
- connectState: o,
47
- action: a,
48
- sourceAppPid: t?.sourceAppPid,
49
- enableSwitchApp: t?.forceSwitch || t?.enableSwitchApp
50
- }), G = n(() => {
51
- try {
52
- return localStorage.getItem(ue);
53
- } catch {
54
- return "";
55
- }
56
- }, []), C = D(null), M = te(C), y = n(() => (M?.width || 0) < 500, [M?.width]), p = n(() => {
57
- if (v)
58
- return {
59
- ...t,
60
- sourceAppPid: E(o.sourceAppPid) ? S : o.sourceAppPid
61
- };
62
- const e = T(c)?.appPid, i = T(globalThis.blocklet)?.appPid;
63
- return g?.session?.user && (e === i || !e) ? E(t?.sourceAppPid) ? {
64
- ...t,
65
- sourceAppPid: g.session.user?.sourceAppPid
66
- } : t : {
67
- ...t,
68
- sourceAppPid: S
69
- };
70
- }, [
71
- v,
72
- t,
73
- o.sourceAppPid,
74
- a,
75
- S,
76
- g?.session?.user
77
- ]), F = n(() => {
78
- const e = window?.navigator?.userAgent;
79
- return e.indexOf("Edge") > -1 || e.indexOf("Edg") > -1 ? "edge" : e.indexOf("Chrome") > -1 ? "chrome" : "unknown";
80
- }, []);
81
- V(() => {
82
- o.sourceAppPid = p.sourceAppPid;
83
- }, [p.sourceAppPid]);
84
- const H = A((e) => {
85
- o.status = e || "created";
86
- }), u = globalThis.blocklet ? se(c) : globalThis.env, I = n(() => {
87
- if (l)
88
- return l;
89
- const e = u.appPid, i = ce(e), Q = i ? void 0 : ie(e);
90
- return i ? pe(e) : Q.color;
91
- }, [u.appId, l]), K = n(() => ({
92
- isWalletWebview: s.wallet || s.arcSphere,
93
- isMobile: s.mobile.any,
94
- matchSmallScreen: y,
95
- connectState: o,
96
- staticState: B,
97
- reactiveState: o,
98
- appInfoList: b,
99
- extraParams: p,
100
- blocklet: c,
101
- masterBlocklet: P,
102
- browserBrand: F,
103
- currentAppInfo: u,
104
- currentAppColor: I,
105
- t: k,
106
- locale: d,
107
- action: a,
108
- changeStatus: H,
109
- getPlugin: J,
110
- latestActivePlugin: _,
111
- plugins: f,
112
- setPlugins: j,
113
- selectedPlugin: m,
114
- setSelectedPlugin: q,
115
- forceUpdate: w,
116
- // 控制钱包登录的显示
117
- showWalletOptions: N,
118
- setShowWalletOptions: U,
119
- // 用于记录上一次登录方式
120
- lastLoginMethod: G
121
- }), [
122
- s.wallet,
123
- s.arcSphere,
124
- s.mobile.any,
125
- y,
126
- JSON.stringify(o),
127
- JSON.stringify(b),
128
- JSON.stringify(p),
129
- c,
130
- P,
131
- d,
132
- m,
133
- w,
134
- u,
135
- I
136
- ]);
137
- return /* @__PURE__ */ O(fe, { value: K, children: /* @__PURE__ */ O(re, { ...L, ref: C, children: R }) });
138
- }
139
- me.propTypes = {
140
- children: r.any.isRequired,
141
- blocklet: r.object.isRequired,
142
- masterBlocklet: r.object,
143
- action: r.string.isRequired,
144
- extraParams: r.object,
145
- locale: r.string,
146
- testOnlyBorderColor: r.string
147
- };
148
- function xe() {
149
- return W(x);
150
- }
151
- export {
152
- We as StateConsumer,
153
- x as StateContext,
154
- me as StateProvider,
155
- xe as useStateContext
156
- };
@@ -1,53 +0,0 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { DIDConnectFooter as a } from "@arcblock/ux/lib/DIDConnect";
3
- import { DID_CONNECT_SMALL_WIDTH as l } from "@arcblock/ux/lib/Util/constant";
4
- import { getCurrentApp as x } from "@arcblock/ux/lib/Util/federated";
5
- import { Box as o, Skeleton as i } from "@mui/material";
6
- function f(r) {
7
- const n = globalThis.blocklet ? x(globalThis.blocklet) : globalThis.env;
8
- return /* @__PURE__ */ t(
9
- o,
10
- {
11
- className: "did-connect__root",
12
- sx: {
13
- backgroundColor: "background.default",
14
- display: "flex",
15
- flexDirection: "column",
16
- height: "100%",
17
- position: "relative",
18
- maxWidth: "100%",
19
- // eslint-disable-next-line react/prop-types
20
- width: r.mode === "drawer" ? "100%" : l - 20,
21
- transition: "width 0.2s ease-in-out",
22
- margin: "auto",
23
- p: 3,
24
- pb: 0,
25
- gap: 2.5
26
- },
27
- children: [
28
- /* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
29
- /* @__PURE__ */ e(i, { variant: "rounded", height: 28, sx: { width: "6rem" } }),
30
- /* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
31
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { fontSize: "13px", height: "15px" } }),
32
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { fontSize: "13px", height: "15px", width: "3rem" } })
33
- ] })
34
- ] }),
35
- /* @__PURE__ */ t(o, { sx: { display: "flex", flexDirection: "column", gap: 1.5 }, children: [
36
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
37
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
38
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { height: "35px" } }),
39
- /* @__PURE__ */ t(o, { sx: { display: "flex", gap: 1.5, mt: 1 }, children: [
40
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
41
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
42
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } }),
43
- /* @__PURE__ */ e(i, { variant: "rounded", sx: { flex: 1, height: "32px" } })
44
- ] })
45
- ] }),
46
- /* @__PURE__ */ e(a, { currentAppInfo: n })
47
- ]
48
- }
49
- );
50
- }
51
- export {
52
- f as default
53
- };