@arcblock/did-connect-react 3.4.14 → 3.5.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.
- package/dist/standalone/did-connect-react.css +1 -0
- package/dist/standalone/index.js +133700 -0
- package/lib/Connect/components/login-item/connect-choose-list.js +111 -111
- package/lib/Connect/components/login-item/connect-provider-list.js +180 -180
- package/lib/Connect/components/login-item/mobile-login-item.js +56 -56
- package/lib/Connect/components/login-item/passkey-login-item.js +27 -29
- package/lib/Connect/components/login-item/web-login-item.js +31 -29
- package/lib/Connect/connect.js +202 -197
- package/lib/Connect/contexts/state.js +19 -17
- package/lib/Connect/hooks/provider-list.js +33 -33
- package/lib/Connect/plugins/email/list-item.js +14 -14
- package/lib/Connect/plugins/email/placeholder.js +77 -76
- package/lib/package.json.js +1 -1
- package/package.json +14 -9
- package/.aigne/doc-smith/config.yaml +0 -85
- package/.aigne/doc-smith/history.yaml +0 -6
- package/.aigne/doc-smith/output/structure-plan.json +0 -204
- package/.aigne/doc-smith/translation-cache.yaml +0 -11
- package/.aigne/doc-smith/upload-cache.yaml +0 -213
- package/docs/_sidebar.md +0 -18
- package/docs/advanced-authentication-methods.ja.md +0 -261
- package/docs/advanced-authentication-methods.md +0 -261
- package/docs/advanced-authentication-methods.zh-TW.md +0 -261
- package/docs/advanced-authentication-methods.zh.md +0 -261
- package/docs/advanced-utilities.ja.md +0 -132
- package/docs/advanced-utilities.md +0 -132
- package/docs/advanced-utilities.zh-TW.md +0 -132
- package/docs/advanced-utilities.zh.md +0 -132
- package/docs/advanced.ja.md +0 -95
- package/docs/advanced.md +0 -95
- package/docs/advanced.zh-TW.md +0 -95
- package/docs/advanced.zh.md +0 -95
- package/docs/api-reference.ja.md +0 -178
- package/docs/api-reference.md +0 -178
- package/docs/api-reference.zh-TW.md +0 -178
- package/docs/api-reference.zh.md +0 -178
- package/docs/assets/diagram/core-components-session-provider-01.ja.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/core-components-session-provider-01.zh.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/did-connect-diagram-0.zh.jpg +0 -0
- package/docs/assets/diagram/overview-01.ja.jpg +0 -0
- package/docs/assets/diagram/overview-01.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh-TW.jpg +0 -0
- package/docs/assets/diagram/overview-01.zh.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.ja.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh-TW.jpg +0 -0
- package/docs/assets/diagram/use-connect-diagram-0.zh.jpg +0 -0
- package/docs/core-components-did-connect.ja.md +0 -166
- package/docs/core-components-did-connect.md +0 -166
- package/docs/core-components-did-connect.zh-TW.md +0 -166
- package/docs/core-components-did-connect.zh.md +0 -166
- package/docs/core-components-session-provider.ja.md +0 -197
- package/docs/core-components-session-provider.md +0 -197
- package/docs/core-components-session-provider.zh-TW.md +0 -197
- package/docs/core-components-session-provider.zh.md +0 -197
- package/docs/core-components.ja.md +0 -16
- package/docs/core-components.md +0 -16
- package/docs/core-components.zh-TW.md +0 -16
- package/docs/core-components.zh.md +0 -16
- package/docs/getting-started.ja.md +0 -138
- package/docs/getting-started.md +0 -138
- package/docs/getting-started.zh-TW.md +0 -138
- package/docs/getting-started.zh.md +0 -138
- package/docs/hooks-use-connect.ja.md +0 -178
- package/docs/hooks-use-connect.md +0 -178
- package/docs/hooks-use-connect.zh-TW.md +0 -178
- package/docs/hooks-use-connect.zh.md +0 -178
- package/docs/hooks-use-did.ja.md +0 -107
- package/docs/hooks-use-did.md +0 -107
- package/docs/hooks-use-did.zh-TW.md +0 -107
- package/docs/hooks-use-did.zh.md +0 -107
- package/docs/hooks-use-oauth-passkey.ja.md +0 -188
- package/docs/hooks-use-oauth-passkey.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh-TW.md +0 -188
- package/docs/hooks-use-oauth-passkey.zh.md +0 -188
- package/docs/hooks.ja.md +0 -23
- package/docs/hooks.md +0 -23
- package/docs/hooks.zh-TW.md +0 -23
- package/docs/hooks.zh.md +0 -23
- package/docs/overview.ja.md +0 -119
- package/docs/overview.md +0 -119
- package/docs/overview.zh-TW.md +0 -119
- package/docs/overview.zh.md +0 -119
- package/docs/ui-components-address.ja.md +0 -121
- package/docs/ui-components-address.md +0 -121
- package/docs/ui-components-address.zh-TW.md +0 -121
- package/docs/ui-components-address.zh.md +0 -121
- package/docs/ui-components-avatar.ja.md +0 -65
- package/docs/ui-components-avatar.md +0 -65
- package/docs/ui-components-avatar.zh-TW.md +0 -65
- package/docs/ui-components-avatar.zh.md +0 -65
- package/docs/ui-components-button.ja.md +0 -99
- package/docs/ui-components-button.md +0 -99
- package/docs/ui-components-button.zh-TW.md +0 -99
- package/docs/ui-components-button.zh.md +0 -99
- package/docs/ui-components-logo.ja.md +0 -52
- package/docs/ui-components-logo.md +0 -52
- package/docs/ui-components-logo.zh-TW.md +0 -52
- package/docs/ui-components-logo.zh.md +0 -52
- package/docs/ui-components.ja.md +0 -57
- package/docs/ui-components.md +0 -57
- package/docs/ui-components.zh-TW.md +0 -57
- package/docs/ui-components.zh.md +0 -57
- package/glossary.md +0 -1
- package/src/Address/index.jsx +0 -2
- package/src/Avatar/index.jsx +0 -2
- package/src/Button/Button.stories.jsx +0 -7
- package/src/Button/index.jsx +0 -21
- package/src/Connect/Connect.stories.jsx +0 -34
- package/src/Connect/assets/locale.js +0 -149
- package/src/Connect/assets/login-bg.png +0 -0
- package/src/Connect/assets/login-slogan.js +0 -7
- package/src/Connect/components/action-button.jsx +0 -22
- package/src/Connect/components/app-tips.jsx +0 -156
- package/src/Connect/components/auto-height.jsx +0 -38
- package/src/Connect/components/back-button.jsx +0 -24
- package/src/Connect/components/connect-status.jsx +0 -259
- package/src/Connect/components/did-connect-title.jsx +0 -107
- package/src/Connect/components/download-tips.jsx +0 -55
- package/src/Connect/components/loading.jsx +0 -25
- package/src/Connect/components/login-item/connect-choose-list.jsx +0 -317
- package/src/Connect/components/login-item/connect-provider-list.jsx +0 -462
- package/src/Connect/components/login-item/login-method-item.jsx +0 -139
- package/src/Connect/components/login-item/mobile-login-item.jsx +0 -181
- package/src/Connect/components/login-item/passkey-login-item.jsx +0 -54
- package/src/Connect/components/login-item/wallet-login-options.jsx +0 -129
- package/src/Connect/components/login-item/web-login-item.jsx +0 -157
- package/src/Connect/components/mask-overlay.jsx +0 -32
- package/src/Connect/components/refresh-overlay.jsx +0 -52
- package/src/Connect/components/switch-app.jsx +0 -69
- package/src/Connect/connect.jsx +0 -617
- package/src/Connect/contexts/state.jsx +0 -234
- package/src/Connect/fallback-connect.jsx +0 -47
- package/src/Connect/fullpage.jsx +0 -3
- package/src/Connect/hooks/auth-url.js +0 -31
- package/src/Connect/hooks/method-list.js +0 -121
- package/src/Connect/hooks/page-show.js +0 -24
- package/src/Connect/hooks/provider-list.js +0 -165
- package/src/Connect/hooks/security.js +0 -40
- package/src/Connect/hooks/token.js +0 -627
- package/src/Connect/hooks/use-apps.js +0 -69
- package/src/Connect/hooks/use-quick-connect.js +0 -119
- package/src/Connect/index.jsx +0 -21
- package/src/Connect/landing-page.jsx +0 -3
- package/src/Connect/plugins/email/index.jsx +0 -85
- package/src/Connect/plugins/email/list-item.jsx +0 -34
- package/src/Connect/plugins/email/placeholder.jsx +0 -365
- package/src/Connect/plugins/index.js +0 -2
- package/src/Connect/use-connect.jsx +0 -321
- package/src/Connect/with-blocklet.jsx +0 -26
- package/src/Connect/with-bridge-call.jsx +0 -138
- package/src/Federated/context.jsx +0 -93
- package/src/Federated/index.jsx +0 -1
- package/src/Logo/index.jsx +0 -2
- package/src/OAuth/bind-conflict-alert.jsx +0 -37
- package/src/OAuth/context.jsx +0 -407
- package/src/OAuth/guest.svg +0 -20
- package/src/OAuth/index.jsx +0 -1
- package/src/OAuth/passport-switcher.jsx +0 -2
- package/src/Passkey/actions.jsx +0 -217
- package/src/Passkey/constants.js +0 -2
- package/src/Passkey/context.jsx +0 -395
- package/src/Passkey/dialog.jsx +0 -401
- package/src/Passkey/icon.jsx +0 -10
- package/src/Passkey/index.jsx +0 -2
- package/src/Service/index.jsx +0 -96
- package/src/Session/assets/did-spaces-guide-cover.svg +0 -1
- package/src/Session/assets/did-spaces-guide-icon.svg +0 -7
- package/src/Session/context.jsx +0 -7
- package/src/Session/did-spaces-guide.jsx +0 -173
- package/src/Session/handler.jsx +0 -98
- package/src/Session/hooks/use-federated.js +0 -91
- package/src/Session/hooks/use-mobile.jsx +0 -6
- package/src/Session/hooks/use-protected-routes.js +0 -16
- package/src/Session/hooks/use-session-token.js +0 -400
- package/src/Session/hooks/use-verify.jsx +0 -76
- package/src/Session/index.jsx +0 -1789
- package/src/Session/libs/constants.js +0 -17
- package/src/Session/libs/did-spaces.js +0 -38
- package/src/Session/libs/federated.js +0 -82
- package/src/Session/libs/index.js +0 -5
- package/src/Session/libs/locales.js +0 -160
- package/src/Session/libs/login-mobile.js +0 -80
- package/src/Session/window-focus-aware.jsx +0 -28
- package/src/SessionManager/index.jsx +0 -2
- package/src/Storage/engine/cookie.js +0 -25
- package/src/Storage/engine/local-storage.js +0 -57
- package/src/Storage/index.js +0 -25
- package/src/User/index.js +0 -4
- package/src/User/use-did.js +0 -80
- package/src/User/wrap-did.jsx +0 -18
- package/src/WebWalletSWKeeper/index.jsx +0 -3
- package/src/components/PassportSwitcher.jsx +0 -160
- package/src/constant.js +0 -27
- package/src/error.js +0 -6
- package/src/hooks/use-locale.jsx +0 -6
- package/src/index.js +0 -32
- package/src/locales/en.jsx +0 -15
- package/src/locales/index.jsx +0 -13
- package/src/locales/zh.jsx +0 -15
- package/src/types.d.ts +0 -355
- package/src/utils.js +0 -413
- package/vite.config.mjs +0 -29
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Box as
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { checkSameProtocol as
|
|
6
|
-
import
|
|
7
|
-
import { useMemoizedFn as
|
|
8
|
-
import
|
|
9
|
-
import { detectWalletExtension as
|
|
10
|
-
import { useRef as w, useEffect as
|
|
11
|
-
import { mergeSx as
|
|
12
|
-
import
|
|
13
|
-
import { GA_LAST_LOGIN_METHOD as
|
|
14
|
-
import { translate as
|
|
15
|
-
import
|
|
16
|
-
import { useBrowser as
|
|
1
|
+
import { jsx as l, jsxs as ho } from "react/jsx-runtime";
|
|
2
|
+
import e from "prop-types";
|
|
3
|
+
import { Box as E } from "@mui/material";
|
|
4
|
+
import { LAST_USED_LOGIN_METHOD as uo, LOGIN_PROVIDER as t, WALLET_LOGIN_METHOD as J, LOGIN_PROVIDER_ICON_SIZE as A, LOGIN_PROVIDER_NAME as go } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { checkSameProtocol as fo, getWebWalletUrl as Lo } from "@arcblock/ux/lib/Util/wallet";
|
|
6
|
+
import M from "lodash/noop";
|
|
7
|
+
import { useMemoizedFn as c, useCreation as yo } from "ahooks";
|
|
8
|
+
import v from "js-cookie";
|
|
9
|
+
import { detectWalletExtension as Io, getCookieOptions as Eo } from "@arcblock/ux/lib/Util";
|
|
10
|
+
import { useRef as w, useEffect as X } from "react";
|
|
11
|
+
import { mergeSx as Ao } from "@arcblock/ux/lib/Util/style";
|
|
12
|
+
import Mo from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as L } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
+
import { translate as bo } from "@arcblock/ux/lib/Locale/util";
|
|
15
|
+
import xo from "@arcblock/ux/lib/Empty";
|
|
16
|
+
import { useBrowser as _o } from "@arcblock/react-hooks";
|
|
17
17
|
import Co from "./mobile-login-item.js";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
18
|
+
import Oo from "./web-login-item.js";
|
|
19
|
+
import Po from "./login-method-item.js";
|
|
20
20
|
import vo from "./wallet-login-options.js";
|
|
21
|
-
import { useOAuth as
|
|
22
|
-
import { useStateContext as
|
|
23
|
-
import { getAppId as
|
|
24
|
-
import
|
|
25
|
-
import { usePasskey as
|
|
21
|
+
import { useOAuth as wo } from "../../../OAuth/context.js";
|
|
22
|
+
import { useStateContext as To } from "../../contexts/state.js";
|
|
23
|
+
import { getAppId as Wo, logger as So, getApiErrorMessage as ko } from "../../../utils.js";
|
|
24
|
+
import Do from "./passkey-login-item.js";
|
|
25
|
+
import { usePasskey as No } from "../../../Passkey/context.js";
|
|
26
26
|
import "../../../Passkey/actions.js";
|
|
27
27
|
import Ro from "../../plugins/email/index.js";
|
|
28
28
|
import jo from "../../assets/locale.js";
|
|
29
|
-
function
|
|
30
|
-
onSuccess:
|
|
31
|
-
onError:
|
|
29
|
+
function Bo({
|
|
30
|
+
onSuccess: T = M,
|
|
31
|
+
onError: W = M,
|
|
32
32
|
size: m = "small",
|
|
33
|
-
tokenState:
|
|
34
|
-
webWalletUrl:
|
|
35
|
-
tokenKey:
|
|
36
|
-
passkeyBehavior:
|
|
37
|
-
onReset:
|
|
38
|
-
providerList:
|
|
39
|
-
slotProps:
|
|
40
|
-
disableSwitchApp:
|
|
41
|
-
forceUpdate:
|
|
42
|
-
magicToken:
|
|
43
|
-
baseUrl:
|
|
44
|
-
customItems:
|
|
45
|
-
qrcode:
|
|
46
|
-
hideQRCode:
|
|
33
|
+
tokenState: n,
|
|
34
|
+
webWalletUrl: b = Lo(),
|
|
35
|
+
tokenKey: S,
|
|
36
|
+
passkeyBehavior: k = "none",
|
|
37
|
+
onReset: x = M,
|
|
38
|
+
providerList: d = [],
|
|
39
|
+
slotProps: z = {},
|
|
40
|
+
disableSwitchApp: _ = !1,
|
|
41
|
+
forceUpdate: Q = M,
|
|
42
|
+
magicToken: D = void 0,
|
|
43
|
+
baseUrl: oo = "/",
|
|
44
|
+
customItems: eo = [],
|
|
45
|
+
qrcode: to = null,
|
|
46
|
+
hideQRCode: p = !1
|
|
47
47
|
}) {
|
|
48
|
-
const
|
|
49
|
-
extraParams:
|
|
50
|
-
locale:
|
|
51
|
-
connectState:
|
|
52
|
-
plugins:
|
|
53
|
-
setPlugins:
|
|
54
|
-
setSelectedPlugin:
|
|
48
|
+
const C = w(null), O = w(null), N = w(null), no = fo(b), R = Io(), h = _o(), { loginOAuth: ro, logoutOAuth: io, t: lo, oauthState: s } = wo(), { passkeyState: j } = No(), {
|
|
49
|
+
extraParams: B,
|
|
50
|
+
locale: G,
|
|
51
|
+
connectState: r,
|
|
52
|
+
plugins: F,
|
|
53
|
+
setPlugins: so,
|
|
54
|
+
setSelectedPlugin: ao,
|
|
55
55
|
getPlugin: U,
|
|
56
56
|
showWalletOptions: f,
|
|
57
|
-
setShowWalletOptions:
|
|
58
|
-
lastLoginMethod:
|
|
59
|
-
} =
|
|
60
|
-
localStorage.setItem(
|
|
57
|
+
setShowWalletOptions: y,
|
|
58
|
+
lastLoginMethod: u
|
|
59
|
+
} = To(), I = c((o, i = {}) => bo(jo, o, G, "en", i)), q = c(async (o) => {
|
|
60
|
+
localStorage.setItem(L, o.provider), n.reset(), s.reset({
|
|
61
61
|
status: "scanned"
|
|
62
|
-
}),
|
|
63
|
-
const
|
|
62
|
+
}), j.reset(), r.chooseMethod = o.provider, r.walletMethod = "";
|
|
63
|
+
const i = B?.sourceAppPid;
|
|
64
64
|
try {
|
|
65
65
|
s.loading = !0, s.status = "scanned";
|
|
66
|
-
const
|
|
67
|
-
action:
|
|
68
|
-
...
|
|
69
|
-
}),
|
|
70
|
-
|
|
66
|
+
const a = await ro(o, {
|
|
67
|
+
action: n.action,
|
|
68
|
+
...B
|
|
69
|
+
}), g = Eo({ returnDomain: !1 });
|
|
70
|
+
v.remove("connected_did", g), v.remove("connected_pk", g), v.remove("connected_wallet_os", g), a?.sessionToken && (localStorage.setItem(uo, o.provider), await T(
|
|
71
71
|
{
|
|
72
|
-
...
|
|
72
|
+
...a,
|
|
73
73
|
encrypted: !1
|
|
74
74
|
},
|
|
75
|
-
(
|
|
75
|
+
(po) => po,
|
|
76
76
|
{
|
|
77
|
-
sourceAppPid:
|
|
78
|
-
connected_app:
|
|
77
|
+
sourceAppPid: i,
|
|
78
|
+
connected_app: Wo(n.appInfo, n.memberAppInfo)
|
|
79
79
|
}
|
|
80
80
|
), s.loading = !1, s.status = "succeed");
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
s.loading = !1, s.error =
|
|
81
|
+
} catch (a) {
|
|
82
|
+
So.error(`Failed login OAuth: ${o.provider}`, a);
|
|
83
|
+
const g = ko(a, lo("loginOAuthFailed"));
|
|
84
|
+
s.loading = !1, s.error = g, s.status = "error", await io({ provider: o.provider }), W(new Error(g));
|
|
85
85
|
}
|
|
86
|
-
}),
|
|
87
|
-
|
|
88
|
-
}),
|
|
89
|
-
localStorage.setItem(
|
|
90
|
-
const o =
|
|
91
|
-
|
|
92
|
-
o(
|
|
86
|
+
}), H = c(async () => {
|
|
87
|
+
n.reset(), await x(), n.status = "created", r.chooseMethod = "wallet", r.walletMethod = "";
|
|
88
|
+
}), K = c(async () => {
|
|
89
|
+
localStorage.setItem(L, t.WALLET), n.reset(), await x(), n.status = "created", r.chooseMethod = "wallet";
|
|
90
|
+
const o = C.current?.connect;
|
|
91
|
+
r.retryConnect = () => {
|
|
92
|
+
o(H);
|
|
93
93
|
};
|
|
94
|
-
}),
|
|
95
|
-
localStorage.setItem(
|
|
96
|
-
const o =
|
|
97
|
-
|
|
98
|
-
await
|
|
94
|
+
}), V = c(() => {
|
|
95
|
+
localStorage.setItem(L, t.WALLET), n.status = "scanned", r.chooseMethod = "wallet-web";
|
|
96
|
+
const o = O.current.connect;
|
|
97
|
+
r.retryConnect = async () => {
|
|
98
|
+
await x(), n.error = "", n.status = "scanned", o();
|
|
99
99
|
};
|
|
100
|
-
}), co =
|
|
101
|
-
|
|
102
|
-
}),
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const o = U(
|
|
109
|
-
o.state.status === "idle" && (localStorage.setItem(
|
|
100
|
+
}), co = c(() => {
|
|
101
|
+
y(!1);
|
|
102
|
+
}), P = yo(() => d.length === 1 && d[0].provider === t.WALLET, [d]);
|
|
103
|
+
X(() => {
|
|
104
|
+
p && P && !h.mobile.any && !f && y(!0);
|
|
105
|
+
}, [p, P, h.mobile.any, y, f]);
|
|
106
|
+
const Y = d.some((o) => o.provider === t.EMAIL), Z = Ro({ baseUrl: oo }), mo = c(() => {
|
|
107
|
+
if (D && d.some((o) => o.name === t.EMAIL) && F.some((o) => o.name === t.EMAIL)) {
|
|
108
|
+
const o = U(t.EMAIL);
|
|
109
|
+
o.state.status === "idle" && (localStorage.setItem(L, t.EMAIL), o.state.reset(), o.state.magicToken = D, r.chooseMethod = t.EMAIL, ao(o), Q());
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
|
|
112
|
+
X(() => {
|
|
113
113
|
const o = [];
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
if (Y) {
|
|
115
|
+
const i = U(t.EMAIL);
|
|
116
|
+
i && i.baseUrl === Z.baseUrl ? o.push(i) : o.push(Z);
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
so(o), r.retryConnect = H, setTimeout(() => {
|
|
119
|
+
mo();
|
|
120
120
|
}, 100);
|
|
121
|
-
}, [
|
|
122
|
-
const $ =
|
|
123
|
-
if (o.provider ===
|
|
124
|
-
return
|
|
121
|
+
}, [Y]);
|
|
122
|
+
const $ = d.map((o) => {
|
|
123
|
+
if (o.provider === t.WALLET)
|
|
124
|
+
return h.mobile.any && !f ? /* @__PURE__ */ l(
|
|
125
125
|
Co,
|
|
126
126
|
{
|
|
127
127
|
t: I,
|
|
128
|
-
isLatest:
|
|
129
|
-
ref:
|
|
130
|
-
tokenState:
|
|
128
|
+
isLatest: u && u === J.MOBILE,
|
|
129
|
+
ref: C,
|
|
130
|
+
tokenState: n,
|
|
131
131
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
132
|
-
locale:
|
|
133
|
-
tokenKey:
|
|
134
|
-
disableSwitchApp:
|
|
135
|
-
onClick:
|
|
132
|
+
locale: G,
|
|
133
|
+
tokenKey: S,
|
|
134
|
+
disableSwitchApp: _,
|
|
135
|
+
onClick: K
|
|
136
136
|
},
|
|
137
|
-
|
|
138
|
-
) :
|
|
139
|
-
|
|
137
|
+
t.WALLET
|
|
138
|
+
) : p || !p && (no || R) && (!h.mobile.any || R) ? /* @__PURE__ */ l(
|
|
139
|
+
Oo,
|
|
140
140
|
{
|
|
141
141
|
t: I,
|
|
142
|
-
isLatest:
|
|
143
|
-
ref:
|
|
144
|
-
tokenState:
|
|
145
|
-
webWalletUrl:
|
|
142
|
+
isLatest: u && u === J.WEB,
|
|
143
|
+
ref: O,
|
|
144
|
+
tokenState: n,
|
|
145
|
+
webWalletUrl: b,
|
|
146
146
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
147
|
-
disableSwitchApp:
|
|
148
|
-
autoConnect: !
|
|
147
|
+
disableSwitchApp: _,
|
|
148
|
+
autoConnect: !p,
|
|
149
149
|
onClick: () => {
|
|
150
|
-
|
|
150
|
+
p ? y(!0) : V();
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
|
-
|
|
153
|
+
t.WALLET
|
|
154
154
|
) : null;
|
|
155
|
-
if (o.provider ===
|
|
156
|
-
return
|
|
157
|
-
|
|
155
|
+
if (o.provider === t.PASSKEY)
|
|
156
|
+
return k === "none" ? null : /* @__PURE__ */ l(
|
|
157
|
+
Do,
|
|
158
158
|
{
|
|
159
|
-
ref:
|
|
160
|
-
onSuccess:
|
|
161
|
-
onError:
|
|
162
|
-
tokenState:
|
|
163
|
-
behavior:
|
|
159
|
+
ref: N,
|
|
160
|
+
onSuccess: T,
|
|
161
|
+
onError: W,
|
|
162
|
+
tokenState: n,
|
|
163
|
+
behavior: k,
|
|
164
164
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
165
165
|
onClick: () => {
|
|
166
|
-
localStorage.setItem(
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
localStorage.setItem(L, t.PASSKEY);
|
|
167
|
+
const i = N.current.connect;
|
|
168
|
+
r.chooseMethod = "passkey", r.walletMethod = "", r.retryConnect = () => {
|
|
169
|
+
j.verifying = !0, r.chooseMethod = "passkey", i();
|
|
170
170
|
};
|
|
171
171
|
},
|
|
172
172
|
slotProps: {
|
|
173
173
|
icon: {
|
|
174
174
|
sx: {
|
|
175
|
-
fontSize:
|
|
175
|
+
fontSize: A,
|
|
176
176
|
"& svg": {
|
|
177
|
-
fontSize:
|
|
177
|
+
fontSize: A,
|
|
178
178
|
width: "1em",
|
|
179
179
|
height: "1em"
|
|
180
180
|
}
|
|
@@ -182,36 +182,36 @@ function No({
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
},
|
|
185
|
-
|
|
185
|
+
t.PASSKEY
|
|
186
186
|
);
|
|
187
|
-
if (o.provider ===
|
|
188
|
-
const
|
|
189
|
-
return
|
|
190
|
-
key:
|
|
187
|
+
if (o.provider === t.EMAIL) {
|
|
188
|
+
const i = F.find((a) => a.name === t.EMAIL);
|
|
189
|
+
return i ? i?.renderListItem({
|
|
190
|
+
key: i.name,
|
|
191
191
|
sx: [m === "small" ? { p: 1 } : { p: 2 }]
|
|
192
192
|
// forceUpdate,
|
|
193
193
|
}) : null;
|
|
194
194
|
}
|
|
195
195
|
return o.type === "oauth" ? /* @__PURE__ */ l(
|
|
196
|
-
|
|
196
|
+
Po,
|
|
197
197
|
{
|
|
198
198
|
t: I,
|
|
199
|
-
isLatest:
|
|
200
|
-
title:
|
|
199
|
+
isLatest: u && u === o.provider,
|
|
200
|
+
title: go[o.provider],
|
|
201
201
|
icon: /* @__PURE__ */ l(
|
|
202
|
-
|
|
202
|
+
Mo,
|
|
203
203
|
{
|
|
204
204
|
provider: o.provider,
|
|
205
205
|
sx: {
|
|
206
206
|
transform: "scale(0.95)",
|
|
207
|
-
width:
|
|
208
|
-
height:
|
|
207
|
+
width: A,
|
|
208
|
+
height: A,
|
|
209
209
|
color: "text.primary"
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
),
|
|
213
213
|
onClick: () => {
|
|
214
|
-
q(o),
|
|
214
|
+
q(o), r.retryConnect = () => {
|
|
215
215
|
q(o);
|
|
216
216
|
};
|
|
217
217
|
},
|
|
@@ -220,42 +220,42 @@ function No({
|
|
|
220
220
|
o.provider
|
|
221
221
|
) : null;
|
|
222
222
|
}).filter(Boolean);
|
|
223
|
-
return /* @__PURE__ */ l(
|
|
224
|
-
|
|
223
|
+
return /* @__PURE__ */ l(E, { className: "did-connect__choose", sx: Ao({ flex: 1 }, z?.root?.sx), children: /* @__PURE__ */ l(
|
|
224
|
+
E,
|
|
225
225
|
{
|
|
226
226
|
sx: {
|
|
227
227
|
display: "flex",
|
|
228
228
|
flexDirection: "column",
|
|
229
229
|
gap: 2
|
|
230
230
|
},
|
|
231
|
-
children: /* @__PURE__ */
|
|
232
|
-
|
|
231
|
+
children: /* @__PURE__ */ ho(
|
|
232
|
+
E,
|
|
233
233
|
{
|
|
234
234
|
sx: [
|
|
235
235
|
{
|
|
236
236
|
display: "flex",
|
|
237
237
|
flexDirection: "column",
|
|
238
|
-
...f && !
|
|
238
|
+
...f && !h.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
|
|
239
239
|
}
|
|
240
240
|
],
|
|
241
241
|
children: [
|
|
242
|
-
f && !
|
|
242
|
+
f && !h.mobile.any ? /* @__PURE__ */ l(
|
|
243
243
|
vo,
|
|
244
244
|
{
|
|
245
|
-
qrcode:
|
|
246
|
-
tokenState:
|
|
247
|
-
webWalletUrl:
|
|
245
|
+
qrcode: to,
|
|
246
|
+
tokenState: n,
|
|
247
|
+
webWalletUrl: b,
|
|
248
248
|
size: m,
|
|
249
|
-
disableSwitchApp:
|
|
250
|
-
tokenKey:
|
|
251
|
-
walletLoginRef:
|
|
252
|
-
webLoginRef:
|
|
253
|
-
onMobileLoginClick:
|
|
254
|
-
onWebLoginClick:
|
|
255
|
-
onBack:
|
|
249
|
+
disableSwitchApp: _,
|
|
250
|
+
tokenKey: S,
|
|
251
|
+
walletLoginRef: C,
|
|
252
|
+
webLoginRef: O,
|
|
253
|
+
onMobileLoginClick: K,
|
|
254
|
+
onWebLoginClick: V,
|
|
255
|
+
onBack: P ? void 0 : co
|
|
256
256
|
}
|
|
257
257
|
) : /* @__PURE__ */ l(
|
|
258
|
-
|
|
258
|
+
E,
|
|
259
259
|
{
|
|
260
260
|
sx: {
|
|
261
261
|
display: "grid",
|
|
@@ -301,7 +301,7 @@ function No({
|
|
|
301
301
|
}
|
|
302
302
|
},
|
|
303
303
|
children: $.length > 0 ? $ : /* @__PURE__ */ l(
|
|
304
|
-
|
|
304
|
+
xo,
|
|
305
305
|
{
|
|
306
306
|
className: "arc-login-item",
|
|
307
307
|
sx: {
|
|
@@ -314,32 +314,32 @@ function No({
|
|
|
314
314
|
)
|
|
315
315
|
}
|
|
316
316
|
),
|
|
317
|
-
|
|
317
|
+
eo.map((o) => o || null)
|
|
318
318
|
]
|
|
319
319
|
}
|
|
320
320
|
)
|
|
321
321
|
}
|
|
322
322
|
) });
|
|
323
323
|
}
|
|
324
|
-
|
|
325
|
-
onSuccess:
|
|
326
|
-
onError:
|
|
327
|
-
size:
|
|
328
|
-
tokenState:
|
|
329
|
-
webWalletUrl:
|
|
330
|
-
tokenKey:
|
|
331
|
-
passkeyBehavior:
|
|
332
|
-
onReset:
|
|
333
|
-
providerList:
|
|
334
|
-
slotProps:
|
|
335
|
-
disableSwitchApp:
|
|
336
|
-
forceUpdate:
|
|
337
|
-
magicToken:
|
|
338
|
-
baseUrl:
|
|
339
|
-
customItems:
|
|
340
|
-
qrcode:
|
|
341
|
-
hideQRCode:
|
|
324
|
+
Bo.propTypes = {
|
|
325
|
+
onSuccess: e.func,
|
|
326
|
+
onError: e.func,
|
|
327
|
+
size: e.oneOf(["small", "normal", "large"]),
|
|
328
|
+
tokenState: e.object.isRequired,
|
|
329
|
+
webWalletUrl: e.string,
|
|
330
|
+
tokenKey: e.string.isRequired,
|
|
331
|
+
passkeyBehavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
|
|
332
|
+
onReset: e.func,
|
|
333
|
+
providerList: e.array,
|
|
334
|
+
slotProps: e.object,
|
|
335
|
+
disableSwitchApp: e.bool,
|
|
336
|
+
forceUpdate: e.func,
|
|
337
|
+
magicToken: e.string,
|
|
338
|
+
baseUrl: e.string,
|
|
339
|
+
customItems: e.arrayOf(e.node),
|
|
340
|
+
qrcode: e.node,
|
|
341
|
+
hideQRCode: e.bool
|
|
342
342
|
};
|
|
343
343
|
export {
|
|
344
|
-
|
|
344
|
+
Bo as default
|
|
345
345
|
};
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
2
|
import n from "prop-types";
|
|
3
|
-
import { CircularProgress as
|
|
4
|
-
import { useReactive as
|
|
5
|
-
import
|
|
6
|
-
import { useBrowser as
|
|
7
|
-
import
|
|
3
|
+
import { CircularProgress as _ } from "@mui/material";
|
|
4
|
+
import { useReactive as v, useCreation as N, useMemoizedFn as l } from "ahooks";
|
|
5
|
+
import W from "@arcblock/bridge";
|
|
6
|
+
import { useBrowser as q } from "@arcblock/react-hooks";
|
|
7
|
+
import B from "lodash/noop";
|
|
8
8
|
import { useImperativeHandle as F } from "react";
|
|
9
|
-
import { mergeSx as
|
|
9
|
+
import { mergeSx as G } from "@arcblock/ux/lib/Util/style";
|
|
10
10
|
import j from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
11
|
-
import { LOGIN_PROVIDER_ICON_SIZE as
|
|
12
|
-
import { useStateContext as
|
|
11
|
+
import { WALLET_LOGIN_METHOD as f, LOGIN_PROVIDER_ICON_SIZE as d, LOGIN_PROVIDER as z } from "@arcblock/ux/lib/Util/constant";
|
|
12
|
+
import { useStateContext as H } from "../../contexts/state.js";
|
|
13
13
|
import J from "./login-method-item.js";
|
|
14
|
-
import { logger as
|
|
14
|
+
import { logger as L } from "../../../utils.js";
|
|
15
15
|
import K from "../../hooks/auth-url.js";
|
|
16
16
|
function V({
|
|
17
|
-
isTablet:
|
|
18
|
-
ref:
|
|
17
|
+
isTablet: C = !1,
|
|
18
|
+
ref: A = null,
|
|
19
19
|
tokenState: e,
|
|
20
20
|
locale: P,
|
|
21
21
|
tokenKey: y,
|
|
22
|
-
onClick: R =
|
|
23
|
-
disableSwitchApp:
|
|
24
|
-
...
|
|
22
|
+
onClick: R = B,
|
|
23
|
+
disableSwitchApp: O = !1,
|
|
24
|
+
...h
|
|
25
25
|
}) {
|
|
26
|
-
const
|
|
26
|
+
const a = v({
|
|
27
27
|
loading: !1
|
|
28
|
-
}), { isWalletWebview:
|
|
28
|
+
}), { isWalletWebview: u, connectState: c } = H(), x = "DID Wallet", m = q(), I = new URL(window.location.href), E = K({ disableSwitchApp: O, tokenState: e }), g = N(() => {
|
|
29
29
|
if (!e.url)
|
|
30
30
|
return "";
|
|
31
|
-
|
|
32
|
-
const o = new URL(
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
let r = "",
|
|
31
|
+
I.searchParams.set("tokenKey", e.token);
|
|
32
|
+
const o = new URL(E);
|
|
33
|
+
m.wallet || (o.searchParams.set("callback", encodeURIComponent(I)), o.searchParams.set("callback_delay", 1500)), o.searchParams.set("locale", P);
|
|
34
|
+
const w = new TextEncoder(), U = o.href.length;
|
|
35
|
+
let r = "", s = "";
|
|
36
36
|
try {
|
|
37
37
|
if (e.appInfo) {
|
|
38
|
-
const
|
|
39
|
-
r = btoa(String.fromCharCode(...
|
|
38
|
+
const i = w.encode(JSON.stringify(e.appInfo));
|
|
39
|
+
r = btoa(String.fromCharCode(...i));
|
|
40
40
|
}
|
|
41
41
|
if (e.memberAppInfo) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const i = w.encode(JSON.stringify(e.memberAppInfo));
|
|
43
|
+
s = btoa(String.fromCharCode(...i));
|
|
44
44
|
}
|
|
45
|
-
if (
|
|
46
|
-
throw
|
|
47
|
-
|
|
48
|
-
} catch (
|
|
49
|
-
|
|
45
|
+
if (U + 8 + r.length + 14 + s.length > 2e3)
|
|
46
|
+
throw L.warn("URL too long, drop appInfo & memberAppInfo", { appInfo: r, memberAppInfo: s }), new Error("URL too long");
|
|
47
|
+
s ? r && (o.searchParams.set("appInfo", r), o.searchParams.set("memberAppInfo", s)) : r && o.searchParams.set("appInfo", r);
|
|
48
|
+
} catch (i) {
|
|
49
|
+
L.warn("Failed to convert appInfo & memberAppInfo", i);
|
|
50
50
|
}
|
|
51
51
|
return o.href.replace(/^https?:\/\//, "abt://");
|
|
52
|
-
}, [y, e.token, e.appInfo, e.memberAppInfo, e.url]),
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
}, [y, e.token, e.appInfo, e.memberAppInfo, e.url]), M = l(() => {
|
|
53
|
+
a.loading = !0, setTimeout(() => {
|
|
54
|
+
W.call("authAction", { action: "auth", deepLink: g });
|
|
55
55
|
}, 600), setTimeout(() => {
|
|
56
|
-
|
|
56
|
+
a.loading = !1;
|
|
57
57
|
}, 2e3);
|
|
58
|
-
}),
|
|
58
|
+
}), T = l(() => {
|
|
59
59
|
e.checking = !0, e.status = "scanned";
|
|
60
|
-
}),
|
|
61
|
-
!
|
|
60
|
+
}), t = {};
|
|
61
|
+
!u && m.mobile.any && (t.component = "a", t.href = g), e.url || (t.sx = {
|
|
62
62
|
cursor: "not-allowed"
|
|
63
63
|
});
|
|
64
|
-
const
|
|
65
|
-
e.url && (
|
|
66
|
-
}),
|
|
67
|
-
|
|
64
|
+
const b = l((o) => {
|
|
65
|
+
e.url && (u ? (c.walletMethod = f.MOBILE, M()) : m.mobile.any || C ? (c.walletMethod = f.MOBILE, T()) : (c.walletMethod = f.SCAN, o()));
|
|
66
|
+
}), D = l(() => {
|
|
67
|
+
b(R);
|
|
68
68
|
});
|
|
69
|
-
return F(
|
|
70
|
-
connect:
|
|
71
|
-
})), /* @__PURE__ */
|
|
69
|
+
return F(A, () => ({
|
|
70
|
+
connect: b
|
|
71
|
+
})), /* @__PURE__ */ p(
|
|
72
72
|
J,
|
|
73
73
|
{
|
|
74
|
-
...
|
|
75
|
-
...
|
|
76
|
-
sx:
|
|
77
|
-
title:
|
|
78
|
-
icon:
|
|
79
|
-
|
|
74
|
+
...h,
|
|
75
|
+
...t,
|
|
76
|
+
sx: G(h?.sx, t?.sx),
|
|
77
|
+
title: x,
|
|
78
|
+
icon: a.loading || !e.url ? /* @__PURE__ */ p(
|
|
79
|
+
_,
|
|
80
80
|
{
|
|
81
81
|
color: "primary",
|
|
82
|
-
size:
|
|
82
|
+
size: d,
|
|
83
83
|
sx: {
|
|
84
84
|
"& svg": {
|
|
85
85
|
transform: "scale(0.75)"
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
) : /* @__PURE__ */
|
|
89
|
+
) : /* @__PURE__ */ p(
|
|
90
90
|
j,
|
|
91
91
|
{
|
|
92
92
|
provider: z.DID_WALLET,
|
|
93
93
|
sx: {
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
94
|
+
width: d,
|
|
95
|
+
height: d,
|
|
96
96
|
transform: "scale(0.9)"
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
),
|
|
100
100
|
iconScale: 1,
|
|
101
|
-
onClick:
|
|
101
|
+
onClick: D
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
104
|
}
|