@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.
Files changed (39) hide show
  1. package/lib/Connect/assets/locale.js +4 -2
  2. package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
  3. package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
  4. package/lib/Connect/components/login-item/login-method-item.js +63 -47
  5. package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
  6. package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
  7. package/lib/Connect/connect.js +503 -0
  8. package/lib/Connect/contexts/state.js +74 -65
  9. package/lib/Connect/fallback-connect.js +53 -0
  10. package/lib/Connect/hooks/provider-list.js +45 -29
  11. package/lib/Connect/index.js +13 -502
  12. package/lib/Connect/plugins/email/list-item.js +19 -18
  13. package/lib/Connect/use-connect.js +10 -10
  14. package/lib/OAuth/context.js +3 -3
  15. package/lib/Passkey/actions.js +80 -75
  16. package/lib/Passkey/context.js +3 -3
  17. package/lib/Passkey/dialog.js +7 -7
  18. package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
  19. package/lib/Session/index.js +189 -189
  20. package/lib/package.json.js +1 -1
  21. package/lib/utils.js +2 -2
  22. package/package.json +8 -8
  23. package/src/Connect/assets/locale.js +2 -0
  24. package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
  25. package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
  26. package/src/Connect/components/login-item/login-method-item.jsx +24 -7
  27. package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
  28. package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
  29. package/src/Connect/connect.jsx +618 -0
  30. package/src/Connect/contexts/state.jsx +10 -0
  31. package/src/Connect/fallback-connect.jsx +47 -0
  32. package/src/Connect/hooks/provider-list.js +48 -17
  33. package/src/Connect/index.jsx +8 -605
  34. package/src/Connect/plugins/email/list-item.jsx +3 -2
  35. package/src/Connect/use-connect.jsx +1 -1
  36. package/src/Passkey/actions.jsx +5 -0
  37. package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
  38. package/src/Session/index.jsx +3 -4
  39. package/src/utils.js +2 -2
@@ -1,35 +1,41 @@
1
- import { jsxs as t, jsx as e, Fragment as g } from "react/jsx-runtime";
2
- import { useTheme as y, Box as r, Tooltip as u, Typography as s } from "@mui/material";
3
- import { Icon as c } from "@iconify/react";
4
- import { isValidElement as _ } from "react";
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 { mergeSx as m } from "@arcblock/ux/lib/Util/style";
7
- import { LOGIN_PROVIDER_ICON_SIZE as p } from "@arcblock/ux/lib/Util/constant";
8
- import I from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
9
- function b({
10
- title: n,
11
- description: a = null,
12
- icon: i,
13
- iconScale: d = 0.95,
14
- slotProps: f = {},
15
- mode: h = "normal",
16
- ...l
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 x = y();
19
- return /* @__PURE__ */ t(
20
- r,
21
+ const m = b();
22
+ return /* @__PURE__ */ i(
23
+ t,
21
24
  {
22
- ...l,
25
+ ...c,
23
26
  className: "arc-login-item",
24
- sx: m(
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
- l?.sx
57
+ c?.sx
52
58
  ),
53
59
  children: [
54
- /* @__PURE__ */ e(u, { title: n, children: /* @__PURE__ */ e(
55
- r,
60
+ /* @__PURE__ */ e(_, { title: l, children: /* @__PURE__ */ e(
61
+ t,
56
62
  {
57
63
  className: "arc-login-item__icon",
58
- sx: m(
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
- f?.icon?.sx
71
+ g?.icon?.sx
66
72
  ),
67
- children: _(i) ? i : /* @__PURE__ */ e(
68
- r,
73
+ children: I(n) ? n : /* @__PURE__ */ e(
74
+ t,
69
75
  {
70
- component: c,
71
- icon: i,
76
+ component: p,
77
+ icon: n,
72
78
  sx: {
73
- transform: `scale(${d})`,
74
- width: p,
75
- height: p
79
+ transform: `scale(${h})`,
80
+ width: f,
81
+ height: f
76
82
  }
77
83
  }
78
84
  )
79
85
  }
80
86
  ) }),
81
- h === "normal" ? /* @__PURE__ */ t(g, { children: [
82
- /* @__PURE__ */ t(r, { className: "arc-login-item__body", sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
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
- s,
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: n
98
+ children: l
93
99
  }
94
100
  ),
95
- a ? /* @__PURE__ */ e(
96
- s,
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: a
109
+ children: s
104
110
  }
105
111
  ) : null
106
112
  ] }),
107
- /* @__PURE__ */ e(
108
- c,
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: I,
125
+ icon: N,
112
126
  fontSize: "1.3rem",
113
- color: x.palette.primary.main
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
- b.propTypes = {
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
- b as default
146
+ R as default
131
147
  };
@@ -1,34 +1,36 @@
1
- import { jsx as f } from "react/jsx-runtime";
1
+ import { jsx as a } from "react/jsx-runtime";
2
2
  import e from "prop-types";
3
- import { useRef as a, useImperativeHandle as l } from "react";
4
- import { useMemoizedFn as d } from "ahooks";
5
- import y from "../../../Passkey/actions.js";
6
- import { getAppId as A } from "../../../utils.js";
7
- import { useStateContext as P } from "../../contexts/state.js";
8
- function x({ ref: t = null, onSuccess: p, tokenState: o, behavior: n = "none", ...c }) {
9
- const { extraParams: r } = P(), s = a(null), i = d(
10
- (m) => p(
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
- ...m,
13
+ ...f,
13
14
  encrypted: !1
14
15
  },
15
16
  (u) => u,
16
17
  {
17
18
  sourceAppPid: r?.sourceAppPid,
18
- connected_app: A(o.appInfo, o.memberAppInfo)
19
+ connected_app: I(o.appInfo, o.memberAppInfo)
19
20
  }
20
21
  )
21
22
  );
22
- return l(t, () => ({
23
+ return d(p, () => ({
23
24
  connect: s.current.click
24
- })), n === "none" ? null : /* @__PURE__ */ f(
25
- y,
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: i,
33
+ onSuccess: m,
32
34
  extraParams: r
33
35
  }
34
36
  );
@@ -1,34 +1,34 @@
1
- import { jsxs as f, Fragment as d, jsx as e } from "react/jsx-runtime";
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 R } from "@mui/material";
4
- import { LOGIN_PROVIDER as p } from "@arcblock/ux/lib/Util/constant";
5
- import { checkSameProtocol as C, getWebWalletUrl as k } from "@arcblock/ux/lib/Util/wallet";
6
- import { detectWalletExtension as W } from "@arcblock/ux/lib/Util";
7
- import { useCreation as q } from "ahooks";
8
- import { useBrowser as j } from "@arcblock/react-hooks";
9
- import T from "./mobile-login-item.js";
10
- import P from "./web-login-item.js";
11
- import v from "../back-button.js";
12
- import { useStateContext as B } from "../../contexts/state.js";
13
- function E({
14
- qrcode: u,
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 = k(),
16
+ webWalletUrl: n = W(),
17
17
  size: l = "small",
18
18
  disableSwitchApp: m = !1,
19
- tokenKey: b,
20
- walletLoginRef: x = null,
21
- webLoginRef: g = null,
22
- onMobileLoginClick: h,
23
- onWebLoginClick: L,
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: w } = B(), i = j(), y = C(n), a = W(), c = q(() => i.mobile.tablet || !i.mobile.any && window?.navigator?.maxTouchPoints > 0, [i.mobile.tablet, i.mobile.any]);
27
- return /* @__PURE__ */ f(d, { children: [
28
- u,
29
- /* @__PURE__ */ f(t, { sx: { width: "100%", display: "flex", flexDirection: "column", gap: 1.5 }, children: [
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
- R,
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: c ? /* @__PURE__ */ e(
61
- T,
60
+ children: f ? /* @__PURE__ */ e(
61
+ P,
62
62
  {
63
- ref: x,
63
+ t: a,
64
+ ref: g,
64
65
  tokenState: r,
65
- isTablet: c,
66
+ isTablet: f,
66
67
  sx: [l === "small" ? { p: 1 } : { p: 2 }],
67
- locale: w,
68
- tokenKey: b,
68
+ locale: y,
69
+ tokenKey: x,
69
70
  disableSwitchApp: m,
70
- onClick: h
71
+ onClick: L
71
72
  },
72
- p.WALLET
73
+ u.WALLET
73
74
  ) : (
74
75
  // eslint-disable-next-line react/jsx-no-useless-fragment
75
- /* @__PURE__ */ e(d, { children: (y || a) && (!i.mobile.any || a) ? /* @__PURE__ */ e(
76
- P,
76
+ /* @__PURE__ */ e(p, { children: (R || c) && (!i.mobile.any || c) ? /* @__PURE__ */ e(
77
+ v,
77
78
  {
78
- ref: g,
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: L
85
+ onClick: w
84
86
  },
85
- p.WALLET
87
+ u.WALLET
86
88
  ) : null })
87
89
  )
88
90
  }
89
91
  ),
90
- s && /* @__PURE__ */ e(v, { variant: "text", onClick: s })
92
+ s && /* @__PURE__ */ e(B, { variant: "text", onClick: s })
91
93
  ] })
92
94
  ] });
93
95
  }
94
- E.propTypes = {
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
- E as default
110
+ I as default
109
111
  };