@arcblock/did-connect-react 3.4.4 → 3.4.5

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.
@@ -10,52 +10,52 @@ import qo from "js-cookie";
10
10
  import Xo from "eventemitter3";
11
11
  import Qo from "p-wait-for";
12
12
  import { useTheme as Yo, Typography as Jo, Box as $, CircularProgress as Zo } from "@mui/material";
13
- import { getVisitorId as q, isUrl as et, ensureVisitorId as ot, setVisitorId as ke } from "@arcblock/ux/lib/Util";
13
+ import { getVisitorId as q, mergeIgnoreEmpty as et, isUrl as ot, ensureVisitorId as tt, setVisitorId as ke } from "@arcblock/ux/lib/Util";
14
14
  import ae, { ToastProvider as ye } from "@arcblock/ux/lib/Toast";
15
- import tt from "@arcblock/ux/lib/Center";
16
- import { useReactive as Ie, useCreation as Le, useMemoizedFn as f, usePrevious as it, useLatest as De, useUpdateEffect as le, useMount as rt } from "ahooks";
15
+ import it from "@arcblock/ux/lib/Center";
16
+ import { useReactive as Ie, useCreation as Le, useMemoizedFn as f, usePrevious as rt, useLatest as De, useUpdateEffect as le, useMount as nt } from "ahooks";
17
17
  import { joinURL as H } from "ufo";
18
- import { Icon as nt } from "@iconify/react";
19
- import st from "@iconify-icons/material-symbols/keyboard-double-arrow-right-rounded";
20
- import ct from "@arcblock/react-hooks/lib/useBrowser";
21
- import at from "@arcblock/ux/lib/Dialog/use-confirm";
18
+ import { Icon as st } from "@iconify/react";
19
+ import ct from "@iconify-icons/material-symbols/keyboard-double-arrow-right-rounded";
20
+ import at from "@arcblock/react-hooks/lib/useBrowser";
21
+ import lt from "@arcblock/ux/lib/Dialog/use-confirm";
22
22
  import _e from "@arcblock/ux/lib/DID";
23
23
  import Ee from "@arcblock/ux/lib/Avatar";
24
- import { getCurrentAppPid as lt } from "@arcblock/ux/lib/SessionUser/libs/utils";
25
- import { translate as dt } from "@arcblock/ux/lib/Locale/util";
26
- import { getBlockletSDK as pt } from "@blocklet/js-sdk";
24
+ import { getCurrentAppPid as dt } from "@arcblock/ux/lib/SessionUser/libs/utils";
25
+ import { translate as pt } from "@arcblock/ux/lib/Locale/util";
26
+ import { getBlockletSDK as ft } from "@blocklet/js-sdk";
27
27
  import b from "@arcblock/bridge";
28
- import { getFederatedEnabled as ft } from "@arcblock/ux/lib/Util/federated";
29
- import ut from "lodash/noop";
30
- import wt from "lodash/isNil";
31
- import { ReactGA as ht } from "@arcblock/ux/lib/withTracker";
32
- import { useState as mt, useEffect as gt } from "react";
28
+ import { getFederatedEnabled as ut } from "@arcblock/ux/lib/Util/federated";
29
+ import wt from "lodash/noop";
30
+ import ht from "lodash/isNil";
31
+ import { ReactGA as mt } from "@arcblock/ux/lib/withTracker";
32
+ import { useState as gt, useEffect as St } from "react";
33
33
  import de from "../Storage/index.js";
34
- import { formatCacheTtl as St, getBrowserLang as Pt, debug as h, decodeUrlParams as ve, sleep as E, debugTmp as xe, updateConnectedInfo as ee, getAppId as oe, logger as Oe } from "../utils.js";
34
+ import { formatCacheTtl as Pt, getBrowserLang as At, debug as h, decodeUrlParams as ve, sleep as E, debugTmp as xe, updateConnectedInfo as ee, getAppId as oe, logger as Oe } from "../utils.js";
35
35
  import Re from "./window-focus-aware.js";
36
- import { OAuthContext as At, OAuthConsumer as bt, OAuthProvider as Ne, useOAuth as Ct } from "../OAuth/context.js";
37
- import { PasskeyContext as Tt, PasskeyConsumer as kt, PasskeyProvider as We, usePasskey as yt } from "../Passkey/context.js";
36
+ import { OAuthContext as bt, OAuthConsumer as Ct, OAuthProvider as Ne, useOAuth as Tt } from "../OAuth/context.js";
37
+ import { PasskeyContext as kt, PasskeyConsumer as yt, PasskeyProvider as We, usePasskey as It } from "../Passkey/context.js";
38
38
  import "../Passkey/actions.js";
39
- import It, { getWalletDid as Lt } from "../User/use-did.js";
40
- import Dt from "../User/wrap-did.js";
41
- import _t from "./hooks/use-federated.js";
42
- import Et from "./hooks/use-session-token.js";
43
- import vt from "./hooks/use-protected-routes.js";
39
+ import Lt, { getWalletDid as Dt } from "../User/use-did.js";
40
+ import _t from "../User/wrap-did.js";
41
+ import Et from "./hooks/use-federated.js";
42
+ import vt from "./hooks/use-session-token.js";
43
+ import xt from "./hooks/use-protected-routes.js";
44
44
  import { SessionContext as qe } from "./context.js";
45
- import xt from "../Connect/use-connect.js";
45
+ import Ot from "../Connect/use-connect.js";
46
46
  import { EVENTS as a } from "./libs/constants.js";
47
47
  import { translations as B } from "./libs/locales.js";
48
- import { NotOpenError as Ot } from "../error.js";
49
- import { SESSION_TOKEN_STORAGE_KEY as Xe, REFRESH_TOKEN_STORAGE_KEY as Qe, CSRF_TOKEN_STORAGE_KEY as Rt, API_DID_PREFIX as Nt, DEFAULT_TIMEOUT as Wt, BLOCKLET_SERVICE_PATH_PREFIX as G, DID_SPACES_BASE_URL as Ft } from "../constant.js";
50
- import { getMobileVisitorId as Bt, checkEnableAutoLogin as Ut, login as Mt } from "./libs/login-mobile.js";
51
- import Ht from "../Connect/hooks/use-quick-connect.js";
48
+ import { NotOpenError as Rt } from "../error.js";
49
+ import { SESSION_TOKEN_STORAGE_KEY as Xe, REFRESH_TOKEN_STORAGE_KEY as Qe, CSRF_TOKEN_STORAGE_KEY as Nt, API_DID_PREFIX as Wt, DEFAULT_TIMEOUT as Ft, BLOCKLET_SERVICE_PATH_PREFIX as G, DID_SPACES_BASE_URL as Bt } from "../constant.js";
50
+ import { getMobileVisitorId as Ut, checkEnableAutoLogin as Mt, login as Ht } from "./libs/login-mobile.js";
51
+ import Gt from "../Connect/hooks/use-quick-connect.js";
52
52
  import { didSpacesIsRequired as Fe } from "./libs/did-spaces.js";
53
- import Gt from "./did-spaces-guide.js";
54
- import { FederatedProvider as zt, useFederatedContext as Vt } from "../Federated/context.js";
55
- import jt from "./hooks/use-verify.js";
53
+ import zt from "./did-spaces-guide.js";
54
+ import { FederatedProvider as Vt, useFederatedContext as jt } from "../Federated/context.js";
55
+ import Kt from "./hooks/use-verify.js";
56
56
  import { gaLoginSuccessHandler as Be, gaLoginFailedHandler as Ue, gaSwitchPassportSuccessHandler as Me, gaSwitchPassportFailedHandler as He, gaBindWalletSuccessHandler as Ge, gaBindWalletFailedHandler as ze } from "./handler.js";
57
- import { loginFederatedMaster as Ji, mountFederatedIframe as Zi } from "./libs/federated.js";
58
- const { Provider: Kt, Consumer: Ve } = qe, je = {
57
+ import { loginFederatedMaster as Zi, mountFederatedIframe as er } from "./libs/federated.js";
58
+ const { Provider: $t, Consumer: Ve } = qe, je = {
59
59
  en: "DID Connect timeout, please reopen DID Connect popup",
60
60
  zh: "DID Connect 超时, 请重新打开 DID Connect"
61
61
  }, Ke = {
@@ -88,14 +88,14 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
88
88
  } else
89
89
  b.callArc("onLogin", { error: "no user", code: 400 }), h("notifyBridge failed", { sessionState: L });
90
90
  }
91
- const Y = de(X, Q, te), z = de(Rt, "cookie", {
91
+ const Y = de(X, Q, te), z = de(Nt, "cookie", {
92
92
  secure: !0,
93
93
  sameSite: "strict"
94
94
  }), Ye = de(k.refreshTokenStorageKey, "ls");
95
95
  function pe({ ...L }) {
96
- const v = pt(), n = Object.assign({}, L);
97
- u(n.serviceHost) && (n.serviceHost = D), u(n.locale) && (n.locale = ""), u(n.action) && (n.action = "login"), u(n.prefix) && (n.prefix = Nt), u(n.appendAuthServicePrefix) && (n.appendAuthServicePrefix = !1), u(n.extraParams) && (n.extraParams = {}), u(n.options) && (n.options = {}), u(n.autoConnect) && (n.autoConnect = !1), u(n.autoDisconnect) && (n.autoDisconnect = !0), u(n.useSocket) && (n.useSocket = !0), u(n.timeout) && (n.timeout = Wt * 1e3), u(n.webWalletUrl) && (n.webWalletUrl = void 0), u(n.protectedRoutes) && (n.protectedRoutes = ["*"]), u(n.apiOptions) && (n.apiOptions = {}), u(n.lazyRefreshToken) && (n.lazyRefreshToken = !1);
98
- const { connectApi: y, connectHolder: Ze } = xt(), [eo, fe] = mt(0), I = ct(), { requestStorageAccess: oo } = Vt(), { palette: to } = Yo(), U = new URLSearchParams(window.location.search), c = Ie({
96
+ const v = ft(), n = Object.assign({}, L);
97
+ u(n.serviceHost) && (n.serviceHost = D), u(n.locale) && (n.locale = ""), u(n.action) && (n.action = "login"), u(n.prefix) && (n.prefix = Wt), u(n.appendAuthServicePrefix) && (n.appendAuthServicePrefix = !1), u(n.extraParams) && (n.extraParams = {}), u(n.options) && (n.options = {}), u(n.autoConnect) && (n.autoConnect = !1), u(n.autoDisconnect) && (n.autoDisconnect = !0), u(n.useSocket) && (n.useSocket = !0), u(n.timeout) && (n.timeout = Ft * 1e3), u(n.webWalletUrl) && (n.webWalletUrl = void 0), u(n.protectedRoutes) && (n.protectedRoutes = ["*"]), u(n.apiOptions) && (n.apiOptions = {}), u(n.lazyRefreshToken) && (n.lazyRefreshToken = !1);
98
+ const { connectApi: y, connectHolder: Ze } = Ot(), [eo, fe] = gt(0), I = at(), { requestStorageAccess: oo } = jt(), { palette: to } = Yo(), U = new URLSearchParams(window.location.search), c = Ie({
99
99
  extraParams: {},
100
100
  options: {},
101
101
  currentLocale: n.locale,
@@ -123,13 +123,13 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
123
123
  baseUrl: "",
124
124
  unReadCount: 0
125
125
  // 不可以直接个性 props.autoConnect (readonly)
126
- }), P = Le(() => n.locale || c.currentLocale || Pt(), [n.locale, c.currentLocale]), { confirmApi: io, confirmHolder: ro } = at(), R = f(() => {
126
+ }), P = Le(() => n.locale || c.currentLocale || At(), [n.locale, c.currentLocale]), { confirmApi: io, confirmHolder: ro } = lt(), R = f(() => {
127
127
  if (i.open && !I.arcSphere) {
128
128
  const e = Ke[P] || Ke.en;
129
129
  throw ae.warning(e), new Error(e);
130
130
  }
131
131
  }), d = Le(() => new Xo(), []);
132
- gt(() => (d.on(a.LOGIN, Be), d.on(a.LOGIN_FAILED, Ue), d.on(a.SWITCH_PASSPORT, Me), d.on(a.SWITCH_PASSPORT_FAILED, He), d.on(a.BIND_WALLET, Ge), d.on(a.BIND_WALLET_FAILED, ze), () => {
132
+ St(() => (d.on(a.LOGIN, Be), d.on(a.LOGIN_FAILED, Ue), d.on(a.SWITCH_PASSPORT, Me), d.on(a.SWITCH_PASSPORT_FAILED, He), d.on(a.BIND_WALLET, Ge), d.on(a.BIND_WALLET_FAILED, ze), () => {
133
133
  d.off(a.LOGIN, Be), d.off(a.LOGIN_FAILED, Ue), d.off(a.SWITCH_PASSPORT, Me), d.off(a.SWITCH_PASSPORT_FAILED, He), d.off(a.BIND_WALLET, Ge), d.off(a.BIND_WALLET_FAILED, ze);
134
134
  }), [d]);
135
135
  const M = f((e, o, t) => {
@@ -151,7 +151,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
151
151
  d.once(s[e][0], l), d.once(s[e][1], async (...p) => {
152
152
  Z(l) && d.off(s[e][0], l), Z(t) && await t(...p), d.emit(`cancel-${e}`, ...p);
153
153
  });
154
- }), no = it(i.initialized, (e, o) => e !== o || e === !0 && o === !0), {
154
+ }), no = rt(i.initialized, (e, o) => e !== o || e === !0 && o === !0), {
155
155
  syncSessionSate: so,
156
156
  handleRefreshUser: C,
157
157
  handleRefreshToken: co,
@@ -164,7 +164,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
164
164
  getRefreshToken: fo,
165
165
  setRefreshToken: uo,
166
166
  setSessionToken: wo
167
- } = Et({
167
+ } = vt({
168
168
  state: i,
169
169
  pageState: c,
170
170
  sessionTokenStorage: Y,
@@ -194,7 +194,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
194
194
  }));
195
195
  }
196
196
  }
197
- }), ho = jt({ state: i, connectApi: y }), we = f((e, o = {}, t = {}) => {
197
+ }), ho = Kt({ state: i, connectApi: y }), we = f((e, o = {}, t = {}) => {
198
198
  R();
199
199
  const s = e;
200
200
  typeof s == "object" && (e = s.onSuccess, o = s.extraParams || {}, t = s.options || {}, t.origin = s.origin || ""), (!i.user || t.origin === "switch-did") && (t.origin === "switch-did" ? M("switch-did", e, s?.onCancel) : M("login", e, s?.onCancel), c.extraParams = o, c.options = t, i.action = "login", F());
@@ -228,7 +228,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
228
228
  const g = Te(o);
229
229
  g.passkeyBehavior = "both", c.allowWallet = void 0;
230
230
  const r = g?.openMode || n?.extraParams?.openMode;
231
- u(r) ? p ? p !== globalThis.blocklet.appPid && ft(globalThis.blocklet) && (c.openMode = "window") : c.openMode = "popup" : c.openMode = r, c.openMode === "window" && !I.arcSphere && !I.wallet && await oo() && (c.openMode = "popup"), p ? i.baseUrl = globalThis.blocklet.appUrl : i.baseUrl = "", we(e, g, t);
231
+ u(r) ? p ? p !== globalThis.blocklet.appPid && ut(globalThis.blocklet) && (c.openMode = "window") : c.openMode = "popup" : c.openMode = r, c.openMode === "window" && !I.arcSphere && !I.wallet && await oo() && (c.openMode = "popup"), p ? i.baseUrl = globalThis.blocklet.appUrl : i.baseUrl = "", we(e, g, t);
232
232
  }), he = f(async (e) => {
233
233
  const o = q();
234
234
  if (globalThis.blocklet && (v.user.logout({ visitorId: o }).catch((t) => {
@@ -241,7 +241,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
241
241
  };
242
242
  h("bridge callArc: onLogout", t), b.callArc("onLogout", t);
243
243
  }
244
- xe("[clearSession] createSessionContext -> logout:"), ue(), j(), i.user = null, i.provider = "", i.walletOS = "", i.error = "", i.loading = !1, d.emit("logout"), ht.set({
244
+ xe("[clearSession] createSessionContext -> logout:"), ue(), j(), i.user = null, i.provider = "", i.walletOS = "", i.error = "", i.loading = !1, d.emit("logout"), mt.set({
245
245
  user_id: void 0
246
246
  }), typeof e == "function" && e();
247
247
  }), {
@@ -249,8 +249,8 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
249
249
  refresh: So,
250
250
  loaded: Po,
251
251
  loginUserSession: re
252
- } = Ht({
253
- appPid: lt(i.user),
252
+ } = Gt({
253
+ appPid: dt(i.user),
254
254
  loginAppPid: globalThis?.blocklet?.appPid,
255
255
  sourceAppPid: i?.user?.sourceAppPid,
256
256
  autoFetch: !1,
@@ -316,11 +316,11 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
316
316
  onSuccess: o,
317
317
  hideCloseButton: !1
318
318
  });
319
- }), { didSpacesGuideApi: J, DidSpacesGuideView: yo } = Gt({
319
+ }), { didSpacesGuideApi: J, DidSpacesGuideView: yo } = zt({
320
320
  autoClose: !1
321
321
  }), W = async ({ extraParams: e = {}, onSuccess: o = () => {
322
322
  } } = {}) => {
323
- await N(), await Fe(i?.user) && (J.open(), J.onConnect((t = ut) => {
323
+ await N(), await Fe(i?.user) && (J.open(), J.onConnect((t = wt) => {
324
324
  const s = {
325
325
  prefix: "/connect-to-did-space",
326
326
  custom: !0,
@@ -347,11 +347,11 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
347
347
  }
348
348
  };
349
349
  y.openPopup(s, {
350
- baseUrl: Ft
350
+ baseUrl: Bt
351
351
  });
352
352
  }));
353
353
  }, ge = f(async (e, o = {}) => {
354
- if (await N(), Lt(i.user)) {
354
+ if (await N(), Dt(i.user)) {
355
355
  e({}, _, A.current);
356
356
  return;
357
357
  }
@@ -410,7 +410,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
410
410
  federatedMaster: Ro,
411
411
  federatedEnabled: No,
412
412
  master: Wo
413
- } = _t({
413
+ } = Et({
414
414
  locale: P,
415
415
  decrypt: _,
416
416
  login: we,
@@ -418,12 +418,12 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
418
418
  handleRefreshUser: C,
419
419
  setRefreshToken: uo,
420
420
  setSessionToken: wo
421
- }), { checkMatch: Fo } = vt({ protectedRoutes: n.protectedRoutes || [] }), Bo = De(go), Se = f(async () => (Po || (await So(), await E(100)), Bo.current)), j = f(() => {
421
+ }), { checkMatch: Fo } = xt({ protectedRoutes: n.protectedRoutes || [] }), Bo = De(go), Se = f(async () => (Po || (await So(), await E(100)), Bo.current)), j = f(() => {
422
422
  i.open = !1, y.close();
423
423
  }), F = async (e = {}) => {
424
424
  let o = i.action;
425
425
  c?.options?.origin === "switch-did" && (o = c?.options?.origin);
426
- const t = B[o], l = Ao(o, P) || t[P] || t.en, p = {
426
+ const t = B[o], s = Ao(o, P), l = et(t[P] || t.en, s || {}), p = {
427
427
  ...k.extraParams,
428
428
  ...n.extraParams,
429
429
  ...c.extraParams,
@@ -431,7 +431,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
431
431
  email: i?.user?.email
432
432
  };
433
433
  if (o === "switch-did" && p?.forceConnected) {
434
- const r = (w, T = {}) => dt(B["switch-specified-did"], w, P, "en", T);
434
+ const r = (w, T = {}) => pt(B["switch-specified-did"], w, P, "en", T);
435
435
  l.title = r("title"), l.scan = r("scan", { did: p.forceConnected }), l.confirm = r("confirm"), l.success = r("success");
436
436
  }
437
437
  delete p?.openMode;
@@ -491,9 +491,9 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
491
491
  ...g,
492
492
  baseUrl: window.location.origin
493
493
  };
494
- et(c.prefix) || (r.prefix = H(window.location.origin, n.serviceHost, c.prefix)), r.extraParams?.provider || (r.extraParams.provider = i?.user?.provider || "wallet"), await y.openPopup(r, { locale: P });
494
+ ot(c.prefix) || (r.prefix = H(window.location.origin, n.serviceHost, c.prefix)), r.extraParams?.provider || (r.extraParams.provider = i?.user?.provider || "wallet"), await y.openPopup(r, { locale: P });
495
495
  } catch (r) {
496
- r instanceof Ot && j(), r.message === "Timeout" ? ae.error(je[P] || je.en) : console.error(r);
496
+ r instanceof Rt && j(), r.message === "Timeout" ? ae.error(je[P] || je.en) : console.error(r);
497
497
  }
498
498
  else
499
499
  y.open(g);
@@ -532,8 +532,8 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
532
532
  /* @__PURE__ */ m($, { sx: { display: "flex", justifyContent: "center", px: 2 }, children: /* @__PURE__ */ m(
533
533
  $,
534
534
  {
535
- component: nt,
536
- icon: st,
535
+ component: st,
536
+ icon: ct,
537
537
  sx: {
538
538
  fontSize: 24,
539
539
  color: to.grey[400],
@@ -675,18 +675,18 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
675
675
  // federated relates
676
676
  federatedMaster: Ro,
677
677
  // oauth relates
678
- useOAuth: Ct,
678
+ useOAuth: Tt,
679
679
  OAuthProvider: Ne,
680
- OAuthConsumer: bt,
681
- OAuthContext: At,
680
+ OAuthConsumer: Ct,
681
+ OAuthContext: bt,
682
682
  // passkey relates
683
- usePasskey: yt,
683
+ usePasskey: It,
684
684
  PasskeyProvider: We,
685
- PasskeyConsumer: kt,
686
- PasskeyContext: Tt,
685
+ PasskeyConsumer: yt,
686
+ PasskeyContext: kt,
687
687
  // user related
688
- useDid: It,
689
- WrapDid: Dt,
688
+ useDid: Lt,
689
+ WrapDid: _t,
690
690
  getUserSessions: Se,
691
691
  async loginUserSession(e) {
692
692
  try {
@@ -748,9 +748,9 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
748
748
  }
749
749
  }, [i.user, i.initialized, d]), le(() => {
750
750
  i.initialized && i.user && Pe();
751
- }, [i.initialized]), rt(async () => {
751
+ }, [i.initialized]), nt(async () => {
752
752
  const e = (r) => {
753
- wt(r.encrypted) && (r.encrypted = !1), window.temporaryDIDConnectOnSuccess instanceof Function ? (h("bridgeOnLogin: temporaryDIDConnectOnSuccess", { result: r }), window.temporaryDIDConnectOnSuccess(r, (w) => w)) : (h("bridgeOnLogin: onLogin", { result: r }), V(r));
753
+ ht(r.encrypted) && (r.encrypted = !1), window.temporaryDIDConnectOnSuccess instanceof Function ? (h("bridgeOnLogin: temporaryDIDConnectOnSuccess", { result: r }), window.temporaryDIDConnectOnSuccess(r, (w) => w)) : (h("bridgeOnLogin: onLogin", { result: r }), V(r));
754
754
  };
755
755
  if (b.registerBlocklet("callLoginOAuth", (r) => {
756
756
  h("bridge registerBlocklet: callLoginOAuth", r), y.loginOAuth({
@@ -759,13 +759,13 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
759
759
  });
760
760
  }), b.registerBlocklet("logout", he), b.registerBlocklet("login", (r) => {
761
761
  h("bridge registerBlocklet: login", r), e(r);
762
- }), ot(), !q()) {
762
+ }), tt(), !q()) {
763
763
  if (I.arcSphere) {
764
764
  h("bridge callArc: getVisitorId");
765
765
  const r = await b.callArc("getVisitorId");
766
766
  h("bridge callArc: getVisitorId result", { walletVisitorId: r }), ke(r);
767
767
  } else if (I.wallet) {
768
- const r = await Bt();
768
+ const r = await Ut();
769
769
  ke(r);
770
770
  }
771
771
  }
@@ -781,10 +781,10 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
781
781
  const l = po();
782
782
  if (window?.self === window?.parent) {
783
783
  let r = "web";
784
- if (I.mobile.apple.device ? r = "ios" : I.mobile.android.device && (r = "android"), I.wallet && Ut({ version: I.walletVersion, platform: r }) && !l)
784
+ if (I.mobile.apple.device ? r = "ios" : I.mobile.android.device && (r = "android"), I.wallet && Mt({ version: I.walletVersion, platform: r }) && !l)
785
785
  try {
786
786
  i.loading = !0;
787
- const w = await Mt();
787
+ const w = await Ht();
788
788
  if (w) {
789
789
  await V({
790
790
  sessionToken: w.sessionToken,
@@ -845,7 +845,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
845
845
  });
846
846
  const zo = U.has("popup");
847
847
  if (Fo() && !i.initialized)
848
- return /* @__PURE__ */ m(tt, { children: zo ? null : /* @__PURE__ */ m(Zo, {}) });
848
+ return /* @__PURE__ */ m(it, { children: zo ? null : /* @__PURE__ */ m(Zo, {}) });
849
849
  const be = {
850
850
  locale: P,
851
851
  onSwitchPassport: ({ sessionToken: e, refreshToken: o, csrfToken: t }) => se({ sessionToken: e, refreshToken: o, csrfToken: t, encrypted: !1 }),
@@ -855,7 +855,7 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
855
855
  onRemovePasskey: () => C(),
856
856
  session: A.current
857
857
  };
858
- return /* @__PURE__ */ m(Kt, { value: Go, children: /* @__PURE__ */ m(We, { ...be, children: /* @__PURE__ */ K(Ne, { ...be, children: [
858
+ return /* @__PURE__ */ m($t, { value: Go, children: /* @__PURE__ */ m(We, { ...be, children: /* @__PURE__ */ K(Ne, { ...be, children: [
859
859
  !i.open && typeof n.children == "function" ? n.children(i) : n.children,
860
860
  Ze,
861
861
  ro,
@@ -891,20 +891,20 @@ function $e(X = Xe, Q = "ls", te = {}, k = {}) {
891
891
  };
892
892
  }
893
893
  return {
894
- SessionProvider: (L) => /* @__PURE__ */ m(ye, { children: /* @__PURE__ */ m(zt, { children: /* @__PURE__ */ m(pe, { ...L }) }) }),
894
+ SessionProvider: (L) => /* @__PURE__ */ m(ye, { children: /* @__PURE__ */ m(Vt, { children: /* @__PURE__ */ m(pe, { ...L }) }) }),
895
895
  SessionConsumer: Ve,
896
896
  SessionContext: qe,
897
897
  withSession: Je
898
898
  };
899
899
  }
900
- function Xi({ storageEngine: X = "cookie" } = {}) {
900
+ function Qi({ storageEngine: X = "cookie" } = {}) {
901
901
  const Q = Xe, te = Qe;
902
902
  let k = null;
903
903
  if (typeof window < "u" && (k = (globalThis.blocklet || {}).componentId), X === "cookie") {
904
904
  let D = "/", O = 1;
905
905
  if (typeof window < "u") {
906
906
  const Y = window.env || {}, z = window.blocklet || {};
907
- D = Y.groupPathPrefix || z.groupPrefix || z.prefix || "", D = D.replace(/\/+$/, ""), D = D || "/", z.serverVersion && (O = St(window.blocklet?.settings?.session?.cacheTtl, 1 / 24));
907
+ D = Y.groupPathPrefix || z.groupPrefix || z.prefix || "", D = D.replace(/\/+$/, ""), D = D || "/", z.serverVersion && (O = Pt(window.blocklet?.settings?.session?.cacheTtl, 1 / 24));
908
908
  }
909
909
  return $e(
910
910
  Q,
@@ -928,14 +928,14 @@ function Xi({ storageEngine: X = "cookie" } = {}) {
928
928
  export {
929
929
  a as EVENTS,
930
930
  qe as SessionContext,
931
- Ut as checkEnableAutoLogin,
932
- Xi as createAuthServiceSessionContext,
931
+ Mt as checkEnableAutoLogin,
932
+ Qi as createAuthServiceSessionContext,
933
933
  $e as createSessionContext,
934
934
  $e as default,
935
935
  Fe as didSpacesIsRequired,
936
- Bt as getMobileVisitorId,
937
- Mt as login,
938
- Ji as loginFederatedMaster,
939
- Zi as mountFederatedIframe,
936
+ Ut as getMobileVisitorId,
937
+ Ht as login,
938
+ Zi as loginFederatedMaster,
939
+ er as mountFederatedIframe,
940
940
  B as translations
941
941
  };
@@ -1,4 +1,4 @@
1
- const o = "3.4.4", s = {
1
+ const o = "3.4.5", 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.4.4",
3
+ "version": "3.4.5",
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.4.4",
35
+ "@arcblock/bridge": "3.4.5",
36
36
  "@arcblock/did": "^1.28.2",
37
- "@arcblock/icons": "3.4.4",
38
- "@arcblock/react-hooks": "3.4.4",
37
+ "@arcblock/icons": "3.4.5",
38
+ "@arcblock/react-hooks": "3.4.5",
39
39
  "@arcblock/ws": "^1.28.2",
40
40
  "@blocklet/constant": "^1.17.7",
41
41
  "@fontsource/lexend": "^5.2.9",
@@ -81,5 +81,5 @@
81
81
  "eslint-plugin-react-hooks": "^4.6.2",
82
82
  "jest": "^29.7.0"
83
83
  },
84
- "gitHead": "89a650622cb03211e105d8d9ac7793ccf18aac4f"
84
+ "gitHead": "a944f14b25e2fd8cd0e7e32b3c3ce276961e6b64"
85
85
  }
@@ -10,7 +10,7 @@ import Cookie from 'js-cookie';
10
10
  import EventEmitter from 'eventemitter3';
11
11
  import pWaitFor from 'p-wait-for';
12
12
  import { Box, CircularProgress, Typography, useTheme } from '@mui/material';
13
- import { getVisitorId, setVisitorId, ensureVisitorId, isUrl } from '@arcblock/ux/lib/Util';
13
+ import { getVisitorId, setVisitorId, ensureVisitorId, isUrl, mergeIgnoreEmpty } from '@arcblock/ux/lib/Util';
14
14
  import Toast, { ToastProvider } from '@arcblock/ux/lib/Toast';
15
15
  import Center from '@arcblock/ux/lib/Center';
16
16
  import { useCreation, useLatest, useMemoizedFn, useMount, usePrevious, useReactive, useUpdateEffect } from 'ahooks';
@@ -1009,7 +1009,8 @@ function createSessionContext(
1009
1009
 
1010
1010
  const messages = getMessageByBlocklet(localeAction, currentLocale);
1011
1011
 
1012
- const connectMessage = messages || defaultMessages[currentLocale] || defaultMessages.en;
1012
+ // 使用对象合并,确保即使前面的对象缺少某些key,也能从后面的对象中获取
1013
+ const connectMessage = mergeIgnoreEmpty(defaultMessages[currentLocale] || defaultMessages.en, messages || {});
1013
1014
  const extraParams = {
1014
1015
  ...opts.extraParams,
1015
1016
  ...props.extraParams,