@arcblock/did-connect-react 3.4.0 → 3.4.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.
- package/lib/Connect/assets/locale.js +4 -2
- package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
- package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
- package/lib/Connect/components/login-item/login-method-item.js +63 -47
- package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
- package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
- package/lib/Connect/connect.js +88 -86
- package/lib/Connect/contexts/state.js +73 -64
- package/lib/Connect/hooks/provider-list.js +43 -33
- package/lib/Connect/plugins/email/list-item.js +19 -18
- package/lib/Passkey/actions.js +80 -75
- package/lib/package.json.js +1 -1
- package/package.json +5 -5
- package/src/Connect/assets/locale.js +2 -0
- package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
- package/src/Connect/components/login-item/login-method-item.jsx +24 -7
- package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
- package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
- package/src/Connect/connect.jsx +2 -0
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/hooks/provider-list.js +43 -17
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Passkey/actions.jsx +5 -0
|
@@ -67,7 +67,8 @@ const e = {
|
|
|
67
67
|
passkeyPreviewDescription: "Sign in with Passkey - More secure and convenient authentication. No passwords to remember, easily access apps and websites.",
|
|
68
68
|
didConnectTitle: "DID Connect",
|
|
69
69
|
didConnectDescription: "Decentralized identities and apps, W3C DID-based, future-ready.",
|
|
70
|
-
noAuthenticationProvider: "No authentication provider configured"
|
|
70
|
+
noAuthenticationProvider: "No authentication provider configured",
|
|
71
|
+
lastUsed: "Last Used"
|
|
71
72
|
},
|
|
72
73
|
zh: {
|
|
73
74
|
generateError: "二维码生成失败",
|
|
@@ -137,7 +138,8 @@ const e = {
|
|
|
137
138
|
passkeyPreviewDescription: "使用 Passkey 账户登录 - 更安全、更便捷的身份验证方式。无需记忆密码,轻松登录各类应用和网站",
|
|
138
139
|
didConnectTitle: "DID Connect",
|
|
139
140
|
didConnectDescription: "面向未来的基于 W3C DID 去中心化身份和应用",
|
|
140
|
-
noAuthenticationProvider: "未配置任何身份验证提供者"
|
|
141
|
+
noAuthenticationProvider: "未配置任何身份验证提供者",
|
|
142
|
+
lastUsed: "上次使用"
|
|
141
143
|
}
|
|
142
144
|
};
|
|
143
145
|
export {
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as U } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
|
-
import { Box as
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { getWebWalletUrl as
|
|
6
|
-
import
|
|
7
|
-
import { useMemoizedFn as
|
|
3
|
+
import { Box as g } from "@mui/material";
|
|
4
|
+
import { LOGIN_PROVIDER as s, LOGIN_PROVIDER_NAME as te, LOGIN_PROVIDER_ICON_SIZE as h } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { getWebWalletUrl as re } from "@arcblock/ux/lib/Util/wallet";
|
|
6
|
+
import L from "lodash/noop";
|
|
7
|
+
import { useMemoizedFn as I } from "ahooks";
|
|
8
8
|
import x from "js-cookie";
|
|
9
|
-
import { getCookieOptions as
|
|
10
|
-
import { useRef as
|
|
11
|
-
import { mergeSx as
|
|
9
|
+
import { getCookieOptions as se } from "@arcblock/ux/lib/Util";
|
|
10
|
+
import { useRef as A, useEffect as ne } from "react";
|
|
11
|
+
import { mergeSx as ie } from "@arcblock/ux/lib/Util/style";
|
|
12
12
|
import le from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
13
|
-
import { GA_LAST_LOGIN_METHOD as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { useOAuth as
|
|
18
|
-
import { useStateContext as
|
|
19
|
-
import { getAppId as
|
|
20
|
-
import
|
|
21
|
-
import { usePasskey as
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as u } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
+
import ae from "./mobile-login-item.js";
|
|
15
|
+
import ce from "./web-login-item.js";
|
|
16
|
+
import pe from "./login-method-item.js";
|
|
17
|
+
import { useOAuth as me } from "../../../OAuth/context.js";
|
|
18
|
+
import { useStateContext as ue } from "../../contexts/state.js";
|
|
19
|
+
import { getAppId as de, logger as fe, getApiErrorMessage as ge } from "../../../utils.js";
|
|
20
|
+
import he from "./passkey-login-item.js";
|
|
21
|
+
import { usePasskey as Le } from "../../../Passkey/context.js";
|
|
22
22
|
import "../../../Passkey/actions.js";
|
|
23
23
|
import ye from "../../plugins/email/index.js";
|
|
24
|
-
function
|
|
25
|
-
onSuccess: b =
|
|
26
|
-
onError:
|
|
27
|
-
size:
|
|
24
|
+
function Ie({
|
|
25
|
+
onSuccess: b = L,
|
|
26
|
+
onError: M = L,
|
|
27
|
+
size: c = "small",
|
|
28
28
|
tokenState: t,
|
|
29
|
-
webWalletUrl:
|
|
30
|
-
tokenKey:
|
|
31
|
-
passkeyBehavior:
|
|
32
|
-
onReset:
|
|
33
|
-
showMobileLogin:
|
|
29
|
+
webWalletUrl: G = re(),
|
|
30
|
+
tokenKey: S,
|
|
31
|
+
passkeyBehavior: j = "none",
|
|
32
|
+
onReset: y = L,
|
|
33
|
+
showMobileLogin: V = !0,
|
|
34
34
|
showOAuthLogin: v = !0,
|
|
35
|
-
showPasskeyLogin:
|
|
36
|
-
showWebLogin:
|
|
37
|
-
showEmailLogin:
|
|
38
|
-
oauthProviderList:
|
|
39
|
-
slotProps:
|
|
40
|
-
disableSwitchApp:
|
|
41
|
-
forceUpdate:
|
|
42
|
-
magicToken:
|
|
43
|
-
baseUrl:
|
|
44
|
-
customItems:
|
|
35
|
+
showPasskeyLogin: O = !0,
|
|
36
|
+
showWebLogin: q = !0,
|
|
37
|
+
showEmailLogin: d = !0,
|
|
38
|
+
oauthProviderList: B = [],
|
|
39
|
+
slotProps: K = {},
|
|
40
|
+
disableSwitchApp: P = !1,
|
|
41
|
+
forceUpdate: H = L,
|
|
42
|
+
magicToken: E = void 0,
|
|
43
|
+
baseUrl: Y = "/",
|
|
44
|
+
customItems: Z = []
|
|
45
45
|
}) {
|
|
46
|
-
const
|
|
47
|
-
localStorage.setItem(
|
|
46
|
+
const w = A(null), C = A(null), _ = A(null), { loginOAuth: $, logoutOAuth: z, t: f, oauthState: n } = me(), { passkeyState: R } = Le(), { extraParams: T, locale: J, connectState: r, plugins: W, setPlugins: Q, setSelectedPlugin: X, getPlugin: k, lastLoginMethod: l } = ue(), D = I(async (e) => {
|
|
47
|
+
localStorage.setItem(u, e.provider), t.reset(), n.reset({
|
|
48
48
|
status: "scanned"
|
|
49
|
-
}),
|
|
50
|
-
const
|
|
49
|
+
}), R.reset(), r.chooseMethod = e.provider;
|
|
50
|
+
const p = T?.sourceAppPid;
|
|
51
51
|
try {
|
|
52
|
-
|
|
53
|
-
const
|
|
52
|
+
n.loading = !0, n.status = "scanned";
|
|
53
|
+
const m = await $(e, {
|
|
54
54
|
action: t.action,
|
|
55
|
-
...
|
|
56
|
-
}),
|
|
57
|
-
x.remove("connected_did",
|
|
55
|
+
...T
|
|
56
|
+
}), a = se({ returnDomain: !1 });
|
|
57
|
+
x.remove("connected_did", a), x.remove("connected_pk", a), x.remove("connected_wallet_os", a), m?.sessionToken && (await b(
|
|
58
58
|
{
|
|
59
|
-
...
|
|
59
|
+
...m,
|
|
60
60
|
encrypted: !1
|
|
61
61
|
},
|
|
62
|
-
(
|
|
62
|
+
(oe) => oe,
|
|
63
63
|
{
|
|
64
|
-
sourceAppPid:
|
|
65
|
-
connected_app:
|
|
64
|
+
sourceAppPid: p,
|
|
65
|
+
connected_app: de(t.appInfo, t.memberAppInfo)
|
|
66
66
|
}
|
|
67
|
-
),
|
|
68
|
-
} catch (
|
|
69
|
-
fe.error(`Failed login OAuth: ${e.provider}`,
|
|
70
|
-
const
|
|
71
|
-
|
|
67
|
+
), n.loading = !1, n.status = "succeed");
|
|
68
|
+
} catch (m) {
|
|
69
|
+
fe.error(`Failed login OAuth: ${e.provider}`, m);
|
|
70
|
+
const a = ge(m, f("loginOAuthFailed"));
|
|
71
|
+
n.loading = !1, n.error = a, n.status = "error", await z({ provider: e.provider }), M(new Error(a));
|
|
72
72
|
}
|
|
73
|
-
}),
|
|
74
|
-
t.reset(), await
|
|
75
|
-
}),
|
|
76
|
-
if (
|
|
77
|
-
const e = k(
|
|
78
|
-
e.state.status === "idle" && (localStorage.setItem(
|
|
73
|
+
}), N = I(async () => {
|
|
74
|
+
t.reset(), await y(), t.status = "created", r.chooseMethod = "wallet";
|
|
75
|
+
}), F = ye({ baseUrl: Y }), ee = I(() => {
|
|
76
|
+
if (E && d && W.some((e) => e.name === s.EMAIL)) {
|
|
77
|
+
const e = k(s.EMAIL);
|
|
78
|
+
e.state.status === "idle" && (localStorage.setItem(u, s.EMAIL), e.state.reset(), e.state.magicToken = E, r.chooseMethod = s.EMAIL, X(e), H());
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
return
|
|
81
|
+
return ne(() => {
|
|
82
82
|
const e = [];
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
83
|
+
if (d) {
|
|
84
|
+
const p = k(s.EMAIL);
|
|
85
|
+
p && p.baseUrl === F.baseUrl ? e.push(p) : e.push(F);
|
|
86
86
|
}
|
|
87
|
-
Q(e), r.retryConnect =
|
|
88
|
-
|
|
87
|
+
Q(e), r.retryConnect = N, setTimeout(() => {
|
|
88
|
+
ee();
|
|
89
89
|
}, 100);
|
|
90
|
-
}, [
|
|
91
|
-
|
|
90
|
+
}, [d]), /* @__PURE__ */ i(g, { className: "did-connect__choose", sx: ie({ flex: 1 }, K?.root?.sx), children: /* @__PURE__ */ i(
|
|
91
|
+
g,
|
|
92
92
|
{
|
|
93
93
|
sx: {
|
|
94
94
|
display: "flex",
|
|
95
95
|
flexDirection: "column",
|
|
96
96
|
gap: 2
|
|
97
97
|
},
|
|
98
|
-
children: /* @__PURE__ */
|
|
99
|
-
|
|
98
|
+
children: /* @__PURE__ */ U(
|
|
99
|
+
g,
|
|
100
100
|
{
|
|
101
101
|
sx: [
|
|
102
102
|
{
|
|
@@ -106,43 +106,47 @@ function xe({
|
|
|
106
106
|
}
|
|
107
107
|
],
|
|
108
108
|
children: [
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
V && /* @__PURE__ */ i(
|
|
110
|
+
ae,
|
|
111
111
|
{
|
|
112
|
-
|
|
112
|
+
t: f,
|
|
113
|
+
isLatest: l && l === s.WALLET,
|
|
114
|
+
ref: w,
|
|
113
115
|
tokenState: t,
|
|
114
|
-
sx: [
|
|
116
|
+
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
115
117
|
locale: J,
|
|
116
|
-
tokenKey:
|
|
117
|
-
disableSwitchApp:
|
|
118
|
+
tokenKey: S,
|
|
119
|
+
disableSwitchApp: P,
|
|
118
120
|
onClick: async () => {
|
|
119
|
-
localStorage.setItem(
|
|
120
|
-
const e =
|
|
121
|
+
localStorage.setItem(u, s.WALLET), t.reset(), await y(), t.status = "created", r.chooseMethod = "wallet";
|
|
122
|
+
const e = w.current?.connect;
|
|
121
123
|
r.retryConnect = () => {
|
|
122
|
-
e(
|
|
124
|
+
e(N);
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
q && /* @__PURE__ */ i(
|
|
130
|
+
ce,
|
|
129
131
|
{
|
|
130
|
-
|
|
132
|
+
isLatest: l && l === s.WALLET,
|
|
133
|
+
ref: C,
|
|
131
134
|
tokenState: t,
|
|
132
|
-
webWalletUrl:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
webWalletUrl: G,
|
|
136
|
+
t: f,
|
|
137
|
+
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
138
|
+
disableSwitchApp: P,
|
|
135
139
|
onClick: () => {
|
|
136
|
-
localStorage.setItem(
|
|
137
|
-
const e =
|
|
140
|
+
localStorage.setItem(u, s.WALLET), t.status = "scanned", r.chooseMethod = "wallet-web";
|
|
141
|
+
const e = C.current.connect;
|
|
138
142
|
r.retryConnect = async () => {
|
|
139
|
-
await
|
|
143
|
+
await y(), t.error = "", t.status = "scanned", e();
|
|
140
144
|
};
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
),
|
|
144
|
-
v ||
|
|
145
|
-
|
|
148
|
+
v || O || d ? /* @__PURE__ */ U(
|
|
149
|
+
g,
|
|
146
150
|
{
|
|
147
151
|
sx: [
|
|
148
152
|
{
|
|
@@ -152,25 +156,27 @@ function xe({
|
|
|
152
156
|
}
|
|
153
157
|
],
|
|
154
158
|
children: [
|
|
155
|
-
|
|
159
|
+
W.map(
|
|
156
160
|
(e) => e.renderListItem({
|
|
157
161
|
key: e.name,
|
|
158
|
-
sx: [
|
|
162
|
+
sx: [c === "small" ? { p: 1 } : { p: 2 }]
|
|
159
163
|
// forceUpdate,
|
|
160
164
|
})
|
|
161
165
|
),
|
|
162
|
-
v ?
|
|
163
|
-
|
|
166
|
+
v ? B.map((e) => /* @__PURE__ */ i(
|
|
167
|
+
pe,
|
|
164
168
|
{
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
t: f,
|
|
170
|
+
isLatest: l && l === e.provider,
|
|
171
|
+
title: te[e.provider],
|
|
172
|
+
icon: /* @__PURE__ */ i(
|
|
167
173
|
le,
|
|
168
174
|
{
|
|
169
175
|
provider: e.provider,
|
|
170
176
|
sx: {
|
|
171
177
|
transform: "scale(0.95)",
|
|
172
|
-
width:
|
|
173
|
-
height:
|
|
178
|
+
width: h,
|
|
179
|
+
height: h,
|
|
174
180
|
color: "text.primary"
|
|
175
181
|
}
|
|
176
182
|
}
|
|
@@ -180,32 +186,32 @@ function xe({
|
|
|
180
186
|
D(e);
|
|
181
187
|
};
|
|
182
188
|
},
|
|
183
|
-
sx: [
|
|
189
|
+
sx: [c === "small" ? { p: 1 } : { p: 2 }]
|
|
184
190
|
},
|
|
185
191
|
e.provider
|
|
186
192
|
)) : null,
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
O ? /* @__PURE__ */ i(
|
|
194
|
+
he,
|
|
189
195
|
{
|
|
190
|
-
ref:
|
|
196
|
+
ref: _,
|
|
191
197
|
onSuccess: b,
|
|
192
|
-
onError:
|
|
198
|
+
onError: M,
|
|
193
199
|
tokenState: t,
|
|
194
|
-
behavior:
|
|
195
|
-
sx: [
|
|
200
|
+
behavior: j,
|
|
201
|
+
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
196
202
|
onClick: () => {
|
|
197
|
-
localStorage.setItem(
|
|
198
|
-
const e =
|
|
203
|
+
localStorage.setItem(u, s.PASSKEY);
|
|
204
|
+
const e = _.current.connect;
|
|
199
205
|
r.chooseMethod = "passkey", r.retryConnect = () => {
|
|
200
|
-
|
|
206
|
+
R.verifying = !0, r.chooseMethod = "passkey", e();
|
|
201
207
|
};
|
|
202
208
|
},
|
|
203
209
|
slotProps: {
|
|
204
210
|
icon: {
|
|
205
211
|
sx: {
|
|
206
|
-
fontSize:
|
|
212
|
+
fontSize: h,
|
|
207
213
|
"& svg": {
|
|
208
|
-
fontSize:
|
|
214
|
+
fontSize: h,
|
|
209
215
|
width: "1em",
|
|
210
216
|
height: "1em"
|
|
211
217
|
}
|
|
@@ -217,14 +223,14 @@ function xe({
|
|
|
217
223
|
]
|
|
218
224
|
}
|
|
219
225
|
) : null,
|
|
220
|
-
|
|
226
|
+
Z.map((e) => e || null)
|
|
221
227
|
]
|
|
222
228
|
}
|
|
223
229
|
)
|
|
224
230
|
}
|
|
225
231
|
) });
|
|
226
232
|
}
|
|
227
|
-
|
|
233
|
+
Ie.propTypes = {
|
|
228
234
|
onSuccess: o.func,
|
|
229
235
|
onError: o.func,
|
|
230
236
|
size: o.oneOf(["small", "normal", "large"]),
|
|
@@ -247,5 +253,5 @@ xe.propTypes = {
|
|
|
247
253
|
customItems: o.arrayOf(o.node)
|
|
248
254
|
};
|
|
249
255
|
export {
|
|
250
|
-
|
|
256
|
+
Ie as default
|
|
251
257
|
};
|