@edgespark/web 0.0.1-beta.5 → 0.0.1-beta.6
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/README.md +14 -4
- package/dist/auth/create-auth.d.ts +3 -2
- package/dist/auth/types.d.ts +15 -24
- package/dist/auth-ui/ManagedAuthUI.d.ts +1 -0
- package/dist/client.d.ts +6 -5
- package/dist/index.cjs +60 -60
- package/dist/index.es.js +612 -424
- package/package.json +3 -2
package/dist/index.es.js
CHANGED
|
@@ -1,75 +1,93 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
2
|
-
class
|
|
1
|
+
import { createAuthClient as Ue } from "better-auth/client";
|
|
2
|
+
class ee 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 m extends ee {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class Se extends ee {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class y extends ee {
|
|
18
18
|
constructor(e, s) {
|
|
19
19
|
super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Pe() {
|
|
23
23
|
if (typeof window > "u" || typeof document > "u")
|
|
24
|
-
throw new
|
|
24
|
+
throw new Se(
|
|
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 Q() {
|
|
29
|
+
return Pe(), window.location.origin;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function Be(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 ke(t) {
|
|
35
|
+
if (t.origin !== Q())
|
|
36
|
+
throw new m(
|
|
37
|
+
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function Me() {
|
|
41
41
|
return {
|
|
42
42
|
async fetch(t, e) {
|
|
43
|
-
const s =
|
|
44
|
-
return
|
|
43
|
+
const s = Be(t);
|
|
44
|
+
return ke(s), fetch(t, {
|
|
45
45
|
...e,
|
|
46
46
|
credentials: "include"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const Ee = "/api/_es/auth", Oe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", S = "__edgespark_auth_pending_sign_in__", _e = Symbol("edgespark.notifyAuthTabs"), Ie = 10 * 60 * 1e3, Ve = /* @__PURE__ */ new Set([
|
|
52
|
+
"signOut",
|
|
53
|
+
"revokeSession",
|
|
54
|
+
"revokeSessions",
|
|
55
|
+
"revokeOtherSessions"
|
|
56
|
+
]);
|
|
57
|
+
class Ne {
|
|
58
|
+
constructor(e) {
|
|
59
|
+
this.value = e;
|
|
60
|
+
}
|
|
61
|
+
deref() {
|
|
62
|
+
return this.value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const ie = globalThis.WeakRef, ne = globalThis.FinalizationRegistry;
|
|
66
|
+
let z, re = !1;
|
|
67
|
+
const A = /* @__PURE__ */ new Map(), D = ne ? new ne((t) => {
|
|
68
|
+
A.delete(t);
|
|
69
|
+
}) : null;
|
|
70
|
+
function Ce(t) {
|
|
71
|
+
return Ue({
|
|
72
|
+
baseURL: Q(),
|
|
73
|
+
basePath: Ee,
|
|
56
74
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
57
75
|
fetchOptions: {
|
|
58
76
|
credentials: "include"
|
|
59
77
|
}
|
|
60
78
|
});
|
|
61
79
|
}
|
|
62
|
-
function
|
|
80
|
+
function T(t) {
|
|
63
81
|
var e, s;
|
|
64
82
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
65
83
|
}
|
|
66
|
-
function
|
|
84
|
+
function Fe(t) {
|
|
67
85
|
return JSON.stringify({
|
|
68
86
|
source: t,
|
|
69
87
|
timestamp: Date.now()
|
|
70
88
|
});
|
|
71
89
|
}
|
|
72
|
-
function
|
|
90
|
+
function ze(t) {
|
|
73
91
|
if (typeof t != "string")
|
|
74
92
|
return null;
|
|
75
93
|
try {
|
|
@@ -79,17 +97,145 @@ function Ee(t) {
|
|
|
79
97
|
return null;
|
|
80
98
|
}
|
|
81
99
|
}
|
|
82
|
-
function
|
|
100
|
+
async function X(t) {
|
|
101
|
+
var e;
|
|
102
|
+
try {
|
|
103
|
+
return await ((e = T(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
104
|
+
} catch {
|
|
105
|
+
return !1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function Te() {
|
|
109
|
+
return z === void 0 && (z = typeof BroadcastChannel < "u" ? new BroadcastChannel(Oe) : null), z;
|
|
110
|
+
}
|
|
111
|
+
function oe(t) {
|
|
112
|
+
const e = ze(t);
|
|
113
|
+
if (e)
|
|
114
|
+
for (const [s, i] of A) {
|
|
115
|
+
if (s === e.source)
|
|
116
|
+
continue;
|
|
117
|
+
const n = i.deref();
|
|
118
|
+
if (!n) {
|
|
119
|
+
A.delete(s);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
X(n);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function De() {
|
|
126
|
+
var t;
|
|
127
|
+
re || (re = !0, (t = Te()) == null || t.addEventListener("message", (e) => {
|
|
128
|
+
oe(e.data);
|
|
129
|
+
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
130
|
+
e.key !== Le || e.newValue === null || oe(e.newValue);
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
function qe(t, e) {
|
|
134
|
+
ie ? A.set(t, new ie(e)) : (A.clear(), A.set(t, new Ne(e))), D == null || D.register(e, t), De();
|
|
135
|
+
}
|
|
136
|
+
function _(t) {
|
|
137
|
+
var s;
|
|
138
|
+
const e = Fe(t);
|
|
139
|
+
try {
|
|
140
|
+
(s = Te()) == null || s.postMessage(e);
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
window.localStorage.setItem(Le, e);
|
|
145
|
+
} catch {
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function q(t) {
|
|
149
|
+
if (!(typeof window > "u"))
|
|
150
|
+
try {
|
|
151
|
+
window.sessionStorage.setItem(
|
|
152
|
+
S,
|
|
153
|
+
JSON.stringify({
|
|
154
|
+
path: t,
|
|
155
|
+
createdAt: Date.now()
|
|
156
|
+
})
|
|
157
|
+
);
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function U() {
|
|
162
|
+
if (!(typeof window > "u"))
|
|
163
|
+
try {
|
|
164
|
+
window.sessionStorage.removeItem(S);
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function He(t) {
|
|
169
|
+
return !!(t != null && t.session && (t != null && t.user));
|
|
170
|
+
}
|
|
171
|
+
function ae() {
|
|
172
|
+
if (typeof window > "u")
|
|
173
|
+
return !1;
|
|
174
|
+
try {
|
|
175
|
+
const t = window.sessionStorage.getItem(S);
|
|
176
|
+
if (!t)
|
|
177
|
+
return !1;
|
|
178
|
+
window.sessionStorage.removeItem(S);
|
|
179
|
+
const e = JSON.parse(t);
|
|
180
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" ? !1 : Date.now() - e.createdAt <= Ie;
|
|
181
|
+
} catch {
|
|
182
|
+
return !1;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function je() {
|
|
186
|
+
if (typeof window > "u")
|
|
187
|
+
return !1;
|
|
188
|
+
try {
|
|
189
|
+
const t = window.sessionStorage.getItem(S);
|
|
190
|
+
if (!t)
|
|
191
|
+
return !1;
|
|
192
|
+
const e = JSON.parse(t);
|
|
193
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ie ? (window.sessionStorage.removeItem(S), !1) : !0;
|
|
194
|
+
} catch {
|
|
195
|
+
return !1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function xe(t) {
|
|
83
199
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
84
200
|
return !1;
|
|
85
201
|
const e = "data" in t ? t.data : t;
|
|
86
202
|
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
203
|
}
|
|
88
|
-
function
|
|
89
|
-
if (t
|
|
204
|
+
function We(t) {
|
|
205
|
+
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
206
|
+
return !1;
|
|
207
|
+
const e = "data" in t ? t.data : t;
|
|
208
|
+
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
209
|
+
}
|
|
210
|
+
function Ge(t) {
|
|
211
|
+
if (R(t) || !(t && typeof t == "object"))
|
|
212
|
+
return !1;
|
|
213
|
+
const e = "data" in t ? t.data : t;
|
|
214
|
+
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
215
|
+
}
|
|
216
|
+
function Ye(t, e) {
|
|
217
|
+
if (t.length !== 1 || t[0] !== "changePassword")
|
|
218
|
+
return !1;
|
|
219
|
+
const [s] = e;
|
|
220
|
+
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
221
|
+
}
|
|
222
|
+
function R(t) {
|
|
223
|
+
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
224
|
+
}
|
|
225
|
+
function Ke(t) {
|
|
226
|
+
if (R(t) || !(t && typeof t == "object"))
|
|
227
|
+
return !1;
|
|
228
|
+
const e = "data" in t ? t.data : t;
|
|
229
|
+
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
230
|
+
}
|
|
231
|
+
function Je(t) {
|
|
232
|
+
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
233
|
+
}
|
|
234
|
+
function H(t) {
|
|
235
|
+
if (t instanceof y)
|
|
90
236
|
return t;
|
|
91
237
|
const e = t;
|
|
92
|
-
return new
|
|
238
|
+
return new y(
|
|
93
239
|
(e == null ? void 0 : e.message) || "Failed to load the current session.",
|
|
94
240
|
{
|
|
95
241
|
code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -98,163 +244,177 @@ function M(t) {
|
|
|
98
244
|
}
|
|
99
245
|
);
|
|
100
246
|
}
|
|
101
|
-
async function
|
|
102
|
-
var
|
|
103
|
-
|
|
247
|
+
async function Ze(t) {
|
|
248
|
+
var s, i;
|
|
249
|
+
let e = null;
|
|
250
|
+
try {
|
|
251
|
+
await ((s = T(t)) == null ? void 0 : s.get().refetch());
|
|
252
|
+
} catch (n) {
|
|
253
|
+
e = n;
|
|
254
|
+
} finally {
|
|
255
|
+
(i = t[_e]) == null || i.call(t);
|
|
256
|
+
}
|
|
257
|
+
if (e)
|
|
258
|
+
throw e;
|
|
104
259
|
}
|
|
105
|
-
function
|
|
106
|
-
const t =
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
260
|
+
function Qe() {
|
|
261
|
+
const t = Ce(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
262
|
+
qe(e, t);
|
|
263
|
+
const s = 2, i = 500;
|
|
264
|
+
let n = null, a = !1, h;
|
|
265
|
+
const w = (o) => (h = o, o), P = () => {
|
|
266
|
+
var c;
|
|
267
|
+
const o = (c = T(t)) == null ? void 0 : c.get();
|
|
268
|
+
return o != null && o.error && !o.data && h !== void 0 ? h : (o == null ? void 0 : o.data) ?? h ?? null;
|
|
269
|
+
}, E = () => a ? Promise.resolve(P()) : (n || (n = (async () => {
|
|
270
|
+
var l, u, g;
|
|
271
|
+
let o = !1, c = null;
|
|
272
|
+
try {
|
|
273
|
+
for (let p = 0; p <= s; p++) {
|
|
274
|
+
let d = null;
|
|
275
|
+
try {
|
|
276
|
+
d = await t.getSession();
|
|
277
|
+
} catch (v) {
|
|
278
|
+
c = v;
|
|
279
|
+
}
|
|
280
|
+
const b = ((l = T(t)) == null ? void 0 : l.get().data) ?? null;
|
|
281
|
+
if ((u = d == null ? void 0 : d.data) != null && u.session && ((g = d.data) != null && g.user))
|
|
282
|
+
return a = !0, ae() && _(e), w(d.data);
|
|
283
|
+
if (b != null && b.session && (b != null && b.user))
|
|
284
|
+
return a = !0, ae() && _(e), w(b);
|
|
285
|
+
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && je() && p < s) {
|
|
286
|
+
await new Promise(
|
|
287
|
+
(v) => setTimeout(v, i)
|
|
288
|
+
);
|
|
289
|
+
continue;
|
|
125
290
|
}
|
|
126
|
-
if (!
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
} catch (h) {
|
|
134
|
-
throw a = null, M(h);
|
|
291
|
+
if (d && !d.error) {
|
|
292
|
+
const v = P();
|
|
293
|
+
return a = !0, w(v);
|
|
294
|
+
}
|
|
295
|
+
p < s && await new Promise(
|
|
296
|
+
(v) => setTimeout(v, i)
|
|
297
|
+
);
|
|
135
298
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
299
|
+
if (!o)
|
|
300
|
+
throw n = null, new y("Failed to load the current session.", {
|
|
301
|
+
code: "SESSION_LOOKUP_FAILED",
|
|
302
|
+
cause: c
|
|
303
|
+
});
|
|
304
|
+
const f = P();
|
|
305
|
+
return a = !0, w(f);
|
|
306
|
+
} catch (f) {
|
|
307
|
+
throw n = null, H(f);
|
|
308
|
+
}
|
|
309
|
+
})()), n);
|
|
310
|
+
E().catch(() => {
|
|
139
311
|
});
|
|
140
|
-
const
|
|
141
|
-
var
|
|
312
|
+
const L = async () => {
|
|
313
|
+
var o, c;
|
|
142
314
|
try {
|
|
143
|
-
const
|
|
144
|
-
if ((
|
|
145
|
-
return
|
|
146
|
-
throw
|
|
315
|
+
const l = await t.getSession();
|
|
316
|
+
if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
|
|
317
|
+
return l.data;
|
|
318
|
+
throw l.error ? H(l.error) : new y("No authenticated session is available.", {
|
|
147
319
|
code: "UNAUTHENTICATED"
|
|
148
320
|
});
|
|
149
|
-
} catch (
|
|
150
|
-
throw
|
|
321
|
+
} catch (l) {
|
|
322
|
+
throw H(l);
|
|
151
323
|
}
|
|
152
|
-
},
|
|
324
|
+
}, $ = async () => {
|
|
325
|
+
await X(t), _(e);
|
|
326
|
+
}, Re = async () => {
|
|
153
327
|
var l;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
s == null || s.postMessage(l);
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
window.localStorage.setItem(K, l);
|
|
166
|
-
} catch {
|
|
167
|
-
}
|
|
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));
|
|
328
|
+
const o = await X(t), c = ((l = T(t)) == null ? void 0 : l.get().data) ?? null;
|
|
329
|
+
He(c) ? (U(), _(e)) : o || _(e);
|
|
330
|
+
}, Ae = (o) => {
|
|
331
|
+
let c = !1, l = !1, u;
|
|
332
|
+
const g = (d) => {
|
|
333
|
+
d !== u && (u = d, o(d));
|
|
183
334
|
};
|
|
184
|
-
|
|
185
|
-
|
|
335
|
+
E().then((d) => {
|
|
336
|
+
c || (l = !0, g(w(d)));
|
|
186
337
|
}).catch(() => {
|
|
187
|
-
|
|
338
|
+
c || (l = !0);
|
|
188
339
|
});
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
340
|
+
const f = T(t);
|
|
341
|
+
if (!f)
|
|
191
342
|
return () => {
|
|
192
|
-
|
|
343
|
+
c = !0;
|
|
193
344
|
};
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
345
|
+
const p = f.subscribe((d) => {
|
|
346
|
+
if (c || !l || d.error && !d.data)
|
|
196
347
|
return;
|
|
197
|
-
const
|
|
198
|
-
|
|
348
|
+
const b = d.data ?? null;
|
|
349
|
+
g(w(b));
|
|
199
350
|
});
|
|
200
351
|
return () => {
|
|
201
|
-
|
|
352
|
+
c = !0, p();
|
|
202
353
|
};
|
|
203
|
-
},
|
|
204
|
-
const o =
|
|
205
|
-
return o &&
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
354
|
+
}, $e = async (o, c, l) => {
|
|
355
|
+
const u = o[0], g = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail";
|
|
356
|
+
return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? (U(), Ke(l) && await $(), l) : o.length === 1 && u && Ve.has(u) ? (U(), R(l) || await $(), l) : Ye(o, c) && !R(l) ? (U(), await $(), l) : o.length === 1 && u === "changeEmail" && !R(l) ? (await $(), l) : ((u === "signIn" || u === "signUp" || g) && xe(l) ? (U(), await $()) : (u === "signIn" || u === "signUp") && We(l) || u === "signUp" && Ge(l) ? q(o) : u === "verifyEmail" && !R(l) && (q(o), await Re()), l);
|
|
357
|
+
}, te = /* @__PURE__ */ new WeakMap(), se = (o, c) => {
|
|
358
|
+
if (!o || typeof o != "object" && typeof o != "function")
|
|
359
|
+
return o;
|
|
360
|
+
const l = te.get(o);
|
|
361
|
+
if (l)
|
|
362
|
+
return l;
|
|
363
|
+
const u = new Proxy(o, {
|
|
364
|
+
get(g, f, p) {
|
|
365
|
+
if (c.length === 0) {
|
|
366
|
+
if (f === "requireSession")
|
|
367
|
+
return L;
|
|
368
|
+
if (f === "onSessionChange")
|
|
369
|
+
return Ae;
|
|
370
|
+
if (f === _e)
|
|
371
|
+
return () => {
|
|
372
|
+
_(e);
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
const d = Reflect.get(g, f, p);
|
|
376
|
+
return typeof f != "string" ? d : se(d, [...c, f]);
|
|
377
|
+
},
|
|
378
|
+
apply(g, f, p) {
|
|
379
|
+
const d = Reflect.apply(
|
|
380
|
+
g,
|
|
381
|
+
f,
|
|
382
|
+
p
|
|
383
|
+
);
|
|
384
|
+
return Je(d) ? Promise.resolve(d).then(
|
|
385
|
+
(b) => $e(c, p, b)
|
|
386
|
+
) : d;
|
|
228
387
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
388
|
+
});
|
|
389
|
+
return te.set(o, u), u;
|
|
390
|
+
};
|
|
391
|
+
return se(t, []);
|
|
232
392
|
}
|
|
233
|
-
function
|
|
234
|
-
return
|
|
393
|
+
function Xe() {
|
|
394
|
+
return Ce({ disableDefaultRedirectPlugin: !0 });
|
|
235
395
|
}
|
|
236
|
-
function
|
|
396
|
+
function B(t) {
|
|
237
397
|
const e = (() => {
|
|
238
398
|
if (t instanceof URL)
|
|
239
399
|
return t;
|
|
240
400
|
const s = t.trim();
|
|
241
401
|
if (!s)
|
|
242
|
-
throw new
|
|
402
|
+
throw new m("redirectTo must not be an empty string.");
|
|
243
403
|
try {
|
|
244
404
|
return new URL(s, window.location.href);
|
|
245
405
|
} catch {
|
|
246
|
-
throw new
|
|
406
|
+
throw new m(
|
|
247
407
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
248
408
|
);
|
|
249
409
|
}
|
|
250
410
|
})();
|
|
251
411
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
252
|
-
throw new
|
|
412
|
+
throw new m(
|
|
253
413
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
254
414
|
);
|
|
255
415
|
return e;
|
|
256
416
|
}
|
|
257
|
-
function
|
|
417
|
+
function et(t, e) {
|
|
258
418
|
return e ? {
|
|
259
419
|
common: { ...t.common, ...e.common },
|
|
260
420
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -266,7 +426,7 @@ function Ie(t, e) {
|
|
|
266
426
|
errors: { ...t.errors, ...e.errors }
|
|
267
427
|
} : t;
|
|
268
428
|
}
|
|
269
|
-
const
|
|
429
|
+
const F = {
|
|
270
430
|
common: {
|
|
271
431
|
loading: "Loading sign-in…",
|
|
272
432
|
redirecting: "Redirecting…",
|
|
@@ -329,7 +489,7 @@ const B = {
|
|
|
329
489
|
invalidCode: "Enter the 6-digit verification code.",
|
|
330
490
|
generic: "Something went wrong. Please try again."
|
|
331
491
|
}
|
|
332
|
-
},
|
|
492
|
+
}, j = {
|
|
333
493
|
common: {
|
|
334
494
|
loading: "加载中…",
|
|
335
495
|
redirecting: "跳转中…",
|
|
@@ -392,7 +552,7 @@ const B = {
|
|
|
392
552
|
invalidCode: "请输入 6 位验证码",
|
|
393
553
|
generic: "出现错误,请稍后重试"
|
|
394
554
|
}
|
|
395
|
-
},
|
|
555
|
+
}, le = {
|
|
396
556
|
common: {
|
|
397
557
|
loading: "サインインを読み込み中…",
|
|
398
558
|
redirecting: "リダイレクト中…",
|
|
@@ -455,7 +615,7 @@ const B = {
|
|
|
455
615
|
invalidCode: "6桁の認証コードを入力してください",
|
|
456
616
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
457
617
|
}
|
|
458
|
-
},
|
|
618
|
+
}, de = {
|
|
459
619
|
common: {
|
|
460
620
|
loading: "로그인 로딩 중…",
|
|
461
621
|
redirecting: "리디렉션 중…",
|
|
@@ -518,7 +678,7 @@ const B = {
|
|
|
518
678
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
519
679
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
520
680
|
}
|
|
521
|
-
},
|
|
681
|
+
}, x = {
|
|
522
682
|
common: {
|
|
523
683
|
loading: "Cargando inicio de sesión…",
|
|
524
684
|
redirecting: "Redirigiendo…",
|
|
@@ -581,7 +741,7 @@ const B = {
|
|
|
581
741
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
582
742
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
583
743
|
}
|
|
584
|
-
},
|
|
744
|
+
}, ce = {
|
|
585
745
|
common: {
|
|
586
746
|
loading: "Carregando login…",
|
|
587
747
|
redirecting: "Redirecionando…",
|
|
@@ -644,7 +804,7 @@ const B = {
|
|
|
644
804
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
645
805
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
646
806
|
}
|
|
647
|
-
},
|
|
807
|
+
}, ue = {
|
|
648
808
|
common: {
|
|
649
809
|
loading: "Chargement de la connexion…",
|
|
650
810
|
redirecting: "Redirection…",
|
|
@@ -707,7 +867,7 @@ const B = {
|
|
|
707
867
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
708
868
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
709
869
|
}
|
|
710
|
-
},
|
|
870
|
+
}, he = {
|
|
711
871
|
common: {
|
|
712
872
|
loading: "Anmeldung wird geladen…",
|
|
713
873
|
redirecting: "Weiterleitung…",
|
|
@@ -770,7 +930,7 @@ const B = {
|
|
|
770
930
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
771
931
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
772
932
|
}
|
|
773
|
-
},
|
|
933
|
+
}, me = {
|
|
774
934
|
common: {
|
|
775
935
|
loading: "Caricamento accesso…",
|
|
776
936
|
redirecting: "Reindirizzamento…",
|
|
@@ -833,7 +993,7 @@ const B = {
|
|
|
833
993
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
834
994
|
generic: "Qualcosa è andato storto. Riprova."
|
|
835
995
|
}
|
|
836
|
-
},
|
|
996
|
+
}, fe = {
|
|
837
997
|
common: {
|
|
838
998
|
loading: "Загрузка входа…",
|
|
839
999
|
redirecting: "Перенаправление…",
|
|
@@ -896,7 +1056,7 @@ const B = {
|
|
|
896
1056
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
897
1057
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
898
1058
|
}
|
|
899
|
-
},
|
|
1059
|
+
}, we = {
|
|
900
1060
|
common: {
|
|
901
1061
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
902
1062
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -959,7 +1119,7 @@ const B = {
|
|
|
959
1119
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
960
1120
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
961
1121
|
}
|
|
962
|
-
},
|
|
1122
|
+
}, ge = {
|
|
963
1123
|
common: {
|
|
964
1124
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
965
1125
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -1022,62 +1182,62 @@ const B = {
|
|
|
1022
1182
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
1023
1183
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1024
1184
|
}
|
|
1025
|
-
},
|
|
1026
|
-
en:
|
|
1027
|
-
"en-US":
|
|
1028
|
-
zh:
|
|
1029
|
-
"zh-CN":
|
|
1030
|
-
"zh-TW":
|
|
1031
|
-
ja:
|
|
1032
|
-
"ja-JP":
|
|
1033
|
-
ko:
|
|
1034
|
-
"ko-KR":
|
|
1035
|
-
es:
|
|
1036
|
-
"es-ES":
|
|
1037
|
-
"es-MX":
|
|
1038
|
-
pt:
|
|
1039
|
-
"pt-BR":
|
|
1040
|
-
fr:
|
|
1041
|
-
"fr-FR":
|
|
1042
|
-
de:
|
|
1043
|
-
"de-DE":
|
|
1044
|
-
it:
|
|
1045
|
-
"it-IT":
|
|
1046
|
-
ru:
|
|
1047
|
-
"ru-RU":
|
|
1048
|
-
ar:
|
|
1049
|
-
"ar-SA":
|
|
1050
|
-
hi:
|
|
1051
|
-
"hi-IN":
|
|
1185
|
+
}, pe = {
|
|
1186
|
+
en: F,
|
|
1187
|
+
"en-US": F,
|
|
1188
|
+
zh: j,
|
|
1189
|
+
"zh-CN": j,
|
|
1190
|
+
"zh-TW": j,
|
|
1191
|
+
ja: le,
|
|
1192
|
+
"ja-JP": le,
|
|
1193
|
+
ko: de,
|
|
1194
|
+
"ko-KR": de,
|
|
1195
|
+
es: x,
|
|
1196
|
+
"es-ES": x,
|
|
1197
|
+
"es-MX": x,
|
|
1198
|
+
pt: ce,
|
|
1199
|
+
"pt-BR": ce,
|
|
1200
|
+
fr: ue,
|
|
1201
|
+
"fr-FR": ue,
|
|
1202
|
+
de: he,
|
|
1203
|
+
"de-DE": he,
|
|
1204
|
+
it: me,
|
|
1205
|
+
"it-IT": me,
|
|
1206
|
+
ru: fe,
|
|
1207
|
+
"ru-RU": fe,
|
|
1208
|
+
ar: we,
|
|
1209
|
+
"ar-SA": we,
|
|
1210
|
+
hi: ge,
|
|
1211
|
+
"hi-IN": ge
|
|
1052
1212
|
};
|
|
1053
|
-
function
|
|
1213
|
+
function tt() {
|
|
1054
1214
|
if (typeof navigator > "u")
|
|
1055
|
-
return
|
|
1215
|
+
return F;
|
|
1056
1216
|
const t = navigator.languages ?? [navigator.language];
|
|
1057
1217
|
for (const e of t) {
|
|
1058
|
-
const s =
|
|
1218
|
+
const s = pe[e] ?? pe[e.split("-")[0]];
|
|
1059
1219
|
if (s) return s;
|
|
1060
1220
|
}
|
|
1061
|
-
return
|
|
1221
|
+
return F;
|
|
1062
1222
|
}
|
|
1063
|
-
function
|
|
1064
|
-
if (t instanceof
|
|
1223
|
+
function W(t, e = "Authentication failed.") {
|
|
1224
|
+
if (t instanceof y)
|
|
1065
1225
|
return t;
|
|
1066
1226
|
if (typeof t == "object" && t !== null) {
|
|
1067
1227
|
const s = t;
|
|
1068
|
-
return new
|
|
1228
|
+
return new y(s.message || e, {
|
|
1069
1229
|
code: s.code,
|
|
1070
1230
|
status: s.status,
|
|
1071
1231
|
cause: t
|
|
1072
1232
|
});
|
|
1073
1233
|
}
|
|
1074
|
-
return typeof t == "string" ? new
|
|
1234
|
+
return typeof t == "string" ? new y(t) : new y(e, { cause: t });
|
|
1075
1235
|
}
|
|
1076
|
-
async function
|
|
1236
|
+
async function k(t) {
|
|
1077
1237
|
var s, i;
|
|
1078
1238
|
const e = await t.getSession();
|
|
1079
1239
|
if (e.error)
|
|
1080
|
-
throw new
|
|
1240
|
+
throw new y(
|
|
1081
1241
|
e.error.message || "Failed to load the current session.",
|
|
1082
1242
|
{
|
|
1083
1243
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1093,7 +1253,7 @@ async function C(t) {
|
|
|
1093
1253
|
session: null
|
|
1094
1254
|
};
|
|
1095
1255
|
}
|
|
1096
|
-
const
|
|
1256
|
+
const st = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion", M = "es_auth_email", be = "oauth", O = "verify-sign-in", I = "verify-sign-up", ye = 200, Y = 2, K = {
|
|
1097
1257
|
google: "Google",
|
|
1098
1258
|
apple: "Apple",
|
|
1099
1259
|
microsoft: "Microsoft",
|
|
@@ -1101,24 +1261,27 @@ const $e = "data-edgespark-auth", n = "edgespark-auth", z = "es_auth_completion"
|
|
|
1101
1261
|
gitlab: "GitLab",
|
|
1102
1262
|
discord: "Discord"
|
|
1103
1263
|
};
|
|
1104
|
-
function
|
|
1264
|
+
function C(t) {
|
|
1105
1265
|
return "redirectTo" in t;
|
|
1106
1266
|
}
|
|
1107
|
-
function
|
|
1267
|
+
function J(t) {
|
|
1108
1268
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1109
1269
|
}
|
|
1110
|
-
function
|
|
1270
|
+
function Z(t) {
|
|
1111
1271
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1112
1272
|
}
|
|
1113
|
-
function
|
|
1273
|
+
function it(t) {
|
|
1114
1274
|
return /^\d{6}$/.test(t.trim());
|
|
1115
1275
|
}
|
|
1116
|
-
function
|
|
1276
|
+
function nt(t) {
|
|
1117
1277
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1118
1278
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1279
|
+
function rt(t) {
|
|
1280
|
+
return !!(t.error || t.errorDescription);
|
|
1281
|
+
}
|
|
1282
|
+
class ot {
|
|
1283
|
+
constructor(e, s, i, n, a) {
|
|
1284
|
+
if (this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
|
|
1122
1285
|
view: "loading",
|
|
1123
1286
|
busy: !0,
|
|
1124
1287
|
busyLabel: void 0,
|
|
@@ -1131,55 +1294,72 @@ class Be {
|
|
|
1131
1294
|
code: "",
|
|
1132
1295
|
newPassword: ""
|
|
1133
1296
|
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, !(e instanceof HTMLElement))
|
|
1134
|
-
throw new
|
|
1135
|
-
this.labels =
|
|
1297
|
+
throw new m("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1298
|
+
this.labels = et(tt(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(st, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1136
1299
|
}
|
|
1137
1300
|
destroy() {
|
|
1138
1301
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
1139
1302
|
}
|
|
1140
1303
|
async initialize() {
|
|
1304
|
+
const e = this.consumeManagedReturnContext();
|
|
1141
1305
|
try {
|
|
1142
|
-
const
|
|
1306
|
+
const [s, i] = await Promise.allSettled([
|
|
1143
1307
|
this.loadConfig(),
|
|
1144
1308
|
this.readMountSession(e)
|
|
1145
1309
|
]);
|
|
1146
1310
|
if (this.destroyed)
|
|
1147
1311
|
return;
|
|
1148
|
-
if (
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1312
|
+
if (i.status === "rejected") {
|
|
1313
|
+
if (e.marker && !rt(e) && C(this.options)) {
|
|
1314
|
+
this.redirectAfterManagedReturnLookupFailure();
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
} else {
|
|
1318
|
+
const a = i.value;
|
|
1319
|
+
if (a.user && a.session) {
|
|
1320
|
+
switch (e.marker) {
|
|
1321
|
+
case be:
|
|
1322
|
+
case O:
|
|
1323
|
+
await this.completeAuth("sign-in", a);
|
|
1324
|
+
return;
|
|
1325
|
+
case I:
|
|
1326
|
+
await this.completeAuth("sign-up", a);
|
|
1327
|
+
return;
|
|
1328
|
+
default:
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
this.handleExistingSessionOnMount(a);
|
|
1332
|
+
return;
|
|
1159
1333
|
}
|
|
1160
|
-
this.handleExistingSessionOnMount(i);
|
|
1161
|
-
return;
|
|
1162
1334
|
}
|
|
1163
|
-
if (
|
|
1335
|
+
if (s.status === "rejected")
|
|
1336
|
+
throw i.status === "rejected" ? i.reason : s.reason;
|
|
1337
|
+
if (this.config = s.value, this.handleSessionlessManagedReturn(e))
|
|
1164
1338
|
return;
|
|
1339
|
+
if (i.status === "rejected")
|
|
1340
|
+
throw i.reason;
|
|
1341
|
+
const n = i.value;
|
|
1165
1342
|
this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.render();
|
|
1166
|
-
} catch (
|
|
1167
|
-
this.handleError(
|
|
1343
|
+
} catch (s) {
|
|
1344
|
+
this.handleError(s, "Failed to load the authentication UI.");
|
|
1168
1345
|
}
|
|
1169
1346
|
}
|
|
1347
|
+
redirectAfterManagedReturnLookupFailure() {
|
|
1348
|
+
C(this.options) && (this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(B(this.options.redirectTo).toString()));
|
|
1349
|
+
}
|
|
1170
1350
|
async readMountSession(e) {
|
|
1171
1351
|
if (!e.marker)
|
|
1172
|
-
return
|
|
1352
|
+
return k(this.auth);
|
|
1173
1353
|
let s = null;
|
|
1174
|
-
for (let i = 0; i <=
|
|
1354
|
+
for (let i = 0; i <= Y; i++) {
|
|
1175
1355
|
try {
|
|
1176
|
-
const
|
|
1177
|
-
if (
|
|
1178
|
-
return
|
|
1179
|
-
} catch (
|
|
1180
|
-
s =
|
|
1356
|
+
const n = await k(this.auth);
|
|
1357
|
+
if (n.user && n.session)
|
|
1358
|
+
return n;
|
|
1359
|
+
} catch (n) {
|
|
1360
|
+
s = n;
|
|
1181
1361
|
}
|
|
1182
|
-
i <
|
|
1362
|
+
i < Y && await new Promise((n) => setTimeout(n, ye));
|
|
1183
1363
|
}
|
|
1184
1364
|
if (s)
|
|
1185
1365
|
throw s;
|
|
@@ -1197,8 +1377,8 @@ class Be {
|
|
|
1197
1377
|
return;
|
|
1198
1378
|
}
|
|
1199
1379
|
this.root.innerHTML = `
|
|
1200
|
-
<div class="${
|
|
1201
|
-
<div class="${
|
|
1380
|
+
<div class="${r}__shell">
|
|
1381
|
+
<div class="${r}__card">
|
|
1202
1382
|
${this.renderStatus()}
|
|
1203
1383
|
${this.renderCurrentView()}
|
|
1204
1384
|
</div>
|
|
@@ -1208,9 +1388,9 @@ class Be {
|
|
|
1208
1388
|
renderLoading() {
|
|
1209
1389
|
const e = this.renderStatus();
|
|
1210
1390
|
return `
|
|
1211
|
-
<div class="${
|
|
1212
|
-
<div class="${
|
|
1213
|
-
${e || `<div class="${
|
|
1391
|
+
<div class="${r}__shell">
|
|
1392
|
+
<div class="${r}__card">
|
|
1393
|
+
${e || `<div class="${r}__status ${r}__status--info">${this.escape(this.labels.common.loading)}</div>`}
|
|
1214
1394
|
</div>
|
|
1215
1395
|
</div>
|
|
1216
1396
|
`;
|
|
@@ -1218,11 +1398,11 @@ class Be {
|
|
|
1218
1398
|
renderStatus() {
|
|
1219
1399
|
const e = [];
|
|
1220
1400
|
return this.state.error && e.push(
|
|
1221
|
-
`<div class="${
|
|
1401
|
+
`<div class="${r}__status ${r}__status--error">${this.escape(this.state.error)}</div>`
|
|
1222
1402
|
), this.state.notice && e.push(
|
|
1223
|
-
`<div class="${
|
|
1403
|
+
`<div class="${r}__status ${r}__status--info">${this.escape(this.state.notice)}</div>`
|
|
1224
1404
|
), this.state.busy && this.state.busyLabel && e.push(
|
|
1225
|
-
`<div class="${
|
|
1405
|
+
`<div class="${r}__status ${r}__status--muted">${this.escape(this.state.busyLabel)}</div>`
|
|
1226
1406
|
), e.join("");
|
|
1227
1407
|
}
|
|
1228
1408
|
renderCurrentView() {
|
|
@@ -1239,38 +1419,38 @@ class Be {
|
|
|
1239
1419
|
return this.renderResetPasswordView();
|
|
1240
1420
|
case "loading":
|
|
1241
1421
|
default:
|
|
1242
|
-
return `<p class="${
|
|
1422
|
+
return `<p class="${r}__copy">${this.escape(this.labels.common.loading)}</p>`;
|
|
1243
1423
|
}
|
|
1244
1424
|
}
|
|
1245
1425
|
renderSignInView() {
|
|
1246
|
-
var i,
|
|
1426
|
+
var i, n;
|
|
1247
1427
|
const e = this.renderOAuthProviders(), s = ((i = this.config) == null ? void 0 : i.emailPasswordEnabled) ?? !0;
|
|
1248
1428
|
return `
|
|
1249
|
-
<section class="${
|
|
1250
|
-
<header class="${
|
|
1251
|
-
<h1 class="${
|
|
1252
|
-
<p class="${
|
|
1429
|
+
<section class="${r}__section">
|
|
1430
|
+
<header class="${r}__header">
|
|
1431
|
+
<h1 class="${r}__title">${this.escape(this.labels.signIn.title)}</h1>
|
|
1432
|
+
<p class="${r}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
|
|
1253
1433
|
</header>
|
|
1254
1434
|
${e}
|
|
1255
|
-
${e && s ? `<div class="${
|
|
1435
|
+
${e && s ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
|
|
1256
1436
|
${s ? `
|
|
1257
|
-
<form class="${
|
|
1437
|
+
<form class="${r}__form" data-view="sign-in" novalidate>
|
|
1258
1438
|
${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
|
|
1259
1439
|
${this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
|
|
1260
|
-
<button class="${
|
|
1440
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
|
|
1261
1441
|
${this.escape(this.labels.signIn.submitButton)}
|
|
1262
1442
|
</button>
|
|
1263
1443
|
</form>
|
|
1264
|
-
<div class="${
|
|
1444
|
+
<div class="${r}__actions">
|
|
1265
1445
|
${this.canUsePasswordResetEmailOtp() ? `
|
|
1266
|
-
<button class="${
|
|
1446
|
+
<button class="${r}__link" type="button" data-action="forgot-password" ${this.state.busy ? "disabled" : ""}>
|
|
1267
1447
|
${this.escape(this.labels.signIn.forgotPassword)}
|
|
1268
1448
|
</button>
|
|
1269
1449
|
` : ""}
|
|
1270
|
-
${(
|
|
1271
|
-
<p class="${
|
|
1450
|
+
${(n = this.config) != null && n.disableSignUp ? "" : `
|
|
1451
|
+
<p class="${r}__meta">
|
|
1272
1452
|
${this.escape(this.labels.signIn.signUpPrompt)}
|
|
1273
|
-
<button class="${
|
|
1453
|
+
<button class="${r}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
|
|
1274
1454
|
${this.escape(this.labels.signIn.switchToSignUp)}
|
|
1275
1455
|
</button>
|
|
1276
1456
|
</p>
|
|
@@ -1283,25 +1463,25 @@ class Be {
|
|
|
1283
1463
|
renderSignUpView() {
|
|
1284
1464
|
const e = this.renderOAuthProviders();
|
|
1285
1465
|
return `
|
|
1286
|
-
<section class="${
|
|
1287
|
-
<header class="${
|
|
1288
|
-
<h1 class="${
|
|
1289
|
-
<p class="${
|
|
1466
|
+
<section class="${r}__section">
|
|
1467
|
+
<header class="${r}__header">
|
|
1468
|
+
<h1 class="${r}__title">${this.escape(this.labels.signUp.title)}</h1>
|
|
1469
|
+
<p class="${r}__copy">${this.escape(this.labels.signUp.subtitle)}</p>
|
|
1290
1470
|
</header>
|
|
1291
1471
|
${e}
|
|
1292
|
-
${e ? `<div class="${
|
|
1293
|
-
<form class="${
|
|
1472
|
+
${e ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
|
|
1473
|
+
<form class="${r}__form" data-view="sign-up" novalidate>
|
|
1294
1474
|
${this.renderInput("name", this.labels.signUp.nameLabel, "text", this.state.name, "name")}
|
|
1295
1475
|
${this.renderInput("email", this.labels.signUp.emailLabel, "email", this.state.email, "email")}
|
|
1296
1476
|
${this.renderInput("password", this.labels.signUp.passwordLabel, "password", this.state.password, "new-password")}
|
|
1297
1477
|
${this.renderInput("confirmPassword", this.labels.signUp.confirmPasswordLabel, "password", this.state.confirmPassword, "new-password")}
|
|
1298
|
-
<button class="${
|
|
1478
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
|
|
1299
1479
|
${this.escape(this.labels.signUp.submitButton)}
|
|
1300
1480
|
</button>
|
|
1301
1481
|
</form>
|
|
1302
|
-
<p class="${
|
|
1482
|
+
<p class="${r}__meta">
|
|
1303
1483
|
${this.escape(this.labels.signUp.signInPrompt)}
|
|
1304
|
-
<button class="${
|
|
1484
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
|
|
1305
1485
|
${this.escape(this.labels.signUp.switchToSignIn)}
|
|
1306
1486
|
</button>
|
|
1307
1487
|
</p>
|
|
@@ -1314,20 +1494,20 @@ class Be {
|
|
|
1314
1494
|
this.labels.verifyEmail.resendCountdown
|
|
1315
1495
|
);
|
|
1316
1496
|
return `
|
|
1317
|
-
<section class="${
|
|
1318
|
-
<header class="${
|
|
1319
|
-
<h1 class="${
|
|
1320
|
-
<p class="${
|
|
1497
|
+
<section class="${r}__section">
|
|
1498
|
+
<header class="${r}__header">
|
|
1499
|
+
<h1 class="${r}__title">${this.escape(this.labels.verifyEmail.title)}</h1>
|
|
1500
|
+
<p class="${r}__copy">${this.escape(this.labels.verifyEmail.subtitle)}</p>
|
|
1321
1501
|
</header>
|
|
1322
|
-
<p class="${
|
|
1502
|
+
<p class="${r}__copy">
|
|
1323
1503
|
<strong>${this.escape(this.labels.verifyEmail.sentToLabel)}:</strong>
|
|
1324
1504
|
${this.escape(this.state.email)}
|
|
1325
1505
|
</p>
|
|
1326
|
-
<div class="${
|
|
1327
|
-
<button class="${
|
|
1506
|
+
<div class="${r}__stack">
|
|
1507
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-verification" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
|
|
1328
1508
|
${this.escape(e)}
|
|
1329
1509
|
</button>
|
|
1330
|
-
<button class="${
|
|
1510
|
+
<button class="${r}__link" type="button" data-action="use-different-email" ${this.state.busy ? "disabled" : ""}>
|
|
1331
1511
|
${this.escape(this.labels.verifyEmail.changeEmailButton)}
|
|
1332
1512
|
</button>
|
|
1333
1513
|
</div>
|
|
@@ -1336,18 +1516,18 @@ class Be {
|
|
|
1336
1516
|
}
|
|
1337
1517
|
renderForgotPasswordView() {
|
|
1338
1518
|
return `
|
|
1339
|
-
<section class="${
|
|
1340
|
-
<header class="${
|
|
1341
|
-
<h1 class="${
|
|
1342
|
-
<p class="${
|
|
1519
|
+
<section class="${r}__section">
|
|
1520
|
+
<header class="${r}__header">
|
|
1521
|
+
<h1 class="${r}__title">${this.escape(this.labels.forgotPassword.title)}</h1>
|
|
1522
|
+
<p class="${r}__copy">${this.escape(this.labels.forgotPassword.subtitle)}</p>
|
|
1343
1523
|
</header>
|
|
1344
|
-
<form class="${
|
|
1524
|
+
<form class="${r}__form" data-view="forgot-password" novalidate>
|
|
1345
1525
|
${this.renderInput("email", this.labels.forgotPassword.emailLabel, "email", this.state.email, "email")}
|
|
1346
|
-
<button class="${
|
|
1526
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
|
|
1347
1527
|
${this.escape(this.labels.forgotPassword.submitButton)}
|
|
1348
1528
|
</button>
|
|
1349
1529
|
</form>
|
|
1350
|
-
<button class="${
|
|
1530
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
|
|
1351
1531
|
${this.escape(this.labels.common.backToSignIn)}
|
|
1352
1532
|
</button>
|
|
1353
1533
|
</section>
|
|
@@ -1359,23 +1539,23 @@ class Be {
|
|
|
1359
1539
|
this.labels.resetPassword.resendCountdown
|
|
1360
1540
|
);
|
|
1361
1541
|
return `
|
|
1362
|
-
<section class="${
|
|
1363
|
-
<header class="${
|
|
1364
|
-
<h1 class="${
|
|
1365
|
-
<p class="${
|
|
1542
|
+
<section class="${r}__section">
|
|
1543
|
+
<header class="${r}__header">
|
|
1544
|
+
<h1 class="${r}__title">${this.escape(this.labels.resetPassword.title)}</h1>
|
|
1545
|
+
<p class="${r}__copy">${this.escape(this.labels.resetPassword.subtitle)}</p>
|
|
1366
1546
|
</header>
|
|
1367
|
-
<form class="${
|
|
1547
|
+
<form class="${r}__form" data-view="reset-password" novalidate>
|
|
1368
1548
|
${this.renderInput("code", this.labels.resetPassword.codeLabel, "text", this.state.code, "one-time-code")}
|
|
1369
1549
|
${this.renderInput("newPassword", this.labels.resetPassword.newPasswordLabel, "password", this.state.newPassword, "new-password")}
|
|
1370
1550
|
${this.renderInput("confirmPassword", this.labels.resetPassword.confirmPasswordLabel, "password", this.state.confirmPassword, "new-password")}
|
|
1371
|
-
<button class="${
|
|
1551
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
|
|
1372
1552
|
${this.escape(this.labels.resetPassword.submitButton)}
|
|
1373
1553
|
</button>
|
|
1374
1554
|
</form>
|
|
1375
|
-
<button class="${
|
|
1555
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-reset-code" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
|
|
1376
1556
|
${this.escape(e)}
|
|
1377
1557
|
</button>
|
|
1378
|
-
<button class="${
|
|
1558
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
|
|
1379
1559
|
${this.escape(this.labels.common.backToSignIn)}
|
|
1380
1560
|
</button>
|
|
1381
1561
|
</section>
|
|
@@ -1385,24 +1565,24 @@ class Be {
|
|
|
1385
1565
|
var s;
|
|
1386
1566
|
const e = ((s = this.config) == null ? void 0 : s.oauthProviders) ?? [];
|
|
1387
1567
|
return e.length === 0 ? "" : `
|
|
1388
|
-
<div class="${
|
|
1568
|
+
<div class="${r}__stack">
|
|
1389
1569
|
${e.map((i) => `
|
|
1390
|
-
<button class="${
|
|
1391
|
-
${this.escape(`${this.labels.oauth.continueWith} ${
|
|
1570
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
|
|
1571
|
+
${this.escape(`${this.labels.oauth.continueWith} ${K[i]}`)}
|
|
1392
1572
|
</button>
|
|
1393
1573
|
`).join("")}
|
|
1394
1574
|
</div>
|
|
1395
1575
|
`;
|
|
1396
1576
|
}
|
|
1397
|
-
renderInput(e, s, i,
|
|
1577
|
+
renderInput(e, s, i, n, a) {
|
|
1398
1578
|
return `
|
|
1399
|
-
<label class="${
|
|
1400
|
-
<span class="${
|
|
1579
|
+
<label class="${r}__field">
|
|
1580
|
+
<span class="${r}__label">${this.escape(s)}</span>
|
|
1401
1581
|
<input
|
|
1402
|
-
class="${
|
|
1582
|
+
class="${r}__input"
|
|
1403
1583
|
name="${this.escape(e)}"
|
|
1404
1584
|
type="${this.escape(i)}"
|
|
1405
|
-
value="${this.escape(
|
|
1585
|
+
value="${this.escape(n)}"
|
|
1406
1586
|
autocomplete="${this.escape(a)}"
|
|
1407
1587
|
${this.state.busy ? "disabled" : ""}
|
|
1408
1588
|
/>
|
|
@@ -1410,20 +1590,20 @@ class Be {
|
|
|
1410
1590
|
`;
|
|
1411
1591
|
}
|
|
1412
1592
|
bindDOM() {
|
|
1413
|
-
this.root.querySelectorAll("form[data-view]").forEach((
|
|
1414
|
-
|
|
1593
|
+
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1594
|
+
n.addEventListener("submit", (a) => {
|
|
1415
1595
|
a.preventDefault();
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1596
|
+
const h = n.dataset.view;
|
|
1597
|
+
h === "sign-in" && this.handleSignIn(), h === "sign-up" && this.handleSignUp(), h === "forgot-password" && this.handleForgotPassword(), h === "reset-password" && this.handleResetPassword();
|
|
1418
1598
|
});
|
|
1419
|
-
}), this.root.querySelectorAll("input[name]").forEach((
|
|
1420
|
-
|
|
1421
|
-
|
|
1599
|
+
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1600
|
+
n.addEventListener("input", () => {
|
|
1601
|
+
nt(n.name) && (this.state[n.name] = n.value);
|
|
1422
1602
|
});
|
|
1423
|
-
}), this.root.querySelectorAll("[data-action]").forEach((
|
|
1424
|
-
|
|
1425
|
-
const a =
|
|
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(
|
|
1603
|
+
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1604
|
+
n.addEventListener("click", () => {
|
|
1605
|
+
const a = n.dataset.action;
|
|
1606
|
+
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(n.dataset.provider);
|
|
1427
1607
|
});
|
|
1428
1608
|
});
|
|
1429
1609
|
}
|
|
@@ -1431,7 +1611,7 @@ class Be {
|
|
|
1431
1611
|
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();
|
|
1432
1612
|
}
|
|
1433
1613
|
async handleSignIn() {
|
|
1434
|
-
if (!
|
|
1614
|
+
if (!Z(this.state.email)) {
|
|
1435
1615
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1436
1616
|
return;
|
|
1437
1617
|
}
|
|
@@ -1443,7 +1623,7 @@ class Be {
|
|
|
1443
1623
|
const e = await this.auth.signIn.email({
|
|
1444
1624
|
email: this.state.email.trim(),
|
|
1445
1625
|
password: this.state.password,
|
|
1446
|
-
callbackURL: this.getManagedReturnURL(
|
|
1626
|
+
callbackURL: this.getManagedReturnURL(O, this.state.email.trim())
|
|
1447
1627
|
});
|
|
1448
1628
|
if (e.error)
|
|
1449
1629
|
throw e.error;
|
|
@@ -1456,7 +1636,7 @@ class Be {
|
|
|
1456
1636
|
this.failValidation(this.labels.errors.requiredField);
|
|
1457
1637
|
return;
|
|
1458
1638
|
}
|
|
1459
|
-
if (!
|
|
1639
|
+
if (!Z(this.state.email)) {
|
|
1460
1640
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1461
1641
|
return;
|
|
1462
1642
|
}
|
|
@@ -1475,16 +1655,16 @@ class Be {
|
|
|
1475
1655
|
return;
|
|
1476
1656
|
}
|
|
1477
1657
|
await this.runAction("Creating account…", async () => {
|
|
1478
|
-
var
|
|
1658
|
+
var n;
|
|
1479
1659
|
const i = await this.auth.signUp.email({
|
|
1480
1660
|
name: this.state.name.trim(),
|
|
1481
1661
|
email: this.state.email.trim(),
|
|
1482
1662
|
password: this.state.password,
|
|
1483
|
-
callbackURL: this.getManagedReturnURL(
|
|
1663
|
+
callbackURL: this.getManagedReturnURL(I, this.state.email.trim())
|
|
1484
1664
|
});
|
|
1485
1665
|
if (i.error)
|
|
1486
1666
|
throw i.error;
|
|
1487
|
-
if ((
|
|
1667
|
+
if ((n = this.config) != null && n.requireEmailVerification) {
|
|
1488
1668
|
this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = "Check your inbox to verify your email address.", this.startCountdown();
|
|
1489
1669
|
return;
|
|
1490
1670
|
}
|
|
@@ -1492,7 +1672,7 @@ class Be {
|
|
|
1492
1672
|
});
|
|
1493
1673
|
}
|
|
1494
1674
|
async handleOAuthSignIn(e) {
|
|
1495
|
-
await this.runAction(`Redirecting to ${
|
|
1675
|
+
await this.runAction(`Redirecting to ${K[e]}…`, async () => {
|
|
1496
1676
|
const s = await this.auth.signIn.social({
|
|
1497
1677
|
provider: e,
|
|
1498
1678
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
@@ -1502,18 +1682,18 @@ class Be {
|
|
|
1502
1682
|
throw s.error;
|
|
1503
1683
|
const i = this.extractRedirectURL(s.data);
|
|
1504
1684
|
if (!i)
|
|
1505
|
-
throw new
|
|
1506
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
1685
|
+
throw new m(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1686
|
+
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${K[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1507
1687
|
});
|
|
1508
1688
|
}
|
|
1509
1689
|
async handleForgotPassword() {
|
|
1510
1690
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1511
1691
|
this.handleError(
|
|
1512
|
-
new
|
|
1692
|
+
new m("Password reset via email OTP is not enabled for this project.")
|
|
1513
1693
|
);
|
|
1514
1694
|
return;
|
|
1515
1695
|
}
|
|
1516
|
-
if (!
|
|
1696
|
+
if (!Z(this.state.email)) {
|
|
1517
1697
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1518
1698
|
return;
|
|
1519
1699
|
}
|
|
@@ -1533,11 +1713,11 @@ class Be {
|
|
|
1533
1713
|
var e, s;
|
|
1534
1714
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1535
1715
|
this.handleError(
|
|
1536
|
-
new
|
|
1716
|
+
new m("Password reset via email OTP is not enabled for this project.")
|
|
1537
1717
|
);
|
|
1538
1718
|
return;
|
|
1539
1719
|
}
|
|
1540
|
-
if (!
|
|
1720
|
+
if (!it(this.state.code)) {
|
|
1541
1721
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1542
1722
|
return;
|
|
1543
1723
|
}
|
|
@@ -1574,7 +1754,7 @@ class Be {
|
|
|
1574
1754
|
const s = await this.auth.sendVerificationEmail({
|
|
1575
1755
|
email: this.state.email.trim(),
|
|
1576
1756
|
callbackURL: this.getManagedReturnURL(
|
|
1577
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1757
|
+
this.verificationCompletionAction === "sign-up" ? I : O,
|
|
1578
1758
|
this.state.email.trim()
|
|
1579
1759
|
)
|
|
1580
1760
|
});
|
|
@@ -1587,47 +1767,53 @@ class Be {
|
|
|
1587
1767
|
const i = await this.retryAuthCompletionDataIfNeeded(
|
|
1588
1768
|
s ?? await this.resolveAuthCompletionData()
|
|
1589
1769
|
);
|
|
1770
|
+
if (this.destroyed)
|
|
1771
|
+
return;
|
|
1590
1772
|
if (!i.user || !i.session) {
|
|
1591
|
-
if (
|
|
1592
|
-
|
|
1773
|
+
if (this.destroyed)
|
|
1774
|
+
return;
|
|
1775
|
+
if (i.lookupError && C(this.options)) {
|
|
1776
|
+
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(B(this.options.redirectTo).toString());
|
|
1593
1777
|
return;
|
|
1594
1778
|
}
|
|
1595
1779
|
if (e === "sign-in")
|
|
1596
|
-
throw i.lookupError ?? new
|
|
1780
|
+
throw i.lookupError ?? new Se(
|
|
1597
1781
|
"Managed sign-in completed without an authenticated session."
|
|
1598
1782
|
);
|
|
1599
1783
|
this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render();
|
|
1600
1784
|
return;
|
|
1601
1785
|
}
|
|
1602
|
-
const
|
|
1786
|
+
const n = {
|
|
1603
1787
|
action: e,
|
|
1604
1788
|
user: i.user,
|
|
1605
1789
|
session: i.session
|
|
1606
1790
|
};
|
|
1607
|
-
if (await this.syncPublicSessionBestEffort(),
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1791
|
+
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1792
|
+
if (C(this.options)) {
|
|
1793
|
+
this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(n), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(B(this.options.redirectTo).toString());
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
if (J(this.options)) {
|
|
1797
|
+
this.options.onSuccess(n), this.terminalActionInProgress = !0;
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1614
1800
|
}
|
|
1615
1801
|
}
|
|
1616
1802
|
async retryAuthCompletionDataIfNeeded(e) {
|
|
1617
1803
|
if (e.session)
|
|
1618
1804
|
return e;
|
|
1619
1805
|
let s = e.lookupError;
|
|
1620
|
-
for (let i = 0; i <
|
|
1621
|
-
await new Promise((
|
|
1806
|
+
for (let i = 0; i < Y; i++) {
|
|
1807
|
+
await new Promise((n) => setTimeout(n, ye));
|
|
1622
1808
|
try {
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1809
|
+
const n = await k(this.auth);
|
|
1810
|
+
if (n.user && n.session)
|
|
1625
1811
|
return {
|
|
1626
|
-
user:
|
|
1627
|
-
session:
|
|
1812
|
+
user: n.user,
|
|
1813
|
+
session: n.session
|
|
1628
1814
|
};
|
|
1629
|
-
} catch (
|
|
1630
|
-
s =
|
|
1815
|
+
} catch (n) {
|
|
1816
|
+
s = n;
|
|
1631
1817
|
}
|
|
1632
1818
|
}
|
|
1633
1819
|
return {
|
|
@@ -1644,7 +1830,7 @@ class Be {
|
|
|
1644
1830
|
}
|
|
1645
1831
|
async resolveAuthCompletionData(e) {
|
|
1646
1832
|
try {
|
|
1647
|
-
const s = await
|
|
1833
|
+
const s = await k(this.auth), i = this.extractUser(e);
|
|
1648
1834
|
return {
|
|
1649
1835
|
user: s.user ?? i,
|
|
1650
1836
|
session: s.session
|
|
@@ -1663,19 +1849,21 @@ class Be {
|
|
|
1663
1849
|
user: null,
|
|
1664
1850
|
session: null
|
|
1665
1851
|
};
|
|
1666
|
-
if (
|
|
1667
|
-
|
|
1668
|
-
|
|
1852
|
+
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1853
|
+
if (J(this.options)) {
|
|
1854
|
+
this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
this.invokeRedirectModeSuccessHook(e), this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.newPassword = "", this.state.code = "", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = "Password updated. Sign in with your new password.", this.render();
|
|
1669
1858
|
}
|
|
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();
|
|
1671
1859
|
}
|
|
1672
1860
|
handleExistingSessionOnMount(e) {
|
|
1673
|
-
if (
|
|
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(
|
|
1861
|
+
if (C(this.options)) {
|
|
1862
|
+
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(B(this.options.redirectTo).toString());
|
|
1675
1863
|
return;
|
|
1676
1864
|
}
|
|
1677
|
-
if (
|
|
1678
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
1865
|
+
if (J(this.options))
|
|
1866
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new m(
|
|
1679
1867
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1680
1868
|
);
|
|
1681
1869
|
}
|
|
@@ -1692,18 +1880,18 @@ class Be {
|
|
|
1692
1880
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1693
1881
|
}
|
|
1694
1882
|
maybeHandleVerificationRequired(e) {
|
|
1695
|
-
return
|
|
1883
|
+
return W(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);
|
|
1696
1884
|
}
|
|
1697
1885
|
handleVerificationEmailSent(e, s) {
|
|
1698
1886
|
this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
1699
1887
|
}
|
|
1700
1888
|
invokeRedirectModeSuccessHook(e) {
|
|
1701
1889
|
var s, i;
|
|
1702
|
-
if (!(
|
|
1890
|
+
if (!(!C(this.options) || !this.options.onSuccess))
|
|
1703
1891
|
try {
|
|
1704
1892
|
this.options.onSuccess(e);
|
|
1705
|
-
} catch (
|
|
1706
|
-
const a =
|
|
1893
|
+
} catch (n) {
|
|
1894
|
+
const a = W(n, "Post-auth callback failed.");
|
|
1707
1895
|
try {
|
|
1708
1896
|
(i = (s = this.options).onError) == null || i.call(s, a);
|
|
1709
1897
|
} catch {
|
|
@@ -1711,9 +1899,9 @@ class Be {
|
|
|
1711
1899
|
}
|
|
1712
1900
|
}
|
|
1713
1901
|
handleError(e, s) {
|
|
1714
|
-
var
|
|
1715
|
-
const i =
|
|
1716
|
-
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (
|
|
1902
|
+
var n, a;
|
|
1903
|
+
const i = W(e, s);
|
|
1904
|
+
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (n = this.options).onError) == null || a.call(n, i);
|
|
1717
1905
|
}
|
|
1718
1906
|
failValidation(e) {
|
|
1719
1907
|
this.state.error = e, this.state.notice = null, this.render();
|
|
@@ -1722,14 +1910,14 @@ class Be {
|
|
|
1722
1910
|
if (!e)
|
|
1723
1911
|
return window.location.href;
|
|
1724
1912
|
const i = new URL(window.location.href);
|
|
1725
|
-
return i.searchParams.set(
|
|
1913
|
+
return i.searchParams.set(G, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
|
|
1726
1914
|
}
|
|
1727
1915
|
consumeManagedReturnContext() {
|
|
1728
|
-
const e = new URL(window.location.href), s = e.searchParams.get(
|
|
1729
|
-
return (s || i) && (e.searchParams.delete(
|
|
1916
|
+
const e = new URL(window.location.href), s = e.searchParams.get(G), i = e.searchParams.get(M), n = s ? e.searchParams.get("error") : null, a = s ? e.searchParams.get("error_description") : null;
|
|
1917
|
+
return (s || i) && (e.searchParams.delete(G), e.searchParams.delete(M), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1730
1918
|
marker: s,
|
|
1731
1919
|
email: i,
|
|
1732
|
-
error:
|
|
1920
|
+
error: n,
|
|
1733
1921
|
errorDescription: a
|
|
1734
1922
|
};
|
|
1735
1923
|
}
|
|
@@ -1764,8 +1952,8 @@ class Be {
|
|
|
1764
1952
|
try {
|
|
1765
1953
|
i.setSelectionRange(e.selectionStart, e.selectionEnd);
|
|
1766
1954
|
} catch {
|
|
1767
|
-
const
|
|
1768
|
-
i.setSelectionRange(
|
|
1955
|
+
const n = i.value.length;
|
|
1956
|
+
i.setSelectionRange(n, n);
|
|
1769
1957
|
}
|
|
1770
1958
|
this.pendingFocusSnapshot = null;
|
|
1771
1959
|
}
|
|
@@ -1794,10 +1982,10 @@ class Be {
|
|
|
1794
1982
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
1795
1983
|
}
|
|
1796
1984
|
handleSessionlessManagedReturn(e) {
|
|
1797
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
1985
|
+
return e.email && (this.state.email = e.email), e.marker === I && !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 === O || e.marker === I ? (this.verificationCompletionAction = e.marker === I ? "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 y(
|
|
1798
1986
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
1799
1987
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
1800
|
-
)) : this.render(), !0) : e.marker ===
|
|
1988
|
+
)) : this.render(), !0) : e.marker === be && (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 y(
|
|
1801
1989
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
1802
1990
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
1803
1991
|
)), !0) : !1;
|
|
@@ -1816,103 +2004,103 @@ class Be {
|
|
|
1816
2004
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1817
2005
|
}
|
|
1818
2006
|
}
|
|
1819
|
-
function
|
|
2007
|
+
function at(t) {
|
|
1820
2008
|
return "data" in t && t.data ? t.data : t;
|
|
1821
2009
|
}
|
|
1822
|
-
const
|
|
2010
|
+
const lt = [
|
|
1823
2011
|
{ id: "google", key: "providerGoogle" },
|
|
1824
2012
|
{ id: "apple", key: "providerApple" },
|
|
1825
2013
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
1826
2014
|
{ id: "github", key: "providerGithub" },
|
|
1827
2015
|
{ id: "gitlab", key: "providerGitlab" },
|
|
1828
2016
|
{ id: "discord", key: "providerDiscord" }
|
|
1829
|
-
],
|
|
1830
|
-
async function
|
|
1831
|
-
const t = `${window.location.origin}${
|
|
2017
|
+
], ve = 2, dt = 500;
|
|
2018
|
+
async function ct() {
|
|
2019
|
+
const t = `${window.location.origin}${Ee}/config`;
|
|
1832
2020
|
let e;
|
|
1833
|
-
for (let s = 0; s <=
|
|
2021
|
+
for (let s = 0; s <= ve; s++)
|
|
1834
2022
|
try {
|
|
1835
2023
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
1836
2024
|
if (!i.ok)
|
|
1837
|
-
throw new
|
|
1838
|
-
const
|
|
1839
|
-
return
|
|
2025
|
+
throw new m(`Failed to load auth config: HTTP ${i.status}`);
|
|
2026
|
+
const n = await i.json();
|
|
2027
|
+
return ht(at(n));
|
|
1840
2028
|
} catch (i) {
|
|
1841
|
-
e = i, s <
|
|
2029
|
+
e = i, s < ve && await new Promise((n) => setTimeout(n, dt));
|
|
1842
2030
|
}
|
|
1843
2031
|
throw e;
|
|
1844
2032
|
}
|
|
1845
|
-
let
|
|
1846
|
-
async function
|
|
1847
|
-
return
|
|
1848
|
-
throw
|
|
1849
|
-
})),
|
|
2033
|
+
let V = null;
|
|
2034
|
+
async function ut() {
|
|
2035
|
+
return V || (V = ct().catch((t) => {
|
|
2036
|
+
throw V = null, t;
|
|
2037
|
+
})), V;
|
|
1850
2038
|
}
|
|
1851
|
-
function
|
|
1852
|
-
var s, i,
|
|
1853
|
-
const e =
|
|
1854
|
-
const
|
|
1855
|
-
return typeof
|
|
1856
|
-
}).map(({ id:
|
|
2039
|
+
function ht(t) {
|
|
2040
|
+
var s, i, n, a, h, w, P;
|
|
2041
|
+
const e = lt.filter(({ key: E }) => {
|
|
2042
|
+
const L = t[E];
|
|
2043
|
+
return typeof L == "object" && L !== null && "enabled" in L && !!L.enabled;
|
|
2044
|
+
}).map(({ id: E }) => E);
|
|
1857
2045
|
return {
|
|
1858
2046
|
disableSignUp: !!t.disableSignUp,
|
|
1859
2047
|
emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
|
|
1860
|
-
minPasswordLength: ((
|
|
1861
|
-
requireEmailVerification: !!((
|
|
1862
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2048
|
+
minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
|
|
2049
|
+
requireEmailVerification: !!((h = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && h.requireEmailVerification),
|
|
2050
|
+
passwordResetEmailOtpEnabled: !!((P = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && P.requirePasswordResetEmailVerification),
|
|
1863
2051
|
oauthProviders: e
|
|
1864
2052
|
};
|
|
1865
2053
|
}
|
|
1866
|
-
const
|
|
1867
|
-
function
|
|
2054
|
+
const N = /* @__PURE__ */ new WeakMap();
|
|
2055
|
+
function mt(t) {
|
|
1868
2056
|
if (!t)
|
|
1869
|
-
throw new
|
|
2057
|
+
throw new m(
|
|
1870
2058
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1871
2059
|
);
|
|
1872
2060
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
1873
2061
|
if (!e && !s)
|
|
1874
|
-
throw new
|
|
2062
|
+
throw new m(
|
|
1875
2063
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
1876
2064
|
);
|
|
1877
2065
|
if ("redirectTo" in t) {
|
|
1878
2066
|
const i = t.redirectTo;
|
|
1879
2067
|
if (!(typeof i == "string" || i instanceof URL))
|
|
1880
|
-
throw new
|
|
2068
|
+
throw new m(
|
|
1881
2069
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
1882
2070
|
);
|
|
1883
2071
|
}
|
|
1884
2072
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
1885
|
-
throw new
|
|
2073
|
+
throw new m(
|
|
1886
2074
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
1887
2075
|
);
|
|
1888
2076
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
1889
|
-
throw new
|
|
2077
|
+
throw new m(
|
|
1890
2078
|
"authUI.mount(container, options) expected onError to be a function."
|
|
1891
2079
|
);
|
|
1892
2080
|
}
|
|
1893
|
-
function
|
|
2081
|
+
function ft(t) {
|
|
1894
2082
|
if (!(t instanceof HTMLElement))
|
|
1895
|
-
throw new
|
|
2083
|
+
throw new m("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1896
2084
|
}
|
|
1897
|
-
function
|
|
2085
|
+
function wt(t, e) {
|
|
1898
2086
|
return {
|
|
1899
2087
|
mount(s, i) {
|
|
1900
|
-
var
|
|
1901
|
-
|
|
1902
|
-
const
|
|
2088
|
+
var w;
|
|
2089
|
+
mt(i), ft(s), (w = N.get(s)) == null || w.destroy();
|
|
2090
|
+
const n = new ot(s, t, i, ut, e), a = n.destroy.bind(n), h = {
|
|
1903
2091
|
destroy() {
|
|
1904
|
-
a(),
|
|
2092
|
+
a(), N.get(s) === h && N.delete(s);
|
|
1905
2093
|
}
|
|
1906
2094
|
};
|
|
1907
|
-
return
|
|
2095
|
+
return N.set(s, h), h;
|
|
1908
2096
|
}
|
|
1909
2097
|
};
|
|
1910
2098
|
}
|
|
1911
|
-
function
|
|
1912
|
-
|
|
1913
|
-
const t =
|
|
2099
|
+
function pt() {
|
|
2100
|
+
Pe();
|
|
2101
|
+
const t = Qe(), e = Xe(), s = Me(), i = wt(e, {
|
|
1914
2102
|
syncPublicSession: async () => {
|
|
1915
|
-
await
|
|
2103
|
+
await Ze(t);
|
|
1916
2104
|
}
|
|
1917
2105
|
});
|
|
1918
2106
|
return {
|
|
@@ -1922,22 +2110,22 @@ function xe() {
|
|
|
1922
2110
|
};
|
|
1923
2111
|
}
|
|
1924
2112
|
export {
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2113
|
+
y as EdgeSparkAuthError,
|
|
2114
|
+
m as EdgeSparkConfigError,
|
|
2115
|
+
ee as EdgeSparkError,
|
|
2116
|
+
Se as EdgeSparkRuntimeError,
|
|
2117
|
+
we as ar,
|
|
2118
|
+
pt as createEdgeSpark,
|
|
2119
|
+
he as de,
|
|
2120
|
+
tt as detectLocale,
|
|
2121
|
+
F as enUS,
|
|
2122
|
+
x as es,
|
|
2123
|
+
ue as fr,
|
|
2124
|
+
ge as hi,
|
|
2125
|
+
me as it,
|
|
2126
|
+
le as ja,
|
|
2127
|
+
de as ko,
|
|
2128
|
+
ce as ptBR,
|
|
2129
|
+
fe as ru,
|
|
2130
|
+
j as zhCN
|
|
1943
2131
|
};
|