@arcblock/did-connect-react 3.3.10 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/lib/Connect/assets/locale.js +4 -2
  2. package/lib/Connect/components/login-item/connect-choose-list.js +120 -114
  3. package/lib/Connect/components/login-item/connect-provider-list.js +187 -180
  4. package/lib/Connect/components/login-item/login-method-item.js +63 -47
  5. package/lib/Connect/components/login-item/passkey-login-item.js +17 -15
  6. package/lib/Connect/components/login-item/wallet-login-options.js +42 -40
  7. package/lib/Connect/connect.js +503 -0
  8. package/lib/Connect/contexts/state.js +74 -65
  9. package/lib/Connect/fallback-connect.js +53 -0
  10. package/lib/Connect/hooks/provider-list.js +45 -29
  11. package/lib/Connect/index.js +13 -502
  12. package/lib/Connect/plugins/email/list-item.js +19 -18
  13. package/lib/Connect/use-connect.js +10 -10
  14. package/lib/OAuth/context.js +3 -3
  15. package/lib/Passkey/actions.js +80 -75
  16. package/lib/Passkey/context.js +3 -3
  17. package/lib/Passkey/dialog.js +7 -7
  18. package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
  19. package/lib/Session/index.js +189 -189
  20. package/lib/package.json.js +1 -1
  21. package/lib/utils.js +2 -2
  22. package/package.json +8 -8
  23. package/src/Connect/assets/locale.js +2 -0
  24. package/src/Connect/components/login-item/connect-choose-list.jsx +12 -5
  25. package/src/Connect/components/login-item/connect-provider-list.jsx +11 -4
  26. package/src/Connect/components/login-item/login-method-item.jsx +24 -7
  27. package/src/Connect/components/login-item/passkey-login-item.jsx +3 -1
  28. package/src/Connect/components/login-item/wallet-login-options.jsx +3 -2
  29. package/src/Connect/connect.jsx +618 -0
  30. package/src/Connect/contexts/state.jsx +10 -0
  31. package/src/Connect/fallback-connect.jsx +47 -0
  32. package/src/Connect/hooks/provider-list.js +48 -17
  33. package/src/Connect/index.jsx +8 -605
  34. package/src/Connect/plugins/email/list-item.jsx +3 -2
  35. package/src/Connect/use-connect.jsx +1 -1
  36. package/src/Passkey/actions.jsx +5 -0
  37. package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
  38. package/src/Session/index.jsx +3 -4
  39. package/src/utils.js +2 -2
@@ -1,20 +1,20 @@
1
- import { jsx as g, jsxs as j, Fragment as zo } from "react/jsx-runtime";
1
+ import { jsx as g, jsxs as K, Fragment as zo } from "react/jsx-runtime";
2
2
  import S from "prop-types";
3
3
  import Vo from "lodash/omit";
4
4
  import jo from "lodash/pick";
5
5
  import Te from "lodash/cloneDeep";
6
- import J from "lodash/isFunction";
6
+ import Z from "lodash/isFunction";
7
7
  import w from "lodash/isUndefined";
8
8
  import Ko from "lodash/defaultsDeep";
9
9
  import $o from "js-cookie";
10
10
  import qo from "eventemitter3";
11
11
  import Xo from "p-wait-for";
12
- import { useTheme as Qo, Typography as Yo, Box as K, CircularProgress as Jo } from "@mui/material";
13
- import { getVisitorId as $, isUrl as Zo, ensureVisitorId as ei, setVisitorId as ke } from "@arcblock/ux/lib/Util";
12
+ import { useTheme as Qo, Typography as Yo, Box as $, CircularProgress as Jo } from "@mui/material";
13
+ import { getVisitorId as q, isUrl as Zo, ensureVisitorId as ei, setVisitorId as ke } from "@arcblock/ux/lib/Util";
14
14
  import ae, { ToastProvider as ye } from "@arcblock/ux/lib/Toast";
15
15
  import oi from "@arcblock/ux/lib/Center";
16
16
  import { useReactive as Ie, useCreation as Le, useMemoizedFn as f, usePrevious as ii, useLatest as De, useUpdateEffect as le, useMount as ti } from "ahooks";
17
- import { joinURL as H } from "ufo";
17
+ import { joinURL as M } from "ufo";
18
18
  import { Icon as ri } from "@iconify/react";
19
19
  import ni from "@iconify-icons/material-symbols/keyboard-double-arrow-right-rounded";
20
20
  import si from "@arcblock/react-hooks/lib/useBrowser";
@@ -23,46 +23,46 @@ import _e from "@arcblock/ux/lib/DID";
23
23
  import Ee from "@arcblock/ux/lib/Avatar";
24
24
  import { getCurrentAppPid as ai } from "@arcblock/ux/lib/SessionUser/libs/utils";
25
25
  import { translate as li } from "@arcblock/ux/lib/Locale/util";
26
- import { getBlockletSDK as di, BlockletSDK as pi } from "@blocklet/js-sdk";
26
+ import { getBlockletSDK as di } from "@blocklet/js-sdk";
27
27
  import A from "@arcblock/bridge";
28
- import { getFederatedEnabled as fi } from "@arcblock/ux/lib/Util/federated";
29
- import ui from "lodash/noop";
30
- import wi from "lodash/isNil";
31
- import { ReactGA as hi } from "@arcblock/ux/lib/withTracker";
32
- import { useState as mi, useEffect as gi } from "react";
28
+ import { getFederatedEnabled as pi } from "@arcblock/ux/lib/Util/federated";
29
+ import fi from "lodash/noop";
30
+ import ui from "lodash/isNil";
31
+ import { ReactGA as wi } from "@arcblock/ux/lib/withTracker";
32
+ import { useState as hi, useEffect as mi } from "react";
33
33
  import de from "../Storage/index.js";
34
- import { formatCacheTtl as Si, getBrowserLang as Pi, debug as m, decodeUrlParams as ve, sleep as E, debugTmp as xe, updateConnectedInfo as Z, getAppId as ee, logger as Oe } from "../utils.js";
34
+ import { formatCacheTtl as gi, getBrowserLang as Si, debug as m, 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 Ai, OAuthConsumer as bi, OAuthProvider as Ne, useOAuth as Ci } from "../OAuth/context.js";
37
- import { PasskeyContext as Ti, PasskeyConsumer as ki, PasskeyProvider as We, usePasskey as yi } from "../Passkey/context.js";
36
+ import { OAuthContext as Pi, OAuthConsumer as Ai, OAuthProvider as Ne, useOAuth as bi } from "../OAuth/context.js";
37
+ import { PasskeyContext as Ci, PasskeyConsumer as Ti, PasskeyProvider as We, usePasskey as ki } from "../Passkey/context.js";
38
38
  import "../Passkey/actions.js";
39
- import Ii, { getWalletDid as Li } from "../User/use-did.js";
40
- import Di from "../User/wrap-did.js";
41
- import _i from "./hooks/use-federated.js";
42
- import Ei from "./hooks/use-session-token.js";
43
- import vi from "./hooks/use-protected-routes.js";
44
- import { SessionContext as Xe } from "./context.js";
45
- import xi from "../Connect/use-connect.js";
39
+ import yi, { getWalletDid as Ii } from "../User/use-did.js";
40
+ import Li from "../User/wrap-did.js";
41
+ import Di from "./hooks/use-federated.js";
42
+ import _i from "./hooks/use-session-token.js";
43
+ import Ei from "./hooks/use-protected-routes.js";
44
+ import { SessionContext as qe } from "./context.js";
45
+ import vi from "../Connect/use-connect.js";
46
46
  import { EVENTS as c } from "./libs/constants.js";
47
- import { translations as F } from "./libs/locales.js";
48
- import { NotOpenError as Oi } from "../error.js";
49
- import { SESSION_TOKEN_STORAGE_KEY as Qe, REFRESH_TOKEN_STORAGE_KEY as Ye, CSRF_TOKEN_STORAGE_KEY as Ri, API_DID_PREFIX as Ni, DEFAULT_TIMEOUT as Wi, BLOCKLET_SERVICE_PATH_PREFIX as M, DID_SPACES_BASE_URL as Fi } from "../constant.js";
50
- import { getMobileVisitorId as Bi, checkEnableAutoLogin as Ui, login as Hi } from "./libs/login-mobile.js";
51
- import Mi from "../Connect/hooks/use-quick-connect.js";
47
+ import { translations as B } from "./libs/locales.js";
48
+ import { NotOpenError as xi } from "../error.js";
49
+ import { SESSION_TOKEN_STORAGE_KEY as Xe, REFRESH_TOKEN_STORAGE_KEY as Qe, CSRF_TOKEN_STORAGE_KEY as Oi, API_DID_PREFIX as Ri, DEFAULT_TIMEOUT as Ni, BLOCKLET_SERVICE_PATH_PREFIX as G, DID_SPACES_BASE_URL as Wi } from "../constant.js";
50
+ import { getMobileVisitorId as Fi, checkEnableAutoLogin as Bi, login as Ui } from "./libs/login-mobile.js";
51
+ import Hi from "../Connect/hooks/use-quick-connect.js";
52
52
  import { didSpacesIsRequired as Fe } from "./libs/did-spaces.js";
53
- import Gi from "./did-spaces-guide.js";
54
- import { FederatedProvider as zi, useFederatedContext as Vi } from "../Federated/context.js";
55
- import ji from "./hooks/use-verify.js";
53
+ import Mi from "./did-spaces-guide.js";
54
+ import { FederatedProvider as Gi, useFederatedContext as zi } from "../Federated/context.js";
55
+ import Vi from "./hooks/use-verify.js";
56
56
  import { gaLoginSuccessHandler as Be, gaLoginFailedHandler as Ue, gaSwitchPassportSuccessHandler as He, gaSwitchPassportFailedHandler as Me, gaBindWalletSuccessHandler as Ge, gaBindWalletFailedHandler as ze } from "./handler.js";
57
- import { loginFederatedMaster as Jt, mountFederatedIframe as Zt } from "./libs/federated.js";
58
- const Ve = di(), { Provider: Ki, Consumer: je } = Xe, Ke = {
57
+ import { loginFederatedMaster as Yt, mountFederatedIframe as Jt } from "./libs/federated.js";
58
+ const { Provider: ji, Consumer: Ve } = qe, je = {
59
59
  en: "DID Connect timeout, please reopen DID Connect popup",
60
60
  zh: "DID Connect 超时, 请重新打开 DID Connect"
61
- }, $e = {
61
+ }, Ke = {
62
62
  en: "DID Connect is already opened, please wait for it to complete",
63
63
  zh: "DID Connect 已打开,请等待完成"
64
64
  };
65
- function qe(q = Qe, X = "ls", oe = {}, T = {}) {
65
+ function $e(X = Xe, Q = "ls", ie = {}, T = {}) {
66
66
  let D = "/";
67
67
  globalThis?.blocklet?.prefix && (D = globalThis.blocklet.prefix), typeof T == "boolean" && (T = {
68
68
  appendAuthServicePrefix: T,
@@ -71,31 +71,31 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
71
71
  rolling: !0,
72
72
  appendAuthServicePrefix: !1,
73
73
  extraParams: {},
74
- refreshTokenStorageKey: Ye
74
+ refreshTokenStorageKey: Qe
75
75
  });
76
- function x(I) {
76
+ function O(I) {
77
77
  if (globalThis.blocklet)
78
78
  if (I?.user) {
79
- const r = {
79
+ const v = {
80
80
  did: I.user.did,
81
81
  host: window.location.host,
82
82
  appPid: globalThis.blocklet.appPid,
83
- visitorId: $(),
83
+ visitorId: q(),
84
84
  sourceAppPid: I.user.sourceAppPid,
85
85
  fullName: I.user.fullName
86
86
  };
87
- m("bridge callArc: onLogin", r), A.callArc("onLogin", { ...r, user: r });
87
+ m("bridge callArc: onLogin", v), A.callArc("onLogin", { ...v, user: v });
88
88
  } else
89
89
  A.callArc("onLogin", { error: "no user", code: 400 }), m("notifyBridge failed", { sessionState: I });
90
90
  }
91
- const Q = de(q, X, oe), G = de(Ri, "cookie", {
91
+ const Y = de(X, Q, ie), z = de(Oi, "cookie", {
92
92
  secure: !0,
93
93
  sameSite: "strict"
94
- }), Je = de(T.refreshTokenStorageKey, "ls");
94
+ }), Ye = de(T.refreshTokenStorageKey, "ls");
95
95
  function pe({ ...I }) {
96
- const r = Object.assign({}, I);
97
- w(r.serviceHost) && (r.serviceHost = D), w(r.locale) && (r.locale = ""), w(r.action) && (r.action = "login"), w(r.prefix) && (r.prefix = Ni), w(r.appendAuthServicePrefix) && (r.appendAuthServicePrefix = !1), w(r.extraParams) && (r.extraParams = {}), w(r.options) && (r.options = {}), w(r.autoConnect) && (r.autoConnect = !1), w(r.autoDisconnect) && (r.autoDisconnect = !0), w(r.useSocket) && (r.useSocket = !0), w(r.timeout) && (r.timeout = Wi * 1e3), w(r.webWalletUrl) && (r.webWalletUrl = void 0), w(r.protectedRoutes) && (r.protectedRoutes = ["*"]), w(r.apiOptions) && (r.apiOptions = {}), w(r.lazyRefreshToken) && (r.lazyRefreshToken = !1);
98
- const { connectApi: k, connectHolder: ie } = xi(), [eo, fe] = mi(0), y = si(), { requestStorageAccess: oo } = Vi(), { palette: io } = Qo(), B = new URLSearchParams(window.location.search), s = Ie({
96
+ const v = di(), r = Object.assign({}, I);
97
+ w(r.serviceHost) && (r.serviceHost = D), w(r.locale) && (r.locale = ""), w(r.action) && (r.action = "login"), w(r.prefix) && (r.prefix = Ri), w(r.appendAuthServicePrefix) && (r.appendAuthServicePrefix = !1), w(r.extraParams) && (r.extraParams = {}), w(r.options) && (r.options = {}), w(r.autoConnect) && (r.autoConnect = !1), w(r.autoDisconnect) && (r.autoDisconnect = !0), w(r.useSocket) && (r.useSocket = !0), w(r.timeout) && (r.timeout = Ni * 1e3), w(r.webWalletUrl) && (r.webWalletUrl = void 0), w(r.protectedRoutes) && (r.protectedRoutes = ["*"]), w(r.apiOptions) && (r.apiOptions = {}), w(r.lazyRefreshToken) && (r.lazyRefreshToken = !1);
98
+ const { connectApi: k, connectHolder: Ze } = vi(), [eo, fe] = hi(0), y = si(), { requestStorageAccess: oo } = zi(), { palette: io } = Qo(), U = new URLSearchParams(window.location.search), s = Ie({
99
99
  extraParams: {},
100
100
  options: {},
101
101
  currentLocale: r.locale,
@@ -105,11 +105,11 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
105
105
  return typeof r.autoConnect == "boolean" ? r.autoConnect : !!r.autoLogin;
106
106
  },
107
107
  get prefix() {
108
- return T.appendAuthServicePrefix || r.appendAuthServicePrefix ? H(M, r.prefix) : r.prefix;
108
+ return T.appendAuthServicePrefix || r.appendAuthServicePrefix ? M(G, r.prefix) : r.prefix;
109
109
  },
110
110
  get notificationPrefix() {
111
111
  const e = "/api/notifications";
112
- return T.appendAuthServicePrefix || r.appendAuthServicePrefix ? H(M, e) : e;
112
+ return T.appendAuthServicePrefix || r.appendAuthServicePrefix ? M(G, e) : e;
113
113
  }
114
114
  }), t = Ie({
115
115
  action: r.action,
@@ -123,16 +123,16 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
123
123
  baseUrl: "",
124
124
  unReadCount: 0
125
125
  // 不可以直接个性 props.autoConnect (readonly)
126
- }), b = Le(() => r.locale || s.currentLocale || Pi(), [r.locale, s.currentLocale]), { confirmApi: to, confirmHolder: ro } = ci(), O = f(() => {
126
+ }), b = Le(() => r.locale || s.currentLocale || Si(), [r.locale, s.currentLocale]), { confirmApi: to, confirmHolder: ro } = ci(), R = f(() => {
127
127
  if (t.open && !y.arcSphere) {
128
- const e = $e[b] || $e.en;
128
+ const e = Ke[b] || Ke.en;
129
129
  throw ae.warning(e), new Error(e);
130
130
  }
131
131
  }), d = Le(() => new qo(), []);
132
- gi(() => (d.on(c.LOGIN, Be), d.on(c.LOGIN_FAILED, Ue), d.on(c.SWITCH_PASSPORT, He), d.on(c.SWITCH_PASSPORT_FAILED, Me), d.on(c.BIND_WALLET, Ge), d.on(c.BIND_WALLET_FAILED, ze), () => {
132
+ mi(() => (d.on(c.LOGIN, Be), d.on(c.LOGIN_FAILED, Ue), d.on(c.SWITCH_PASSPORT, He), d.on(c.SWITCH_PASSPORT_FAILED, Me), d.on(c.BIND_WALLET, Ge), d.on(c.BIND_WALLET_FAILED, ze), () => {
133
133
  d.off(c.LOGIN, Be), d.off(c.LOGIN_FAILED, Ue), d.off(c.SWITCH_PASSPORT, He), d.off(c.SWITCH_PASSPORT_FAILED, Me), d.off(c.BIND_WALLET, Ge), d.off(c.BIND_WALLET_FAILED, ze);
134
134
  }), [d]);
135
- const U = f((e, o, i) => {
135
+ const H = f((e, o, i) => {
136
136
  const n = {
137
137
  login: [c.LOGIN, c.CANCEL_LOGIN],
138
138
  "bind-wallet": [c.BIND_WALLET, c.CANCEL_BIND_WALLET],
@@ -146,10 +146,10 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
146
146
  if (!Object.keys(n).includes(e))
147
147
  return;
148
148
  const l = async (...u) => {
149
- J(o) && await o(...u), d.emit(e, ...u);
149
+ Z(o) && await o(...u), d.emit(e, ...u);
150
150
  };
151
151
  d.once(n[e][0], l), d.once(n[e][1], async (...u) => {
152
- J(l) && d.off(n[e][0], l), J(i) && await i(...u), d.emit(`cancel-${e}`, ...u);
152
+ Z(l) && d.off(n[e][0], l), Z(i) && await i(...u), d.emit(`cancel-${e}`, ...u);
153
153
  });
154
154
  }), no = ii(t.initialized, (e, o) => e !== o || e === !0 && o === !0), {
155
155
  syncSessionSate: so,
@@ -157,19 +157,19 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
157
157
  handleRefreshToken: co,
158
158
  renewToken: ao,
159
159
  clearSession: ue,
160
- handleLoginResult: v,
160
+ handleLoginResult: x,
161
161
  decrypt: _,
162
162
  service: lo,
163
163
  getSessionToken: po,
164
164
  getRefreshToken: fo,
165
165
  setRefreshToken: uo,
166
166
  setSessionToken: wo
167
- } = Ei({
167
+ } = _i({
168
168
  state: t,
169
169
  pageState: s,
170
- sessionTokenStorage: Q,
171
- refreshTokenStorage: Je,
172
- csrfTokenStorage: G,
170
+ sessionTokenStorage: Y,
171
+ refreshTokenStorage: Ye,
172
+ csrfTokenStorage: z,
173
173
  serviceHost: r.serviceHost,
174
174
  apiOptions: r.apiOptions,
175
175
  lazyRefreshToken: r.lazyRefreshToken,
@@ -179,7 +179,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
179
179
  did: n.did,
180
180
  host: window.location.host,
181
181
  appPid: globalThis.blocklet.appPid,
182
- visitorId: $(),
182
+ visitorId: q(),
183
183
  sourceAppPid: n.sourceAppPid,
184
184
  fullName: n.fullName
185
185
  };
@@ -194,10 +194,10 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
194
194
  }));
195
195
  }
196
196
  }
197
- }), ho = ji({ state: t, connectApi: k }), we = f((e, o = {}, i = {}) => {
198
- O();
197
+ }), ho = Vi({ state: t, connectApi: k }), we = f((e, o = {}, i = {}) => {
198
+ R();
199
199
  const n = e;
200
- typeof n == "object" && (e = n.onSuccess, o = n.extraParams || {}, i = n.options || {}, i.origin = n.origin || ""), (!t.user || i.origin === "switch-did") && (i.origin === "switch-did" ? U("switch-did", e, n?.onCancel) : U("login", e, n?.onCancel), s.extraParams = o, s.options = i, t.action = "login", W());
200
+ typeof n == "object" && (e = n.onSuccess, o = n.extraParams || {}, i = n.options || {}, i.origin = n.origin || ""), (!t.user || i.origin === "switch-did") && (i.origin === "switch-did" ? H("switch-did", e, n?.onCancel) : H("login", e, n?.onCancel), s.extraParams = o, s.options = i, t.action = "login", F());
201
201
  }), mo = f((e, o = {}) => {
202
202
  const i = e;
203
203
  return function(...l) {
@@ -214,12 +214,12 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
214
214
  })();
215
215
  };
216
216
  }), te = f(async (e, o = {}, i = {}) => {
217
- O();
217
+ R();
218
218
  const n = e;
219
219
  typeof n == "object" && (e = n.onSuccess, o = n.extraParams || {}, i = n.options || {}), w(o?.inviter) && window.localStorage.getItem("inviter") && (o.inviter = window.localStorage.getItem("inviter"));
220
220
  const { params: l } = await ve();
221
221
  if (w(o?.forceConnected) && l?.forceConnected && (o.forceConnected = l.forceConnected, w(i.showQuickConnect) && (i.showQuickConnect = !1)), w(o?.sourceAppPid) && !w(l?.sourceAppPid) && (o.sourceAppPid = l.sourceAppPid), o?.openMode === "redirect") {
222
- const h = o?.redirect || "/", L = new URL(`${M}/login`, window.location.origin);
222
+ const h = o?.redirect || "/", L = new URL(`${G}/login`, window.location.origin);
223
223
  L.searchParams.set("redirect", h), o?.forceConnected && L.searchParams.set("forceConnected", o?.forceConnected), w(o?.sourceAppPid) || L.searchParams.set("sourceAppPid", o?.sourceAppPid), w(o?.inviter) || L.searchParams.set("inviter", o?.inviter), i?.origin && L.searchParams.set("origin", i.origin), window.location.href = L.href;
224
224
  return;
225
225
  }
@@ -228,10 +228,10 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
228
228
  const p = Te(o);
229
229
  p.passkeyBehavior = "both", s.allowWallet = void 0;
230
230
  const a = p?.openMode || r?.extraParams?.openMode;
231
- w(a) ? u ? u !== globalThis.blocklet.appPid && fi(globalThis.blocklet) && (s.openMode = "window") : s.openMode = "popup" : s.openMode = a, s.openMode === "window" && !y.arcSphere && !y.wallet && await oo() && (s.openMode = "popup"), u ? t.baseUrl = globalThis.blocklet.appUrl : t.baseUrl = "", we(e, p, i);
231
+ w(a) ? u ? u !== globalThis.blocklet.appPid && pi(globalThis.blocklet) && (s.openMode = "window") : s.openMode = "popup" : s.openMode = a, s.openMode === "window" && !y.arcSphere && !y.wallet && await oo() && (s.openMode = "popup"), u ? t.baseUrl = globalThis.blocklet.appUrl : t.baseUrl = "", we(e, p, i);
232
232
  }), he = f(async (e) => {
233
- const o = $();
234
- if (globalThis.blocklet && (Ve.user.logout({ visitorId: o }).catch((i) => {
233
+ const o = q();
234
+ if (globalThis.blocklet && (v.user.logout({ visitorId: o }).catch((i) => {
235
235
  console.warn("Failed to logout remote", i);
236
236
  }), await E(100)), globalThis.blocklet) {
237
237
  const i = {
@@ -241,7 +241,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
241
241
  };
242
242
  m("bridge callArc: onLogout", i), A.callArc("onLogout", i);
243
243
  }
244
- xe("[clearSession] createSessionContext -> logout:"), ue(), V(), t.user = null, t.provider = "", t.walletOS = "", t.error = "", t.loading = !1, d.emit("logout"), hi.set({
244
+ xe("[clearSession] createSessionContext -> logout:"), ue(), j(), t.user = null, t.provider = "", t.walletOS = "", t.error = "", t.loading = !1, d.emit("logout"), wi.set({
245
245
  user_id: void 0
246
246
  }), typeof e == "function" && e();
247
247
  }), {
@@ -249,61 +249,61 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
249
249
  refresh: So,
250
250
  loaded: Po,
251
251
  loginUserSession: re
252
- } = Mi({
252
+ } = Hi({
253
253
  appPid: ai(t.user),
254
254
  loginAppPid: globalThis?.blocklet?.appPid,
255
255
  sourceAppPid: t?.user?.sourceAppPid,
256
256
  autoFetch: !1,
257
257
  fetchAll: !0
258
- }), R = f(async () => {
258
+ }), N = f(async () => {
259
259
  t?.user || await new Promise((e) => {
260
260
  te(() => {
261
261
  e();
262
262
  });
263
263
  });
264
264
  }), ne = f((e, o = {}, i = {}) => {
265
- O();
265
+ R();
266
266
  const n = e;
267
267
  typeof n == "object" && (e = n.onSuccess, o = n.extraParams || {}, i = n.options || {}), typeof i == "string" && (i = { origin: i }), i?.userSession ? re(i.userSession).then((l) => {
268
- Z(
268
+ ee(
269
269
  {
270
270
  connected_did: i.userSession.user.did,
271
271
  connected_pk: i.userSession.user.pk,
272
272
  connected_wallet_os: i.userSession.extra.walletOS,
273
- connected_app: ee()
273
+ connected_app: oe()
274
274
  },
275
275
  !0
276
- ), U("switch-did", e), v({ ...l, encrypted: !1 }), C({ showProgress: !0 }).then(async () => {
277
- await E(200), d.emit(c.LOGIN, l, _, P.current), x(P.current), await N();
276
+ ), H("switch-did", e), x({ ...l, encrypted: !1 }), C({ showProgress: !0 }).then(async () => {
277
+ await E(200), d.emit(c.LOGIN, l, _, P.current), O(P.current), await W();
278
278
  }).catch((u) => {
279
279
  throw d.emit(c.LOGIN_FAILED, u), u;
280
280
  });
281
281
  }) : (w(o?.forceConnected) && (o.forceConnected = !1), o.passkeyBehavior = "both", te(e, o, { ...i, origin: "switch-did" }));
282
282
  }), Ao = f(async () => {
283
- await Ve.user.refreshProfile();
283
+ await v.user.refreshProfile();
284
284
  }), bo = f(async (e, o = {}) => {
285
- await R(), O();
285
+ await N(), R();
286
286
  const i = e;
287
- typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}), U("switch-profile", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "switch-profile", W();
287
+ typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}), H("switch-profile", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "switch-profile", F();
288
288
  }), Co = f(async (e, o = {}) => {
289
- await R(), O();
289
+ await N(), R();
290
290
  const i = e;
291
- typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}), U("switch-passport", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "switch-passport", W();
291
+ typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}), H("switch-passport", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "switch-passport", F();
292
292
  }), To = f(async ({ extraParams: e = {}, onSuccess: o = () => {
293
293
  }, ...i } = {}) => {
294
- await R(), O(), s.extraParams = {
294
+ await N(), R(), s.extraParams = {
295
295
  referrer: window.location.href,
296
296
  purpose: "authorize-for-import",
297
297
  ...e,
298
298
  saveConnect: !1
299
299
  // 连接 spaces 不保存连接信息
300
- }, s.options = {}, t.action = "connect-to-did-spaces-for-user", W({
300
+ }, s.options = {}, t.action = "connect-to-did-spaces-for-user", F({
301
301
  hideCloseButton: !0,
302
302
  onSuccess: o,
303
303
  ...i
304
304
  });
305
305
  }), me = f(async ({ extraParams: e = {}, onSuccess: o = {} } = {}) => {
306
- await R(), To({
306
+ await N(), To({
307
307
  extraParams: {
308
308
  // service 交互
309
309
  purpose: "authorize-for-import",
@@ -312,11 +312,11 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
312
312
  onSuccess: o,
313
313
  hideCloseButton: !1
314
314
  });
315
- }), { didSpacesGuideApi: Y, DidSpacesGuideView: ko } = Gi({
315
+ }), { didSpacesGuideApi: J, DidSpacesGuideView: ko } = Mi({
316
316
  autoClose: !1
317
- }), N = async ({ extraParams: e = {}, onSuccess: o = () => {
317
+ }), W = async ({ extraParams: e = {}, onSuccess: o = () => {
318
318
  } } = {}) => {
319
- await R(), await Fe(t?.user) && (Y.open(), Y.onConnect((i = ui) => {
319
+ await N(), await Fe(t?.user) && (J.open(), J.onConnect((i = fi) => {
320
320
  const n = {
321
321
  prefix: "/connect-to-did-space",
322
322
  custom: !0,
@@ -333,41 +333,41 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
333
333
  },
334
334
  onSuccess: async (l, u) => {
335
335
  const p = u ? u(l.spaceGateway) : l.spaceGateway;
336
- await new pi().user.updateDidSpace({ spaceGateway: p }), await C({ showProgress: !0 }), await o(l, u), await Y.close(), d.emit(c.DID_SPACE_CONNECTED, l, u), globalThis.blocklet && (m("bridge callArc: onDidSpaceConnected"), A.callArc("onDidSpaceConnected")), i(!0);
336
+ await v.user.updateDidSpace({ spaceGateway: p }), await C({ showProgress: !0 }), await o(l, u), await J.close(), d.emit(c.DID_SPACE_CONNECTED, l, u), globalThis.blocklet && (m("bridge callArc: onDidSpaceConnected"), A.callArc("onDidSpaceConnected")), i(!0);
337
337
  },
338
338
  onError: (l) => {
339
- console.error(l), ae.error(l.message), Y.close(), i(!1);
339
+ console.error(l), ae.error(l.message), J.close(), i(!1);
340
340
  },
341
341
  onClose: () => {
342
342
  i();
343
343
  }
344
344
  };
345
345
  k.openPopup(n, {
346
- baseUrl: Fi
346
+ baseUrl: Wi
347
347
  });
348
348
  }));
349
349
  }, ge = f(async (e, o = {}) => {
350
- if (await R(), Li(t.user)) {
350
+ if (await N(), Ii(t.user)) {
351
351
  e({}, _, P.current);
352
352
  return;
353
353
  }
354
- O();
354
+ R();
355
355
  const i = e;
356
- typeof i == "object" && (e = i.onSuccess), U("bind-wallet", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "bind-wallet", W();
356
+ typeof i == "object" && (e = i.onSuccess), H("bind-wallet", e, i?.onCancel), s.extraParams = o, s.options = {}, t.action = "bind-wallet", F();
357
357
  }), se = f(async (e) => {
358
- m("onSwitchPassport", { result: e }), s.extraParams = {}, s.options = {}, v(e), t.loading = !1, await C({ showProgress: !0 }), await E(200), d.emit(c.SWITCH_PASSPORT, e, _, P.current), globalThis.blocklet && (m("bridge callArc: onSwitchPassport"), A.callArc("onSwitchPassport"));
358
+ m("onSwitchPassport", { result: e }), s.extraParams = {}, s.options = {}, x(e), t.loading = !1, await C({ showProgress: !0 }), await E(200), d.emit(c.SWITCH_PASSPORT, e, _, P.current), globalThis.blocklet && (m("bridge callArc: onSwitchPassport"), A.callArc("onSwitchPassport"));
359
359
  }), yo = f((e) => {
360
360
  d.emit(c.SWITCH_PASSPORT_FAILED, e);
361
- }), z = f(async (e) => {
361
+ }), V = f(async (e) => {
362
362
  if (t.action === "switch-passport") {
363
363
  se(e);
364
364
  return;
365
365
  }
366
- m("onLogin", { result: e }), s.extraParams = {}, s.options = {}, v(e), t.loading = !1, await C({ showProgress: !0 }), await E(200), t.action === "login" && (m("onLogin: emit LOGIN event", { result: e }), d.emit(c.LOGIN, e, _, P.current), x(P.current), N());
366
+ m("onLogin", { result: e }), s.extraParams = {}, s.options = {}, x(e), t.loading = !1, await C({ showProgress: !0 }), await E(200), t.action === "login" && (m("onLogin: emit LOGIN event", { result: e }), d.emit(c.LOGIN, e, _, P.current), O(P.current), W());
367
367
  }), Io = f((e) => {
368
368
  d.emit(c.LOGIN_FAILED, e);
369
369
  }), Lo = f((e) => {
370
- s.extraParams = {}, s.options = {}, v(e), t.loading = !1, C({ showProgress: !0 }).then(async () => {
370
+ s.extraParams = {}, s.options = {}, x(e), t.loading = !1, C({ showProgress: !0 }).then(async () => {
371
371
  await E(100), d.emit(c.BIND_WALLET, e, _, P.current), globalThis.blocklet && (m("bridge callArc: onBindWallet"), A.callArc("onBindWallet"));
372
372
  });
373
373
  }), Do = f((e) => {
@@ -377,7 +377,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
377
377
  await E(100), d.emit(c.SWITCH_PROFILE, e, _, P.current), globalThis.blocklet && (m("bridge callArc: onSwitchProfile"), A.callArc("onSwitchProfile"));
378
378
  });
379
379
  }), Eo = f((e) => {
380
- s.extraParams = {}, s.options = {}, V();
380
+ s.extraParams = {}, s.options = {}, j();
381
381
  const o = {
382
382
  login: c.CANCEL_LOGIN,
383
383
  "switch-profile": c.CANCEL_SWITCH_PROFILE,
@@ -406,20 +406,20 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
406
406
  federatedMaster: Oo,
407
407
  federatedEnabled: Ro,
408
408
  master: No
409
- } = _i({
409
+ } = Di({
410
410
  locale: b,
411
411
  decrypt: _,
412
412
  login: we,
413
- handleLoginResult: v,
413
+ handleLoginResult: x,
414
414
  handleRefreshUser: C,
415
415
  setRefreshToken: uo,
416
416
  setSessionToken: wo
417
- }), { checkMatch: Wo } = vi({ protectedRoutes: r.protectedRoutes || [] }), Fo = De(go), Se = f(async () => (Po || (await So(), await E(100)), Fo.current)), V = f(() => {
417
+ }), { checkMatch: Wo } = Ei({ protectedRoutes: r.protectedRoutes || [] }), Fo = De(go), Se = f(async () => (Po || (await So(), await E(100)), Fo.current)), j = f(() => {
418
418
  t.open = !1, k.close();
419
- }), W = async (e = {}) => {
419
+ }), F = async (e = {}) => {
420
420
  let o = t.action;
421
421
  s?.options?.origin === "switch-did" && (o = s?.options?.origin);
422
- const i = F[o], n = i[b] || i.en, l = {
422
+ const i = B[o], n = i[b] || i.en, l = {
423
423
  ...T.extraParams,
424
424
  ...r.extraParams,
425
425
  ...s.extraParams,
@@ -427,7 +427,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
427
427
  email: t?.user?.email
428
428
  };
429
429
  if (o === "switch-did" && l?.forceConnected) {
430
- const p = (a, h = {}) => li(F["switch-specified-did"], a, b, "en", h);
430
+ const p = (a, h = {}) => li(B["switch-specified-did"], a, b, "en", h);
431
431
  n.title = p("title"), n.scan = p("scan", { did: l.forceConnected }), n.confirm = p("confirm"), n.success = p("success");
432
432
  }
433
433
  delete l?.openMode;
@@ -472,7 +472,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
472
472
  prefix: s.prefix,
473
473
  allowWallet: w(s.allowWallet) ? t.action !== "login" || ["1", "true", void 0, null].includes(globalThis.blocklet?.DID_CONNECT_ALLOW_WALLET) : s.allowWallet,
474
474
  onSuccess: async (...p) => {
475
- vo(t.action, ...p), J(e?.onSuccess) && await e.onSuccess(...p), t.open = !1;
475
+ vo(t.action, ...p), Z(e?.onSuccess) && await e.onSuccess(...p), t.open = !1;
476
476
  },
477
477
  onClose(...p) {
478
478
  Eo(t.action, ...p);
@@ -487,9 +487,9 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
487
487
  ...u,
488
488
  baseUrl: window.location.origin
489
489
  };
490
- Zo(s.prefix) || (p.prefix = H(window.location.origin, r.serviceHost, s.prefix)), p.extraParams?.provider || (p.extraParams.provider = t?.user?.provider || "wallet"), await k.openPopup(p, { locale: b });
490
+ Zo(s.prefix) || (p.prefix = M(window.location.origin, r.serviceHost, s.prefix)), p.extraParams?.provider || (p.extraParams.provider = t?.user?.provider || "wallet"), await k.openPopup(p, { locale: b });
491
491
  } catch (p) {
492
- p instanceof Oi && V(), p.message === "Timeout" ? ae.error(Ke[b] || Ke.en) : console.error(p);
492
+ p instanceof xi && j(), p.message === "Timeout" ? ae.error(je[b] || je.en) : console.error(p);
493
493
  }
494
494
  else
495
495
  k.open(u);
@@ -504,12 +504,12 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
504
504
  sourceAppPid: l,
505
505
  forceConnected: n
506
506
  }) : i === "disabled" ? window.history.replaceState(null, "trim", o) : to.open({
507
- title: F.switchAccountDialog[b].title,
508
- content: /* @__PURE__ */ j(zo, { children: [
509
- /* @__PURE__ */ g(Yo, { variant: "body1", sx: { textAlign: "center", mb: 2 }, children: F.switchAccountDialog[b].description }),
510
- /* @__PURE__ */ j(K, { sx: { display: "flex", alignItems: "center", color: "grey.A700" }, children: [
511
- /* @__PURE__ */ j(
512
- K,
507
+ title: B.switchAccountDialog[b].title,
508
+ content: /* @__PURE__ */ K(zo, { children: [
509
+ /* @__PURE__ */ g(Yo, { variant: "body1", sx: { textAlign: "center", mb: 2 }, children: B.switchAccountDialog[b].description }),
510
+ /* @__PURE__ */ K($, { sx: { display: "flex", alignItems: "center", color: "grey.A700" }, children: [
511
+ /* @__PURE__ */ K(
512
+ $,
513
513
  {
514
514
  sx: {
515
515
  display: "flex",
@@ -521,12 +521,12 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
521
521
  children: [
522
522
  /* @__PURE__ */ g(Ee, { did: t.user.did, shape: "circle", variant: "circle", size: 80 }),
523
523
  /* @__PURE__ */ g(_e, { did: t.user.did, showAvatar: !1, compact: !0, responsive: !1 }),
524
- F.switchAccountDialog[b].currentAccount
524
+ B.switchAccountDialog[b].currentAccount
525
525
  ]
526
526
  }
527
527
  ),
528
- /* @__PURE__ */ g(K, { sx: { display: "flex", justifyContent: "center", px: 2 }, children: /* @__PURE__ */ g(
529
- K,
528
+ /* @__PURE__ */ g($, { sx: { display: "flex", justifyContent: "center", px: 2 }, children: /* @__PURE__ */ g(
529
+ $,
530
530
  {
531
531
  component: ri,
532
532
  icon: ni,
@@ -551,8 +551,8 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
551
551
  }
552
552
  }
553
553
  ) }),
554
- /* @__PURE__ */ j(
555
- K,
554
+ /* @__PURE__ */ K(
555
+ $,
556
556
  {
557
557
  sx: {
558
558
  display: "flex",
@@ -565,7 +565,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
565
565
  children: [
566
566
  /* @__PURE__ */ g(Ee, { did: n, shape: "circle", variant: "circle", size: 80 }),
567
567
  /* @__PURE__ */ g(_e, { did: n, showAvatar: !1, compact: !0, responsive: !1 }),
568
- F.switchAccountDialog[b].nextAccount
568
+ B.switchAccountDialog[b].nextAccount
569
569
  ]
570
570
  }
571
571
  )
@@ -573,21 +573,21 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
573
573
  ] }),
574
574
  showCloseButton: u,
575
575
  showCancelButton: !1,
576
- confirmButtonText: F.switchAccountDialog[b].confirm,
576
+ confirmButtonText: B.switchAccountDialog[b].confirm,
577
577
  async onConfirm(p) {
578
578
  const h = (await Se()).find((L) => L.userDid === n);
579
579
  if (h) {
580
580
  re(h).then((L) => {
581
- Z(
581
+ ee(
582
582
  {
583
583
  connected_did: h.user.did,
584
584
  connected_pk: h.user.pk,
585
585
  connected_wallet_os: h.extra.walletOS,
586
- connected_app: ee()
586
+ connected_app: oe()
587
587
  },
588
588
  !0
589
- ), v({ ...L, encrypted: !1 }), C({ showProgress: !0 }).then(async () => {
590
- await E(200), d.emit(c.LOGIN, L, _, P.current), x(P.current), await N();
589
+ ), x({ ...L, encrypted: !1 }), C({ showProgress: !0 }).then(async () => {
590
+ await E(200), d.emit(c.LOGIN, L, _, P.current), O(P.current), await W();
591
591
  }).catch((Ce) => {
592
592
  throw d.emit(c.LOGIN_FAILED, Ce), Ce;
593
593
  });
@@ -613,12 +613,12 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
613
613
  },
614
614
  o?.requirements
615
615
  ), n = o?.openMode || "popup";
616
- i.login && await R(), i.bindWallet && await new Promise((l) => {
616
+ i.login && await N(), i.bindWallet && await new Promise((l) => {
617
617
  ge(() => {
618
618
  l();
619
619
  });
620
620
  }), i.bindDidSpaces && (await Fe(t?.user) || await new Promise((l) => {
621
- i.bindDidSpaces === "full" ? N({
621
+ i.bindDidSpaces === "full" ? W({
622
622
  onSuccess() {
623
623
  l();
624
624
  }
@@ -634,7 +634,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
634
634
  fe(e);
635
635
  }, [t.unReadCount]);
636
636
  const Uo = f(() => {
637
- B.get("magicToken") && B.delete("magicToken"), B.toString() && window.history.replaceState({}, "", `${window.location.pathname}?${B.toString()}`);
637
+ U.get("magicToken") && U.delete("magicToken"), U.toString() && window.history.replaceState({}, "", `${window.location.pathname}?${U.toString()}`);
638
638
  }), Ae = f((e) => new Promise((o, i) => {
639
639
  k.open({
640
640
  action: "login",
@@ -646,7 +646,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
646
646
  },
647
647
  magicToken: e,
648
648
  onSuccess(...n) {
649
- z(...n), Uo(), o();
649
+ V(...n), Uo(), o();
650
650
  },
651
651
  onError(n) {
652
652
  d.emit(c.LOGIN_FAILED, n), i(n);
@@ -664,38 +664,38 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
664
664
  switchProfile: bo,
665
665
  switchPassport: Co,
666
666
  connectToDidSpaceForImport: me,
667
- connectToDidSpaceForFullAccess: N,
667
+ connectToDidSpaceForFullAccess: W,
668
668
  bindWallet: ge,
669
669
  refresh: C,
670
- updateConnectedInfo: Z,
670
+ updateConnectedInfo: ee,
671
671
  // federated relates
672
672
  federatedMaster: Oo,
673
673
  // oauth relates
674
- useOAuth: Ci,
674
+ useOAuth: bi,
675
675
  OAuthProvider: Ne,
676
- OAuthConsumer: bi,
677
- OAuthContext: Ai,
676
+ OAuthConsumer: Ai,
677
+ OAuthContext: Pi,
678
678
  // passkey relates
679
- usePasskey: yi,
679
+ usePasskey: ki,
680
680
  PasskeyProvider: We,
681
- PasskeyConsumer: ki,
682
- PasskeyContext: Ti,
681
+ PasskeyConsumer: Ti,
682
+ PasskeyContext: Ci,
683
683
  // user related
684
- useDid: Ii,
685
- WrapDid: Di,
684
+ useDid: yi,
685
+ WrapDid: Li,
686
686
  getUserSessions: Se,
687
687
  async loginUserSession(e) {
688
688
  try {
689
689
  const o = await re(e);
690
- Z(
690
+ ee(
691
691
  {
692
692
  connected_did: e.user.did,
693
693
  connected_pk: e.user.pk,
694
694
  connected_wallet_os: e.extra.walletOS,
695
- connected_app: ee()
695
+ connected_app: oe()
696
696
  },
697
697
  !0
698
- ), v({ ...o, encrypted: !1 }), await C({ showProgress: !0 }), await E(200), d.emit(c.LOGIN, o, _, P.current), x(P.current), await N();
698
+ ), x({ ...o, encrypted: !1 }), await C({ showProgress: !0 }), await E(200), d.emit(c.LOGIN, o, _, P.current), O(P.current), await W();
699
699
  } catch (o) {
700
700
  throw d.emit(c.LOGIN_FAILED, o), o;
701
701
  }
@@ -708,11 +708,11 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
708
708
  }, P = De(Ho), Mo = {
709
709
  api: lo,
710
710
  events: d,
711
- storage: Q,
711
+ storage: Y,
712
712
  connectApi: k,
713
713
  session: P.current
714
714
  }, ce = {
715
- login: z,
715
+ login: V,
716
716
  "switch-profile": _o,
717
717
  "switch-passport": se,
718
718
  "switch-passport-failed": yo,
@@ -728,7 +728,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
728
728
  did: t.user.did,
729
729
  host: window.location.host,
730
730
  appPid: globalThis.blocklet.appPid,
731
- visitorId: $(),
731
+ visitorId: q(),
732
732
  sourceAppPid: t.user.sourceAppPid,
733
733
  fullName: t.user.fullName
734
734
  };
@@ -746,7 +746,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
746
746
  t.initialized && t.user && Pe();
747
747
  }, [t.initialized]), ti(async () => {
748
748
  const e = (a) => {
749
- wi(a.encrypted) && (a.encrypted = !1), window.temporaryDIDConnectOnSuccess instanceof Function ? (m("bridgeOnLogin: temporaryDIDConnectOnSuccess", { result: a }), window.temporaryDIDConnectOnSuccess(a, (h) => h)) : (m("bridgeOnLogin: onLogin", { result: a }), z(a));
749
+ ui(a.encrypted) && (a.encrypted = !1), window.temporaryDIDConnectOnSuccess instanceof Function ? (m("bridgeOnLogin: temporaryDIDConnectOnSuccess", { result: a }), window.temporaryDIDConnectOnSuccess(a, (h) => h)) : (m("bridgeOnLogin: onLogin", { result: a }), V(a));
750
750
  };
751
751
  if (A.registerBlocklet("callLoginOAuth", (a) => {
752
752
  m("bridge registerBlocklet: callLoginOAuth", a), k.loginOAuth({
@@ -755,34 +755,34 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
755
755
  });
756
756
  }), A.registerBlocklet("logout", he), A.registerBlocklet("login", (a) => {
757
757
  m("bridge registerBlocklet: login", a), e(a);
758
- }), ei(), !$()) {
758
+ }), ei(), !q()) {
759
759
  if (y.arcSphere) {
760
760
  m("bridge callArc: getVisitorId");
761
761
  const a = await A.callArc("getVisitorId");
762
762
  m("bridge callArc: getVisitorId result", { walletVisitorId: a }), ke(a);
763
763
  } else if (y.wallet) {
764
- const a = await Bi();
764
+ const a = await Fi();
765
765
  ke(a);
766
766
  }
767
767
  }
768
- const i = $o.get("connected_app"), n = ee();
768
+ const i = $o.get("connected_app"), n = oe();
769
769
  if (r.autoDisconnect && i && n && i !== n) {
770
770
  xe("[clearSession] createSessionContext -> SessionProvider -> useMount: autoDisconnect", {
771
771
  autoDisconnect: r.autoDisconnect,
772
772
  connectedApp: i,
773
773
  actualApp: n
774
- }), ue(), t.initialized = !0, s.autoConnect ? W() : V();
774
+ }), ue(), t.initialized = !0, s.autoConnect ? F() : j();
775
775
  return;
776
776
  }
777
777
  const l = po();
778
778
  if (window?.self === window?.parent) {
779
779
  let a = "web";
780
- if (y.mobile.apple.device ? a = "ios" : y.mobile.android.device && (a = "android"), y.wallet && Ui({ version: y.walletVersion, platform: a }) && !l)
780
+ if (y.mobile.apple.device ? a = "ios" : y.mobile.android.device && (a = "android"), y.wallet && Bi({ version: y.walletVersion, platform: a }) && !l)
781
781
  try {
782
782
  t.loading = !0;
783
- const h = await Hi();
783
+ const h = await Ui();
784
784
  if (h) {
785
- await z({
785
+ await V({
786
786
  sessionToken: h.sessionToken,
787
787
  refreshToken: h.refreshToken,
788
788
  csrfToken: h.csrfToken,
@@ -797,7 +797,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
797
797
  t.loading = !1;
798
798
  }
799
799
  }
800
- const u = B.get("magicToken");
800
+ const u = U.get("magicToken");
801
801
  if (u)
802
802
  try {
803
803
  t.initialized = !0, await Ae(u);
@@ -805,13 +805,13 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
805
805
  console.error("verifyMagicToken failed", a);
806
806
  }
807
807
  if (l) {
808
- await C({ showProgress: !0 }), t.initialized = !0, t.user && await N();
808
+ await C({ showProgress: !0 }), t.initialized = !0, t.user && await W();
809
809
  return;
810
810
  }
811
811
  if (typeof window < "u") {
812
812
  const a = new URL(window.location.href), h = a.searchParams.get("loginToken");
813
813
  if (h) {
814
- v({ loginToken: h, encrypted: !1 }), a.searchParams.delete("loginToken"), window.history.replaceState({}, window.title, a.href);
814
+ x({ loginToken: h, encrypted: !1 }), a.searchParams.delete("loginToken"), window.history.replaceState({}, window.title, a.href);
815
815
  return;
816
816
  }
817
817
  }
@@ -819,16 +819,16 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
819
819
  await co(!0), t.initialized = !0;
820
820
  return;
821
821
  }
822
- if (t.initialized = !0, s.autoConnect ? W() : V(), y.arcSphere && ![
822
+ if (t.initialized = !0, s.autoConnect ? F() : j(), y.arcSphere && ![
823
823
  // 不应该唤起自动登录的路由
824
- H(M, "login"),
825
- H(M, "connect"),
826
- H(M, "lost-passport")
824
+ M(G, "login"),
825
+ M(G, "connect"),
826
+ M(G, "lost-passport")
827
827
  ].includes(window.location.pathname) && !l)
828
828
  try {
829
829
  m("bridge callArc: autoLogin");
830
830
  const a = await A.callArc("autoLogin");
831
- m("bridgecallArc: autoLogin result", a), a && await z({
831
+ m("bridgecallArc: autoLogin result", a), a && await V({
832
832
  sessionToken: a.sessionToken,
833
833
  refreshToken: a.refreshToken,
834
834
  csrfToken: a.csrfToken,
@@ -839,7 +839,7 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
839
839
  d.emit(c.LOGIN_FAILED, a), Oe.error("Failed to autoLogin ArcSphere", a);
840
840
  }
841
841
  });
842
- const Go = B.has("popup");
842
+ const Go = U.has("popup");
843
843
  if (Wo() && !t.initialized)
844
844
  return /* @__PURE__ */ g(oi, { children: Go ? null : /* @__PURE__ */ g(Jo, {}) });
845
845
  const be = {
@@ -851,9 +851,9 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
851
851
  onRemovePasskey: () => C(),
852
852
  session: P.current
853
853
  };
854
- return /* @__PURE__ */ g(Ki, { value: Mo, children: /* @__PURE__ */ g(We, { ...be, children: /* @__PURE__ */ j(Ne, { ...be, children: [
854
+ return /* @__PURE__ */ g(ji, { value: Mo, children: /* @__PURE__ */ g(We, { ...be, children: /* @__PURE__ */ K(Ne, { ...be, children: [
855
855
  !t.open && typeof r.children == "function" ? r.children(t) : r.children,
856
- ie,
856
+ Ze,
857
857
  ro,
858
858
  ko,
859
859
  T.rolling && /* @__PURE__ */ g(Re, { callback: () => ao() }),
@@ -881,57 +881,57 @@ function qe(q = Qe, X = "ls", oe = {}, T = {}) {
881
881
  apiOptions: S.object,
882
882
  lazyRefreshToken: S.bool
883
883
  };
884
- function Ze(I) {
885
- return function(k) {
886
- return /* @__PURE__ */ g(ye, { children: /* @__PURE__ */ g(je, { children: (ie) => /* @__PURE__ */ g(I, { ...k, ...ie }) }) });
884
+ function Je(I) {
885
+ return function(r) {
886
+ return /* @__PURE__ */ g(ye, { children: /* @__PURE__ */ g(Ve, { children: (k) => /* @__PURE__ */ g(I, { ...r, ...k }) }) });
887
887
  };
888
888
  }
889
889
  return {
890
- SessionProvider: (I) => /* @__PURE__ */ g(ye, { children: /* @__PURE__ */ g(zi, { children: /* @__PURE__ */ g(pe, { ...I }) }) }),
891
- SessionConsumer: je,
892
- SessionContext: Xe,
893
- withSession: Ze
890
+ SessionProvider: (I) => /* @__PURE__ */ g(ye, { children: /* @__PURE__ */ g(Gi, { children: /* @__PURE__ */ g(pe, { ...I }) }) }),
891
+ SessionConsumer: Ve,
892
+ SessionContext: qe,
893
+ withSession: Je
894
894
  };
895
895
  }
896
- function Xt({ storageEngine: q = "cookie" } = {}) {
897
- const X = Qe, oe = Ye;
896
+ function qt({ storageEngine: X = "cookie" } = {}) {
897
+ const Q = Xe, ie = Qe;
898
898
  let T = null;
899
- if (typeof window < "u" && (T = (globalThis.blocklet || {}).componentId), q === "cookie") {
900
- let D = "/", x = 1;
899
+ if (typeof window < "u" && (T = (globalThis.blocklet || {}).componentId), X === "cookie") {
900
+ let D = "/", O = 1;
901
901
  if (typeof window < "u") {
902
- const Q = window.env || {}, G = window.blocklet || {};
903
- D = Q.groupPathPrefix || G.groupPrefix || G.prefix || "", D = D.replace(/\/+$/, ""), D = D || "/", G.serverVersion && (x = Si(window.blocklet?.settings?.session?.cacheTtl, 1 / 24));
902
+ const Y = window.env || {}, z = window.blocklet || {};
903
+ D = Y.groupPathPrefix || z.groupPrefix || z.prefix || "", D = D.replace(/\/+$/, ""), D = D || "/", z.serverVersion && (O = gi(window.blocklet?.settings?.session?.cacheTtl, 1 / 24));
904
904
  }
905
- return qe(
906
- X,
905
+ return $e(
906
+ Q,
907
907
  "cookie",
908
908
  {
909
909
  path: D,
910
910
  returnDomain: !1,
911
- expireInDays: x
911
+ expireInDays: O
912
912
  },
913
913
  {
914
914
  appendAuthServicePrefix: !0,
915
915
  extraParams: { componentId: T },
916
- refreshTokenStorageKey: oe
916
+ refreshTokenStorageKey: ie
917
917
  }
918
918
  );
919
919
  }
920
- if (q === "localStorage")
921
- return qe(X, "ls", {}, !0);
920
+ if (X === "localStorage")
921
+ return $e(Q, "ls", {}, !0);
922
922
  throw new Error("storageEngine must be cookie or localStorage");
923
923
  }
924
924
  export {
925
925
  c as EVENTS,
926
- Xe as SessionContext,
927
- Ui as checkEnableAutoLogin,
928
- Xt as createAuthServiceSessionContext,
929
- qe as createSessionContext,
930
- qe as default,
926
+ qe as SessionContext,
927
+ Bi as checkEnableAutoLogin,
928
+ qt as createAuthServiceSessionContext,
929
+ $e as createSessionContext,
930
+ $e as default,
931
931
  Fe as didSpacesIsRequired,
932
- Bi as getMobileVisitorId,
933
- Hi as login,
934
- Jt as loginFederatedMaster,
935
- Zt as mountFederatedIframe,
936
- F as translations
932
+ Fi as getMobileVisitorId,
933
+ Ui as login,
934
+ Yt as loginFederatedMaster,
935
+ Jt as mountFederatedIframe,
936
+ B as translations
937
937
  };