@arcblock/did-connect-react 3.3.10 → 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 +503 -0
- package/lib/Connect/contexts/state.js +74 -65
- package/lib/Connect/fallback-connect.js +53 -0
- package/lib/Connect/hooks/provider-list.js +45 -29
- package/lib/Connect/index.js +13 -502
- package/lib/Connect/plugins/email/list-item.js +19 -18
- package/lib/Connect/use-connect.js +10 -10
- package/lib/OAuth/context.js +3 -3
- package/lib/Passkey/actions.js +80 -75
- package/lib/Passkey/context.js +3 -3
- package/lib/Passkey/dialog.js +7 -7
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
- package/lib/Session/index.js +189 -189
- package/lib/package.json.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +8 -8
- 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 +618 -0
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/fallback-connect.jsx +47 -0
- package/src/Connect/hooks/provider-list.js +48 -17
- package/src/Connect/index.jsx +8 -605
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Connect/use-connect.jsx +1 -1
- package/src/Passkey/actions.jsx +5 -0
- package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
- package/src/Session/index.jsx +3 -4
- package/src/utils.js +2 -2
package/lib/Passkey/actions.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { jsxs as q, Fragment as D, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as I, useEffect as
|
|
2
|
+
import { useRef as I, useEffect as L, useImperativeHandle as M } from "react";
|
|
3
3
|
import z from "lodash/trim";
|
|
4
4
|
import e from "prop-types";
|
|
5
5
|
import k from "js-cookie";
|
|
6
|
-
import { CircularProgress as
|
|
6
|
+
import { CircularProgress as B } from "@mui/material";
|
|
7
7
|
import { Icon as S } from "@iconify/react";
|
|
8
|
-
import { getCookieOptions as
|
|
8
|
+
import { getCookieOptions as H } from "@arcblock/ux/lib/Util";
|
|
9
9
|
import { useMemoizedFn as v } from "ahooks";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { mergeSx as
|
|
14
|
-
import { usePasskey as
|
|
15
|
-
import { logger as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
10
|
+
import V from "@iconify-icons/material-symbols/passkey-rounded";
|
|
11
|
+
import $ from "@iconify-icons/material-symbols/person-add-rounded";
|
|
12
|
+
import G from "lodash/noop";
|
|
13
|
+
import { mergeSx as K } from "@arcblock/ux/lib/Util/style";
|
|
14
|
+
import { usePasskey as N } from "./context.js";
|
|
15
|
+
import { logger as W, getWebAuthnErrorMessage as Y } from "../utils.js";
|
|
16
|
+
import J from "../Connect/components/login-item/login-method-item.js";
|
|
17
|
+
import Q from "./dialog.js";
|
|
18
18
|
import { VERIFY_CODE_LENGTH as w } from "./constants.js";
|
|
19
|
-
function x({ action: d, onClick:
|
|
19
|
+
function x({ action: d, onClick: c, title: s, state: f, dense: l = !1, icon: u, ...m }) {
|
|
20
20
|
return /* @__PURE__ */ n(
|
|
21
|
-
|
|
21
|
+
J,
|
|
22
22
|
{
|
|
23
|
-
...
|
|
24
|
-
icon:
|
|
25
|
-
|
|
23
|
+
...m,
|
|
24
|
+
icon: f[d] ? /* @__PURE__ */ n(
|
|
25
|
+
B,
|
|
26
26
|
{
|
|
27
27
|
size: "1em",
|
|
28
28
|
sx: {
|
|
@@ -32,11 +32,11 @@ function x({ action: d, onClick: a, title: i, state: c, dense: f = !1, icon: l,
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
) :
|
|
35
|
+
) : u,
|
|
36
36
|
iconScale: 1,
|
|
37
|
-
title:
|
|
38
|
-
onClick:
|
|
39
|
-
sx:
|
|
37
|
+
title: s,
|
|
38
|
+
onClick: c,
|
|
39
|
+
sx: K(l ? { p: 1, backgroundColor: "transparent" } : {}, m?.sx)
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -48,104 +48,108 @@ x.propTypes = {
|
|
|
48
48
|
dense: e.bool,
|
|
49
49
|
icon: e.any.isRequired
|
|
50
50
|
};
|
|
51
|
-
function
|
|
51
|
+
function U({
|
|
52
52
|
ref: d = null,
|
|
53
|
-
action:
|
|
54
|
-
behavior:
|
|
55
|
-
onSuccess:
|
|
56
|
-
onError:
|
|
57
|
-
extraParams:
|
|
58
|
-
createButtonText:
|
|
53
|
+
action: c,
|
|
54
|
+
behavior: s = "none",
|
|
55
|
+
onSuccess: f,
|
|
56
|
+
onError: l,
|
|
57
|
+
extraParams: u = {},
|
|
58
|
+
createButtonText: m = "",
|
|
59
59
|
createMode: T = "register",
|
|
60
60
|
dense: P = !1,
|
|
61
61
|
slotProps: R = {},
|
|
62
|
-
sx:
|
|
63
|
-
mode:
|
|
64
|
-
onClick: E =
|
|
62
|
+
sx: b = {},
|
|
63
|
+
mode: h = "normal",
|
|
64
|
+
onClick: E = G,
|
|
65
|
+
isLatest: j = !1
|
|
65
66
|
}) {
|
|
66
|
-
const
|
|
67
|
+
const p = I(""), C = I(null), { t: i, loginPasskey: O, logoutPasskey: _, passkeyState: o } = N(), A = v(async (a = "") => {
|
|
67
68
|
try {
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
...
|
|
71
|
-
action:
|
|
72
|
-
credentialId:
|
|
73
|
-
}), t =
|
|
74
|
-
k.remove("connected_did", t), k.remove("connected_pk", t), k.remove("connected_wallet_os", t),
|
|
75
|
-
} catch (
|
|
76
|
-
|
|
77
|
-
const t =
|
|
78
|
-
|
|
69
|
+
o.verifying = !0, o.error = "", a || (o.verifyingStatus = "");
|
|
70
|
+
const r = await O({
|
|
71
|
+
...u,
|
|
72
|
+
action: c,
|
|
73
|
+
credentialId: a
|
|
74
|
+
}), t = H({ expireInDays: 7 });
|
|
75
|
+
k.remove("connected_did", t), k.remove("connected_pk", t), k.remove("connected_wallet_os", t), o.verifying = !1, r?.sessionToken && (await f({ ...r, encrypted: !1 }, (F) => F), o.verifyingStatus = "succeed");
|
|
76
|
+
} catch (r) {
|
|
77
|
+
W.error("Failed to verify passkey", r);
|
|
78
|
+
const t = Y(r, i("verifyPasskeyFailed"), i);
|
|
79
|
+
o.verifying = !1, o.error = t, o.verifyingStatus = "error", await _(), l(new Error(t));
|
|
79
80
|
}
|
|
80
81
|
}), y = v(
|
|
81
|
-
(
|
|
82
|
-
if (!
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
if (!/^\d+$/.test(
|
|
86
|
-
|
|
87
|
-
const t = document.getElementById(`code-input-${
|
|
82
|
+
(a) => {
|
|
83
|
+
if (!o.sent) return;
|
|
84
|
+
a.preventDefault();
|
|
85
|
+
const r = z(a.clipboardData.getData("text/plain").slice(0, w));
|
|
86
|
+
if (!/^\d+$/.test(r)) return;
|
|
87
|
+
o.code = r.padEnd(w, " ");
|
|
88
|
+
const t = document.getElementById(`code-input-${r.length}`);
|
|
88
89
|
t && t.focus();
|
|
89
90
|
},
|
|
90
|
-
[
|
|
91
|
+
[o]
|
|
91
92
|
);
|
|
92
|
-
|
|
93
|
+
L(() => (document.addEventListener("paste", y), () => {
|
|
93
94
|
document.removeEventListener("paste", y);
|
|
94
95
|
}), [y]);
|
|
95
96
|
const g = v(() => {
|
|
96
|
-
|
|
97
|
+
p.current === "verifying" ? A() : p.current === "creating" && C.current.open();
|
|
97
98
|
});
|
|
98
99
|
return M(d, () => ({
|
|
99
100
|
click: g
|
|
100
|
-
})),
|
|
101
|
-
["both", "only-existing"].includes(
|
|
101
|
+
})), s === "none" ? null : /* @__PURE__ */ q(D, { children: [
|
|
102
|
+
["both", "only-existing"].includes(s) ? /* @__PURE__ */ n(
|
|
102
103
|
x,
|
|
103
104
|
{
|
|
105
|
+
isLatest: j,
|
|
106
|
+
t: i,
|
|
104
107
|
action: "verifying",
|
|
105
|
-
state:
|
|
106
|
-
title:
|
|
108
|
+
state: o,
|
|
109
|
+
title: i("usePasskey"),
|
|
107
110
|
onClick: () => {
|
|
108
|
-
|
|
111
|
+
p.current = "verifying", g(), E();
|
|
109
112
|
},
|
|
110
113
|
dense: P,
|
|
111
114
|
slotProps: R,
|
|
112
|
-
sx:
|
|
113
|
-
mode:
|
|
114
|
-
icon: /* @__PURE__ */ n(S, { icon:
|
|
115
|
+
sx: b,
|
|
116
|
+
mode: h,
|
|
117
|
+
icon: /* @__PURE__ */ n(S, { icon: V, fontSize: "1em" })
|
|
115
118
|
}
|
|
116
119
|
) : null,
|
|
117
|
-
["both", "only-new"].includes(
|
|
120
|
+
["both", "only-new"].includes(s) ? /* @__PURE__ */ q(D, { children: [
|
|
118
121
|
/* @__PURE__ */ n(
|
|
119
122
|
x,
|
|
120
123
|
{
|
|
124
|
+
t: i,
|
|
121
125
|
action: "creating",
|
|
122
|
-
state:
|
|
123
|
-
title:
|
|
126
|
+
state: o,
|
|
127
|
+
title: m || i("createPasskey"),
|
|
124
128
|
onClick: () => {
|
|
125
|
-
|
|
129
|
+
p.current = "creating", g(), E();
|
|
126
130
|
},
|
|
127
131
|
dense: P,
|
|
128
132
|
slotProps: R,
|
|
129
|
-
sx:
|
|
130
|
-
mode:
|
|
131
|
-
icon: /* @__PURE__ */ n(S, { icon:
|
|
133
|
+
sx: b,
|
|
134
|
+
mode: h,
|
|
135
|
+
icon: /* @__PURE__ */ n(S, { icon: $, fontSize: "1em" })
|
|
132
136
|
}
|
|
133
137
|
),
|
|
134
138
|
/* @__PURE__ */ n(
|
|
135
|
-
|
|
139
|
+
Q,
|
|
136
140
|
{
|
|
137
141
|
ref: C,
|
|
138
|
-
action:
|
|
142
|
+
action: c,
|
|
139
143
|
createMode: T,
|
|
140
|
-
extraParams:
|
|
141
|
-
onSuccess:
|
|
142
|
-
onError:
|
|
144
|
+
extraParams: u,
|
|
145
|
+
onSuccess: f,
|
|
146
|
+
onError: l
|
|
143
147
|
}
|
|
144
148
|
)
|
|
145
149
|
] }) : null
|
|
146
150
|
] });
|
|
147
151
|
}
|
|
148
|
-
|
|
152
|
+
U.propTypes = {
|
|
149
153
|
action: e.string.isRequired,
|
|
150
154
|
onSuccess: e.func.isRequired,
|
|
151
155
|
onError: e.func.isRequired,
|
|
@@ -158,8 +162,9 @@ Q.propTypes = {
|
|
|
158
162
|
sx: e.oneOfType([e.object, e.array]),
|
|
159
163
|
mode: e.oneOf(["simple", "normal"]),
|
|
160
164
|
onClick: e.func,
|
|
161
|
-
ref: e.any
|
|
165
|
+
ref: e.any,
|
|
166
|
+
isLatest: e.bool
|
|
162
167
|
};
|
|
163
168
|
export {
|
|
164
|
-
|
|
169
|
+
U as default
|
|
165
170
|
};
|
package/lib/Passkey/context.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as V, jsx as O } from "react/jsx-runtime";
|
|
2
2
|
import p from "prop-types";
|
|
3
3
|
import z from "lodash/isUndefined";
|
|
4
|
-
import {
|
|
4
|
+
import { use as J, createContext as K } from "react";
|
|
5
5
|
import u from "@arcblock/ux/lib/Toast";
|
|
6
6
|
import { useReactive as g, useMemoizedFn as i, useCreation as W } from "ahooks";
|
|
7
7
|
import w from "lodash/noop";
|
|
@@ -12,7 +12,7 @@ import { getBlockletData as H, getFederatedEnabled as X, getMaster as Q } from "
|
|
|
12
12
|
import { startRegistration as Y, startAuthentication as Z } from "@simplewebauthn/browser";
|
|
13
13
|
import { createAxios as $, getWebAuthnErrorMessage as h, logger as U, getApiErrorMessage as A } from "../utils.js";
|
|
14
14
|
import { parseResponse as ee, PassportSwitcher as se } from "../components/PassportSwitcher.js";
|
|
15
|
-
const F =
|
|
15
|
+
const F = K({}), { Provider: te, Consumer: he } = F, re = {
|
|
16
16
|
zh: {
|
|
17
17
|
cancel: "取消",
|
|
18
18
|
usePasskey: "使用 Passkey",
|
|
@@ -260,7 +260,7 @@ function ae({
|
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
function me() {
|
|
263
|
-
return
|
|
263
|
+
return J(F);
|
|
264
264
|
}
|
|
265
265
|
ae.propTypes = {
|
|
266
266
|
children: p.node.isRequired,
|
package/lib/Passkey/dialog.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs as l, jsx as o, Fragment as L } from "react/jsx-runtime";
|
|
|
2
2
|
import c from "prop-types";
|
|
3
3
|
import { useState as G, useImperativeHandle as N } from "react";
|
|
4
4
|
import p from "@emotion/styled";
|
|
5
|
-
import {
|
|
5
|
+
import { Alert as Y, TextField as j, Stack as J, Box as z, Dialog as Q, DialogTitle as U, DialogContent as X, Button as k, CircularProgress as A, DialogActions as Z } from "@mui/material";
|
|
6
6
|
import m from "validator/lib/isEmail";
|
|
7
7
|
import { Icon as ee } from "@iconify/react";
|
|
8
8
|
import te from "@iconify-icons/material-symbols/passkey-rounded";
|
|
@@ -134,7 +134,7 @@ function ne({ ref: y, extraParams: C = {}, createMode: D = "connect", action: P,
|
|
|
134
134
|
/* @__PURE__ */ l(le, { children: [
|
|
135
135
|
/* @__PURE__ */ o(b, { variant: "body1", children: i("createPasskeyDesc1") }),
|
|
136
136
|
/* @__PURE__ */ o(b, { variant: "body1", children: i("createPasskeyDesc2") }),
|
|
137
|
-
e.error && /* @__PURE__ */ o(
|
|
137
|
+
e.error && /* @__PURE__ */ o(Y, { severity: "error", children: e.error }),
|
|
138
138
|
a && /* @__PURE__ */ l(pe, { children: [
|
|
139
139
|
!e.sent && /* @__PURE__ */ o(
|
|
140
140
|
j,
|
|
@@ -155,7 +155,7 @@ function ne({ ref: y, extraParams: C = {}, createMode: D = "connect", action: P,
|
|
|
155
155
|
}
|
|
156
156
|
),
|
|
157
157
|
e.sent && !e.verified && /* @__PURE__ */ l(
|
|
158
|
-
|
|
158
|
+
J,
|
|
159
159
|
{
|
|
160
160
|
direction: "column",
|
|
161
161
|
sx: {
|
|
@@ -211,17 +211,17 @@ ne.propTypes = {
|
|
|
211
211
|
onError: c.func,
|
|
212
212
|
ref: c.any.isRequired
|
|
213
213
|
};
|
|
214
|
-
const ae = p(
|
|
214
|
+
const ae = p(Q)`
|
|
215
215
|
.MuiDialog-paper {
|
|
216
216
|
border-radius: 12px;
|
|
217
217
|
max-width: 440px;
|
|
218
218
|
}
|
|
219
|
-
`, se = p(
|
|
219
|
+
`, se = p(U)`
|
|
220
220
|
text-align: center;
|
|
221
221
|
padding: 24px 24px 16px;
|
|
222
222
|
font-size: 20px;
|
|
223
223
|
font-weight: 600;
|
|
224
|
-
`, le = p(
|
|
224
|
+
`, le = p(X)`
|
|
225
225
|
padding: 0 24px;
|
|
226
226
|
|
|
227
227
|
.MuiTypography-body1 {
|
|
@@ -234,7 +234,7 @@ const ae = p(Y)`
|
|
|
234
234
|
margin-top: 16px;
|
|
235
235
|
width: 100%;
|
|
236
236
|
}
|
|
237
|
-
`, ce = p(
|
|
237
|
+
`, ce = p(Z)`
|
|
238
238
|
text-align: center;
|
|
239
239
|
padding: 16px 24px 24px;
|
|
240
240
|
|