@edgespark/web 0.0.1-beta.3 → 0.0.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-ui/ManagedAuthUI.d.ts +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.es.js +304 -283
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
2
|
-
class
|
|
3
|
-
constructor(e,
|
|
4
|
-
super(
|
|
1
|
+
import { createAuthClient as le } from "better-auth/client";
|
|
2
|
+
class x extends Error {
|
|
3
|
+
constructor(e, t) {
|
|
4
|
+
super(t), this.name = "EdgeSparkError", this.code = e;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class d extends
|
|
7
|
+
class d extends x {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class ne extends x {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class m extends
|
|
18
|
-
constructor(e,
|
|
19
|
-
super((
|
|
17
|
+
class m extends x {
|
|
18
|
+
constructor(e, t) {
|
|
19
|
+
super((t == null ? void 0 : t.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = t == null ? void 0 : t.cause, this.status = t == null ? void 0 : t.status;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function re() {
|
|
23
23
|
if (typeof window > "u" || typeof document > "u")
|
|
24
|
-
throw new
|
|
24
|
+
throw new ne(
|
|
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 H() {
|
|
29
|
+
return re(), window.location.origin;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
31
|
+
function de(s) {
|
|
32
|
+
return s instanceof URL ? s : typeof s == "string" ? new URL(s, window.location.href) : new URL(s.url, window.location.href);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (
|
|
34
|
+
function ce(s) {
|
|
35
|
+
if (s.origin !== H())
|
|
36
36
|
throw new d(
|
|
37
|
-
`Cross-origin requests are not supported by this SDK. Received ${
|
|
37
|
+
`Cross-origin requests are not supported by this SDK. Received ${s.origin}, expected ${H()}.`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function ue() {
|
|
41
41
|
return {
|
|
42
|
-
async fetch(
|
|
43
|
-
const
|
|
44
|
-
return
|
|
42
|
+
async fetch(s, e) {
|
|
43
|
+
const t = de(s);
|
|
44
|
+
return ce(t), fetch(s, {
|
|
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:
|
|
56
|
-
...
|
|
51
|
+
const oe = "/api/_es/auth";
|
|
52
|
+
function ae(s) {
|
|
53
|
+
return le({
|
|
54
|
+
baseURL: H(),
|
|
55
|
+
basePath: oe,
|
|
56
|
+
...s != null && s.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
57
57
|
fetchOptions: {
|
|
58
58
|
credentials: "include"
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
function v(
|
|
63
|
-
var e,
|
|
64
|
-
return (
|
|
62
|
+
function v(s) {
|
|
63
|
+
var e, t;
|
|
64
|
+
return (t = (e = s.$store) == null ? void 0 : e.atoms) == null ? void 0 : t.session;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
if (
|
|
68
|
-
return
|
|
69
|
-
const e =
|
|
66
|
+
function B(s) {
|
|
67
|
+
if (s instanceof m)
|
|
68
|
+
return s;
|
|
69
|
+
const e = s;
|
|
70
70
|
return new m(
|
|
71
71
|
(e == null ? void 0 : e.message) || "Failed to load the current session.",
|
|
72
72
|
{
|
|
73
73
|
code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
|
|
74
|
-
cause:
|
|
74
|
+
cause: s,
|
|
75
75
|
status: e == null ? void 0 : e.status
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
async function
|
|
79
|
+
async function he(s) {
|
|
80
80
|
var e;
|
|
81
|
-
await ((e = v(
|
|
81
|
+
await ((e = v(s)) == null ? void 0 : e.get().refetch());
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
83
|
+
function me() {
|
|
84
|
+
const s = ae(), e = 2, t = 500;
|
|
85
85
|
let i = null, r = !1;
|
|
86
86
|
const o = () => {
|
|
87
87
|
var c;
|
|
88
|
-
return r ? Promise.resolve(((c = v(
|
|
88
|
+
return r ? Promise.resolve(((c = v(s)) == null ? void 0 : c.get().data) ?? null) : (i || (i = (async () => {
|
|
89
89
|
var P, L, y, S;
|
|
90
90
|
let a = !1, l = null;
|
|
91
91
|
try {
|
|
92
92
|
for (let p = 0; p <= e; p++) {
|
|
93
|
-
const f = await
|
|
93
|
+
const f = await s.getSession(), b = ((P = v(s)) == null ? void 0 : P.get().data) ?? null;
|
|
94
94
|
if ((L = f.data) != null && L.session && ((y = f.data) != null && y.user))
|
|
95
95
|
return r = !0, f.data;
|
|
96
96
|
if (b != null && b.session && (b != null && b.user))
|
|
97
97
|
return r = !0, b;
|
|
98
98
|
if (f.error ? l = f.error : a = !0, !f.error && p < e) {
|
|
99
|
-
await new Promise((
|
|
99
|
+
await new Promise((A) => setTimeout(A, t));
|
|
100
100
|
continue;
|
|
101
101
|
}
|
|
102
|
-
p < e && await new Promise((
|
|
102
|
+
p < e && await new Promise((A) => setTimeout(A, t));
|
|
103
103
|
}
|
|
104
104
|
if (!a)
|
|
105
105
|
throw i = null, new m("Failed to load the current session.", {
|
|
106
106
|
code: "SESSION_LOOKUP_FAILED",
|
|
107
107
|
cause: l
|
|
108
108
|
});
|
|
109
|
-
const h = ((S = v(
|
|
109
|
+
const h = ((S = v(s)) == null ? void 0 : S.get().data) ?? null;
|
|
110
110
|
return r = !0, h;
|
|
111
111
|
} catch (h) {
|
|
112
|
-
throw i = null,
|
|
112
|
+
throw i = null, B(h);
|
|
113
113
|
}
|
|
114
114
|
})()), i);
|
|
115
115
|
};
|
|
@@ -118,14 +118,14 @@ function ue() {
|
|
|
118
118
|
const u = async () => {
|
|
119
119
|
var c, a;
|
|
120
120
|
try {
|
|
121
|
-
const l = await
|
|
121
|
+
const l = await s.getSession();
|
|
122
122
|
if ((c = l.data) != null && c.session && ((a = l.data) != null && a.user))
|
|
123
123
|
return l.data;
|
|
124
|
-
throw l.error ?
|
|
124
|
+
throw l.error ? B(l.error) : new m("No authenticated session is available.", {
|
|
125
125
|
code: "UNAUTHENTICATED"
|
|
126
126
|
});
|
|
127
127
|
} catch (l) {
|
|
128
|
-
throw
|
|
128
|
+
throw B(l);
|
|
129
129
|
}
|
|
130
130
|
}, w = (c) => {
|
|
131
131
|
let a = !1, l = !1, P;
|
|
@@ -137,7 +137,7 @@ function ue() {
|
|
|
137
137
|
}).catch(() => {
|
|
138
138
|
a || (l = !0);
|
|
139
139
|
});
|
|
140
|
-
const y = v(
|
|
140
|
+
const y = v(s);
|
|
141
141
|
if (!y)
|
|
142
142
|
return () => {
|
|
143
143
|
a = !0;
|
|
@@ -153,36 +153,36 @@ function ue() {
|
|
|
153
153
|
};
|
|
154
154
|
}, E = async (...c) => {
|
|
155
155
|
var l;
|
|
156
|
-
const a = await
|
|
156
|
+
const a = await s.signOut(...c);
|
|
157
157
|
if (a && typeof a == "object" && "error" in a && a.error)
|
|
158
158
|
return a;
|
|
159
159
|
try {
|
|
160
|
-
await ((l = v(
|
|
160
|
+
await ((l = v(s)) == null ? void 0 : l.get().refetch());
|
|
161
161
|
} catch {
|
|
162
162
|
}
|
|
163
163
|
return a;
|
|
164
164
|
};
|
|
165
|
-
return new Proxy(
|
|
165
|
+
return new Proxy(s, {
|
|
166
166
|
get(c, a, l) {
|
|
167
167
|
return a === "requireSession" ? u : a === "onSessionChange" ? w : a === "signOut" ? E : Reflect.get(c, a, l);
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
171
|
+
function we() {
|
|
172
|
+
return ae({ disableDefaultRedirectPlugin: !0 });
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function k(s) {
|
|
175
175
|
const e = (() => {
|
|
176
|
-
if (
|
|
177
|
-
return
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
176
|
+
if (s instanceof URL)
|
|
177
|
+
return s;
|
|
178
|
+
const t = s.trim();
|
|
179
|
+
if (!t)
|
|
180
180
|
throw new d("redirectTo must not be an empty string.");
|
|
181
181
|
try {
|
|
182
|
-
return new URL(
|
|
182
|
+
return new URL(t, window.location.href);
|
|
183
183
|
} catch {
|
|
184
184
|
throw new d(
|
|
185
|
-
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(
|
|
185
|
+
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(s)}`
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
})();
|
|
@@ -192,19 +192,19 @@ function B(t) {
|
|
|
192
192
|
);
|
|
193
193
|
return e;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function be(s, e) {
|
|
196
196
|
return e ? {
|
|
197
|
-
common: { ...
|
|
198
|
-
signIn: { ...
|
|
199
|
-
signUp: { ...
|
|
200
|
-
verifyEmail: { ...
|
|
201
|
-
forgotPassword: { ...
|
|
202
|
-
resetPassword: { ...
|
|
203
|
-
oauth: { ...
|
|
204
|
-
errors: { ...
|
|
205
|
-
} :
|
|
197
|
+
common: { ...s.common, ...e.common },
|
|
198
|
+
signIn: { ...s.signIn, ...e.signIn },
|
|
199
|
+
signUp: { ...s.signUp, ...e.signUp },
|
|
200
|
+
verifyEmail: { ...s.verifyEmail, ...e.verifyEmail },
|
|
201
|
+
forgotPassword: { ...s.forgotPassword, ...e.forgotPassword },
|
|
202
|
+
resetPassword: { ...s.resetPassword, ...e.resetPassword },
|
|
203
|
+
oauth: { ...s.oauth, ...e.oauth },
|
|
204
|
+
errors: { ...s.errors, ...e.errors }
|
|
205
|
+
} : s;
|
|
206
206
|
}
|
|
207
|
-
const
|
|
207
|
+
const U = {
|
|
208
208
|
common: {
|
|
209
209
|
loading: "Loading sign-in…",
|
|
210
210
|
redirecting: "Redirecting…",
|
|
@@ -267,7 +267,7 @@ const $ = {
|
|
|
267
267
|
invalidCode: "Enter the 6-digit verification code.",
|
|
268
268
|
generic: "Something went wrong. Please try again."
|
|
269
269
|
}
|
|
270
|
-
},
|
|
270
|
+
}, M = {
|
|
271
271
|
common: {
|
|
272
272
|
loading: "加载中…",
|
|
273
273
|
redirecting: "跳转中…",
|
|
@@ -330,7 +330,7 @@ const $ = {
|
|
|
330
330
|
invalidCode: "请输入 6 位验证码",
|
|
331
331
|
generic: "出现错误,请稍后重试"
|
|
332
332
|
}
|
|
333
|
-
},
|
|
333
|
+
}, W = {
|
|
334
334
|
common: {
|
|
335
335
|
loading: "サインインを読み込み中…",
|
|
336
336
|
redirecting: "リダイレクト中…",
|
|
@@ -393,7 +393,7 @@ const $ = {
|
|
|
393
393
|
invalidCode: "6桁の認証コードを入力してください",
|
|
394
394
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
395
395
|
}
|
|
396
|
-
},
|
|
396
|
+
}, j = {
|
|
397
397
|
common: {
|
|
398
398
|
loading: "로그인 로딩 중…",
|
|
399
399
|
redirecting: "리디렉션 중…",
|
|
@@ -456,7 +456,7 @@ const $ = {
|
|
|
456
456
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
457
457
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
458
458
|
}
|
|
459
|
-
},
|
|
459
|
+
}, O = {
|
|
460
460
|
common: {
|
|
461
461
|
loading: "Cargando inicio de sesión…",
|
|
462
462
|
redirecting: "Redirigiendo…",
|
|
@@ -519,7 +519,7 @@ const $ = {
|
|
|
519
519
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
520
520
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
521
521
|
}
|
|
522
|
-
},
|
|
522
|
+
}, G = {
|
|
523
523
|
common: {
|
|
524
524
|
loading: "Carregando login…",
|
|
525
525
|
redirecting: "Redirecionando…",
|
|
@@ -582,7 +582,7 @@ const $ = {
|
|
|
582
582
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
583
583
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
584
584
|
}
|
|
585
|
-
},
|
|
585
|
+
}, Y = {
|
|
586
586
|
common: {
|
|
587
587
|
loading: "Chargement de la connexion…",
|
|
588
588
|
redirecting: "Redirection…",
|
|
@@ -645,7 +645,7 @@ const $ = {
|
|
|
645
645
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
646
646
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
647
647
|
}
|
|
648
|
-
},
|
|
648
|
+
}, K = {
|
|
649
649
|
common: {
|
|
650
650
|
loading: "Anmeldung wird geladen…",
|
|
651
651
|
redirecting: "Weiterleitung…",
|
|
@@ -708,7 +708,7 @@ const $ = {
|
|
|
708
708
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
709
709
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
710
710
|
}
|
|
711
|
-
},
|
|
711
|
+
}, J = {
|
|
712
712
|
common: {
|
|
713
713
|
loading: "Caricamento accesso…",
|
|
714
714
|
redirecting: "Reindirizzamento…",
|
|
@@ -771,7 +771,7 @@ const $ = {
|
|
|
771
771
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
772
772
|
generic: "Qualcosa è andato storto. Riprova."
|
|
773
773
|
}
|
|
774
|
-
},
|
|
774
|
+
}, Z = {
|
|
775
775
|
common: {
|
|
776
776
|
loading: "Загрузка входа…",
|
|
777
777
|
redirecting: "Перенаправление…",
|
|
@@ -834,7 +834,7 @@ const $ = {
|
|
|
834
834
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
835
835
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
836
836
|
}
|
|
837
|
-
},
|
|
837
|
+
}, Q = {
|
|
838
838
|
common: {
|
|
839
839
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
840
840
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -897,7 +897,7 @@ const $ = {
|
|
|
897
897
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
898
898
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
899
899
|
}
|
|
900
|
-
},
|
|
900
|
+
}, X = {
|
|
901
901
|
common: {
|
|
902
902
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
903
903
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -960,60 +960,60 @@ const $ = {
|
|
|
960
960
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
961
961
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
962
962
|
}
|
|
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":
|
|
963
|
+
}, ee = {
|
|
964
|
+
en: U,
|
|
965
|
+
"en-US": U,
|
|
966
|
+
zh: M,
|
|
967
|
+
"zh-CN": M,
|
|
968
|
+
"zh-TW": M,
|
|
969
|
+
ja: W,
|
|
970
|
+
"ja-JP": W,
|
|
971
|
+
ko: j,
|
|
972
|
+
"ko-KR": j,
|
|
973
|
+
es: O,
|
|
974
|
+
"es-ES": O,
|
|
975
|
+
"es-MX": O,
|
|
976
|
+
pt: G,
|
|
977
|
+
"pt-BR": G,
|
|
978
|
+
fr: Y,
|
|
979
|
+
"fr-FR": Y,
|
|
980
|
+
de: K,
|
|
981
|
+
"de-DE": K,
|
|
982
|
+
it: J,
|
|
983
|
+
"it-IT": J,
|
|
984
|
+
ru: Z,
|
|
985
|
+
"ru-RU": Z,
|
|
986
|
+
ar: Q,
|
|
987
|
+
"ar-SA": Q,
|
|
988
|
+
hi: X,
|
|
989
|
+
"hi-IN": X
|
|
990
990
|
};
|
|
991
|
-
function
|
|
991
|
+
function pe() {
|
|
992
992
|
if (typeof navigator > "u")
|
|
993
|
-
return
|
|
994
|
-
const
|
|
995
|
-
for (const e of
|
|
996
|
-
const
|
|
997
|
-
if (
|
|
993
|
+
return U;
|
|
994
|
+
const s = navigator.languages ?? [navigator.language];
|
|
995
|
+
for (const e of s) {
|
|
996
|
+
const t = ee[e] ?? ee[e.split("-")[0]];
|
|
997
|
+
if (t) return t;
|
|
998
998
|
}
|
|
999
|
-
return
|
|
999
|
+
return U;
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1002
|
-
if (
|
|
1003
|
-
return
|
|
1004
|
-
if (typeof
|
|
1005
|
-
const
|
|
1006
|
-
return new m(
|
|
1007
|
-
code:
|
|
1008
|
-
status:
|
|
1009
|
-
cause:
|
|
1001
|
+
function V(s, e = "Authentication failed.") {
|
|
1002
|
+
if (s instanceof m)
|
|
1003
|
+
return s;
|
|
1004
|
+
if (typeof s == "object" && s !== null) {
|
|
1005
|
+
const t = s;
|
|
1006
|
+
return new m(t.message || e, {
|
|
1007
|
+
code: t.code,
|
|
1008
|
+
status: t.status,
|
|
1009
|
+
cause: s
|
|
1010
1010
|
});
|
|
1011
1011
|
}
|
|
1012
|
-
return typeof
|
|
1012
|
+
return typeof s == "string" ? new m(s) : new m(e, { cause: s });
|
|
1013
1013
|
}
|
|
1014
|
-
async function
|
|
1015
|
-
var
|
|
1016
|
-
const e = await
|
|
1014
|
+
async function _(s) {
|
|
1015
|
+
var t, i;
|
|
1016
|
+
const e = await s.getSession();
|
|
1017
1017
|
if (e.error)
|
|
1018
1018
|
throw new m(
|
|
1019
1019
|
e.error.message || "Failed to load the current session.",
|
|
@@ -1023,7 +1023,7 @@ async function V(t) {
|
|
|
1023
1023
|
cause: e.error
|
|
1024
1024
|
}
|
|
1025
1025
|
);
|
|
1026
|
-
return (
|
|
1026
|
+
return (t = e.data) != null && t.user && ((i = e.data) != null && i.session) ? {
|
|
1027
1027
|
user: e.data.user,
|
|
1028
1028
|
session: e.data
|
|
1029
1029
|
} : {
|
|
@@ -1031,7 +1031,7 @@ async function V(t) {
|
|
|
1031
1031
|
session: null
|
|
1032
1032
|
};
|
|
1033
1033
|
}
|
|
1034
|
-
const
|
|
1034
|
+
const fe = "data-edgespark-auth", n = "edgespark-auth", F = "es_auth_completion", C = "es_auth_email", te = "oauth", T = "verify-sign-in", g = "verify-sign-up", se = 200, z = 2, N = {
|
|
1035
1035
|
google: "Google",
|
|
1036
1036
|
apple: "Apple",
|
|
1037
1037
|
microsoft: "Microsoft",
|
|
@@ -1039,24 +1039,24 @@ const be = "data-edgespark-auth", n = "edgespark-auth", F = "es_auth_completion"
|
|
|
1039
1039
|
gitlab: "GitLab",
|
|
1040
1040
|
discord: "Discord"
|
|
1041
1041
|
};
|
|
1042
|
-
function
|
|
1043
|
-
return "redirectTo" in
|
|
1042
|
+
function I(s) {
|
|
1043
|
+
return "redirectTo" in s;
|
|
1044
1044
|
}
|
|
1045
|
-
function
|
|
1046
|
-
return "onSuccess" in
|
|
1045
|
+
function q(s) {
|
|
1046
|
+
return "onSuccess" in s && !("redirectTo" in s);
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1049
|
-
return !
|
|
1048
|
+
function D(s) {
|
|
1049
|
+
return !s || typeof s != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim());
|
|
1050
1050
|
}
|
|
1051
|
-
function ge(
|
|
1052
|
-
return /^\d{6}$/.test(
|
|
1051
|
+
function ge(s) {
|
|
1052
|
+
return /^\d{6}$/.test(s.trim());
|
|
1053
1053
|
}
|
|
1054
|
-
function ve(
|
|
1055
|
-
return
|
|
1054
|
+
function ve(s) {
|
|
1055
|
+
return s === "email" || s === "name" || s === "password" || s === "confirmPassword" || s === "code" || s === "newPassword";
|
|
1056
1056
|
}
|
|
1057
1057
|
class Pe {
|
|
1058
|
-
constructor(e,
|
|
1059
|
-
if (this.container = e, this.auth =
|
|
1058
|
+
constructor(e, t, i, r, o) {
|
|
1059
|
+
if (this.container = e, this.auth = t, this.options = i, this.loadConfig = r, this.runtimeOptions = o, this.state = {
|
|
1060
1060
|
view: "loading",
|
|
1061
1061
|
busy: !0,
|
|
1062
1062
|
busyLabel: void 0,
|
|
@@ -1070,23 +1070,23 @@ class Pe {
|
|
|
1070
1070
|
newPassword: ""
|
|
1071
1071
|
}, 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
1072
|
throw new d("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1073
|
-
this.labels =
|
|
1073
|
+
this.labels = be(pe(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(fe, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1074
1074
|
}
|
|
1075
1075
|
destroy() {
|
|
1076
1076
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
1077
1077
|
}
|
|
1078
1078
|
async initialize() {
|
|
1079
1079
|
try {
|
|
1080
|
-
const e = this.consumeManagedReturnContext(), [
|
|
1080
|
+
const e = this.consumeManagedReturnContext(), [t, i] = await Promise.all([
|
|
1081
1081
|
this.loadConfig(),
|
|
1082
|
-
|
|
1082
|
+
this.readMountSession(e)
|
|
1083
1083
|
]);
|
|
1084
1084
|
if (this.destroyed)
|
|
1085
1085
|
return;
|
|
1086
|
-
if (this.config =
|
|
1086
|
+
if (this.config = t, i.user && i.session) {
|
|
1087
1087
|
switch (e.marker) {
|
|
1088
|
-
case
|
|
1089
|
-
case
|
|
1088
|
+
case te:
|
|
1089
|
+
case T:
|
|
1090
1090
|
await this.completeAuth("sign-in", i);
|
|
1091
1091
|
return;
|
|
1092
1092
|
case g:
|
|
@@ -1105,6 +1105,27 @@ class Pe {
|
|
|
1105
1105
|
this.handleError(e, "Failed to load the authentication UI.");
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
|
+
async readMountSession(e) {
|
|
1109
|
+
if (!e.marker)
|
|
1110
|
+
return _(this.auth);
|
|
1111
|
+
let t = null;
|
|
1112
|
+
for (let i = 0; i <= z; i++) {
|
|
1113
|
+
try {
|
|
1114
|
+
const r = await _(this.auth);
|
|
1115
|
+
if (r.user && r.session)
|
|
1116
|
+
return r;
|
|
1117
|
+
} catch (r) {
|
|
1118
|
+
t = r;
|
|
1119
|
+
}
|
|
1120
|
+
i < z && await new Promise((r) => setTimeout(r, se));
|
|
1121
|
+
}
|
|
1122
|
+
if (t)
|
|
1123
|
+
throw t;
|
|
1124
|
+
return {
|
|
1125
|
+
user: null,
|
|
1126
|
+
session: null
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1108
1129
|
render() {
|
|
1109
1130
|
if (this.destroyed)
|
|
1110
1131
|
return;
|
|
@@ -1161,7 +1182,7 @@ class Pe {
|
|
|
1161
1182
|
}
|
|
1162
1183
|
renderSignInView() {
|
|
1163
1184
|
var i, r;
|
|
1164
|
-
const e = this.renderOAuthProviders(),
|
|
1185
|
+
const e = this.renderOAuthProviders(), t = ((i = this.config) == null ? void 0 : i.emailPasswordEnabled) ?? !0;
|
|
1165
1186
|
return `
|
|
1166
1187
|
<section class="${n}__section">
|
|
1167
1188
|
<header class="${n}__header">
|
|
@@ -1169,8 +1190,8 @@ class Pe {
|
|
|
1169
1190
|
<p class="${n}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
|
|
1170
1191
|
</header>
|
|
1171
1192
|
${e}
|
|
1172
|
-
${e &&
|
|
1173
|
-
${
|
|
1193
|
+
${e && t ? `<div class="${n}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
|
|
1194
|
+
${t ? `
|
|
1174
1195
|
<form class="${n}__form" data-view="sign-in" novalidate>
|
|
1175
1196
|
${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
|
|
1176
1197
|
${this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
|
|
@@ -1299,22 +1320,22 @@ class Pe {
|
|
|
1299
1320
|
`;
|
|
1300
1321
|
}
|
|
1301
1322
|
renderOAuthProviders() {
|
|
1302
|
-
var
|
|
1303
|
-
const e = ((
|
|
1323
|
+
var t;
|
|
1324
|
+
const e = ((t = this.config) == null ? void 0 : t.oauthProviders) ?? [];
|
|
1304
1325
|
return e.length === 0 ? "" : `
|
|
1305
1326
|
<div class="${n}__stack">
|
|
1306
1327
|
${e.map((i) => `
|
|
1307
1328
|
<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} ${
|
|
1329
|
+
${this.escape(`${this.labels.oauth.continueWith} ${N[i]}`)}
|
|
1309
1330
|
</button>
|
|
1310
1331
|
`).join("")}
|
|
1311
1332
|
</div>
|
|
1312
1333
|
`;
|
|
1313
1334
|
}
|
|
1314
|
-
renderInput(e,
|
|
1335
|
+
renderInput(e, t, i, r, o) {
|
|
1315
1336
|
return `
|
|
1316
1337
|
<label class="${n}__field">
|
|
1317
|
-
<span class="${n}__label">${this.escape(
|
|
1338
|
+
<span class="${n}__label">${this.escape(t)}</span>
|
|
1318
1339
|
<input
|
|
1319
1340
|
class="${n}__input"
|
|
1320
1341
|
name="${this.escape(e)}"
|
|
@@ -1348,7 +1369,7 @@ class Pe {
|
|
|
1348
1369
|
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
1370
|
}
|
|
1350
1371
|
async handleSignIn() {
|
|
1351
|
-
if (!
|
|
1372
|
+
if (!D(this.state.email)) {
|
|
1352
1373
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1353
1374
|
return;
|
|
1354
1375
|
}
|
|
@@ -1360,7 +1381,7 @@ class Pe {
|
|
|
1360
1381
|
const e = await this.auth.signIn.email({
|
|
1361
1382
|
email: this.state.email.trim(),
|
|
1362
1383
|
password: this.state.password,
|
|
1363
|
-
callbackURL: this.getManagedReturnURL(
|
|
1384
|
+
callbackURL: this.getManagedReturnURL(T, this.state.email.trim())
|
|
1364
1385
|
});
|
|
1365
1386
|
if (e.error)
|
|
1366
1387
|
throw e.error;
|
|
@@ -1368,12 +1389,12 @@ class Pe {
|
|
|
1368
1389
|
});
|
|
1369
1390
|
}
|
|
1370
1391
|
async handleSignUp() {
|
|
1371
|
-
var e,
|
|
1392
|
+
var e, t;
|
|
1372
1393
|
if (!this.state.name.trim()) {
|
|
1373
1394
|
this.failValidation(this.labels.errors.requiredField);
|
|
1374
1395
|
return;
|
|
1375
1396
|
}
|
|
1376
|
-
if (!
|
|
1397
|
+
if (!D(this.state.email)) {
|
|
1377
1398
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1378
1399
|
return;
|
|
1379
1400
|
}
|
|
@@ -1383,7 +1404,7 @@ class Pe {
|
|
|
1383
1404
|
}
|
|
1384
1405
|
if (this.state.password.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1385
1406
|
this.failValidation(
|
|
1386
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1407
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((t = this.config) == null ? void 0 : t.minPasswordLength) ?? 8))
|
|
1387
1408
|
);
|
|
1388
1409
|
return;
|
|
1389
1410
|
}
|
|
@@ -1409,18 +1430,18 @@ class Pe {
|
|
|
1409
1430
|
});
|
|
1410
1431
|
}
|
|
1411
1432
|
async handleOAuthSignIn(e) {
|
|
1412
|
-
await this.runAction(`Redirecting to ${
|
|
1413
|
-
const
|
|
1433
|
+
await this.runAction(`Redirecting to ${N[e]}…`, async () => {
|
|
1434
|
+
const t = await this.auth.signIn.social({
|
|
1414
1435
|
provider: e,
|
|
1415
1436
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
1416
1437
|
errorCallbackURL: this.getManagedReturnURL("oauth")
|
|
1417
1438
|
});
|
|
1418
|
-
if (
|
|
1419
|
-
throw
|
|
1420
|
-
const i = this.extractRedirectURL(
|
|
1439
|
+
if (t.error)
|
|
1440
|
+
throw t.error;
|
|
1441
|
+
const i = this.extractRedirectURL(t.data);
|
|
1421
1442
|
if (!i)
|
|
1422
1443
|
throw new d(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1423
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
1444
|
+
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${N[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1424
1445
|
});
|
|
1425
1446
|
}
|
|
1426
1447
|
async handleForgotPassword() {
|
|
@@ -1430,7 +1451,7 @@ class Pe {
|
|
|
1430
1451
|
);
|
|
1431
1452
|
return;
|
|
1432
1453
|
}
|
|
1433
|
-
if (!
|
|
1454
|
+
if (!D(this.state.email)) {
|
|
1434
1455
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1435
1456
|
return;
|
|
1436
1457
|
}
|
|
@@ -1447,7 +1468,7 @@ class Pe {
|
|
|
1447
1468
|
this.isCountdownActive() || await this.handleForgotPassword();
|
|
1448
1469
|
}
|
|
1449
1470
|
async handleResetPassword() {
|
|
1450
|
-
var e,
|
|
1471
|
+
var e, t;
|
|
1451
1472
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1452
1473
|
this.handleError(
|
|
1453
1474
|
new d("Password reset via email OTP is not enabled for this project.")
|
|
@@ -1464,7 +1485,7 @@ class Pe {
|
|
|
1464
1485
|
}
|
|
1465
1486
|
if (this.state.newPassword.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1466
1487
|
this.failValidation(
|
|
1467
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1488
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((t = this.config) == null ? void 0 : t.minPasswordLength) ?? 8))
|
|
1468
1489
|
);
|
|
1469
1490
|
return;
|
|
1470
1491
|
}
|
|
@@ -1488,29 +1509,29 @@ class Pe {
|
|
|
1488
1509
|
}
|
|
1489
1510
|
async sendVerificationEmail(e) {
|
|
1490
1511
|
!e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
|
|
1491
|
-
const
|
|
1512
|
+
const t = await this.auth.sendVerificationEmail({
|
|
1492
1513
|
email: this.state.email.trim(),
|
|
1493
1514
|
callbackURL: this.getManagedReturnURL(
|
|
1494
|
-
this.verificationCompletionAction === "sign-up" ? g :
|
|
1515
|
+
this.verificationCompletionAction === "sign-up" ? g : T,
|
|
1495
1516
|
this.state.email.trim()
|
|
1496
1517
|
)
|
|
1497
1518
|
});
|
|
1498
|
-
if (
|
|
1499
|
-
throw
|
|
1519
|
+
if (t.error)
|
|
1520
|
+
throw t.error;
|
|
1500
1521
|
this.handleVerificationEmailSent(this.state.email.trim(), !0);
|
|
1501
1522
|
});
|
|
1502
1523
|
}
|
|
1503
|
-
async completeAuth(e,
|
|
1524
|
+
async completeAuth(e, t) {
|
|
1504
1525
|
const i = await this.retryAuthCompletionDataIfNeeded(
|
|
1505
|
-
|
|
1526
|
+
t ?? await this.resolveAuthCompletionData()
|
|
1506
1527
|
);
|
|
1507
1528
|
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(
|
|
1529
|
+
if (i.lookupError && I(this.options)) {
|
|
1530
|
+
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(k(this.options.redirectTo).toString());
|
|
1510
1531
|
return;
|
|
1511
1532
|
}
|
|
1512
1533
|
if (e === "sign-in")
|
|
1513
|
-
throw i.lookupError ?? new
|
|
1534
|
+
throw i.lookupError ?? new ne(
|
|
1514
1535
|
"Managed sign-in completed without an authenticated session."
|
|
1515
1536
|
);
|
|
1516
1537
|
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 +1542,11 @@ class Pe {
|
|
|
1521
1542
|
user: i.user,
|
|
1522
1543
|
session: i.session
|
|
1523
1544
|
};
|
|
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(
|
|
1545
|
+
if (await this.syncPublicSessionBestEffort(), I(this.options)) {
|
|
1546
|
+
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(k(this.options.redirectTo).toString());
|
|
1526
1547
|
return;
|
|
1527
1548
|
}
|
|
1528
|
-
if (
|
|
1549
|
+
if (q(this.options)) {
|
|
1529
1550
|
this.destroy(), this.options.onSuccess(r);
|
|
1530
1551
|
return;
|
|
1531
1552
|
}
|
|
@@ -1533,44 +1554,44 @@ class Pe {
|
|
|
1533
1554
|
async retryAuthCompletionDataIfNeeded(e) {
|
|
1534
1555
|
if (e.session)
|
|
1535
1556
|
return e;
|
|
1536
|
-
let
|
|
1537
|
-
for (let i = 0; i <
|
|
1538
|
-
await new Promise((r) => setTimeout(r,
|
|
1557
|
+
let t = e.lookupError;
|
|
1558
|
+
for (let i = 0; i < z; i++) {
|
|
1559
|
+
await new Promise((r) => setTimeout(r, se));
|
|
1539
1560
|
try {
|
|
1540
|
-
const r = await
|
|
1561
|
+
const r = await _(this.auth);
|
|
1541
1562
|
if (r.user && r.session)
|
|
1542
1563
|
return {
|
|
1543
1564
|
user: r.user,
|
|
1544
1565
|
session: r.session
|
|
1545
1566
|
};
|
|
1546
1567
|
} catch (r) {
|
|
1547
|
-
|
|
1568
|
+
t = r;
|
|
1548
1569
|
}
|
|
1549
1570
|
}
|
|
1550
1571
|
return {
|
|
1551
1572
|
...e,
|
|
1552
|
-
lookupError:
|
|
1573
|
+
lookupError: t ?? e.lookupError
|
|
1553
1574
|
};
|
|
1554
1575
|
}
|
|
1555
1576
|
async syncPublicSessionBestEffort() {
|
|
1556
|
-
var e,
|
|
1577
|
+
var e, t;
|
|
1557
1578
|
try {
|
|
1558
|
-
await ((
|
|
1579
|
+
await ((t = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : t.call(e));
|
|
1559
1580
|
} catch {
|
|
1560
1581
|
}
|
|
1561
1582
|
}
|
|
1562
1583
|
async resolveAuthCompletionData(e) {
|
|
1563
1584
|
try {
|
|
1564
|
-
const
|
|
1585
|
+
const t = await _(this.auth), i = this.extractUser(e);
|
|
1565
1586
|
return {
|
|
1566
|
-
user:
|
|
1567
|
-
session:
|
|
1587
|
+
user: t.user ?? i,
|
|
1588
|
+
session: t.session
|
|
1568
1589
|
};
|
|
1569
|
-
} catch (
|
|
1590
|
+
} catch (t) {
|
|
1570
1591
|
return {
|
|
1571
1592
|
user: this.extractUser(e),
|
|
1572
1593
|
session: null,
|
|
1573
|
-
lookupError:
|
|
1594
|
+
lookupError: t
|
|
1574
1595
|
};
|
|
1575
1596
|
}
|
|
1576
1597
|
}
|
|
@@ -1580,26 +1601,26 @@ class Pe {
|
|
|
1580
1601
|
user: null,
|
|
1581
1602
|
session: null
|
|
1582
1603
|
};
|
|
1583
|
-
if (
|
|
1604
|
+
if (q(this.options)) {
|
|
1584
1605
|
this.destroy(), this.options.onSuccess(e);
|
|
1585
1606
|
return;
|
|
1586
1607
|
}
|
|
1587
1608
|
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
1609
|
}
|
|
1589
1610
|
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(
|
|
1611
|
+
if (I(this.options)) {
|
|
1612
|
+
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(k(this.options.redirectTo).toString());
|
|
1592
1613
|
return;
|
|
1593
1614
|
}
|
|
1594
|
-
if (
|
|
1615
|
+
if (q(this.options))
|
|
1595
1616
|
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new d(
|
|
1596
1617
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1597
1618
|
);
|
|
1598
1619
|
}
|
|
1599
|
-
async runAction(e,
|
|
1620
|
+
async runAction(e, t) {
|
|
1600
1621
|
this.state.busy = !0, this.state.busyLabel = e, this.state.error = null, this.state.notice = null, this.render();
|
|
1601
1622
|
try {
|
|
1602
|
-
await
|
|
1623
|
+
await t();
|
|
1603
1624
|
} catch (i) {
|
|
1604
1625
|
if (this.maybeHandleVerificationRequired(i))
|
|
1605
1626
|
return;
|
|
@@ -1609,42 +1630,42 @@ class Pe {
|
|
|
1609
1630
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1610
1631
|
}
|
|
1611
1632
|
maybeHandleVerificationRequired(e) {
|
|
1612
|
-
return
|
|
1633
|
+
return V(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
1634
|
}
|
|
1614
|
-
handleVerificationEmailSent(e,
|
|
1615
|
-
this.state.notice =
|
|
1635
|
+
handleVerificationEmailSent(e, t) {
|
|
1636
|
+
this.state.notice = t ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
1616
1637
|
}
|
|
1617
1638
|
invokeRedirectModeSuccessHook(e) {
|
|
1618
|
-
var
|
|
1619
|
-
if (!(!
|
|
1639
|
+
var t, i;
|
|
1640
|
+
if (!(!I(this.options) || !this.options.onSuccess))
|
|
1620
1641
|
try {
|
|
1621
1642
|
this.options.onSuccess(e);
|
|
1622
1643
|
} catch (r) {
|
|
1623
|
-
const o =
|
|
1644
|
+
const o = V(r, "Post-auth callback failed.");
|
|
1624
1645
|
try {
|
|
1625
|
-
(i = (
|
|
1646
|
+
(i = (t = this.options).onError) == null || i.call(t, o);
|
|
1626
1647
|
} catch {
|
|
1627
1648
|
}
|
|
1628
1649
|
}
|
|
1629
1650
|
}
|
|
1630
|
-
handleError(e,
|
|
1651
|
+
handleError(e, t) {
|
|
1631
1652
|
var r, o;
|
|
1632
|
-
const i =
|
|
1653
|
+
const i = V(e, t);
|
|
1633
1654
|
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (o = (r = this.options).onError) == null || o.call(r, i);
|
|
1634
1655
|
}
|
|
1635
1656
|
failValidation(e) {
|
|
1636
1657
|
this.state.error = e, this.state.notice = null, this.render();
|
|
1637
1658
|
}
|
|
1638
|
-
getManagedReturnURL(e,
|
|
1659
|
+
getManagedReturnURL(e, t) {
|
|
1639
1660
|
if (!e)
|
|
1640
1661
|
return window.location.href;
|
|
1641
1662
|
const i = new URL(window.location.href);
|
|
1642
|
-
return i.searchParams.set(F, e),
|
|
1663
|
+
return i.searchParams.set(F, e), t ? i.searchParams.set(C, t) : i.searchParams.delete(C), i.toString();
|
|
1643
1664
|
}
|
|
1644
1665
|
consumeManagedReturnContext() {
|
|
1645
|
-
const e = new URL(window.location.href),
|
|
1646
|
-
return (
|
|
1647
|
-
marker:
|
|
1666
|
+
const e = new URL(window.location.href), t = e.searchParams.get(F), i = e.searchParams.get(C), r = t ? e.searchParams.get("error") : null, o = t ? e.searchParams.get("error_description") : null;
|
|
1667
|
+
return (t || i) && (e.searchParams.delete(F), e.searchParams.delete(C), t && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1668
|
+
marker: t,
|
|
1648
1669
|
email: i,
|
|
1649
1670
|
error: r,
|
|
1650
1671
|
errorDescription: o
|
|
@@ -1675,7 +1696,7 @@ class Pe {
|
|
|
1675
1696
|
this.pendingFocusSnapshot && (this.clearFocusRestoreTimer(), this.focusRestoreTimer = window.setTimeout(() => {
|
|
1676
1697
|
if (this.focusRestoreTimer = null, this.destroyed || !this.pendingFocusSnapshot)
|
|
1677
1698
|
return;
|
|
1678
|
-
const e = this.pendingFocusSnapshot,
|
|
1699
|
+
const e = this.pendingFocusSnapshot, t = `input[name="${this.escape(e.name)}"][type="${this.escape(e.type)}"]`, i = this.root.querySelector(t);
|
|
1679
1700
|
if (!(!i || i.disabled)) {
|
|
1680
1701
|
if (i.focus(), e.selectionStart !== null && e.selectionEnd !== null)
|
|
1681
1702
|
try {
|
|
@@ -1697,24 +1718,24 @@ class Pe {
|
|
|
1697
1718
|
extractRedirectURL(e) {
|
|
1698
1719
|
if (!e || typeof e != "object")
|
|
1699
1720
|
return null;
|
|
1700
|
-
const
|
|
1701
|
-
return
|
|
1721
|
+
const t = e;
|
|
1722
|
+
return t.redirect && typeof t.url == "string" && t.url.length > 0 ? t.url : null;
|
|
1702
1723
|
}
|
|
1703
1724
|
extractUser(e) {
|
|
1704
1725
|
if (!e || typeof e != "object")
|
|
1705
1726
|
return null;
|
|
1706
|
-
const
|
|
1707
|
-
return
|
|
1727
|
+
const t = e;
|
|
1728
|
+
return t.user && typeof t.user == "object" ? t.user : null;
|
|
1708
1729
|
}
|
|
1709
1730
|
canUsePasswordResetEmailOtp() {
|
|
1710
1731
|
var e;
|
|
1711
1732
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
1712
1733
|
}
|
|
1713
1734
|
handleSessionlessManagedReturn(e) {
|
|
1714
|
-
return e.email && (this.state.email = e.email), e.marker === g && !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 ===
|
|
1735
|
+
return e.email && (this.state.email = e.email), e.marker === g && !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 === T || e.marker === g ? (this.verificationCompletionAction = e.marker === g ? "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 m(
|
|
1715
1736
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
1716
1737
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
1717
|
-
)) : this.render(), !0) : e.marker ===
|
|
1738
|
+
)) : this.render(), !0) : e.marker === te && (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 m(
|
|
1718
1739
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
1719
1740
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
1720
1741
|
)), !0) : !1;
|
|
@@ -1725,16 +1746,16 @@ class Pe {
|
|
|
1725
1746
|
getCountdownSecondsRemaining() {
|
|
1726
1747
|
return this.countdownUntil ? Math.max(0, Math.ceil((this.countdownUntil - Date.now()) / 1e3)) : 0;
|
|
1727
1748
|
}
|
|
1728
|
-
countdownText(e,
|
|
1749
|
+
countdownText(e, t) {
|
|
1729
1750
|
const i = this.getCountdownSecondsRemaining();
|
|
1730
|
-
return i <= 0 ? e :
|
|
1751
|
+
return i <= 0 ? e : t.replace("{seconds}", String(i));
|
|
1731
1752
|
}
|
|
1732
1753
|
escape(e) {
|
|
1733
1754
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1734
1755
|
}
|
|
1735
1756
|
}
|
|
1736
|
-
function Le(
|
|
1737
|
-
return "data" in
|
|
1757
|
+
function Le(s) {
|
|
1758
|
+
return "data" in s && s.data ? s.data : s;
|
|
1738
1759
|
}
|
|
1739
1760
|
const ye = [
|
|
1740
1761
|
{ id: "google", key: "providerGoogle" },
|
|
@@ -1743,118 +1764,118 @@ const ye = [
|
|
|
1743
1764
|
{ id: "github", key: "providerGithub" },
|
|
1744
1765
|
{ id: "gitlab", key: "providerGitlab" },
|
|
1745
1766
|
{ id: "discord", key: "providerDiscord" }
|
|
1746
|
-
],
|
|
1767
|
+
], ie = 2, Ee = 500;
|
|
1747
1768
|
async function Se() {
|
|
1748
|
-
const
|
|
1769
|
+
const s = `${window.location.origin}${oe}/config`;
|
|
1749
1770
|
let e;
|
|
1750
|
-
for (let
|
|
1771
|
+
for (let t = 0; t <= ie; t++)
|
|
1751
1772
|
try {
|
|
1752
|
-
const i = await fetch(
|
|
1773
|
+
const i = await fetch(s, { method: "GET", credentials: "include" });
|
|
1753
1774
|
if (!i.ok)
|
|
1754
1775
|
throw new d(`Failed to load auth config: HTTP ${i.status}`);
|
|
1755
1776
|
const r = await i.json();
|
|
1756
1777
|
return Ce(Le(r));
|
|
1757
1778
|
} catch (i) {
|
|
1758
|
-
e = i,
|
|
1779
|
+
e = i, t < ie && await new Promise((r) => setTimeout(r, Ee));
|
|
1759
1780
|
}
|
|
1760
1781
|
throw e;
|
|
1761
1782
|
}
|
|
1762
|
-
let
|
|
1783
|
+
let R = null;
|
|
1763
1784
|
async function _e() {
|
|
1764
|
-
return
|
|
1765
|
-
throw
|
|
1766
|
-
})),
|
|
1785
|
+
return R || (R = Se().catch((s) => {
|
|
1786
|
+
throw R = null, s;
|
|
1787
|
+
})), R;
|
|
1767
1788
|
}
|
|
1768
|
-
function Ce(
|
|
1769
|
-
var
|
|
1789
|
+
function Ce(s) {
|
|
1790
|
+
var t, i, r, o, u, w, E;
|
|
1770
1791
|
const e = ye.filter(({ key: c }) => {
|
|
1771
|
-
const a =
|
|
1792
|
+
const a = s[c];
|
|
1772
1793
|
return typeof a == "object" && a !== null && "enabled" in a && !!a.enabled;
|
|
1773
1794
|
}).map(({ id: c }) => c);
|
|
1774
1795
|
return {
|
|
1775
|
-
disableSignUp: !!
|
|
1776
|
-
emailPasswordEnabled: !!((
|
|
1777
|
-
minPasswordLength: ((r = (i =
|
|
1778
|
-
requireEmailVerification: !!((u = (o =
|
|
1779
|
-
passwordResetEmailOtpEnabled: !!((E = (w =
|
|
1796
|
+
disableSignUp: !!s.disableSignUp,
|
|
1797
|
+
emailPasswordEnabled: !!((t = s.providerEmailPassword) != null && t.enabled),
|
|
1798
|
+
minPasswordLength: ((r = (i = s.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : r.minPasswordLength) ?? 8,
|
|
1799
|
+
requireEmailVerification: !!((u = (o = s.providerEmailPassword) == null ? void 0 : o.config) != null && u.requireEmailVerification),
|
|
1800
|
+
passwordResetEmailOtpEnabled: !!((E = (w = s.providerEmailPassword) == null ? void 0 : w.config) != null && E.requirePasswordResetEmailVerification),
|
|
1780
1801
|
oauthProviders: e
|
|
1781
1802
|
};
|
|
1782
1803
|
}
|
|
1783
|
-
const
|
|
1784
|
-
function Te(
|
|
1785
|
-
if (!
|
|
1804
|
+
const $ = /* @__PURE__ */ new WeakMap();
|
|
1805
|
+
function Te(s) {
|
|
1806
|
+
if (!s)
|
|
1786
1807
|
throw new d(
|
|
1787
1808
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1788
1809
|
);
|
|
1789
|
-
const e = "redirectTo" in
|
|
1790
|
-
if (!e && !
|
|
1810
|
+
const e = "redirectTo" in s, t = "onSuccess" in s && typeof s.onSuccess == "function";
|
|
1811
|
+
if (!e && !t)
|
|
1791
1812
|
throw new d(
|
|
1792
1813
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1793
1814
|
);
|
|
1794
|
-
if ("redirectTo" in
|
|
1795
|
-
const i =
|
|
1815
|
+
if ("redirectTo" in s) {
|
|
1816
|
+
const i = s.redirectTo;
|
|
1796
1817
|
if (!(typeof i == "string" || i instanceof URL))
|
|
1797
1818
|
throw new d(
|
|
1798
1819
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
1799
1820
|
);
|
|
1800
1821
|
}
|
|
1801
|
-
if ("onSuccess" in
|
|
1822
|
+
if ("onSuccess" in s && s.onSuccess !== void 0 && typeof s.onSuccess != "function")
|
|
1802
1823
|
throw new d(
|
|
1803
1824
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
1804
1825
|
);
|
|
1805
|
-
if ("onError" in
|
|
1826
|
+
if ("onError" in s && s.onError !== void 0 && typeof s.onError != "function")
|
|
1806
1827
|
throw new d(
|
|
1807
1828
|
"authUI.mount(container, options) expected onError to be a function."
|
|
1808
1829
|
);
|
|
1809
1830
|
}
|
|
1810
|
-
function Ie(
|
|
1811
|
-
if (!(
|
|
1831
|
+
function Ie(s) {
|
|
1832
|
+
if (!(s instanceof HTMLElement))
|
|
1812
1833
|
throw new d("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1813
1834
|
}
|
|
1814
|
-
function Re(
|
|
1835
|
+
function Re(s, e) {
|
|
1815
1836
|
return {
|
|
1816
|
-
mount(
|
|
1837
|
+
mount(t, i) {
|
|
1817
1838
|
var w;
|
|
1818
|
-
Te(i), Ie(
|
|
1819
|
-
const r = new Pe(
|
|
1839
|
+
Te(i), Ie(t), (w = $.get(t)) == null || w.destroy();
|
|
1840
|
+
const r = new Pe(t, s, i, _e, e), o = r.destroy.bind(r), u = {
|
|
1820
1841
|
destroy() {
|
|
1821
|
-
o(),
|
|
1842
|
+
o(), $.get(t) === u && $.delete(t);
|
|
1822
1843
|
}
|
|
1823
1844
|
};
|
|
1824
|
-
return
|
|
1845
|
+
return $.set(t, u), u;
|
|
1825
1846
|
}
|
|
1826
1847
|
};
|
|
1827
1848
|
}
|
|
1828
1849
|
function Ue() {
|
|
1829
|
-
|
|
1830
|
-
const
|
|
1850
|
+
re();
|
|
1851
|
+
const s = me(), e = we(), t = ue(), i = Re(e, {
|
|
1831
1852
|
syncPublicSession: async () => {
|
|
1832
|
-
await
|
|
1853
|
+
await he(s);
|
|
1833
1854
|
}
|
|
1834
1855
|
});
|
|
1835
1856
|
return {
|
|
1836
|
-
auth:
|
|
1837
|
-
api:
|
|
1857
|
+
auth: s,
|
|
1858
|
+
api: t,
|
|
1838
1859
|
authUI: i
|
|
1839
1860
|
};
|
|
1840
1861
|
}
|
|
1841
1862
|
export {
|
|
1842
1863
|
m as EdgeSparkAuthError,
|
|
1843
1864
|
d as EdgeSparkConfigError,
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1865
|
+
x as EdgeSparkError,
|
|
1866
|
+
ne as EdgeSparkRuntimeError,
|
|
1867
|
+
Q as ar,
|
|
1847
1868
|
Ue as createEdgeSpark,
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1869
|
+
K as de,
|
|
1870
|
+
pe as detectLocale,
|
|
1871
|
+
U as enUS,
|
|
1872
|
+
O as es,
|
|
1873
|
+
Y as fr,
|
|
1874
|
+
X as hi,
|
|
1875
|
+
J as it,
|
|
1876
|
+
W as ja,
|
|
1877
|
+
j as ko,
|
|
1878
|
+
G as ptBR,
|
|
1879
|
+
Z as ru,
|
|
1880
|
+
M as zhCN
|
|
1860
1881
|
};
|