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