@arcblock/did-connect-react 3.2.7 → 3.2.8

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.
@@ -24,7 +24,7 @@ import he from "../../plugins/email/index.js";
24
24
  function ye({
25
25
  onSuccess: I = d,
26
26
  onError: b = d,
27
- size: l = "small",
27
+ size: i = "small",
28
28
  tokenState: t,
29
29
  webWalletUrl: U = oe(),
30
30
  tokenKey: N,
@@ -43,7 +43,7 @@ function ye({
43
43
  baseUrl: V = "/",
44
44
  customItems: H = []
45
45
  }) {
46
- const A = x(null), P = x(null), O = x(null), { loginOAuth: K, logoutOAuth: $, t: J, oauthState: s } = ce(), { passkeyState: C } = ge(), { extraParams: _, locale: Q, connectState: r, plugins: E, setPlugins: X, setSelectedPlugin: Y, getPlugin: R } = pe(), k = h(async (e) => {
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) => {
47
47
  localStorage.setItem(p, e.provider), t.reset(), s.reset({
48
48
  status: "scanned"
49
49
  }), C.reset(), r.chooseMethod = e.provider;
@@ -53,13 +53,13 @@ function ye({
53
53
  const c = await K(e, {
54
54
  action: t.action,
55
55
  ..._
56
- }), i = te({ returnDomain: !1 });
57
- y.remove("connected_did", i), y.remove("connected_pk", i), y.remove("connected_wallet_os", i), c?.sessionToken && (await I(
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(
58
58
  {
59
59
  ...c,
60
60
  encrypted: !1
61
61
  },
62
- (z) => z,
62
+ (Z) => Z,
63
63
  {
64
64
  sourceAppPid: a,
65
65
  connected_app: me(t.appInfo, t.memberAppInfo)
@@ -67,15 +67,15 @@ function ye({
67
67
  ), s.loading = !1, s.status = "succeed");
68
68
  } catch (c) {
69
69
  ue.error(`Failed login OAuth: ${e.provider}`, c);
70
- const i = fe(c, J("loginOAuthFailed"));
71
- s.loading = !1, s.error = i, s.status = "error", await $({ provider: e.provider }), b(new Error(i));
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));
72
72
  }
73
73
  }), T = h(async () => {
74
74
  t.reset(), await g(), t.status = "created", r.chooseMethod = "wallet";
75
- }), D = he({ baseUrl: V }), Z = h(() => {
75
+ }), D = he({ baseUrl: V }), Y = h(() => {
76
76
  if (M && m && E.some((e) => e.name === f.EMAIL)) {
77
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, Y(e), S());
78
+ e.state.status === "idle" && (localStorage.setItem(p, "email"), e.state.reset(), e.state.magicToken = M, r.chooseMethod = f.EMAIL, X(e), S());
79
79
  }
80
80
  });
81
81
  return re(() => {
@@ -84,8 +84,8 @@ function ye({
84
84
  const a = R(f.EMAIL);
85
85
  a && a.baseUrl === D.baseUrl ? e.push(a) : e.push(D);
86
86
  }
87
- X(e), r.retryConnect = T, setTimeout(() => {
88
- Z();
87
+ Q(e), r.retryConnect = T, setTimeout(() => {
88
+ Y();
89
89
  }, 100);
90
90
  }, [m]), /* @__PURE__ */ n(u, { className: "did-connect__choose", sx: se({ flex: 1 }, B?.root?.sx), children: /* @__PURE__ */ n(
91
91
  u,
@@ -106,13 +106,13 @@ function ye({
106
106
  }
107
107
  ],
108
108
  children: [
109
- j && l !== "small" && /* @__PURE__ */ n(
109
+ j && /* @__PURE__ */ n(
110
110
  le,
111
111
  {
112
112
  ref: A,
113
113
  tokenState: t,
114
- sx: [l === "small" ? { p: 1 } : { p: 2 }],
115
- locale: Q,
114
+ sx: [i === "small" ? { p: 1 } : { p: 2 }],
115
+ locale: J,
116
116
  tokenKey: N,
117
117
  disableSwitchApp: L,
118
118
  onClick: async () => {
@@ -130,7 +130,7 @@ function ye({
130
130
  ref: P,
131
131
  tokenState: t,
132
132
  webWalletUrl: U,
133
- sx: [l === "small" ? { p: 1 } : { p: 2 }],
133
+ sx: [i === "small" ? { p: 1 } : { p: 2 }],
134
134
  disableSwitchApp: L,
135
135
  onClick: () => {
136
136
  localStorage.setItem(p, "wallet"), t.status = "scanned", r.chooseMethod = "wallet-web";
@@ -155,7 +155,7 @@ function ye({
155
155
  E.map(
156
156
  (e) => e.renderListItem({
157
157
  key: e.name,
158
- sx: [l === "small" ? { p: 1 } : { p: 2 }]
158
+ sx: [i === "small" ? { p: 1 } : { p: 2 }]
159
159
  // forceUpdate,
160
160
  })
161
161
  ),
@@ -180,7 +180,7 @@ function ye({
180
180
  k(e);
181
181
  };
182
182
  },
183
- sx: [l === "small" ? { p: 1 } : { p: 2 }]
183
+ sx: [i === "small" ? { p: 1 } : { p: 2 }]
184
184
  },
185
185
  e.provider
186
186
  )) : null,
@@ -192,7 +192,7 @@ function ye({
192
192
  onError: b,
193
193
  tokenState: t,
194
194
  behavior: W,
195
- sx: [l === "small" ? { p: 1 } : { p: 2 }],
195
+ sx: [i === "small" ? { p: 1 } : { p: 2 }],
196
196
  onClick: () => {
197
197
  localStorage.setItem(p, "passkey");
198
198
  const e = O.current.connect;
@@ -2,8 +2,8 @@ import { jsx as t, jsxs as p, Fragment as He } from "react/jsx-runtime";
2
2
  import { use as Ve, useRef as ie, useState as qe, useEffect as se } from "react";
3
3
  import e from "prop-types";
4
4
  import { Box as i, Skeleton as Ye, Divider as Ge } from "@mui/material";
5
- import { useUpdate as Ke, useSize as Qe, useCreation as d, useMount as ae, useMemoizedFn as M, useDebounceFn as Xe, usePrevious as Je, useUpdateEffect as Ze } from "ahooks";
6
- import x from "lodash/noop";
5
+ import { useUpdate as Ke, useSize as Qe, useCreation as f, useMount as ae, useMemoizedFn as M, useDebounceFn as Xe, usePrevious as Je, useUpdateEffect as Ze } from "ahooks";
6
+ import b from "lodash/noop";
7
7
  import $e from "lodash/isUndefined";
8
8
  import et from "@arcblock/ux/lib/CloseButton";
9
9
  import { LOGIN_PROVIDER as tt, OAUTH_PROVIDER as z, DID_CONNECT_MEDIUM_WIDTH as U, LOGIN_PROVIDER_NAME as ot, DID_CONNECT_SMALL_WIDTH as rt } from "@arcblock/ux/lib/Util/constant";
@@ -20,8 +20,8 @@ import { SessionContext as ft } from "../Session/context.js";
20
20
  import { StateProvider as mt, useStateContext as pt } from "./contexts/state.js";
21
21
  import ht from "./components/login-item/connect-choose-list.js";
22
22
  import gt from "./components/auto-height.js";
23
- import xt from "./hooks/token.js";
24
- import { useOAuth as bt } from "../OAuth/context.js";
23
+ import bt from "./hooks/token.js";
24
+ import { useOAuth as xt } from "../OAuth/context.js";
25
25
  import Ct from "./components/connect-status.js";
26
26
  import { usePasskey as wt } from "../Passkey/context.js";
27
27
  import { CHECK_STATUS_INTERVAL as yt, API_DID_PREFIX as kt, BUSY_STATUS as y, DEFAULT_TIMEOUT as St } from "../constant.js";
@@ -33,8 +33,8 @@ import Tt from "./hooks/auth-url.js";
33
33
  import { getWalletDid as vt } from "../User/use-did.js";
34
34
  import { getWebWalletUrl as _t } from "@arcblock/ux/lib/Util/wallet";
35
35
  function ce({
36
- hideCloseButton: b = !1,
37
- mode: f = "dialog",
36
+ hideCloseButton: x = !1,
37
+ mode: m = "dialog",
38
38
  action: k,
39
39
  baseUrl: h = "",
40
40
  checkFn: S,
@@ -58,13 +58,13 @@ function ce({
58
58
  disableSwitchApp: T = !1,
59
59
  magicToken: G = void 0,
60
60
  customItems: he = [],
61
- onClose: v = x,
62
- onError: K = x,
63
- onSuccess: _ = x,
64
- onRecreateSession: Q = x,
65
- setColor: ge = x
61
+ onClose: v = b,
62
+ onError: K = b,
63
+ onSuccess: _ = b,
64
+ onRecreateSession: Q = b,
65
+ setColor: ge = b
66
66
  }) {
67
- const R = ct(), X = Ke(), xe = Ve(ft), be = vt(xe?.session?.user), {
67
+ const R = ct(), X = Ke(), be = Ve(ft), xe = vt(be?.session?.user), {
68
68
  t: J,
69
69
  staticState: Ce,
70
70
  connectState: s,
@@ -75,7 +75,7 @@ function ce({
75
75
  selectedPlugin: a,
76
76
  blocklet: Z,
77
77
  masterBlocklet: ke
78
- } = pt(), { state: o, generate: $, cancelWhenScanned: Se } = xt({
78
+ } = pt(), { state: o, generate: $, cancelWhenScanned: Se } = bt({
79
79
  action: k,
80
80
  baseUrl: h,
81
81
  checkFn: S,
@@ -89,21 +89,21 @@ function ce({
89
89
  tokenKey: B,
90
90
  encKey: ue,
91
91
  autoConnect: de,
92
- forceConnected: N === !0 ? be || !0 : N,
92
+ forceConnected: N === !0 ? xe || !0 : N,
93
93
  saveConnect: fe,
94
94
  useSocket: me,
95
95
  provider: pe
96
- }), A = ie(!1), ee = ie(null), g = Qe(ee), W = d(() => g ? g.width < U - 50 : !0, [g, g?.width]), [te, Ie] = qe(!1);
96
+ }), A = ie(!1), ee = ie(null), g = Qe(ee), L = f(() => g ? g.width < U - 50 : !0, [g, g?.width]), [te, Ie] = qe(!1);
97
97
  ae(() => {
98
98
  Ie(g?.width < U - 50);
99
99
  });
100
- const { oauthState: c, setBaseUrl: De } = bt(), { passkeyState: l, setTargetAppPid: Pe } = wt();
100
+ const { oauthState: c, setBaseUrl: De } = xt(), { passkeyState: l, setTargetAppPid: Pe } = wt();
101
101
  ae(() => {
102
102
  De(h), Pe(Z?.appPid), o.reset(), c.reset(), l.reset();
103
103
  }), se(() => {
104
104
  ge(O);
105
105
  }, [O]);
106
- const Te = d(() => ({
106
+ const Te = f(() => ({
107
107
  confirm: u.confirm,
108
108
  success: u.success,
109
109
  error: a?.state?.error || o.error || l.error || c.error || ""
@@ -114,7 +114,7 @@ function ce({
114
114
  c.error,
115
115
  l.error,
116
116
  a?.state?.error
117
- ]), C = d(() => y.includes(l.status) || y.includes(c.status) || y.includes(o.status) || y.includes(a?.state?.computedStatus), [o.status, c.status, l.status, a?.state?.computedStatus]), oe = M(async () => {
117
+ ]), C = f(() => y.includes(l.status) || y.includes(c.status) || y.includes(o.status) || y.includes(a?.state?.computedStatus), [o.status, c.status, l.status, a?.state?.computedStatus]), oe = M(async () => {
118
118
  Q(), c.reset(), l.reset(), await $(!1);
119
119
  }), ve = M(() => {
120
120
  s?.retryConnect();
@@ -127,15 +127,15 @@ function ce({
127
127
  { leading: !0, trailing: !1 }
128
128
  );
129
129
  se(Re, [o.status]);
130
- const Oe = d(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), {
130
+ const Oe = f(() => ot[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), {
131
131
  showMobileLogin: Ae,
132
132
  hideChooseList: r,
133
- oauthProviderList: We,
134
- showOAuthLogin: Le,
133
+ oauthProviderList: Le,
134
+ showOAuthLogin: We,
135
135
  showPasskeyLogin: Ee,
136
136
  showWebLogin: Me,
137
137
  showEmailLogin: Ue,
138
- hideQRCode: m
138
+ hideQRCode: d
139
139
  } = Pt({
140
140
  action: o.action,
141
141
  sourceAppPid: s?.sourceAppPid,
@@ -143,9 +143,9 @@ function ce({
143
143
  allowWallet: j,
144
144
  passkeyBehavior: H,
145
145
  webWalletUrl: V,
146
- mode: f,
146
+ mode: m,
147
147
  blocklet: s?.sourceAppPid ? ke : Z,
148
- isSmallView: W
148
+ isSmallView: L
149
149
  }), ze = Je(s?.sourceAppPid);
150
150
  Ze(() => {
151
151
  $e(ze) || $();
@@ -153,7 +153,7 @@ function ce({
153
153
  const n = (w) => {
154
154
  const je = R.spacing(w);
155
155
  return parseInt(je, 10);
156
- }, Be = d(() => b ? null : /* @__PURE__ */ t(
156
+ }, Be = f(() => x ? null : /* @__PURE__ */ t(
157
157
  et,
158
158
  {
159
159
  onClose: v,
@@ -163,7 +163,7 @@ function ce({
163
163
  top: 14
164
164
  }
165
165
  }
166
- ), [b, v]);
166
+ ), [x, v]);
167
167
  let re = null;
168
168
  C && (re = /* @__PURE__ */ t(
169
169
  i,
@@ -194,7 +194,7 @@ function ce({
194
194
  ) })
195
195
  }
196
196
  ));
197
- const ne = Tt({ disableSwitchApp: T, tokenState: o }), Fe = d(() => {
197
+ const ne = Tt({ disableSwitchApp: T, tokenState: o }), Fe = f(() => {
198
198
  const w = R.mode === "dark" ? R.palette.grey[500] : "white";
199
199
  return /* @__PURE__ */ t(
200
200
  i,
@@ -248,7 +248,7 @@ function ce({
248
248
  )
249
249
  }
250
250
  );
251
- }, [ne, r]), Ne = d(() => r ? "column-reverse" : !m && te ? "column" : "row", [r, te, m]), L = /* @__PURE__ */ p(
251
+ }, [ne, r]), Ne = f(() => r ? "column-reverse" : !d && te ? "column" : "row", [r, te, d]), W = /* @__PURE__ */ p(
252
252
  i,
253
253
  {
254
254
  className: "did-connect__body",
@@ -258,12 +258,12 @@ function ce({
258
258
  justifyContent: "center",
259
259
  alignItems: "stretch",
260
260
  flex: 1,
261
- gap: !m && W ? 0 : 1.5,
261
+ gap: !d && L ? 0 : 1.5,
262
262
  overflow: "visible",
263
263
  px: r ? 2 : 0
264
264
  },
265
265
  children: [
266
- !C && !m ? /* @__PURE__ */ p(He, { children: [
266
+ !C && !d ? /* @__PURE__ */ p(He, { children: [
267
267
  /* @__PURE__ */ t(
268
268
  i,
269
269
  {
@@ -345,7 +345,7 @@ function ce({
345
345
  }
346
346
  },
347
347
  allowWallet: j,
348
- size: m && f !== "dialog" ? "normal" : "small",
348
+ size: d && m !== "dialog" ? "normal" : "small",
349
349
  tokenState: o,
350
350
  messages: u,
351
351
  tokenKey: B,
@@ -355,12 +355,12 @@ function ce({
355
355
  extraContent: Y,
356
356
  enabledConnectTypes: q,
357
357
  onRest: oe,
358
- showMobileLogin: Ae,
359
- showOAuthLogin: Le,
358
+ showMobileLogin: Ae && d,
359
+ showOAuthLogin: We,
360
360
  showPasskeyLogin: Ee,
361
361
  showWebLogin: Me,
362
362
  showEmailLogin: Ue,
363
- oauthProviderList: We,
363
+ oauthProviderList: Le,
364
364
  disableSwitchApp: T,
365
365
  forceUpdate: X,
366
366
  magicToken: G,
@@ -374,13 +374,13 @@ function ce({
374
374
  ]
375
375
  }
376
376
  );
377
- let E = L;
377
+ let E = W;
378
378
  return a ? E = a.renderPlaceholder({
379
- fallback: L,
379
+ fallback: W,
380
380
  forceUpdate: X,
381
381
  onSuccess: _,
382
382
  onError: K
383
- }) : E = L, /* @__PURE__ */ p(
383
+ }) : E = W, /* @__PURE__ */ p(
384
384
  i,
385
385
  {
386
386
  ref: ee,
@@ -394,11 +394,11 @@ function ce({
394
394
  maxWidth: "100%",
395
395
  width: (
396
396
  // eslint-disable-next-line no-nested-ternary
397
- f === "drawer" ? "100%" : m || C || r ? rt : U
397
+ m === "drawer" ? "100%" : d || C || r ? rt : U
398
398
  ),
399
399
  transition: "width 0.2s ease-in-out",
400
400
  margin: "auto",
401
- p: W ? 2 : 3,
401
+ p: L ? 2 : 3,
402
402
  pb: 0,
403
403
  gap: 2
404
404
  },
@@ -453,8 +453,8 @@ ce.propTypes = {
453
453
  magicToken: e.string,
454
454
  customItems: e.arrayOf(e.node)
455
455
  };
456
- function le({ testOnlyBorderColor: b = void 0, ...f }) {
457
- const { checkFn: k, extraParams: h = {}, blocklet: S, masterBlocklet: I, action: D, locale: P = "en" } = f;
456
+ function le({ testOnlyBorderColor: x = void 0, ...m }) {
457
+ const { checkFn: k, extraParams: h = {}, blocklet: S, masterBlocklet: I, action: D, locale: P = "en" } = m;
458
458
  if (typeof k != "function")
459
459
  throw new Error("Cannot initialize did connect component without a fetchFn");
460
460
  return /* @__PURE__ */ t(
@@ -465,7 +465,7 @@ function le({ testOnlyBorderColor: b = void 0, ...f }) {
465
465
  action: D,
466
466
  locale: P,
467
467
  extraParams: h,
468
- testOnlyBorderColor: b,
468
+ testOnlyBorderColor: x,
469
469
  sx: {
470
470
  position: "relative",
471
471
  width: "100%",
@@ -478,7 +478,7 @@ function le({ testOnlyBorderColor: b = void 0, ...f }) {
478
478
  boxSizing: "border-box"
479
479
  }
480
480
  },
481
- children: /* @__PURE__ */ t(ce, { ...f })
481
+ children: /* @__PURE__ */ t(ce, { ...m })
482
482
  }
483
483
  );
484
484
  }
@@ -1,24 +1,24 @@
1
- import { jsxs as l, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as l, jsx as o, Fragment as L } from "react/jsx-runtime";
2
2
  import c from "prop-types";
3
- import { useState as W, useImperativeHandle as H } from "react";
3
+ import { useState as G, useImperativeHandle as N } from "react";
4
4
  import p from "@emotion/styled";
5
- import { Dialog as K, DialogTitle as L, DialogContent as G, DialogActions as N, Alert as Y, TextField as F, Stack as J, Box as Q, Button as x, CircularProgress as M } from "@mui/material";
5
+ import { Dialog as Y, DialogTitle as J, DialogContent as Q, DialogActions as U, Alert as X, TextField as j, Stack as Z, Box as z, Button as k, CircularProgress as A } from "@mui/material";
6
6
  import m from "validator/lib/isEmail";
7
- import { Icon as U } from "@iconify/react";
8
- import X from "@iconify-icons/material-symbols/passkey-rounded";
7
+ import { Icon as ee } from "@iconify/react";
8
+ import te from "@iconify-icons/material-symbols/passkey-rounded";
9
9
  import { useMemoizedFn as d } from "ahooks";
10
- import k from "@arcblock/ux/lib/Toast";
10
+ import S from "@arcblock/ux/lib/Toast";
11
11
  import b from "@arcblock/ux/lib/Typography";
12
- import { getCookieOptions as Z } from "@arcblock/ux/lib/Util";
12
+ import { getCookieOptions as re } from "@arcblock/ux/lib/Util";
13
13
  import g from "lodash/trim";
14
- import ee from "base64-url";
15
- import S from "js-cookie";
16
- import z from "lodash/noop";
17
- import { usePasskey as te } from "./context.js";
18
- import { getWebAuthnErrorMessage as j } from "../utils.js";
19
- import { VERIFY_CODE_LENGTH as $ } from "./constants.js";
20
- function re({ ref: y, extraParams: w = {}, createMode: D = "connect", action: C, onSuccess: P = z, onError: A = z }) {
21
- const { api: E, locale: I, t: i, loginPasskey: _, logoutPasskey: q, passkeyState: e, connectPasskey: R } = te(), a = D === "register", [T, s] = W(!1), B = d(() => {
14
+ import ie from "base64-url";
15
+ import w from "js-cookie";
16
+ import $ from "lodash/noop";
17
+ import { usePasskey as oe } from "./context.js";
18
+ import { getWebAuthnErrorMessage as _ } from "../utils.js";
19
+ import { VERIFY_CODE_LENGTH as q } from "./constants.js";
20
+ function ne({ ref: y, extraParams: C = {}, createMode: D = "connect", action: P, onSuccess: I = $, onError: R = $ }) {
21
+ const { api: E, locale: T, t: i, loginPasskey: V, logoutPasskey: O, passkeyState: e, connectPasskey: W } = oe(), a = D === "register", [F, s] = G(!1), h = window.innerWidth < 600, B = d(() => {
22
22
  e.openDialog = !0, e.error = "", e.creatingStatus = "", e.verifyingStatus = "";
23
23
  const t = e.email;
24
24
  s(t && a ? !m(t) : !1);
@@ -26,88 +26,118 @@ function re({ ref: y, extraParams: w = {}, createMode: D = "connect", action: C,
26
26
  e.openDialog = !1, e.error = "", e.creatingStatus = "", e.verifyingStatus = "";
27
27
  const t = e.email;
28
28
  s(t && a ? !m(t) : !1);
29
- }), V = d(async (t) => {
29
+ }), H = d(async (t) => {
30
30
  if (t.preventDefault(), a && !m(e.email)) {
31
31
  s(!0);
32
32
  return;
33
33
  }
34
34
  s(!1), e.loading = !0;
35
35
  try {
36
- await E.post(`../kyc/email/send?locale=${I}`, { email: e.email }), e.sent = !0, k.success(i("codeSentSuccess"));
36
+ await E.post(`../kyc/email/send?locale=${T}`, { email: e.email }), e.sent = !0, S.success(i("codeSentSuccess"));
37
37
  } catch (r) {
38
- k.error(r.message), document.getElementById("email-input")?.focus();
38
+ S.error(r.message), document.getElementById("email-input")?.focus();
39
39
  } finally {
40
40
  e.loading = !1;
41
41
  }
42
- }), O = d(async (t = "") => {
42
+ }), K = d(async (t = "") => {
43
43
  try {
44
44
  e.verifying = !0, e.error = "", t || (e.verifyingStatus = "");
45
- const r = await _({
46
- ...w,
47
- action: C,
45
+ const r = await V({
46
+ ...C,
47
+ action: P,
48
48
  credentialId: t
49
- }), n = Z({ expireInDays: 7 });
50
- S.remove("connected_did", n), S.remove("connected_pk", n), S.remove("connected_wallet_os", n), e.verifying = !1, r?.sessionToken && (e.verifyingStatus = "succeed", P({ ...r, encrypted: !1 }, (f) => f));
49
+ }), n = re({ expireInDays: 7 });
50
+ w.remove("connected_did", n), w.remove("connected_pk", n), w.remove("connected_wallet_os", n), e.verifying = !1, r?.sessionToken && (e.verifyingStatus = "succeed", I({ ...r, encrypted: !1 }, (f) => f));
51
51
  } catch (r) {
52
52
  console.error("Failed to verify passkey", r);
53
- const n = j(r, i("verifyPasskeyFailed"));
54
- e.verifying = !1, e.error = n, e.verifyingStatus = "error", await q(), A(new Error(n));
53
+ const n = _(r, i("verifyPasskeyFailed"));
54
+ e.verifying = !1, e.error = n, e.verifyingStatus = "error", await O(), R(new Error(n));
55
55
  }
56
- }), h = d(async () => {
56
+ }), x = d(async () => {
57
57
  if (a && !m(e.email)) {
58
58
  s(!0);
59
59
  return;
60
60
  }
61
61
  s(!1), e.creating = !0, e.error = "", e.creatingStatus = "";
62
62
  try {
63
- const t = await R({
64
- ...w,
65
- action: C,
63
+ const t = await W({
64
+ ...C,
65
+ action: P,
66
66
  purpose: a ? "register" : "connect",
67
- email: a ? ee.encode(e.email) : ""
67
+ email: a ? ie.encode(e.email) : ""
68
68
  });
69
69
  if (!t) {
70
70
  e.error = i("cancelAuth"), e.creatingStatus = "error", e.creating = !1, e.verifying = !1, e.verifyingStatus = "";
71
71
  return;
72
72
  }
73
- e.creating = !1, e.openDialog = !1, e.creatingStatus = "succeed", D === "connect" ? P({ ...t, encrypted: !1 }, (r) => r) : t?.credentialId && O(t.credentialId);
73
+ e.creating = !1, e.openDialog = !1, e.creatingStatus = "succeed", D === "connect" ? I({ ...t, encrypted: !1 }, (r) => r) : t?.credentialId && K(t.credentialId);
74
74
  } catch (t) {
75
- console.error("Failed to create passkey", t), e.creating = !1, e.error = j(t, i("createPasskeyFailed")), e.creatingStatus = "error";
75
+ console.error("Failed to create passkey", t), e.creating = !1, e.error = _(t, i("createPasskeyFailed")), e.creatingStatus = "error";
76
76
  }
77
77
  }), v = d(async (t) => {
78
78
  t && t.preventDefault(), e.loading = !0;
79
79
  try {
80
- await E.post(`../kyc/email/verify?locale=${I}`, { code: e.code }), e.verified = !0, h();
80
+ await E.post(`../kyc/email/verify?locale=${T}`, { code: e.code }), e.verified = !0, x();
81
81
  } catch (r) {
82
- k.error(r.message), e.verified = !1, document.getElementById(`code-input-${g(e.code).length - 1}`)?.focus();
82
+ S.error(r.message), e.verified = !1, document.getElementById(`code-input-${g(e.code).length - 1}`)?.focus();
83
83
  } finally {
84
84
  e.loading = !1;
85
85
  }
86
86
  });
87
- return H(y, () => ({
87
+ N(y, () => ({
88
88
  open: B,
89
89
  close: u,
90
90
  handleVerifyCode: v
91
- }), [B, u, v]), /* @__PURE__ */ l(
92
- ie,
91
+ }), [B, u, v]);
92
+ const M = () => /* @__PURE__ */ l(L, { children: [
93
+ /* @__PURE__ */ o(k, { onClick: u, sx: { color: "text.secondary" }, children: i("cancel") }),
94
+ a && /* @__PURE__ */ l(
95
+ k,
96
+ {
97
+ variant: "contained",
98
+ onClick: (
99
+ // eslint-disable-next-line no-nested-ternary
100
+ e.verified ? x : e.sent ? v : H
101
+ ),
102
+ disabled: e.verifying || e.creating || !e.email || e.sent && g(e.code).length !== q,
103
+ children: [
104
+ (e.loading || e.creating) && /* @__PURE__ */ o(A, { size: 16, sx: { mr: 1 } }),
105
+ e.verified ? i("createPasskey") : e.sent ? i("verifyButton") : i("sendCodeButton")
106
+ ]
107
+ }
108
+ ),
109
+ !a && /* @__PURE__ */ o(
110
+ k,
111
+ {
112
+ variant: "contained",
113
+ color: "primary",
114
+ onClick: x,
115
+ disabled: e.loading || e.creating || a && (!e.email || !e.verified),
116
+ startIcon: (e.loading || e.creating) && /* @__PURE__ */ o(A, { size: 16, sx: { mr: 1 }, color: "inherit" }),
117
+ children: e.loading || e.creating ? i("creatingPasskey") : i("createPasskey")
118
+ }
119
+ )
120
+ ] });
121
+ return /* @__PURE__ */ l(
122
+ ae,
93
123
  {
94
124
  open: e.openDialog,
95
125
  onClose: u,
96
126
  fullWidth: !0,
97
127
  maxWidth: "sm",
98
- fullScreen: window.innerWidth < 600,
128
+ fullScreen: h,
99
129
  children: [
100
- /* @__PURE__ */ l(oe, { children: [
101
- /* @__PURE__ */ o(se, { children: /* @__PURE__ */ o(U, { icon: X, fontSize: 24, color: "initial" }) }),
130
+ /* @__PURE__ */ l(se, { children: [
131
+ /* @__PURE__ */ o(de, { children: /* @__PURE__ */ o(ee, { icon: te, fontSize: 24, color: "initial" }) }),
102
132
  i("createPasskey")
103
133
  ] }),
104
- /* @__PURE__ */ l(ne, { children: [
134
+ /* @__PURE__ */ l(le, { children: [
105
135
  /* @__PURE__ */ o(b, { variant: "body1", children: i("createPasskeyDesc1") }),
106
136
  /* @__PURE__ */ o(b, { variant: "body1", children: i("createPasskeyDesc2") }),
107
- e.error && /* @__PURE__ */ o(Y, { severity: "error", children: e.error }),
108
- a && /* @__PURE__ */ l(le, { children: [
137
+ e.error && /* @__PURE__ */ o(X, { severity: "error", children: e.error }),
138
+ a && /* @__PURE__ */ l(pe, { children: [
109
139
  !e.sent && /* @__PURE__ */ o(
110
- F,
140
+ j,
111
141
  {
112
142
  type: "email",
113
143
  id: "email-input",
@@ -120,12 +150,12 @@ function re({ ref: y, extraParams: w = {}, createMode: D = "connect", action: C,
120
150
  },
121
151
  disabled: e.loading || e.creating,
122
152
  required: !0,
123
- error: T,
124
- helperText: T ? i("emailInvalid") : ""
153
+ error: F,
154
+ helperText: F ? i("emailInvalid") : ""
125
155
  }
126
156
  ),
127
157
  e.sent && !e.verified && /* @__PURE__ */ l(
128
- J,
158
+ Z,
129
159
  {
130
160
  direction: "column",
131
161
  sx: {
@@ -135,8 +165,8 @@ function re({ ref: y, extraParams: w = {}, createMode: D = "connect", action: C,
135
165
  },
136
166
  children: [
137
167
  /* @__PURE__ */ o(b, { variant: "body2", children: i("codeSentMessage", { email: e.email }) }),
138
- /* @__PURE__ */ o(Q, { sx: { width: "100%", display: "flex", justifyContent: "space-between", gap: 2, mt: 0 }, children: Array($).fill("").map((t, r) => /* @__PURE__ */ o(
139
- F,
168
+ /* @__PURE__ */ o(z, { sx: { width: "100%", display: "flex", justifyContent: "space-between", gap: 2, mt: 0 }, children: Array(q).fill("").map((t, r) => /* @__PURE__ */ o(
169
+ j,
140
170
  {
141
171
  value: g(e.code[r]) || "",
142
172
  type: "number",
@@ -165,42 +195,15 @@ function re({ ref: y, extraParams: w = {}, createMode: D = "connect", action: C,
165
195
  ]
166
196
  }
167
197
  )
168
- ] })
198
+ ] }),
199
+ h && /* @__PURE__ */ o(z, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center", mt: 2 }, children: M() })
169
200
  ] }),
170
- /* @__PURE__ */ l(ae, { children: [
171
- /* @__PURE__ */ o(x, { onClick: u, sx: { color: "text.secondary" }, children: i("cancel") }),
172
- a && /* @__PURE__ */ l(
173
- x,
174
- {
175
- variant: "contained",
176
- onClick: (
177
- // eslint-disable-next-line no-nested-ternary
178
- e.verified ? h : e.sent ? v : V
179
- ),
180
- disabled: e.verifying || e.creating || !e.email || e.sent && g(e.code).length !== $,
181
- children: [
182
- (e.loading || e.creating) && /* @__PURE__ */ o(M, { size: 16, sx: { mr: 1 } }),
183
- e.verified ? i("createPasskey") : e.sent ? i("verifyButton") : i("sendCodeButton")
184
- ]
185
- }
186
- ),
187
- !a && /* @__PURE__ */ o(
188
- x,
189
- {
190
- variant: "contained",
191
- color: "primary",
192
- onClick: h,
193
- disabled: e.loading || e.creating || a && (!e.email || !e.verified),
194
- startIcon: (e.loading || e.creating) && /* @__PURE__ */ o(M, { size: 16, sx: { mr: 1 }, color: "inherit" }),
195
- children: e.loading || e.creating ? i("creatingPasskey") : i("createPasskey")
196
- }
197
- )
198
- ] })
201
+ !h && /* @__PURE__ */ o(ce, { children: M() })
199
202
  ]
200
203
  }
201
204
  );
202
205
  }
203
- re.propTypes = {
206
+ ne.propTypes = {
204
207
  extraParams: c.object,
205
208
  createMode: c.string,
206
209
  action: c.string.isRequired,
@@ -208,17 +211,17 @@ re.propTypes = {
208
211
  onError: c.func,
209
212
  ref: c.any.isRequired
210
213
  };
211
- const ie = p(K)`
214
+ const ae = p(Y)`
212
215
  .MuiDialog-paper {
213
216
  border-radius: 12px;
214
217
  max-width: 440px;
215
218
  }
216
- `, oe = p(L)`
219
+ `, se = p(J)`
217
220
  text-align: center;
218
221
  padding: 24px 24px 16px;
219
222
  font-size: 20px;
220
223
  font-weight: 600;
221
- `, ne = p(G)`
224
+ `, le = p(Q)`
222
225
  padding: 0 24px;
223
226
 
224
227
  .MuiTypography-body1 {
@@ -231,7 +234,7 @@ const ie = p(K)`
231
234
  margin-top: 16px;
232
235
  width: 100%;
233
236
  }
234
- `, ae = p(N)`
237
+ `, ce = p(U)`
235
238
  text-align: center;
236
239
  padding: 16px 24px 24px;
237
240
 
@@ -241,7 +244,7 @@ const ie = p(K)`
241
244
  border-radius: 6px;
242
245
  padding: 6px 16px;
243
246
  }
244
- `, se = p("div")`
247
+ `, de = p("div")`
245
248
  width: 48px;
246
249
  height: 48px;
247
250
  margin: 0 auto 16px;
@@ -255,7 +258,7 @@ const ie = p(K)`
255
258
  width: 32px;
256
259
  height: 32px;
257
260
  }
258
- `, le = p.div`
261
+ `, pe = p.div`
259
262
  display: flex;
260
263
  flex-direction: column;
261
264
  align-items: center;
@@ -273,5 +276,5 @@ const ie = p(K)`
273
276
  }
274
277
  `;
275
278
  export {
276
- re as default
279
+ ne as default
277
280
  };
@@ -1,4 +1,4 @@
1
- const o = "3.2.7", s = {
1
+ const o = "3.2.8", s = {
2
2
  version: o
3
3
  };
4
4
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/did-connect-react",
3
- "version": "3.2.7",
3
+ "version": "3.2.8",
4
4
  "description": "Client side library to work with DID Connect by ArcBlock.",
5
5
  "keywords": [
6
6
  "react",
@@ -32,10 +32,10 @@
32
32
  "url": "https://github.com/ArcBlock/ux/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@arcblock/bridge": "3.2.7",
35
+ "@arcblock/bridge": "3.2.8",
36
36
  "@arcblock/did": "^1.27.6",
37
- "@arcblock/icons": "3.2.7",
38
- "@arcblock/react-hooks": "3.2.7",
37
+ "@arcblock/icons": "3.2.8",
38
+ "@arcblock/react-hooks": "3.2.8",
39
39
  "@arcblock/ws": "^1.27.6",
40
40
  "@fontsource/lexend": "^5.2.9",
41
41
  "@iconify-icons/logos": "^1.2.36",
@@ -80,5 +80,5 @@
80
80
  "eslint-plugin-react-hooks": "^4.6.2",
81
81
  "jest": "^29.7.0"
82
82
  },
83
- "gitHead": "756a9f08c4008f45690ef38e612e1c429855948d"
83
+ "gitHead": "c3986ded30e94992b83a628e4ffc73c99e630b5d"
84
84
  }
@@ -158,7 +158,7 @@ export default function ConnectChooseList({
158
158
  gap: 1.5,
159
159
  },
160
160
  ]}>
161
- {showMobileLogin && size !== 'small' && (
161
+ {showMobileLogin && (
162
162
  <MobileLoginItem
163
163
  ref={walletLoginRef}
164
164
  tokenState={tokenState}
@@ -454,7 +454,7 @@ function Connect({
454
454
  extraContent={extraContent}
455
455
  enabledConnectTypes={enabledConnectTypes}
456
456
  onRest={handleReset}
457
- showMobileLogin={showMobileLogin}
457
+ showMobileLogin={showMobileLogin && hideQRCode}
458
458
  showOAuthLogin={showOAuthLogin}
459
459
  showPasskeyLogin={showPasskeyLogin}
460
460
  showWebLogin={showWebLogin}
@@ -33,6 +33,7 @@ function PasskeyDialog({ ref, extraParams = {}, createMode = 'connect', action,
33
33
  const { api, locale, t, loginPasskey, logoutPasskey, passkeyState, connectPasskey } = usePasskey();
34
34
  const isEmailRequired = createMode === 'register';
35
35
  const [isEmailVerified, setIsEmailVerified] = useState(false);
36
+ const isFullScreen = window.innerWidth < 600;
36
37
  const handleOpenDialog = useMemoizedFn(() => {
37
38
  passkeyState.openDialog = true;
38
39
  passkeyState.error = '';
@@ -172,13 +173,59 @@ function PasskeyDialog({ ref, extraParams = {}, createMode = 'connect', action,
172
173
  };
173
174
  }, [handleOpenDialog, handleCloseDialog, handleVerifyCode]);
174
175
 
176
+ const renderActions = () => {
177
+ return (
178
+ <>
179
+ <Button onClick={handleCloseDialog} sx={{ color: 'text.secondary' }}>
180
+ {t('cancel')}
181
+ </Button>
182
+ {isEmailRequired && (
183
+ <Button
184
+ variant="contained"
185
+ onClick={
186
+ // eslint-disable-next-line no-nested-ternary
187
+ passkeyState.verified ? handleCreatePasskey : passkeyState.sent ? handleVerifyCode : handleSendCode
188
+ }
189
+ disabled={
190
+ passkeyState.verifying ||
191
+ passkeyState.creating ||
192
+ !passkeyState.email ||
193
+ (passkeyState.sent && trim(passkeyState.code).length !== VERIFY_CODE_LENGTH)
194
+ }>
195
+ {(passkeyState.loading || passkeyState.creating) && <CircularProgress size={16} sx={{ mr: 1 }} />}
196
+ {/* eslint-disable-next-line no-nested-ternary */}
197
+ {passkeyState.verified ? t('createPasskey') : passkeyState.sent ? t('verifyButton') : t('sendCodeButton')}
198
+ </Button>
199
+ )}
200
+ {!isEmailRequired && (
201
+ <Button
202
+ variant="contained"
203
+ color="primary"
204
+ onClick={handleCreatePasskey}
205
+ disabled={
206
+ passkeyState.loading ||
207
+ passkeyState.creating ||
208
+ (isEmailRequired && (!passkeyState.email || !passkeyState.verified))
209
+ }
210
+ startIcon={
211
+ (passkeyState.loading || passkeyState.creating) && (
212
+ <CircularProgress size={16} sx={{ mr: 1 }} color="inherit" />
213
+ )
214
+ }>
215
+ {passkeyState.loading || passkeyState.creating ? t('creatingPasskey') : t('createPasskey')}
216
+ </Button>
217
+ )}
218
+ </>
219
+ );
220
+ };
221
+
175
222
  return (
176
223
  <StyledDialog
177
224
  open={passkeyState.openDialog}
178
225
  onClose={handleCloseDialog}
179
226
  fullWidth
180
227
  maxWidth="sm"
181
- fullScreen={window.innerWidth < 600}>
228
+ fullScreen={isFullScreen}>
182
229
  <StyledDialogTitle>
183
230
  <KeyIcon>
184
231
  <Icon icon={passKeyRoundedIcon} fontSize={24} color="initial" />
@@ -259,48 +306,11 @@ function PasskeyDialog({ ref, extraParams = {}, createMode = 'connect', action,
259
306
  )}
260
307
  </Form>
261
308
  )}
262
- </StyledDialogContent>
263
- <StyledDialogActions>
264
- <Button onClick={handleCloseDialog} sx={{ color: 'text.secondary' }}>
265
- {t('cancel')}
266
- </Button>
267
- {isEmailRequired && (
268
- <Button
269
- variant="contained"
270
- onClick={
271
- // eslint-disable-next-line no-nested-ternary
272
- passkeyState.verified ? handleCreatePasskey : passkeyState.sent ? handleVerifyCode : handleSendCode
273
- }
274
- disabled={
275
- passkeyState.verifying ||
276
- passkeyState.creating ||
277
- !passkeyState.email ||
278
- (passkeyState.sent && trim(passkeyState.code).length !== VERIFY_CODE_LENGTH)
279
- }>
280
- {(passkeyState.loading || passkeyState.creating) && <CircularProgress size={16} sx={{ mr: 1 }} />}
281
- {/* eslint-disable-next-line no-nested-ternary */}
282
- {passkeyState.verified ? t('createPasskey') : passkeyState.sent ? t('verifyButton') : t('sendCodeButton')}
283
- </Button>
284
- )}
285
- {!isEmailRequired && (
286
- <Button
287
- variant="contained"
288
- color="primary"
289
- onClick={handleCreatePasskey}
290
- disabled={
291
- passkeyState.loading ||
292
- passkeyState.creating ||
293
- (isEmailRequired && (!passkeyState.email || !passkeyState.verified))
294
- }
295
- startIcon={
296
- (passkeyState.loading || passkeyState.creating) && (
297
- <CircularProgress size={16} sx={{ mr: 1 }} color="inherit" />
298
- )
299
- }>
300
- {passkeyState.loading || passkeyState.creating ? t('creatingPasskey') : t('createPasskey')}
301
- </Button>
309
+ {isFullScreen && (
310
+ <Box sx={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center', mt: 2 }}>{renderActions()}</Box>
302
311
  )}
303
- </StyledDialogActions>
312
+ </StyledDialogContent>
313
+ {!isFullScreen && <StyledDialogActions>{renderActions()}</StyledDialogActions>}
304
314
  </StyledDialog>
305
315
  );
306
316
  }