@arcblock/did-connect-react 3.3.10 → 3.4.0
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.
- package/lib/Connect/connect.js +501 -0
- package/lib/Connect/contexts/state.js +3 -3
- package/lib/Connect/fallback-connect.js +53 -0
- package/lib/Connect/hooks/provider-list.js +25 -19
- package/lib/Connect/index.js +13 -502
- package/lib/Connect/use-connect.js +10 -10
- package/lib/OAuth/context.js +3 -3
- package/lib/Passkey/context.js +3 -3
- package/lib/Passkey/dialog.js +7 -7
- package/lib/Session/assets/did-spaces-guide-cover.svg.js +74 -98
- package/lib/Session/index.js +189 -189
- package/lib/package.json.js +1 -1
- package/lib/utils.js +2 -2
- package/package.json +8 -8
- package/src/Connect/connect.jsx +616 -0
- package/src/Connect/fallback-connect.jsx +47 -0
- package/src/Connect/hooks/provider-list.js +5 -0
- package/src/Connect/index.jsx +8 -605
- package/src/Connect/use-connect.jsx +1 -1
- package/src/Session/assets/did-spaces-guide-cover.svg +1 -128
- package/src/Session/index.jsx +3 -4
- package/src/utils.js +2 -2
package/lib/Session/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as g, jsxs as
|
|
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
|
|
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
|
|
13
|
-
import { getVisitorId as
|
|
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
|
|
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
|
|
26
|
+
import { getBlockletSDK as di } from "@blocklet/js-sdk";
|
|
27
27
|
import A from "@arcblock/bridge";
|
|
28
|
-
import { getFederatedEnabled as
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import { ReactGA as
|
|
32
|
-
import { useState as
|
|
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
|
|
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
|
|
37
|
-
import { PasskeyContext as
|
|
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
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import { SessionContext as
|
|
45
|
-
import
|
|
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
|
|
48
|
-
import { NotOpenError as
|
|
49
|
-
import { SESSION_TOKEN_STORAGE_KEY as
|
|
50
|
-
import { getMobileVisitorId as
|
|
51
|
-
import
|
|
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
|
|
54
|
-
import { FederatedProvider as
|
|
55
|
-
import
|
|
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
|
|
58
|
-
const
|
|
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
|
-
},
|
|
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
|
|
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:
|
|
74
|
+
refreshTokenStorageKey: Qe
|
|
75
75
|
});
|
|
76
|
-
function
|
|
76
|
+
function O(I) {
|
|
77
77
|
if (globalThis.blocklet)
|
|
78
78
|
if (I?.user) {
|
|
79
|
-
const
|
|
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",
|
|
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
|
|
91
|
+
const Y = de(X, Q, ie), z = de(Oi, "cookie", {
|
|
92
92
|
secure: !0,
|
|
93
93
|
sameSite: "strict"
|
|
94
|
-
}),
|
|
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 =
|
|
98
|
-
const { connectApi: k, connectHolder:
|
|
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 ?
|
|
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 ?
|
|
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 ||
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
} =
|
|
167
|
+
} = _i({
|
|
168
168
|
state: t,
|
|
169
169
|
pageState: s,
|
|
170
|
-
sessionTokenStorage:
|
|
171
|
-
refreshTokenStorage:
|
|
172
|
-
csrfTokenStorage:
|
|
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 =
|
|
198
|
-
|
|
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" ?
|
|
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
|
-
|
|
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(`${
|
|
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 &&
|
|
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 && (
|
|
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(),
|
|
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
|
-
} =
|
|
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
|
-
}),
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
273
|
+
connected_app: oe()
|
|
274
274
|
},
|
|
275
275
|
!0
|
|
276
|
-
),
|
|
277
|
-
await E(200), d.emit(c.LOGIN, l, _, P.current),
|
|
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
|
|
283
|
+
await v.user.refreshProfile();
|
|
284
284
|
}), bo = f(async (e, o = {}) => {
|
|
285
|
-
await
|
|
285
|
+
await N(), R();
|
|
286
286
|
const i = e;
|
|
287
|
-
typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}),
|
|
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
|
|
289
|
+
await N(), R();
|
|
290
290
|
const i = e;
|
|
291
|
-
typeof i == "object" && (e = i.onSuccess, o = i.extraParams || {}),
|
|
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
|
|
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",
|
|
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
|
|
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:
|
|
315
|
+
}), { didSpacesGuideApi: J, DidSpacesGuideView: ko } = Mi({
|
|
316
316
|
autoClose: !1
|
|
317
|
-
}),
|
|
317
|
+
}), W = async ({ extraParams: e = {}, onSuccess: o = () => {
|
|
318
318
|
} } = {}) => {
|
|
319
|
-
await
|
|
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
|
|
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),
|
|
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:
|
|
346
|
+
baseUrl: Wi
|
|
347
347
|
});
|
|
348
348
|
}));
|
|
349
349
|
}, ge = f(async (e, o = {}) => {
|
|
350
|
-
if (await
|
|
350
|
+
if (await N(), Ii(t.user)) {
|
|
351
351
|
e({}, _, P.current);
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
|
-
|
|
354
|
+
R();
|
|
355
355
|
const i = e;
|
|
356
|
-
typeof i == "object" && (e = i.onSuccess),
|
|
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 = {},
|
|
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
|
-
}),
|
|
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 = {},
|
|
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 = {},
|
|
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 = {},
|
|
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
|
-
} =
|
|
409
|
+
} = Di({
|
|
410
410
|
locale: b,
|
|
411
411
|
decrypt: _,
|
|
412
412
|
login: we,
|
|
413
|
-
handleLoginResult:
|
|
413
|
+
handleLoginResult: x,
|
|
414
414
|
handleRefreshUser: C,
|
|
415
415
|
setRefreshToken: uo,
|
|
416
416
|
setSessionToken: wo
|
|
417
|
-
}), { checkMatch: Wo } =
|
|
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
|
-
}),
|
|
419
|
+
}), F = async (e = {}) => {
|
|
420
420
|
let o = t.action;
|
|
421
421
|
s?.options?.origin === "switch-did" && (o = s?.options?.origin);
|
|
422
|
-
const i =
|
|
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(
|
|
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),
|
|
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 =
|
|
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
|
|
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:
|
|
508
|
-
content: /* @__PURE__ */
|
|
509
|
-
/* @__PURE__ */ g(Yo, { variant: "body1", sx: { textAlign: "center", mb: 2 }, children:
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
/* @__PURE__ */
|
|
512
|
-
|
|
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
|
-
|
|
524
|
+
B.switchAccountDialog[b].currentAccount
|
|
525
525
|
]
|
|
526
526
|
}
|
|
527
527
|
),
|
|
528
|
-
/* @__PURE__ */ g(
|
|
529
|
-
|
|
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__ */
|
|
555
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
586
|
+
connected_app: oe()
|
|
587
587
|
},
|
|
588
588
|
!0
|
|
589
|
-
),
|
|
590
|
-
await E(200), d.emit(c.LOGIN, L, _, P.current),
|
|
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
|
|
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" ?
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
667
|
+
connectToDidSpaceForFullAccess: W,
|
|
668
668
|
bindWallet: ge,
|
|
669
669
|
refresh: C,
|
|
670
|
-
updateConnectedInfo:
|
|
670
|
+
updateConnectedInfo: ee,
|
|
671
671
|
// federated relates
|
|
672
672
|
federatedMaster: Oo,
|
|
673
673
|
// oauth relates
|
|
674
|
-
useOAuth:
|
|
674
|
+
useOAuth: bi,
|
|
675
675
|
OAuthProvider: Ne,
|
|
676
|
-
OAuthConsumer:
|
|
677
|
-
OAuthContext:
|
|
676
|
+
OAuthConsumer: Ai,
|
|
677
|
+
OAuthContext: Pi,
|
|
678
678
|
// passkey relates
|
|
679
|
-
usePasskey:
|
|
679
|
+
usePasskey: ki,
|
|
680
680
|
PasskeyProvider: We,
|
|
681
|
-
PasskeyConsumer:
|
|
682
|
-
PasskeyContext:
|
|
681
|
+
PasskeyConsumer: Ti,
|
|
682
|
+
PasskeyContext: Ci,
|
|
683
683
|
// user related
|
|
684
|
-
useDid:
|
|
685
|
-
WrapDid:
|
|
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
|
-
|
|
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:
|
|
695
|
+
connected_app: oe()
|
|
696
696
|
},
|
|
697
697
|
!0
|
|
698
|
-
),
|
|
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:
|
|
711
|
+
storage: Y,
|
|
712
712
|
connectApi: k,
|
|
713
713
|
session: P.current
|
|
714
714
|
}, ce = {
|
|
715
|
-
login:
|
|
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
|
-
|
|
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
|
|
764
|
+
const a = await Fi();
|
|
765
765
|
ke(a);
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
-
const i = $o.get("connected_app"), n =
|
|
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 ?
|
|
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 &&
|
|
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
|
|
783
|
+
const h = await Ui();
|
|
784
784
|
if (h) {
|
|
785
|
-
await
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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 ?
|
|
822
|
+
if (t.initialized = !0, s.autoConnect ? F() : j(), y.arcSphere && ![
|
|
823
823
|
// 不应该唤起自动登录的路由
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
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
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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
|
|
885
|
-
return function(
|
|
886
|
-
return /* @__PURE__ */ g(ye, { children: /* @__PURE__ */ g(
|
|
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(
|
|
891
|
-
SessionConsumer:
|
|
892
|
-
SessionContext:
|
|
893
|
-
withSession:
|
|
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
|
|
897
|
-
const
|
|
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),
|
|
900
|
-
let D = "/",
|
|
899
|
+
if (typeof window < "u" && (T = (globalThis.blocklet || {}).componentId), X === "cookie") {
|
|
900
|
+
let D = "/", O = 1;
|
|
901
901
|
if (typeof window < "u") {
|
|
902
|
-
const
|
|
903
|
-
D =
|
|
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
|
|
906
|
-
|
|
905
|
+
return $e(
|
|
906
|
+
Q,
|
|
907
907
|
"cookie",
|
|
908
908
|
{
|
|
909
909
|
path: D,
|
|
910
910
|
returnDomain: !1,
|
|
911
|
-
expireInDays:
|
|
911
|
+
expireInDays: O
|
|
912
912
|
},
|
|
913
913
|
{
|
|
914
914
|
appendAuthServicePrefix: !0,
|
|
915
915
|
extraParams: { componentId: T },
|
|
916
|
-
refreshTokenStorageKey:
|
|
916
|
+
refreshTokenStorageKey: ie
|
|
917
917
|
}
|
|
918
918
|
);
|
|
919
919
|
}
|
|
920
|
-
if (
|
|
921
|
-
return
|
|
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
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
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
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
932
|
+
Fi as getMobileVisitorId,
|
|
933
|
+
Ui as login,
|
|
934
|
+
Yt as loginFederatedMaster,
|
|
935
|
+
Jt as mountFederatedIframe,
|
|
936
|
+
B as translations
|
|
937
937
|
};
|