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