@edgespark/web 0.0.4 → 0.0.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/auth/styles/styles.css +59 -2
- package/dist/auth/local-dev.d.ts +5 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +8 -0
- package/dist/auth-ui/config.d.ts +5 -0
- package/dist/auth-ui/types.d.ts +7 -0
- package/dist/index.cjs +32 -17
- package/dist/index.es.js +732 -602
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
1
|
+
import { createAuthClient as He } from "better-auth/client";
|
|
2
2
|
class le extends Error {
|
|
3
|
-
constructor(e,
|
|
4
|
-
super(
|
|
3
|
+
constructor(e, s) {
|
|
4
|
+
super(s), this.name = "EdgeSparkError", this.code = e;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class b extends le {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class Ue extends le {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
class L extends le {
|
|
18
|
-
constructor(e,
|
|
19
|
-
super((
|
|
18
|
+
constructor(e, s) {
|
|
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 de(t, e = "Authentication failed.",
|
|
22
|
+
function de(t, e = "Authentication failed.", s) {
|
|
23
23
|
if (t instanceof L)
|
|
24
24
|
return t;
|
|
25
25
|
if (typeof t == "object" && t !== null) {
|
|
26
|
-
const
|
|
27
|
-
return new L(
|
|
28
|
-
code:
|
|
29
|
-
status:
|
|
26
|
+
const i = t;
|
|
27
|
+
return new L(i.message || e, {
|
|
28
|
+
code: i.code ?? s,
|
|
29
|
+
status: i.status,
|
|
30
30
|
cause: t
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
return typeof t == "string" ? new L(t, { code:
|
|
33
|
+
return typeof t == "string" ? new L(t, { code: s }) : new L(e, { code: s, cause: t });
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function $e() {
|
|
36
36
|
if (typeof window > "u" || typeof document > "u")
|
|
37
|
-
throw new
|
|
37
|
+
throw new Ue(
|
|
38
38
|
"@edgespark/web is browser-only. Create the client from a real browser runtime."
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
function oe() {
|
|
42
|
-
return
|
|
42
|
+
return $e(), window.location.origin;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function ze(t) {
|
|
45
45
|
return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function xe(t) {
|
|
48
48
|
if (t.origin !== oe())
|
|
49
|
-
throw new
|
|
49
|
+
throw new b(
|
|
50
50
|
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${oe()}.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function je() {
|
|
54
54
|
return {
|
|
55
55
|
async fetch(t, e) {
|
|
56
|
-
const
|
|
57
|
-
return
|
|
56
|
+
const s = ze(t);
|
|
57
|
+
return xe(s), fetch(t, {
|
|
58
58
|
...e,
|
|
59
59
|
credentials: "include"
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const ke = "/api/_es/auth", qe = "edgespark-auth-session", Oe = "__edgespark_auth_sync__", q = "__edgespark_auth_pending_sign_in__", Be = Symbol("edgespark.notifyAuthTabs"), We = 10 * 60 * 1e3, Ke = /* @__PURE__ */ new Set([
|
|
65
65
|
"signOut",
|
|
66
66
|
"revokeSession",
|
|
67
67
|
"revokeSessions",
|
|
68
68
|
"revokeOtherSessions"
|
|
69
|
-
]),
|
|
69
|
+
]), Ye = /* @__PURE__ */ new Map([
|
|
70
70
|
[
|
|
71
71
|
"changeEmail",
|
|
72
72
|
"changeEmail() is not currently supported by EdgeSpark platform auth. Use authUI.mount() or other supported client.auth flows instead of wiring raw /api/_es/auth/* routes manually."
|
|
@@ -80,7 +80,7 @@ const Ue = "/api/_es/auth", je = "edgespark-auth-session", $e = "__edgespark_aut
|
|
|
80
80
|
"deleteUserCallback() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
|
|
81
81
|
]
|
|
82
82
|
]);
|
|
83
|
-
class
|
|
83
|
+
class Je {
|
|
84
84
|
constructor(e) {
|
|
85
85
|
this.value = e;
|
|
86
86
|
}
|
|
@@ -88,32 +88,32 @@ class Ye {
|
|
|
88
88
|
return this.value;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
let
|
|
93
|
-
const M = /* @__PURE__ */ new Map(), K =
|
|
91
|
+
const ue = globalThis.WeakRef, he = globalThis.FinalizationRegistry;
|
|
92
|
+
let W, me = !1;
|
|
93
|
+
const M = /* @__PURE__ */ new Map(), K = he ? new he((t) => {
|
|
94
94
|
M.delete(t);
|
|
95
95
|
}) : null;
|
|
96
|
-
function
|
|
97
|
-
return
|
|
96
|
+
function Me(t) {
|
|
97
|
+
return He({
|
|
98
98
|
baseURL: oe(),
|
|
99
|
-
basePath:
|
|
99
|
+
basePath: ke,
|
|
100
100
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
101
101
|
fetchOptions: {
|
|
102
102
|
credentials: "include"
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
var e,
|
|
108
|
-
return (
|
|
106
|
+
function B(t) {
|
|
107
|
+
var e, s;
|
|
108
|
+
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function Xe(t) {
|
|
111
111
|
return JSON.stringify({
|
|
112
112
|
source: t,
|
|
113
113
|
timestamp: Date.now()
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function Ze(t) {
|
|
117
117
|
if (typeof t != "string")
|
|
118
118
|
return null;
|
|
119
119
|
try {
|
|
@@ -123,70 +123,70 @@ function Xe(t) {
|
|
|
123
123
|
return null;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Qe(t) {
|
|
127
127
|
return t.join(".");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const e =
|
|
131
|
-
return
|
|
129
|
+
function et(t) {
|
|
130
|
+
const e = Qe(t), s = Ye.get(e);
|
|
131
|
+
return s ? new L(s, {
|
|
132
132
|
code: "UNSUPPORTED_AUTH_METHOD"
|
|
133
133
|
}) : null;
|
|
134
134
|
}
|
|
135
135
|
async function ae(t) {
|
|
136
136
|
var e;
|
|
137
137
|
try {
|
|
138
|
-
return await ((e =
|
|
138
|
+
return await ((e = B(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
139
139
|
} catch {
|
|
140
140
|
return !1;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
143
|
+
function De() {
|
|
144
|
+
return W === void 0 && (W = typeof BroadcastChannel < "u" ? new BroadcastChannel(qe) : null), W;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const e =
|
|
146
|
+
function fe(t) {
|
|
147
|
+
const e = Ze(t);
|
|
148
148
|
if (e)
|
|
149
|
-
for (const [
|
|
150
|
-
if (
|
|
149
|
+
for (const [s, i] of M) {
|
|
150
|
+
if (s === e.source)
|
|
151
151
|
continue;
|
|
152
|
-
const n =
|
|
152
|
+
const n = i.deref();
|
|
153
153
|
if (!n) {
|
|
154
|
-
M.delete(
|
|
154
|
+
M.delete(s);
|
|
155
155
|
continue;
|
|
156
156
|
}
|
|
157
157
|
ae(n);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function tt() {
|
|
161
161
|
var t;
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
me || (me = !0, (t = De()) == null || t.addEventListener("message", (e) => {
|
|
163
|
+
fe(e.data);
|
|
164
164
|
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
165
|
-
e.key !==
|
|
165
|
+
e.key !== Oe || e.newValue === null || fe(e.newValue);
|
|
166
166
|
}));
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
168
|
+
function st(t, e) {
|
|
169
|
+
ue ? M.set(t, new ue(e)) : (M.clear(), M.set(t, new Je(e))), K == null || K.register(e, t), tt();
|
|
170
170
|
}
|
|
171
171
|
function k(t) {
|
|
172
|
-
const e =
|
|
173
|
-
let
|
|
174
|
-
if (
|
|
172
|
+
const e = Xe(t), s = De();
|
|
173
|
+
let i = !1;
|
|
174
|
+
if (s)
|
|
175
175
|
try {
|
|
176
|
-
|
|
176
|
+
s.postMessage(e), i = !0;
|
|
177
177
|
} catch {
|
|
178
178
|
}
|
|
179
|
-
if (!
|
|
179
|
+
if (!i)
|
|
180
180
|
try {
|
|
181
|
-
window.localStorage.setItem(
|
|
181
|
+
window.localStorage.setItem(Oe, e);
|
|
182
182
|
} catch {
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Y(t) {
|
|
186
186
|
if (!(typeof window > "u"))
|
|
187
187
|
try {
|
|
188
188
|
window.sessionStorage.setItem(
|
|
189
|
-
|
|
189
|
+
q,
|
|
190
190
|
JSON.stringify({
|
|
191
191
|
path: t,
|
|
192
192
|
createdAt: Date.now()
|
|
@@ -195,315 +195,328 @@ function W(t) {
|
|
|
195
195
|
} catch {
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function O() {
|
|
199
199
|
if (!(typeof window > "u"))
|
|
200
200
|
try {
|
|
201
|
-
window.sessionStorage.removeItem(
|
|
201
|
+
window.sessionStorage.removeItem(q);
|
|
202
202
|
} catch {
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function it(t) {
|
|
206
206
|
return !!(t != null && t.session && (t != null && t.user));
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function v(t) {
|
|
209
209
|
return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function nt(t) {
|
|
212
212
|
return t ? JSON.stringify({
|
|
213
213
|
session: {
|
|
214
|
-
createdAt:
|
|
215
|
-
expiresAt:
|
|
216
|
-
id:
|
|
217
|
-
impersonatedBy:
|
|
218
|
-
ipAddress:
|
|
219
|
-
token:
|
|
220
|
-
updatedAt:
|
|
221
|
-
userAgent:
|
|
222
|
-
userId:
|
|
214
|
+
createdAt: v(t.session.createdAt),
|
|
215
|
+
expiresAt: v(t.session.expiresAt),
|
|
216
|
+
id: v(t.session.id),
|
|
217
|
+
impersonatedBy: v(t.session.impersonatedBy),
|
|
218
|
+
ipAddress: v(t.session.ipAddress),
|
|
219
|
+
token: v(t.session.token),
|
|
220
|
+
updatedAt: v(t.session.updatedAt),
|
|
221
|
+
userAgent: v(t.session.userAgent),
|
|
222
|
+
userId: v(t.session.userId)
|
|
223
223
|
},
|
|
224
224
|
user: {
|
|
225
|
-
banExpires:
|
|
226
|
-
banReason:
|
|
227
|
-
banned:
|
|
228
|
-
createdAt:
|
|
229
|
-
email:
|
|
230
|
-
emailVerified:
|
|
231
|
-
id:
|
|
232
|
-
image:
|
|
233
|
-
lastLoginAt:
|
|
234
|
-
name:
|
|
235
|
-
role:
|
|
236
|
-
updatedAt:
|
|
225
|
+
banExpires: v(t.user.banExpires),
|
|
226
|
+
banReason: v(t.user.banReason),
|
|
227
|
+
banned: v(t.user.banned),
|
|
228
|
+
createdAt: v(t.user.createdAt),
|
|
229
|
+
email: v(t.user.email),
|
|
230
|
+
emailVerified: v(t.user.emailVerified),
|
|
231
|
+
id: v(t.user.id),
|
|
232
|
+
image: v(t.user.image),
|
|
233
|
+
lastLoginAt: v(t.user.lastLoginAt),
|
|
234
|
+
name: v(t.user.name),
|
|
235
|
+
role: v(t.user.role),
|
|
236
|
+
updatedAt: v(t.user.updatedAt)
|
|
237
237
|
}
|
|
238
238
|
}) : "__null__";
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Ne() {
|
|
241
241
|
if (typeof window > "u")
|
|
242
242
|
return null;
|
|
243
243
|
try {
|
|
244
|
-
const t = window.sessionStorage.getItem(
|
|
244
|
+
const t = window.sessionStorage.getItem(q);
|
|
245
245
|
if (!t)
|
|
246
246
|
return null;
|
|
247
247
|
const e = JSON.parse(t);
|
|
248
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt >
|
|
248
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > We ? null : { createdAt: e.createdAt };
|
|
249
249
|
} catch {
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
if (!
|
|
253
|
+
function ge() {
|
|
254
|
+
if (!Ne())
|
|
255
255
|
return !1;
|
|
256
256
|
try {
|
|
257
|
-
window.sessionStorage.removeItem(
|
|
257
|
+
window.sessionStorage.removeItem(q);
|
|
258
258
|
} catch {
|
|
259
259
|
}
|
|
260
260
|
return !0;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
return
|
|
262
|
+
function rt() {
|
|
263
|
+
return Ne() !== null;
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function ot(t) {
|
|
266
266
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
267
267
|
return !1;
|
|
268
268
|
const e = "data" in t ? t.data : t;
|
|
269
269
|
return e && typeof e == "object" ? "token" in e && typeof e.token == "string" && e.token.length > 0 ? !0 : "session" in e && "user" in e && !!e.session && !!e.user : !1;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function at(t) {
|
|
272
272
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
273
273
|
return !1;
|
|
274
274
|
const e = "data" in t ? t.data : t;
|
|
275
275
|
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function lt(t) {
|
|
278
278
|
if ($(t) || !(t && typeof t == "object"))
|
|
279
279
|
return !1;
|
|
280
280
|
const e = "data" in t ? t.data : t;
|
|
281
281
|
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function dt(t, e) {
|
|
284
284
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
285
285
|
return !1;
|
|
286
|
-
const [
|
|
287
|
-
return !!(
|
|
286
|
+
const [s] = e;
|
|
287
|
+
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
288
288
|
}
|
|
289
289
|
function $(t) {
|
|
290
290
|
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function ct(t) {
|
|
293
293
|
if ($(t) || !(t && typeof t == "object"))
|
|
294
294
|
return !1;
|
|
295
295
|
const e = "data" in t ? t.data : t;
|
|
296
296
|
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function ut(t) {
|
|
299
299
|
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function J(t) {
|
|
302
302
|
return de(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
303
303
|
}
|
|
304
|
-
async function
|
|
305
|
-
var
|
|
304
|
+
async function ht(t) {
|
|
305
|
+
var s, i;
|
|
306
306
|
let e = null;
|
|
307
307
|
try {
|
|
308
|
-
await ((
|
|
308
|
+
await ((s = B(t)) == null ? void 0 : s.get().refetch());
|
|
309
309
|
} catch (n) {
|
|
310
310
|
e = n;
|
|
311
311
|
} finally {
|
|
312
|
-
(
|
|
312
|
+
(i = t[Be]) == null || i.call(t);
|
|
313
313
|
}
|
|
314
314
|
if (e)
|
|
315
315
|
throw e;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
const t =
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
let n = null, o = !1,
|
|
322
|
-
const
|
|
323
|
-
var
|
|
324
|
-
const a = (
|
|
325
|
-
return a != null && a.error && !a.data &&
|
|
326
|
-
},
|
|
327
|
-
var
|
|
328
|
-
let a = !1,
|
|
317
|
+
function mt() {
|
|
318
|
+
const t = Me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
319
|
+
st(e, t);
|
|
320
|
+
const s = 2, i = 500;
|
|
321
|
+
let n = null, o = !1, c;
|
|
322
|
+
const h = (a) => (c = a, a), p = () => {
|
|
323
|
+
var m;
|
|
324
|
+
const a = (m = B(t)) == null ? void 0 : m.get();
|
|
325
|
+
return a != null && a.error && !a.data && c !== void 0 ? c : (a == null ? void 0 : a.data) ?? c ?? null;
|
|
326
|
+
}, P = () => o ? Promise.resolve(p()) : (n || (n = (async () => {
|
|
327
|
+
var d, f, T;
|
|
328
|
+
let a = !1, m = null;
|
|
329
329
|
try {
|
|
330
|
-
for (let _ = 0; _ <=
|
|
331
|
-
let
|
|
330
|
+
for (let _ = 0; _ <= s; _++) {
|
|
331
|
+
let u = null;
|
|
332
332
|
try {
|
|
333
|
-
|
|
334
|
-
} catch (
|
|
335
|
-
|
|
333
|
+
u = await t.getSession();
|
|
334
|
+
} catch (C) {
|
|
335
|
+
m = C;
|
|
336
336
|
}
|
|
337
|
-
const E = ((
|
|
338
|
-
if ((
|
|
339
|
-
return o = !0,
|
|
337
|
+
const E = ((d = B(t)) == null ? void 0 : d.get().data) ?? null;
|
|
338
|
+
if ((f = u == null ? void 0 : u.data) != null && f.session && ((T = u.data) != null && T.user))
|
|
339
|
+
return o = !0, ge() && k(e), h(u.data);
|
|
340
340
|
if (E != null && E.session && (E != null && E.user))
|
|
341
|
-
return o = !0,
|
|
342
|
-
if (
|
|
341
|
+
return o = !0, ge() && k(e), h(E);
|
|
342
|
+
if (u != null && u.error ? m = u.error : u && (a = !0), u && !u.error && rt() && _ < s) {
|
|
343
343
|
await new Promise(
|
|
344
|
-
(
|
|
344
|
+
(C) => setTimeout(C, i)
|
|
345
345
|
);
|
|
346
346
|
continue;
|
|
347
347
|
}
|
|
348
|
-
if (
|
|
349
|
-
const
|
|
350
|
-
return o = !0,
|
|
348
|
+
if (u && !u.error) {
|
|
349
|
+
const C = p();
|
|
350
|
+
return o = !0, h(C);
|
|
351
351
|
}
|
|
352
|
-
_ <
|
|
353
|
-
(
|
|
352
|
+
_ < s && await new Promise(
|
|
353
|
+
(C) => setTimeout(C, i)
|
|
354
354
|
);
|
|
355
355
|
}
|
|
356
356
|
if (!a)
|
|
357
357
|
throw n = null, new L("Failed to load the current session.", {
|
|
358
358
|
code: "SESSION_LOOKUP_FAILED",
|
|
359
|
-
cause:
|
|
359
|
+
cause: m
|
|
360
360
|
});
|
|
361
361
|
const y = p();
|
|
362
|
-
return o = !0,
|
|
362
|
+
return o = !0, h(y);
|
|
363
363
|
} catch (y) {
|
|
364
|
-
throw n = null,
|
|
364
|
+
throw n = null, J(y);
|
|
365
365
|
}
|
|
366
366
|
})()), n);
|
|
367
|
-
|
|
367
|
+
P().catch(() => {
|
|
368
368
|
});
|
|
369
|
-
const
|
|
370
|
-
var a,
|
|
369
|
+
const w = async () => {
|
|
370
|
+
var a, m;
|
|
371
371
|
try {
|
|
372
|
-
const
|
|
373
|
-
if ((a =
|
|
374
|
-
return
|
|
375
|
-
throw
|
|
372
|
+
const d = await t.getSession();
|
|
373
|
+
if ((a = d.data) != null && a.session && ((m = d.data) != null && m.user))
|
|
374
|
+
return d.data;
|
|
375
|
+
throw d.error ? J(d.error) : new L("No authenticated session is available.", {
|
|
376
376
|
code: "UNAUTHENTICATED"
|
|
377
377
|
});
|
|
378
|
-
} catch (
|
|
379
|
-
throw
|
|
378
|
+
} catch (d) {
|
|
379
|
+
throw J(d);
|
|
380
380
|
}
|
|
381
|
-
},
|
|
381
|
+
}, g = async () => {
|
|
382
382
|
await ae(t), k(e);
|
|
383
|
-
},
|
|
384
|
-
var
|
|
385
|
-
const a = await ae(t),
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
let
|
|
389
|
-
const T = (
|
|
390
|
-
const E =
|
|
391
|
-
E !==
|
|
383
|
+
}, S = async () => {
|
|
384
|
+
var d;
|
|
385
|
+
const a = await ae(t), m = ((d = B(t)) == null ? void 0 : d.get().data) ?? null;
|
|
386
|
+
it(m) ? (O(), k(e)) : a || k(e);
|
|
387
|
+
}, l = (a) => {
|
|
388
|
+
let m = !1, d = !1, f;
|
|
389
|
+
const T = (u) => {
|
|
390
|
+
const E = nt(u);
|
|
391
|
+
E !== f && (f = E, a(u));
|
|
392
392
|
};
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
P().then((u) => {
|
|
394
|
+
m || (d = !0, T(h(u)));
|
|
395
395
|
}).catch(() => {
|
|
396
|
-
|
|
396
|
+
m || (d = !0);
|
|
397
397
|
});
|
|
398
|
-
const y =
|
|
398
|
+
const y = B(t);
|
|
399
399
|
if (!y)
|
|
400
400
|
return () => {
|
|
401
|
-
|
|
401
|
+
m = !0;
|
|
402
402
|
};
|
|
403
|
-
const _ = y.subscribe((
|
|
404
|
-
if (
|
|
403
|
+
const _ = y.subscribe((u) => {
|
|
404
|
+
if (m || !d || u.error && !u.data)
|
|
405
405
|
return;
|
|
406
|
-
const E =
|
|
407
|
-
T(
|
|
406
|
+
const E = u.data ?? null;
|
|
407
|
+
T(h(E));
|
|
408
408
|
});
|
|
409
409
|
return () => {
|
|
410
|
-
|
|
410
|
+
m = !0, _();
|
|
411
411
|
};
|
|
412
|
-
},
|
|
413
|
-
const
|
|
414
|
-
return a.length === 1 && (
|
|
415
|
-
},
|
|
412
|
+
}, I = async (a, m, d) => {
|
|
413
|
+
const f = a[0], T = a.length >= 2 && f === "emailOtp" && a[1] === "verifyEmail", y = a.length >= 2 && f === "emailOtp" && a[1] === "resetPassword", _ = a.length >= 2 && f === "resetPassword" && a[1] === "emailOtp", u = a.length >= 2 && f === "oneTap" && a[1] === "callback";
|
|
414
|
+
return a.length === 1 && (f === "deleteUser" || f === "deleteUserCallback") ? (O(), ct(d) && await g(), d) : a.length === 1 && f && Ke.has(f) ? (O(), $(d) || await g(), d) : dt(a, m) && !$(d) ? (O(), await g(), d) : (y || _) && !$(d) ? (O(), await g(), d) : a.length === 1 && f === "changeEmail" && !$(d) ? (await g(), d) : ((f === "signIn" || f === "signUp" || T || u) && ot(d) ? (O(), await g()) : (f === "signIn" || f === "signUp") && at(d) || f === "signUp" && lt(d) ? Y(a) : f === "verifyEmail" && !$(d) && (Y(a), await S()), d);
|
|
415
|
+
}, A = /* @__PURE__ */ new WeakMap(), D = (a, m) => {
|
|
416
416
|
if (!a || typeof a != "object" && typeof a != "function")
|
|
417
417
|
return a;
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
return
|
|
421
|
-
const
|
|
418
|
+
const d = A.get(a);
|
|
419
|
+
if (d)
|
|
420
|
+
return d;
|
|
421
|
+
const f = new Proxy(a, {
|
|
422
422
|
get(T, y, _) {
|
|
423
|
-
if (
|
|
423
|
+
if (m.length === 0) {
|
|
424
424
|
if (y === "requireSession")
|
|
425
|
-
return
|
|
425
|
+
return w;
|
|
426
426
|
if (y === "onSessionChange")
|
|
427
|
-
return
|
|
428
|
-
if (y ===
|
|
427
|
+
return l;
|
|
428
|
+
if (y === Be)
|
|
429
429
|
return () => {
|
|
430
430
|
k(e);
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
const
|
|
434
|
-
return typeof y != "string" ?
|
|
433
|
+
const u = Reflect.get(T, y, _);
|
|
434
|
+
return typeof y != "string" ? u : D(u, [...m, y]);
|
|
435
435
|
},
|
|
436
436
|
apply(T, y, _) {
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
439
|
-
throw
|
|
437
|
+
const u = et(m);
|
|
438
|
+
if (u)
|
|
439
|
+
throw u;
|
|
440
440
|
const E = Reflect.apply(
|
|
441
441
|
T,
|
|
442
442
|
y,
|
|
443
443
|
_
|
|
444
444
|
);
|
|
445
|
-
return
|
|
446
|
-
(
|
|
445
|
+
return ut(E) ? Promise.resolve(E).then(
|
|
446
|
+
(C) => I(m, _, C)
|
|
447
447
|
) : E;
|
|
448
448
|
}
|
|
449
449
|
});
|
|
450
|
-
return
|
|
450
|
+
return A.set(a, f), f;
|
|
451
451
|
};
|
|
452
452
|
return D(t, []);
|
|
453
453
|
}
|
|
454
|
-
function mt() {
|
|
455
|
-
return Be({ disableDefaultRedirectPlugin: !0 });
|
|
456
|
-
}
|
|
457
|
-
const De = "/api/_es/dev";
|
|
458
454
|
function ft() {
|
|
455
|
+
return Me({ disableDefaultRedirectPlugin: !0 });
|
|
456
|
+
}
|
|
457
|
+
const ce = "/api/_es/dev";
|
|
458
|
+
function gt() {
|
|
459
459
|
if (typeof document > "u") return !1;
|
|
460
460
|
const t = document.querySelector('meta[name="edgespark-local-dev"]');
|
|
461
461
|
return (t == null ? void 0 : t.getAttribute("content")) === "true";
|
|
462
462
|
}
|
|
463
|
-
async function
|
|
463
|
+
async function pt(t) {
|
|
464
464
|
const e = typeof window < "u" ? window.location.origin : "";
|
|
465
465
|
if (!e) return !1;
|
|
466
|
-
const
|
|
467
|
-
`${e}${
|
|
466
|
+
const s = await fetch(
|
|
467
|
+
`${e}${ce}/auto-verify?email=${encodeURIComponent(t)}`,
|
|
468
468
|
{ credentials: "include" }
|
|
469
469
|
);
|
|
470
|
-
return
|
|
470
|
+
return s.ok ? (await s.json()).verified === !0 : !1;
|
|
471
|
+
}
|
|
472
|
+
async function wt(t) {
|
|
473
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
|
+
if (!e) return null;
|
|
475
|
+
try {
|
|
476
|
+
const s = await fetch(
|
|
477
|
+
`${e}${ce}/pending-otp?email=${encodeURIComponent(t)}`,
|
|
478
|
+
{ credentials: "include" }
|
|
479
|
+
);
|
|
480
|
+
return s.ok ? (await s.json()).otp ?? null : null;
|
|
481
|
+
} catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
471
484
|
}
|
|
472
|
-
async function
|
|
485
|
+
async function bt(t) {
|
|
473
486
|
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
487
|
if (!e) return null;
|
|
475
488
|
try {
|
|
476
|
-
const
|
|
477
|
-
`${e}${
|
|
489
|
+
const s = await fetch(
|
|
490
|
+
`${e}${ce}/pending-sign-in-otp?email=${encodeURIComponent(t)}`,
|
|
478
491
|
{ credentials: "include" }
|
|
479
492
|
);
|
|
480
|
-
return
|
|
493
|
+
return s.ok ? (await s.json()).otp ?? null : null;
|
|
481
494
|
} catch {
|
|
482
495
|
return null;
|
|
483
496
|
}
|
|
484
497
|
}
|
|
485
|
-
function
|
|
498
|
+
function vt(t) {
|
|
486
499
|
const e = (() => {
|
|
487
500
|
if (t instanceof URL)
|
|
488
501
|
return t;
|
|
489
|
-
const
|
|
490
|
-
if (!
|
|
491
|
-
throw new
|
|
502
|
+
const s = t.trim();
|
|
503
|
+
if (!s)
|
|
504
|
+
throw new b("redirectTo must not be an empty string.");
|
|
492
505
|
try {
|
|
493
|
-
return new URL(
|
|
506
|
+
return new URL(s, window.location.href);
|
|
494
507
|
} catch {
|
|
495
|
-
throw new
|
|
508
|
+
throw new b(
|
|
496
509
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
497
510
|
);
|
|
498
511
|
}
|
|
499
512
|
})();
|
|
500
513
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
501
|
-
throw new
|
|
514
|
+
throw new b(
|
|
502
515
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
503
516
|
);
|
|
504
517
|
return e;
|
|
505
518
|
}
|
|
506
|
-
function
|
|
519
|
+
function yt(t, e) {
|
|
507
520
|
return e ? {
|
|
508
521
|
common: { ...t.common, ...e.common },
|
|
509
522
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -515,7 +528,7 @@ function bt(t, e) {
|
|
|
515
528
|
errors: { ...t.errors, ...e.errors }
|
|
516
529
|
} : t;
|
|
517
530
|
}
|
|
518
|
-
const
|
|
531
|
+
const j = {
|
|
519
532
|
common: {
|
|
520
533
|
loading: "Loading sign-in…",
|
|
521
534
|
redirecting: "Redirecting…",
|
|
@@ -527,6 +540,8 @@ const x = {
|
|
|
527
540
|
emailLabel: "Email",
|
|
528
541
|
passwordLabel: "Password",
|
|
529
542
|
submitButton: "Sign in",
|
|
543
|
+
resendCodeButton: "Resend code",
|
|
544
|
+
resendCountdown: "Resend in {seconds}s",
|
|
530
545
|
forgotPassword: "Forgot password?",
|
|
531
546
|
switchToSignUp: "Create an account",
|
|
532
547
|
signUpPrompt: "Don’t have an account?"
|
|
@@ -578,7 +593,7 @@ const x = {
|
|
|
578
593
|
invalidCode: "Enter the 6-digit verification code.",
|
|
579
594
|
generic: "Something went wrong. Please try again."
|
|
580
595
|
}
|
|
581
|
-
},
|
|
596
|
+
}, X = {
|
|
582
597
|
common: {
|
|
583
598
|
loading: "加载中…",
|
|
584
599
|
redirecting: "跳转中…",
|
|
@@ -641,7 +656,7 @@ const x = {
|
|
|
641
656
|
invalidCode: "请输入 6 位验证码",
|
|
642
657
|
generic: "出现错误,请稍后重试"
|
|
643
658
|
}
|
|
644
|
-
},
|
|
659
|
+
}, pe = {
|
|
645
660
|
common: {
|
|
646
661
|
loading: "サインインを読み込み中…",
|
|
647
662
|
redirecting: "リダイレクト中…",
|
|
@@ -704,7 +719,7 @@ const x = {
|
|
|
704
719
|
invalidCode: "6桁の認証コードを入力してください",
|
|
705
720
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
706
721
|
}
|
|
707
|
-
},
|
|
722
|
+
}, we = {
|
|
708
723
|
common: {
|
|
709
724
|
loading: "로그인 로딩 중…",
|
|
710
725
|
redirecting: "리디렉션 중…",
|
|
@@ -767,7 +782,7 @@ const x = {
|
|
|
767
782
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
768
783
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
769
784
|
}
|
|
770
|
-
},
|
|
785
|
+
}, Z = {
|
|
771
786
|
common: {
|
|
772
787
|
loading: "Cargando inicio de sesión…",
|
|
773
788
|
redirecting: "Redirigiendo…",
|
|
@@ -830,7 +845,7 @@ const x = {
|
|
|
830
845
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
831
846
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
832
847
|
}
|
|
833
|
-
},
|
|
848
|
+
}, be = {
|
|
834
849
|
common: {
|
|
835
850
|
loading: "Carregando login…",
|
|
836
851
|
redirecting: "Redirecionando…",
|
|
@@ -893,7 +908,7 @@ const x = {
|
|
|
893
908
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
894
909
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
895
910
|
}
|
|
896
|
-
},
|
|
911
|
+
}, ve = {
|
|
897
912
|
common: {
|
|
898
913
|
loading: "Chargement de la connexion…",
|
|
899
914
|
redirecting: "Redirection…",
|
|
@@ -956,7 +971,7 @@ const x = {
|
|
|
956
971
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
957
972
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
958
973
|
}
|
|
959
|
-
},
|
|
974
|
+
}, ye = {
|
|
960
975
|
common: {
|
|
961
976
|
loading: "Anmeldung wird geladen…",
|
|
962
977
|
redirecting: "Weiterleitung…",
|
|
@@ -1019,7 +1034,7 @@ const x = {
|
|
|
1019
1034
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
1020
1035
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
1021
1036
|
}
|
|
1022
|
-
},
|
|
1037
|
+
}, Se = {
|
|
1023
1038
|
common: {
|
|
1024
1039
|
loading: "Caricamento accesso…",
|
|
1025
1040
|
redirecting: "Reindirizzamento…",
|
|
@@ -1145,7 +1160,7 @@ const x = {
|
|
|
1145
1160
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
1146
1161
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
1147
1162
|
}
|
|
1148
|
-
},
|
|
1163
|
+
}, Pe = {
|
|
1149
1164
|
common: {
|
|
1150
1165
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
1151
1166
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -1208,7 +1223,7 @@ const x = {
|
|
|
1208
1223
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
1209
1224
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
1210
1225
|
}
|
|
1211
|
-
},
|
|
1226
|
+
}, Ie = {
|
|
1212
1227
|
common: {
|
|
1213
1228
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
1214
1229
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -1272,47 +1287,47 @@ const x = {
|
|
|
1272
1287
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1273
1288
|
}
|
|
1274
1289
|
}, _e = {
|
|
1275
|
-
en:
|
|
1276
|
-
"en-US":
|
|
1277
|
-
zh:
|
|
1278
|
-
"zh-CN":
|
|
1279
|
-
"zh-TW":
|
|
1280
|
-
ja:
|
|
1281
|
-
"ja-JP":
|
|
1282
|
-
ko:
|
|
1283
|
-
"ko-KR":
|
|
1284
|
-
es:
|
|
1285
|
-
"es-ES":
|
|
1286
|
-
"es-MX":
|
|
1287
|
-
pt:
|
|
1288
|
-
"pt-BR":
|
|
1289
|
-
fr:
|
|
1290
|
-
"fr-FR":
|
|
1291
|
-
de:
|
|
1292
|
-
"de-DE":
|
|
1293
|
-
it:
|
|
1294
|
-
"it-IT":
|
|
1290
|
+
en: j,
|
|
1291
|
+
"en-US": j,
|
|
1292
|
+
zh: X,
|
|
1293
|
+
"zh-CN": X,
|
|
1294
|
+
"zh-TW": X,
|
|
1295
|
+
ja: pe,
|
|
1296
|
+
"ja-JP": pe,
|
|
1297
|
+
ko: we,
|
|
1298
|
+
"ko-KR": we,
|
|
1299
|
+
es: Z,
|
|
1300
|
+
"es-ES": Z,
|
|
1301
|
+
"es-MX": Z,
|
|
1302
|
+
pt: be,
|
|
1303
|
+
"pt-BR": be,
|
|
1304
|
+
fr: ve,
|
|
1305
|
+
"fr-FR": ve,
|
|
1306
|
+
de: ye,
|
|
1307
|
+
"de-DE": ye,
|
|
1308
|
+
it: Se,
|
|
1309
|
+
"it-IT": Se,
|
|
1295
1310
|
ru: Ee,
|
|
1296
1311
|
"ru-RU": Ee,
|
|
1297
|
-
ar:
|
|
1298
|
-
"ar-SA":
|
|
1299
|
-
hi:
|
|
1300
|
-
"hi-IN":
|
|
1312
|
+
ar: Pe,
|
|
1313
|
+
"ar-SA": Pe,
|
|
1314
|
+
hi: Ie,
|
|
1315
|
+
"hi-IN": Ie
|
|
1301
1316
|
};
|
|
1302
|
-
function
|
|
1317
|
+
function St() {
|
|
1303
1318
|
if (typeof navigator > "u")
|
|
1304
|
-
return
|
|
1319
|
+
return j;
|
|
1305
1320
|
const t = navigator.languages ?? [navigator.language];
|
|
1306
1321
|
for (const e of t) {
|
|
1307
|
-
const
|
|
1308
|
-
if (
|
|
1322
|
+
const s = _e[e] ?? _e[e.split("-")[0]];
|
|
1323
|
+
if (s) return s;
|
|
1309
1324
|
}
|
|
1310
|
-
return
|
|
1325
|
+
return j;
|
|
1311
1326
|
}
|
|
1312
|
-
const
|
|
1327
|
+
const Ve = {
|
|
1313
1328
|
LIGHT: "light",
|
|
1314
1329
|
DARK: "dark"
|
|
1315
|
-
},
|
|
1330
|
+
}, Fe = Ve.LIGHT, Et = Ve.DARK, Ge = [Fe, Et], Pt = Fe, It = {
|
|
1316
1331
|
BACKGROUND: "--edgespark-auth-bg",
|
|
1317
1332
|
BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
|
|
1318
1333
|
CARD_BACKGROUND: "--edgespark-auth-card-bg",
|
|
@@ -1332,28 +1347,28 @@ const Ne = {
|
|
|
1332
1347
|
MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
|
|
1333
1348
|
MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
|
|
1334
1349
|
MODAL_SHADOW: "--edgespark-auth-modal-shadow"
|
|
1335
|
-
},
|
|
1336
|
-
|
|
1350
|
+
}, _t = Object.values(
|
|
1351
|
+
It
|
|
1337
1352
|
);
|
|
1338
|
-
function _t(t) {
|
|
1339
|
-
return typeof t == "string" && Fe.includes(t);
|
|
1340
|
-
}
|
|
1341
1353
|
function Lt(t) {
|
|
1342
|
-
return
|
|
1354
|
+
return typeof t == "string" && Ge.includes(t);
|
|
1343
1355
|
}
|
|
1344
1356
|
function At(t) {
|
|
1357
|
+
return _t.includes(t);
|
|
1358
|
+
}
|
|
1359
|
+
function Tt(t) {
|
|
1345
1360
|
var e;
|
|
1346
1361
|
return {
|
|
1347
|
-
theme: (t == null ? void 0 : t.theme) ??
|
|
1362
|
+
theme: (t == null ? void 0 : t.theme) ?? Pt,
|
|
1348
1363
|
className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
|
|
1349
1364
|
variables: { ...(t == null ? void 0 : t.variables) ?? {} }
|
|
1350
1365
|
};
|
|
1351
1366
|
}
|
|
1352
|
-
function
|
|
1367
|
+
function Q(t, e = "Authentication failed.") {
|
|
1353
1368
|
return de(t, e);
|
|
1354
1369
|
}
|
|
1355
1370
|
async function V(t) {
|
|
1356
|
-
var
|
|
1371
|
+
var s, i;
|
|
1357
1372
|
const e = await t.getSession();
|
|
1358
1373
|
if (e.error)
|
|
1359
1374
|
throw new L(
|
|
@@ -1364,7 +1379,7 @@ async function V(t) {
|
|
|
1364
1379
|
cause: e.error
|
|
1365
1380
|
}
|
|
1366
1381
|
);
|
|
1367
|
-
return (
|
|
1382
|
+
return (s = e.data) != null && s.user && ((i = e.data) != null && i.session) ? {
|
|
1368
1383
|
user: e.data.user,
|
|
1369
1384
|
session: e.data
|
|
1370
1385
|
} : {
|
|
@@ -1372,13 +1387,13 @@ async function V(t) {
|
|
|
1372
1387
|
session: null
|
|
1373
1388
|
};
|
|
1374
1389
|
}
|
|
1375
|
-
const
|
|
1390
|
+
const Ct = "data-edgespark-auth", Rt = "data-edgespark-auth-theme", r = "edgespark-auth", ee = "es_auth_completion", F = "es_auth_email", te = "oauth", N = "verify-sign-in", R = "verify-sign-up", Le = 200, se = 2, Ut = {
|
|
1376
1391
|
"&": "&",
|
|
1377
1392
|
"<": "<",
|
|
1378
1393
|
">": ">",
|
|
1379
1394
|
'"': """,
|
|
1380
1395
|
"'": "'"
|
|
1381
|
-
},
|
|
1396
|
+
}, ie = {
|
|
1382
1397
|
google: "Google",
|
|
1383
1398
|
apple: "Apple",
|
|
1384
1399
|
microsoft: "Microsoft",
|
|
@@ -1389,24 +1404,24 @@ const Tt = "data-edgespark-auth", It = "data-edgespark-auth-theme", r = "edgespa
|
|
|
1389
1404
|
function U(t) {
|
|
1390
1405
|
return "redirectTo" in t;
|
|
1391
1406
|
}
|
|
1392
|
-
function
|
|
1407
|
+
function ne(t) {
|
|
1393
1408
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1394
1409
|
}
|
|
1395
|
-
function
|
|
1410
|
+
function G(t) {
|
|
1396
1411
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1397
1412
|
}
|
|
1398
|
-
function
|
|
1413
|
+
function Ae(t) {
|
|
1399
1414
|
return /^\d{6}$/.test(t.trim());
|
|
1400
1415
|
}
|
|
1401
|
-
function
|
|
1416
|
+
function $t(t) {
|
|
1402
1417
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1403
1418
|
}
|
|
1404
|
-
function
|
|
1419
|
+
function kt(t) {
|
|
1405
1420
|
return !!(t.error || t.errorDescription);
|
|
1406
1421
|
}
|
|
1407
|
-
class
|
|
1408
|
-
constructor(e,
|
|
1409
|
-
this.container = e, this.auth =
|
|
1422
|
+
class Ot {
|
|
1423
|
+
constructor(e, s, i, n, o) {
|
|
1424
|
+
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = o, this.state = {
|
|
1410
1425
|
view: "loading",
|
|
1411
1426
|
busy: !0,
|
|
1412
1427
|
busyLabel: void 0,
|
|
@@ -1417,12 +1432,14 @@ class kt {
|
|
|
1417
1432
|
password: "",
|
|
1418
1433
|
confirmPassword: "",
|
|
1419
1434
|
code: "",
|
|
1420
|
-
newPassword: ""
|
|
1435
|
+
newPassword: "",
|
|
1436
|
+
signInMethod: "password",
|
|
1437
|
+
signInOtpSent: !1
|
|
1421
1438
|
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
|
|
1422
|
-
const
|
|
1423
|
-
this.labels =
|
|
1424
|
-
for (const [
|
|
1425
|
-
p !== void 0 && this.root.style.setProperty(
|
|
1439
|
+
const c = Tt(i.appearance);
|
|
1440
|
+
this.labels = yt(St(), i.labels), this.root = document.createElement("div"), this.root.className = c.className ? `${r} ${c.className}` : r, this.root.setAttribute(Ct, ""), this.root.setAttribute(Rt, c.theme);
|
|
1441
|
+
for (const [h, p] of Object.entries(c.variables))
|
|
1442
|
+
p !== void 0 && this.root.style.setProperty(h, p);
|
|
1426
1443
|
e.appendChild(this.root), this.render(), this.initialize();
|
|
1427
1444
|
}
|
|
1428
1445
|
destroy() {
|
|
@@ -1431,26 +1448,26 @@ class kt {
|
|
|
1431
1448
|
async initialize() {
|
|
1432
1449
|
const e = this.consumeManagedReturnContext();
|
|
1433
1450
|
try {
|
|
1434
|
-
const [
|
|
1451
|
+
const [s, i] = await Promise.allSettled([
|
|
1435
1452
|
this.loadConfig(),
|
|
1436
1453
|
this.readMountSession(e)
|
|
1437
1454
|
]);
|
|
1438
1455
|
if (this.destroyed)
|
|
1439
1456
|
return;
|
|
1440
|
-
if (
|
|
1441
|
-
if (e.marker &&
|
|
1457
|
+
if (i.status === "rejected") {
|
|
1458
|
+
if (e.marker && !kt(e) && U(this.options)) {
|
|
1442
1459
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1443
1460
|
return;
|
|
1444
1461
|
}
|
|
1445
1462
|
} else {
|
|
1446
|
-
const o =
|
|
1463
|
+
const o = i.value;
|
|
1447
1464
|
if (o.user && o.session) {
|
|
1448
1465
|
switch (e.marker) {
|
|
1449
|
-
case
|
|
1466
|
+
case te:
|
|
1450
1467
|
case N:
|
|
1451
1468
|
await this.completeAuth("sign-in", o);
|
|
1452
1469
|
return;
|
|
1453
|
-
case
|
|
1470
|
+
case R:
|
|
1454
1471
|
await this.completeAuth("sign-up", o);
|
|
1455
1472
|
return;
|
|
1456
1473
|
default:
|
|
@@ -1460,40 +1477,40 @@ class kt {
|
|
|
1460
1477
|
return;
|
|
1461
1478
|
}
|
|
1462
1479
|
}
|
|
1463
|
-
if (i.status === "rejected")
|
|
1464
|
-
throw s.status === "rejected" ? s.reason : i.reason;
|
|
1465
|
-
if (this.config = i.value, this.handleSessionlessManagedReturn(e))
|
|
1466
|
-
return;
|
|
1467
1480
|
if (s.status === "rejected")
|
|
1468
|
-
throw s.reason;
|
|
1469
|
-
|
|
1481
|
+
throw i.status === "rejected" ? i.reason : s.reason;
|
|
1482
|
+
if (this.config = s.value, this.state.signInMethod = this.resolveInitialSignInMethod(), this.handleSessionlessManagedReturn(e))
|
|
1483
|
+
return;
|
|
1484
|
+
if (i.status === "rejected")
|
|
1485
|
+
throw i.reason;
|
|
1486
|
+
const n = i.value;
|
|
1470
1487
|
this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.render();
|
|
1471
|
-
} catch (
|
|
1472
|
-
this.handleError(
|
|
1488
|
+
} catch (s) {
|
|
1489
|
+
this.handleError(s, "Failed to load the authentication UI.");
|
|
1473
1490
|
}
|
|
1474
1491
|
}
|
|
1475
1492
|
redirectAfterManagedReturnLookupFailure() {
|
|
1476
1493
|
U(this.options) && this.navigateToRedirect();
|
|
1477
1494
|
}
|
|
1478
1495
|
navigateToRedirect() {
|
|
1479
|
-
U(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(
|
|
1496
|
+
U(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(vt(this.options.redirectTo).toString()));
|
|
1480
1497
|
}
|
|
1481
1498
|
async readMountSession(e) {
|
|
1482
1499
|
if (!e.marker)
|
|
1483
1500
|
return V(this.auth);
|
|
1484
|
-
let
|
|
1485
|
-
for (let
|
|
1501
|
+
let s = null;
|
|
1502
|
+
for (let i = 0; i <= se; i++) {
|
|
1486
1503
|
try {
|
|
1487
1504
|
const n = await V(this.auth);
|
|
1488
1505
|
if (n.user && n.session)
|
|
1489
1506
|
return n;
|
|
1490
1507
|
} catch (n) {
|
|
1491
|
-
|
|
1508
|
+
s = n;
|
|
1492
1509
|
}
|
|
1493
|
-
|
|
1510
|
+
i < se && await new Promise((n) => setTimeout(n, Le));
|
|
1494
1511
|
}
|
|
1495
|
-
if (
|
|
1496
|
-
throw
|
|
1512
|
+
if (s)
|
|
1513
|
+
throw s;
|
|
1497
1514
|
return {
|
|
1498
1515
|
user: null,
|
|
1499
1516
|
session: null
|
|
@@ -1559,8 +1576,11 @@ class kt {
|
|
|
1559
1576
|
}
|
|
1560
1577
|
}
|
|
1561
1578
|
renderSignInView() {
|
|
1562
|
-
var
|
|
1563
|
-
const e = this.renderOAuthProviders(), i = ((
|
|
1579
|
+
var w, g, S, l;
|
|
1580
|
+
const e = this.renderOAuthProviders(), s = !!((w = this.config) != null && w.emailPasswordEnabled), i = !!((g = this.config) != null && g.emailOtpSignInEnabled), n = s || i, o = s && i, c = i && !s ? "otp" : this.state.signInMethod, h = c === "otp", p = h ? this.state.signInOtpSent ? this.labels.signIn.verifyCodeButton ?? "Verify code" : this.labels.signIn.sendCodeButton ?? "Send code" : this.labels.signIn.submitButton, P = this.countdownText(
|
|
1581
|
+
this.labels.signIn.resendCodeButton ?? "Resend code",
|
|
1582
|
+
this.labels.signIn.resendCountdown ?? "Resend in {seconds}s"
|
|
1583
|
+
);
|
|
1564
1584
|
return `
|
|
1565
1585
|
<section class="${r}__section">
|
|
1566
1586
|
<header class="${r}__header">
|
|
@@ -1568,29 +1588,44 @@ class kt {
|
|
|
1568
1588
|
<p class="${r}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
|
|
1569
1589
|
</header>
|
|
1570
1590
|
${e}
|
|
1571
|
-
${e &&
|
|
1572
|
-
${
|
|
1591
|
+
${e && n ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
|
|
1592
|
+
${n ? `
|
|
1593
|
+
${o ? `
|
|
1594
|
+
<div class="${r}__tabs" role="tablist" aria-label="Sign-in method">
|
|
1595
|
+
<button class="${r}__tab ${c === "password" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="password" ${this.state.busy ? "disabled" : ""}>
|
|
1596
|
+
${this.escape(this.labels.signIn.passwordTab ?? "Password")}
|
|
1597
|
+
</button>
|
|
1598
|
+
<button class="${r}__tab ${c === "otp" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="otp" ${this.state.busy ? "disabled" : ""}>
|
|
1599
|
+
${this.escape(this.labels.signIn.codeTab ?? "Code")}
|
|
1600
|
+
</button>
|
|
1601
|
+
</div>
|
|
1602
|
+
` : ""}
|
|
1573
1603
|
<form class="${r}__form" data-view="sign-in" novalidate>
|
|
1574
1604
|
${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
|
|
1575
|
-
${this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
|
|
1605
|
+
${h ? this.state.signInOtpSent ? this.renderInput("code", this.labels.signIn.codeLabel ?? "Code", "text", this.state.code, "one-time-code") : "" : this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
|
|
1576
1606
|
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
|
|
1577
|
-
${this.escape(
|
|
1607
|
+
${this.escape(p)}
|
|
1578
1608
|
</button>
|
|
1579
1609
|
</form>
|
|
1610
|
+
${h && this.state.signInOtpSent ? `
|
|
1611
|
+
<button class="${r}__text-action" type="button" data-action="resend-sign-in-code" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
|
|
1612
|
+
${this.escape(P)}
|
|
1613
|
+
</button>
|
|
1614
|
+
` : ""}
|
|
1580
1615
|
<div class="${r}__actions">
|
|
1581
|
-
${this.canUsePasswordResetEmailOtp() ? `
|
|
1616
|
+
${!h && this.canUsePasswordResetEmailOtp() ? `
|
|
1582
1617
|
<button class="${r}__link" type="button" data-action="forgot-password" ${this.state.busy ? "disabled" : ""}>
|
|
1583
1618
|
${this.escape(this.labels.signIn.forgotPassword)}
|
|
1584
1619
|
</button>
|
|
1585
1620
|
` : ""}
|
|
1586
|
-
${(
|
|
1621
|
+
${!((S = this.config) != null && S.disableSignUp) && ((l = this.config) != null && l.emailPasswordEnabled) ? `
|
|
1587
1622
|
<p class="${r}__meta">
|
|
1588
1623
|
${this.escape(this.labels.signIn.signUpPrompt)}
|
|
1589
1624
|
<button class="${r}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
|
|
1590
1625
|
${this.escape(this.labels.signIn.switchToSignUp)}
|
|
1591
1626
|
</button>
|
|
1592
1627
|
</p>
|
|
1593
|
-
`}
|
|
1628
|
+
` : ""}
|
|
1594
1629
|
</div>
|
|
1595
1630
|
` : ""}
|
|
1596
1631
|
</section>
|
|
@@ -1698,26 +1733,26 @@ class kt {
|
|
|
1698
1733
|
`;
|
|
1699
1734
|
}
|
|
1700
1735
|
renderOAuthProviders() {
|
|
1701
|
-
var
|
|
1702
|
-
const e = ((
|
|
1736
|
+
var s;
|
|
1737
|
+
const e = ((s = this.config) == null ? void 0 : s.oauthProviders) ?? [];
|
|
1703
1738
|
return e.length === 0 ? "" : `
|
|
1704
1739
|
<div class="${r}__stack">
|
|
1705
|
-
${e.map((
|
|
1706
|
-
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${
|
|
1707
|
-
${this.escape(`${this.labels.oauth.continueWith} ${
|
|
1740
|
+
${e.map((i) => `
|
|
1741
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
|
|
1742
|
+
${this.escape(`${this.labels.oauth.continueWith} ${ie[i]}`)}
|
|
1708
1743
|
</button>
|
|
1709
1744
|
`).join("")}
|
|
1710
1745
|
</div>
|
|
1711
1746
|
`;
|
|
1712
1747
|
}
|
|
1713
|
-
renderInput(e,
|
|
1748
|
+
renderInput(e, s, i, n, o) {
|
|
1714
1749
|
return `
|
|
1715
1750
|
<label class="${r}__field">
|
|
1716
|
-
<span class="${r}__label">${this.escape(
|
|
1751
|
+
<span class="${r}__label">${this.escape(s)}</span>
|
|
1717
1752
|
<input
|
|
1718
1753
|
class="${r}__input"
|
|
1719
1754
|
name="${this.escape(e)}"
|
|
1720
|
-
type="${this.escape(
|
|
1755
|
+
type="${this.escape(i)}"
|
|
1721
1756
|
value="${this.escape(n)}"
|
|
1722
1757
|
autocomplete="${this.escape(o)}"
|
|
1723
1758
|
${this.state.busy ? "disabled" : ""}
|
|
@@ -1729,17 +1764,17 @@ class kt {
|
|
|
1729
1764
|
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1730
1765
|
n.addEventListener("submit", (o) => {
|
|
1731
1766
|
o.preventDefault();
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1767
|
+
const c = n.dataset.view;
|
|
1768
|
+
c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
|
|
1734
1769
|
});
|
|
1735
1770
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1736
1771
|
n.addEventListener("input", () => {
|
|
1737
|
-
|
|
1772
|
+
$t(n.name) && (this.state[n.name] = n.value, n.name === "email" && this.state.signInOtpSent && (this.state.signInOtpSent = !1, this.state.code = "", this.clearCountdown()));
|
|
1738
1773
|
});
|
|
1739
1774
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1740
1775
|
n.addEventListener("click", () => {
|
|
1741
1776
|
const o = n.dataset.action;
|
|
1742
|
-
o === "switch-sign-up" && this.switchView("sign-up"), o === "switch-sign-in" && this.switchView("sign-in"), o === "forgot-password" && this.switchView("forgot-password"), o === "resend-verification" && this.resendVerificationEmail(), o === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), o === "resend-reset-code" && this.resendResetCode(), o === "oauth" && this.handleOAuthSignIn(n.dataset.provider);
|
|
1777
|
+
o === "switch-sign-up" && this.switchView("sign-up"), o === "switch-sign-in" && this.switchView("sign-in"), o === "forgot-password" && this.switchView("forgot-password"), o === "resend-verification" && this.resendVerificationEmail(), o === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), o === "sign-in-method" && this.setSignInMethod(n.dataset.method === "otp" ? "otp" : "password"), o === "resend-sign-in-code" && this.resendSignInCode(), o === "resend-reset-code" && this.resendResetCode(), o === "oauth" && this.handleOAuthSignIn(n.dataset.provider);
|
|
1743
1778
|
});
|
|
1744
1779
|
});
|
|
1745
1780
|
}
|
|
@@ -1747,7 +1782,12 @@ class kt {
|
|
|
1747
1782
|
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();
|
|
1748
1783
|
}
|
|
1749
1784
|
async handleSignIn() {
|
|
1750
|
-
|
|
1785
|
+
var s, i;
|
|
1786
|
+
if (((s = this.config) != null && s.emailOtpSignInEnabled && !((i = this.config) != null && i.emailPasswordEnabled) ? "otp" : this.state.signInMethod) === "otp") {
|
|
1787
|
+
await this.handleEmailOtpSignIn();
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
if (!G(this.state.email)) {
|
|
1751
1791
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1752
1792
|
return;
|
|
1753
1793
|
}
|
|
@@ -1756,23 +1796,73 @@ class kt {
|
|
|
1756
1796
|
return;
|
|
1757
1797
|
}
|
|
1758
1798
|
await this.runAction("Signing in…", async () => {
|
|
1759
|
-
const
|
|
1799
|
+
const n = await this.auth.signIn.email({
|
|
1760
1800
|
email: this.state.email.trim(),
|
|
1761
1801
|
password: this.state.password,
|
|
1762
1802
|
callbackURL: this.getManagedReturnURL(N, this.state.email.trim())
|
|
1763
1803
|
});
|
|
1804
|
+
if (n.error)
|
|
1805
|
+
throw n.error;
|
|
1806
|
+
await this.completeAuth("sign-in");
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
async handleEmailOtpSignIn() {
|
|
1810
|
+
if (!this.canUseEmailOtpSignIn()) {
|
|
1811
|
+
this.handleError(
|
|
1812
|
+
new b("Email OTP sign-in is not enabled for this project.")
|
|
1813
|
+
);
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
if (!G(this.state.email)) {
|
|
1817
|
+
this.failValidation(this.labels.errors.invalidEmail);
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
if (!this.state.signInOtpSent) {
|
|
1821
|
+
await this.sendSignInOtp();
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
if (!Ae(this.state.code)) {
|
|
1825
|
+
this.failValidation(this.labels.errors.invalidCode);
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
await this.runAction("Signing in...", async () => {
|
|
1829
|
+
const e = await this.emailOtpSignInEndpoints().signIn.emailOtp({
|
|
1830
|
+
email: this.state.email.trim(),
|
|
1831
|
+
otp: this.state.code.trim()
|
|
1832
|
+
});
|
|
1764
1833
|
if (e.error)
|
|
1765
1834
|
throw e.error;
|
|
1766
|
-
await this.completeAuth("sign-in");
|
|
1835
|
+
await this.completeAuth("sign-in", await this.resolveAuthCompletionData(e.data));
|
|
1767
1836
|
});
|
|
1768
1837
|
}
|
|
1838
|
+
async sendSignInOtp(e = !1) {
|
|
1839
|
+
await this.runAction("Sending sign-in code...", async () => {
|
|
1840
|
+
var i;
|
|
1841
|
+
const s = await this.emailOtpSignInEndpoints().emailOtp.sendVerificationOtp({
|
|
1842
|
+
email: this.state.email.trim(),
|
|
1843
|
+
type: "sign-in"
|
|
1844
|
+
});
|
|
1845
|
+
if (s.error)
|
|
1846
|
+
throw s.error;
|
|
1847
|
+
if (this.state.signInOtpSent = !0, this.state.code = "", (i = this.config) != null && i.isLocalDev) {
|
|
1848
|
+
this.state.busyLabel = "Dev mode: fetching sign-in code...", this.render();
|
|
1849
|
+
const n = await bt(this.state.email.trim());
|
|
1850
|
+
n ? (this.state.code = n, this.state.notice = `Dev mode: sign-in code auto-filled (${n})`) : this.state.notice = "Dev mode: could not retrieve sign-in code — check server logs";
|
|
1851
|
+
} else
|
|
1852
|
+
this.state.notice = e ? `We sent another sign-in code to ${this.state.email.trim()}.` : `We sent a sign-in code to ${this.state.email.trim()}.`;
|
|
1853
|
+
this.startCountdown();
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
async resendSignInCode() {
|
|
1857
|
+
this.isCountdownActive() || await this.sendSignInOtp(!0);
|
|
1858
|
+
}
|
|
1769
1859
|
async handleSignUp() {
|
|
1770
|
-
var e,
|
|
1860
|
+
var e, s;
|
|
1771
1861
|
if (!this.state.name.trim()) {
|
|
1772
1862
|
this.failValidation(this.labels.errors.requiredField);
|
|
1773
1863
|
return;
|
|
1774
1864
|
}
|
|
1775
|
-
if (!
|
|
1865
|
+
if (!G(this.state.email)) {
|
|
1776
1866
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1777
1867
|
return;
|
|
1778
1868
|
}
|
|
@@ -1782,7 +1872,7 @@ class kt {
|
|
|
1782
1872
|
}
|
|
1783
1873
|
if (this.state.password.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1784
1874
|
this.failValidation(
|
|
1785
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1875
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((s = this.config) == null ? void 0 : s.minPasswordLength) ?? 8))
|
|
1786
1876
|
);
|
|
1787
1877
|
return;
|
|
1788
1878
|
}
|
|
@@ -1792,60 +1882,60 @@ class kt {
|
|
|
1792
1882
|
}
|
|
1793
1883
|
await this.runAction("Creating account…", async () => {
|
|
1794
1884
|
var n;
|
|
1795
|
-
const
|
|
1885
|
+
const i = await this.auth.signUp.email({
|
|
1796
1886
|
name: this.state.name.trim(),
|
|
1797
1887
|
email: this.state.email.trim(),
|
|
1798
1888
|
password: this.state.password,
|
|
1799
|
-
callbackURL: this.getManagedReturnURL(
|
|
1889
|
+
callbackURL: this.getManagedReturnURL(R, this.state.email.trim())
|
|
1800
1890
|
});
|
|
1801
|
-
if (
|
|
1802
|
-
throw
|
|
1891
|
+
if (i.error)
|
|
1892
|
+
throw i.error;
|
|
1803
1893
|
if ((n = this.config) != null && n.requireEmailVerification) {
|
|
1804
|
-
if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up",
|
|
1894
|
+
if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", i.data))
|
|
1805
1895
|
return;
|
|
1806
1896
|
this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = this.config.isLocalDev ? "Dev mode: auto-verify didn’t complete. Click resend to retry." : "Check your inbox to verify your email address.", this.startCountdown();
|
|
1807
1897
|
return;
|
|
1808
1898
|
}
|
|
1809
|
-
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(
|
|
1899
|
+
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(i.data));
|
|
1810
1900
|
});
|
|
1811
1901
|
}
|
|
1812
1902
|
async handleOAuthSignIn(e) {
|
|
1813
|
-
await this.runAction(`Redirecting to ${
|
|
1814
|
-
const
|
|
1903
|
+
await this.runAction(`Redirecting to ${ie[e]}…`, async () => {
|
|
1904
|
+
const s = await this.auth.signIn.social({
|
|
1815
1905
|
provider: e,
|
|
1816
1906
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
1817
1907
|
errorCallbackURL: this.getManagedReturnURL("oauth")
|
|
1818
1908
|
});
|
|
1819
|
-
if (
|
|
1820
|
-
throw
|
|
1821
|
-
const
|
|
1822
|
-
if (!
|
|
1823
|
-
throw new
|
|
1824
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
1909
|
+
if (s.error)
|
|
1910
|
+
throw s.error;
|
|
1911
|
+
const i = this.extractRedirectURL(s.data);
|
|
1912
|
+
if (!i)
|
|
1913
|
+
throw new b(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1914
|
+
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${ie[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1825
1915
|
});
|
|
1826
1916
|
}
|
|
1827
1917
|
async handleForgotPassword() {
|
|
1828
1918
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1829
1919
|
this.handleError(
|
|
1830
|
-
new
|
|
1920
|
+
new b("Password reset via email OTP is not enabled for this project.")
|
|
1831
1921
|
);
|
|
1832
1922
|
return;
|
|
1833
1923
|
}
|
|
1834
|
-
if (!
|
|
1924
|
+
if (!G(this.state.email)) {
|
|
1835
1925
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1836
1926
|
return;
|
|
1837
1927
|
}
|
|
1838
1928
|
await this.runAction("Sending reset code…", async () => {
|
|
1839
|
-
var
|
|
1929
|
+
var s;
|
|
1840
1930
|
const e = await this.passwordResetEndpoints().forgetPassword.emailOtp({
|
|
1841
1931
|
email: this.state.email.trim()
|
|
1842
1932
|
});
|
|
1843
1933
|
if (e.error)
|
|
1844
1934
|
throw e.error;
|
|
1845
|
-
if (this.state.view = "reset-password", (
|
|
1935
|
+
if (this.state.view = "reset-password", (s = this.config) != null && s.isLocalDev) {
|
|
1846
1936
|
this.state.busyLabel = "Dev mode: fetching reset code…", this.render();
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1937
|
+
const i = await wt(this.state.email.trim());
|
|
1938
|
+
i ? (this.state.code = i, this.state.notice = `Dev mode: reset code auto-filled (${i})`) : this.state.notice = "Dev mode: could not retrieve reset code — check server logs";
|
|
1849
1939
|
} else
|
|
1850
1940
|
this.state.notice = `We sent a reset code to ${this.state.email.trim()}.`;
|
|
1851
1941
|
this.startCountdown();
|
|
@@ -1855,14 +1945,14 @@ class kt {
|
|
|
1855
1945
|
this.isCountdownActive() || await this.handleForgotPassword();
|
|
1856
1946
|
}
|
|
1857
1947
|
async handleResetPassword() {
|
|
1858
|
-
var e,
|
|
1948
|
+
var e, s;
|
|
1859
1949
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1860
1950
|
this.handleError(
|
|
1861
|
-
new
|
|
1951
|
+
new b("Password reset via email OTP is not enabled for this project.")
|
|
1862
1952
|
);
|
|
1863
1953
|
return;
|
|
1864
1954
|
}
|
|
1865
|
-
if (!
|
|
1955
|
+
if (!Ae(this.state.code)) {
|
|
1866
1956
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1867
1957
|
return;
|
|
1868
1958
|
}
|
|
@@ -1872,7 +1962,7 @@ class kt {
|
|
|
1872
1962
|
}
|
|
1873
1963
|
if (this.state.newPassword.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1874
1964
|
this.failValidation(
|
|
1875
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1965
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((s = this.config) == null ? void 0 : s.minPasswordLength) ?? 8))
|
|
1876
1966
|
);
|
|
1877
1967
|
return;
|
|
1878
1968
|
}
|
|
@@ -1881,13 +1971,13 @@ class kt {
|
|
|
1881
1971
|
return;
|
|
1882
1972
|
}
|
|
1883
1973
|
await this.runAction("Updating password…", async () => {
|
|
1884
|
-
const
|
|
1974
|
+
const i = await this.passwordResetEndpoints().emailOtp.resetPassword({
|
|
1885
1975
|
email: this.state.email.trim(),
|
|
1886
1976
|
otp: this.state.code.trim(),
|
|
1887
1977
|
password: this.state.newPassword
|
|
1888
1978
|
});
|
|
1889
|
-
if (
|
|
1890
|
-
throw
|
|
1979
|
+
if (i.error)
|
|
1980
|
+
throw i.error;
|
|
1891
1981
|
await this.completePasswordReset();
|
|
1892
1982
|
});
|
|
1893
1983
|
}
|
|
@@ -1896,8 +1986,8 @@ class kt {
|
|
|
1896
1986
|
if ((e = this.config) != null && e.isLocalDev) {
|
|
1897
1987
|
if (this.isCountdownActive()) return;
|
|
1898
1988
|
await this.runAction("Dev mode: retrying auto-verify…", async () => {
|
|
1899
|
-
const
|
|
1900
|
-
if (!await this.tryDevAutoVerify(
|
|
1989
|
+
const s = this.verificationCompletionAction ?? "sign-in";
|
|
1990
|
+
if (!await this.tryDevAutoVerify(s))
|
|
1901
1991
|
throw new Error(
|
|
1902
1992
|
"Dev auto-verify did not complete. Check the edgespark dev logs and try again."
|
|
1903
1993
|
);
|
|
@@ -1911,43 +2001,43 @@ class kt {
|
|
|
1911
2001
|
* auth flow. Returns whether auto-verify completed — callers decide what
|
|
1912
2002
|
* to do on `false` (sign-up falls through to a retry UI; resend throws).
|
|
1913
2003
|
*/
|
|
1914
|
-
async tryDevAutoVerify(e,
|
|
1915
|
-
const
|
|
2004
|
+
async tryDevAutoVerify(e, s) {
|
|
2005
|
+
const i = this.state.email.trim();
|
|
1916
2006
|
try {
|
|
1917
|
-
return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await
|
|
2007
|
+
return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await pt(i) ? (this.state.notice = "Dev mode: email verification auto-completed", await this.completeAuth(e, await this.resolveAuthCompletionData(s)), !0) : (console.warn("[edgespark] Dev auto-verify returned false — falling through"), !1);
|
|
1918
2008
|
} catch (n) {
|
|
1919
2009
|
return console.warn("[edgespark] Dev auto-verify failed:", n), !1;
|
|
1920
2010
|
}
|
|
1921
2011
|
}
|
|
1922
2012
|
async sendVerificationEmail(e) {
|
|
1923
2013
|
!e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
|
|
1924
|
-
const
|
|
2014
|
+
const s = await this.auth.sendVerificationEmail({
|
|
1925
2015
|
email: this.state.email.trim(),
|
|
1926
2016
|
callbackURL: this.getManagedReturnURL(
|
|
1927
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
2017
|
+
this.verificationCompletionAction === "sign-up" ? R : N,
|
|
1928
2018
|
this.state.email.trim()
|
|
1929
2019
|
)
|
|
1930
2020
|
});
|
|
1931
|
-
if (
|
|
1932
|
-
throw
|
|
2021
|
+
if (s.error)
|
|
2022
|
+
throw s.error;
|
|
1933
2023
|
this.handleVerificationEmailSent(this.state.email.trim(), !0);
|
|
1934
2024
|
});
|
|
1935
2025
|
}
|
|
1936
|
-
async completeAuth(e,
|
|
1937
|
-
const
|
|
1938
|
-
|
|
2026
|
+
async completeAuth(e, s) {
|
|
2027
|
+
const i = await this.retryAuthCompletionDataIfNeeded(
|
|
2028
|
+
s ?? await this.resolveAuthCompletionData()
|
|
1939
2029
|
);
|
|
1940
2030
|
if (this.destroyed)
|
|
1941
2031
|
return;
|
|
1942
|
-
if (!
|
|
2032
|
+
if (!i.user || !i.session) {
|
|
1943
2033
|
if (this.destroyed)
|
|
1944
2034
|
return;
|
|
1945
|
-
if (
|
|
2035
|
+
if (i.lookupError && U(this.options)) {
|
|
1946
2036
|
this.navigateToRedirect();
|
|
1947
2037
|
return;
|
|
1948
2038
|
}
|
|
1949
2039
|
if (e === "sign-in")
|
|
1950
|
-
throw
|
|
2040
|
+
throw i.lookupError ?? new Ue(
|
|
1951
2041
|
"Managed sign-in completed without an authenticated session."
|
|
1952
2042
|
);
|
|
1953
2043
|
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();
|
|
@@ -1955,15 +2045,15 @@ class kt {
|
|
|
1955
2045
|
}
|
|
1956
2046
|
const n = {
|
|
1957
2047
|
action: e,
|
|
1958
|
-
user:
|
|
1959
|
-
session:
|
|
2048
|
+
user: i.user,
|
|
2049
|
+
session: i.session
|
|
1960
2050
|
};
|
|
1961
2051
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1962
2052
|
if (U(this.options)) {
|
|
1963
2053
|
this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
|
|
1964
2054
|
return;
|
|
1965
2055
|
}
|
|
1966
|
-
if (
|
|
2056
|
+
if (ne(this.options)) {
|
|
1967
2057
|
this.options.onSuccess(n), this.terminalActionInProgress = !0;
|
|
1968
2058
|
return;
|
|
1969
2059
|
}
|
|
@@ -1972,8 +2062,8 @@ class kt {
|
|
|
1972
2062
|
async retryAuthCompletionDataIfNeeded(e) {
|
|
1973
2063
|
if (e.session)
|
|
1974
2064
|
return e;
|
|
1975
|
-
let
|
|
1976
|
-
for (let
|
|
2065
|
+
let s = e.lookupError;
|
|
2066
|
+
for (let i = 0; i < se; i++) {
|
|
1977
2067
|
await new Promise((n) => setTimeout(n, Le));
|
|
1978
2068
|
try {
|
|
1979
2069
|
const n = await V(this.auth);
|
|
@@ -1983,33 +2073,33 @@ class kt {
|
|
|
1983
2073
|
session: n.session
|
|
1984
2074
|
};
|
|
1985
2075
|
} catch (n) {
|
|
1986
|
-
|
|
2076
|
+
s = n;
|
|
1987
2077
|
}
|
|
1988
2078
|
}
|
|
1989
2079
|
return {
|
|
1990
2080
|
...e,
|
|
1991
|
-
lookupError:
|
|
2081
|
+
lookupError: s ?? e.lookupError
|
|
1992
2082
|
};
|
|
1993
2083
|
}
|
|
1994
2084
|
async syncPublicSessionBestEffort() {
|
|
1995
|
-
var e,
|
|
2085
|
+
var e, s;
|
|
1996
2086
|
try {
|
|
1997
|
-
await ((
|
|
2087
|
+
await ((s = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : s.call(e));
|
|
1998
2088
|
} catch {
|
|
1999
2089
|
}
|
|
2000
2090
|
}
|
|
2001
2091
|
async resolveAuthCompletionData(e) {
|
|
2002
2092
|
try {
|
|
2003
|
-
const
|
|
2093
|
+
const s = await V(this.auth), i = this.extractUser(e);
|
|
2004
2094
|
return {
|
|
2005
|
-
user:
|
|
2006
|
-
session:
|
|
2095
|
+
user: s.user ?? i,
|
|
2096
|
+
session: s.session
|
|
2007
2097
|
};
|
|
2008
|
-
} catch (
|
|
2098
|
+
} catch (s) {
|
|
2009
2099
|
return {
|
|
2010
2100
|
user: this.extractUser(e),
|
|
2011
2101
|
session: null,
|
|
2012
|
-
lookupError:
|
|
2102
|
+
lookupError: s
|
|
2013
2103
|
};
|
|
2014
2104
|
}
|
|
2015
2105
|
}
|
|
@@ -2020,7 +2110,7 @@ class kt {
|
|
|
2020
2110
|
session: null
|
|
2021
2111
|
};
|
|
2022
2112
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
2023
|
-
if (
|
|
2113
|
+
if (ne(this.options)) {
|
|
2024
2114
|
this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
|
|
2025
2115
|
return;
|
|
2026
2116
|
}
|
|
@@ -2032,74 +2122,99 @@ class kt {
|
|
|
2032
2122
|
this.navigateToRedirect();
|
|
2033
2123
|
return;
|
|
2034
2124
|
}
|
|
2035
|
-
if (
|
|
2036
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
2125
|
+
if (ne(this.options))
|
|
2126
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new b(
|
|
2037
2127
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
2038
2128
|
);
|
|
2039
2129
|
}
|
|
2040
|
-
async runAction(e,
|
|
2130
|
+
async runAction(e, s) {
|
|
2041
2131
|
this.state.busy = !0, this.state.busyLabel = e, this.state.error = null, this.state.notice = null, this.render();
|
|
2042
2132
|
try {
|
|
2043
|
-
await
|
|
2044
|
-
} catch (
|
|
2045
|
-
if (this.maybeHandleVerificationRequired(
|
|
2133
|
+
await s();
|
|
2134
|
+
} catch (i) {
|
|
2135
|
+
if (this.maybeHandleVerificationRequired(i))
|
|
2046
2136
|
return;
|
|
2047
|
-
this.handleError(
|
|
2137
|
+
this.handleError(i);
|
|
2048
2138
|
return;
|
|
2049
2139
|
}
|
|
2050
2140
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
2051
2141
|
}
|
|
2052
2142
|
maybeHandleVerificationRequired(e) {
|
|
2053
|
-
return
|
|
2143
|
+
return Q(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);
|
|
2054
2144
|
}
|
|
2055
|
-
handleVerificationEmailSent(e,
|
|
2056
|
-
this.state.notice =
|
|
2145
|
+
handleVerificationEmailSent(e, s) {
|
|
2146
|
+
this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
2057
2147
|
}
|
|
2058
2148
|
invokeRedirectModeSuccessHook(e) {
|
|
2059
|
-
var
|
|
2149
|
+
var s, i;
|
|
2060
2150
|
if (!(!U(this.options) || !this.options.onSuccess))
|
|
2061
2151
|
try {
|
|
2062
2152
|
this.options.onSuccess(e);
|
|
2063
2153
|
} catch (n) {
|
|
2064
|
-
const o =
|
|
2154
|
+
const o = Q(n, "Post-auth callback failed.");
|
|
2065
2155
|
try {
|
|
2066
|
-
(
|
|
2156
|
+
(i = (s = this.options).onError) == null || i.call(s, o);
|
|
2067
2157
|
} catch {
|
|
2068
2158
|
}
|
|
2069
2159
|
}
|
|
2070
2160
|
}
|
|
2071
|
-
handleError(e,
|
|
2161
|
+
handleError(e, s) {
|
|
2072
2162
|
var n, o;
|
|
2073
|
-
const
|
|
2074
|
-
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error =
|
|
2163
|
+
const i = Q(e, s);
|
|
2164
|
+
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (o = (n = this.options).onError) == null || o.call(n, i);
|
|
2075
2165
|
}
|
|
2076
2166
|
failValidation(e) {
|
|
2077
2167
|
this.state.error = e, this.state.notice = null, this.render();
|
|
2078
2168
|
}
|
|
2079
|
-
getManagedReturnURL(e,
|
|
2169
|
+
getManagedReturnURL(e, s) {
|
|
2080
2170
|
if (!e)
|
|
2081
2171
|
return window.location.href;
|
|
2082
|
-
const
|
|
2083
|
-
return
|
|
2172
|
+
const i = new URL(window.location.href);
|
|
2173
|
+
return i.searchParams.set(ee, e), s ? i.searchParams.set(F, s) : i.searchParams.delete(F), i.toString();
|
|
2084
2174
|
}
|
|
2085
2175
|
consumeManagedReturnContext() {
|
|
2086
|
-
const e = new URL(window.location.href),
|
|
2087
|
-
return (
|
|
2088
|
-
marker:
|
|
2176
|
+
const e = new URL(window.location.href), s = e.searchParams.get(ee), i = s === te || s === N || s === R ? s : null, n = e.searchParams.get(F), o = i ? e.searchParams.get("error") : null, c = i ? e.searchParams.get("error_description") : null;
|
|
2177
|
+
return (i || n) && (e.searchParams.delete(ee), e.searchParams.delete(F), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
2178
|
+
marker: i,
|
|
2089
2179
|
email: n,
|
|
2090
2180
|
error: o,
|
|
2091
|
-
errorDescription:
|
|
2181
|
+
errorDescription: c
|
|
2092
2182
|
};
|
|
2093
2183
|
}
|
|
2094
2184
|
startCountdown(e = 60) {
|
|
2095
2185
|
this.countdownUntil = Date.now() + e * 1e3, this.countdownTimer && window.clearInterval(this.countdownTimer), this.countdownTimer = window.setInterval(() => {
|
|
2096
2186
|
if (!this.isCountdownActive()) {
|
|
2097
|
-
this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null), this.
|
|
2187
|
+
this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null), this.updateCountdownControls();
|
|
2098
2188
|
return;
|
|
2099
2189
|
}
|
|
2100
|
-
this.
|
|
2190
|
+
this.updateCountdownControls();
|
|
2101
2191
|
}, 1e3);
|
|
2102
2192
|
}
|
|
2193
|
+
updateCountdownControls() {
|
|
2194
|
+
const e = [
|
|
2195
|
+
{
|
|
2196
|
+
action: "resend-sign-in-code",
|
|
2197
|
+
base: this.labels.signIn.resendCodeButton ?? "Resend code",
|
|
2198
|
+
template: this.labels.signIn.resendCountdown ?? "Resend in {seconds}s"
|
|
2199
|
+
},
|
|
2200
|
+
{
|
|
2201
|
+
action: "resend-verification",
|
|
2202
|
+
base: this.labels.verifyEmail.resendButton,
|
|
2203
|
+
template: this.labels.verifyEmail.resendCountdown
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
action: "resend-reset-code",
|
|
2207
|
+
base: this.labels.resetPassword.resendCodeButton,
|
|
2208
|
+
template: this.labels.resetPassword.resendCountdown
|
|
2209
|
+
}
|
|
2210
|
+
];
|
|
2211
|
+
for (const s of e) {
|
|
2212
|
+
const i = this.root.querySelector(
|
|
2213
|
+
`[data-action="${s.action}"]`
|
|
2214
|
+
);
|
|
2215
|
+
i && (i.textContent = this.countdownText(s.base, s.template), i.disabled = this.state.busy || this.isCountdownActive());
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2103
2218
|
clearCountdown() {
|
|
2104
2219
|
this.countdownUntil = null, this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null);
|
|
2105
2220
|
}
|
|
@@ -2116,14 +2231,14 @@ class kt {
|
|
|
2116
2231
|
this.pendingFocusSnapshot && (this.clearFocusRestoreTimer(), this.focusRestoreTimer = window.setTimeout(() => {
|
|
2117
2232
|
if (this.focusRestoreTimer = null, this.destroyed || !this.pendingFocusSnapshot)
|
|
2118
2233
|
return;
|
|
2119
|
-
const e = this.pendingFocusSnapshot,
|
|
2120
|
-
if (!(!
|
|
2121
|
-
if (
|
|
2234
|
+
const e = this.pendingFocusSnapshot, s = `input[name="${this.escape(e.name)}"][type="${this.escape(e.type)}"]`, i = this.root.querySelector(s);
|
|
2235
|
+
if (!(!i || i.disabled)) {
|
|
2236
|
+
if (i.focus(), e.selectionStart !== null && e.selectionEnd !== null)
|
|
2122
2237
|
try {
|
|
2123
|
-
|
|
2238
|
+
i.setSelectionRange(e.selectionStart, e.selectionEnd);
|
|
2124
2239
|
} catch {
|
|
2125
|
-
const n =
|
|
2126
|
-
|
|
2240
|
+
const n = i.value.length;
|
|
2241
|
+
i.setSelectionRange(n, n);
|
|
2127
2242
|
}
|
|
2128
2243
|
this.pendingFocusSnapshot = null;
|
|
2129
2244
|
}
|
|
@@ -2135,27 +2250,41 @@ class kt {
|
|
|
2135
2250
|
passwordResetEndpoints() {
|
|
2136
2251
|
return this.auth;
|
|
2137
2252
|
}
|
|
2253
|
+
emailOtpSignInEndpoints() {
|
|
2254
|
+
return this.auth;
|
|
2255
|
+
}
|
|
2256
|
+
resolveInitialSignInMethod() {
|
|
2257
|
+
var e, s;
|
|
2258
|
+
return (e = this.config) != null && e.emailPasswordEnabled ? "password" : (s = this.config) != null && s.emailOtpSignInEnabled ? "otp" : "password";
|
|
2259
|
+
}
|
|
2260
|
+
setSignInMethod(e) {
|
|
2261
|
+
this.state.signInMethod !== e && (this.state.signInMethod = e, this.state.signInOtpSent = !1, this.state.code = "", this.state.error = null, this.state.notice = null, this.render());
|
|
2262
|
+
}
|
|
2263
|
+
canUseEmailOtpSignIn() {
|
|
2264
|
+
var e;
|
|
2265
|
+
return !!((e = this.config) != null && e.emailOtpSignInEnabled);
|
|
2266
|
+
}
|
|
2138
2267
|
extractRedirectURL(e) {
|
|
2139
2268
|
if (!e || typeof e != "object")
|
|
2140
2269
|
return null;
|
|
2141
|
-
const
|
|
2142
|
-
return
|
|
2270
|
+
const s = e;
|
|
2271
|
+
return s.redirect && typeof s.url == "string" && s.url.length > 0 ? s.url : null;
|
|
2143
2272
|
}
|
|
2144
2273
|
extractUser(e) {
|
|
2145
2274
|
if (!e || typeof e != "object")
|
|
2146
2275
|
return null;
|
|
2147
|
-
const
|
|
2148
|
-
return
|
|
2276
|
+
const s = e;
|
|
2277
|
+
return s.user && typeof s.user == "object" ? s.user : null;
|
|
2149
2278
|
}
|
|
2150
2279
|
canUsePasswordResetEmailOtp() {
|
|
2151
2280
|
var e;
|
|
2152
2281
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
2153
2282
|
}
|
|
2154
2283
|
handleSessionlessManagedReturn(e) {
|
|
2155
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
2284
|
+
return e.email && (this.state.email = e.email), e.marker === R && !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 === N || e.marker === R ? (this.verificationCompletionAction = e.marker === R ? "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 L(
|
|
2156
2285
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
2157
2286
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
2158
|
-
)) : this.render(), !0) : e.marker ===
|
|
2287
|
+
)) : 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 L(
|
|
2159
2288
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
2160
2289
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
2161
2290
|
)), !0) : !1;
|
|
@@ -2166,199 +2295,200 @@ class kt {
|
|
|
2166
2295
|
getCountdownSecondsRemaining() {
|
|
2167
2296
|
return this.countdownUntil ? Math.max(0, Math.ceil((this.countdownUntil - Date.now()) / 1e3)) : 0;
|
|
2168
2297
|
}
|
|
2169
|
-
countdownText(e,
|
|
2170
|
-
const
|
|
2171
|
-
return
|
|
2298
|
+
countdownText(e, s) {
|
|
2299
|
+
const i = this.getCountdownSecondsRemaining();
|
|
2300
|
+
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2172
2301
|
}
|
|
2173
2302
|
escape(e) {
|
|
2174
|
-
return e.replace(/[&<>"']/g, (
|
|
2303
|
+
return e.replace(/[&<>"']/g, (s) => Ut[s]);
|
|
2175
2304
|
}
|
|
2176
2305
|
}
|
|
2177
2306
|
function Bt(t) {
|
|
2178
2307
|
return "data" in t && t.data ? t.data : t;
|
|
2179
2308
|
}
|
|
2180
|
-
const
|
|
2309
|
+
const Mt = [
|
|
2181
2310
|
{ id: "google", key: "providerGoogle" },
|
|
2182
2311
|
{ id: "apple", key: "providerApple" },
|
|
2183
2312
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2184
2313
|
{ id: "github", key: "providerGithub" },
|
|
2185
2314
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2186
2315
|
{ id: "discord", key: "providerDiscord" }
|
|
2187
|
-
],
|
|
2188
|
-
async function
|
|
2189
|
-
const t = `${window.location.origin}${
|
|
2316
|
+
], Te = 2, Dt = 500;
|
|
2317
|
+
async function Nt() {
|
|
2318
|
+
const t = `${window.location.origin}${ke}/config`;
|
|
2190
2319
|
let e;
|
|
2191
|
-
for (let
|
|
2320
|
+
for (let s = 0; s <= Te; s++)
|
|
2192
2321
|
try {
|
|
2193
|
-
const
|
|
2194
|
-
if (!
|
|
2195
|
-
throw new
|
|
2196
|
-
const n = await
|
|
2197
|
-
return
|
|
2198
|
-
} catch (
|
|
2199
|
-
e =
|
|
2322
|
+
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2323
|
+
if (!i.ok)
|
|
2324
|
+
throw new b(`Failed to load auth config: HTTP ${i.status}`);
|
|
2325
|
+
const n = await i.json(), o = Bt(n);
|
|
2326
|
+
return Vt(o, gt());
|
|
2327
|
+
} catch (i) {
|
|
2328
|
+
e = i, s < Te && await new Promise((n) => setTimeout(n, Dt));
|
|
2200
2329
|
}
|
|
2201
2330
|
throw e;
|
|
2202
2331
|
}
|
|
2203
|
-
let
|
|
2204
|
-
async function
|
|
2205
|
-
return
|
|
2206
|
-
throw
|
|
2207
|
-
})),
|
|
2208
|
-
}
|
|
2209
|
-
function
|
|
2210
|
-
var o,
|
|
2211
|
-
const
|
|
2212
|
-
const
|
|
2213
|
-
return typeof
|
|
2214
|
-
}).map(({ id:
|
|
2332
|
+
let H = null;
|
|
2333
|
+
async function Ce() {
|
|
2334
|
+
return H || (H = Nt().catch((t) => {
|
|
2335
|
+
throw H = null, t;
|
|
2336
|
+
})), H;
|
|
2337
|
+
}
|
|
2338
|
+
function Vt(t, e = !1) {
|
|
2339
|
+
var o, c, h, p, P, w, g, S, l;
|
|
2340
|
+
const s = Mt.filter(({ key: I }) => {
|
|
2341
|
+
const A = t[I];
|
|
2342
|
+
return typeof A == "object" && A !== null && "enabled" in A && !!A.enabled;
|
|
2343
|
+
}).map(({ id: I }) => I), i = t.providerGoogle, n = i != null && i.enabled && typeof ((o = i.config) == null ? void 0 : o.clientId) == "string" ? i.config.clientId : null;
|
|
2215
2344
|
return {
|
|
2216
2345
|
disableSignUp: !!t.disableSignUp,
|
|
2217
|
-
emailPasswordEnabled: !!((
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2346
|
+
emailPasswordEnabled: !!((c = t.providerEmailPassword) != null && c.enabled),
|
|
2347
|
+
emailOtpSignInEnabled: !!((h = t.providerEmailOtp) != null && h.enabled),
|
|
2348
|
+
minPasswordLength: ((P = (p = t.providerEmailPassword) == null ? void 0 : p.config) == null ? void 0 : P.minPasswordLength) ?? 8,
|
|
2349
|
+
requireEmailVerification: !!((g = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && g.requireEmailVerification),
|
|
2350
|
+
passwordResetEmailOtpEnabled: !!((l = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && l.requirePasswordResetEmailVerification),
|
|
2351
|
+
oauthProviders: s,
|
|
2222
2352
|
googleClientId: n,
|
|
2223
2353
|
isLocalDev: e
|
|
2224
2354
|
};
|
|
2225
2355
|
}
|
|
2226
|
-
const
|
|
2227
|
-
let
|
|
2356
|
+
const Ft = "https://accounts.google.com/gsi/client", Re = "data-edgespark-gsi";
|
|
2357
|
+
let z = null;
|
|
2228
2358
|
function re() {
|
|
2229
2359
|
var t, e;
|
|
2230
2360
|
return (e = (t = window.google) == null ? void 0 : t.accounts) == null ? void 0 : e.id;
|
|
2231
2361
|
}
|
|
2232
|
-
function
|
|
2362
|
+
function Gt() {
|
|
2233
2363
|
if (typeof window > "u")
|
|
2234
2364
|
return Promise.reject(new Error("Google Identity Services is unavailable outside the browser."));
|
|
2235
2365
|
const t = re();
|
|
2236
|
-
return t ? Promise.resolve(t) : (
|
|
2237
|
-
const
|
|
2238
|
-
`script[${
|
|
2366
|
+
return t ? Promise.resolve(t) : (z || (z = new Promise((e, s) => {
|
|
2367
|
+
const i = document.querySelector(
|
|
2368
|
+
`script[${Re}]`
|
|
2239
2369
|
);
|
|
2240
|
-
if (
|
|
2370
|
+
if (i) {
|
|
2241
2371
|
const o = re();
|
|
2242
2372
|
if (o) {
|
|
2243
2373
|
e(o);
|
|
2244
2374
|
return;
|
|
2245
2375
|
}
|
|
2246
|
-
|
|
2376
|
+
i.remove();
|
|
2247
2377
|
}
|
|
2248
2378
|
const n = document.createElement("script");
|
|
2249
|
-
n.src =
|
|
2379
|
+
n.src = Ft, n.async = !0, n.defer = !0, n.setAttribute(Re, ""), n.addEventListener(
|
|
2250
2380
|
"load",
|
|
2251
2381
|
() => {
|
|
2252
2382
|
const o = re();
|
|
2253
|
-
o ? e(o) : (n.remove(),
|
|
2383
|
+
o ? e(o) : (n.remove(), s(new Error("Google Identity Services loaded but did not expose google.accounts.id.")));
|
|
2254
2384
|
},
|
|
2255
2385
|
{ once: !0 }
|
|
2256
2386
|
), n.addEventListener(
|
|
2257
2387
|
"error",
|
|
2258
2388
|
() => {
|
|
2259
|
-
n.remove(),
|
|
2389
|
+
n.remove(), s(new Error("Failed to load Google Identity Services."));
|
|
2260
2390
|
},
|
|
2261
2391
|
{ once: !0 }
|
|
2262
2392
|
), document.head.appendChild(n);
|
|
2263
2393
|
}).catch((e) => {
|
|
2264
|
-
throw
|
|
2265
|
-
})),
|
|
2394
|
+
throw z = null, e;
|
|
2395
|
+
})), z);
|
|
2266
2396
|
}
|
|
2267
|
-
function
|
|
2397
|
+
function Ht() {
|
|
2268
2398
|
return { cancel: () => {
|
|
2269
2399
|
} };
|
|
2270
2400
|
}
|
|
2271
|
-
function
|
|
2401
|
+
function zt(t) {
|
|
2272
2402
|
let e = null;
|
|
2273
|
-
return function(
|
|
2403
|
+
return function(i) {
|
|
2274
2404
|
if (typeof window > "u")
|
|
2275
2405
|
return console.error(
|
|
2276
2406
|
"[edgespark] promptGoogleOneTap() requires a browser environment."
|
|
2277
|
-
),
|
|
2407
|
+
), Ht();
|
|
2278
2408
|
if (e)
|
|
2279
2409
|
return console.warn(
|
|
2280
2410
|
"[edgespark] promptGoogleOneTap() is already in flight; returning the existing handle. Call cancel() on the original before re-prompting."
|
|
2281
2411
|
), e;
|
|
2282
2412
|
let n = !1, o = null;
|
|
2283
|
-
const
|
|
2284
|
-
n || (n = !0, e ===
|
|
2285
|
-
},
|
|
2413
|
+
const c = () => {
|
|
2414
|
+
n || (n = !0, e === h && (e = null));
|
|
2415
|
+
}, h = {
|
|
2286
2416
|
cancel() {
|
|
2287
|
-
if (!n && (
|
|
2417
|
+
if (!n && (c(), o))
|
|
2288
2418
|
try {
|
|
2289
2419
|
o.cancel();
|
|
2290
2420
|
} catch {
|
|
2291
2421
|
}
|
|
2292
2422
|
}
|
|
2293
2423
|
}, p = () => {
|
|
2294
|
-
var
|
|
2424
|
+
var g;
|
|
2295
2425
|
if (!n) {
|
|
2296
|
-
|
|
2426
|
+
c();
|
|
2297
2427
|
try {
|
|
2298
|
-
(
|
|
2299
|
-
} catch (
|
|
2300
|
-
console.error("[edgespark] onUnavailable threw:",
|
|
2428
|
+
(g = i == null ? void 0 : i.onUnavailable) == null || g.call(i);
|
|
2429
|
+
} catch (S) {
|
|
2430
|
+
console.error("[edgespark] onUnavailable threw:", S);
|
|
2301
2431
|
}
|
|
2302
2432
|
}
|
|
2303
|
-
},
|
|
2304
|
-
var
|
|
2433
|
+
}, P = (g, S) => {
|
|
2434
|
+
var I;
|
|
2305
2435
|
if (n) return;
|
|
2306
|
-
|
|
2307
|
-
const
|
|
2436
|
+
c();
|
|
2437
|
+
const l = de(g, S);
|
|
2308
2438
|
try {
|
|
2309
|
-
(
|
|
2310
|
-
} catch (
|
|
2311
|
-
console.error("[edgespark] onError threw:",
|
|
2439
|
+
(I = i == null ? void 0 : i.onError) == null || I.call(i, l);
|
|
2440
|
+
} catch (A) {
|
|
2441
|
+
console.error("[edgespark] onError threw:", A);
|
|
2312
2442
|
}
|
|
2313
|
-
},
|
|
2314
|
-
var
|
|
2443
|
+
}, w = (g, S) => {
|
|
2444
|
+
var l;
|
|
2315
2445
|
if (!n) {
|
|
2316
|
-
|
|
2446
|
+
c();
|
|
2317
2447
|
try {
|
|
2318
|
-
(
|
|
2319
|
-
} catch (
|
|
2320
|
-
console.error("[edgespark] onSuccess threw:",
|
|
2448
|
+
(l = i == null ? void 0 : i.onSuccess) == null || l.call(i, { action: "sign-in", user: g, session: S });
|
|
2449
|
+
} catch (I) {
|
|
2450
|
+
console.error("[edgespark] onSuccess threw:", I);
|
|
2321
2451
|
}
|
|
2322
2452
|
}
|
|
2323
2453
|
};
|
|
2324
|
-
return e =
|
|
2325
|
-
let
|
|
2454
|
+
return e = h, (async () => {
|
|
2455
|
+
let g;
|
|
2326
2456
|
try {
|
|
2327
|
-
|
|
2328
|
-
} catch (
|
|
2329
|
-
|
|
2457
|
+
g = await t.loadConfig();
|
|
2458
|
+
} catch (l) {
|
|
2459
|
+
P(l, "Failed to load auth config for Google One Tap.");
|
|
2330
2460
|
return;
|
|
2331
2461
|
}
|
|
2332
2462
|
if (n) return;
|
|
2333
|
-
if (
|
|
2463
|
+
if (g.isLocalDev) {
|
|
2334
2464
|
console.error(
|
|
2335
2465
|
"[edgespark] promptGoogleOneTap() is disabled in local dev mode — Google Identity Services cannot run against mock OAuth."
|
|
2336
|
-
),
|
|
2466
|
+
), c();
|
|
2337
2467
|
return;
|
|
2338
2468
|
}
|
|
2339
|
-
const
|
|
2340
|
-
if (!
|
|
2469
|
+
const S = g.googleClientId;
|
|
2470
|
+
if (!S) {
|
|
2341
2471
|
console.error(
|
|
2342
2472
|
"[edgespark] promptGoogleOneTap() called but Google is not configured. Set `providerGoogle` in `auth-config.yaml` with resolvable credentials."
|
|
2343
|
-
),
|
|
2473
|
+
), c();
|
|
2344
2474
|
return;
|
|
2345
2475
|
}
|
|
2346
2476
|
try {
|
|
2347
|
-
o = await
|
|
2348
|
-
} catch (
|
|
2477
|
+
o = await Gt();
|
|
2478
|
+
} catch (l) {
|
|
2349
2479
|
console.warn(
|
|
2350
2480
|
"[edgespark] Google Identity Services failed to load; treating as unavailable.",
|
|
2351
|
-
|
|
2481
|
+
l
|
|
2352
2482
|
), p();
|
|
2353
2483
|
return;
|
|
2354
2484
|
}
|
|
2355
2485
|
if (!n) {
|
|
2356
2486
|
o.initialize({
|
|
2357
|
-
client_id:
|
|
2358
|
-
callback: (
|
|
2359
|
-
n || typeof (
|
|
2360
|
-
emitSuccess:
|
|
2361
|
-
emitError:
|
|
2487
|
+
client_id: S,
|
|
2488
|
+
callback: (l) => {
|
|
2489
|
+
n || typeof (l == null ? void 0 : l.credential) != "string" || l.credential.length === 0 || xt(l.credential, t, {
|
|
2490
|
+
emitSuccess: w,
|
|
2491
|
+
emitError: P,
|
|
2362
2492
|
isDone: () => n
|
|
2363
2493
|
});
|
|
2364
2494
|
},
|
|
@@ -2367,29 +2497,29 @@ function Ht(t) {
|
|
|
2367
2497
|
context: "signin"
|
|
2368
2498
|
});
|
|
2369
2499
|
try {
|
|
2370
|
-
o.prompt((
|
|
2371
|
-
var
|
|
2500
|
+
o.prompt((l) => {
|
|
2501
|
+
var I, A, D, a;
|
|
2372
2502
|
if (!n) {
|
|
2373
|
-
if ((
|
|
2374
|
-
const
|
|
2375
|
-
if (
|
|
2503
|
+
if ((I = l.isDismissedMoment) != null && I.call(l)) {
|
|
2504
|
+
const m = (A = l.getDismissedReason) == null ? void 0 : A.call(l);
|
|
2505
|
+
if (m === "credential_returned" || m === "cancel_called") return;
|
|
2376
2506
|
p();
|
|
2377
2507
|
return;
|
|
2378
2508
|
}
|
|
2379
|
-
((D =
|
|
2509
|
+
((D = l.isNotDisplayed) != null && D.call(l) || (a = l.isSkippedMoment) != null && a.call(l)) && p();
|
|
2380
2510
|
}
|
|
2381
2511
|
});
|
|
2382
|
-
} catch (
|
|
2383
|
-
|
|
2512
|
+
} catch (l) {
|
|
2513
|
+
P(l, "Failed to prompt Google One Tap.");
|
|
2384
2514
|
}
|
|
2385
2515
|
}
|
|
2386
|
-
})(),
|
|
2516
|
+
})(), h;
|
|
2387
2517
|
};
|
|
2388
2518
|
}
|
|
2389
|
-
async function
|
|
2390
|
-
var
|
|
2391
|
-
const { emitSuccess:
|
|
2392
|
-
if (!((
|
|
2519
|
+
async function xt(t, e, s) {
|
|
2520
|
+
var P;
|
|
2521
|
+
const { emitSuccess: i, emitError: n, isDone: o } = s, c = e.authClient;
|
|
2522
|
+
if (!((P = c.oneTap) != null && P.callback)) {
|
|
2393
2523
|
n(
|
|
2394
2524
|
new L(
|
|
2395
2525
|
"Google One Tap endpoint not registered. Update the EdgeSpark sidecar.",
|
|
@@ -2400,38 +2530,38 @@ async function zt(t, e, i) {
|
|
|
2400
2530
|
return;
|
|
2401
2531
|
}
|
|
2402
2532
|
try {
|
|
2403
|
-
const
|
|
2533
|
+
const w = await c.oneTap.callback({ idToken: t });
|
|
2404
2534
|
if (o()) return;
|
|
2405
|
-
if (
|
|
2535
|
+
if (w.error) {
|
|
2406
2536
|
n(
|
|
2407
2537
|
new L(
|
|
2408
|
-
|
|
2538
|
+
w.error.message ?? "Google One Tap sign-in failed.",
|
|
2409
2539
|
{
|
|
2410
|
-
code:
|
|
2411
|
-
status:
|
|
2412
|
-
cause:
|
|
2540
|
+
code: w.error.code ?? "ONE_TAP_FAILED",
|
|
2541
|
+
status: w.error.status,
|
|
2542
|
+
cause: w.error
|
|
2413
2543
|
}
|
|
2414
2544
|
),
|
|
2415
2545
|
"Google One Tap sign-in failed."
|
|
2416
2546
|
);
|
|
2417
2547
|
return;
|
|
2418
2548
|
}
|
|
2419
|
-
} catch (
|
|
2549
|
+
} catch (w) {
|
|
2420
2550
|
if (o()) return;
|
|
2421
|
-
n(
|
|
2551
|
+
n(w, "Google One Tap sign-in failed.");
|
|
2422
2552
|
return;
|
|
2423
2553
|
}
|
|
2424
|
-
let
|
|
2554
|
+
let h = null, p = null;
|
|
2425
2555
|
try {
|
|
2426
|
-
const
|
|
2556
|
+
const w = await V(e.authClient);
|
|
2427
2557
|
if (o()) return;
|
|
2428
|
-
|
|
2429
|
-
} catch (
|
|
2558
|
+
h = w.user, p = w.session;
|
|
2559
|
+
} catch (w) {
|
|
2430
2560
|
if (o()) return;
|
|
2431
|
-
n(
|
|
2561
|
+
n(w, "Sign-in succeeded but session lookup failed.");
|
|
2432
2562
|
return;
|
|
2433
2563
|
}
|
|
2434
|
-
if (!
|
|
2564
|
+
if (!h || !p) {
|
|
2435
2565
|
n(
|
|
2436
2566
|
new L(
|
|
2437
2567
|
"Google One Tap completed without an authenticated session.",
|
|
@@ -2441,127 +2571,127 @@ async function zt(t, e, i) {
|
|
|
2441
2571
|
);
|
|
2442
2572
|
return;
|
|
2443
2573
|
}
|
|
2444
|
-
|
|
2574
|
+
i(h, p);
|
|
2445
2575
|
}
|
|
2446
|
-
const
|
|
2447
|
-
function
|
|
2576
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
2577
|
+
function jt(t) {
|
|
2448
2578
|
if (!t)
|
|
2449
|
-
throw new
|
|
2579
|
+
throw new b(
|
|
2450
2580
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2451
2581
|
);
|
|
2452
|
-
const e = "redirectTo" in t,
|
|
2453
|
-
if (!e && !
|
|
2454
|
-
throw new
|
|
2582
|
+
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2583
|
+
if (!e && !s)
|
|
2584
|
+
throw new b(
|
|
2455
2585
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2456
2586
|
);
|
|
2457
2587
|
if ("redirectTo" in t) {
|
|
2458
|
-
const
|
|
2459
|
-
if (!(typeof
|
|
2460
|
-
throw new
|
|
2588
|
+
const i = t.redirectTo;
|
|
2589
|
+
if (!(typeof i == "string" || i instanceof URL))
|
|
2590
|
+
throw new b(
|
|
2461
2591
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2462
2592
|
);
|
|
2463
2593
|
}
|
|
2464
2594
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2465
|
-
throw new
|
|
2595
|
+
throw new b(
|
|
2466
2596
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2467
2597
|
);
|
|
2468
2598
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2469
|
-
throw new
|
|
2599
|
+
throw new b(
|
|
2470
2600
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2471
2601
|
);
|
|
2472
2602
|
if ("appearance" in t && t.appearance !== void 0) {
|
|
2473
|
-
const
|
|
2474
|
-
if (!
|
|
2475
|
-
throw new
|
|
2603
|
+
const i = t.appearance;
|
|
2604
|
+
if (!i || typeof i != "object" || Array.isArray(i))
|
|
2605
|
+
throw new b(
|
|
2476
2606
|
"authUI.mount(container, options) expected appearance to be an object."
|
|
2477
2607
|
);
|
|
2478
|
-
if ("theme" in
|
|
2479
|
-
throw new
|
|
2480
|
-
`authUI.mount(container, options) expected appearance.theme to be one of: ${
|
|
2608
|
+
if ("theme" in i && i.theme !== void 0 && !Lt(i.theme))
|
|
2609
|
+
throw new b(
|
|
2610
|
+
`authUI.mount(container, options) expected appearance.theme to be one of: ${Ge.join(", ")}.`
|
|
2481
2611
|
);
|
|
2482
|
-
if ("className" in
|
|
2483
|
-
throw new
|
|
2612
|
+
if ("className" in i && i.className !== void 0 && typeof i.className != "string")
|
|
2613
|
+
throw new b(
|
|
2484
2614
|
"authUI.mount(container, options) expected appearance.className to be a string."
|
|
2485
2615
|
);
|
|
2486
|
-
if ("variables" in
|
|
2487
|
-
if (!
|
|
2488
|
-
throw new
|
|
2616
|
+
if ("variables" in i && i.variables !== void 0) {
|
|
2617
|
+
if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
|
|
2618
|
+
throw new b(
|
|
2489
2619
|
"authUI.mount(container, options) expected appearance.variables to be an object."
|
|
2490
2620
|
);
|
|
2491
|
-
for (const [n, o] of Object.entries(
|
|
2492
|
-
if (!
|
|
2493
|
-
throw new
|
|
2621
|
+
for (const [n, o] of Object.entries(i.variables)) {
|
|
2622
|
+
if (!At(n))
|
|
2623
|
+
throw new b(
|
|
2494
2624
|
`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
|
|
2495
2625
|
);
|
|
2496
2626
|
if (o !== void 0 && typeof o != "string")
|
|
2497
|
-
throw new
|
|
2627
|
+
throw new b(
|
|
2498
2628
|
`authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
|
|
2499
2629
|
);
|
|
2500
2630
|
}
|
|
2501
2631
|
}
|
|
2502
2632
|
}
|
|
2503
2633
|
}
|
|
2504
|
-
function
|
|
2634
|
+
function qt(t) {
|
|
2505
2635
|
if (!(t instanceof HTMLElement))
|
|
2506
|
-
throw new
|
|
2636
|
+
throw new b("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2507
2637
|
}
|
|
2508
|
-
function
|
|
2509
|
-
const
|
|
2638
|
+
function Wt(t, e) {
|
|
2639
|
+
const s = zt({
|
|
2510
2640
|
authClient: e.publicAuthClient,
|
|
2511
|
-
loadConfig:
|
|
2641
|
+
loadConfig: Ce
|
|
2512
2642
|
});
|
|
2513
2643
|
return {
|
|
2514
|
-
mount(
|
|
2644
|
+
mount(i, n) {
|
|
2515
2645
|
var p;
|
|
2516
|
-
|
|
2517
|
-
const o = new
|
|
2646
|
+
jt(n), qt(i), (p = x.get(i)) == null || p.destroy();
|
|
2647
|
+
const o = new Ot(i, t, n, Ce, e), c = o.destroy.bind(o), h = {
|
|
2518
2648
|
destroy() {
|
|
2519
|
-
|
|
2649
|
+
c(), x.get(i) === h && x.delete(i);
|
|
2520
2650
|
}
|
|
2521
2651
|
};
|
|
2522
|
-
return
|
|
2652
|
+
return x.set(i, h), h;
|
|
2523
2653
|
},
|
|
2524
|
-
promptGoogleOneTap:
|
|
2654
|
+
promptGoogleOneTap: s
|
|
2525
2655
|
};
|
|
2526
2656
|
}
|
|
2527
|
-
function
|
|
2528
|
-
|
|
2529
|
-
const t =
|
|
2657
|
+
function Yt() {
|
|
2658
|
+
$e();
|
|
2659
|
+
const t = mt(), e = ft(), s = je(), i = Wt(e, {
|
|
2530
2660
|
syncPublicSession: async () => {
|
|
2531
|
-
await
|
|
2661
|
+
await ht(t);
|
|
2532
2662
|
},
|
|
2533
2663
|
publicAuthClient: t
|
|
2534
2664
|
});
|
|
2535
2665
|
return {
|
|
2536
2666
|
auth: t,
|
|
2537
|
-
api:
|
|
2538
|
-
authUI:
|
|
2667
|
+
api: s,
|
|
2668
|
+
authUI: i
|
|
2539
2669
|
};
|
|
2540
2670
|
}
|
|
2541
2671
|
export {
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2672
|
+
It as AUTH_UI_APPEARANCE_VARIABLE,
|
|
2673
|
+
_t as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
|
|
2674
|
+
Pt as AUTH_UI_DEFAULT_THEME,
|
|
2675
|
+
Ve as AUTH_UI_THEME,
|
|
2676
|
+
Ge as AUTH_UI_THEMES,
|
|
2677
|
+
Et as AUTH_UI_THEME_DARK,
|
|
2678
|
+
Fe as AUTH_UI_THEME_LIGHT,
|
|
2549
2679
|
L as EdgeSparkAuthError,
|
|
2550
|
-
|
|
2680
|
+
b as EdgeSparkConfigError,
|
|
2551
2681
|
le as EdgeSparkError,
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2682
|
+
Ue as EdgeSparkRuntimeError,
|
|
2683
|
+
Pe as ar,
|
|
2684
|
+
Yt as createEdgeSpark,
|
|
2685
|
+
ye as de,
|
|
2686
|
+
St as detectLocale,
|
|
2687
|
+
j as enUS,
|
|
2688
|
+
Z as es,
|
|
2689
|
+
ve as fr,
|
|
2690
|
+
Ie as hi,
|
|
2691
|
+
Se as it,
|
|
2692
|
+
pe as ja,
|
|
2693
|
+
we as ko,
|
|
2694
|
+
be as ptBR,
|
|
2565
2695
|
Ee as ru,
|
|
2566
|
-
|
|
2696
|
+
X as zhCN
|
|
2567
2697
|
};
|