@arcblock/did-connect-react 3.4.0 → 3.4.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/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 +116 -117
- package/lib/Connect/contexts/state.js +73 -64
- package/lib/Connect/hooks/provider-list.js +43 -33
- package/lib/Connect/hooks/token.js +121 -122
- package/lib/Connect/plugins/email/index.js +15 -12
- 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 +36 -35
- package/src/Connect/contexts/state.jsx +10 -0
- package/src/Connect/hooks/provider-list.js +43 -17
- package/src/Connect/hooks/token.js +13 -13
- package/src/Connect/plugins/email/index.jsx +3 -0
- package/src/Connect/plugins/email/list-item.jsx +3 -2
- package/src/Passkey/actions.jsx +5 -0
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useTheme as
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { isValidElement as
|
|
1
|
+
import { jsxs as i, jsx as e, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme as b, Box as t, Tooltip as _, Typography as a } from "@mui/material";
|
|
3
|
+
import { Icon as p } from "@iconify/react";
|
|
4
|
+
import { isValidElement as I } from "react";
|
|
5
5
|
import o from "prop-types";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
import S from "lodash/noop";
|
|
7
|
+
import { mergeSx as d } from "@arcblock/ux/lib/Util/style";
|
|
8
|
+
import { LOGIN_PROVIDER_ICON_SIZE as f } from "@arcblock/ux/lib/Util/constant";
|
|
9
|
+
import N from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
|
|
10
|
+
function R({
|
|
11
|
+
isLatest: r = !1,
|
|
12
|
+
title: l,
|
|
13
|
+
description: s = null,
|
|
14
|
+
icon: n,
|
|
15
|
+
iconScale: h = 0.95,
|
|
16
|
+
slotProps: g = {},
|
|
17
|
+
mode: x = "normal",
|
|
18
|
+
t: y = S,
|
|
19
|
+
...c
|
|
17
20
|
}) {
|
|
18
|
-
const
|
|
19
|
-
return /* @__PURE__ */
|
|
20
|
-
|
|
21
|
+
const m = b();
|
|
22
|
+
return /* @__PURE__ */ i(
|
|
23
|
+
t,
|
|
21
24
|
{
|
|
22
|
-
...
|
|
25
|
+
...c,
|
|
23
26
|
className: "arc-login-item",
|
|
24
|
-
sx:
|
|
27
|
+
sx: d(
|
|
25
28
|
{
|
|
29
|
+
position: "relative",
|
|
26
30
|
display: "flex",
|
|
27
31
|
alignItems: "center",
|
|
28
32
|
gap: 1,
|
|
29
33
|
cursor: "pointer",
|
|
30
34
|
p: 1.2,
|
|
31
35
|
borderRadius: 1,
|
|
32
|
-
backgroundColor: "grey.50",
|
|
36
|
+
backgroundColor: r ? "grey.100" : "grey.50",
|
|
37
|
+
border: r ? "1px solid" : "none",
|
|
38
|
+
borderColor: r ? "grey.100" : "transparent",
|
|
33
39
|
textDecoration: "none",
|
|
34
40
|
transition: "background-color 0.5s",
|
|
35
41
|
"&:hover, &:active, &.did-connect__choose-item__active": {
|
|
@@ -48,40 +54,40 @@ function b({
|
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
|
-
|
|
57
|
+
c?.sx
|
|
52
58
|
),
|
|
53
59
|
children: [
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
|
|
60
|
+
/* @__PURE__ */ e(_, { title: l, children: /* @__PURE__ */ e(
|
|
61
|
+
t,
|
|
56
62
|
{
|
|
57
63
|
className: "arc-login-item__icon",
|
|
58
|
-
sx:
|
|
64
|
+
sx: d(
|
|
59
65
|
{
|
|
60
66
|
display: "flex",
|
|
61
67
|
justifyContent: "center",
|
|
62
68
|
alignItems: "center",
|
|
63
69
|
color: "text.primary"
|
|
64
70
|
},
|
|
65
|
-
|
|
71
|
+
g?.icon?.sx
|
|
66
72
|
),
|
|
67
|
-
children:
|
|
68
|
-
|
|
73
|
+
children: I(n) ? n : /* @__PURE__ */ e(
|
|
74
|
+
t,
|
|
69
75
|
{
|
|
70
|
-
component:
|
|
71
|
-
icon:
|
|
76
|
+
component: p,
|
|
77
|
+
icon: n,
|
|
72
78
|
sx: {
|
|
73
|
-
transform: `scale(${
|
|
74
|
-
width:
|
|
75
|
-
height:
|
|
79
|
+
transform: `scale(${h})`,
|
|
80
|
+
width: f,
|
|
81
|
+
height: f
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
)
|
|
79
85
|
}
|
|
80
86
|
) }),
|
|
81
|
-
|
|
82
|
-
/* @__PURE__ */ t
|
|
87
|
+
x === "normal" ? /* @__PURE__ */ i(u, { children: [
|
|
88
|
+
/* @__PURE__ */ i(t, { className: "arc-login-item__body", sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
|
|
83
89
|
/* @__PURE__ */ e(
|
|
84
|
-
|
|
90
|
+
a,
|
|
85
91
|
{
|
|
86
92
|
sx: {
|
|
87
93
|
fontSize: 14,
|
|
@@ -89,28 +95,36 @@ function b({
|
|
|
89
95
|
color: "text.primary",
|
|
90
96
|
whiteSpace: "nowrap"
|
|
91
97
|
},
|
|
92
|
-
children:
|
|
98
|
+
children: l
|
|
93
99
|
}
|
|
94
100
|
),
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
s ? /* @__PURE__ */ e(
|
|
102
|
+
a,
|
|
97
103
|
{
|
|
98
104
|
sx: {
|
|
99
105
|
color: "text.secondary",
|
|
100
106
|
fontSize: 12,
|
|
101
107
|
lineHeight: 1
|
|
102
108
|
},
|
|
103
|
-
children:
|
|
109
|
+
children: s
|
|
104
110
|
}
|
|
105
111
|
) : null
|
|
106
112
|
] }),
|
|
107
|
-
/* @__PURE__ */ e(
|
|
108
|
-
|
|
113
|
+
r ? /* @__PURE__ */ e(
|
|
114
|
+
a,
|
|
115
|
+
{
|
|
116
|
+
component: "span",
|
|
117
|
+
className: "latest-badge",
|
|
118
|
+
style: { color: m.palette.text.secondary, fontSize: 11 },
|
|
119
|
+
children: y("lastUsed")
|
|
120
|
+
}
|
|
121
|
+
) : /* @__PURE__ */ e(
|
|
122
|
+
p,
|
|
109
123
|
{
|
|
110
124
|
className: "other-item-icon",
|
|
111
|
-
icon:
|
|
125
|
+
icon: N,
|
|
112
126
|
fontSize: "1.3rem",
|
|
113
|
-
color:
|
|
127
|
+
color: m.palette.primary.main
|
|
114
128
|
}
|
|
115
129
|
)
|
|
116
130
|
] }) : null
|
|
@@ -118,14 +132,16 @@ function b({
|
|
|
118
132
|
}
|
|
119
133
|
);
|
|
120
134
|
}
|
|
121
|
-
|
|
135
|
+
R.propTypes = {
|
|
122
136
|
title: o.string.isRequired,
|
|
123
137
|
description: o.string,
|
|
124
138
|
icon: o.any.isRequired,
|
|
125
139
|
iconScale: o.number,
|
|
126
140
|
slotProps: o.object,
|
|
127
|
-
mode: o.oneOf(["mini", "simple", "normal"])
|
|
141
|
+
mode: o.oneOf(["mini", "simple", "normal"]),
|
|
142
|
+
isLatest: o.bool,
|
|
143
|
+
t: o.func
|
|
128
144
|
};
|
|
129
145
|
export {
|
|
130
|
-
|
|
146
|
+
R as default
|
|
131
147
|
};
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import e from "prop-types";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { useRef as l, useImperativeHandle as d } from "react";
|
|
4
|
+
import { useMemoizedFn as y } from "ahooks";
|
|
5
|
+
import { LOGIN_PROVIDER as P } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
+
import A from "../../../Passkey/actions.js";
|
|
7
|
+
import { getAppId as I } from "../../../utils.js";
|
|
8
|
+
import { useStateContext as R } from "../../contexts/state.js";
|
|
9
|
+
function x({ ref: p = null, onSuccess: i, tokenState: o, behavior: n = "none", ...c }) {
|
|
10
|
+
const { extraParams: r, lastLoginMethod: t } = R(), s = l(null), m = y(
|
|
11
|
+
(f) => i(
|
|
11
12
|
{
|
|
12
|
-
...
|
|
13
|
+
...f,
|
|
13
14
|
encrypted: !1
|
|
14
15
|
},
|
|
15
16
|
(u) => u,
|
|
16
17
|
{
|
|
17
18
|
sourceAppPid: r?.sourceAppPid,
|
|
18
|
-
connected_app:
|
|
19
|
+
connected_app: I(o.appInfo, o.memberAppInfo)
|
|
19
20
|
}
|
|
20
21
|
)
|
|
21
22
|
);
|
|
22
|
-
return
|
|
23
|
+
return d(p, () => ({
|
|
23
24
|
connect: s.current.click
|
|
24
|
-
})), n === "none" ? null : /* @__PURE__ */
|
|
25
|
-
|
|
25
|
+
})), n === "none" ? null : /* @__PURE__ */ a(
|
|
26
|
+
A,
|
|
26
27
|
{
|
|
27
28
|
...c,
|
|
28
29
|
ref: s,
|
|
30
|
+
isLatest: t && t === P.PASSKEY,
|
|
29
31
|
action: o.action,
|
|
30
32
|
behavior: n,
|
|
31
|
-
onSuccess:
|
|
33
|
+
onSuccess: m,
|
|
32
34
|
extraParams: r
|
|
33
35
|
}
|
|
34
36
|
);
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as d, Fragment as p, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
|
-
import { Box as t, Divider as
|
|
4
|
-
import { LOGIN_PROVIDER as
|
|
5
|
-
import { checkSameProtocol as
|
|
6
|
-
import { detectWalletExtension as
|
|
7
|
-
import { useCreation as
|
|
8
|
-
import { useBrowser as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { useStateContext as
|
|
13
|
-
function
|
|
14
|
-
qrcode:
|
|
3
|
+
import { Box as t, Divider as C } from "@mui/material";
|
|
4
|
+
import { LOGIN_PROVIDER as u } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { checkSameProtocol as k, getWebWalletUrl as W } from "@arcblock/ux/lib/Util/wallet";
|
|
6
|
+
import { detectWalletExtension as q } from "@arcblock/ux/lib/Util";
|
|
7
|
+
import { useCreation as j } from "ahooks";
|
|
8
|
+
import { useBrowser as T } from "@arcblock/react-hooks";
|
|
9
|
+
import P from "./mobile-login-item.js";
|
|
10
|
+
import v from "./web-login-item.js";
|
|
11
|
+
import B from "../back-button.js";
|
|
12
|
+
import { useStateContext as E } from "../../contexts/state.js";
|
|
13
|
+
function I({
|
|
14
|
+
qrcode: b,
|
|
15
15
|
tokenState: r,
|
|
16
|
-
webWalletUrl: n =
|
|
16
|
+
webWalletUrl: n = W(),
|
|
17
17
|
size: l = "small",
|
|
18
18
|
disableSwitchApp: m = !1,
|
|
19
|
-
tokenKey:
|
|
20
|
-
walletLoginRef:
|
|
21
|
-
webLoginRef:
|
|
22
|
-
onMobileLoginClick:
|
|
23
|
-
onWebLoginClick:
|
|
19
|
+
tokenKey: x,
|
|
20
|
+
walletLoginRef: g = null,
|
|
21
|
+
webLoginRef: h = null,
|
|
22
|
+
onMobileLoginClick: L,
|
|
23
|
+
onWebLoginClick: w,
|
|
24
24
|
onBack: s
|
|
25
25
|
}) {
|
|
26
|
-
const { locale:
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
|
|
29
|
-
/* @__PURE__ */
|
|
26
|
+
const { t: a, locale: y } = E(), i = T(), R = k(n), c = q(), f = j(() => i.mobile.tablet || !i.mobile.any && window?.navigator?.maxTouchPoints > 0, [i.mobile.tablet, i.mobile.any]);
|
|
27
|
+
return /* @__PURE__ */ d(p, { children: [
|
|
28
|
+
b,
|
|
29
|
+
/* @__PURE__ */ d(t, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
30
30
|
/* @__PURE__ */ e(t, { sx: { width: "100%" }, children: /* @__PURE__ */ e(
|
|
31
|
-
|
|
31
|
+
C,
|
|
32
32
|
{
|
|
33
33
|
orientation: "horizontal",
|
|
34
34
|
sx: {
|
|
@@ -57,41 +57,43 @@ function E({
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
children:
|
|
61
|
-
|
|
60
|
+
children: f ? /* @__PURE__ */ e(
|
|
61
|
+
P,
|
|
62
62
|
{
|
|
63
|
-
|
|
63
|
+
t: a,
|
|
64
|
+
ref: g,
|
|
64
65
|
tokenState: r,
|
|
65
|
-
isTablet:
|
|
66
|
+
isTablet: f,
|
|
66
67
|
sx: [l === "small" ? { p: 1 } : { p: 2 }],
|
|
67
|
-
locale:
|
|
68
|
-
tokenKey:
|
|
68
|
+
locale: y,
|
|
69
|
+
tokenKey: x,
|
|
69
70
|
disableSwitchApp: m,
|
|
70
|
-
onClick:
|
|
71
|
+
onClick: L
|
|
71
72
|
},
|
|
72
|
-
|
|
73
|
+
u.WALLET
|
|
73
74
|
) : (
|
|
74
75
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
75
|
-
/* @__PURE__ */ e(
|
|
76
|
-
|
|
76
|
+
/* @__PURE__ */ e(p, { children: (R || c) && (!i.mobile.any || c) ? /* @__PURE__ */ e(
|
|
77
|
+
v,
|
|
77
78
|
{
|
|
78
|
-
|
|
79
|
+
t: a,
|
|
80
|
+
ref: h,
|
|
79
81
|
tokenState: r,
|
|
80
82
|
webWalletUrl: n,
|
|
81
83
|
sx: [l === "small" ? { p: 1 } : { p: 2 }],
|
|
82
84
|
disableSwitchApp: m,
|
|
83
|
-
onClick:
|
|
85
|
+
onClick: w
|
|
84
86
|
},
|
|
85
|
-
|
|
87
|
+
u.WALLET
|
|
86
88
|
) : null })
|
|
87
89
|
)
|
|
88
90
|
}
|
|
89
91
|
),
|
|
90
|
-
s && /* @__PURE__ */ e(
|
|
92
|
+
s && /* @__PURE__ */ e(B, { variant: "text", onClick: s })
|
|
91
93
|
] })
|
|
92
94
|
] });
|
|
93
95
|
}
|
|
94
|
-
|
|
96
|
+
I.propTypes = {
|
|
95
97
|
qrcode: o.node.isRequired,
|
|
96
98
|
tokenState: o.object.isRequired,
|
|
97
99
|
webWalletUrl: o.string,
|
|
@@ -105,5 +107,5 @@ E.propTypes = {
|
|
|
105
107
|
onBack: o.func.isRequired
|
|
106
108
|
};
|
|
107
109
|
export {
|
|
108
|
-
|
|
110
|
+
I as default
|
|
109
111
|
};
|