@abyss-project/commons-front-core 5.0.0 → 6.0.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/dist/{CookieConsentSettings.component-Qv7WlFv1.js → CookieConsentSettings.component-Da4l2tFQ.js} +1073 -1038
- package/dist/auth/client/abyss-login.d.ts +61 -0
- package/dist/auth/client/abyss-login.spec.d.ts +1 -0
- package/dist/auth/client/auth-refresh-interceptor.d.ts +41 -0
- package/dist/auth/client/auth-refresh-interceptor.spec.d.ts +1 -0
- package/dist/auth/client/index.d.ts +2 -0
- package/dist/auth/client/web-bridge.d.ts +10 -5
- package/dist/auth/components/RequireSession/RequireSession.component.d.ts +17 -0
- package/dist/auth/components/RequireSession/RequireSession.component.spec.d.ts +1 -0
- package/dist/auth/components/RequireSession/RequireSession.logout.spec.d.ts +1 -0
- package/dist/auth/components/SecuritySettings/sections/PasswordSection.component.d.ts +0 -2
- package/dist/auth/components/SessionBoundary/AbyssSessionBoundary.component.d.ts +27 -0
- package/dist/auth/components/SessionBoundary/AbyssSessionBoundary.component.spec.d.ts +1 -0
- package/dist/auth/components/SessionErrorScreen/SessionErrorScreen.component.d.ts +27 -0
- package/dist/auth/components/index.d.ts +6 -0
- package/dist/auth-client.js +33 -22
- package/dist/components/Inputs/CloudImport/CloudImport.component.d.ts +4 -0
- package/dist/components/Inputs/CloudImport/CloudImportFile.component.spec.d.ts +1 -0
- package/dist/components/Inputs/CloudImport/cloud-accept.d.ts +13 -0
- package/dist/components/Inputs/CloudImport/cloud-accept.spec.d.ts +1 -0
- package/dist/components/Support/support-status-timeline.logic.d.ts +2 -2
- package/dist/cookie-consent.js +1 -1
- package/dist/hooks/use-rich-intl.hook.d.ts +28 -2
- package/dist/{index-CS_grWE4.js → index-2EY2JNir.js} +4 -4
- package/dist/{index-C8PVDVGQ.js → index-B3yNQeWK.js} +2 -2
- package/dist/{index-C2RWcbVl.js → index-B7dA6I-R.js} +2 -2
- package/dist/{index-CDUED8YP.js → index-B8jAaZFi.js} +2 -2
- package/dist/{index-Cl8WUtRw.js → index-BB8-EZF4.js} +2 -2
- package/dist/{index-B2u_xNxk.js → index-BI9lpDsi.js} +2 -2
- package/dist/{index-BuIwrS34.js → index-BM0yX2Iz.js} +2 -2
- package/dist/{index-Y2TnZBi8.js → index-Bw5kKOog.js} +4 -4
- package/dist/{index-D5ylhtng.js → index-C8lLApSB.js} +2 -2
- package/dist/{index-D1N8_Qim.js → index-CEJ4iiA5.js} +4 -4
- package/dist/{index-BFEmh_EV.js → index-CLFBr4MF.js} +2 -2
- package/dist/{index-5owlFn6W.js → index-CZRRt2kg.js} +2 -2
- package/dist/{index-BsFPvS1n.js → index-Cb-sJiqp.js} +2 -2
- package/dist/{index-C_-NoOPN.js → index-CxKeAkSY.js} +2 -2
- package/dist/{index-B0h04i9u.js → index-CxfOutZw.js} +3 -3
- package/dist/{index-oKfJH01a.js → index-CzlzF3eF.js} +3 -3
- package/dist/{index-1CoDaadD.js → index-CzpB9qD9.js} +1 -1
- package/dist/{index-CLz2EEY4.js → index-D1QkFZiF.js} +3 -3
- package/dist/{index-B4Ff-AfL.js → index-DI9IV0Ew.js} +19209 -18897
- package/dist/{index-BG716EPB.js → index-Dc_oDJTw.js} +3 -3
- package/dist/{index-DHCXtcI7.js → index-HfP5qfTf.js} +2 -2
- package/dist/{index-Ci4SXMFB.js → index-Kbs9OrDN.js} +2 -2
- package/dist/index.js +261 -246
- package/dist/internal/lazy-value.d.ts +11 -0
- package/dist/internal/lazy-value.spec.d.ts +1 -0
- package/dist/lazy-value-Co76vxsM.js +7 -0
- package/dist/load-safety.spec.d.ts +1 -0
- package/dist/translations/en.d.ts +13 -0
- package/dist/translations/fr.d.ts +13 -0
- package/dist/use-auth.hook-oRxzI95f.js +469 -0
- package/package.json +3 -3
- package/dist/use-auth.hook-BLaU_u8T.js +0 -391
|
@@ -1537,6 +1537,19 @@ declare const _default: {
|
|
|
1537
1537
|
'organization-overdue': string;
|
|
1538
1538
|
action: string;
|
|
1539
1539
|
};
|
|
1540
|
+
'session-error': {
|
|
1541
|
+
'still-anonymous': string;
|
|
1542
|
+
unreachable: string;
|
|
1543
|
+
'prepare-failed': string;
|
|
1544
|
+
details: {
|
|
1545
|
+
'still-anonymous': string;
|
|
1546
|
+
unreachable: string;
|
|
1547
|
+
'prepare-failed': string;
|
|
1548
|
+
};
|
|
1549
|
+
retry: string;
|
|
1550
|
+
'sign-in': string;
|
|
1551
|
+
'sign-out': string;
|
|
1552
|
+
};
|
|
1540
1553
|
};
|
|
1541
1554
|
};
|
|
1542
1555
|
export default _default;
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { SessionPlatform as j, AbyssCore as F, Code as x, AuthResultStatus as Z, MfaFactorType as q } from "@abyss-project/main";
|
|
2
|
+
import { l as ee } from "./lazy-value-Co76vxsM.js";
|
|
3
|
+
import { browserSupportsWebAuthn as I, startRegistration as te, browserSupportsWebAuthnAutofill as se, startAuthentication as ne, WebAuthnError as oe } from "@simplewebauthn/browser";
|
|
4
|
+
import { a as f, A as p, s as re } from "./token-storage-CbWrBeIP.js";
|
|
5
|
+
import { createContext as ae, useState as ie, useEffect as ue, useMemo as le, useContext as ce } from "react";
|
|
6
|
+
import { jsx as de } from "react/jsx-runtime";
|
|
7
|
+
const b = "abyss-login-redirect", fe = 3e5, N = ({
|
|
8
|
+
abyssSite: e,
|
|
9
|
+
service: s,
|
|
10
|
+
redirectPath: n
|
|
11
|
+
}) => {
|
|
12
|
+
const o = e.replace(/\/+$/, ""), r = [`abyss_service=${encodeURIComponent(s)}`];
|
|
13
|
+
return n && r.push(`redirect_path=${encodeURIComponent(n)}`), `${o}/auth/login?${r.join("&")}`;
|
|
14
|
+
}, xe = (e = window.location) => `${e.pathname}${e.search}`, qe = () => {
|
|
15
|
+
const e = window.sessionStorage.getItem(b);
|
|
16
|
+
if (e === null)
|
|
17
|
+
return !1;
|
|
18
|
+
const s = Number(e), n = Date.now() - s;
|
|
19
|
+
return Number.isFinite(s) && n >= 0 && n < fe ? !0 : (window.sessionStorage.removeItem(b), !1);
|
|
20
|
+
}, $e = () => {
|
|
21
|
+
window.sessionStorage.removeItem(b);
|
|
22
|
+
}, We = (e) => {
|
|
23
|
+
window.location.assign(N(e));
|
|
24
|
+
}, Ye = (e) => {
|
|
25
|
+
window.sessionStorage.setItem(b, String(Date.now())), window.location.assign(N(e));
|
|
26
|
+
};
|
|
27
|
+
let z = !1;
|
|
28
|
+
const Be = () => z, He = async (e, { abyssSite: s, service: n }) => {
|
|
29
|
+
z = !0;
|
|
30
|
+
try {
|
|
31
|
+
await e.logout();
|
|
32
|
+
} finally {
|
|
33
|
+
window.location.assign(N({ abyssSite: s, service: n }));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var pe = /* @__PURE__ */ ((e) => (e.LOADING = "loading", e.ANONYMOUS = "anonymous", e.AUTHENTICATED = "authenticated", e))(pe || {}), he = /* @__PURE__ */ ((e) => (e.PASSKEY = "passkey", e.TOTP = "totp", e.PASSWORD = "password", e.EMAIL_CODE = "email-code", e))(he || {});
|
|
37
|
+
const we = 6e4, $ = 3e4, me = [
|
|
38
|
+
500,
|
|
39
|
+
1e3,
|
|
40
|
+
2e3
|
|
41
|
+
], Ee = [
|
|
42
|
+
7500,
|
|
43
|
+
15e3,
|
|
44
|
+
22500,
|
|
45
|
+
27e3
|
|
46
|
+
], W = 3e4, ye = 5e3, Ae = "abyss-auth-refresh", Re = 2147483647, Te = "Token Expired", ge = (e) => typeof e == "object" && e !== null && e.isAxiosError === !0, Y = (e) => {
|
|
47
|
+
var n;
|
|
48
|
+
if (!ge(e) || e.code === "ERR_CANCELED")
|
|
49
|
+
return { kind: "other" };
|
|
50
|
+
if (!e.response)
|
|
51
|
+
return { kind: "network" };
|
|
52
|
+
const s = (n = e.response.data) == null ? void 0 : n.error;
|
|
53
|
+
return {
|
|
54
|
+
kind: "http",
|
|
55
|
+
status: e.response.status,
|
|
56
|
+
code: s == null ? void 0 : s.code,
|
|
57
|
+
message: s == null ? void 0 : s.message,
|
|
58
|
+
params: s == null ? void 0 : s.params
|
|
59
|
+
};
|
|
60
|
+
}, _e = ee(
|
|
61
|
+
() => /* @__PURE__ */ new Map([
|
|
62
|
+
[
|
|
63
|
+
q.TOTP,
|
|
64
|
+
"totp"
|
|
65
|
+
/* TOTP */
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
q.PASSKEY,
|
|
69
|
+
"passkey"
|
|
70
|
+
/* PASSKEY */
|
|
71
|
+
]
|
|
72
|
+
])
|
|
73
|
+
), ke = (e) => {
|
|
74
|
+
const s = e == null ? void 0 : e.methods;
|
|
75
|
+
return Array.isArray(s) ? {
|
|
76
|
+
methods: s.flatMap((n) => {
|
|
77
|
+
const o = _e().get(n);
|
|
78
|
+
return o ? [o] : [];
|
|
79
|
+
})
|
|
80
|
+
} : {};
|
|
81
|
+
}, be = (e) => new Promise((s) => setTimeout(s, e)), Se = () => typeof navigator > "u" || navigator.onLine !== !1, Le = () => typeof navigator > "u" ? null : navigator.locks ?? null, Ke = (e) => {
|
|
82
|
+
const s = e.bridge.platform === j.WEB, n = e.isOnline ?? Se;
|
|
83
|
+
let o = {
|
|
84
|
+
status: "loading"
|
|
85
|
+
/* LOADING */
|
|
86
|
+
}, r = null, a = null, u = null, l = null, y = null, w = null, m = null, d = null, T = 0;
|
|
87
|
+
const g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set(), S = (t) => {
|
|
88
|
+
o = t, g.forEach((i) => i(o));
|
|
89
|
+
}, C = (t) => {
|
|
90
|
+
r = t, e.applyToken(t), _.forEach((i) => i(t));
|
|
91
|
+
}, k = () => {
|
|
92
|
+
w && (clearTimeout(w), w = null), m && (clearTimeout(m), m = null);
|
|
93
|
+
}, X = (t) => {
|
|
94
|
+
const i = Date.parse(t);
|
|
95
|
+
if (!Number.isFinite(i))
|
|
96
|
+
return;
|
|
97
|
+
const c = Math.min(
|
|
98
|
+
Math.max(i - we - Date.now(), 0),
|
|
99
|
+
Re
|
|
100
|
+
);
|
|
101
|
+
w = setTimeout(() => {
|
|
102
|
+
w = null, E.refresh();
|
|
103
|
+
}, c);
|
|
104
|
+
}, P = async (t) => {
|
|
105
|
+
var i;
|
|
106
|
+
k(), t.refreshToken && await e.storage.setRefreshToken(t.refreshToken), C(t.accessToken), a = t.user, (i = e.onPersistUser) == null || i.call(e, t.user), S({
|
|
107
|
+
status: "authenticated",
|
|
108
|
+
user: t.user,
|
|
109
|
+
mfaEnrollmentRequired: t.mfaEnrollmentRequired,
|
|
110
|
+
offline: !1
|
|
111
|
+
}), X(t.accessTokenExpiresAt);
|
|
112
|
+
}, O = async () => {
|
|
113
|
+
var t;
|
|
114
|
+
T += 1, k(), d = null, await e.storage.setRefreshToken(null), C(null), a = null, (t = e.onPersistUser) == null || t.call(e, null), S({
|
|
115
|
+
status: "anonymous"
|
|
116
|
+
/* ANONYMOUS */
|
|
117
|
+
});
|
|
118
|
+
}, V = () => {
|
|
119
|
+
if (d === null)
|
|
120
|
+
return W;
|
|
121
|
+
const t = Date.now() - d, i = Ee.find(
|
|
122
|
+
(c) => c > t && c < $
|
|
123
|
+
);
|
|
124
|
+
return i === void 0 ? (d = null, W) : i - t;
|
|
125
|
+
}, Q = () => {
|
|
126
|
+
k();
|
|
127
|
+
const t = o.user ?? a;
|
|
128
|
+
S(
|
|
129
|
+
t ? {
|
|
130
|
+
status: "authenticated",
|
|
131
|
+
user: t,
|
|
132
|
+
mfaEnrollmentRequired: o.mfaEnrollmentRequired,
|
|
133
|
+
offline: !0
|
|
134
|
+
} : { status: "anonymous", offline: !0 }
|
|
135
|
+
), m = setTimeout(() => {
|
|
136
|
+
m = null, E.refresh();
|
|
137
|
+
}, V());
|
|
138
|
+
}, M = async () => {
|
|
139
|
+
const t = s ? null : await e.storage.getRefreshToken();
|
|
140
|
+
if (!s && !t)
|
|
141
|
+
return { kind: "revoked" };
|
|
142
|
+
if (!n())
|
|
143
|
+
return { kind: "offline" };
|
|
144
|
+
const i = Date.now(), c = new AbortController(), h = setTimeout(
|
|
145
|
+
() => c.abort(),
|
|
146
|
+
ye
|
|
147
|
+
);
|
|
148
|
+
try {
|
|
149
|
+
const A = await F.sdk.auth.refresh(
|
|
150
|
+
t ? { refreshToken: t } : void 0,
|
|
151
|
+
{ signal: c.signal }
|
|
152
|
+
);
|
|
153
|
+
return A.error ? { kind: "unreachable", sentAt: i } : { kind: "session", session: A.data };
|
|
154
|
+
} catch (A) {
|
|
155
|
+
if (c.signal.aborted)
|
|
156
|
+
return { kind: "unreachable", sentAt: i };
|
|
157
|
+
const R = Y(A);
|
|
158
|
+
if (R.kind === "other")
|
|
159
|
+
throw A;
|
|
160
|
+
return R.kind === "http" && R.status === 401 ? { kind: "revoked" } : R.kind === "http" && R.status === 403 && R.code === x.originRefused ? { kind: "revoked" } : { kind: "unreachable", sentAt: i };
|
|
161
|
+
} finally {
|
|
162
|
+
clearTimeout(h);
|
|
163
|
+
}
|
|
164
|
+
}, U = async () => {
|
|
165
|
+
const t = T;
|
|
166
|
+
d !== null && Date.now() - d >= $ && (d = null);
|
|
167
|
+
let i = await M();
|
|
168
|
+
const c = d === null ? me : [];
|
|
169
|
+
for (const h of c) {
|
|
170
|
+
if (i.kind !== "unreachable" || t !== T || (d = d ?? i.sentAt, await be(h), t !== T))
|
|
171
|
+
break;
|
|
172
|
+
i = await M();
|
|
173
|
+
}
|
|
174
|
+
if (i.kind === "unreachable" ? d = d ?? i.sentAt : i.kind !== "offline" && (d = null), t !== T) {
|
|
175
|
+
e.applyToken(r);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
switch (i.kind) {
|
|
179
|
+
case "session":
|
|
180
|
+
await P(i.session);
|
|
181
|
+
return;
|
|
182
|
+
case "revoked":
|
|
183
|
+
await O();
|
|
184
|
+
return;
|
|
185
|
+
case "offline":
|
|
186
|
+
case "unreachable":
|
|
187
|
+
Q();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
}, L = () => {
|
|
191
|
+
o.offline && (m && (clearTimeout(m), m = null), E.refresh());
|
|
192
|
+
}, G = () => {
|
|
193
|
+
document.visibilityState === "visible" && L();
|
|
194
|
+
};
|
|
195
|
+
typeof window < "u" && window.addEventListener("online", L), typeof document < "u" && document.addEventListener("visibilitychange", G);
|
|
196
|
+
const E = {
|
|
197
|
+
bridge: e.bridge,
|
|
198
|
+
state: () => o,
|
|
199
|
+
subscribe: (t) => (g.add(t), () => {
|
|
200
|
+
g.delete(t);
|
|
201
|
+
}),
|
|
202
|
+
accessToken: () => r,
|
|
203
|
+
subscribeToken: (t) => (_.add(t), t(r), () => {
|
|
204
|
+
_.delete(t);
|
|
205
|
+
}),
|
|
206
|
+
bootstrap: () => (y || (y = (async () => {
|
|
207
|
+
var t;
|
|
208
|
+
a = await ((t = e.restoreUser) == null ? void 0 : t.call(e)) ?? null, await E.refresh();
|
|
209
|
+
})()), y),
|
|
210
|
+
handleResult: async (t) => (t.status === Z.AUTHENTICATED && await P(t.session), t),
|
|
211
|
+
refresh: () => {
|
|
212
|
+
if (!l) {
|
|
213
|
+
const t = s ? Le() : null;
|
|
214
|
+
l = (t ? t.request(Ae, U) : U()).finally(() => {
|
|
215
|
+
l = null;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return l;
|
|
219
|
+
},
|
|
220
|
+
withAuthRetry: async (t) => {
|
|
221
|
+
const i = r;
|
|
222
|
+
try {
|
|
223
|
+
return await t();
|
|
224
|
+
} catch (c) {
|
|
225
|
+
const h = Y(c);
|
|
226
|
+
if (h.kind !== "http")
|
|
227
|
+
throw c;
|
|
228
|
+
if (h.status === 401 && h.message === Te) {
|
|
229
|
+
if (r === i && await E.refresh(), o.status !== "authenticated" || r === null || r === i)
|
|
230
|
+
throw c;
|
|
231
|
+
return t();
|
|
232
|
+
}
|
|
233
|
+
if (h.status === 403 && h.code === x.reauthRequired && u) {
|
|
234
|
+
if (!await u(ke(h.params)))
|
|
235
|
+
throw c;
|
|
236
|
+
return t();
|
|
237
|
+
}
|
|
238
|
+
throw c;
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
onReauthRequired: (t) => (u = t, () => {
|
|
242
|
+
u === t && (u = null);
|
|
243
|
+
}),
|
|
244
|
+
logout: async () => {
|
|
245
|
+
try {
|
|
246
|
+
o.status === "authenticated" && r === null && await E.refresh(), r !== null && await E.withAuthRetry(() => F.sdk.auth.logout());
|
|
247
|
+
} finally {
|
|
248
|
+
await O();
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
dispose: () => {
|
|
252
|
+
k(), g.clear(), _.clear(), typeof window < "u" && window.removeEventListener("online", L), typeof document < "u" && document.removeEventListener("visibilitychange", G);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return E;
|
|
256
|
+
}, Ie = "Token Expired", ve = /(^|\/)auth\//, je = (e, s) => {
|
|
257
|
+
const n = s.map((o) => ({
|
|
258
|
+
instance: o,
|
|
259
|
+
id: o.interceptors.response.use(
|
|
260
|
+
null,
|
|
261
|
+
async (r) => {
|
|
262
|
+
var l, y, w;
|
|
263
|
+
const a = r == null ? void 0 : r.config;
|
|
264
|
+
if (((l = r == null ? void 0 : r.response) == null ? void 0 : l.status) !== 401 || ((w = (y = r.response.data) == null ? void 0 : y.error) == null ? void 0 : w.message) !== Ie || !a || a.abyssAuthReplayed || ve.test(a.url ?? ""))
|
|
265
|
+
throw r;
|
|
266
|
+
await e.refresh();
|
|
267
|
+
const u = e.accessToken();
|
|
268
|
+
if (!u)
|
|
269
|
+
throw r;
|
|
270
|
+
return a.abyssAuthReplayed = !0, a.headers = {
|
|
271
|
+
...a.headers,
|
|
272
|
+
Authorization: `Bearer ${u}`
|
|
273
|
+
}, o.request(a);
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
}));
|
|
277
|
+
return () => {
|
|
278
|
+
n.forEach(
|
|
279
|
+
({ instance: o, id: r }) => o.interceptors.response.eject(r)
|
|
280
|
+
);
|
|
281
|
+
};
|
|
282
|
+
}, De = "https://accounts.google.com/gsi/client", Ne = "https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1.0/en_US/appleid.auth.js", v = /* @__PURE__ */ new Map(), B = (e) => {
|
|
283
|
+
const s = v.get(e);
|
|
284
|
+
if (s)
|
|
285
|
+
return s;
|
|
286
|
+
const n = new Promise((o, r) => {
|
|
287
|
+
const a = document.createElement("script");
|
|
288
|
+
a.src = e, a.async = !0, a.onload = () => o(), a.onerror = () => {
|
|
289
|
+
v.delete(e), a.remove(), r(
|
|
290
|
+
new f(
|
|
291
|
+
p.FAILED,
|
|
292
|
+
`Could not load ${e}`
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
}, document.head.appendChild(a);
|
|
296
|
+
});
|
|
297
|
+
return v.set(e, n), n;
|
|
298
|
+
}, Ce = [
|
|
299
|
+
"popup_closed_by_user",
|
|
300
|
+
"user_cancelled_authorize"
|
|
301
|
+
], H = (e) => {
|
|
302
|
+
const { name: s, message: n } = e ?? {}, o = typeof n == "string" ? n : "Passkey ceremony failed";
|
|
303
|
+
return s === "NotAllowedError" || s === "AbortError" || e instanceof oe && e.code === "ERROR_CEREMONY_ABORTED" ? new f(p.CANCELLED, o, e) : new f(p.FAILED, o, e);
|
|
304
|
+
}, D = (e) => new f(
|
|
305
|
+
p.UNSUPPORTED,
|
|
306
|
+
`${e} is not supported by this browser`
|
|
307
|
+
), K = (e) => new f(
|
|
308
|
+
p.UNSUPPORTED,
|
|
309
|
+
`${e} sign-in is not configured on this site`
|
|
310
|
+
), ze = (e) => ({
|
|
311
|
+
platform: j.WEB,
|
|
312
|
+
passkeySupported: async () => I(),
|
|
313
|
+
getPasskey: async (s, n = !1) => {
|
|
314
|
+
if (!I())
|
|
315
|
+
throw D("WebAuthn");
|
|
316
|
+
if (n && !await se())
|
|
317
|
+
throw D("Passkey autofill");
|
|
318
|
+
try {
|
|
319
|
+
return await ne({
|
|
320
|
+
// abyss-main's options are the WebAuthn JSON this call reads (base64url binary fields).
|
|
321
|
+
optionsJSON: s,
|
|
322
|
+
useBrowserAutofill: n
|
|
323
|
+
});
|
|
324
|
+
} catch (o) {
|
|
325
|
+
throw H(o);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
createPasskey: async (s) => {
|
|
329
|
+
if (!I())
|
|
330
|
+
throw D("WebAuthn");
|
|
331
|
+
try {
|
|
332
|
+
return await te({
|
|
333
|
+
optionsJSON: s
|
|
334
|
+
});
|
|
335
|
+
} catch (n) {
|
|
336
|
+
throw H(n);
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
google: async (s) => {
|
|
340
|
+
const n = e.googleClientId;
|
|
341
|
+
if (!n)
|
|
342
|
+
throw K("Google");
|
|
343
|
+
await B(De);
|
|
344
|
+
const o = window.google;
|
|
345
|
+
if (!o)
|
|
346
|
+
throw new f(
|
|
347
|
+
p.FAILED,
|
|
348
|
+
"Google Identity Services missing"
|
|
349
|
+
);
|
|
350
|
+
return new Promise((r, a) => {
|
|
351
|
+
o.accounts.id.initialize({
|
|
352
|
+
client_id: n,
|
|
353
|
+
// Google copies the raw nonce into the id_token; abyss-main compares it as is.
|
|
354
|
+
nonce: s,
|
|
355
|
+
callback: (u) => {
|
|
356
|
+
if (u.credential) {
|
|
357
|
+
r({ idToken: u.credential });
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
a(
|
|
361
|
+
new f(
|
|
362
|
+
p.FAILED,
|
|
363
|
+
"Google returned no credential"
|
|
364
|
+
)
|
|
365
|
+
);
|
|
366
|
+
},
|
|
367
|
+
auto_select: !1,
|
|
368
|
+
cancel_on_tap_outside: !0,
|
|
369
|
+
use_fedcm_for_prompt: !0,
|
|
370
|
+
itp_support: !0
|
|
371
|
+
}), o.accounts.id.prompt((u) => {
|
|
372
|
+
if (u.isSkippedMoment()) {
|
|
373
|
+
a(
|
|
374
|
+
new f(
|
|
375
|
+
p.CANCELLED,
|
|
376
|
+
"Google prompt skipped"
|
|
377
|
+
)
|
|
378
|
+
);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
u.isDismissedMoment() && u.getDismissedReason() !== "credential_returned" && a(
|
|
382
|
+
new f(
|
|
383
|
+
p.CANCELLED,
|
|
384
|
+
"Google prompt dismissed"
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
},
|
|
390
|
+
apple: async (s) => {
|
|
391
|
+
var a;
|
|
392
|
+
const { appleServiceId: n, appleRedirectUri: o } = e;
|
|
393
|
+
if (!n || !o)
|
|
394
|
+
throw K("Apple");
|
|
395
|
+
await B(Ne);
|
|
396
|
+
const r = window.AppleID;
|
|
397
|
+
if (!r)
|
|
398
|
+
throw new f(
|
|
399
|
+
p.FAILED,
|
|
400
|
+
"Sign in with Apple JS missing"
|
|
401
|
+
);
|
|
402
|
+
r.auth.init({
|
|
403
|
+
clientId: n,
|
|
404
|
+
scope: "name email",
|
|
405
|
+
redirectURI: o,
|
|
406
|
+
usePopup: !0,
|
|
407
|
+
// Apple carries what it is given; abyss-main compares it with SHA-256(raw nonce) in hex.
|
|
408
|
+
nonce: await re(s)
|
|
409
|
+
});
|
|
410
|
+
try {
|
|
411
|
+
const u = await r.auth.signIn(), l = (a = u.user) == null ? void 0 : a.name;
|
|
412
|
+
return {
|
|
413
|
+
idToken: u.authorization.id_token,
|
|
414
|
+
...l != null && l.firstName ? { givenName: l.firstName } : {},
|
|
415
|
+
...l != null && l.lastName ? { familyName: l.lastName } : {}
|
|
416
|
+
};
|
|
417
|
+
} catch (u) {
|
|
418
|
+
const l = u == null ? void 0 : u.error;
|
|
419
|
+
throw typeof l == "string" && Ce.includes(l) ? new f(p.CANCELLED, l, u) : new f(
|
|
420
|
+
p.FAILED,
|
|
421
|
+
typeof l == "string" ? l : "Sign in with Apple failed",
|
|
422
|
+
u
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}), J = ae(null), Je = ({ client: e, children: s }) => {
|
|
427
|
+
const [n, o] = ie(() => e.state());
|
|
428
|
+
ue(() => {
|
|
429
|
+
o(e.state());
|
|
430
|
+
const a = e.subscribe(o);
|
|
431
|
+
return e.bootstrap(), a;
|
|
432
|
+
}, [e]);
|
|
433
|
+
const r = le(() => ({ state: n, client: e }), [n, e]);
|
|
434
|
+
return /* @__PURE__ */ de(J.Provider, { value: r, children: s });
|
|
435
|
+
}, Xe = () => {
|
|
436
|
+
const e = ce(J);
|
|
437
|
+
if (!e)
|
|
438
|
+
throw new Error("useAuth() must be called inside <AuthProvider>");
|
|
439
|
+
return e;
|
|
440
|
+
};
|
|
441
|
+
export {
|
|
442
|
+
pe as A,
|
|
443
|
+
De as G,
|
|
444
|
+
b as L,
|
|
445
|
+
he as R,
|
|
446
|
+
W as U,
|
|
447
|
+
fe as a,
|
|
448
|
+
N as b,
|
|
449
|
+
xe as c,
|
|
450
|
+
$e as d,
|
|
451
|
+
We as e,
|
|
452
|
+
Ye as f,
|
|
453
|
+
we as g,
|
|
454
|
+
$ as h,
|
|
455
|
+
Be as i,
|
|
456
|
+
me as j,
|
|
457
|
+
Ee as k,
|
|
458
|
+
He as l,
|
|
459
|
+
ye as m,
|
|
460
|
+
Ae as n,
|
|
461
|
+
Ke as o,
|
|
462
|
+
je as p,
|
|
463
|
+
Ne as q,
|
|
464
|
+
qe as r,
|
|
465
|
+
ze as s,
|
|
466
|
+
J as t,
|
|
467
|
+
Je as u,
|
|
468
|
+
Xe as v
|
|
469
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abyss-project/commons-front-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Front Core package of AbyssProject",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"react-is": "^18.0.0 || ^19.0.0",
|
|
70
70
|
"react-router-dom": "^6.15.0",
|
|
71
71
|
"zustand": "^5.0.0",
|
|
72
|
-
"@abyss-project/main": "
|
|
72
|
+
"@abyss-project/main": "14.0.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
75
75
|
"@abyss-project/capacitor-auth": {
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"use-debounce": "^10.0.5",
|
|
117
117
|
"uuid": "^9.0.0",
|
|
118
118
|
"yup": "^0.32.11",
|
|
119
|
-
"@abyss-project/main": "
|
|
119
|
+
"@abyss-project/main": "14.0.0"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@abyss-project/cloud": "^2.4.0",
|