@edgespark/web 0.0.1-beta.3 → 0.0.1-beta.5
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/types.d.ts +9 -5
- package/dist/auth-ui/ManagedAuthUI.d.ts +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.es.js +352 -269
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,73 +1,95 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
2
|
-
class
|
|
1
|
+
import { createAuthClient as be } from "better-auth/client";
|
|
2
|
+
class j extends Error {
|
|
3
3
|
constructor(e, s) {
|
|
4
4
|
super(s), this.name = "EdgeSparkError", this.code = e;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class u extends j {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class de extends j {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class w extends j {
|
|
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
|
|
22
|
+
function ce() {
|
|
23
23
|
if (typeof window > "u" || typeof document > "u")
|
|
24
|
-
throw new
|
|
24
|
+
throw new de(
|
|
25
25
|
"@edgespark/web is browser-only. Create the client from a real browser runtime."
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function W() {
|
|
29
|
+
return ce(), window.location.origin;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function ge(t) {
|
|
32
32
|
return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (t.origin !==
|
|
36
|
-
throw new
|
|
37
|
-
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${
|
|
34
|
+
function ve(t) {
|
|
35
|
+
if (t.origin !== W())
|
|
36
|
+
throw new u(
|
|
37
|
+
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${W()}.`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function ye() {
|
|
41
41
|
return {
|
|
42
42
|
async fetch(t, e) {
|
|
43
|
-
const s =
|
|
44
|
-
return
|
|
43
|
+
const s = ge(t);
|
|
44
|
+
return ve(s), fetch(t, {
|
|
45
45
|
...e,
|
|
46
46
|
credentials: "include"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
function
|
|
53
|
-
return
|
|
54
|
-
baseURL:
|
|
55
|
-
basePath:
|
|
51
|
+
const ue = "/api/_es/auth", Pe = "edgespark-auth-session", K = "__edgespark_auth_sync__", he = Symbol("edgespark.notifyAuthTabs");
|
|
52
|
+
function me(t) {
|
|
53
|
+
return be({
|
|
54
|
+
baseURL: W(),
|
|
55
|
+
basePath: ue,
|
|
56
56
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
57
57
|
fetchOptions: {
|
|
58
58
|
credentials: "include"
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function _(t) {
|
|
63
63
|
var e, s;
|
|
64
64
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
66
|
+
function Le(t) {
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
source: t,
|
|
69
|
+
timestamp: Date.now()
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function Ee(t) {
|
|
73
|
+
if (typeof t != "string")
|
|
74
|
+
return null;
|
|
75
|
+
try {
|
|
76
|
+
const e = JSON.parse(t);
|
|
77
|
+
return e && typeof e == "object" ? e : null;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function Se(t) {
|
|
83
|
+
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
84
|
+
return !1;
|
|
85
|
+
const e = "data" in t ? t.data : t;
|
|
86
|
+
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;
|
|
87
|
+
}
|
|
88
|
+
function M(t) {
|
|
89
|
+
if (t instanceof w)
|
|
68
90
|
return t;
|
|
69
91
|
const e = t;
|
|
70
|
-
return new
|
|
92
|
+
return new w(
|
|
71
93
|
(e == null ? void 0 : e.message) || "Failed to load the current session.",
|
|
72
94
|
{
|
|
73
95
|
code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -76,123 +98,163 @@ function A(t) {
|
|
|
76
98
|
}
|
|
77
99
|
);
|
|
78
100
|
}
|
|
79
|
-
async function
|
|
80
|
-
var e;
|
|
81
|
-
await ((e =
|
|
101
|
+
async function _e(t) {
|
|
102
|
+
var e, s;
|
|
103
|
+
await ((e = _(t)) == null ? void 0 : e.get().refetch()), (s = t[he]) == null || s.call(t);
|
|
82
104
|
}
|
|
83
|
-
function
|
|
84
|
-
const t =
|
|
85
|
-
let
|
|
86
|
-
const
|
|
87
|
-
var
|
|
88
|
-
return
|
|
89
|
-
var
|
|
90
|
-
let
|
|
105
|
+
function Te() {
|
|
106
|
+
const t = me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`, s = typeof BroadcastChannel < "u" ? new BroadcastChannel(Pe) : null, i = 2, r = 500;
|
|
107
|
+
let a = null, c = !1;
|
|
108
|
+
const p = () => {
|
|
109
|
+
var l;
|
|
110
|
+
return c ? Promise.resolve(((l = _(t)) == null ? void 0 : l.get().data) ?? null) : (a || (a = (async () => {
|
|
111
|
+
var m, f, g, v;
|
|
112
|
+
let o = !1, d = null;
|
|
91
113
|
try {
|
|
92
|
-
for (let
|
|
93
|
-
const
|
|
94
|
-
if ((
|
|
95
|
-
return
|
|
96
|
-
if (
|
|
97
|
-
return
|
|
98
|
-
if (
|
|
99
|
-
await new Promise((
|
|
114
|
+
for (let L = 0; L <= i; L++) {
|
|
115
|
+
const E = await t.getSession(), y = ((m = _(t)) == null ? void 0 : m.get().data) ?? null;
|
|
116
|
+
if ((f = E.data) != null && f.session && ((g = E.data) != null && g.user))
|
|
117
|
+
return c = !0, E.data;
|
|
118
|
+
if (y != null && y.session && (y != null && y.user))
|
|
119
|
+
return c = !0, y;
|
|
120
|
+
if (E.error ? d = E.error : o = !0, !E.error && L < i) {
|
|
121
|
+
await new Promise((k) => setTimeout(k, r));
|
|
100
122
|
continue;
|
|
101
123
|
}
|
|
102
|
-
|
|
124
|
+
L < i && await new Promise((k) => setTimeout(k, r));
|
|
103
125
|
}
|
|
104
|
-
if (!
|
|
105
|
-
throw
|
|
126
|
+
if (!o)
|
|
127
|
+
throw a = null, new w("Failed to load the current session.", {
|
|
106
128
|
code: "SESSION_LOOKUP_FAILED",
|
|
107
|
-
cause:
|
|
129
|
+
cause: d
|
|
108
130
|
});
|
|
109
|
-
const h = ((
|
|
110
|
-
return
|
|
131
|
+
const h = ((v = _(t)) == null ? void 0 : v.get().data) ?? null;
|
|
132
|
+
return c = !0, h;
|
|
111
133
|
} catch (h) {
|
|
112
|
-
throw
|
|
134
|
+
throw a = null, M(h);
|
|
113
135
|
}
|
|
114
|
-
})()),
|
|
136
|
+
})()), a);
|
|
115
137
|
};
|
|
116
|
-
|
|
138
|
+
p().catch(() => {
|
|
117
139
|
});
|
|
118
|
-
const
|
|
119
|
-
var
|
|
140
|
+
const T = async () => {
|
|
141
|
+
var l, o;
|
|
120
142
|
try {
|
|
121
|
-
const
|
|
122
|
-
if ((
|
|
123
|
-
return
|
|
124
|
-
throw
|
|
143
|
+
const d = await t.getSession();
|
|
144
|
+
if ((l = d.data) != null && l.session && ((o = d.data) != null && o.user))
|
|
145
|
+
return d.data;
|
|
146
|
+
throw d.error ? M(d.error) : new w("No authenticated session is available.", {
|
|
125
147
|
code: "UNAUTHENTICATED"
|
|
126
148
|
});
|
|
127
|
-
} catch (
|
|
128
|
-
throw
|
|
149
|
+
} catch (d) {
|
|
150
|
+
throw M(d);
|
|
151
|
+
}
|
|
152
|
+
}, P = async () => {
|
|
153
|
+
var l;
|
|
154
|
+
try {
|
|
155
|
+
await ((l = _(t)) == null ? void 0 : l.get().refetch());
|
|
156
|
+
} catch {
|
|
157
|
+
}
|
|
158
|
+
}, b = () => {
|
|
159
|
+
const l = Le(e);
|
|
160
|
+
try {
|
|
161
|
+
s == null || s.postMessage(l);
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
window.localStorage.setItem(K, l);
|
|
166
|
+
} catch {
|
|
129
167
|
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
168
|
+
}, G = (l) => {
|
|
169
|
+
const o = Ee(l);
|
|
170
|
+
!o || o.source === e || P();
|
|
171
|
+
};
|
|
172
|
+
s == null || s.addEventListener("message", (l) => {
|
|
173
|
+
G(l.data);
|
|
174
|
+
}), typeof window < "u" && window.addEventListener("storage", (l) => {
|
|
175
|
+
l.key !== K || l.newValue === null || G(l.newValue);
|
|
176
|
+
});
|
|
177
|
+
const Y = async () => {
|
|
178
|
+
await P(), b();
|
|
179
|
+
}, we = (l) => {
|
|
180
|
+
let o = !1, d = !1, m;
|
|
181
|
+
const f = (h) => {
|
|
182
|
+
h !== m && (m = h, l(h));
|
|
134
183
|
};
|
|
135
|
-
|
|
136
|
-
|
|
184
|
+
p().then((h) => {
|
|
185
|
+
o || (d = !0, f(h));
|
|
137
186
|
}).catch(() => {
|
|
138
|
-
|
|
187
|
+
o || (d = !0);
|
|
139
188
|
});
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
189
|
+
const g = _(t);
|
|
190
|
+
if (!g)
|
|
142
191
|
return () => {
|
|
143
|
-
|
|
192
|
+
o = !0;
|
|
144
193
|
};
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
194
|
+
const v = g.subscribe((h) => {
|
|
195
|
+
if (o || !d || h.error && !h.data)
|
|
147
196
|
return;
|
|
148
|
-
const
|
|
149
|
-
L
|
|
197
|
+
const L = h.data ?? null;
|
|
198
|
+
f(L);
|
|
150
199
|
});
|
|
151
200
|
return () => {
|
|
152
|
-
|
|
201
|
+
o = !0, v();
|
|
153
202
|
};
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
203
|
+
}, fe = async (...l) => {
|
|
204
|
+
const o = await t.signOut(...l);
|
|
205
|
+
return o && typeof o == "object" && "error" in o && o.error || await Y(), o;
|
|
206
|
+
}, pe = (l) => new Proxy(l, {
|
|
207
|
+
get(o, d, m) {
|
|
208
|
+
const f = Reflect.get(o, d, m);
|
|
209
|
+
return typeof f != "function" ? f : async (...g) => {
|
|
210
|
+
const v = await f.apply(o, g);
|
|
211
|
+
return Se(v) && await Y(), v;
|
|
212
|
+
};
|
|
162
213
|
}
|
|
163
|
-
|
|
164
|
-
};
|
|
214
|
+
});
|
|
165
215
|
return new Proxy(t, {
|
|
166
|
-
get(
|
|
167
|
-
|
|
216
|
+
get(l, o, d) {
|
|
217
|
+
if (o === "requireSession")
|
|
218
|
+
return T;
|
|
219
|
+
if (o === "onSessionChange")
|
|
220
|
+
return we;
|
|
221
|
+
if (o === "signOut")
|
|
222
|
+
return fe;
|
|
223
|
+
if (o === he)
|
|
224
|
+
return b;
|
|
225
|
+
if (o === "signIn" || o === "signUp") {
|
|
226
|
+
const m = Reflect.get(l, o, d);
|
|
227
|
+
return m && typeof m == "object" ? pe(m) : m;
|
|
228
|
+
}
|
|
229
|
+
return Reflect.get(l, o, d);
|
|
168
230
|
}
|
|
169
231
|
});
|
|
170
232
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
233
|
+
function Ce() {
|
|
234
|
+
return me({ disableDefaultRedirectPlugin: !0 });
|
|
173
235
|
}
|
|
174
|
-
function
|
|
236
|
+
function O(t) {
|
|
175
237
|
const e = (() => {
|
|
176
238
|
if (t instanceof URL)
|
|
177
239
|
return t;
|
|
178
240
|
const s = t.trim();
|
|
179
241
|
if (!s)
|
|
180
|
-
throw new
|
|
242
|
+
throw new u("redirectTo must not be an empty string.");
|
|
181
243
|
try {
|
|
182
244
|
return new URL(s, window.location.href);
|
|
183
245
|
} catch {
|
|
184
|
-
throw new
|
|
246
|
+
throw new u(
|
|
185
247
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
186
248
|
);
|
|
187
249
|
}
|
|
188
250
|
})();
|
|
189
251
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
190
|
-
throw new
|
|
252
|
+
throw new u(
|
|
191
253
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
192
254
|
);
|
|
193
255
|
return e;
|
|
194
256
|
}
|
|
195
|
-
function
|
|
257
|
+
function Ie(t, e) {
|
|
196
258
|
return e ? {
|
|
197
259
|
common: { ...t.common, ...e.common },
|
|
198
260
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -204,7 +266,7 @@ function me(t, e) {
|
|
|
204
266
|
errors: { ...t.errors, ...e.errors }
|
|
205
267
|
} : t;
|
|
206
268
|
}
|
|
207
|
-
const
|
|
269
|
+
const B = {
|
|
208
270
|
common: {
|
|
209
271
|
loading: "Loading sign-in…",
|
|
210
272
|
redirecting: "Redirecting…",
|
|
@@ -267,7 +329,7 @@ const $ = {
|
|
|
267
329
|
invalidCode: "Enter the 6-digit verification code.",
|
|
268
330
|
generic: "Something went wrong. Please try again."
|
|
269
331
|
}
|
|
270
|
-
},
|
|
332
|
+
}, V = {
|
|
271
333
|
common: {
|
|
272
334
|
loading: "加载中…",
|
|
273
335
|
redirecting: "跳转中…",
|
|
@@ -330,7 +392,7 @@ const $ = {
|
|
|
330
392
|
invalidCode: "请输入 6 位验证码",
|
|
331
393
|
generic: "出现错误,请稍后重试"
|
|
332
394
|
}
|
|
333
|
-
},
|
|
395
|
+
}, J = {
|
|
334
396
|
common: {
|
|
335
397
|
loading: "サインインを読み込み中…",
|
|
336
398
|
redirecting: "リダイレクト中…",
|
|
@@ -393,7 +455,7 @@ const $ = {
|
|
|
393
455
|
invalidCode: "6桁の認証コードを入力してください",
|
|
394
456
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
395
457
|
}
|
|
396
|
-
},
|
|
458
|
+
}, Z = {
|
|
397
459
|
common: {
|
|
398
460
|
loading: "로그인 로딩 중…",
|
|
399
461
|
redirecting: "리디렉션 중…",
|
|
@@ -456,7 +518,7 @@ const $ = {
|
|
|
456
518
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
457
519
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
458
520
|
}
|
|
459
|
-
},
|
|
521
|
+
}, F = {
|
|
460
522
|
common: {
|
|
461
523
|
loading: "Cargando inicio de sesión…",
|
|
462
524
|
redirecting: "Redirigiendo…",
|
|
@@ -519,7 +581,7 @@ const $ = {
|
|
|
519
581
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
520
582
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
521
583
|
}
|
|
522
|
-
},
|
|
584
|
+
}, Q = {
|
|
523
585
|
common: {
|
|
524
586
|
loading: "Carregando login…",
|
|
525
587
|
redirecting: "Redirecionando…",
|
|
@@ -582,7 +644,7 @@ const $ = {
|
|
|
582
644
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
583
645
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
584
646
|
}
|
|
585
|
-
},
|
|
647
|
+
}, X = {
|
|
586
648
|
common: {
|
|
587
649
|
loading: "Chargement de la connexion…",
|
|
588
650
|
redirecting: "Redirection…",
|
|
@@ -645,7 +707,7 @@ const $ = {
|
|
|
645
707
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
646
708
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
647
709
|
}
|
|
648
|
-
},
|
|
710
|
+
}, ee = {
|
|
649
711
|
common: {
|
|
650
712
|
loading: "Anmeldung wird geladen…",
|
|
651
713
|
redirecting: "Weiterleitung…",
|
|
@@ -708,7 +770,7 @@ const $ = {
|
|
|
708
770
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
709
771
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
710
772
|
}
|
|
711
|
-
},
|
|
773
|
+
}, te = {
|
|
712
774
|
common: {
|
|
713
775
|
loading: "Caricamento accesso…",
|
|
714
776
|
redirecting: "Reindirizzamento…",
|
|
@@ -771,7 +833,7 @@ const $ = {
|
|
|
771
833
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
772
834
|
generic: "Qualcosa è andato storto. Riprova."
|
|
773
835
|
}
|
|
774
|
-
},
|
|
836
|
+
}, se = {
|
|
775
837
|
common: {
|
|
776
838
|
loading: "Загрузка входа…",
|
|
777
839
|
redirecting: "Перенаправление…",
|
|
@@ -834,7 +896,7 @@ const $ = {
|
|
|
834
896
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
835
897
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
836
898
|
}
|
|
837
|
-
},
|
|
899
|
+
}, ie = {
|
|
838
900
|
common: {
|
|
839
901
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
840
902
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -897,7 +959,7 @@ const $ = {
|
|
|
897
959
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
898
960
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
899
961
|
}
|
|
900
|
-
},
|
|
962
|
+
}, ne = {
|
|
901
963
|
common: {
|
|
902
964
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
903
965
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -960,62 +1022,62 @@ const $ = {
|
|
|
960
1022
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
961
1023
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
962
1024
|
}
|
|
963
|
-
},
|
|
964
|
-
en:
|
|
965
|
-
"en-US":
|
|
966
|
-
zh:
|
|
967
|
-
"zh-CN":
|
|
968
|
-
"zh-TW":
|
|
969
|
-
ja:
|
|
970
|
-
"ja-JP":
|
|
971
|
-
ko:
|
|
972
|
-
"ko-KR":
|
|
973
|
-
es:
|
|
974
|
-
"es-ES":
|
|
975
|
-
"es-MX":
|
|
976
|
-
pt:
|
|
977
|
-
"pt-BR":
|
|
978
|
-
fr:
|
|
979
|
-
"fr-FR":
|
|
980
|
-
de:
|
|
981
|
-
"de-DE":
|
|
982
|
-
it:
|
|
983
|
-
"it-IT":
|
|
984
|
-
ru:
|
|
985
|
-
"ru-RU":
|
|
986
|
-
ar:
|
|
987
|
-
"ar-SA":
|
|
988
|
-
hi:
|
|
989
|
-
"hi-IN":
|
|
1025
|
+
}, re = {
|
|
1026
|
+
en: B,
|
|
1027
|
+
"en-US": B,
|
|
1028
|
+
zh: V,
|
|
1029
|
+
"zh-CN": V,
|
|
1030
|
+
"zh-TW": V,
|
|
1031
|
+
ja: J,
|
|
1032
|
+
"ja-JP": J,
|
|
1033
|
+
ko: Z,
|
|
1034
|
+
"ko-KR": Z,
|
|
1035
|
+
es: F,
|
|
1036
|
+
"es-ES": F,
|
|
1037
|
+
"es-MX": F,
|
|
1038
|
+
pt: Q,
|
|
1039
|
+
"pt-BR": Q,
|
|
1040
|
+
fr: X,
|
|
1041
|
+
"fr-FR": X,
|
|
1042
|
+
de: ee,
|
|
1043
|
+
"de-DE": ee,
|
|
1044
|
+
it: te,
|
|
1045
|
+
"it-IT": te,
|
|
1046
|
+
ru: se,
|
|
1047
|
+
"ru-RU": se,
|
|
1048
|
+
ar: ie,
|
|
1049
|
+
"ar-SA": ie,
|
|
1050
|
+
hi: ne,
|
|
1051
|
+
"hi-IN": ne
|
|
990
1052
|
};
|
|
991
|
-
function
|
|
1053
|
+
function Re() {
|
|
992
1054
|
if (typeof navigator > "u")
|
|
993
|
-
return
|
|
1055
|
+
return B;
|
|
994
1056
|
const t = navigator.languages ?? [navigator.language];
|
|
995
1057
|
for (const e of t) {
|
|
996
|
-
const s =
|
|
1058
|
+
const s = re[e] ?? re[e.split("-")[0]];
|
|
997
1059
|
if (s) return s;
|
|
998
1060
|
}
|
|
999
|
-
return
|
|
1061
|
+
return B;
|
|
1000
1062
|
}
|
|
1001
|
-
function
|
|
1002
|
-
if (t instanceof
|
|
1063
|
+
function N(t, e = "Authentication failed.") {
|
|
1064
|
+
if (t instanceof w)
|
|
1003
1065
|
return t;
|
|
1004
1066
|
if (typeof t == "object" && t !== null) {
|
|
1005
1067
|
const s = t;
|
|
1006
|
-
return new
|
|
1068
|
+
return new w(s.message || e, {
|
|
1007
1069
|
code: s.code,
|
|
1008
1070
|
status: s.status,
|
|
1009
1071
|
cause: t
|
|
1010
1072
|
});
|
|
1011
1073
|
}
|
|
1012
|
-
return typeof t == "string" ? new
|
|
1074
|
+
return typeof t == "string" ? new w(t) : new w(e, { cause: t });
|
|
1013
1075
|
}
|
|
1014
|
-
async function
|
|
1076
|
+
async function C(t) {
|
|
1015
1077
|
var s, i;
|
|
1016
1078
|
const e = await t.getSession();
|
|
1017
1079
|
if (e.error)
|
|
1018
|
-
throw new
|
|
1080
|
+
throw new w(
|
|
1019
1081
|
e.error.message || "Failed to load the current session.",
|
|
1020
1082
|
{
|
|
1021
1083
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1031,7 +1093,7 @@ async function V(t) {
|
|
|
1031
1093
|
session: null
|
|
1032
1094
|
};
|
|
1033
1095
|
}
|
|
1034
|
-
const
|
|
1096
|
+
const $e = "data-edgespark-auth", n = "edgespark-auth", z = "es_auth_completion", I = "es_auth_email", oe = "oauth", R = "verify-sign-in", S = "verify-sign-up", ae = 200, q = 2, D = {
|
|
1035
1097
|
google: "Google",
|
|
1036
1098
|
apple: "Apple",
|
|
1037
1099
|
microsoft: "Microsoft",
|
|
@@ -1039,24 +1101,24 @@ const be = "data-edgespark-auth", n = "edgespark-auth", F = "es_auth_completion"
|
|
|
1039
1101
|
gitlab: "GitLab",
|
|
1040
1102
|
discord: "Discord"
|
|
1041
1103
|
};
|
|
1042
|
-
function
|
|
1104
|
+
function $(t) {
|
|
1043
1105
|
return "redirectTo" in t;
|
|
1044
1106
|
}
|
|
1045
|
-
function
|
|
1107
|
+
function H(t) {
|
|
1046
1108
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1047
1109
|
}
|
|
1048
|
-
function
|
|
1110
|
+
function x(t) {
|
|
1049
1111
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1050
1112
|
}
|
|
1051
|
-
function
|
|
1113
|
+
function Ue(t) {
|
|
1052
1114
|
return /^\d{6}$/.test(t.trim());
|
|
1053
1115
|
}
|
|
1054
|
-
function
|
|
1116
|
+
function Ae(t) {
|
|
1055
1117
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1056
1118
|
}
|
|
1057
|
-
class
|
|
1058
|
-
constructor(e, s, i, r,
|
|
1059
|
-
if (this.container = e, this.auth = s, this.options = i, this.loadConfig = r, this.runtimeOptions =
|
|
1119
|
+
class Be {
|
|
1120
|
+
constructor(e, s, i, r, a) {
|
|
1121
|
+
if (this.container = e, this.auth = s, this.options = i, this.loadConfig = r, this.runtimeOptions = a, this.state = {
|
|
1060
1122
|
view: "loading",
|
|
1061
1123
|
busy: !0,
|
|
1062
1124
|
busyLabel: void 0,
|
|
@@ -1069,8 +1131,8 @@ class Pe {
|
|
|
1069
1131
|
code: "",
|
|
1070
1132
|
newPassword: ""
|
|
1071
1133
|
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, !(e instanceof HTMLElement))
|
|
1072
|
-
throw new
|
|
1073
|
-
this.labels =
|
|
1134
|
+
throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1135
|
+
this.labels = Ie(Re(), i.labels), this.root = document.createElement("div"), this.root.setAttribute($e, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1074
1136
|
}
|
|
1075
1137
|
destroy() {
|
|
1076
1138
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
@@ -1079,17 +1141,17 @@ class Pe {
|
|
|
1079
1141
|
try {
|
|
1080
1142
|
const e = this.consumeManagedReturnContext(), [s, i] = await Promise.all([
|
|
1081
1143
|
this.loadConfig(),
|
|
1082
|
-
|
|
1144
|
+
this.readMountSession(e)
|
|
1083
1145
|
]);
|
|
1084
1146
|
if (this.destroyed)
|
|
1085
1147
|
return;
|
|
1086
1148
|
if (this.config = s, i.user && i.session) {
|
|
1087
1149
|
switch (e.marker) {
|
|
1088
|
-
case
|
|
1089
|
-
case
|
|
1150
|
+
case oe:
|
|
1151
|
+
case R:
|
|
1090
1152
|
await this.completeAuth("sign-in", i);
|
|
1091
1153
|
return;
|
|
1092
|
-
case
|
|
1154
|
+
case S:
|
|
1093
1155
|
await this.completeAuth("sign-up", i);
|
|
1094
1156
|
return;
|
|
1095
1157
|
default:
|
|
@@ -1105,6 +1167,27 @@ class Pe {
|
|
|
1105
1167
|
this.handleError(e, "Failed to load the authentication UI.");
|
|
1106
1168
|
}
|
|
1107
1169
|
}
|
|
1170
|
+
async readMountSession(e) {
|
|
1171
|
+
if (!e.marker)
|
|
1172
|
+
return C(this.auth);
|
|
1173
|
+
let s = null;
|
|
1174
|
+
for (let i = 0; i <= q; i++) {
|
|
1175
|
+
try {
|
|
1176
|
+
const r = await C(this.auth);
|
|
1177
|
+
if (r.user && r.session)
|
|
1178
|
+
return r;
|
|
1179
|
+
} catch (r) {
|
|
1180
|
+
s = r;
|
|
1181
|
+
}
|
|
1182
|
+
i < q && await new Promise((r) => setTimeout(r, ae));
|
|
1183
|
+
}
|
|
1184
|
+
if (s)
|
|
1185
|
+
throw s;
|
|
1186
|
+
return {
|
|
1187
|
+
user: null,
|
|
1188
|
+
session: null
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1108
1191
|
render() {
|
|
1109
1192
|
if (this.destroyed)
|
|
1110
1193
|
return;
|
|
@@ -1305,13 +1388,13 @@ class Pe {
|
|
|
1305
1388
|
<div class="${n}__stack">
|
|
1306
1389
|
${e.map((i) => `
|
|
1307
1390
|
<button class="${n}__button ${n}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
|
|
1308
|
-
${this.escape(`${this.labels.oauth.continueWith} ${
|
|
1391
|
+
${this.escape(`${this.labels.oauth.continueWith} ${D[i]}`)}
|
|
1309
1392
|
</button>
|
|
1310
1393
|
`).join("")}
|
|
1311
1394
|
</div>
|
|
1312
1395
|
`;
|
|
1313
1396
|
}
|
|
1314
|
-
renderInput(e, s, i, r,
|
|
1397
|
+
renderInput(e, s, i, r, a) {
|
|
1315
1398
|
return `
|
|
1316
1399
|
<label class="${n}__field">
|
|
1317
1400
|
<span class="${n}__label">${this.escape(s)}</span>
|
|
@@ -1320,7 +1403,7 @@ class Pe {
|
|
|
1320
1403
|
name="${this.escape(e)}"
|
|
1321
1404
|
type="${this.escape(i)}"
|
|
1322
1405
|
value="${this.escape(r)}"
|
|
1323
|
-
autocomplete="${this.escape(
|
|
1406
|
+
autocomplete="${this.escape(a)}"
|
|
1324
1407
|
${this.state.busy ? "disabled" : ""}
|
|
1325
1408
|
/>
|
|
1326
1409
|
</label>
|
|
@@ -1328,19 +1411,19 @@ class Pe {
|
|
|
1328
1411
|
}
|
|
1329
1412
|
bindDOM() {
|
|
1330
1413
|
this.root.querySelectorAll("form[data-view]").forEach((r) => {
|
|
1331
|
-
r.addEventListener("submit", (
|
|
1332
|
-
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1414
|
+
r.addEventListener("submit", (a) => {
|
|
1415
|
+
a.preventDefault();
|
|
1416
|
+
const c = r.dataset.view;
|
|
1417
|
+
c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
|
|
1335
1418
|
});
|
|
1336
1419
|
}), this.root.querySelectorAll("input[name]").forEach((r) => {
|
|
1337
1420
|
r.addEventListener("input", () => {
|
|
1338
|
-
|
|
1421
|
+
Ae(r.name) && (this.state[r.name] = r.value);
|
|
1339
1422
|
});
|
|
1340
1423
|
}), this.root.querySelectorAll("[data-action]").forEach((r) => {
|
|
1341
1424
|
r.addEventListener("click", () => {
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1425
|
+
const a = r.dataset.action;
|
|
1426
|
+
a === "switch-sign-up" && this.switchView("sign-up"), a === "switch-sign-in" && this.switchView("sign-in"), a === "forgot-password" && this.switchView("forgot-password"), a === "resend-verification" && this.resendVerificationEmail(), a === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), a === "resend-reset-code" && this.resendResetCode(), a === "oauth" && this.handleOAuthSignIn(r.dataset.provider);
|
|
1344
1427
|
});
|
|
1345
1428
|
});
|
|
1346
1429
|
}
|
|
@@ -1348,7 +1431,7 @@ class Pe {
|
|
|
1348
1431
|
this.clearCountdown(), e !== "verify-email" && (this.verificationCompletionAction = null), this.state.view = e, this.state.error = null, this.state.notice = null, this.state.busy = !1, this.state.busyLabel = void 0, this.terminalActionInProgress = !1, this.render();
|
|
1349
1432
|
}
|
|
1350
1433
|
async handleSignIn() {
|
|
1351
|
-
if (!
|
|
1434
|
+
if (!x(this.state.email)) {
|
|
1352
1435
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1353
1436
|
return;
|
|
1354
1437
|
}
|
|
@@ -1360,7 +1443,7 @@ class Pe {
|
|
|
1360
1443
|
const e = await this.auth.signIn.email({
|
|
1361
1444
|
email: this.state.email.trim(),
|
|
1362
1445
|
password: this.state.password,
|
|
1363
|
-
callbackURL: this.getManagedReturnURL(
|
|
1446
|
+
callbackURL: this.getManagedReturnURL(R, this.state.email.trim())
|
|
1364
1447
|
});
|
|
1365
1448
|
if (e.error)
|
|
1366
1449
|
throw e.error;
|
|
@@ -1373,7 +1456,7 @@ class Pe {
|
|
|
1373
1456
|
this.failValidation(this.labels.errors.requiredField);
|
|
1374
1457
|
return;
|
|
1375
1458
|
}
|
|
1376
|
-
if (!
|
|
1459
|
+
if (!x(this.state.email)) {
|
|
1377
1460
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1378
1461
|
return;
|
|
1379
1462
|
}
|
|
@@ -1397,7 +1480,7 @@ class Pe {
|
|
|
1397
1480
|
name: this.state.name.trim(),
|
|
1398
1481
|
email: this.state.email.trim(),
|
|
1399
1482
|
password: this.state.password,
|
|
1400
|
-
callbackURL: this.getManagedReturnURL(
|
|
1483
|
+
callbackURL: this.getManagedReturnURL(S, this.state.email.trim())
|
|
1401
1484
|
});
|
|
1402
1485
|
if (i.error)
|
|
1403
1486
|
throw i.error;
|
|
@@ -1409,7 +1492,7 @@ class Pe {
|
|
|
1409
1492
|
});
|
|
1410
1493
|
}
|
|
1411
1494
|
async handleOAuthSignIn(e) {
|
|
1412
|
-
await this.runAction(`Redirecting to ${
|
|
1495
|
+
await this.runAction(`Redirecting to ${D[e]}…`, async () => {
|
|
1413
1496
|
const s = await this.auth.signIn.social({
|
|
1414
1497
|
provider: e,
|
|
1415
1498
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
@@ -1419,18 +1502,18 @@ class Pe {
|
|
|
1419
1502
|
throw s.error;
|
|
1420
1503
|
const i = this.extractRedirectURL(s.data);
|
|
1421
1504
|
if (!i)
|
|
1422
|
-
throw new
|
|
1423
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
1505
|
+
throw new u(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1506
|
+
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${D[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1424
1507
|
});
|
|
1425
1508
|
}
|
|
1426
1509
|
async handleForgotPassword() {
|
|
1427
1510
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1428
1511
|
this.handleError(
|
|
1429
|
-
new
|
|
1512
|
+
new u("Password reset via email OTP is not enabled for this project.")
|
|
1430
1513
|
);
|
|
1431
1514
|
return;
|
|
1432
1515
|
}
|
|
1433
|
-
if (!
|
|
1516
|
+
if (!x(this.state.email)) {
|
|
1434
1517
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1435
1518
|
return;
|
|
1436
1519
|
}
|
|
@@ -1450,11 +1533,11 @@ class Pe {
|
|
|
1450
1533
|
var e, s;
|
|
1451
1534
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1452
1535
|
this.handleError(
|
|
1453
|
-
new
|
|
1536
|
+
new u("Password reset via email OTP is not enabled for this project.")
|
|
1454
1537
|
);
|
|
1455
1538
|
return;
|
|
1456
1539
|
}
|
|
1457
|
-
if (!
|
|
1540
|
+
if (!Ue(this.state.code)) {
|
|
1458
1541
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1459
1542
|
return;
|
|
1460
1543
|
}
|
|
@@ -1491,7 +1574,7 @@ class Pe {
|
|
|
1491
1574
|
const s = await this.auth.sendVerificationEmail({
|
|
1492
1575
|
email: this.state.email.trim(),
|
|
1493
1576
|
callbackURL: this.getManagedReturnURL(
|
|
1494
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1577
|
+
this.verificationCompletionAction === "sign-up" ? S : R,
|
|
1495
1578
|
this.state.email.trim()
|
|
1496
1579
|
)
|
|
1497
1580
|
});
|
|
@@ -1505,12 +1588,12 @@ class Pe {
|
|
|
1505
1588
|
s ?? await this.resolveAuthCompletionData()
|
|
1506
1589
|
);
|
|
1507
1590
|
if (!i.user || !i.session) {
|
|
1508
|
-
if (i.lookupError &&
|
|
1509
|
-
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(
|
|
1591
|
+
if (i.lookupError && $(this.options)) {
|
|
1592
|
+
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(O(this.options.redirectTo).toString());
|
|
1510
1593
|
return;
|
|
1511
1594
|
}
|
|
1512
1595
|
if (e === "sign-in")
|
|
1513
|
-
throw i.lookupError ?? new
|
|
1596
|
+
throw i.lookupError ?? new de(
|
|
1514
1597
|
"Managed sign-in completed without an authenticated session."
|
|
1515
1598
|
);
|
|
1516
1599
|
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();
|
|
@@ -1521,11 +1604,11 @@ class Pe {
|
|
|
1521
1604
|
user: i.user,
|
|
1522
1605
|
session: i.session
|
|
1523
1606
|
};
|
|
1524
|
-
if (await this.syncPublicSessionBestEffort(),
|
|
1525
|
-
this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(r), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(
|
|
1607
|
+
if (await this.syncPublicSessionBestEffort(), $(this.options)) {
|
|
1608
|
+
this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(r), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(O(this.options.redirectTo).toString());
|
|
1526
1609
|
return;
|
|
1527
1610
|
}
|
|
1528
|
-
if (
|
|
1611
|
+
if (H(this.options)) {
|
|
1529
1612
|
this.destroy(), this.options.onSuccess(r);
|
|
1530
1613
|
return;
|
|
1531
1614
|
}
|
|
@@ -1534,10 +1617,10 @@ class Pe {
|
|
|
1534
1617
|
if (e.session)
|
|
1535
1618
|
return e;
|
|
1536
1619
|
let s = e.lookupError;
|
|
1537
|
-
for (let i = 0; i <
|
|
1538
|
-
await new Promise((r) => setTimeout(r,
|
|
1620
|
+
for (let i = 0; i < q; i++) {
|
|
1621
|
+
await new Promise((r) => setTimeout(r, ae));
|
|
1539
1622
|
try {
|
|
1540
|
-
const r = await
|
|
1623
|
+
const r = await C(this.auth);
|
|
1541
1624
|
if (r.user && r.session)
|
|
1542
1625
|
return {
|
|
1543
1626
|
user: r.user,
|
|
@@ -1561,7 +1644,7 @@ class Pe {
|
|
|
1561
1644
|
}
|
|
1562
1645
|
async resolveAuthCompletionData(e) {
|
|
1563
1646
|
try {
|
|
1564
|
-
const s = await
|
|
1647
|
+
const s = await C(this.auth), i = this.extractUser(e);
|
|
1565
1648
|
return {
|
|
1566
1649
|
user: s.user ?? i,
|
|
1567
1650
|
session: s.session
|
|
@@ -1580,19 +1663,19 @@ class Pe {
|
|
|
1580
1663
|
user: null,
|
|
1581
1664
|
session: null
|
|
1582
1665
|
};
|
|
1583
|
-
if (
|
|
1666
|
+
if (H(this.options)) {
|
|
1584
1667
|
this.destroy(), this.options.onSuccess(e);
|
|
1585
1668
|
return;
|
|
1586
1669
|
}
|
|
1587
1670
|
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();
|
|
1588
1671
|
}
|
|
1589
1672
|
handleExistingSessionOnMount(e) {
|
|
1590
|
-
if (
|
|
1591
|
-
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(
|
|
1673
|
+
if ($(this.options)) {
|
|
1674
|
+
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(O(this.options.redirectTo).toString());
|
|
1592
1675
|
return;
|
|
1593
1676
|
}
|
|
1594
|
-
if (
|
|
1595
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
1677
|
+
if (H(this.options))
|
|
1678
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new u(
|
|
1596
1679
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1597
1680
|
);
|
|
1598
1681
|
}
|
|
@@ -1609,28 +1692,28 @@ class Pe {
|
|
|
1609
1692
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1610
1693
|
}
|
|
1611
1694
|
maybeHandleVerificationRequired(e) {
|
|
1612
|
-
return
|
|
1695
|
+
return N(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);
|
|
1613
1696
|
}
|
|
1614
1697
|
handleVerificationEmailSent(e, s) {
|
|
1615
1698
|
this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
1616
1699
|
}
|
|
1617
1700
|
invokeRedirectModeSuccessHook(e) {
|
|
1618
1701
|
var s, i;
|
|
1619
|
-
if (!(
|
|
1702
|
+
if (!(!$(this.options) || !this.options.onSuccess))
|
|
1620
1703
|
try {
|
|
1621
1704
|
this.options.onSuccess(e);
|
|
1622
1705
|
} catch (r) {
|
|
1623
|
-
const
|
|
1706
|
+
const a = N(r, "Post-auth callback failed.");
|
|
1624
1707
|
try {
|
|
1625
|
-
(i = (s = this.options).onError) == null || i.call(s,
|
|
1708
|
+
(i = (s = this.options).onError) == null || i.call(s, a);
|
|
1626
1709
|
} catch {
|
|
1627
1710
|
}
|
|
1628
1711
|
}
|
|
1629
1712
|
}
|
|
1630
1713
|
handleError(e, s) {
|
|
1631
|
-
var r,
|
|
1632
|
-
const i =
|
|
1633
|
-
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (
|
|
1714
|
+
var r, a;
|
|
1715
|
+
const i = N(e, s);
|
|
1716
|
+
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (r = this.options).onError) == null || a.call(r, i);
|
|
1634
1717
|
}
|
|
1635
1718
|
failValidation(e) {
|
|
1636
1719
|
this.state.error = e, this.state.notice = null, this.render();
|
|
@@ -1639,15 +1722,15 @@ class Pe {
|
|
|
1639
1722
|
if (!e)
|
|
1640
1723
|
return window.location.href;
|
|
1641
1724
|
const i = new URL(window.location.href);
|
|
1642
|
-
return i.searchParams.set(
|
|
1725
|
+
return i.searchParams.set(z, e), s ? i.searchParams.set(I, s) : i.searchParams.delete(I), i.toString();
|
|
1643
1726
|
}
|
|
1644
1727
|
consumeManagedReturnContext() {
|
|
1645
|
-
const e = new URL(window.location.href), s = e.searchParams.get(
|
|
1646
|
-
return (s || i) && (e.searchParams.delete(
|
|
1728
|
+
const e = new URL(window.location.href), s = e.searchParams.get(z), i = e.searchParams.get(I), r = s ? e.searchParams.get("error") : null, a = s ? e.searchParams.get("error_description") : null;
|
|
1729
|
+
return (s || i) && (e.searchParams.delete(z), e.searchParams.delete(I), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1647
1730
|
marker: s,
|
|
1648
1731
|
email: i,
|
|
1649
1732
|
error: r,
|
|
1650
|
-
errorDescription:
|
|
1733
|
+
errorDescription: a
|
|
1651
1734
|
};
|
|
1652
1735
|
}
|
|
1653
1736
|
startCountdown(e = 60) {
|
|
@@ -1711,10 +1794,10 @@ class Pe {
|
|
|
1711
1794
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
1712
1795
|
}
|
|
1713
1796
|
handleSessionlessManagedReturn(e) {
|
|
1714
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
1797
|
+
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 === R || 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 w(
|
|
1715
1798
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
1716
1799
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
1717
|
-
)) : this.render(), !0) : e.marker ===
|
|
1800
|
+
)) : this.render(), !0) : e.marker === oe && (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 w(
|
|
1718
1801
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
1719
1802
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
1720
1803
|
)), !0) : !1;
|
|
@@ -1733,103 +1816,103 @@ class Pe {
|
|
|
1733
1816
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1734
1817
|
}
|
|
1735
1818
|
}
|
|
1736
|
-
function
|
|
1819
|
+
function ke(t) {
|
|
1737
1820
|
return "data" in t && t.data ? t.data : t;
|
|
1738
1821
|
}
|
|
1739
|
-
const
|
|
1822
|
+
const Me = [
|
|
1740
1823
|
{ id: "google", key: "providerGoogle" },
|
|
1741
1824
|
{ id: "apple", key: "providerApple" },
|
|
1742
1825
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
1743
1826
|
{ id: "github", key: "providerGithub" },
|
|
1744
1827
|
{ id: "gitlab", key: "providerGitlab" },
|
|
1745
1828
|
{ id: "discord", key: "providerDiscord" }
|
|
1746
|
-
],
|
|
1747
|
-
async function
|
|
1748
|
-
const t = `${window.location.origin}${
|
|
1829
|
+
], le = 2, Oe = 500;
|
|
1830
|
+
async function Ve() {
|
|
1831
|
+
const t = `${window.location.origin}${ue}/config`;
|
|
1749
1832
|
let e;
|
|
1750
|
-
for (let s = 0; s <=
|
|
1833
|
+
for (let s = 0; s <= le; s++)
|
|
1751
1834
|
try {
|
|
1752
1835
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
1753
1836
|
if (!i.ok)
|
|
1754
|
-
throw new
|
|
1837
|
+
throw new u(`Failed to load auth config: HTTP ${i.status}`);
|
|
1755
1838
|
const r = await i.json();
|
|
1756
|
-
return
|
|
1839
|
+
return Ne(ke(r));
|
|
1757
1840
|
} catch (i) {
|
|
1758
|
-
e = i, s <
|
|
1841
|
+
e = i, s < le && await new Promise((r) => setTimeout(r, Oe));
|
|
1759
1842
|
}
|
|
1760
1843
|
throw e;
|
|
1761
1844
|
}
|
|
1762
|
-
let
|
|
1763
|
-
async function
|
|
1764
|
-
return
|
|
1765
|
-
throw
|
|
1766
|
-
})),
|
|
1845
|
+
let U = null;
|
|
1846
|
+
async function Fe() {
|
|
1847
|
+
return U || (U = Ve().catch((t) => {
|
|
1848
|
+
throw U = null, t;
|
|
1849
|
+
})), U;
|
|
1767
1850
|
}
|
|
1768
|
-
function
|
|
1769
|
-
var s, i, r,
|
|
1770
|
-
const e =
|
|
1771
|
-
const
|
|
1772
|
-
return typeof
|
|
1773
|
-
}).map(({ id:
|
|
1851
|
+
function Ne(t) {
|
|
1852
|
+
var s, i, r, a, c, p, T;
|
|
1853
|
+
const e = Me.filter(({ key: P }) => {
|
|
1854
|
+
const b = t[P];
|
|
1855
|
+
return typeof b == "object" && b !== null && "enabled" in b && !!b.enabled;
|
|
1856
|
+
}).map(({ id: P }) => P);
|
|
1774
1857
|
return {
|
|
1775
1858
|
disableSignUp: !!t.disableSignUp,
|
|
1776
1859
|
emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
|
|
1777
1860
|
minPasswordLength: ((r = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : r.minPasswordLength) ?? 8,
|
|
1778
|
-
requireEmailVerification: !!((
|
|
1779
|
-
passwordResetEmailOtpEnabled: !!((
|
|
1861
|
+
requireEmailVerification: !!((c = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && c.requireEmailVerification),
|
|
1862
|
+
passwordResetEmailOtpEnabled: !!((T = (p = t.providerEmailPassword) == null ? void 0 : p.config) != null && T.requirePasswordResetEmailVerification),
|
|
1780
1863
|
oauthProviders: e
|
|
1781
1864
|
};
|
|
1782
1865
|
}
|
|
1783
|
-
const
|
|
1784
|
-
function
|
|
1866
|
+
const A = /* @__PURE__ */ new WeakMap();
|
|
1867
|
+
function ze(t) {
|
|
1785
1868
|
if (!t)
|
|
1786
|
-
throw new
|
|
1869
|
+
throw new u(
|
|
1787
1870
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1788
1871
|
);
|
|
1789
1872
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
1790
1873
|
if (!e && !s)
|
|
1791
|
-
throw new
|
|
1874
|
+
throw new u(
|
|
1792
1875
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1793
1876
|
);
|
|
1794
1877
|
if ("redirectTo" in t) {
|
|
1795
1878
|
const i = t.redirectTo;
|
|
1796
1879
|
if (!(typeof i == "string" || i instanceof URL))
|
|
1797
|
-
throw new
|
|
1880
|
+
throw new u(
|
|
1798
1881
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
1799
1882
|
);
|
|
1800
1883
|
}
|
|
1801
1884
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
1802
|
-
throw new
|
|
1885
|
+
throw new u(
|
|
1803
1886
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
1804
1887
|
);
|
|
1805
1888
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
1806
|
-
throw new
|
|
1889
|
+
throw new u(
|
|
1807
1890
|
"authUI.mount(container, options) expected onError to be a function."
|
|
1808
1891
|
);
|
|
1809
1892
|
}
|
|
1810
|
-
function
|
|
1893
|
+
function qe(t) {
|
|
1811
1894
|
if (!(t instanceof HTMLElement))
|
|
1812
|
-
throw new
|
|
1895
|
+
throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1813
1896
|
}
|
|
1814
|
-
function
|
|
1897
|
+
function De(t, e) {
|
|
1815
1898
|
return {
|
|
1816
1899
|
mount(s, i) {
|
|
1817
|
-
var
|
|
1818
|
-
|
|
1819
|
-
const r = new
|
|
1900
|
+
var p;
|
|
1901
|
+
ze(i), qe(s), (p = A.get(s)) == null || p.destroy();
|
|
1902
|
+
const r = new Be(s, t, i, Fe, e), a = r.destroy.bind(r), c = {
|
|
1820
1903
|
destroy() {
|
|
1821
|
-
|
|
1904
|
+
a(), A.get(s) === c && A.delete(s);
|
|
1822
1905
|
}
|
|
1823
1906
|
};
|
|
1824
|
-
return
|
|
1907
|
+
return A.set(s, c), c;
|
|
1825
1908
|
}
|
|
1826
1909
|
};
|
|
1827
1910
|
}
|
|
1828
|
-
function
|
|
1829
|
-
|
|
1830
|
-
const t =
|
|
1911
|
+
function xe() {
|
|
1912
|
+
ce();
|
|
1913
|
+
const t = Te(), e = Ce(), s = ye(), i = De(e, {
|
|
1831
1914
|
syncPublicSession: async () => {
|
|
1832
|
-
await
|
|
1915
|
+
await _e(t);
|
|
1833
1916
|
}
|
|
1834
1917
|
});
|
|
1835
1918
|
return {
|
|
@@ -1839,22 +1922,22 @@ function Ue() {
|
|
|
1839
1922
|
};
|
|
1840
1923
|
}
|
|
1841
1924
|
export {
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1925
|
+
w as EdgeSparkAuthError,
|
|
1926
|
+
u as EdgeSparkConfigError,
|
|
1927
|
+
j as EdgeSparkError,
|
|
1928
|
+
de as EdgeSparkRuntimeError,
|
|
1929
|
+
ie as ar,
|
|
1930
|
+
xe as createEdgeSpark,
|
|
1931
|
+
ee as de,
|
|
1932
|
+
Re as detectLocale,
|
|
1933
|
+
B as enUS,
|
|
1934
|
+
F as es,
|
|
1935
|
+
X as fr,
|
|
1936
|
+
ne as hi,
|
|
1937
|
+
te as it,
|
|
1938
|
+
J as ja,
|
|
1939
|
+
Z as ko,
|
|
1940
|
+
Q as ptBR,
|
|
1941
|
+
se as ru,
|
|
1942
|
+
V as zhCN
|
|
1860
1943
|
};
|