@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.
@@ -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 g({ title: p, description: s, extraContent: e = null, disableSwitchApp: a = !1 }) {
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
- g.propTypes = {
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
- g as default
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 ee } from "@arcblock/ux/lib/Util/constant";
5
- import { getWebWalletUrl as oe } from "@arcblock/ux/lib/Util/wallet";
6
- import d from "lodash/noop";
7
- import { useMemoizedFn as h } from "ahooks";
8
- import y from "js-cookie";
9
- import { getCookieOptions as te } from "@arcblock/ux/lib/Util";
10
- import { useRef as x, useEffect as re } from "react";
11
- import { mergeSx as se } from "@arcblock/ux/lib/Util/style";
12
- import ne from "@arcblock/ux/lib/DIDConnect/provider-icon";
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 le from "./mobile-login-item.js";
15
- import ie from "./web-login-item.js";
16
- import ae from "./login-method-item.js";
17
- import { useOAuth as ce } from "../../../OAuth/context.js";
18
- import { useStateContext as pe } from "../../contexts/state.js";
19
- import { getAppId as me, logger as ue, getApiErrorMessage as fe } from "../../../utils.js";
20
- import de from "./passkey-login-item.js";
21
- import { usePasskey as ge } from "../../../Passkey/context.js";
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 he from "../../plugins/email/index.js";
24
- function ye({
25
- onSuccess: I = d,
26
- onError: b = d,
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 = oe(),
30
- tokenKey: N,
29
+ webWalletUrl: U = te(),
30
+ tokenKey: G,
31
31
  passkeyBehavior: W = "none",
32
- onReset: g = d,
32
+ onReset: h = g,
33
33
  showMobileLogin: j = !0,
34
34
  showOAuthLogin: v = !0,
35
35
  showPasskeyLogin: w = !0,
36
- showWebLogin: G = !0,
36
+ showWebLogin: S = !0,
37
37
  showEmailLogin: m = !0,
38
- oauthProviderList: q = [],
39
- slotProps: B = {},
40
- disableSwitchApp: L = !1,
41
- forceUpdate: S = d,
42
- magicToken: M = void 0,
43
- baseUrl: V = "/",
44
- customItems: H = []
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 A = x(null), P = x(null), O = x(null), { loginOAuth: K, logoutOAuth: $, t: z, oauthState: s } = ce(), { passkeyState: C } = ge(), { extraParams: _, locale: J, connectState: r, plugins: E, setPlugins: Q, setSelectedPlugin: X, getPlugin: R } = pe(), k = h(async (e) => {
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
- }), C.reset(), r.chooseMethod = e.provider;
50
- const a = _?.sourceAppPid;
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 K(e, {
53
+ const c = await Z(e, {
54
54
  action: t.action,
55
- ..._
56
- }), l = te({ returnDomain: !1 });
57
- y.remove("connected_did", l), y.remove("connected_pk", l), y.remove("connected_wallet_os", l), c?.sessionToken && (await I(
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
- (Z) => Z,
62
+ (ee) => ee,
63
63
  {
64
64
  sourceAppPid: a,
65
- connected_app: me(t.appInfo, t.memberAppInfo)
65
+ connected_app: ue(t.appInfo, t.memberAppInfo)
66
66
  }
67
67
  ), s.loading = !1, s.status = "succeed");
68
68
  } catch (c) {
69
- ue.error(`Failed login OAuth: ${e.provider}`, c);
70
- const l = fe(c, z("loginOAuthFailed"));
71
- s.loading = !1, s.error = l, s.status = "error", await $({ provider: e.provider }), b(new Error(l));
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 = h(async () => {
74
- t.reset(), await g(), t.status = "created", r.chooseMethod = "wallet";
75
- }), D = he({ baseUrl: V }), Y = h(() => {
76
- if (M && m && E.some((e) => e.name === f.EMAIL)) {
77
- const e = R(f.EMAIL);
78
- e.state.status === "idle" && (localStorage.setItem(p, "email"), e.state.reset(), e.state.magicToken = M, r.chooseMethod = f.EMAIL, X(e), S());
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 re(() => {
81
+ return se(() => {
82
82
  const e = [];
83
83
  if (m) {
84
- const a = R(f.EMAIL);
85
- a && a.baseUrl === D.baseUrl ? e.push(a) : e.push(D);
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: se({ flex: 1 }, B?.root?.sx), children: /* @__PURE__ */ n(
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
- le,
110
+ ie,
111
111
  {
112
- ref: A,
112
+ ref: P,
113
113
  tokenState: t,
114
114
  sx: [i === "small" ? { p: 1 } : { p: 2 }],
115
115
  locale: J,
116
- tokenKey: N,
117
- disableSwitchApp: L,
116
+ tokenKey: G,
117
+ disableSwitchApp: M,
118
118
  onClick: async () => {
119
- localStorage.setItem(p, "wallet"), t.reset(), await g(), t.status = "created", r.chooseMethod = "wallet";
120
- const e = A.current?.connect;
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
- G && /* @__PURE__ */ n(
128
- ie,
127
+ S && /* @__PURE__ */ n(
128
+ ae,
129
129
  {
130
- ref: P,
130
+ ref: A,
131
131
  tokenState: t,
132
132
  webWalletUrl: U,
133
133
  sx: [i === "small" ? { p: 1 } : { p: 2 }],
134
- disableSwitchApp: L,
134
+ disableSwitchApp: M,
135
135
  onClick: () => {
136
136
  localStorage.setItem(p, "wallet"), t.status = "scanned", r.chooseMethod = "wallet-web";
137
- const e = P.current.connect;
137
+ const e = A.current.connect;
138
138
  r.retryConnect = async () => {
139
- await g(), t.error = "", t.status = "scanned", e();
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
- E.map(
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 ? q.map((e) => /* @__PURE__ */ n(
163
- ae,
162
+ v ? V.map((e) => /* @__PURE__ */ n(
163
+ ce,
164
164
  {
165
- title: ee[e.provider],
165
+ title: oe[e.provider],
166
166
  icon: /* @__PURE__ */ n(
167
- ne,
167
+ le,
168
168
  {
169
169
  provider: e.provider,
170
170
  sx: {
171
171
  transform: "scale(0.95)",
172
- width: 24,
173
- height: 24,
172
+ width: d,
173
+ height: d,
174
174
  color: "text.primary"
175
175
  }
176
176
  }
177
177
  ),
178
178
  onClick: () => {
179
- k(e), r.retryConnect = () => {
180
- k(e);
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
- de,
188
+ ge,
189
189
  {
190
- ref: O,
191
- onSuccess: I,
192
- onError: b,
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 = O.current.connect;
198
+ const e = C.current.connect;
199
199
  r.chooseMethod = "passkey", r.retryConnect = () => {
200
- C.verifying = !0, r.chooseMethod = "passkey", e();
200
+ _.verifying = !0, r.chooseMethod = "passkey", e();
201
201
  };
202
202
  },
203
203
  slotProps: {
204
204
  icon: {
205
205
  sx: {
206
- fontSize: 24,
206
+ fontSize: d,
207
207
  "& svg": {
208
- fontSize: 24,
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
- H.map((e) => e || null)
220
+ K.map((e) => e || null)
221
221
  ]
222
222
  }
223
223
  )
224
224
  }
225
225
  ) });
226
226
  }
227
- ye.propTypes = {
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
- ye as default
250
+ xe as default
251
251
  };