@edgespark/web 0.0.2 → 0.0.3
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/auth/styles/styles.css +10 -0
- package/dist/auth/local-dev.d.ts +31 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +7 -0
- package/dist/auth-ui/config.d.ts +2 -1
- package/dist/index.cjs +4 -3
- package/dist/index.es.js +263 -195
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
1
|
+
import { createAuthClient as De } from "better-auth/client";
|
|
2
2
|
class te extends Error {
|
|
3
3
|
constructor(e, s) {
|
|
4
4
|
super(s), this.name = "EdgeSparkError", this.code = e;
|
|
@@ -14,23 +14,23 @@ class Ee extends te {
|
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class E extends te {
|
|
18
18
|
constructor(e, s) {
|
|
19
19
|
super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
function Se(t, e = "Authentication failed.", s) {
|
|
23
|
-
if (t instanceof
|
|
23
|
+
if (t instanceof E)
|
|
24
24
|
return t;
|
|
25
25
|
if (typeof t == "object" && t !== null) {
|
|
26
26
|
const i = t;
|
|
27
|
-
return new
|
|
27
|
+
return new E(i.message || e, {
|
|
28
28
|
code: i.code ?? s,
|
|
29
29
|
status: i.status,
|
|
30
30
|
cause: t
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
return typeof t == "string" ? new
|
|
33
|
+
return typeof t == "string" ? new E(t, { code: s }) : new E(e, { code: s, cause: t });
|
|
34
34
|
}
|
|
35
35
|
function Pe() {
|
|
36
36
|
if (typeof window > "u" || typeof document > "u")
|
|
@@ -50,7 +50,7 @@ function Ve(t) {
|
|
|
50
50
|
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Fe() {
|
|
54
54
|
return {
|
|
55
55
|
async fetch(t, e) {
|
|
56
56
|
const s = Ne(t);
|
|
@@ -61,12 +61,12 @@ function De() {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const Le = "/api/_es/auth", He = "edgespark-auth-session", _e = "__edgespark_auth_sync__", V = "__edgespark_auth_pending_sign_in__", Ae = Symbol("edgespark.notifyAuthTabs"), ze = 10 * 60 * 1e3, je = /* @__PURE__ */ new Set([
|
|
65
65
|
"signOut",
|
|
66
66
|
"revokeSession",
|
|
67
67
|
"revokeSessions",
|
|
68
68
|
"revokeOtherSessions"
|
|
69
|
-
]),
|
|
69
|
+
]), qe = /* @__PURE__ */ new Map([
|
|
70
70
|
[
|
|
71
71
|
"changeEmail",
|
|
72
72
|
"changeEmail() is not currently supported by EdgeSpark platform auth. Use authUI.mount() or other supported client.auth flows instead of wiring raw /api/_es/auth/* routes manually."
|
|
@@ -90,30 +90,30 @@ class xe {
|
|
|
90
90
|
}
|
|
91
91
|
const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
|
|
92
92
|
let F, oe = !1;
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const C = /* @__PURE__ */ new Map(), H = re ? new re((t) => {
|
|
94
|
+
C.delete(t);
|
|
95
95
|
}) : null;
|
|
96
96
|
function Re(t) {
|
|
97
|
-
return
|
|
97
|
+
return De({
|
|
98
98
|
baseURL: Q(),
|
|
99
|
-
basePath:
|
|
99
|
+
basePath: Le,
|
|
100
100
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
101
101
|
fetchOptions: {
|
|
102
102
|
credentials: "include"
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function I(t) {
|
|
107
107
|
var e, s;
|
|
108
108
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function Ge(t) {
|
|
111
111
|
return JSON.stringify({
|
|
112
112
|
source: t,
|
|
113
113
|
timestamp: Date.now()
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function Ke(t) {
|
|
117
117
|
if (typeof t != "string")
|
|
118
118
|
return null;
|
|
119
119
|
try {
|
|
@@ -123,53 +123,53 @@ function Ge(t) {
|
|
|
123
123
|
return null;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function We(t) {
|
|
127
127
|
return t.join(".");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const e =
|
|
131
|
-
return s ? new
|
|
129
|
+
function Ye(t) {
|
|
130
|
+
const e = We(t), s = qe.get(e);
|
|
131
|
+
return s ? new E(s, {
|
|
132
132
|
code: "UNSUPPORTED_AUTH_METHOD"
|
|
133
133
|
}) : null;
|
|
134
134
|
}
|
|
135
135
|
async function ee(t) {
|
|
136
136
|
var e;
|
|
137
137
|
try {
|
|
138
|
-
return await ((e =
|
|
138
|
+
return await ((e = I(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
139
139
|
} catch {
|
|
140
140
|
return !1;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
function Te() {
|
|
144
|
-
return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(
|
|
144
|
+
return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(He) : null), F;
|
|
145
145
|
}
|
|
146
146
|
function ae(t) {
|
|
147
|
-
const e =
|
|
147
|
+
const e = Ke(t);
|
|
148
148
|
if (e)
|
|
149
|
-
for (const [s, i] of
|
|
149
|
+
for (const [s, i] of C) {
|
|
150
150
|
if (s === e.source)
|
|
151
151
|
continue;
|
|
152
152
|
const n = i.deref();
|
|
153
153
|
if (!n) {
|
|
154
|
-
|
|
154
|
+
C.delete(s);
|
|
155
155
|
continue;
|
|
156
156
|
}
|
|
157
157
|
ee(n);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function Je() {
|
|
161
161
|
var t;
|
|
162
162
|
oe || (oe = !0, (t = Te()) == null || t.addEventListener("message", (e) => {
|
|
163
163
|
ae(e.data);
|
|
164
164
|
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
165
|
-
e.key !==
|
|
165
|
+
e.key !== _e || e.newValue === null || ae(e.newValue);
|
|
166
166
|
}));
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
ne ?
|
|
168
|
+
function Xe(t, e) {
|
|
169
|
+
ne ? C.set(t, new ne(e)) : (C.clear(), C.set(t, new xe(e))), H == null || H.register(e, t), Je();
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
const e =
|
|
171
|
+
function R(t) {
|
|
172
|
+
const e = Ge(t), s = Te();
|
|
173
173
|
let i = !1;
|
|
174
174
|
if (s)
|
|
175
175
|
try {
|
|
@@ -178,7 +178,7 @@ function I(t) {
|
|
|
178
178
|
}
|
|
179
179
|
if (!i)
|
|
180
180
|
try {
|
|
181
|
-
window.localStorage.setItem(
|
|
181
|
+
window.localStorage.setItem(_e, e);
|
|
182
182
|
} catch {
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -186,7 +186,7 @@ function z(t) {
|
|
|
186
186
|
if (!(typeof window > "u"))
|
|
187
187
|
try {
|
|
188
188
|
window.sessionStorage.setItem(
|
|
189
|
-
|
|
189
|
+
V,
|
|
190
190
|
JSON.stringify({
|
|
191
191
|
path: t,
|
|
192
192
|
createdAt: Date.now()
|
|
@@ -195,20 +195,20 @@ function z(t) {
|
|
|
195
195
|
} catch {
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function T() {
|
|
199
199
|
if (!(typeof window > "u"))
|
|
200
200
|
try {
|
|
201
|
-
window.sessionStorage.removeItem(
|
|
201
|
+
window.sessionStorage.removeItem(V);
|
|
202
202
|
} catch {
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Ze(t) {
|
|
206
206
|
return !!(t != null && t.session && (t != null && t.user));
|
|
207
207
|
}
|
|
208
208
|
function m(t) {
|
|
209
209
|
return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function Qe(t) {
|
|
212
212
|
return t ? JSON.stringify({
|
|
213
213
|
session: {
|
|
214
214
|
createdAt: m(t.session.createdAt),
|
|
@@ -241,11 +241,11 @@ function Ie() {
|
|
|
241
241
|
if (typeof window > "u")
|
|
242
242
|
return null;
|
|
243
243
|
try {
|
|
244
|
-
const t = window.sessionStorage.getItem(
|
|
244
|
+
const t = window.sessionStorage.getItem(V);
|
|
245
245
|
if (!t)
|
|
246
246
|
return null;
|
|
247
247
|
const e = JSON.parse(t);
|
|
248
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt >
|
|
248
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > ze ? null : { createdAt: e.createdAt };
|
|
249
249
|
} catch {
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
@@ -254,58 +254,58 @@ function le() {
|
|
|
254
254
|
if (!Ie())
|
|
255
255
|
return !1;
|
|
256
256
|
try {
|
|
257
|
-
window.sessionStorage.removeItem(
|
|
257
|
+
window.sessionStorage.removeItem(V);
|
|
258
258
|
} catch {
|
|
259
259
|
}
|
|
260
260
|
return !0;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function et() {
|
|
263
263
|
return Ie() !== null;
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function tt(t) {
|
|
266
266
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
267
267
|
return !1;
|
|
268
268
|
const e = "data" in t ? t.data : t;
|
|
269
269
|
return e && typeof e == "object" ? "token" in e && typeof e.token == "string" && e.token.length > 0 ? !0 : "session" in e && "user" in e && !!e.session && !!e.user : !1;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function st(t) {
|
|
272
272
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
273
273
|
return !1;
|
|
274
274
|
const e = "data" in t ? t.data : t;
|
|
275
275
|
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
278
|
-
if (
|
|
277
|
+
function it(t) {
|
|
278
|
+
if (A(t) || !(t && typeof t == "object"))
|
|
279
279
|
return !1;
|
|
280
280
|
const e = "data" in t ? t.data : t;
|
|
281
281
|
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function nt(t, e) {
|
|
284
284
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
285
285
|
return !1;
|
|
286
286
|
const [s] = e;
|
|
287
287
|
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function A(t) {
|
|
290
290
|
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
if (
|
|
292
|
+
function rt(t) {
|
|
293
|
+
if (A(t) || !(t && typeof t == "object"))
|
|
294
294
|
return !1;
|
|
295
295
|
const e = "data" in t ? t.data : t;
|
|
296
296
|
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function ot(t) {
|
|
299
299
|
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
300
300
|
}
|
|
301
301
|
function j(t) {
|
|
302
302
|
return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
303
303
|
}
|
|
304
|
-
async function
|
|
304
|
+
async function at(t) {
|
|
305
305
|
var s, i;
|
|
306
306
|
let e = null;
|
|
307
307
|
try {
|
|
308
|
-
await ((s =
|
|
308
|
+
await ((s = I(t)) == null ? void 0 : s.get().refetch());
|
|
309
309
|
} catch (n) {
|
|
310
310
|
e = n;
|
|
311
311
|
} finally {
|
|
@@ -314,16 +314,16 @@ async function ot(t) {
|
|
|
314
314
|
if (e)
|
|
315
315
|
throw e;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function lt() {
|
|
318
318
|
const t = Re(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
319
|
-
|
|
319
|
+
Xe(e, t);
|
|
320
320
|
const s = 2, i = 500;
|
|
321
321
|
let n = null, a = !1, u;
|
|
322
|
-
const g = (o) => (u = o, o),
|
|
322
|
+
const g = (o) => (u = o, o), S = () => {
|
|
323
323
|
var c;
|
|
324
|
-
const o = (c =
|
|
324
|
+
const o = (c = I(t)) == null ? void 0 : c.get();
|
|
325
325
|
return o != null && o.error && !o.data && u !== void 0 ? u : (o == null ? void 0 : o.data) ?? u ?? null;
|
|
326
|
-
},
|
|
326
|
+
}, U = () => a ? Promise.resolve(S()) : (n || (n = (async () => {
|
|
327
327
|
var l, h, y;
|
|
328
328
|
let o = !1, c = null;
|
|
329
329
|
try {
|
|
@@ -331,71 +331,71 @@ function at() {
|
|
|
331
331
|
let d = null;
|
|
332
332
|
try {
|
|
333
333
|
d = await t.getSession();
|
|
334
|
-
} catch (
|
|
335
|
-
c =
|
|
334
|
+
} catch (P) {
|
|
335
|
+
c = P;
|
|
336
336
|
}
|
|
337
|
-
const p = ((l =
|
|
337
|
+
const p = ((l = I(t)) == null ? void 0 : l.get().data) ?? null;
|
|
338
338
|
if ((h = d == null ? void 0 : d.data) != null && h.session && ((y = d.data) != null && y.user))
|
|
339
|
-
return a = !0, le() &&
|
|
339
|
+
return a = !0, le() && R(e), g(d.data);
|
|
340
340
|
if (p != null && p.session && (p != null && p.user))
|
|
341
|
-
return a = !0, le() &&
|
|
342
|
-
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error &&
|
|
341
|
+
return a = !0, le() && R(e), g(p);
|
|
342
|
+
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && et() && b < s) {
|
|
343
343
|
await new Promise(
|
|
344
|
-
(
|
|
344
|
+
(P) => setTimeout(P, i)
|
|
345
345
|
);
|
|
346
346
|
continue;
|
|
347
347
|
}
|
|
348
348
|
if (d && !d.error) {
|
|
349
|
-
const
|
|
350
|
-
return a = !0, g(
|
|
349
|
+
const P = S();
|
|
350
|
+
return a = !0, g(P);
|
|
351
351
|
}
|
|
352
352
|
b < s && await new Promise(
|
|
353
|
-
(
|
|
353
|
+
(P) => setTimeout(P, i)
|
|
354
354
|
);
|
|
355
355
|
}
|
|
356
356
|
if (!o)
|
|
357
|
-
throw n = null, new
|
|
357
|
+
throw n = null, new E("Failed to load the current session.", {
|
|
358
358
|
code: "SESSION_LOOKUP_FAILED",
|
|
359
359
|
cause: c
|
|
360
360
|
});
|
|
361
|
-
const w =
|
|
361
|
+
const w = S();
|
|
362
362
|
return a = !0, g(w);
|
|
363
363
|
} catch (w) {
|
|
364
364
|
throw n = null, j(w);
|
|
365
365
|
}
|
|
366
366
|
})()), n);
|
|
367
|
-
|
|
367
|
+
U().catch(() => {
|
|
368
368
|
});
|
|
369
|
-
const
|
|
369
|
+
const $ = async () => {
|
|
370
370
|
var o, c;
|
|
371
371
|
try {
|
|
372
372
|
const l = await t.getSession();
|
|
373
373
|
if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
|
|
374
374
|
return l.data;
|
|
375
|
-
throw l.error ? j(l.error) : new
|
|
375
|
+
throw l.error ? j(l.error) : new E("No authenticated session is available.", {
|
|
376
376
|
code: "UNAUTHENTICATED"
|
|
377
377
|
});
|
|
378
378
|
} catch (l) {
|
|
379
379
|
throw j(l);
|
|
380
380
|
}
|
|
381
|
-
},
|
|
382
|
-
await ee(t),
|
|
381
|
+
}, v = async () => {
|
|
382
|
+
await ee(t), R(e);
|
|
383
383
|
}, Be = async () => {
|
|
384
384
|
var l;
|
|
385
|
-
const o = await ee(t), c = ((l =
|
|
386
|
-
|
|
387
|
-
},
|
|
385
|
+
const o = await ee(t), c = ((l = I(t)) == null ? void 0 : l.get().data) ?? null;
|
|
386
|
+
Ze(c) ? (T(), R(e)) : o || R(e);
|
|
387
|
+
}, Me = (o) => {
|
|
388
388
|
let c = !1, l = !1, h;
|
|
389
389
|
const y = (d) => {
|
|
390
|
-
const p =
|
|
390
|
+
const p = Qe(d);
|
|
391
391
|
p !== h && (h = p, o(d));
|
|
392
392
|
};
|
|
393
|
-
|
|
393
|
+
U().then((d) => {
|
|
394
394
|
c || (l = !0, y(g(d)));
|
|
395
395
|
}).catch(() => {
|
|
396
396
|
c || (l = !0);
|
|
397
397
|
});
|
|
398
|
-
const w =
|
|
398
|
+
const w = I(t);
|
|
399
399
|
if (!w)
|
|
400
400
|
return () => {
|
|
401
401
|
c = !0;
|
|
@@ -409,9 +409,9 @@ function at() {
|
|
|
409
409
|
return () => {
|
|
410
410
|
c = !0, b();
|
|
411
411
|
};
|
|
412
|
-
},
|
|
412
|
+
}, Oe = async (o, c, l) => {
|
|
413
413
|
const h = o[0], y = o.length >= 2 && h === "emailOtp" && o[1] === "verifyEmail", w = o.length >= 2 && h === "emailOtp" && o[1] === "resetPassword", b = o.length >= 2 && h === "resetPassword" && o[1] === "emailOtp";
|
|
414
|
-
return o.length === 1 && (h === "deleteUser" || h === "deleteUserCallback") ? (
|
|
414
|
+
return o.length === 1 && (h === "deleteUser" || h === "deleteUserCallback") ? (T(), rt(l) && await v(), l) : o.length === 1 && h && je.has(h) ? (T(), A(l) || await v(), l) : nt(o, c) && !A(l) ? (T(), await v(), l) : (w || b) && !A(l) ? (T(), await v(), l) : o.length === 1 && h === "changeEmail" && !A(l) ? (await v(), l) : ((h === "signIn" || h === "signUp" || y) && tt(l) ? (T(), await v()) : (h === "signIn" || h === "signUp") && st(l) || h === "signUp" && it(l) ? z(o) : h === "verifyEmail" && !A(l) && (z(o), await Be()), l);
|
|
415
415
|
}, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
|
|
416
416
|
if (!o || typeof o != "object" && typeof o != "function")
|
|
417
417
|
return o;
|
|
@@ -422,19 +422,19 @@ function at() {
|
|
|
422
422
|
get(y, w, b) {
|
|
423
423
|
if (c.length === 0) {
|
|
424
424
|
if (w === "requireSession")
|
|
425
|
-
return
|
|
425
|
+
return $;
|
|
426
426
|
if (w === "onSessionChange")
|
|
427
|
-
return
|
|
427
|
+
return Me;
|
|
428
428
|
if (w === Ae)
|
|
429
429
|
return () => {
|
|
430
|
-
|
|
430
|
+
R(e);
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
const d = Reflect.get(y, w, b);
|
|
434
434
|
return typeof w != "string" ? d : ie(d, [...c, w]);
|
|
435
435
|
},
|
|
436
436
|
apply(y, w, b) {
|
|
437
|
-
const d =
|
|
437
|
+
const d = Ye(c);
|
|
438
438
|
if (d)
|
|
439
439
|
throw d;
|
|
440
440
|
const p = Reflect.apply(
|
|
@@ -442,8 +442,8 @@ function at() {
|
|
|
442
442
|
w,
|
|
443
443
|
b
|
|
444
444
|
);
|
|
445
|
-
return
|
|
446
|
-
(
|
|
445
|
+
return ot(p) ? Promise.resolve(p).then(
|
|
446
|
+
(P) => Oe(c, b, P)
|
|
447
447
|
) : p;
|
|
448
448
|
}
|
|
449
449
|
});
|
|
@@ -451,10 +451,38 @@ function at() {
|
|
|
451
451
|
};
|
|
452
452
|
return ie(t, []);
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function dt() {
|
|
455
455
|
return Re({ disableDefaultRedirectPlugin: !0 });
|
|
456
456
|
}
|
|
457
|
-
|
|
457
|
+
const Ce = "/api/_es/dev";
|
|
458
|
+
function ct() {
|
|
459
|
+
if (typeof document > "u") return !1;
|
|
460
|
+
const t = document.querySelector('meta[name="edgespark-local-dev"]');
|
|
461
|
+
return (t == null ? void 0 : t.getAttribute("content")) === "true";
|
|
462
|
+
}
|
|
463
|
+
async function ut(t) {
|
|
464
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
465
|
+
if (!e) return !1;
|
|
466
|
+
const s = await fetch(
|
|
467
|
+
`${e}${Ce}/auto-verify?email=${encodeURIComponent(t)}`,
|
|
468
|
+
{ credentials: "include" }
|
|
469
|
+
);
|
|
470
|
+
return s.ok ? (await s.json()).verified === !0 : !1;
|
|
471
|
+
}
|
|
472
|
+
async function ht(t) {
|
|
473
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
|
+
if (!e) return null;
|
|
475
|
+
try {
|
|
476
|
+
const s = await fetch(
|
|
477
|
+
`${e}${Ce}/pending-otp?email=${encodeURIComponent(t)}`,
|
|
478
|
+
{ credentials: "include" }
|
|
479
|
+
);
|
|
480
|
+
return s.ok ? (await s.json()).otp ?? null : null;
|
|
481
|
+
} catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function mt(t) {
|
|
458
486
|
const e = (() => {
|
|
459
487
|
if (t instanceof URL)
|
|
460
488
|
return t;
|
|
@@ -475,7 +503,7 @@ function dt(t) {
|
|
|
475
503
|
);
|
|
476
504
|
return e;
|
|
477
505
|
}
|
|
478
|
-
function
|
|
506
|
+
function ft(t, e) {
|
|
479
507
|
return e ? {
|
|
480
508
|
common: { ...t.common, ...e.common },
|
|
481
509
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -487,7 +515,7 @@ function ct(t, e) {
|
|
|
487
515
|
errors: { ...t.errors, ...e.errors }
|
|
488
516
|
} : t;
|
|
489
517
|
}
|
|
490
|
-
const
|
|
518
|
+
const N = {
|
|
491
519
|
common: {
|
|
492
520
|
loading: "Loading sign-in…",
|
|
493
521
|
redirecting: "Redirecting…",
|
|
@@ -550,7 +578,7 @@ const V = {
|
|
|
550
578
|
invalidCode: "Enter the 6-digit verification code.",
|
|
551
579
|
generic: "Something went wrong. Please try again."
|
|
552
580
|
}
|
|
553
|
-
},
|
|
581
|
+
}, q = {
|
|
554
582
|
common: {
|
|
555
583
|
loading: "加载中…",
|
|
556
584
|
redirecting: "跳转中…",
|
|
@@ -739,7 +767,7 @@ const V = {
|
|
|
739
767
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
740
768
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
741
769
|
}
|
|
742
|
-
},
|
|
770
|
+
}, x = {
|
|
743
771
|
common: {
|
|
744
772
|
loading: "Cargando inicio de sesión…",
|
|
745
773
|
redirecting: "Redirigiendo…",
|
|
@@ -1244,18 +1272,18 @@ const V = {
|
|
|
1244
1272
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1245
1273
|
}
|
|
1246
1274
|
}, be = {
|
|
1247
|
-
en:
|
|
1248
|
-
"en-US":
|
|
1249
|
-
zh:
|
|
1250
|
-
"zh-CN":
|
|
1251
|
-
"zh-TW":
|
|
1275
|
+
en: N,
|
|
1276
|
+
"en-US": N,
|
|
1277
|
+
zh: q,
|
|
1278
|
+
"zh-CN": q,
|
|
1279
|
+
"zh-TW": q,
|
|
1252
1280
|
ja: de,
|
|
1253
1281
|
"ja-JP": de,
|
|
1254
1282
|
ko: ce,
|
|
1255
1283
|
"ko-KR": ce,
|
|
1256
|
-
es:
|
|
1257
|
-
"es-ES":
|
|
1258
|
-
"es-MX":
|
|
1284
|
+
es: x,
|
|
1285
|
+
"es-ES": x,
|
|
1286
|
+
"es-MX": x,
|
|
1259
1287
|
pt: ue,
|
|
1260
1288
|
"pt-BR": ue,
|
|
1261
1289
|
fr: he,
|
|
@@ -1271,20 +1299,20 @@ const V = {
|
|
|
1271
1299
|
hi: ge,
|
|
1272
1300
|
"hi-IN": ge
|
|
1273
1301
|
};
|
|
1274
|
-
function
|
|
1302
|
+
function wt() {
|
|
1275
1303
|
if (typeof navigator > "u")
|
|
1276
|
-
return
|
|
1304
|
+
return N;
|
|
1277
1305
|
const t = navigator.languages ?? [navigator.language];
|
|
1278
1306
|
for (const e of t) {
|
|
1279
1307
|
const s = be[e] ?? be[e.split("-")[0]];
|
|
1280
1308
|
if (s) return s;
|
|
1281
1309
|
}
|
|
1282
|
-
return
|
|
1310
|
+
return N;
|
|
1283
1311
|
}
|
|
1284
|
-
const
|
|
1312
|
+
const Ue = {
|
|
1285
1313
|
LIGHT: "light",
|
|
1286
1314
|
DARK: "dark"
|
|
1287
|
-
},
|
|
1315
|
+
}, $e = Ue.LIGHT, pt = Ue.DARK, ke = [$e, pt], gt = $e, bt = {
|
|
1288
1316
|
BACKGROUND: "--edgespark-auth-bg",
|
|
1289
1317
|
BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
|
|
1290
1318
|
CARD_BACKGROUND: "--edgespark-auth-card-bg",
|
|
@@ -1304,19 +1332,19 @@ const Ce = {
|
|
|
1304
1332
|
MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
|
|
1305
1333
|
MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
|
|
1306
1334
|
MODAL_SHADOW: "--edgespark-auth-modal-shadow"
|
|
1307
|
-
},
|
|
1308
|
-
|
|
1335
|
+
}, vt = Object.values(
|
|
1336
|
+
bt
|
|
1309
1337
|
);
|
|
1310
|
-
function
|
|
1311
|
-
return typeof t == "string" &&
|
|
1338
|
+
function yt(t) {
|
|
1339
|
+
return typeof t == "string" && ke.includes(t);
|
|
1312
1340
|
}
|
|
1313
|
-
function
|
|
1314
|
-
return
|
|
1341
|
+
function Et(t) {
|
|
1342
|
+
return vt.includes(t);
|
|
1315
1343
|
}
|
|
1316
|
-
function
|
|
1344
|
+
function St(t) {
|
|
1317
1345
|
var e;
|
|
1318
1346
|
return {
|
|
1319
|
-
theme: (t == null ? void 0 : t.theme) ??
|
|
1347
|
+
theme: (t == null ? void 0 : t.theme) ?? gt,
|
|
1320
1348
|
className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
|
|
1321
1349
|
variables: { ...(t == null ? void 0 : t.variables) ?? {} }
|
|
1322
1350
|
};
|
|
@@ -1324,11 +1352,11 @@ function bt(t) {
|
|
|
1324
1352
|
function G(t, e = "Authentication failed.") {
|
|
1325
1353
|
return Se(t, e);
|
|
1326
1354
|
}
|
|
1327
|
-
async function
|
|
1355
|
+
async function B(t) {
|
|
1328
1356
|
var s, i;
|
|
1329
1357
|
const e = await t.getSession();
|
|
1330
1358
|
if (e.error)
|
|
1331
|
-
throw new
|
|
1359
|
+
throw new E(
|
|
1332
1360
|
e.error.message || "Failed to load the current session.",
|
|
1333
1361
|
{
|
|
1334
1362
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1344,7 +1372,7 @@ async function k(t) {
|
|
|
1344
1372
|
session: null
|
|
1345
1373
|
};
|
|
1346
1374
|
}
|
|
1347
|
-
const
|
|
1375
|
+
const Pt = "data-edgespark-auth", Lt = "data-edgespark-auth-theme", r = "edgespark-auth", K = "es_auth_completion", M = "es_auth_email", W = "oauth", k = "verify-sign-in", L = "verify-sign-up", ve = 200, Y = 2, _t = {
|
|
1348
1376
|
"&": "&",
|
|
1349
1377
|
"<": "<",
|
|
1350
1378
|
">": ">",
|
|
@@ -1367,16 +1395,16 @@ function X(t) {
|
|
|
1367
1395
|
function Z(t) {
|
|
1368
1396
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1369
1397
|
}
|
|
1370
|
-
function
|
|
1398
|
+
function At(t) {
|
|
1371
1399
|
return /^\d{6}$/.test(t.trim());
|
|
1372
1400
|
}
|
|
1373
|
-
function
|
|
1401
|
+
function Rt(t) {
|
|
1374
1402
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1375
1403
|
}
|
|
1376
|
-
function
|
|
1404
|
+
function Tt(t) {
|
|
1377
1405
|
return !!(t.error || t.errorDescription);
|
|
1378
1406
|
}
|
|
1379
|
-
class
|
|
1407
|
+
class It {
|
|
1380
1408
|
constructor(e, s, i, n, a) {
|
|
1381
1409
|
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
|
|
1382
1410
|
view: "loading",
|
|
@@ -1391,10 +1419,10 @@ class Lt {
|
|
|
1391
1419
|
code: "",
|
|
1392
1420
|
newPassword: ""
|
|
1393
1421
|
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
|
|
1394
|
-
const u =
|
|
1395
|
-
this.labels =
|
|
1396
|
-
for (const [g,
|
|
1397
|
-
|
|
1422
|
+
const u = St(i.appearance);
|
|
1423
|
+
this.labels = ft(wt(), i.labels), this.root = document.createElement("div"), this.root.className = u.className ? `${r} ${u.className}` : r, this.root.setAttribute(Pt, ""), this.root.setAttribute(Lt, u.theme);
|
|
1424
|
+
for (const [g, S] of Object.entries(u.variables))
|
|
1425
|
+
S !== void 0 && this.root.style.setProperty(g, S);
|
|
1398
1426
|
e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1399
1427
|
}
|
|
1400
1428
|
destroy() {
|
|
@@ -1410,7 +1438,7 @@ class Lt {
|
|
|
1410
1438
|
if (this.destroyed)
|
|
1411
1439
|
return;
|
|
1412
1440
|
if (i.status === "rejected") {
|
|
1413
|
-
if (e.marker && !
|
|
1441
|
+
if (e.marker && !Tt(e) && _(this.options)) {
|
|
1414
1442
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1415
1443
|
return;
|
|
1416
1444
|
}
|
|
@@ -1419,10 +1447,10 @@ class Lt {
|
|
|
1419
1447
|
if (a.user && a.session) {
|
|
1420
1448
|
switch (e.marker) {
|
|
1421
1449
|
case W:
|
|
1422
|
-
case
|
|
1450
|
+
case k:
|
|
1423
1451
|
await this.completeAuth("sign-in", a);
|
|
1424
1452
|
return;
|
|
1425
|
-
case
|
|
1453
|
+
case L:
|
|
1426
1454
|
await this.completeAuth("sign-up", a);
|
|
1427
1455
|
return;
|
|
1428
1456
|
default:
|
|
@@ -1448,21 +1476,21 @@ class Lt {
|
|
|
1448
1476
|
_(this.options) && this.navigateToRedirect();
|
|
1449
1477
|
}
|
|
1450
1478
|
navigateToRedirect() {
|
|
1451
|
-
_(this.options) && (this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(
|
|
1479
|
+
_(this.options) && (this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(mt(this.options.redirectTo).toString()));
|
|
1452
1480
|
}
|
|
1453
1481
|
async readMountSession(e) {
|
|
1454
1482
|
if (!e.marker)
|
|
1455
|
-
return
|
|
1483
|
+
return B(this.auth);
|
|
1456
1484
|
let s = null;
|
|
1457
1485
|
for (let i = 0; i <= Y; i++) {
|
|
1458
1486
|
try {
|
|
1459
|
-
const n = await
|
|
1487
|
+
const n = await B(this.auth);
|
|
1460
1488
|
if (n.user && n.session)
|
|
1461
1489
|
return n;
|
|
1462
1490
|
} catch (n) {
|
|
1463
1491
|
s = n;
|
|
1464
1492
|
}
|
|
1465
|
-
i < Y && await new Promise((n) => setTimeout(n,
|
|
1493
|
+
i < Y && await new Promise((n) => setTimeout(n, ve));
|
|
1466
1494
|
}
|
|
1467
1495
|
if (s)
|
|
1468
1496
|
throw s;
|
|
@@ -1481,6 +1509,7 @@ class Lt {
|
|
|
1481
1509
|
}
|
|
1482
1510
|
this.root.innerHTML = `
|
|
1483
1511
|
<div class="${r}__shell">
|
|
1512
|
+
${this.renderDevModeBanner()}
|
|
1484
1513
|
<div class="${r}__card">
|
|
1485
1514
|
${this.renderStatus()}
|
|
1486
1515
|
${this.renderCurrentView()}
|
|
@@ -1498,6 +1527,10 @@ class Lt {
|
|
|
1498
1527
|
</div>
|
|
1499
1528
|
`;
|
|
1500
1529
|
}
|
|
1530
|
+
renderDevModeBanner() {
|
|
1531
|
+
var e;
|
|
1532
|
+
return (e = this.config) != null && e.isLocalDev ? `<div class="${r}__dev-banner">Local dev mode — emails are mocked, OAuth uses test identities</div>` : "";
|
|
1533
|
+
}
|
|
1501
1534
|
renderStatus() {
|
|
1502
1535
|
const e = [];
|
|
1503
1536
|
return this.state.error && e.push(
|
|
@@ -1701,7 +1734,7 @@ class Lt {
|
|
|
1701
1734
|
});
|
|
1702
1735
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1703
1736
|
n.addEventListener("input", () => {
|
|
1704
|
-
|
|
1737
|
+
Rt(n.name) && (this.state[n.name] = n.value);
|
|
1705
1738
|
});
|
|
1706
1739
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1707
1740
|
n.addEventListener("click", () => {
|
|
@@ -1726,7 +1759,7 @@ class Lt {
|
|
|
1726
1759
|
const e = await this.auth.signIn.email({
|
|
1727
1760
|
email: this.state.email.trim(),
|
|
1728
1761
|
password: this.state.password,
|
|
1729
|
-
callbackURL: this.getManagedReturnURL(
|
|
1762
|
+
callbackURL: this.getManagedReturnURL(k, this.state.email.trim())
|
|
1730
1763
|
});
|
|
1731
1764
|
if (e.error)
|
|
1732
1765
|
throw e.error;
|
|
@@ -1763,12 +1796,14 @@ class Lt {
|
|
|
1763
1796
|
name: this.state.name.trim(),
|
|
1764
1797
|
email: this.state.email.trim(),
|
|
1765
1798
|
password: this.state.password,
|
|
1766
|
-
callbackURL: this.getManagedReturnURL(
|
|
1799
|
+
callbackURL: this.getManagedReturnURL(L, this.state.email.trim())
|
|
1767
1800
|
});
|
|
1768
1801
|
if (i.error)
|
|
1769
1802
|
throw i.error;
|
|
1770
1803
|
if ((n = this.config) != null && n.requireEmailVerification) {
|
|
1771
|
-
|
|
1804
|
+
if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", i.data))
|
|
1805
|
+
return;
|
|
1806
|
+
this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = this.config.isLocalDev ? "Dev mode: auto-verify didn’t complete. Click resend to retry." : "Check your inbox to verify your email address.", this.startCountdown();
|
|
1772
1807
|
return;
|
|
1773
1808
|
}
|
|
1774
1809
|
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(i.data));
|
|
@@ -1801,12 +1836,19 @@ class Lt {
|
|
|
1801
1836
|
return;
|
|
1802
1837
|
}
|
|
1803
1838
|
await this.runAction("Sending reset code…", async () => {
|
|
1839
|
+
var s;
|
|
1804
1840
|
const e = await this.passwordResetEndpoints().forgetPassword.emailOtp({
|
|
1805
1841
|
email: this.state.email.trim()
|
|
1806
1842
|
});
|
|
1807
1843
|
if (e.error)
|
|
1808
1844
|
throw e.error;
|
|
1809
|
-
this.state.view = "reset-password",
|
|
1845
|
+
if (this.state.view = "reset-password", (s = this.config) != null && s.isLocalDev) {
|
|
1846
|
+
this.state.busyLabel = "Dev mode: fetching reset code…", this.render();
|
|
1847
|
+
const i = await ht(this.state.email.trim());
|
|
1848
|
+
i ? (this.state.code = i, this.state.notice = `Dev mode: reset code auto-filled (${i})`) : this.state.notice = "Dev mode: could not retrieve reset code — check server logs";
|
|
1849
|
+
} else
|
|
1850
|
+
this.state.notice = `We sent a reset code to ${this.state.email.trim()}.`;
|
|
1851
|
+
this.startCountdown();
|
|
1810
1852
|
});
|
|
1811
1853
|
}
|
|
1812
1854
|
async resendResetCode() {
|
|
@@ -1820,7 +1862,7 @@ class Lt {
|
|
|
1820
1862
|
);
|
|
1821
1863
|
return;
|
|
1822
1864
|
}
|
|
1823
|
-
if (!
|
|
1865
|
+
if (!At(this.state.code)) {
|
|
1824
1866
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1825
1867
|
return;
|
|
1826
1868
|
}
|
|
@@ -1850,14 +1892,39 @@ class Lt {
|
|
|
1850
1892
|
});
|
|
1851
1893
|
}
|
|
1852
1894
|
async resendVerificationEmail() {
|
|
1895
|
+
var e;
|
|
1896
|
+
if ((e = this.config) != null && e.isLocalDev) {
|
|
1897
|
+
if (this.isCountdownActive()) return;
|
|
1898
|
+
await this.runAction("Dev mode: retrying auto-verify…", async () => {
|
|
1899
|
+
const s = this.verificationCompletionAction ?? "sign-in";
|
|
1900
|
+
if (!await this.tryDevAutoVerify(s))
|
|
1901
|
+
throw new Error(
|
|
1902
|
+
"Dev auto-verify did not complete. Check the edgespark dev logs and try again."
|
|
1903
|
+
);
|
|
1904
|
+
});
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1853
1907
|
await this.sendVerificationEmail(!1);
|
|
1854
1908
|
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Drive the local-dev auto-verify endpoint and, on success, complete the
|
|
1911
|
+
* auth flow. Returns whether auto-verify completed — callers decide what
|
|
1912
|
+
* to do on `false` (sign-up falls through to a retry UI; resend throws).
|
|
1913
|
+
*/
|
|
1914
|
+
async tryDevAutoVerify(e, s) {
|
|
1915
|
+
const i = this.state.email.trim();
|
|
1916
|
+
try {
|
|
1917
|
+
return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await ut(i) ? (this.state.notice = "Dev mode: email verification auto-completed", await this.completeAuth(e, await this.resolveAuthCompletionData(s)), !0) : (console.warn("[edgespark] Dev auto-verify returned false — falling through"), !1);
|
|
1918
|
+
} catch (n) {
|
|
1919
|
+
return console.warn("[edgespark] Dev auto-verify failed:", n), !1;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1855
1922
|
async sendVerificationEmail(e) {
|
|
1856
1923
|
!e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
|
|
1857
1924
|
const s = await this.auth.sendVerificationEmail({
|
|
1858
1925
|
email: this.state.email.trim(),
|
|
1859
1926
|
callbackURL: this.getManagedReturnURL(
|
|
1860
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1927
|
+
this.verificationCompletionAction === "sign-up" ? L : k,
|
|
1861
1928
|
this.state.email.trim()
|
|
1862
1929
|
)
|
|
1863
1930
|
});
|
|
@@ -1907,9 +1974,9 @@ class Lt {
|
|
|
1907
1974
|
return e;
|
|
1908
1975
|
let s = e.lookupError;
|
|
1909
1976
|
for (let i = 0; i < Y; i++) {
|
|
1910
|
-
await new Promise((n) => setTimeout(n,
|
|
1977
|
+
await new Promise((n) => setTimeout(n, ve));
|
|
1911
1978
|
try {
|
|
1912
|
-
const n = await
|
|
1979
|
+
const n = await B(this.auth);
|
|
1913
1980
|
if (n.user && n.session)
|
|
1914
1981
|
return {
|
|
1915
1982
|
user: n.user,
|
|
@@ -1933,7 +2000,7 @@ class Lt {
|
|
|
1933
2000
|
}
|
|
1934
2001
|
async resolveAuthCompletionData(e) {
|
|
1935
2002
|
try {
|
|
1936
|
-
const s = await
|
|
2003
|
+
const s = await B(this.auth), i = this.extractUser(e);
|
|
1937
2004
|
return {
|
|
1938
2005
|
user: s.user ?? i,
|
|
1939
2006
|
session: s.session
|
|
@@ -2016,7 +2083,7 @@ class Lt {
|
|
|
2016
2083
|
return i.searchParams.set(K, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
|
|
2017
2084
|
}
|
|
2018
2085
|
consumeManagedReturnContext() {
|
|
2019
|
-
const e = new URL(window.location.href), s = e.searchParams.get(K), i = s === W || s ===
|
|
2086
|
+
const e = new URL(window.location.href), s = e.searchParams.get(K), i = s === W || s === k || s === L ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, u = i ? e.searchParams.get("error_description") : null;
|
|
2020
2087
|
return (i || n) && (e.searchParams.delete(K), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
2021
2088
|
marker: i,
|
|
2022
2089
|
email: n,
|
|
@@ -2085,10 +2152,10 @@ class Lt {
|
|
|
2085
2152
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
2086
2153
|
}
|
|
2087
2154
|
handleSessionlessManagedReturn(e) {
|
|
2088
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
2155
|
+
return e.email && (this.state.email = e.email), e.marker === L && !e.error ? (this.verificationCompletionAction = null, this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render(), !0) : e.marker === k || e.marker === L ? (this.verificationCompletionAction = e.marker === L ? "sign-up" : "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, e.error || e.errorDescription ? this.handleError(new E(
|
|
2089
2156
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
2090
2157
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
2091
|
-
)) : this.render(), !0) : e.marker === W && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new
|
|
2158
|
+
)) : this.render(), !0) : e.marker === W && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new E(
|
|
2092
2159
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
2093
2160
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
2094
2161
|
)), !0) : !1;
|
|
@@ -2104,58 +2171,59 @@ class Lt {
|
|
|
2104
2171
|
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2105
2172
|
}
|
|
2106
2173
|
escape(e) {
|
|
2107
|
-
return e.replace(/[&<>"']/g, (s) =>
|
|
2174
|
+
return e.replace(/[&<>"']/g, (s) => _t[s]);
|
|
2108
2175
|
}
|
|
2109
2176
|
}
|
|
2110
|
-
function
|
|
2177
|
+
function Ct(t) {
|
|
2111
2178
|
return "data" in t && t.data ? t.data : t;
|
|
2112
2179
|
}
|
|
2113
|
-
const
|
|
2180
|
+
const Ut = [
|
|
2114
2181
|
{ id: "google", key: "providerGoogle" },
|
|
2115
2182
|
{ id: "apple", key: "providerApple" },
|
|
2116
2183
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2117
2184
|
{ id: "github", key: "providerGithub" },
|
|
2118
2185
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2119
2186
|
{ id: "discord", key: "providerDiscord" }
|
|
2120
|
-
],
|
|
2121
|
-
async function
|
|
2122
|
-
const t = `${window.location.origin}${
|
|
2187
|
+
], ye = 2, $t = 500;
|
|
2188
|
+
async function kt() {
|
|
2189
|
+
const t = `${window.location.origin}${Le}/config`;
|
|
2123
2190
|
let e;
|
|
2124
|
-
for (let s = 0; s <=
|
|
2191
|
+
for (let s = 0; s <= ye; s++)
|
|
2125
2192
|
try {
|
|
2126
2193
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2127
2194
|
if (!i.ok)
|
|
2128
2195
|
throw new f(`Failed to load auth config: HTTP ${i.status}`);
|
|
2129
|
-
const n = await i.json();
|
|
2130
|
-
return
|
|
2196
|
+
const n = await i.json(), a = Ct(n);
|
|
2197
|
+
return Mt(a, ct());
|
|
2131
2198
|
} catch (i) {
|
|
2132
|
-
e = i, s <
|
|
2199
|
+
e = i, s < ye && await new Promise((n) => setTimeout(n, $t));
|
|
2133
2200
|
}
|
|
2134
2201
|
throw e;
|
|
2135
2202
|
}
|
|
2136
2203
|
let O = null;
|
|
2137
|
-
async function
|
|
2138
|
-
return O || (O =
|
|
2204
|
+
async function Bt() {
|
|
2205
|
+
return O || (O = kt().catch((t) => {
|
|
2139
2206
|
throw O = null, t;
|
|
2140
2207
|
})), O;
|
|
2141
2208
|
}
|
|
2142
|
-
function
|
|
2143
|
-
var
|
|
2144
|
-
const
|
|
2145
|
-
const
|
|
2146
|
-
return typeof
|
|
2147
|
-
}).map(({ id:
|
|
2209
|
+
function Mt(t, e = !1) {
|
|
2210
|
+
var i, n, a, u, g, S, U;
|
|
2211
|
+
const s = Ut.filter(({ key: $ }) => {
|
|
2212
|
+
const v = t[$];
|
|
2213
|
+
return typeof v == "object" && v !== null && "enabled" in v && !!v.enabled;
|
|
2214
|
+
}).map(({ id: $ }) => $);
|
|
2148
2215
|
return {
|
|
2149
2216
|
disableSignUp: !!t.disableSignUp,
|
|
2150
|
-
emailPasswordEnabled: !!((
|
|
2151
|
-
minPasswordLength: ((
|
|
2152
|
-
requireEmailVerification: !!((
|
|
2153
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2154
|
-
oauthProviders:
|
|
2217
|
+
emailPasswordEnabled: !!((i = t.providerEmailPassword) != null && i.enabled),
|
|
2218
|
+
minPasswordLength: ((a = (n = t.providerEmailPassword) == null ? void 0 : n.config) == null ? void 0 : a.minPasswordLength) ?? 8,
|
|
2219
|
+
requireEmailVerification: !!((g = (u = t.providerEmailPassword) == null ? void 0 : u.config) != null && g.requireEmailVerification),
|
|
2220
|
+
passwordResetEmailOtpEnabled: !!((U = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && U.requirePasswordResetEmailVerification),
|
|
2221
|
+
oauthProviders: s,
|
|
2222
|
+
isLocalDev: e
|
|
2155
2223
|
};
|
|
2156
2224
|
}
|
|
2157
|
-
const
|
|
2158
|
-
function
|
|
2225
|
+
const D = /* @__PURE__ */ new WeakMap();
|
|
2226
|
+
function Ot(t) {
|
|
2159
2227
|
if (!t)
|
|
2160
2228
|
throw new f(
|
|
2161
2229
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
@@ -2186,9 +2254,9 @@ function $t(t) {
|
|
|
2186
2254
|
throw new f(
|
|
2187
2255
|
"authUI.mount(container, options) expected appearance to be an object."
|
|
2188
2256
|
);
|
|
2189
|
-
if ("theme" in i && i.theme !== void 0 && !
|
|
2257
|
+
if ("theme" in i && i.theme !== void 0 && !yt(i.theme))
|
|
2190
2258
|
throw new f(
|
|
2191
|
-
`authUI.mount(container, options) expected appearance.theme to be one of: ${
|
|
2259
|
+
`authUI.mount(container, options) expected appearance.theme to be one of: ${ke.join(", ")}.`
|
|
2192
2260
|
);
|
|
2193
2261
|
if ("className" in i && i.className !== void 0 && typeof i.className != "string")
|
|
2194
2262
|
throw new f(
|
|
@@ -2200,7 +2268,7 @@ function $t(t) {
|
|
|
2200
2268
|
"authUI.mount(container, options) expected appearance.variables to be an object."
|
|
2201
2269
|
);
|
|
2202
2270
|
for (const [n, a] of Object.entries(i.variables)) {
|
|
2203
|
-
if (!
|
|
2271
|
+
if (!Et(n))
|
|
2204
2272
|
throw new f(
|
|
2205
2273
|
`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
|
|
2206
2274
|
);
|
|
@@ -2212,29 +2280,29 @@ function $t(t) {
|
|
|
2212
2280
|
}
|
|
2213
2281
|
}
|
|
2214
2282
|
}
|
|
2215
|
-
function
|
|
2283
|
+
function Dt(t) {
|
|
2216
2284
|
if (!(t instanceof HTMLElement))
|
|
2217
2285
|
throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2218
2286
|
}
|
|
2219
|
-
function
|
|
2287
|
+
function Nt(t, e) {
|
|
2220
2288
|
return {
|
|
2221
2289
|
mount(s, i) {
|
|
2222
2290
|
var g;
|
|
2223
|
-
|
|
2224
|
-
const n = new
|
|
2291
|
+
Ot(i), Dt(s), (g = D.get(s)) == null || g.destroy();
|
|
2292
|
+
const n = new It(s, t, i, Bt, e), a = n.destroy.bind(n), u = {
|
|
2225
2293
|
destroy() {
|
|
2226
|
-
a(),
|
|
2294
|
+
a(), D.get(s) === u && D.delete(s);
|
|
2227
2295
|
}
|
|
2228
2296
|
};
|
|
2229
|
-
return
|
|
2297
|
+
return D.set(s, u), u;
|
|
2230
2298
|
}
|
|
2231
2299
|
};
|
|
2232
2300
|
}
|
|
2233
|
-
function
|
|
2301
|
+
function Ft() {
|
|
2234
2302
|
Pe();
|
|
2235
|
-
const t =
|
|
2303
|
+
const t = lt(), e = dt(), s = Fe(), i = Nt(e, {
|
|
2236
2304
|
syncPublicSession: async () => {
|
|
2237
|
-
await
|
|
2305
|
+
await at(t);
|
|
2238
2306
|
}
|
|
2239
2307
|
});
|
|
2240
2308
|
return {
|
|
@@ -2244,23 +2312,23 @@ function Ot() {
|
|
|
2244
2312
|
};
|
|
2245
2313
|
}
|
|
2246
2314
|
export {
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2315
|
+
bt as AUTH_UI_APPEARANCE_VARIABLE,
|
|
2316
|
+
vt as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
|
|
2317
|
+
gt as AUTH_UI_DEFAULT_THEME,
|
|
2318
|
+
Ue as AUTH_UI_THEME,
|
|
2319
|
+
ke as AUTH_UI_THEMES,
|
|
2320
|
+
pt as AUTH_UI_THEME_DARK,
|
|
2321
|
+
$e as AUTH_UI_THEME_LIGHT,
|
|
2322
|
+
E as EdgeSparkAuthError,
|
|
2255
2323
|
f as EdgeSparkConfigError,
|
|
2256
2324
|
te as EdgeSparkError,
|
|
2257
2325
|
Ee as EdgeSparkRuntimeError,
|
|
2258
2326
|
pe as ar,
|
|
2259
|
-
|
|
2327
|
+
Ft as createEdgeSpark,
|
|
2260
2328
|
me as de,
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2329
|
+
wt as detectLocale,
|
|
2330
|
+
N as enUS,
|
|
2331
|
+
x as es,
|
|
2264
2332
|
he as fr,
|
|
2265
2333
|
ge as hi,
|
|
2266
2334
|
fe as it,
|
|
@@ -2268,5 +2336,5 @@ export {
|
|
|
2268
2336
|
ce as ko,
|
|
2269
2337
|
ue as ptBR,
|
|
2270
2338
|
we as ru,
|
|
2271
|
-
|
|
2339
|
+
q as zhCN
|
|
2272
2340
|
};
|