@arcblock/did-connect-react 3.4.13 → 3.4.15
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/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 +8 -8
- package/src/Connect/components/login-item/connect-choose-list.jsx +14 -3
- package/src/Connect/components/login-item/connect-provider-list.jsx +14 -3
- package/src/Connect/components/login-item/mobile-login-item.jsx +5 -2
- package/src/Connect/components/login-item/passkey-login-item.jsx +7 -5
- package/src/Connect/components/login-item/web-login-item.jsx +4 -2
- package/src/Connect/connect.jsx +21 -3
- package/src/Connect/contexts/state.jsx +3 -2
- package/src/Connect/hooks/provider-list.js +6 -3
- package/src/Connect/plugins/email/list-item.jsx +1 -0
- package/src/Connect/plugins/email/placeholder.jsx +7 -0
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as l, jsxs as G } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
3
|
import { Box as g } from "@mui/material";
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { getWebWalletUrl as
|
|
4
|
+
import { LAST_USED_LOGIN_METHOD as re, LOGIN_PROVIDER as n, WALLET_LOGIN_METHOD as U, LOGIN_PROVIDER_NAME as se, LOGIN_PROVIDER_ICON_SIZE as h } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { getWebWalletUrl as ne } from "@arcblock/ux/lib/Util/wallet";
|
|
6
6
|
import L from "lodash/noop";
|
|
7
|
-
import { useMemoizedFn as
|
|
7
|
+
import { useMemoizedFn as y } from "ahooks";
|
|
8
8
|
import x from "js-cookie";
|
|
9
|
-
import { getCookieOptions as
|
|
10
|
-
import { useRef as
|
|
11
|
-
import { mergeSx as
|
|
12
|
-
import
|
|
9
|
+
import { getCookieOptions as le } from "@arcblock/ux/lib/Util";
|
|
10
|
+
import { useRef as M, useEffect as ie } from "react";
|
|
11
|
+
import { mergeSx as ae } from "@arcblock/ux/lib/Util/style";
|
|
12
|
+
import ce from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
13
13
|
import { GA_LAST_LOGIN_METHOD as u } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { useOAuth as
|
|
18
|
-
import { useStateContext as
|
|
19
|
-
import { getAppId as
|
|
20
|
-
import
|
|
21
|
-
import { usePasskey as
|
|
14
|
+
import pe from "./mobile-login-item.js";
|
|
15
|
+
import me from "./web-login-item.js";
|
|
16
|
+
import ue from "./login-method-item.js";
|
|
17
|
+
import { useOAuth as de } from "../../../OAuth/context.js";
|
|
18
|
+
import { useStateContext as fe } from "../../contexts/state.js";
|
|
19
|
+
import { getAppId as ge, logger as he, getApiErrorMessage as Le } from "../../../utils.js";
|
|
20
|
+
import Ie from "./passkey-login-item.js";
|
|
21
|
+
import { usePasskey as ye } from "../../../Passkey/context.js";
|
|
22
22
|
import "../../../Passkey/actions.js";
|
|
23
|
-
import
|
|
24
|
-
function
|
|
25
|
-
onSuccess:
|
|
26
|
-
onError:
|
|
23
|
+
import xe from "../../plugins/email/index.js";
|
|
24
|
+
function Me({
|
|
25
|
+
onSuccess: O = L,
|
|
26
|
+
onError: A = L,
|
|
27
27
|
size: c = "small",
|
|
28
|
-
tokenState:
|
|
29
|
-
webWalletUrl:
|
|
30
|
-
tokenKey:
|
|
31
|
-
passkeyBehavior:
|
|
32
|
-
onReset:
|
|
33
|
-
showMobileLogin:
|
|
34
|
-
showOAuthLogin:
|
|
35
|
-
showPasskeyLogin:
|
|
36
|
-
showWebLogin:
|
|
28
|
+
tokenState: r,
|
|
29
|
+
webWalletUrl: F = ne(),
|
|
30
|
+
tokenKey: j,
|
|
31
|
+
passkeyBehavior: B = "none",
|
|
32
|
+
onReset: I = L,
|
|
33
|
+
showMobileLogin: H = !0,
|
|
34
|
+
showOAuthLogin: E = !0,
|
|
35
|
+
showPasskeyLogin: b = !0,
|
|
36
|
+
showWebLogin: V = !0,
|
|
37
37
|
showEmailLogin: d = !0,
|
|
38
|
-
oauthProviderList:
|
|
38
|
+
oauthProviderList: q = [],
|
|
39
39
|
slotProps: K = {},
|
|
40
|
-
disableSwitchApp:
|
|
41
|
-
forceUpdate:
|
|
42
|
-
magicToken:
|
|
43
|
-
baseUrl:
|
|
44
|
-
customItems:
|
|
40
|
+
disableSwitchApp: v = !1,
|
|
41
|
+
forceUpdate: Y = L,
|
|
42
|
+
magicToken: w = void 0,
|
|
43
|
+
baseUrl: Z = "/",
|
|
44
|
+
customItems: $ = []
|
|
45
45
|
}) {
|
|
46
|
-
const
|
|
47
|
-
localStorage.setItem(u, e.provider),
|
|
46
|
+
const _ = M(null), P = M(null), C = M(null), { loginOAuth: z, logoutOAuth: J, t: f, oauthState: s } = de(), { passkeyState: T } = ye(), { extraParams: R, locale: Q, connectState: t, plugins: D, setPlugins: X, setSelectedPlugin: ee, getPlugin: N, lastLoginMethod: i } = fe(), W = y(async (e) => {
|
|
47
|
+
localStorage.setItem(u, e.provider), r.reset(), s.reset({
|
|
48
48
|
status: "scanned"
|
|
49
|
-
}),
|
|
50
|
-
const p =
|
|
49
|
+
}), T.reset(), t.chooseMethod = e.provider, t.walletMethod = "";
|
|
50
|
+
const p = R?.sourceAppPid;
|
|
51
51
|
try {
|
|
52
|
-
|
|
53
|
-
const m = await
|
|
54
|
-
action:
|
|
55
|
-
...
|
|
56
|
-
}), a =
|
|
57
|
-
x.remove("connected_did", a), x.remove("connected_pk", a), x.remove("connected_wallet_os", a), m?.sessionToken && (await
|
|
52
|
+
s.loading = !0, s.status = "scanned";
|
|
53
|
+
const m = await z(e, {
|
|
54
|
+
action: r.action,
|
|
55
|
+
...R
|
|
56
|
+
}), a = le({ returnDomain: !1 });
|
|
57
|
+
x.remove("connected_did", a), x.remove("connected_pk", a), x.remove("connected_wallet_os", a), m?.sessionToken && (localStorage.setItem(re, e.provider), await O(
|
|
58
58
|
{
|
|
59
59
|
...m,
|
|
60
60
|
encrypted: !1
|
|
61
61
|
},
|
|
62
|
-
(
|
|
62
|
+
(te) => te,
|
|
63
63
|
{
|
|
64
64
|
sourceAppPid: p,
|
|
65
|
-
connected_app:
|
|
65
|
+
connected_app: ge(r.appInfo, r.memberAppInfo)
|
|
66
66
|
}
|
|
67
|
-
),
|
|
67
|
+
), s.loading = !1, s.status = "succeed");
|
|
68
68
|
} catch (m) {
|
|
69
|
-
|
|
70
|
-
const a =
|
|
71
|
-
|
|
69
|
+
he.error(`Failed login OAuth: ${e.provider}`, m);
|
|
70
|
+
const a = Le(m, f("loginOAuthFailed"));
|
|
71
|
+
s.loading = !1, s.error = a, s.status = "error", await J({ provider: e.provider }), A(new Error(a));
|
|
72
72
|
}
|
|
73
|
-
}),
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
if (
|
|
77
|
-
const e =
|
|
78
|
-
e.state.status === "idle" && (localStorage.setItem(u,
|
|
73
|
+
}), k = y(async () => {
|
|
74
|
+
r.reset(), await I(), r.status = "created", t.chooseMethod = "wallet", t.walletMethod = "";
|
|
75
|
+
}), S = xe({ baseUrl: Z }), oe = y(() => {
|
|
76
|
+
if (w && d && D.some((e) => e.name === n.EMAIL)) {
|
|
77
|
+
const e = N(n.EMAIL);
|
|
78
|
+
e.state.status === "idle" && (localStorage.setItem(u, n.EMAIL), e.state.reset(), e.state.magicToken = w, t.chooseMethod = n.EMAIL, ee(e), Y());
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
return
|
|
81
|
+
return ie(() => {
|
|
82
82
|
const e = [];
|
|
83
83
|
if (d) {
|
|
84
|
-
const p =
|
|
85
|
-
p && p.baseUrl ===
|
|
84
|
+
const p = N(n.EMAIL);
|
|
85
|
+
p && p.baseUrl === S.baseUrl ? e.push(p) : e.push(S);
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
X(e), t.retryConnect = k, setTimeout(() => {
|
|
88
|
+
oe();
|
|
89
89
|
}, 100);
|
|
90
|
-
}, [d]), /* @__PURE__ */
|
|
90
|
+
}, [d]), /* @__PURE__ */ l(g, { className: "did-connect__choose", sx: ae({ flex: 1 }, K?.root?.sx), children: /* @__PURE__ */ l(
|
|
91
91
|
g,
|
|
92
92
|
{
|
|
93
93
|
sx: {
|
|
@@ -95,7 +95,7 @@ function Ie({
|
|
|
95
95
|
flexDirection: "column",
|
|
96
96
|
gap: 2
|
|
97
97
|
},
|
|
98
|
-
children: /* @__PURE__ */
|
|
98
|
+
children: /* @__PURE__ */ G(
|
|
99
99
|
g,
|
|
100
100
|
{
|
|
101
101
|
sx: [
|
|
@@ -106,46 +106,46 @@ function Ie({
|
|
|
106
106
|
}
|
|
107
107
|
],
|
|
108
108
|
children: [
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
H && /* @__PURE__ */ l(
|
|
110
|
+
pe,
|
|
111
111
|
{
|
|
112
112
|
t: f,
|
|
113
|
-
isLatest:
|
|
114
|
-
ref:
|
|
115
|
-
tokenState:
|
|
113
|
+
isLatest: i && i === U.MOBILE,
|
|
114
|
+
ref: _,
|
|
115
|
+
tokenState: r,
|
|
116
116
|
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
117
|
-
locale:
|
|
118
|
-
tokenKey:
|
|
119
|
-
disableSwitchApp:
|
|
117
|
+
locale: Q,
|
|
118
|
+
tokenKey: j,
|
|
119
|
+
disableSwitchApp: v,
|
|
120
120
|
onClick: async () => {
|
|
121
|
-
localStorage.setItem(u,
|
|
122
|
-
const e =
|
|
123
|
-
|
|
124
|
-
e(
|
|
121
|
+
localStorage.setItem(u, n.WALLET), r.reset(), await I(), r.status = "created", t.chooseMethod = "wallet";
|
|
122
|
+
const e = _.current?.connect;
|
|
123
|
+
t.retryConnect = () => {
|
|
124
|
+
e(k);
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
),
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
V && /* @__PURE__ */ l(
|
|
130
|
+
me,
|
|
131
131
|
{
|
|
132
|
-
isLatest:
|
|
133
|
-
ref:
|
|
134
|
-
tokenState:
|
|
135
|
-
webWalletUrl:
|
|
132
|
+
isLatest: i && i === U.WEB,
|
|
133
|
+
ref: P,
|
|
134
|
+
tokenState: r,
|
|
135
|
+
webWalletUrl: F,
|
|
136
136
|
t: f,
|
|
137
137
|
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
138
|
-
disableSwitchApp:
|
|
138
|
+
disableSwitchApp: v,
|
|
139
139
|
onClick: () => {
|
|
140
|
-
localStorage.setItem(u,
|
|
141
|
-
const e =
|
|
142
|
-
|
|
143
|
-
await
|
|
140
|
+
localStorage.setItem(u, n.WALLET), r.status = "scanned", t.chooseMethod = "wallet-web";
|
|
141
|
+
const e = P.current.connect;
|
|
142
|
+
t.retryConnect = async () => {
|
|
143
|
+
await I(), r.error = "", r.status = "scanned", e();
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
),
|
|
148
|
-
|
|
148
|
+
E || b || d ? /* @__PURE__ */ G(
|
|
149
149
|
g,
|
|
150
150
|
{
|
|
151
151
|
sx: [
|
|
@@ -156,21 +156,21 @@ function Ie({
|
|
|
156
156
|
}
|
|
157
157
|
],
|
|
158
158
|
children: [
|
|
159
|
-
|
|
159
|
+
D.map(
|
|
160
160
|
(e) => e.renderListItem({
|
|
161
161
|
key: e.name,
|
|
162
162
|
sx: [c === "small" ? { p: 1 } : { p: 2 }]
|
|
163
163
|
// forceUpdate,
|
|
164
164
|
})
|
|
165
165
|
),
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
E ? q.map((e) => /* @__PURE__ */ l(
|
|
167
|
+
ue,
|
|
168
168
|
{
|
|
169
169
|
t: f,
|
|
170
|
-
isLatest:
|
|
171
|
-
title:
|
|
172
|
-
icon: /* @__PURE__ */
|
|
173
|
-
|
|
170
|
+
isLatest: i && i === e.provider,
|
|
171
|
+
title: se[e.provider],
|
|
172
|
+
icon: /* @__PURE__ */ l(
|
|
173
|
+
ce,
|
|
174
174
|
{
|
|
175
175
|
provider: e.provider,
|
|
176
176
|
sx: {
|
|
@@ -182,28 +182,28 @@ function Ie({
|
|
|
182
182
|
}
|
|
183
183
|
),
|
|
184
184
|
onClick: () => {
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
W(e), t.retryConnect = () => {
|
|
186
|
+
W(e);
|
|
187
187
|
};
|
|
188
188
|
},
|
|
189
189
|
sx: [c === "small" ? { p: 1 } : { p: 2 }]
|
|
190
190
|
},
|
|
191
191
|
e.provider
|
|
192
192
|
)) : null,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
b ? /* @__PURE__ */ l(
|
|
194
|
+
Ie,
|
|
195
195
|
{
|
|
196
|
-
ref:
|
|
197
|
-
onSuccess:
|
|
198
|
-
onError:
|
|
199
|
-
tokenState:
|
|
200
|
-
behavior:
|
|
196
|
+
ref: C,
|
|
197
|
+
onSuccess: O,
|
|
198
|
+
onError: A,
|
|
199
|
+
tokenState: r,
|
|
200
|
+
behavior: B,
|
|
201
201
|
sx: [c === "small" ? { p: 1 } : { p: 2 }],
|
|
202
202
|
onClick: () => {
|
|
203
|
-
localStorage.setItem(u,
|
|
204
|
-
const e =
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
localStorage.setItem(u, n.PASSKEY);
|
|
204
|
+
const e = C.current.connect;
|
|
205
|
+
t.chooseMethod = "passkey", t.walletMethod = "", t.retryConnect = () => {
|
|
206
|
+
T.verifying = !0, t.chooseMethod = "passkey", e();
|
|
207
207
|
};
|
|
208
208
|
},
|
|
209
209
|
slotProps: {
|
|
@@ -223,14 +223,14 @@ function Ie({
|
|
|
223
223
|
]
|
|
224
224
|
}
|
|
225
225
|
) : null,
|
|
226
|
-
|
|
226
|
+
$.map((e) => e || null)
|
|
227
227
|
]
|
|
228
228
|
}
|
|
229
229
|
)
|
|
230
230
|
}
|
|
231
231
|
) });
|
|
232
232
|
}
|
|
233
|
-
|
|
233
|
+
Me.propTypes = {
|
|
234
234
|
onSuccess: o.func,
|
|
235
235
|
onError: o.func,
|
|
236
236
|
size: o.oneOf(["small", "normal", "large"]),
|
|
@@ -253,5 +253,5 @@ Ie.propTypes = {
|
|
|
253
253
|
customItems: o.arrayOf(o.node)
|
|
254
254
|
};
|
|
255
255
|
export {
|
|
256
|
-
|
|
256
|
+
Me as default
|
|
257
257
|
};
|