@arcblock/did-connect-react 3.3.0 → 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.
@@ -1,68 +1,68 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
2
  import r from "prop-types";
3
3
  import { CircularProgress as C } from "@mui/material";
4
- import { useReactive as R, useMemoizedFn as c, useCreation as p } from "ahooks";
5
- import { detectWalletExtension as w, openWebWallet as L } from "@arcblock/ux/lib/Util";
6
- import { mergeSx as v } from "@arcblock/ux/lib/Util/style";
7
- import y from "lodash/noop";
8
- import A from "lodash/omit";
9
- import { useImperativeHandle as P } from "react";
10
- import E from "@arcblock/ux/lib/DIDConnect/provider-icon";
11
- import { LOGIN_PROVIDER as T } from "@arcblock/ux/lib/Util/constant";
12
- import _ from "./login-method-item.js";
13
- import { useStateContext as O } from "../../contexts/state.js";
14
- import { EXT_DOWNLOAD_URL as d } from "../../../constant.js";
4
+ import { useReactive as L, useMemoizedFn as d, useCreation as p } from "ahooks";
5
+ import { detectWalletExtension as _, openWebWallet as w } from "@arcblock/ux/lib/Util";
6
+ import { mergeSx as E } from "@arcblock/ux/lib/Util/style";
7
+ import O from "lodash/noop";
8
+ import P from "lodash/omit";
9
+ import { useImperativeHandle as v } from "react";
10
+ import A from "@arcblock/ux/lib/DIDConnect/provider-icon";
11
+ import { LOGIN_PROVIDER_ICON_SIZE as a, LOGIN_PROVIDER as y } from "@arcblock/ux/lib/Util/constant";
12
+ import T from "./login-method-item.js";
13
+ import { useStateContext as N } from "../../contexts/state.js";
14
+ import { EXT_DOWNLOAD_URL as I } from "../../../constant.js";
15
15
  import U from "../../hooks/auth-url.js";
16
16
  function j({
17
- ref: x = null,
17
+ ref: g = null,
18
18
  tokenState: o,
19
- locale: g = "en",
19
+ locale: x = "en",
20
20
  webWalletUrl: b,
21
- onClick: I = y,
21
+ onClick: D = O,
22
22
  disableSwitchApp: h = !1,
23
- ...a
23
+ ...f
24
24
  }) {
25
- const { browserBrand: i } = O(), l = w(), t = R({
25
+ const { browserBrand: i } = N(), l = _(), t = L({
26
26
  loading: !1
27
- }), D = U({ disableSwitchApp: h, tokenState: o }), f = c(() => {
28
- t.loading = !0, L({
27
+ }), W = U({ disableSwitchApp: h, tokenState: o }), u = d(() => {
28
+ t.loading = !0, w({
29
29
  webWalletUrl: b,
30
- url: D,
31
- locale: g,
30
+ url: W,
31
+ locale: x,
32
32
  appInfo: o.appInfo,
33
33
  memberAppInfo: o.memberAppInfo
34
34
  })?.type === "web" ? t.loading = !1 : setTimeout(() => {
35
35
  t.loading = !1;
36
36
  }, 3e3);
37
- }), s = c((e) => {
38
- o.url && (I(e), e?.preventDefault(), f());
37
+ }), s = d((e) => {
38
+ o.url && (D(e), e?.preventDefault(), u());
39
39
  });
40
- P(x, () => ({
41
- connect: f
40
+ v(g, () => ({
41
+ connect: u
42
42
  }));
43
- const n = p(() => i === "edge" ? d.edge : i === "chrome" ? d.chrome : null, [i]), u = p(() => {
43
+ const n = p(() => i === "edge" ? I.edge : i === "chrome" ? I.chrome : null, [i]), c = p(() => {
44
44
  const e = {};
45
45
  return l ? e.onClick = s : n ? (e.component = "a", e.href = n, e.target = "_blank", e.rel = "noopener") : e.onClick = s, o.url || (e.sx = {
46
46
  cursor: "not-allowed"
47
47
  }), e;
48
- }, [s, o.url]), W = p(() => l || n ? "DID Wallet (Extension)" : "DID Wallet (Web)", [l, n]);
48
+ }, [s, o.url]), R = p(() => l || n ? "DID Wallet (Extension)" : "DID Wallet (Web)", [l, n]);
49
49
  return /* @__PURE__ */ m(
50
- _,
50
+ T,
51
51
  {
52
- ...a,
53
- sx: v(
52
+ ...f,
53
+ sx: E(
54
54
  {
55
55
  textDecoration: "none"
56
56
  },
57
- a?.sx,
58
- u.sx
57
+ f?.sx,
58
+ c.sx
59
59
  ),
60
- title: W,
60
+ title: R,
61
61
  icon: t.loading || !o.url ? /* @__PURE__ */ m(
62
62
  C,
63
63
  {
64
64
  color: "primary",
65
- size: 24,
65
+ size: a,
66
66
  sx: {
67
67
  "& svg": {
68
68
  transform: "scale(0.75)"
@@ -70,17 +70,17 @@ function j({
70
70
  }
71
71
  }
72
72
  ) : /* @__PURE__ */ m(
73
- E,
73
+ A,
74
74
  {
75
- width: "24px",
76
- height: "24px",
77
- provider: T.DID_WALLET,
78
- style: {
75
+ sx: {
76
+ width: a,
77
+ height: a,
79
78
  transform: "scale(0.9)"
80
- }
79
+ },
80
+ provider: y.DID_WALLET
81
81
  }
82
82
  ),
83
- ...A(u, "sx")
83
+ ...P(c, "sx")
84
84
  }
85
85
  );
86
86
  }
@@ -2,11 +2,11 @@ import { jsx as t, jsxs as p, Fragment as Le } from "react/jsx-runtime";
2
2
  import { use as Be, useRef as re, useState as Fe, useEffect as ne } from "react";
3
3
  import e from "prop-types";
4
4
  import { Box as i, Skeleton as Ne, Divider as je } from "@mui/material";
5
- import { useUpdate as He, useSize as Ve, useCreation as d, useMount as ie, useMemoizedFn as z, useDebounceFn as qe, usePrevious as Ye, useUpdateEffect as Ge } from "ahooks";
5
+ import { useUpdate as He, useSize as Ve, useCreation as d, useMount as ie, useMemoizedFn as U, useDebounceFn as qe, usePrevious as Ye, useUpdateEffect as Ge } from "ahooks";
6
6
  import b from "lodash/noop";
7
7
  import Ke from "lodash/isUndefined";
8
8
  import Qe from "@arcblock/ux/lib/CloseButton";
9
- import { LOGIN_PROVIDER as Xe, OAUTH_PROVIDER as L, DID_CONNECT_MEDIUM_WIDTH as M, LOGIN_PROVIDER_NAME as Je, DID_CONNECT_SMALL_WIDTH as Ze } from "@arcblock/ux/lib/Util/constant";
9
+ import { LOGIN_PROVIDER as Xe, OAUTH_PROVIDER as M, DID_CONNECT_MEDIUM_WIDTH as z, LOGIN_PROVIDER_NAME as Je, DID_CONNECT_SMALL_WIDTH as Ze } from "@arcblock/ux/lib/Util/constant";
10
10
  import $e from "@arcblock/ux/lib/QRCode";
11
11
  import { withUxTheme as et, withContainer as tt, DIDConnectFooter as ot } from "@arcblock/ux/lib/DIDConnect";
12
12
  import { useTheme as rt } from "@arcblock/ux/lib/Theme";
@@ -41,31 +41,31 @@ function se({
41
41
  checkInterval: I = xt,
42
42
  checkTimeout: v = gt * 1e3,
43
43
  prefix: D = bt,
44
- tokenKey: B = "_t_",
45
- locale: F = "en",
44
+ tokenKey: L = "_t_",
45
+ locale: B = "en",
46
46
  encKey: ae = "_ek_",
47
47
  autoConnect: le = !0,
48
- forceConnected: N = !0,
48
+ forceConnected: F = !0,
49
49
  saveConnect: ue = !0,
50
50
  useSocket: de = !0,
51
- allowWallet: j = !0,
51
+ allowWallet: N = !0,
52
52
  provider: fe = "",
53
53
  messages: u = {},
54
- passkeyBehavior: H = "none",
54
+ passkeyBehavior: j = "none",
55
55
  webWalletUrl: me = It(),
56
- enabledConnectTypes: pe = ["web", "mobile", ...Object.keys(L)],
57
- extraContent: V = null,
56
+ enabledConnectTypes: pe = ["web", "mobile", ...Object.keys(M)],
57
+ extraContent: H = null,
58
58
  disableSwitchApp: T = !1,
59
- magicToken: q = void 0,
59
+ magicToken: V = void 0,
60
60
  customItems: he = [],
61
61
  onClose: P = b,
62
- onError: Y = b,
62
+ onError: q = b,
63
63
  onSuccess: _ = b,
64
- onRecreateSession: G = b,
64
+ onRecreateSession: Y = b,
65
65
  setColor: xe = b
66
66
  }) {
67
- const R = rt(), K = He(), be = Be(ct), ge = St(be?.session?.user), {
68
- t: Q,
67
+ const R = rt(), G = He(), be = Be(ct), ge = St(be?.session?.user), {
68
+ t: K,
69
69
  staticState: Ce,
70
70
  connectState: s,
71
71
  extraParams: ye,
@@ -73,9 +73,9 @@ function se({
73
73
  currentAppColor: O,
74
74
  // 插件相关
75
75
  selectedPlugin: c,
76
- blocklet: X,
76
+ blocklet: Q,
77
77
  masterBlocklet: we
78
- } = lt(), { state: o, generate: J, cancelWhenScanned: Se } = ft({
78
+ } = lt(), { state: o, generate: X, cancelWhenScanned: Se } = ft({
79
79
  action: w,
80
80
  baseUrl: h,
81
81
  checkFn: S,
@@ -83,23 +83,23 @@ function se({
83
83
  checkTimeout: v,
84
84
  extraParams: ye,
85
85
  prefix: D,
86
- onError: Y,
86
+ onError: q,
87
87
  onSuccess: _,
88
- locale: F,
89
- tokenKey: B,
88
+ locale: B,
89
+ tokenKey: L,
90
90
  encKey: ae,
91
91
  autoConnect: le,
92
- forceConnected: N === !0 ? ge || !0 : N,
92
+ forceConnected: F === !0 ? ge || !0 : F,
93
93
  saveConnect: ue,
94
94
  useSocket: de,
95
95
  provider: fe
96
- }), A = re(!1), Z = re(null), x = Ve(Z), W = d(() => x ? x.width < M - 50 : !0, [x, x?.width]), [$, Ie] = Fe(!1);
96
+ }), A = re(!1), J = re(null), x = Ve(J), Z = d(() => x ? x.width < z - 50 : !0, [x, x?.width]), [$, Ie] = Fe(!1);
97
97
  ie(() => {
98
- Ie(x?.width < M - 50);
98
+ Ie(x?.width < z - 50);
99
99
  });
100
100
  const { oauthState: a, setBaseUrl: ve } = mt(), { passkeyState: l, setTargetAppPid: De } = ht();
101
101
  ie(() => {
102
- ve(h), De(X?.appPid), o.reset(), a.reset(), l.reset();
102
+ ve(h), De(Q?.appPid), o.reset(), a.reset(), l.reset();
103
103
  }), ne(() => {
104
104
  xe(O);
105
105
  }, [O]);
@@ -114,12 +114,12 @@ function se({
114
114
  a.error,
115
115
  l.error,
116
116
  c?.state?.error
117
- ]), C = d(() => k.includes(l.status) || k.includes(a.status) || k.includes(o.status) || k.includes(c?.state?.computedStatus), [o.status, a.status, l.status, c?.state?.computedStatus]), ee = z(async () => {
118
- G(), a.reset(), l.reset(), await J(!1);
119
- }), Pe = z(() => {
117
+ ]), C = d(() => k.includes(l.status) || k.includes(a.status) || k.includes(o.status) || k.includes(c?.state?.computedStatus), [o.status, a.status, l.status, c?.state?.computedStatus]), ee = U(async () => {
118
+ Y(), a.reset(), l.reset(), await X(!1);
119
+ }), Pe = U(() => {
120
120
  s?.retryConnect();
121
- }), _e = z(() => {
122
- G(), a.reset(), l.reset(), c?.state?.reset(), Ce.current.cancelCount++, Se();
121
+ }), _e = U(() => {
122
+ Y(), a.reset(), l.reset(), c?.state?.reset(), Ce.current.cancelCount++, Se();
123
123
  }), { run: Re } = qe(
124
124
  () => {
125
125
  A.current || o.status === "timeout" && (A.current = !0, o.reset(), ee(), A.current = !1);
@@ -130,14 +130,14 @@ function se({
130
130
  const Oe = d(() => Je[s.chooseMethod] || "DID Wallet", [s.chooseMethod]), { providerList: Ae, hideQRCode: m, hideChooseList: n } = kt({
131
131
  action: o.action,
132
132
  sourceAppPid: s?.sourceAppPid,
133
- allowWallet: j,
134
- passkeyBehavior: H,
133
+ allowWallet: N,
134
+ passkeyBehavior: j,
135
135
  mode: f,
136
- blocklet: s?.sourceAppPid ? we : X,
137
- isSmallView: W
136
+ blocklet: s?.sourceAppPid ? we : Q,
137
+ isSmallView: Z
138
138
  }), We = Ye(s?.sourceAppPid);
139
139
  Ge(() => {
140
- Ke(We) || J();
140
+ Ke(We) || X();
141
141
  }, [s?.sourceAppPid]);
142
142
  const r = (y) => {
143
143
  const Me = R.spacing(y);
@@ -173,12 +173,12 @@ function se({
173
173
  onRetry: Pe,
174
174
  onClose: P,
175
175
  messages: Te,
176
- locale: F,
176
+ locale: B,
177
177
  className: "did-connect__auth-status auth-status",
178
178
  loadingIcon: s.chooseMethod ? /* @__PURE__ */ t(nt, { provider: s.chooseMethod, sx: { color: "text.primary" } }) : null,
179
179
  chooseMethod: Oe,
180
180
  hideRetry: s.chooseMethod === "email",
181
- hideBack: !!q
181
+ hideBack: !!V
182
182
  }
183
183
  ) })
184
184
  }
@@ -237,7 +237,7 @@ function se({
237
237
  )
238
238
  }
239
239
  );
240
- }, [oe, n]), ze = d(() => n ? "column-reverse" : !m && $ ? "column" : "row", [n, $, m]), E = /* @__PURE__ */ p(
240
+ }, [oe, n]), ze = d(() => n ? "column-reverse" : !m && $ ? "column" : "row", [n, $, m]), W = /* @__PURE__ */ p(
241
241
  i,
242
242
  {
243
243
  className: "did-connect__body",
@@ -247,7 +247,7 @@ function se({
247
247
  justifyContent: "center",
248
248
  alignItems: "stretch",
249
249
  flex: 1,
250
- gap: !m && W ? 0 : 1.5,
250
+ gap: !m && Z ? 0 : 1.5,
251
251
  overflow: "visible",
252
252
  px: n ? 2 : 0
253
253
  },
@@ -288,11 +288,11 @@ function se({
288
288
  textAlign: "center"
289
289
  },
290
290
  children: [
291
- Q("scanWithWallet1"),
291
+ K("scanWithWallet1"),
292
292
  " ",
293
293
  /* @__PURE__ */ t(yt, {}),
294
294
  " ",
295
- Q("scanWithWallet2")
295
+ K("scanWithWallet2")
296
296
  ]
297
297
  }
298
298
  )
@@ -333,20 +333,20 @@ function se({
333
333
  sx: [C ? { display: "none" } : {}]
334
334
  }
335
335
  },
336
- allowWallet: j,
336
+ allowWallet: N,
337
337
  size: m && f !== "dialog" ? "normal" : "small",
338
338
  tokenState: o,
339
339
  messages: u,
340
- tokenKey: B,
340
+ tokenKey: L,
341
341
  onSuccess: _,
342
- passkeyBehavior: H,
342
+ passkeyBehavior: j,
343
343
  webWalletUrl: me,
344
- extraContent: V,
344
+ extraContent: H,
345
345
  enabledConnectTypes: pe,
346
346
  onReset: ee,
347
347
  disableSwitchApp: T,
348
- forceUpdate: K,
349
- magicToken: q,
348
+ forceUpdate: G,
349
+ magicToken: V,
350
350
  baseUrl: h,
351
351
  customItems: he,
352
352
  providerList: Ae
@@ -358,16 +358,16 @@ function se({
358
358
  ]
359
359
  }
360
360
  );
361
- let U = E;
362
- return c ? U = c.renderPlaceholder({
363
- fallback: E,
364
- forceUpdate: K,
361
+ let E = W;
362
+ return c ? E = c.renderPlaceholder({
363
+ fallback: W,
364
+ forceUpdate: G,
365
365
  onSuccess: _,
366
- onError: Y
367
- }) : U = E, /* @__PURE__ */ p(
366
+ onError: q
367
+ }) : E = W, /* @__PURE__ */ p(
368
368
  i,
369
369
  {
370
- ref: Z,
370
+ ref: J,
371
371
  className: "did-connect__root",
372
372
  sx: {
373
373
  backgroundColor: "background.default",
@@ -378,13 +378,13 @@ function se({
378
378
  maxWidth: "100%",
379
379
  width: (
380
380
  // eslint-disable-next-line no-nested-ternary
381
- f === "drawer" ? "100%" : m || C ? Ze : M
381
+ f === "drawer" ? "100%" : m || C ? Ze : z
382
382
  ),
383
383
  transition: "width 0.2s ease-in-out",
384
384
  margin: "auto",
385
- p: W ? 2 : 3,
385
+ p: 3,
386
386
  pb: 0,
387
- gap: 2
387
+ gap: 2.5
388
388
  },
389
389
  children: [
390
390
  /* @__PURE__ */ t(i, { "data-did-auth-url": o.url, sx: { display: "none" } }),
@@ -393,11 +393,11 @@ function se({
393
393
  {
394
394
  title: u.title,
395
395
  description: u.scan,
396
- extraContent: V,
396
+ extraContent: H,
397
397
  disableSwitchApp: T
398
398
  }
399
399
  ),
400
- /* @__PURE__ */ t(dt, { initHeight: 72, children: U }),
400
+ /* @__PURE__ */ t(dt, { initHeight: 72, children: E }),
401
401
  /* @__PURE__ */ t(ot, { currentAppInfo: ke, currentAppColor: O }),
402
402
  Ee
403
403
  ]
@@ -423,10 +423,10 @@ se.propTypes = {
423
423
  useSocket: e.bool,
424
424
  extraContent: e.any,
425
425
  passkeyBehavior: e.oneOf(["none", "both", "only-existing", "only-new"]),
426
- enabledConnectTypes: e.arrayOf(e.oneOf(["web", "mobile", ...Object.keys(L)])),
426
+ enabledConnectTypes: e.arrayOf(e.oneOf(["web", "mobile", ...Object.keys(M)])),
427
427
  webWalletUrl: e.string,
428
428
  allowWallet: e.bool,
429
- provider: e.oneOf([Xe.WALLET, ...Object.keys(L), ""]),
429
+ provider: e.oneOf([Xe.WALLET, ...Object.keys(M), ""]),
430
430
  hideCloseButton: e.bool,
431
431
  disableSwitchApp: e.bool,
432
432
  onClose: e.func,
@@ -1,24 +1,24 @@
1
1
  import { jsx as s } from "react/jsx-runtime";
2
2
  import c from "prop-types";
3
3
  import { useMemoizedFn as l } from "ahooks";
4
- import p from "@iconify-icons/material-symbols/mail-outline-rounded";
4
+ import p from "@iconify-icons/tabler/mail-filled";
5
5
  import { LOGIN_PROVIDER as o, LOGIN_PROVIDER_NAME as a } from "@arcblock/ux/lib/Util/constant";
6
- import { GA_LAST_LOGIN_METHOD as u } from "@arcblock/ux/lib/withTracker/constant";
7
- import I from "../../components/login-item/login-method-item.js";
8
- import { useStateContext as f } from "../../contexts/state.js";
6
+ import { GA_LAST_LOGIN_METHOD as I } from "@arcblock/ux/lib/withTracker/constant";
7
+ import f from "../../components/login-item/login-method-item.js";
8
+ import { useStateContext as u } from "../../contexts/state.js";
9
9
  function L({ ...e }) {
10
- const { setSelectedPlugin: n, getPlugin: i, connectState: r } = f(), m = l(() => {
11
- localStorage.setItem(u, "email");
12
- const t = i(o.EMAIL);
13
- t.state.reset(), t.state.status = "creating", r.chooseMethod = o.EMAIL, n(t);
10
+ const { setSelectedPlugin: i, getPlugin: r, connectState: m } = u(), n = l(() => {
11
+ localStorage.setItem(I, "email");
12
+ const t = r(o.EMAIL);
13
+ t.state.reset(), t.state.status = "creating", m.chooseMethod = o.EMAIL, i(t);
14
14
  });
15
15
  return /* @__PURE__ */ s(
16
- I,
16
+ f,
17
17
  {
18
18
  ...e,
19
19
  title: a[o.EMAIL],
20
20
  icon: p,
21
- onClick: m
21
+ onClick: n
22
22
  }
23
23
  );
24
24
  }
@@ -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 = J({}), { Provider: te, Consumer: he } = F, ae = {
15
+ const F = J({}), { Provider: te, Consumer: he } = F, re = {
16
16
  zh: {
17
17
  cancel: "取消",
18
18
  usePasskey: "使用 Passkey",
@@ -76,7 +76,7 @@ const F = J({}), { Provider: te, Consumer: he } = F, ae = {
76
76
  }
77
77
  }
78
78
  };
79
- function re({
79
+ function ae({
80
80
  children: m,
81
81
  locale: l = "en",
82
82
  onAddPasskey: E = w,
@@ -84,7 +84,7 @@ function re({
84
84
  onSwitchPassport: I = w,
85
85
  session: R = null
86
86
  }) {
87
- const v = S(window.env?.apiPrefix || G, "/api/passkey"), t = g({
87
+ const v = S(window.env?.apiPrefix || G, "/api/passkey"), r = g({
88
88
  baseUrl: "/",
89
89
  session: void 0,
90
90
  connecting: !1,
@@ -117,52 +117,52 @@ function re({
117
117
  reset() {
118
118
  d.creating = !1, d.verifying = !1, d.creatingStatus = "", d.verifyingStatus = "", d.error = "";
119
119
  }
120
- }), n = i((s, e = {}) => q(ae, s, l, "en", e)), c = W(() => $({ baseURL: S(t.baseUrl, v), sessionTokenKey: "__sst", timeout: 60 * 1e3 }), [t.baseUrl, v]), x = i(async () => {
121
- if (t.baseUrl === "/")
120
+ }), n = i((t, e = {}) => q(re, t, l, "en", e)), c = W(() => $({ baseURL: S(r.baseUrl, v), sessionTokenKey: "__sst", timeout: 60 * 1e3 }), [r.baseUrl, v]), x = i(async () => {
121
+ if (r.baseUrl === "/")
122
122
  return window.blocklet;
123
123
  try {
124
- if (new URL(t.baseUrl).host === window.location.host)
124
+ if (new URL(r.baseUrl).host === window.location.host)
125
125
  return window.blocklet;
126
126
  } catch {
127
127
  }
128
- return await H(t.baseUrl);
129
- }), P = window?.blocklet?.componentId, B = (s) => {
130
- t.baseUrl = s || "/";
131
- }, T = (s) => {
132
- t.targetAppPid = s;
133
- }, b = i(async (s) => {
134
- const { data: e } = await c.get("/register", { params: s });
128
+ return await H(r.baseUrl);
129
+ }), P = window?.blocklet?.componentId, B = (t) => {
130
+ r.baseUrl = t || "/";
131
+ }, T = (t) => {
132
+ r.targetAppPid = t;
133
+ }, b = i(async (t) => {
134
+ const { data: e } = await c.get("/register", { params: t });
135
135
  console.warn("passkey.create.options", e);
136
136
  try {
137
- const a = await Y({ optionsJSON: e, useAutoRegister: !1 });
138
- console.warn("passkey.create.response", a);
139
- const { data: r } = await c.post("/register", a, { params: { challenge: e.challenge } });
140
- if (console.warn("passkey.create.result", r), !r.verified)
137
+ const s = await Y({ optionsJSON: e, useAutoRegister: !1 });
138
+ console.warn("passkey.create.response", s);
139
+ const { data: a } = await c.post("/register", s, { params: { challenge: e.challenge } });
140
+ if (console.warn("passkey.create.result", a), !a.verified)
141
141
  throw new Error(n("createPasskeyFailed"));
142
- return r;
143
- } catch (a) {
144
- throw a.name ? new Error(h(a, n("createPasskeyFailed"), n)) : a;
142
+ return a;
143
+ } catch (s) {
144
+ throw console.error("passkey.create.error", s), s.name ? new Error(h(s, n("createPasskeyFailed"), n)) : s;
145
145
  }
146
- }), k = i(async (s) => {
147
- const { data: e } = await c.get("/auth", { params: s });
146
+ }), k = i(async (t) => {
147
+ const { data: e } = await c.get("/auth", { params: t });
148
148
  console.warn("passkey.auth.options", e);
149
149
  try {
150
- const a = await Z({ optionsJSON: e });
151
- console.warn("passkey.auth.response", a);
152
- const { data: r } = await c.post("/auth", a, {
153
- params: { challenge: e.challenge, targetAppPid: t.targetAppPid }
150
+ const s = await Z({ optionsJSON: e });
151
+ console.warn("passkey.auth.response", s);
152
+ const { data: a } = await c.post("/auth", s, {
153
+ params: { challenge: e.challenge, targetAppPid: r.targetAppPid }
154
154
  });
155
- if (console.warn("passkey.auth.result", r), !r.verified)
155
+ if (console.warn("passkey.auth.result", a), !a.verified)
156
156
  throw new Error(n("verifyPasskeyFailed"));
157
- return r;
158
- } catch (a) {
159
- throw a.name ? new Error(h(a, n("verifyPasskeyFailed"), n)) : a;
157
+ return a;
158
+ } catch (s) {
159
+ throw console.error("passkey.auth.error", s), s.name ? new Error(h(s, n("verifyPasskeyFailed"), n)) : s;
160
160
  }
161
- }), M = async (s) => {
162
- t.connecting = !0;
161
+ }), M = async (t) => {
162
+ r.connecting = !0;
163
163
  try {
164
164
  const e = await b({
165
- ...s,
165
+ ...t,
166
166
  locale: l,
167
167
  componentId: P
168
168
  });
@@ -170,54 +170,55 @@ function re({
170
170
  } catch (e) {
171
171
  U.error("Failed to connect passkey", e), u.error(A(e, n("connectPasskeyFailed")));
172
172
  } finally {
173
- t.connecting = !1;
173
+ r.connecting = !1;
174
174
  }
175
- }, D = async ({ session: s, connectedAccount: e }) => {
176
- t.session = s, t.disconnecting = !0;
175
+ }, D = async ({ session: t, connectedAccount: e }) => {
176
+ r.session = t, r.disconnecting = !0;
177
177
  try {
178
- const a = await k({
178
+ const s = await k({
179
179
  action: "disconnect",
180
180
  locale: l,
181
181
  componentId: P,
182
- sourceAppPid: s?.user?.sourceAppPid,
182
+ sourceAppPid: t?.user?.sourceAppPid,
183
183
  credentialId: e.id
184
184
  });
185
- u.success(n("disconnectPasskeySucceed")), C(a);
186
- } catch (a) {
187
- U.error("Failed to disconnect passkey", a), u.error(A(a, n("disconnectPasskeyFailed")));
185
+ u.success(n("disconnectPasskeySucceed")), C(s);
186
+ } catch (s) {
187
+ U.error("Failed to disconnect passkey", s), u.error(A(s, n("disconnectPasskeyFailed")));
188
188
  } finally {
189
- t.disconnecting = !1;
189
+ r.disconnecting = !1;
190
190
  }
191
- }, N = async (s = {}) => {
191
+ }, N = async (t = {}) => {
192
192
  try {
193
193
  const { data: e } = await c.get("/passports");
194
- e.length ? (o.open = !0, o.currentUser = s, o.passports = e || []) : u.error(n("noPassports"));
194
+ e.length ? (o.open = !0, o.currentUser = t, o.passports = e || []) : u.error(n("noPassports"));
195
195
  } catch (e) {
196
196
  u.error(e.message || n("getPassportFailed"));
197
197
  }
198
- }, j = i((...s) => {
199
- o.reset(), I(...s);
200
- }), L = i(async ({ action: s = "login", ...e } = {}) => {
201
- const a = t.baseUrl;
198
+ }, j = i((...t) => {
199
+ o.reset(), I(...t);
200
+ }), L = i(async ({ action: t = "login", ...e } = {}) => {
201
+ const s = r.baseUrl;
202
202
  if (e?.sourceAppPid === window.blocklet?.appPid)
203
- t.baseUrl = window.blocklet?.appUrl || "/";
203
+ r.baseUrl = window.blocklet?.appUrl || "/";
204
204
  else if (e?.sourceAppPid) {
205
- const r = await x(), y = X(r), f = Q(r);
206
- y && f?.appPid && e?.sourceAppPid === f?.appPid && (t.baseUrl = f.appUrl);
205
+ const a = await x(), y = X(a), f = Q(a);
206
+ y && f?.appPid && e?.sourceAppPid === f?.appPid && (r.baseUrl = f.appUrl);
207
207
  }
208
208
  try {
209
- const r = {
209
+ const a = {
210
210
  ...e,
211
- action: s,
211
+ action: t,
212
212
  locale: l,
213
213
  componentId: P
214
214
  };
215
- z(r.inviter) && window.localStorage.getItem("inviter") && (r.inviter = window.localStorage.getItem("inviter"));
216
- const y = ee(await k(r));
215
+ z(a.inviter) && window.localStorage.getItem("inviter") && (a.inviter = window.localStorage.getItem("inviter"));
216
+ const y = ee(await k(a));
217
217
  return y.provider = "passkey", y;
218
- } catch (r) {
219
- const y = h(r, n("verifyPasskeyFailed"), n);
220
- throw t.baseUrl = a, new Error(y);
218
+ } catch (a) {
219
+ console.error("passkey.login.error", a);
220
+ const y = h(a, n("verifyPasskeyFailed"), n);
221
+ throw r.baseUrl = s, new Error(y);
221
222
  }
222
223
  }), _ = i(() => {
223
224
  });
@@ -234,12 +235,12 @@ function re({
234
235
  loginPasskey: L,
235
236
  logoutPasskey: _,
236
237
  switchPassport: N,
237
- baseUrl: t.baseUrl,
238
+ baseUrl: r.baseUrl,
238
239
  setBaseUrl: B,
239
240
  setTargetAppPid: T,
240
241
  passkeyState: d,
241
- disconnecting: t.disconnecting,
242
- connecting: t.connecting,
242
+ disconnecting: r.disconnecting,
243
+ connecting: r.connecting,
243
244
  t: n
244
245
  },
245
246
  children: [
@@ -261,7 +262,7 @@ function re({
261
262
  function me() {
262
263
  return K(F);
263
264
  }
264
- re.propTypes = {
265
+ ae.propTypes = {
265
266
  children: p.node.isRequired,
266
267
  locale: p.string,
267
268
  onAddPasskey: p.func,
@@ -272,6 +273,6 @@ re.propTypes = {
272
273
  export {
273
274
  he as PasskeyConsumer,
274
275
  F as PasskeyContext,
275
- re as PasskeyProvider,
276
+ ae as PasskeyProvider,
276
277
  me as usePasskey
277
278
  };