@edgespark/web 0.0.1-beta.6 → 0.0.1-beta.7
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/auth-ui/ManagedAuthUI.d.ts +2 -2
- package/dist/auth-ui/mount.d.ts +1 -4
- package/dist/errors.d.ts +9 -0
- package/dist/index.cjs +2 -2
- package/dist/index.es.js +250 -250
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -4,24 +4,37 @@ class ee extends Error {
|
|
|
4
4
|
super(s), this.name = "EdgeSparkError", this.code = e;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class f extends ee {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class ye extends ee {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class v extends ee {
|
|
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
|
+
function Se(t, e = "Authentication failed.", s) {
|
|
23
|
+
if (t instanceof v)
|
|
24
|
+
return t;
|
|
25
|
+
if (typeof t == "object" && t !== null) {
|
|
26
|
+
const i = t;
|
|
27
|
+
return new v(i.message || e, {
|
|
28
|
+
code: i.code ?? s,
|
|
29
|
+
status: i.status,
|
|
30
|
+
cause: t
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return typeof t == "string" ? new v(t, { code: s }) : new v(e, { code: s, cause: t });
|
|
34
|
+
}
|
|
22
35
|
function Pe() {
|
|
23
36
|
if (typeof window > "u" || typeof document > "u")
|
|
24
|
-
throw new
|
|
37
|
+
throw new ye(
|
|
25
38
|
"@edgespark/web is browser-only. Create the client from a real browser runtime."
|
|
26
39
|
);
|
|
27
40
|
}
|
|
@@ -33,7 +46,7 @@ function Be(t) {
|
|
|
33
46
|
}
|
|
34
47
|
function ke(t) {
|
|
35
48
|
if (t.origin !== Q())
|
|
36
|
-
throw new
|
|
49
|
+
throw new f(
|
|
37
50
|
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
|
|
38
51
|
);
|
|
39
52
|
}
|
|
@@ -48,13 +61,13 @@ function Me() {
|
|
|
48
61
|
}
|
|
49
62
|
};
|
|
50
63
|
}
|
|
51
|
-
const Ee = "/api/_es/auth", Oe = "edgespark-auth-session", Le = "__edgespark_auth_sync__",
|
|
64
|
+
const Ee = "/api/_es/auth", Oe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", N = "__edgespark_auth_pending_sign_in__", _e = Symbol("edgespark.notifyAuthTabs"), Ve = 10 * 60 * 1e3, Ne = /* @__PURE__ */ new Set([
|
|
52
65
|
"signOut",
|
|
53
66
|
"revokeSession",
|
|
54
67
|
"revokeSessions",
|
|
55
68
|
"revokeOtherSessions"
|
|
56
69
|
]);
|
|
57
|
-
class
|
|
70
|
+
class Fe {
|
|
58
71
|
constructor(e) {
|
|
59
72
|
this.value = e;
|
|
60
73
|
}
|
|
@@ -63,11 +76,11 @@ class Ne {
|
|
|
63
76
|
}
|
|
64
77
|
}
|
|
65
78
|
const ie = globalThis.WeakRef, ne = globalThis.FinalizationRegistry;
|
|
66
|
-
let
|
|
67
|
-
const
|
|
68
|
-
|
|
79
|
+
let F, re = !1;
|
|
80
|
+
const C = /* @__PURE__ */ new Map(), z = ne ? new ne((t) => {
|
|
81
|
+
C.delete(t);
|
|
69
82
|
}) : null;
|
|
70
|
-
function
|
|
83
|
+
function Ie(t) {
|
|
71
84
|
return Ue({
|
|
72
85
|
baseURL: Q(),
|
|
73
86
|
basePath: Ee,
|
|
@@ -77,17 +90,17 @@ function Ce(t) {
|
|
|
77
90
|
}
|
|
78
91
|
});
|
|
79
92
|
}
|
|
80
|
-
function
|
|
93
|
+
function R(t) {
|
|
81
94
|
var e, s;
|
|
82
95
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
83
96
|
}
|
|
84
|
-
function
|
|
97
|
+
function ze(t) {
|
|
85
98
|
return JSON.stringify({
|
|
86
99
|
source: t,
|
|
87
100
|
timestamp: Date.now()
|
|
88
101
|
});
|
|
89
102
|
}
|
|
90
|
-
function
|
|
103
|
+
function De(t) {
|
|
91
104
|
if (typeof t != "string")
|
|
92
105
|
return null;
|
|
93
106
|
try {
|
|
@@ -100,56 +113,58 @@ function ze(t) {
|
|
|
100
113
|
async function X(t) {
|
|
101
114
|
var e;
|
|
102
115
|
try {
|
|
103
|
-
return await ((e =
|
|
116
|
+
return await ((e = R(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
104
117
|
} catch {
|
|
105
118
|
return !1;
|
|
106
119
|
}
|
|
107
120
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
121
|
+
function Re() {
|
|
122
|
+
return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Oe) : null), F;
|
|
110
123
|
}
|
|
111
124
|
function oe(t) {
|
|
112
|
-
const e =
|
|
125
|
+
const e = De(t);
|
|
113
126
|
if (e)
|
|
114
|
-
for (const [s, i] of
|
|
127
|
+
for (const [s, i] of C) {
|
|
115
128
|
if (s === e.source)
|
|
116
129
|
continue;
|
|
117
130
|
const n = i.deref();
|
|
118
131
|
if (!n) {
|
|
119
|
-
|
|
132
|
+
C.delete(s);
|
|
120
133
|
continue;
|
|
121
134
|
}
|
|
122
135
|
X(n);
|
|
123
136
|
}
|
|
124
137
|
}
|
|
125
|
-
function
|
|
138
|
+
function qe() {
|
|
126
139
|
var t;
|
|
127
|
-
re || (re = !0, (t =
|
|
140
|
+
re || (re = !0, (t = Re()) == null || t.addEventListener("message", (e) => {
|
|
128
141
|
oe(e.data);
|
|
129
142
|
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
130
143
|
e.key !== Le || e.newValue === null || oe(e.newValue);
|
|
131
144
|
}));
|
|
132
145
|
}
|
|
133
|
-
function
|
|
134
|
-
ie ?
|
|
146
|
+
function je(t, e) {
|
|
147
|
+
ie ? C.set(t, new ie(e)) : (C.clear(), C.set(t, new Fe(e))), z == null || z.register(e, t), qe();
|
|
135
148
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
function I(t) {
|
|
150
|
+
const e = ze(t), s = Re();
|
|
151
|
+
let i = !1;
|
|
152
|
+
if (s)
|
|
153
|
+
try {
|
|
154
|
+
s.postMessage(e), i = !0;
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
if (!i)
|
|
158
|
+
try {
|
|
159
|
+
window.localStorage.setItem(Le, e);
|
|
160
|
+
} catch {
|
|
161
|
+
}
|
|
147
162
|
}
|
|
148
|
-
function
|
|
163
|
+
function D(t) {
|
|
149
164
|
if (!(typeof window > "u"))
|
|
150
165
|
try {
|
|
151
166
|
window.sessionStorage.setItem(
|
|
152
|
-
|
|
167
|
+
N,
|
|
153
168
|
JSON.stringify({
|
|
154
169
|
path: t,
|
|
155
170
|
createdAt: Date.now()
|
|
@@ -158,97 +173,85 @@ function q(t) {
|
|
|
158
173
|
} catch {
|
|
159
174
|
}
|
|
160
175
|
}
|
|
161
|
-
function
|
|
176
|
+
function $() {
|
|
162
177
|
if (!(typeof window > "u"))
|
|
163
178
|
try {
|
|
164
|
-
window.sessionStorage.removeItem(
|
|
179
|
+
window.sessionStorage.removeItem(N);
|
|
165
180
|
} catch {
|
|
166
181
|
}
|
|
167
182
|
}
|
|
168
183
|
function He(t) {
|
|
169
184
|
return !!(t != null && t.session && (t != null && t.user));
|
|
170
185
|
}
|
|
171
|
-
function
|
|
186
|
+
function Te() {
|
|
172
187
|
if (typeof window > "u")
|
|
173
|
-
return
|
|
188
|
+
return null;
|
|
174
189
|
try {
|
|
175
|
-
const t = window.sessionStorage.getItem(
|
|
190
|
+
const t = window.sessionStorage.getItem(N);
|
|
176
191
|
if (!t)
|
|
177
|
-
return
|
|
178
|
-
window.sessionStorage.removeItem(S);
|
|
192
|
+
return null;
|
|
179
193
|
const e = JSON.parse(t);
|
|
180
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number"
|
|
194
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ve ? null : { createdAt: e.createdAt };
|
|
181
195
|
} catch {
|
|
182
|
-
return
|
|
196
|
+
return null;
|
|
183
197
|
}
|
|
184
198
|
}
|
|
185
|
-
function
|
|
186
|
-
if (
|
|
199
|
+
function ae() {
|
|
200
|
+
if (!Te())
|
|
187
201
|
return !1;
|
|
188
202
|
try {
|
|
189
|
-
|
|
190
|
-
if (!t)
|
|
191
|
-
return !1;
|
|
192
|
-
const e = JSON.parse(t);
|
|
193
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ie ? (window.sessionStorage.removeItem(S), !1) : !0;
|
|
203
|
+
window.sessionStorage.removeItem(N);
|
|
194
204
|
} catch {
|
|
195
|
-
return !1;
|
|
196
205
|
}
|
|
206
|
+
return !0;
|
|
207
|
+
}
|
|
208
|
+
function xe() {
|
|
209
|
+
return Te() !== null;
|
|
197
210
|
}
|
|
198
|
-
function
|
|
211
|
+
function We(t) {
|
|
199
212
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
200
213
|
return !1;
|
|
201
214
|
const e = "data" in t ? t.data : t;
|
|
202
215
|
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;
|
|
203
216
|
}
|
|
204
|
-
function
|
|
217
|
+
function Ge(t) {
|
|
205
218
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
206
219
|
return !1;
|
|
207
220
|
const e = "data" in t ? t.data : t;
|
|
208
221
|
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
209
222
|
}
|
|
210
|
-
function
|
|
211
|
-
if (
|
|
223
|
+
function Ye(t) {
|
|
224
|
+
if (T(t) || !(t && typeof t == "object"))
|
|
212
225
|
return !1;
|
|
213
226
|
const e = "data" in t ? t.data : t;
|
|
214
227
|
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
215
228
|
}
|
|
216
|
-
function
|
|
229
|
+
function Ke(t, e) {
|
|
217
230
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
218
231
|
return !1;
|
|
219
232
|
const [s] = e;
|
|
220
233
|
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
221
234
|
}
|
|
222
|
-
function
|
|
235
|
+
function T(t) {
|
|
223
236
|
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
224
237
|
}
|
|
225
|
-
function
|
|
226
|
-
if (
|
|
238
|
+
function Je(t) {
|
|
239
|
+
if (T(t) || !(t && typeof t == "object"))
|
|
227
240
|
return !1;
|
|
228
241
|
const e = "data" in t ? t.data : t;
|
|
229
242
|
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
230
243
|
}
|
|
231
|
-
function
|
|
244
|
+
function Ze(t) {
|
|
232
245
|
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
233
246
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
236
|
-
return t;
|
|
237
|
-
const e = t;
|
|
238
|
-
return new y(
|
|
239
|
-
(e == null ? void 0 : e.message) || "Failed to load the current session.",
|
|
240
|
-
{
|
|
241
|
-
code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
|
|
242
|
-
cause: t,
|
|
243
|
-
status: e == null ? void 0 : e.status
|
|
244
|
-
}
|
|
245
|
-
);
|
|
247
|
+
function q(t) {
|
|
248
|
+
return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
246
249
|
}
|
|
247
|
-
async function
|
|
250
|
+
async function Qe(t) {
|
|
248
251
|
var s, i;
|
|
249
252
|
let e = null;
|
|
250
253
|
try {
|
|
251
|
-
await ((s =
|
|
254
|
+
await ((s = R(t)) == null ? void 0 : s.get().refetch());
|
|
252
255
|
} catch (n) {
|
|
253
256
|
e = n;
|
|
254
257
|
} finally {
|
|
@@ -257,16 +260,16 @@ async function Ze(t) {
|
|
|
257
260
|
if (e)
|
|
258
261
|
throw e;
|
|
259
262
|
}
|
|
260
|
-
function
|
|
261
|
-
const t =
|
|
262
|
-
|
|
263
|
+
function Xe() {
|
|
264
|
+
const t = Ie(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
265
|
+
je(e, t);
|
|
263
266
|
const s = 2, i = 500;
|
|
264
267
|
let n = null, a = !1, h;
|
|
265
|
-
const w = (o) => (h = o, o),
|
|
268
|
+
const w = (o) => (h = o, o), E = () => {
|
|
266
269
|
var c;
|
|
267
|
-
const o = (c =
|
|
270
|
+
const o = (c = R(t)) == null ? void 0 : c.get();
|
|
268
271
|
return o != null && o.error && !o.data && h !== void 0 ? h : (o == null ? void 0 : o.data) ?? h ?? null;
|
|
269
|
-
},
|
|
272
|
+
}, L = () => a ? Promise.resolve(E()) : (n || (n = (async () => {
|
|
270
273
|
var l, u, g;
|
|
271
274
|
let o = !1, c = null;
|
|
272
275
|
try {
|
|
@@ -274,75 +277,75 @@ function Qe() {
|
|
|
274
277
|
let d = null;
|
|
275
278
|
try {
|
|
276
279
|
d = await t.getSession();
|
|
277
|
-
} catch (
|
|
278
|
-
c =
|
|
280
|
+
} catch (y) {
|
|
281
|
+
c = y;
|
|
279
282
|
}
|
|
280
|
-
const b = ((l =
|
|
283
|
+
const b = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
|
|
281
284
|
if ((u = d == null ? void 0 : d.data) != null && u.session && ((g = d.data) != null && g.user))
|
|
282
|
-
return a = !0, ae() &&
|
|
285
|
+
return a = !0, ae() && I(e), w(d.data);
|
|
283
286
|
if (b != null && b.session && (b != null && b.user))
|
|
284
|
-
return a = !0, ae() &&
|
|
285
|
-
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error &&
|
|
287
|
+
return a = !0, ae() && I(e), w(b);
|
|
288
|
+
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && xe() && p < s) {
|
|
286
289
|
await new Promise(
|
|
287
|
-
(
|
|
290
|
+
(y) => setTimeout(y, i)
|
|
288
291
|
);
|
|
289
292
|
continue;
|
|
290
293
|
}
|
|
291
294
|
if (d && !d.error) {
|
|
292
|
-
const
|
|
293
|
-
return a = !0, w(
|
|
295
|
+
const y = E();
|
|
296
|
+
return a = !0, w(y);
|
|
294
297
|
}
|
|
295
298
|
p < s && await new Promise(
|
|
296
|
-
(
|
|
299
|
+
(y) => setTimeout(y, i)
|
|
297
300
|
);
|
|
298
301
|
}
|
|
299
302
|
if (!o)
|
|
300
|
-
throw n = null, new
|
|
303
|
+
throw n = null, new v("Failed to load the current session.", {
|
|
301
304
|
code: "SESSION_LOOKUP_FAILED",
|
|
302
305
|
cause: c
|
|
303
306
|
});
|
|
304
|
-
const
|
|
305
|
-
return a = !0, w(
|
|
306
|
-
} catch (
|
|
307
|
-
throw n = null,
|
|
307
|
+
const m = E();
|
|
308
|
+
return a = !0, w(m);
|
|
309
|
+
} catch (m) {
|
|
310
|
+
throw n = null, q(m);
|
|
308
311
|
}
|
|
309
312
|
})()), n);
|
|
310
|
-
|
|
313
|
+
L().catch(() => {
|
|
311
314
|
});
|
|
312
|
-
const
|
|
315
|
+
const _ = async () => {
|
|
313
316
|
var o, c;
|
|
314
317
|
try {
|
|
315
318
|
const l = await t.getSession();
|
|
316
319
|
if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
|
|
317
320
|
return l.data;
|
|
318
|
-
throw l.error ?
|
|
321
|
+
throw l.error ? q(l.error) : new v("No authenticated session is available.", {
|
|
319
322
|
code: "UNAUTHENTICATED"
|
|
320
323
|
});
|
|
321
324
|
} catch (l) {
|
|
322
|
-
throw
|
|
325
|
+
throw q(l);
|
|
323
326
|
}
|
|
324
|
-
},
|
|
325
|
-
await X(t),
|
|
326
|
-
},
|
|
327
|
+
}, A = async () => {
|
|
328
|
+
await X(t), I(e);
|
|
329
|
+
}, Ce = async () => {
|
|
327
330
|
var l;
|
|
328
|
-
const o = await X(t), c = ((l =
|
|
329
|
-
He(c) ? (
|
|
331
|
+
const o = await X(t), c = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
|
|
332
|
+
He(c) ? ($(), I(e)) : o || I(e);
|
|
330
333
|
}, Ae = (o) => {
|
|
331
334
|
let c = !1, l = !1, u;
|
|
332
335
|
const g = (d) => {
|
|
333
336
|
d !== u && (u = d, o(d));
|
|
334
337
|
};
|
|
335
|
-
|
|
338
|
+
L().then((d) => {
|
|
336
339
|
c || (l = !0, g(w(d)));
|
|
337
340
|
}).catch(() => {
|
|
338
341
|
c || (l = !0);
|
|
339
342
|
});
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
343
|
+
const m = R(t);
|
|
344
|
+
if (!m)
|
|
342
345
|
return () => {
|
|
343
346
|
c = !0;
|
|
344
347
|
};
|
|
345
|
-
const p =
|
|
348
|
+
const p = m.subscribe((d) => {
|
|
346
349
|
if (c || !l || d.error && !d.data)
|
|
347
350
|
return;
|
|
348
351
|
const b = d.data ?? null;
|
|
@@ -353,7 +356,7 @@ function Qe() {
|
|
|
353
356
|
};
|
|
354
357
|
}, $e = async (o, c, l) => {
|
|
355
358
|
const u = o[0], g = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail";
|
|
356
|
-
return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? (
|
|
359
|
+
return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? ($(), Je(l) && await A(), l) : o.length === 1 && u && Ne.has(u) ? ($(), T(l) || await A(), l) : Ke(o, c) && !T(l) ? ($(), await A(), l) : o.length === 1 && u === "changeEmail" && !T(l) ? (await A(), l) : ((u === "signIn" || u === "signUp" || g) && We(l) ? ($(), await A()) : (u === "signIn" || u === "signUp") && Ge(l) || u === "signUp" && Ye(l) ? D(o) : u === "verifyEmail" && !T(l) && (D(o), await Ce()), l);
|
|
357
360
|
}, te = /* @__PURE__ */ new WeakMap(), se = (o, c) => {
|
|
358
361
|
if (!o || typeof o != "object" && typeof o != "function")
|
|
359
362
|
return o;
|
|
@@ -361,27 +364,27 @@ function Qe() {
|
|
|
361
364
|
if (l)
|
|
362
365
|
return l;
|
|
363
366
|
const u = new Proxy(o, {
|
|
364
|
-
get(g,
|
|
367
|
+
get(g, m, p) {
|
|
365
368
|
if (c.length === 0) {
|
|
366
|
-
if (
|
|
367
|
-
return
|
|
368
|
-
if (
|
|
369
|
+
if (m === "requireSession")
|
|
370
|
+
return _;
|
|
371
|
+
if (m === "onSessionChange")
|
|
369
372
|
return Ae;
|
|
370
|
-
if (
|
|
373
|
+
if (m === _e)
|
|
371
374
|
return () => {
|
|
372
|
-
|
|
375
|
+
I(e);
|
|
373
376
|
};
|
|
374
377
|
}
|
|
375
|
-
const d = Reflect.get(g,
|
|
376
|
-
return typeof
|
|
378
|
+
const d = Reflect.get(g, m, p);
|
|
379
|
+
return typeof m != "string" ? d : se(d, [...c, m]);
|
|
377
380
|
},
|
|
378
|
-
apply(g,
|
|
381
|
+
apply(g, m, p) {
|
|
379
382
|
const d = Reflect.apply(
|
|
380
383
|
g,
|
|
381
|
-
|
|
384
|
+
m,
|
|
382
385
|
p
|
|
383
386
|
);
|
|
384
|
-
return
|
|
387
|
+
return Ze(d) ? Promise.resolve(d).then(
|
|
385
388
|
(b) => $e(c, p, b)
|
|
386
389
|
) : d;
|
|
387
390
|
}
|
|
@@ -390,31 +393,31 @@ function Qe() {
|
|
|
390
393
|
};
|
|
391
394
|
return se(t, []);
|
|
392
395
|
}
|
|
393
|
-
function
|
|
394
|
-
return
|
|
396
|
+
function et() {
|
|
397
|
+
return Ie({ disableDefaultRedirectPlugin: !0 });
|
|
395
398
|
}
|
|
396
|
-
function
|
|
399
|
+
function tt(t) {
|
|
397
400
|
const e = (() => {
|
|
398
401
|
if (t instanceof URL)
|
|
399
402
|
return t;
|
|
400
403
|
const s = t.trim();
|
|
401
404
|
if (!s)
|
|
402
|
-
throw new
|
|
405
|
+
throw new f("redirectTo must not be an empty string.");
|
|
403
406
|
try {
|
|
404
407
|
return new URL(s, window.location.href);
|
|
405
408
|
} catch {
|
|
406
|
-
throw new
|
|
409
|
+
throw new f(
|
|
407
410
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
408
411
|
);
|
|
409
412
|
}
|
|
410
413
|
})();
|
|
411
414
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
412
|
-
throw new
|
|
415
|
+
throw new f(
|
|
413
416
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
414
417
|
);
|
|
415
418
|
return e;
|
|
416
419
|
}
|
|
417
|
-
function
|
|
420
|
+
function st(t, e) {
|
|
418
421
|
return e ? {
|
|
419
422
|
common: { ...t.common, ...e.common },
|
|
420
423
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -426,7 +429,7 @@ function et(t, e) {
|
|
|
426
429
|
errors: { ...t.errors, ...e.errors }
|
|
427
430
|
} : t;
|
|
428
431
|
}
|
|
429
|
-
const
|
|
432
|
+
const V = {
|
|
430
433
|
common: {
|
|
431
434
|
loading: "Loading sign-in…",
|
|
432
435
|
redirecting: "Redirecting…",
|
|
@@ -678,7 +681,7 @@ const F = {
|
|
|
678
681
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
679
682
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
680
683
|
}
|
|
681
|
-
},
|
|
684
|
+
}, H = {
|
|
682
685
|
common: {
|
|
683
686
|
loading: "Cargando inicio de sesión…",
|
|
684
687
|
redirecting: "Redirigiendo…",
|
|
@@ -1183,8 +1186,8 @@ const F = {
|
|
|
1183
1186
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1184
1187
|
}
|
|
1185
1188
|
}, pe = {
|
|
1186
|
-
en:
|
|
1187
|
-
"en-US":
|
|
1189
|
+
en: V,
|
|
1190
|
+
"en-US": V,
|
|
1188
1191
|
zh: j,
|
|
1189
1192
|
"zh-CN": j,
|
|
1190
1193
|
"zh-TW": j,
|
|
@@ -1192,9 +1195,9 @@ const F = {
|
|
|
1192
1195
|
"ja-JP": le,
|
|
1193
1196
|
ko: de,
|
|
1194
1197
|
"ko-KR": de,
|
|
1195
|
-
es:
|
|
1196
|
-
"es-ES":
|
|
1197
|
-
"es-MX":
|
|
1198
|
+
es: H,
|
|
1199
|
+
"es-ES": H,
|
|
1200
|
+
"es-MX": H,
|
|
1198
1201
|
pt: ce,
|
|
1199
1202
|
"pt-BR": ce,
|
|
1200
1203
|
fr: ue,
|
|
@@ -1210,34 +1213,24 @@ const F = {
|
|
|
1210
1213
|
hi: ge,
|
|
1211
1214
|
"hi-IN": ge
|
|
1212
1215
|
};
|
|
1213
|
-
function
|
|
1216
|
+
function it() {
|
|
1214
1217
|
if (typeof navigator > "u")
|
|
1215
|
-
return
|
|
1218
|
+
return V;
|
|
1216
1219
|
const t = navigator.languages ?? [navigator.language];
|
|
1217
1220
|
for (const e of t) {
|
|
1218
1221
|
const s = pe[e] ?? pe[e.split("-")[0]];
|
|
1219
1222
|
if (s) return s;
|
|
1220
1223
|
}
|
|
1221
|
-
return
|
|
1224
|
+
return V;
|
|
1222
1225
|
}
|
|
1223
|
-
function
|
|
1224
|
-
|
|
1225
|
-
return t;
|
|
1226
|
-
if (typeof t == "object" && t !== null) {
|
|
1227
|
-
const s = t;
|
|
1228
|
-
return new y(s.message || e, {
|
|
1229
|
-
code: s.code,
|
|
1230
|
-
status: s.status,
|
|
1231
|
-
cause: t
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
return typeof t == "string" ? new y(t) : new y(e, { cause: t });
|
|
1226
|
+
function x(t, e = "Authentication failed.") {
|
|
1227
|
+
return Se(t, e);
|
|
1235
1228
|
}
|
|
1236
|
-
async function
|
|
1229
|
+
async function B(t) {
|
|
1237
1230
|
var s, i;
|
|
1238
1231
|
const e = await t.getSession();
|
|
1239
1232
|
if (e.error)
|
|
1240
|
-
throw new
|
|
1233
|
+
throw new v(
|
|
1241
1234
|
e.error.message || "Failed to load the current session.",
|
|
1242
1235
|
{
|
|
1243
1236
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1253,7 +1246,13 @@ async function k(t) {
|
|
|
1253
1246
|
session: null
|
|
1254
1247
|
};
|
|
1255
1248
|
}
|
|
1256
|
-
const
|
|
1249
|
+
const nt = "data-edgespark-auth", r = "edgespark-auth", W = "es_auth_completion", k = "es_auth_email", G = "oauth", U = "verify-sign-in", S = "verify-sign-up", be = 200, Y = 2, rt = {
|
|
1250
|
+
"&": "&",
|
|
1251
|
+
"<": "<",
|
|
1252
|
+
">": ">",
|
|
1253
|
+
'"': """,
|
|
1254
|
+
"'": "'"
|
|
1255
|
+
}, K = {
|
|
1257
1256
|
google: "Google",
|
|
1258
1257
|
apple: "Apple",
|
|
1259
1258
|
microsoft: "Microsoft",
|
|
@@ -1261,7 +1260,7 @@ const st = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion"
|
|
|
1261
1260
|
gitlab: "GitLab",
|
|
1262
1261
|
discord: "Discord"
|
|
1263
1262
|
};
|
|
1264
|
-
function
|
|
1263
|
+
function P(t) {
|
|
1265
1264
|
return "redirectTo" in t;
|
|
1266
1265
|
}
|
|
1267
1266
|
function J(t) {
|
|
@@ -1270,18 +1269,18 @@ function J(t) {
|
|
|
1270
1269
|
function Z(t) {
|
|
1271
1270
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1272
1271
|
}
|
|
1273
|
-
function
|
|
1272
|
+
function ot(t) {
|
|
1274
1273
|
return /^\d{6}$/.test(t.trim());
|
|
1275
1274
|
}
|
|
1276
|
-
function
|
|
1275
|
+
function at(t) {
|
|
1277
1276
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1278
1277
|
}
|
|
1279
|
-
function
|
|
1278
|
+
function lt(t) {
|
|
1280
1279
|
return !!(t.error || t.errorDescription);
|
|
1281
1280
|
}
|
|
1282
|
-
class
|
|
1281
|
+
class dt {
|
|
1283
1282
|
constructor(e, s, i, n, a) {
|
|
1284
|
-
|
|
1283
|
+
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
|
|
1285
1284
|
view: "loading",
|
|
1286
1285
|
busy: !0,
|
|
1287
1286
|
busyLabel: void 0,
|
|
@@ -1293,9 +1292,7 @@ class ot {
|
|
|
1293
1292
|
confirmPassword: "",
|
|
1294
1293
|
code: "",
|
|
1295
1294
|
newPassword: ""
|
|
1296
|
-
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null,
|
|
1297
|
-
throw new m("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1298
|
-
this.labels = et(tt(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(st, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1295
|
+
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, this.labels = st(it(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(nt, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1299
1296
|
}
|
|
1300
1297
|
destroy() {
|
|
1301
1298
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
@@ -1310,7 +1307,7 @@ class ot {
|
|
|
1310
1307
|
if (this.destroyed)
|
|
1311
1308
|
return;
|
|
1312
1309
|
if (i.status === "rejected") {
|
|
1313
|
-
if (e.marker && !
|
|
1310
|
+
if (e.marker && !lt(e) && P(this.options)) {
|
|
1314
1311
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1315
1312
|
return;
|
|
1316
1313
|
}
|
|
@@ -1318,17 +1315,17 @@ class ot {
|
|
|
1318
1315
|
const a = i.value;
|
|
1319
1316
|
if (a.user && a.session) {
|
|
1320
1317
|
switch (e.marker) {
|
|
1321
|
-
case
|
|
1322
|
-
case
|
|
1318
|
+
case G:
|
|
1319
|
+
case U:
|
|
1323
1320
|
await this.completeAuth("sign-in", a);
|
|
1324
1321
|
return;
|
|
1325
|
-
case
|
|
1322
|
+
case S:
|
|
1326
1323
|
await this.completeAuth("sign-up", a);
|
|
1327
1324
|
return;
|
|
1328
1325
|
default:
|
|
1329
1326
|
break;
|
|
1330
1327
|
}
|
|
1331
|
-
this.handleExistingSessionOnMount(
|
|
1328
|
+
this.handleExistingSessionOnMount();
|
|
1332
1329
|
return;
|
|
1333
1330
|
}
|
|
1334
1331
|
}
|
|
@@ -1345,21 +1342,24 @@ class ot {
|
|
|
1345
1342
|
}
|
|
1346
1343
|
}
|
|
1347
1344
|
redirectAfterManagedReturnLookupFailure() {
|
|
1348
|
-
|
|
1345
|
+
P(this.options) && this.navigateToRedirect();
|
|
1346
|
+
}
|
|
1347
|
+
navigateToRedirect() {
|
|
1348
|
+
P(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(tt(this.options.redirectTo).toString()));
|
|
1349
1349
|
}
|
|
1350
1350
|
async readMountSession(e) {
|
|
1351
1351
|
if (!e.marker)
|
|
1352
|
-
return
|
|
1352
|
+
return B(this.auth);
|
|
1353
1353
|
let s = null;
|
|
1354
1354
|
for (let i = 0; i <= Y; i++) {
|
|
1355
1355
|
try {
|
|
1356
|
-
const n = await
|
|
1356
|
+
const n = await B(this.auth);
|
|
1357
1357
|
if (n.user && n.session)
|
|
1358
1358
|
return n;
|
|
1359
1359
|
} catch (n) {
|
|
1360
1360
|
s = n;
|
|
1361
1361
|
}
|
|
1362
|
-
i < Y && await new Promise((n) => setTimeout(n,
|
|
1362
|
+
i < Y && await new Promise((n) => setTimeout(n, be));
|
|
1363
1363
|
}
|
|
1364
1364
|
if (s)
|
|
1365
1365
|
throw s;
|
|
@@ -1598,7 +1598,7 @@ class ot {
|
|
|
1598
1598
|
});
|
|
1599
1599
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1600
1600
|
n.addEventListener("input", () => {
|
|
1601
|
-
|
|
1601
|
+
at(n.name) && (this.state[n.name] = n.value);
|
|
1602
1602
|
});
|
|
1603
1603
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1604
1604
|
n.addEventListener("click", () => {
|
|
@@ -1623,7 +1623,7 @@ class ot {
|
|
|
1623
1623
|
const e = await this.auth.signIn.email({
|
|
1624
1624
|
email: this.state.email.trim(),
|
|
1625
1625
|
password: this.state.password,
|
|
1626
|
-
callbackURL: this.getManagedReturnURL(
|
|
1626
|
+
callbackURL: this.getManagedReturnURL(U, this.state.email.trim())
|
|
1627
1627
|
});
|
|
1628
1628
|
if (e.error)
|
|
1629
1629
|
throw e.error;
|
|
@@ -1660,7 +1660,7 @@ class ot {
|
|
|
1660
1660
|
name: this.state.name.trim(),
|
|
1661
1661
|
email: this.state.email.trim(),
|
|
1662
1662
|
password: this.state.password,
|
|
1663
|
-
callbackURL: this.getManagedReturnURL(
|
|
1663
|
+
callbackURL: this.getManagedReturnURL(S, this.state.email.trim())
|
|
1664
1664
|
});
|
|
1665
1665
|
if (i.error)
|
|
1666
1666
|
throw i.error;
|
|
@@ -1682,14 +1682,14 @@ class ot {
|
|
|
1682
1682
|
throw s.error;
|
|
1683
1683
|
const i = this.extractRedirectURL(s.data);
|
|
1684
1684
|
if (!i)
|
|
1685
|
-
throw new
|
|
1685
|
+
throw new f(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1686
1686
|
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${K[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1687
1687
|
});
|
|
1688
1688
|
}
|
|
1689
1689
|
async handleForgotPassword() {
|
|
1690
1690
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1691
1691
|
this.handleError(
|
|
1692
|
-
new
|
|
1692
|
+
new f("Password reset via email OTP is not enabled for this project.")
|
|
1693
1693
|
);
|
|
1694
1694
|
return;
|
|
1695
1695
|
}
|
|
@@ -1713,11 +1713,11 @@ class ot {
|
|
|
1713
1713
|
var e, s;
|
|
1714
1714
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1715
1715
|
this.handleError(
|
|
1716
|
-
new
|
|
1716
|
+
new f("Password reset via email OTP is not enabled for this project.")
|
|
1717
1717
|
);
|
|
1718
1718
|
return;
|
|
1719
1719
|
}
|
|
1720
|
-
if (!
|
|
1720
|
+
if (!ot(this.state.code)) {
|
|
1721
1721
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1722
1722
|
return;
|
|
1723
1723
|
}
|
|
@@ -1754,7 +1754,7 @@ class ot {
|
|
|
1754
1754
|
const s = await this.auth.sendVerificationEmail({
|
|
1755
1755
|
email: this.state.email.trim(),
|
|
1756
1756
|
callbackURL: this.getManagedReturnURL(
|
|
1757
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1757
|
+
this.verificationCompletionAction === "sign-up" ? S : U,
|
|
1758
1758
|
this.state.email.trim()
|
|
1759
1759
|
)
|
|
1760
1760
|
});
|
|
@@ -1772,12 +1772,12 @@ class ot {
|
|
|
1772
1772
|
if (!i.user || !i.session) {
|
|
1773
1773
|
if (this.destroyed)
|
|
1774
1774
|
return;
|
|
1775
|
-
if (i.lookupError &&
|
|
1776
|
-
this.
|
|
1775
|
+
if (i.lookupError && P(this.options)) {
|
|
1776
|
+
this.navigateToRedirect();
|
|
1777
1777
|
return;
|
|
1778
1778
|
}
|
|
1779
1779
|
if (e === "sign-in")
|
|
1780
|
-
throw i.lookupError ?? new
|
|
1780
|
+
throw i.lookupError ?? new ye(
|
|
1781
1781
|
"Managed sign-in completed without an authenticated session."
|
|
1782
1782
|
);
|
|
1783
1783
|
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();
|
|
@@ -1789,8 +1789,8 @@ class ot {
|
|
|
1789
1789
|
session: i.session
|
|
1790
1790
|
};
|
|
1791
1791
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1792
|
-
if (
|
|
1793
|
-
this.
|
|
1792
|
+
if (P(this.options)) {
|
|
1793
|
+
this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
|
|
1794
1794
|
return;
|
|
1795
1795
|
}
|
|
1796
1796
|
if (J(this.options)) {
|
|
@@ -1804,9 +1804,9 @@ class ot {
|
|
|
1804
1804
|
return e;
|
|
1805
1805
|
let s = e.lookupError;
|
|
1806
1806
|
for (let i = 0; i < Y; i++) {
|
|
1807
|
-
await new Promise((n) => setTimeout(n,
|
|
1807
|
+
await new Promise((n) => setTimeout(n, be));
|
|
1808
1808
|
try {
|
|
1809
|
-
const n = await
|
|
1809
|
+
const n = await B(this.auth);
|
|
1810
1810
|
if (n.user && n.session)
|
|
1811
1811
|
return {
|
|
1812
1812
|
user: n.user,
|
|
@@ -1830,7 +1830,7 @@ class ot {
|
|
|
1830
1830
|
}
|
|
1831
1831
|
async resolveAuthCompletionData(e) {
|
|
1832
1832
|
try {
|
|
1833
|
-
const s = await
|
|
1833
|
+
const s = await B(this.auth), i = this.extractUser(e);
|
|
1834
1834
|
return {
|
|
1835
1835
|
user: s.user ?? i,
|
|
1836
1836
|
session: s.session
|
|
@@ -1857,13 +1857,13 @@ class ot {
|
|
|
1857
1857
|
this.invokeRedirectModeSuccessHook(e), this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.newPassword = "", this.state.code = "", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = "Password updated. Sign in with your new password.", this.render();
|
|
1858
1858
|
}
|
|
1859
1859
|
}
|
|
1860
|
-
handleExistingSessionOnMount(
|
|
1861
|
-
if (
|
|
1862
|
-
this.
|
|
1860
|
+
handleExistingSessionOnMount() {
|
|
1861
|
+
if (P(this.options)) {
|
|
1862
|
+
this.navigateToRedirect();
|
|
1863
1863
|
return;
|
|
1864
1864
|
}
|
|
1865
1865
|
if (J(this.options))
|
|
1866
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
1866
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
|
|
1867
1867
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1868
1868
|
);
|
|
1869
1869
|
}
|
|
@@ -1880,18 +1880,18 @@ class ot {
|
|
|
1880
1880
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1881
1881
|
}
|
|
1882
1882
|
maybeHandleVerificationRequired(e) {
|
|
1883
|
-
return
|
|
1883
|
+
return x(e).code !== "EMAIL_NOT_VERIFIED" ? !1 : (this.verificationCompletionAction = "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = `Verify your email to finish signing in as ${this.state.email.trim()}.`, this.render(), this.sendVerificationEmail(!0), !0);
|
|
1884
1884
|
}
|
|
1885
1885
|
handleVerificationEmailSent(e, s) {
|
|
1886
1886
|
this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
1887
1887
|
}
|
|
1888
1888
|
invokeRedirectModeSuccessHook(e) {
|
|
1889
1889
|
var s, i;
|
|
1890
|
-
if (!(!
|
|
1890
|
+
if (!(!P(this.options) || !this.options.onSuccess))
|
|
1891
1891
|
try {
|
|
1892
1892
|
this.options.onSuccess(e);
|
|
1893
1893
|
} catch (n) {
|
|
1894
|
-
const a =
|
|
1894
|
+
const a = x(n, "Post-auth callback failed.");
|
|
1895
1895
|
try {
|
|
1896
1896
|
(i = (s = this.options).onError) == null || i.call(s, a);
|
|
1897
1897
|
} catch {
|
|
@@ -1900,7 +1900,7 @@ class ot {
|
|
|
1900
1900
|
}
|
|
1901
1901
|
handleError(e, s) {
|
|
1902
1902
|
var n, a;
|
|
1903
|
-
const i =
|
|
1903
|
+
const i = x(e, s);
|
|
1904
1904
|
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (n = this.options).onError) == null || a.call(n, i);
|
|
1905
1905
|
}
|
|
1906
1906
|
failValidation(e) {
|
|
@@ -1910,15 +1910,15 @@ class ot {
|
|
|
1910
1910
|
if (!e)
|
|
1911
1911
|
return window.location.href;
|
|
1912
1912
|
const i = new URL(window.location.href);
|
|
1913
|
-
return i.searchParams.set(
|
|
1913
|
+
return i.searchParams.set(W, e), s ? i.searchParams.set(k, s) : i.searchParams.delete(k), i.toString();
|
|
1914
1914
|
}
|
|
1915
1915
|
consumeManagedReturnContext() {
|
|
1916
|
-
const e = new URL(window.location.href), s = e.searchParams.get(
|
|
1917
|
-
return (
|
|
1918
|
-
marker:
|
|
1919
|
-
email:
|
|
1920
|
-
error:
|
|
1921
|
-
errorDescription:
|
|
1916
|
+
const e = new URL(window.location.href), s = e.searchParams.get(W), i = s === G || s === U || s === S ? s : null, n = e.searchParams.get(k), a = i ? e.searchParams.get("error") : null, h = i ? e.searchParams.get("error_description") : null;
|
|
1917
|
+
return (i || n) && (e.searchParams.delete(W), e.searchParams.delete(k), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1918
|
+
marker: i,
|
|
1919
|
+
email: n,
|
|
1920
|
+
error: a,
|
|
1921
|
+
errorDescription: h
|
|
1922
1922
|
};
|
|
1923
1923
|
}
|
|
1924
1924
|
startCountdown(e = 60) {
|
|
@@ -1982,10 +1982,10 @@ class ot {
|
|
|
1982
1982
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
1983
1983
|
}
|
|
1984
1984
|
handleSessionlessManagedReturn(e) {
|
|
1985
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
1985
|
+
return e.email && (this.state.email = e.email), e.marker === S && !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 === U || e.marker === S ? (this.verificationCompletionAction = e.marker === S ? "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 v(
|
|
1986
1986
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
1987
1987
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
1988
|
-
)) : this.render(), !0) : e.marker ===
|
|
1988
|
+
)) : this.render(), !0) : e.marker === G && (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 v(
|
|
1989
1989
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
1990
1990
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
1991
1991
|
)), !0) : !1;
|
|
@@ -2001,106 +2001,106 @@ class ot {
|
|
|
2001
2001
|
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2002
2002
|
}
|
|
2003
2003
|
escape(e) {
|
|
2004
|
-
return e.replace(
|
|
2004
|
+
return e.replace(/[&<>"']/g, (s) => rt[s]);
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
|
-
function
|
|
2007
|
+
function ct(t) {
|
|
2008
2008
|
return "data" in t && t.data ? t.data : t;
|
|
2009
2009
|
}
|
|
2010
|
-
const
|
|
2010
|
+
const ut = [
|
|
2011
2011
|
{ id: "google", key: "providerGoogle" },
|
|
2012
2012
|
{ id: "apple", key: "providerApple" },
|
|
2013
2013
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2014
2014
|
{ id: "github", key: "providerGithub" },
|
|
2015
2015
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2016
2016
|
{ id: "discord", key: "providerDiscord" }
|
|
2017
|
-
], ve = 2,
|
|
2018
|
-
async function
|
|
2017
|
+
], ve = 2, ht = 500;
|
|
2018
|
+
async function mt() {
|
|
2019
2019
|
const t = `${window.location.origin}${Ee}/config`;
|
|
2020
2020
|
let e;
|
|
2021
2021
|
for (let s = 0; s <= ve; s++)
|
|
2022
2022
|
try {
|
|
2023
2023
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2024
2024
|
if (!i.ok)
|
|
2025
|
-
throw new
|
|
2025
|
+
throw new f(`Failed to load auth config: HTTP ${i.status}`);
|
|
2026
2026
|
const n = await i.json();
|
|
2027
|
-
return
|
|
2027
|
+
return wt(ct(n));
|
|
2028
2028
|
} catch (i) {
|
|
2029
|
-
e = i, s < ve && await new Promise((n) => setTimeout(n,
|
|
2029
|
+
e = i, s < ve && await new Promise((n) => setTimeout(n, ht));
|
|
2030
2030
|
}
|
|
2031
2031
|
throw e;
|
|
2032
2032
|
}
|
|
2033
|
-
let
|
|
2034
|
-
async function
|
|
2035
|
-
return
|
|
2036
|
-
throw
|
|
2037
|
-
})),
|
|
2033
|
+
let M = null;
|
|
2034
|
+
async function ft() {
|
|
2035
|
+
return M || (M = mt().catch((t) => {
|
|
2036
|
+
throw M = null, t;
|
|
2037
|
+
})), M;
|
|
2038
2038
|
}
|
|
2039
|
-
function
|
|
2040
|
-
var s, i, n, a, h, w,
|
|
2041
|
-
const e =
|
|
2042
|
-
const
|
|
2043
|
-
return typeof
|
|
2044
|
-
}).map(({ id:
|
|
2039
|
+
function wt(t) {
|
|
2040
|
+
var s, i, n, a, h, w, E;
|
|
2041
|
+
const e = ut.filter(({ key: L }) => {
|
|
2042
|
+
const _ = t[L];
|
|
2043
|
+
return typeof _ == "object" && _ !== null && "enabled" in _ && !!_.enabled;
|
|
2044
|
+
}).map(({ id: L }) => L);
|
|
2045
2045
|
return {
|
|
2046
2046
|
disableSignUp: !!t.disableSignUp,
|
|
2047
2047
|
emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
|
|
2048
2048
|
minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
|
|
2049
2049
|
requireEmailVerification: !!((h = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && h.requireEmailVerification),
|
|
2050
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2050
|
+
passwordResetEmailOtpEnabled: !!((E = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && E.requirePasswordResetEmailVerification),
|
|
2051
2051
|
oauthProviders: e
|
|
2052
2052
|
};
|
|
2053
2053
|
}
|
|
2054
|
-
const
|
|
2055
|
-
function
|
|
2054
|
+
const O = /* @__PURE__ */ new WeakMap();
|
|
2055
|
+
function gt(t) {
|
|
2056
2056
|
if (!t)
|
|
2057
|
-
throw new
|
|
2057
|
+
throw new f(
|
|
2058
2058
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2059
2059
|
);
|
|
2060
2060
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2061
2061
|
if (!e && !s)
|
|
2062
|
-
throw new
|
|
2062
|
+
throw new f(
|
|
2063
2063
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2064
2064
|
);
|
|
2065
2065
|
if ("redirectTo" in t) {
|
|
2066
2066
|
const i = t.redirectTo;
|
|
2067
2067
|
if (!(typeof i == "string" || i instanceof URL))
|
|
2068
|
-
throw new
|
|
2068
|
+
throw new f(
|
|
2069
2069
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2070
2070
|
);
|
|
2071
2071
|
}
|
|
2072
2072
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2073
|
-
throw new
|
|
2073
|
+
throw new f(
|
|
2074
2074
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2075
2075
|
);
|
|
2076
2076
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2077
|
-
throw new
|
|
2077
|
+
throw new f(
|
|
2078
2078
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2079
2079
|
);
|
|
2080
2080
|
}
|
|
2081
|
-
function
|
|
2081
|
+
function pt(t) {
|
|
2082
2082
|
if (!(t instanceof HTMLElement))
|
|
2083
|
-
throw new
|
|
2083
|
+
throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2084
2084
|
}
|
|
2085
|
-
function
|
|
2085
|
+
function bt(t, e) {
|
|
2086
2086
|
return {
|
|
2087
2087
|
mount(s, i) {
|
|
2088
2088
|
var w;
|
|
2089
|
-
|
|
2090
|
-
const n = new
|
|
2089
|
+
gt(i), pt(s), (w = O.get(s)) == null || w.destroy();
|
|
2090
|
+
const n = new dt(s, t, i, ft, e), a = n.destroy.bind(n), h = {
|
|
2091
2091
|
destroy() {
|
|
2092
|
-
a(),
|
|
2092
|
+
a(), O.get(s) === h && O.delete(s);
|
|
2093
2093
|
}
|
|
2094
2094
|
};
|
|
2095
|
-
return
|
|
2095
|
+
return O.set(s, h), h;
|
|
2096
2096
|
}
|
|
2097
2097
|
};
|
|
2098
2098
|
}
|
|
2099
|
-
function
|
|
2099
|
+
function yt() {
|
|
2100
2100
|
Pe();
|
|
2101
|
-
const t =
|
|
2101
|
+
const t = Xe(), e = et(), s = Me(), i = bt(e, {
|
|
2102
2102
|
syncPublicSession: async () => {
|
|
2103
|
-
await
|
|
2103
|
+
await Qe(t);
|
|
2104
2104
|
}
|
|
2105
2105
|
});
|
|
2106
2106
|
return {
|
|
@@ -2110,16 +2110,16 @@ function pt() {
|
|
|
2110
2110
|
};
|
|
2111
2111
|
}
|
|
2112
2112
|
export {
|
|
2113
|
-
|
|
2114
|
-
|
|
2113
|
+
v as EdgeSparkAuthError,
|
|
2114
|
+
f as EdgeSparkConfigError,
|
|
2115
2115
|
ee as EdgeSparkError,
|
|
2116
|
-
|
|
2116
|
+
ye as EdgeSparkRuntimeError,
|
|
2117
2117
|
we as ar,
|
|
2118
|
-
|
|
2118
|
+
yt as createEdgeSpark,
|
|
2119
2119
|
he as de,
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2120
|
+
it as detectLocale,
|
|
2121
|
+
V as enUS,
|
|
2122
|
+
H as es,
|
|
2123
2123
|
ue as fr,
|
|
2124
2124
|
ge as hi,
|
|
2125
2125
|
me as it,
|