@arcblock/did-connect-react 3.4.3 → 3.4.4
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/components/login-item/connect-provider-list.js +34 -34
- package/lib/Connect/hooks/provider-list.js +29 -29
- package/lib/Passkey/context.js +65 -62
- package/lib/Session/index.js +425 -421
- package/lib/package.json.js +1 -1
- package/package.json +5 -5
- package/src/Connect/components/login-item/connect-provider-list.jsx +2 -2
- package/src/Connect/hooks/provider-list.js +7 -6
- package/src/Passkey/context.jsx +3 -0
- package/src/Session/index.jsx +15 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as l, jsxs as po } from "react/jsx-runtime";
|
|
2
2
|
import n from "prop-types";
|
|
3
3
|
import { Box as A } from "@mui/material";
|
|
4
|
-
import { LOGIN_PROVIDER as e, LOGIN_PROVIDER_ICON_SIZE as E, LOGIN_PROVIDER_NAME as
|
|
5
|
-
import { checkSameProtocol as
|
|
4
|
+
import { LOGIN_PROVIDER as e, LOGIN_PROVIDER_ICON_SIZE as E, LOGIN_PROVIDER_NAME as uo } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
+
import { checkSameProtocol as go, getWebWalletUrl as ho } from "@arcblock/ux/lib/Util/wallet";
|
|
6
6
|
import b from "lodash/noop";
|
|
7
7
|
import { useMemoizedFn as a, useCreation as fo } from "ahooks";
|
|
8
8
|
import O from "js-cookie";
|
|
@@ -10,7 +10,7 @@ import { detectWalletExtension as yo, getCookieOptions as Lo } from "@arcblock/u
|
|
|
10
10
|
import { useRef as w, useEffect as J } from "react";
|
|
11
11
|
import { mergeSx as Io } from "@arcblock/ux/lib/Util/style";
|
|
12
12
|
import Ao from "@arcblock/ux/lib/DIDConnect/provider-icon";
|
|
13
|
-
import { GA_LAST_LOGIN_METHOD as
|
|
13
|
+
import { GA_LAST_LOGIN_METHOD as y } from "@arcblock/ux/lib/withTracker/constant";
|
|
14
14
|
import { translate as Eo } from "@arcblock/ux/lib/Locale/util";
|
|
15
15
|
import bo from "@arcblock/ux/lib/Empty";
|
|
16
16
|
import { useBrowser as xo } from "@arcblock/react-hooks";
|
|
@@ -31,11 +31,11 @@ function No({
|
|
|
31
31
|
onError: T = b,
|
|
32
32
|
size: m = "small",
|
|
33
33
|
tokenState: t,
|
|
34
|
-
webWalletUrl: x =
|
|
34
|
+
webWalletUrl: x = ho(),
|
|
35
35
|
tokenKey: k,
|
|
36
36
|
passkeyBehavior: S = "none",
|
|
37
37
|
onReset: C = b,
|
|
38
|
-
providerList:
|
|
38
|
+
providerList: p = [],
|
|
39
39
|
slotProps: X = {},
|
|
40
40
|
disableSwitchApp: P = !1,
|
|
41
41
|
forceUpdate: z = b,
|
|
@@ -43,9 +43,9 @@ function No({
|
|
|
43
43
|
baseUrl: Q = "/",
|
|
44
44
|
customItems: oo = [],
|
|
45
45
|
qrcode: eo = null,
|
|
46
|
-
hideQRCode:
|
|
46
|
+
hideQRCode: d = !1
|
|
47
47
|
}) {
|
|
48
|
-
const M = w(null), v = w(null), j = w(null), no =
|
|
48
|
+
const M = w(null), v = w(null), j = w(null), no = go(x), N = yo(), u = xo(), { loginOAuth: to, logoutOAuth: ro, t: io, oauthState: s } = _o(), { passkeyState: D } = So(), {
|
|
49
49
|
extraParams: F,
|
|
50
50
|
locale: B,
|
|
51
51
|
connectState: i,
|
|
@@ -53,11 +53,11 @@ function No({
|
|
|
53
53
|
setPlugins: lo,
|
|
54
54
|
setSelectedPlugin: so,
|
|
55
55
|
getPlugin: U,
|
|
56
|
-
showWalletOptions:
|
|
56
|
+
showWalletOptions: f,
|
|
57
57
|
setShowWalletOptions: L,
|
|
58
|
-
lastLoginMethod:
|
|
58
|
+
lastLoginMethod: g
|
|
59
59
|
} = Oo(), I = a((o, r = {}) => Eo(jo, o, B, "en", r)), q = a(async (o) => {
|
|
60
|
-
localStorage.setItem(
|
|
60
|
+
localStorage.setItem(y, o.provider), t.reset(), s.reset({
|
|
61
61
|
status: "scanned"
|
|
62
62
|
}), D.reset(), i.chooseMethod = o.provider;
|
|
63
63
|
const r = F?.sourceAppPid;
|
|
@@ -66,8 +66,8 @@ function No({
|
|
|
66
66
|
const c = await to(o, {
|
|
67
67
|
action: t.action,
|
|
68
68
|
...F
|
|
69
|
-
}),
|
|
70
|
-
O.remove("connected_did",
|
|
69
|
+
}), h = Lo({ returnDomain: !1 });
|
|
70
|
+
O.remove("connected_did", h), O.remove("connected_pk", h), O.remove("connected_wallet_os", h), c?.sessionToken && (await W(
|
|
71
71
|
{
|
|
72
72
|
...c,
|
|
73
73
|
encrypted: !1
|
|
@@ -80,33 +80,33 @@ function No({
|
|
|
80
80
|
), s.loading = !1, s.status = "succeed");
|
|
81
81
|
} catch (c) {
|
|
82
82
|
Wo.error(`Failed login OAuth: ${o.provider}`, c);
|
|
83
|
-
const
|
|
84
|
-
s.loading = !1, s.error =
|
|
83
|
+
const h = To(c, io("loginOAuthFailed"));
|
|
84
|
+
s.loading = !1, s.error = h, s.status = "error", await ro({ provider: o.provider }), T(new Error(h));
|
|
85
85
|
}
|
|
86
86
|
}), K = a(async () => {
|
|
87
87
|
t.reset(), await C(), t.status = "created", i.chooseMethod = "wallet";
|
|
88
88
|
}), V = a(async () => {
|
|
89
|
-
localStorage.setItem(
|
|
89
|
+
localStorage.setItem(y, e.WALLET), t.reset(), await C(), t.status = "created", i.chooseMethod = "wallet";
|
|
90
90
|
const o = M.current?.connect;
|
|
91
91
|
i.retryConnect = () => {
|
|
92
92
|
o(K);
|
|
93
93
|
};
|
|
94
94
|
}), Y = a(() => {
|
|
95
|
-
localStorage.setItem(
|
|
95
|
+
localStorage.setItem(y, e.WALLET), t.status = "scanned", i.chooseMethod = "wallet-web";
|
|
96
96
|
const o = v.current.connect;
|
|
97
97
|
i.retryConnect = async () => {
|
|
98
98
|
await C(), t.error = "", t.status = "scanned", o();
|
|
99
99
|
};
|
|
100
100
|
}), co = a(() => {
|
|
101
101
|
L(!1);
|
|
102
|
-
}), _ = fo(() =>
|
|
102
|
+
}), _ = fo(() => p.length === 1 && p[0].provider === e.WALLET, [p]);
|
|
103
103
|
J(() => {
|
|
104
|
-
_ && !
|
|
105
|
-
}, [_,
|
|
106
|
-
const H =
|
|
107
|
-
if (R &&
|
|
104
|
+
d && _ && !u.mobile.any && !f && L(!0);
|
|
105
|
+
}, [d, _, u.mobile.any, L, f]);
|
|
106
|
+
const H = p.some((o) => o.provider === e.EMAIL), Z = Ro({ baseUrl: Q }), ao = a(() => {
|
|
107
|
+
if (R && p.some((o) => o.name === e.EMAIL) && G.some((o) => o.name === e.EMAIL)) {
|
|
108
108
|
const o = U(e.EMAIL);
|
|
109
|
-
o.state.status === "idle" && (localStorage.setItem(
|
|
109
|
+
o.state.status === "idle" && (localStorage.setItem(y, e.EMAIL), o.state.reset(), o.state.magicToken = R, i.chooseMethod = e.EMAIL, so(o), z());
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
J(() => {
|
|
@@ -119,13 +119,13 @@ function No({
|
|
|
119
119
|
ao();
|
|
120
120
|
}, 100);
|
|
121
121
|
}, [H]);
|
|
122
|
-
const $ =
|
|
122
|
+
const $ = p.map((o) => {
|
|
123
123
|
if (o.provider === e.WALLET)
|
|
124
|
-
return
|
|
124
|
+
return u.mobile.any && !f ? /* @__PURE__ */ l(
|
|
125
125
|
Co,
|
|
126
126
|
{
|
|
127
127
|
t: I,
|
|
128
|
-
isLatest:
|
|
128
|
+
isLatest: g && g === e.WALLET,
|
|
129
129
|
ref: M,
|
|
130
130
|
tokenState: t,
|
|
131
131
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
@@ -135,19 +135,19 @@ function No({
|
|
|
135
135
|
onClick: V
|
|
136
136
|
},
|
|
137
137
|
e.WALLET
|
|
138
|
-
) :
|
|
138
|
+
) : d || !d && (no || N) && (!u.mobile.any || N) ? /* @__PURE__ */ l(
|
|
139
139
|
Po,
|
|
140
140
|
{
|
|
141
141
|
t: I,
|
|
142
|
-
isLatest:
|
|
142
|
+
isLatest: g && g === e.WALLET,
|
|
143
143
|
ref: v,
|
|
144
144
|
tokenState: t,
|
|
145
145
|
webWalletUrl: x,
|
|
146
146
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
147
147
|
disableSwitchApp: P,
|
|
148
|
-
autoConnect: !
|
|
148
|
+
autoConnect: !d,
|
|
149
149
|
onClick: () => {
|
|
150
|
-
|
|
150
|
+
d ? L(!0) : Y();
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
e.WALLET
|
|
@@ -163,7 +163,7 @@ function No({
|
|
|
163
163
|
behavior: S,
|
|
164
164
|
sx: [m === "small" ? { p: 1 } : { p: 2 }],
|
|
165
165
|
onClick: () => {
|
|
166
|
-
localStorage.setItem(
|
|
166
|
+
localStorage.setItem(y, e.PASSKEY);
|
|
167
167
|
const r = j.current.connect;
|
|
168
168
|
i.chooseMethod = "passkey", i.retryConnect = () => {
|
|
169
169
|
D.verifying = !0, i.chooseMethod = "passkey", r();
|
|
@@ -196,8 +196,8 @@ function No({
|
|
|
196
196
|
Mo,
|
|
197
197
|
{
|
|
198
198
|
t: I,
|
|
199
|
-
isLatest:
|
|
200
|
-
title:
|
|
199
|
+
isLatest: g && g === o.provider,
|
|
200
|
+
title: uo[o.provider],
|
|
201
201
|
icon: /* @__PURE__ */ l(
|
|
202
202
|
Ao,
|
|
203
203
|
{
|
|
@@ -235,11 +235,11 @@ function No({
|
|
|
235
235
|
{
|
|
236
236
|
display: "flex",
|
|
237
237
|
flexDirection: "column",
|
|
238
|
-
...
|
|
238
|
+
...f && !u.mobile.any ? { alignItems: "center", gap: 0 } : { gap: 1.5 }
|
|
239
239
|
}
|
|
240
240
|
],
|
|
241
241
|
children: [
|
|
242
|
-
|
|
242
|
+
f && !u.mobile.any ? /* @__PURE__ */ l(
|
|
243
243
|
vo,
|
|
244
244
|
{
|
|
245
245
|
qrcode: eo,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useBrowser as k } from "@arcblock/react-hooks";
|
|
2
|
-
import { useRequest as y, useCreation as
|
|
3
|
-
import
|
|
2
|
+
import { useRequest as y, useCreation as p } from "ahooks";
|
|
3
|
+
import i from "lodash/isNil";
|
|
4
4
|
import { LOGIN_PROVIDER as s } from "@arcblock/ux/lib/Util/constant";
|
|
5
|
-
import { getFederatedEnabled as
|
|
6
|
-
import { useState as
|
|
7
|
-
const
|
|
5
|
+
import { getFederatedEnabled as C, getMaster as T, getBlockletData as I } from "@arcblock/ux/lib/Util/federated";
|
|
6
|
+
import { useState as S } from "react";
|
|
7
|
+
const B = async ({ sourceAppPid: d }) => {
|
|
8
8
|
const t = globalThis?.blocklet;
|
|
9
9
|
if (!t)
|
|
10
10
|
return {
|
|
@@ -18,49 +18,49 @@ const S = async ({ sourceAppPid: a }) => {
|
|
|
18
18
|
enabled: !0
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
const t = await
|
|
25
|
-
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !
|
|
21
|
+
const a = C(t), e = T(t);
|
|
22
|
+
return a && e?.appPid && d === e?.appPid ? (await I(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
|
|
23
|
+
}, R = async ({ sourceAppPid: d } = {}) => {
|
|
24
|
+
const t = await B({ sourceAppPid: d });
|
|
25
|
+
return Object.entries(t).map(([e, o]) => ({ ...o, provider: e })).filter((e) => e.enabled).sort((e, o) => !i(e?.order) && !i(o?.order) ? e.order - o.order : i(e?.order) ? 1 : -1);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
28
|
-
allowWallet:
|
|
27
|
+
function j({
|
|
28
|
+
allowWallet: d = !0,
|
|
29
29
|
passkeyBehavior: t = "none",
|
|
30
|
-
action:
|
|
30
|
+
action: a,
|
|
31
31
|
sourceAppPid: e,
|
|
32
32
|
mode: o = "dialog",
|
|
33
33
|
blocklet: b = globalThis.blocklet,
|
|
34
|
-
isSmallView:
|
|
34
|
+
isSmallView: L = !1,
|
|
35
35
|
lastLoginMethod: u = ""
|
|
36
36
|
}) {
|
|
37
|
-
const [P, g] =
|
|
37
|
+
const [P, g] = S(!1), w = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], E = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], c = k(), { data: v = [] } = y(
|
|
38
38
|
async () => {
|
|
39
39
|
g(!0);
|
|
40
|
-
const
|
|
41
|
-
return g(!1),
|
|
40
|
+
const l = await R({ sourceAppPid: e });
|
|
41
|
+
return g(!1), l;
|
|
42
42
|
},
|
|
43
43
|
{ refreshDeps: [e] }
|
|
44
|
-
), f =
|
|
44
|
+
), f = p(() => v.filter((r) => r.provider === s.WALLET ? d : r.provider === s.PASSKEY ? t !== "none" && !c.wallet && !c.arcSphere : r.provider === s.EMAIL ? E.includes(a) && (b?.settings?.notification?.email?.enabled ?? !1) : !(r.type === "oauth" && !w.includes(a))).sort((r, n) => {
|
|
45
45
|
if (u) {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
46
|
+
const h = r.provider === u, m = n.provider === u;
|
|
47
|
+
if (h && !m)
|
|
48
48
|
return -1;
|
|
49
|
-
if (!
|
|
49
|
+
if (!h && m)
|
|
50
50
|
return 1;
|
|
51
51
|
}
|
|
52
|
-
return !
|
|
53
|
-
}), [
|
|
54
|
-
const
|
|
55
|
-
return globalThis?.blocklet ? !!(f.find((
|
|
56
|
-
}, [o,
|
|
52
|
+
return !i(r?.order) && !i(n?.order) ? r.order - n.order : i(r?.order) ? i(n?.order) ? 0 : 1 : -1;
|
|
53
|
+
}), [v, u]), A = p(() => {
|
|
54
|
+
const l = o === "drawer" || L && c.mobile.any;
|
|
55
|
+
return globalThis?.blocklet ? !!(f.find((n) => n.provider === s.WALLET)?.showQrcode !== !0 || l) : !!l;
|
|
56
|
+
}, [o, L, f]);
|
|
57
57
|
return {
|
|
58
|
-
hideChooseList:
|
|
59
|
-
hideQRCode:
|
|
58
|
+
hideChooseList: p(() => !1),
|
|
59
|
+
hideQRCode: A,
|
|
60
60
|
providerList: f,
|
|
61
61
|
loadingProviderList: P
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
export {
|
|
65
|
-
|
|
65
|
+
j as default
|
|
66
66
|
};
|
package/lib/Passkey/context.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { use as
|
|
1
|
+
import { jsxs as z, jsx as O } from "react/jsx-runtime";
|
|
2
|
+
import y from "prop-types";
|
|
3
|
+
import J from "lodash/isUndefined";
|
|
4
|
+
import { use as K, createContext as W } from "react";
|
|
5
5
|
import u from "@arcblock/ux/lib/Toast";
|
|
6
|
-
import { useReactive as g, useMemoizedFn as i, useCreation as
|
|
6
|
+
import { useReactive as g, useMemoizedFn as i, useCreation as q } from "ahooks";
|
|
7
7
|
import w from "lodash/noop";
|
|
8
8
|
import { joinURL as S } from "ufo";
|
|
9
|
-
import { translate as
|
|
10
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX as
|
|
11
|
-
import { getBlockletData as
|
|
9
|
+
import { translate as G } from "@arcblock/ux/lib/Locale/util";
|
|
10
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as H } from "@arcblock/ux/lib/Util/constant";
|
|
11
|
+
import { getBlockletData as X, getFederatedEnabled as $, getMaster as Q } from "@arcblock/ux/lib/Util/federated";
|
|
12
12
|
import { startRegistration as Y, startAuthentication as Z } from "@simplewebauthn/browser";
|
|
13
|
-
import { createAxios as
|
|
14
|
-
import { parseResponse as
|
|
15
|
-
|
|
13
|
+
import { createAxios as ee, getWebAuthnErrorMessage as h, logger as U, getApiErrorMessage as A } from "../utils.js";
|
|
14
|
+
import { parseResponse as se, PassportSwitcher as te } from "../components/PassportSwitcher.js";
|
|
15
|
+
import F from "../Connect/assets/locale.js";
|
|
16
|
+
const E = W({}), { Provider: re, Consumer: ve } = E, ae = {
|
|
16
17
|
zh: {
|
|
18
|
+
...F.zh,
|
|
17
19
|
cancel: "取消",
|
|
18
20
|
usePasskey: "使用 Passkey",
|
|
19
21
|
createPasskey: "新建 Passkey",
|
|
@@ -45,6 +47,7 @@ const F = K({}), { Provider: te, Consumer: he } = F, re = {
|
|
|
45
47
|
}
|
|
46
48
|
},
|
|
47
49
|
en: {
|
|
50
|
+
...F.en,
|
|
48
51
|
cancel: "Cancel",
|
|
49
52
|
usePasskey: "Use Existing Passkey",
|
|
50
53
|
createPasskey: "Create New Passkey",
|
|
@@ -76,15 +79,15 @@ const F = K({}), { Provider: te, Consumer: he } = F, re = {
|
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
|
-
function
|
|
82
|
+
function ne({
|
|
80
83
|
children: m,
|
|
81
84
|
locale: l = "en",
|
|
82
|
-
onAddPasskey:
|
|
83
|
-
onRemovePasskey:
|
|
84
|
-
onSwitchPassport:
|
|
85
|
-
session:
|
|
85
|
+
onAddPasskey: C = w,
|
|
86
|
+
onRemovePasskey: I = w,
|
|
87
|
+
onSwitchPassport: R = w,
|
|
88
|
+
session: x = null
|
|
86
89
|
}) {
|
|
87
|
-
const v = S(window.env?.apiPrefix ||
|
|
90
|
+
const v = S(window.env?.apiPrefix || H, "/api/passkey"), r = g({
|
|
88
91
|
baseUrl: "/",
|
|
89
92
|
session: void 0,
|
|
90
93
|
connecting: !1,
|
|
@@ -117,7 +120,7 @@ function ae({
|
|
|
117
120
|
reset() {
|
|
118
121
|
d.creating = !1, d.verifying = !1, d.creatingStatus = "", d.verifyingStatus = "", d.error = "";
|
|
119
122
|
}
|
|
120
|
-
}), n = i((t, e = {}) =>
|
|
123
|
+
}), n = i((t, e = {}) => G(ae, t, l, "en", e)), c = q(() => ee({ baseURL: S(r.baseUrl, v), sessionTokenKey: "__sst", timeout: 60 * 1e3 }), [r.baseUrl, v]), B = i(async () => {
|
|
121
124
|
if (r.baseUrl === "/")
|
|
122
125
|
return window.blocklet;
|
|
123
126
|
try {
|
|
@@ -125,10 +128,10 @@ function ae({
|
|
|
125
128
|
return window.blocklet;
|
|
126
129
|
} catch {
|
|
127
130
|
}
|
|
128
|
-
return await
|
|
129
|
-
}), P = window?.blocklet?.componentId,
|
|
131
|
+
return await X(r.baseUrl);
|
|
132
|
+
}), P = window?.blocklet?.componentId, T = (t) => {
|
|
130
133
|
r.baseUrl = t || "/";
|
|
131
|
-
},
|
|
134
|
+
}, M = (t) => {
|
|
132
135
|
r.targetAppPid = t;
|
|
133
136
|
}, b = i(async (t) => {
|
|
134
137
|
const { data: e } = await c.get("/register", { params: t });
|
|
@@ -158,7 +161,7 @@ function ae({
|
|
|
158
161
|
} catch (s) {
|
|
159
162
|
throw console.error("passkey.auth.error", s), s.name ? new Error(h(s, n("verifyPasskeyFailed"), n)) : s;
|
|
160
163
|
}
|
|
161
|
-
}),
|
|
164
|
+
}), D = async (t) => {
|
|
162
165
|
r.connecting = !0;
|
|
163
166
|
try {
|
|
164
167
|
const e = await b({
|
|
@@ -166,13 +169,13 @@ function ae({
|
|
|
166
169
|
locale: l,
|
|
167
170
|
componentId: P
|
|
168
171
|
});
|
|
169
|
-
return u.success(n("connectPasskeySucceed")),
|
|
172
|
+
return u.success(n("connectPasskeySucceed")), C(e), e;
|
|
170
173
|
} catch (e) {
|
|
171
174
|
U.error("Failed to connect passkey", e), u.error(A(e, n("connectPasskeyFailed")));
|
|
172
175
|
} finally {
|
|
173
176
|
r.connecting = !1;
|
|
174
177
|
}
|
|
175
|
-
},
|
|
178
|
+
}, N = async ({ session: t, connectedAccount: e }) => {
|
|
176
179
|
r.session = t, r.disconnecting = !0;
|
|
177
180
|
try {
|
|
178
181
|
const s = await k({
|
|
@@ -182,28 +185,28 @@ function ae({
|
|
|
182
185
|
sourceAppPid: t?.user?.sourceAppPid,
|
|
183
186
|
credentialId: e.id
|
|
184
187
|
});
|
|
185
|
-
u.success(n("disconnectPasskeySucceed")),
|
|
188
|
+
u.success(n("disconnectPasskeySucceed")), I(s);
|
|
186
189
|
} catch (s) {
|
|
187
190
|
U.error("Failed to disconnect passkey", s), u.error(A(s, n("disconnectPasskeyFailed")));
|
|
188
191
|
} finally {
|
|
189
192
|
r.disconnecting = !1;
|
|
190
193
|
}
|
|
191
|
-
},
|
|
194
|
+
}, j = async (t = {}) => {
|
|
192
195
|
try {
|
|
193
196
|
const { data: e } = await c.get("/passports");
|
|
194
197
|
e.length ? (o.open = !0, o.currentUser = t, o.passports = e || []) : u.error(n("noPassports"));
|
|
195
198
|
} catch (e) {
|
|
196
199
|
u.error(e.message || n("getPassportFailed"));
|
|
197
200
|
}
|
|
198
|
-
},
|
|
199
|
-
o.reset(),
|
|
200
|
-
}),
|
|
201
|
+
}, L = i((...t) => {
|
|
202
|
+
o.reset(), R(...t);
|
|
203
|
+
}), _ = i(async ({ action: t = "login", ...e } = {}) => {
|
|
201
204
|
const s = r.baseUrl;
|
|
202
205
|
if (e?.sourceAppPid === window.blocklet?.appPid)
|
|
203
206
|
r.baseUrl = window.blocklet?.appUrl || "/";
|
|
204
207
|
else if (e?.sourceAppPid) {
|
|
205
|
-
const a = await
|
|
206
|
-
|
|
208
|
+
const a = await B(), p = $(a), f = Q(a);
|
|
209
|
+
p && f?.appPid && e?.sourceAppPid === f?.appPid && (r.baseUrl = f.appUrl);
|
|
207
210
|
}
|
|
208
211
|
try {
|
|
209
212
|
const a = {
|
|
@@ -212,32 +215,32 @@ function ae({
|
|
|
212
215
|
locale: l,
|
|
213
216
|
componentId: P
|
|
214
217
|
};
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
return
|
|
218
|
+
J(a.inviter) && window.localStorage.getItem("inviter") && (a.inviter = window.localStorage.getItem("inviter"));
|
|
219
|
+
const p = se(await k(a));
|
|
220
|
+
return p.provider = "passkey", p;
|
|
218
221
|
} catch (a) {
|
|
219
222
|
console.error("passkey.login.error", a);
|
|
220
|
-
const
|
|
221
|
-
throw r.baseUrl = s, new Error(
|
|
223
|
+
const p = h(a, n("verifyPasskeyFailed"), n);
|
|
224
|
+
throw r.baseUrl = s, new Error(p);
|
|
222
225
|
}
|
|
223
|
-
}),
|
|
226
|
+
}), V = i(() => {
|
|
224
227
|
});
|
|
225
|
-
return /* @__PURE__ */
|
|
226
|
-
|
|
228
|
+
return /* @__PURE__ */ z(
|
|
229
|
+
re,
|
|
227
230
|
{
|
|
228
231
|
value: {
|
|
229
232
|
api: c,
|
|
230
233
|
locale: l,
|
|
231
|
-
connectPasskey:
|
|
232
|
-
disconnectPasskey:
|
|
234
|
+
connectPasskey: D,
|
|
235
|
+
disconnectPasskey: N,
|
|
233
236
|
createPasskey: b,
|
|
234
237
|
verifyPasskey: k,
|
|
235
|
-
loginPasskey:
|
|
236
|
-
logoutPasskey:
|
|
237
|
-
switchPassport:
|
|
238
|
+
loginPasskey: _,
|
|
239
|
+
logoutPasskey: V,
|
|
240
|
+
switchPassport: j,
|
|
238
241
|
baseUrl: r.baseUrl,
|
|
239
|
-
setBaseUrl:
|
|
240
|
-
setTargetAppPid:
|
|
242
|
+
setBaseUrl: T,
|
|
243
|
+
setTargetAppPid: M,
|
|
241
244
|
passkeyState: d,
|
|
242
245
|
disconnecting: r.disconnecting,
|
|
243
246
|
connecting: r.connecting,
|
|
@@ -246,33 +249,33 @@ function ae({
|
|
|
246
249
|
children: [
|
|
247
250
|
m,
|
|
248
251
|
/* @__PURE__ */ O(
|
|
249
|
-
|
|
252
|
+
te,
|
|
250
253
|
{
|
|
251
254
|
api: c,
|
|
252
255
|
locale: l,
|
|
253
256
|
switchState: o,
|
|
254
|
-
onSwitchPassport:
|
|
255
|
-
session:
|
|
257
|
+
onSwitchPassport: L,
|
|
258
|
+
session: x
|
|
256
259
|
}
|
|
257
260
|
)
|
|
258
261
|
]
|
|
259
262
|
}
|
|
260
263
|
);
|
|
261
264
|
}
|
|
262
|
-
function
|
|
263
|
-
return
|
|
265
|
+
function be() {
|
|
266
|
+
return K(E);
|
|
264
267
|
}
|
|
265
|
-
|
|
266
|
-
children:
|
|
267
|
-
locale:
|
|
268
|
-
onAddPasskey:
|
|
269
|
-
onRemovePasskey:
|
|
270
|
-
onSwitchPassport:
|
|
271
|
-
session:
|
|
268
|
+
ne.propTypes = {
|
|
269
|
+
children: y.node.isRequired,
|
|
270
|
+
locale: y.string,
|
|
271
|
+
onAddPasskey: y.func,
|
|
272
|
+
onRemovePasskey: y.func,
|
|
273
|
+
onSwitchPassport: y.func,
|
|
274
|
+
session: y.object
|
|
272
275
|
};
|
|
273
276
|
export {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
ve as PasskeyConsumer,
|
|
278
|
+
E as PasskeyContext,
|
|
279
|
+
ne as PasskeyProvider,
|
|
280
|
+
be as usePasskey
|
|
278
281
|
};
|