@edgespark/web 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auth/styles/styles.css +59 -2
- package/dist/auth/local-dev.d.ts +5 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +15 -4
- package/dist/auth-ui/config.d.ts +20 -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 +26 -1
- package/dist/index.cjs +28 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +786 -454
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
2
|
-
class
|
|
1
|
+
import { createAuthClient as He } from "better-auth/client";
|
|
2
|
+
class le extends Error {
|
|
3
3
|
constructor(e, s) {
|
|
4
4
|
super(s), this.name = "EdgeSparkError", this.code = e;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
class
|
|
7
|
+
class 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
|
-
class
|
|
17
|
+
class L extends le {
|
|
18
18
|
constructor(e, s) {
|
|
19
19
|
super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
if (t instanceof
|
|
22
|
+
function de(t, e = "Authentication failed.", s) {
|
|
23
|
+
if (t instanceof L)
|
|
24
24
|
return t;
|
|
25
25
|
if (typeof t == "object" && t !== null) {
|
|
26
26
|
const i = t;
|
|
27
|
-
return new
|
|
27
|
+
return new L(i.message || e, {
|
|
28
28
|
code: i.code ?? s,
|
|
29
29
|
status: i.status,
|
|
30
30
|
cause: t
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
return typeof t == "string" ? new
|
|
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
|
-
function
|
|
42
|
-
return
|
|
41
|
+
function oe() {
|
|
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
|
|
48
|
-
if (t.origin !==
|
|
49
|
-
throw new
|
|
50
|
-
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${
|
|
47
|
+
function xe(t) {
|
|
48
|
+
if (t.origin !== oe())
|
|
49
|
+
throw new b(
|
|
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 s =
|
|
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 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 Je {
|
|
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 ue = globalThis.WeakRef, he = globalThis.FinalizationRegistry;
|
|
92
|
+
let W, me = !1;
|
|
93
|
+
const M = /* @__PURE__ */ new Map(), K = he ? new he((t) => {
|
|
94
|
+
M.delete(t);
|
|
95
95
|
}) : null;
|
|
96
|
-
function
|
|
97
|
-
return
|
|
98
|
-
baseURL:
|
|
99
|
-
basePath:
|
|
96
|
+
function Me(t) {
|
|
97
|
+
return He({
|
|
98
|
+
baseURL: oe(),
|
|
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
|
|
106
|
+
function B(t) {
|
|
107
107
|
var e, s;
|
|
108
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,53 +123,53 @@ function Ke(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 s ? new
|
|
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
|
-
async function
|
|
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 [s, i] of
|
|
149
|
+
for (const [s, i] of M) {
|
|
150
150
|
if (s === e.source)
|
|
151
151
|
continue;
|
|
152
152
|
const n = i.deref();
|
|
153
153
|
if (!n) {
|
|
154
|
-
|
|
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
|
-
function
|
|
172
|
-
const e =
|
|
171
|
+
function k(t) {
|
|
172
|
+
const e = Xe(t), s = De();
|
|
173
173
|
let i = !1;
|
|
174
174
|
if (s)
|
|
175
175
|
try {
|
|
@@ -178,15 +178,15 @@ function R(t) {
|
|
|
178
178
|
}
|
|
179
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,286 +195,286 @@ function z(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
|
|
278
|
-
if (
|
|
277
|
+
function lt(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 dt(t, e) {
|
|
284
284
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
285
285
|
return !1;
|
|
286
286
|
const [s] = e;
|
|
287
287
|
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.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 ct(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 ut(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 J(t) {
|
|
302
|
+
return de(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
303
303
|
}
|
|
304
|
-
async function
|
|
304
|
+
async function ht(t) {
|
|
305
305
|
var s, i;
|
|
306
306
|
let e = null;
|
|
307
307
|
try {
|
|
308
|
-
await ((s =
|
|
308
|
+
await ((s = B(t)) == null ? void 0 : s.get().refetch());
|
|
309
309
|
} catch (n) {
|
|
310
310
|
e = n;
|
|
311
311
|
} finally {
|
|
312
|
-
(i = t[
|
|
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
|
-
|
|
317
|
+
function mt() {
|
|
318
|
+
const t = Me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
319
|
+
st(e, t);
|
|
320
320
|
const s = 2, i = 500;
|
|
321
|
-
let n = null,
|
|
322
|
-
const
|
|
323
|
-
var
|
|
324
|
-
const
|
|
325
|
-
return
|
|
326
|
-
},
|
|
327
|
-
var
|
|
328
|
-
let
|
|
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
|
|
331
|
-
let
|
|
330
|
+
for (let I = 0; I <= s; I++) {
|
|
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
|
|
338
|
-
if ((
|
|
339
|
-
return
|
|
340
|
-
if (
|
|
341
|
-
return
|
|
342
|
-
if (
|
|
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
|
+
if (E != null && E.session && (E != null && E.user))
|
|
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() && I < 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
|
|
348
|
+
if (u && !u.error) {
|
|
349
|
+
const C = p();
|
|
350
|
+
return o = !0, h(C);
|
|
351
351
|
}
|
|
352
|
-
|
|
353
|
-
(
|
|
352
|
+
I < s && await new Promise(
|
|
353
|
+
(C) => setTimeout(C, i)
|
|
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: m
|
|
360
360
|
});
|
|
361
|
-
const
|
|
362
|
-
return
|
|
363
|
-
} catch (
|
|
364
|
-
throw n = null,
|
|
361
|
+
const y = p();
|
|
362
|
+
return o = !0, h(y);
|
|
363
|
+
} catch (y) {
|
|
364
|
+
throw n = null, J(y);
|
|
365
365
|
}
|
|
366
366
|
})()), n);
|
|
367
|
-
|
|
367
|
+
P().catch(() => {
|
|
368
368
|
});
|
|
369
|
-
const
|
|
370
|
-
var
|
|
369
|
+
const w = async () => {
|
|
370
|
+
var a, m;
|
|
371
371
|
try {
|
|
372
|
-
const
|
|
373
|
-
if ((
|
|
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
|
-
},
|
|
382
|
-
await
|
|
383
|
-
},
|
|
384
|
-
var
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
let
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
|
|
381
|
+
}, g = async () => {
|
|
382
|
+
await ae(t), k(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
|
|
399
|
-
if (!
|
|
398
|
+
const y = B(t);
|
|
399
|
+
if (!y)
|
|
400
400
|
return () => {
|
|
401
|
-
|
|
401
|
+
m = !0;
|
|
402
402
|
};
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
403
|
+
const I = y.subscribe((u) => {
|
|
404
|
+
if (m || !d || u.error && !u.data)
|
|
405
405
|
return;
|
|
406
|
-
const
|
|
407
|
-
|
|
406
|
+
const E = u.data ?? null;
|
|
407
|
+
T(h(E));
|
|
408
408
|
});
|
|
409
409
|
return () => {
|
|
410
|
-
|
|
410
|
+
m = !0, I();
|
|
411
411
|
};
|
|
412
|
-
},
|
|
413
|
-
const
|
|
414
|
-
return
|
|
415
|
-
},
|
|
416
|
-
if (!
|
|
417
|
-
return
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
return
|
|
421
|
-
const
|
|
422
|
-
get(
|
|
423
|
-
if (
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
426
|
-
if (
|
|
427
|
-
return
|
|
428
|
-
if (
|
|
412
|
+
}, _ = 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", I = 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 || I) && !$(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
|
+
if (!a || typeof a != "object" && typeof a != "function")
|
|
417
|
+
return a;
|
|
418
|
+
const d = A.get(a);
|
|
419
|
+
if (d)
|
|
420
|
+
return d;
|
|
421
|
+
const f = new Proxy(a, {
|
|
422
|
+
get(T, y, I) {
|
|
423
|
+
if (m.length === 0) {
|
|
424
|
+
if (y === "requireSession")
|
|
425
|
+
return w;
|
|
426
|
+
if (y === "onSessionChange")
|
|
427
|
+
return l;
|
|
428
|
+
if (y === Be)
|
|
429
429
|
return () => {
|
|
430
|
-
|
|
430
|
+
k(e);
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
const
|
|
434
|
-
return typeof
|
|
433
|
+
const u = Reflect.get(T, y, I);
|
|
434
|
+
return typeof y != "string" ? u : D(u, [...m, y]);
|
|
435
435
|
},
|
|
436
|
-
apply(
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
439
|
-
throw
|
|
440
|
-
const
|
|
436
|
+
apply(T, y, I) {
|
|
437
|
+
const u = et(m);
|
|
438
|
+
if (u)
|
|
439
|
+
throw u;
|
|
440
|
+
const E = Reflect.apply(
|
|
441
|
+
T,
|
|
441
442
|
y,
|
|
442
|
-
|
|
443
|
-
b
|
|
443
|
+
I
|
|
444
444
|
);
|
|
445
|
-
return
|
|
446
|
-
(
|
|
447
|
-
) :
|
|
445
|
+
return ut(E) ? Promise.resolve(E).then(
|
|
446
|
+
(C) => _(m, I, C)
|
|
447
|
+
) : E;
|
|
448
448
|
}
|
|
449
449
|
});
|
|
450
|
-
return
|
|
450
|
+
return A.set(a, f), f;
|
|
451
451
|
};
|
|
452
|
-
return
|
|
452
|
+
return D(t, []);
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
return
|
|
454
|
+
function ft() {
|
|
455
|
+
return Me({ disableDefaultRedirectPlugin: !0 });
|
|
456
456
|
}
|
|
457
|
-
const
|
|
458
|
-
function
|
|
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
466
|
const s = await fetch(
|
|
467
|
-
`${e}${
|
|
467
|
+
`${e}${ce}/auto-verify?email=${encodeURIComponent(t)}`,
|
|
468
468
|
{ credentials: "include" }
|
|
469
469
|
);
|
|
470
470
|
return s.ok ? (await s.json()).verified === !0 : !1;
|
|
471
471
|
}
|
|
472
|
-
async function
|
|
472
|
+
async function wt(t) {
|
|
473
473
|
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
474
|
if (!e) return null;
|
|
475
475
|
try {
|
|
476
476
|
const s = await fetch(
|
|
477
|
-
`${e}${
|
|
477
|
+
`${e}${ce}/pending-otp?email=${encodeURIComponent(t)}`,
|
|
478
478
|
{ credentials: "include" }
|
|
479
479
|
);
|
|
480
480
|
return s.ok ? (await s.json()).otp ?? null : null;
|
|
@@ -482,28 +482,41 @@ async function ht(t) {
|
|
|
482
482
|
return null;
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
async function bt(t) {
|
|
486
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
487
|
+
if (!e) return null;
|
|
488
|
+
try {
|
|
489
|
+
const s = await fetch(
|
|
490
|
+
`${e}${ce}/pending-sign-in-otp?email=${encodeURIComponent(t)}`,
|
|
491
|
+
{ credentials: "include" }
|
|
492
|
+
);
|
|
493
|
+
return s.ok ? (await s.json()).otp ?? null : null;
|
|
494
|
+
} catch {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function vt(t) {
|
|
486
499
|
const e = (() => {
|
|
487
500
|
if (t instanceof URL)
|
|
488
501
|
return t;
|
|
489
502
|
const s = t.trim();
|
|
490
503
|
if (!s)
|
|
491
|
-
throw new
|
|
504
|
+
throw new b("redirectTo must not be an empty string.");
|
|
492
505
|
try {
|
|
493
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 ft(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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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 N = {
|
|
|
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…",
|
|
@@ -1082,7 +1097,7 @@ const N = {
|
|
|
1082
1097
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
1083
1098
|
generic: "Qualcosa è andato storto. Riprova."
|
|
1084
1099
|
}
|
|
1085
|
-
},
|
|
1100
|
+
}, Ee = {
|
|
1086
1101
|
common: {
|
|
1087
1102
|
loading: "Загрузка входа…",
|
|
1088
1103
|
redirecting: "Перенаправление…",
|
|
@@ -1145,7 +1160,7 @@ const N = {
|
|
|
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 N = {
|
|
|
1208
1223
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
1209
1224
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
1210
1225
|
}
|
|
1211
|
-
},
|
|
1226
|
+
}, _e = {
|
|
1212
1227
|
common: {
|
|
1213
1228
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
1214
1229
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -1271,48 +1286,48 @@ const N = {
|
|
|
1271
1286
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
1272
1287
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1273
1288
|
}
|
|
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":
|
|
1289
|
+
}, Ie = {
|
|
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,
|
|
1310
|
+
ru: Ee,
|
|
1311
|
+
"ru-RU": Ee,
|
|
1312
|
+
ar: Pe,
|
|
1313
|
+
"ar-SA": Pe,
|
|
1314
|
+
hi: _e,
|
|
1315
|
+
"hi-IN": _e
|
|
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 s =
|
|
1322
|
+
const s = Ie[e] ?? Ie[e.split("-")[0]];
|
|
1308
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, _t = {
|
|
1316
1331
|
BACKGROUND: "--edgespark-auth-bg",
|
|
1317
1332
|
BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
|
|
1318
1333
|
CARD_BACKGROUND: "--edgespark-auth-card-bg",
|
|
@@ -1332,31 +1347,31 @@ const Ue = {
|
|
|
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
|
+
}, It = Object.values(
|
|
1351
|
+
_t
|
|
1337
1352
|
);
|
|
1338
|
-
function
|
|
1339
|
-
return typeof t == "string" &&
|
|
1353
|
+
function Lt(t) {
|
|
1354
|
+
return typeof t == "string" && Ge.includes(t);
|
|
1340
1355
|
}
|
|
1341
|
-
function
|
|
1342
|
-
return
|
|
1356
|
+
function At(t) {
|
|
1357
|
+
return It.includes(t);
|
|
1343
1358
|
}
|
|
1344
|
-
function
|
|
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
|
|
1353
|
-
return
|
|
1367
|
+
function Q(t, e = "Authentication failed.") {
|
|
1368
|
+
return de(t, e);
|
|
1354
1369
|
}
|
|
1355
|
-
async function
|
|
1370
|
+
async function V(t) {
|
|
1356
1371
|
var s, i;
|
|
1357
1372
|
const e = await t.getSession();
|
|
1358
1373
|
if (e.error)
|
|
1359
|
-
throw new
|
|
1374
|
+
throw new L(
|
|
1360
1375
|
e.error.message || "Failed to load the current session.",
|
|
1361
1376
|
{
|
|
1362
1377
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1372,13 +1387,13 @@ async function B(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",
|
|
@@ -1386,27 +1401,27 @@ const Pt = "data-edgespark-auth", Lt = "data-edgespark-auth-theme", r = "edgespa
|
|
|
1386
1401
|
gitlab: "GitLab",
|
|
1387
1402
|
discord: "Discord"
|
|
1388
1403
|
};
|
|
1389
|
-
function
|
|
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, s, i, n,
|
|
1409
|
-
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions =
|
|
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,16 +1432,18 @@ class It {
|
|
|
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
|
-
|
|
1426
|
-
e.
|
|
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);
|
|
1443
|
+
e.appendChild(this.root), this.render(), this.initialize();
|
|
1427
1444
|
}
|
|
1428
1445
|
destroy() {
|
|
1429
|
-
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.
|
|
1446
|
+
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.root.remove());
|
|
1430
1447
|
}
|
|
1431
1448
|
async initialize() {
|
|
1432
1449
|
const e = this.consumeManagedReturnContext();
|
|
@@ -1438,20 +1455,20 @@ class It {
|
|
|
1438
1455
|
if (this.destroyed)
|
|
1439
1456
|
return;
|
|
1440
1457
|
if (i.status === "rejected") {
|
|
1441
|
-
if (e.marker && !
|
|
1458
|
+
if (e.marker && !kt(e) && U(this.options)) {
|
|
1442
1459
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1443
1460
|
return;
|
|
1444
1461
|
}
|
|
1445
1462
|
} else {
|
|
1446
|
-
const
|
|
1447
|
-
if (
|
|
1463
|
+
const o = i.value;
|
|
1464
|
+
if (o.user && o.session) {
|
|
1448
1465
|
switch (e.marker) {
|
|
1449
|
-
case
|
|
1450
|
-
case
|
|
1451
|
-
await this.completeAuth("sign-in",
|
|
1466
|
+
case te:
|
|
1467
|
+
case N:
|
|
1468
|
+
await this.completeAuth("sign-in", o);
|
|
1452
1469
|
return;
|
|
1453
|
-
case
|
|
1454
|
-
await this.completeAuth("sign-up",
|
|
1470
|
+
case R:
|
|
1471
|
+
await this.completeAuth("sign-up", o);
|
|
1455
1472
|
return;
|
|
1456
1473
|
default:
|
|
1457
1474
|
break;
|
|
@@ -1462,7 +1479,7 @@ class It {
|
|
|
1462
1479
|
}
|
|
1463
1480
|
if (s.status === "rejected")
|
|
1464
1481
|
throw i.status === "rejected" ? i.reason : s.reason;
|
|
1465
|
-
if (this.config = s.value, this.handleSessionlessManagedReturn(e))
|
|
1482
|
+
if (this.config = s.value, this.state.signInMethod = this.resolveInitialSignInMethod(), this.handleSessionlessManagedReturn(e))
|
|
1466
1483
|
return;
|
|
1467
1484
|
if (i.status === "rejected")
|
|
1468
1485
|
throw i.reason;
|
|
@@ -1473,24 +1490,24 @@ class It {
|
|
|
1473
1490
|
}
|
|
1474
1491
|
}
|
|
1475
1492
|
redirectAfterManagedReturnLookupFailure() {
|
|
1476
|
-
|
|
1493
|
+
U(this.options) && this.navigateToRedirect();
|
|
1477
1494
|
}
|
|
1478
1495
|
navigateToRedirect() {
|
|
1479
|
-
|
|
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
|
-
return
|
|
1500
|
+
return V(this.auth);
|
|
1484
1501
|
let s = null;
|
|
1485
|
-
for (let i = 0; i <=
|
|
1502
|
+
for (let i = 0; i <= se; i++) {
|
|
1486
1503
|
try {
|
|
1487
|
-
const n = await
|
|
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
|
-
i <
|
|
1510
|
+
i < se && await new Promise((n) => setTimeout(n, Le));
|
|
1494
1511
|
}
|
|
1495
1512
|
if (s)
|
|
1496
1513
|
throw s;
|
|
@@ -1559,8 +1576,11 @@ class It {
|
|
|
1559
1576
|
}
|
|
1560
1577
|
}
|
|
1561
1578
|
renderSignInView() {
|
|
1562
|
-
var
|
|
1563
|
-
const e = this.renderOAuthProviders(), s = ((i = this.config)
|
|
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 It {
|
|
|
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>
|
|
@@ -1704,13 +1739,13 @@ class It {
|
|
|
1704
1739
|
<div class="${r}__stack">
|
|
1705
1740
|
${e.map((i) => `
|
|
1706
1741
|
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
|
|
1707
|
-
${this.escape(`${this.labels.oauth.continueWith} ${
|
|
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, s, i, n,
|
|
1748
|
+
renderInput(e, s, i, n, o) {
|
|
1714
1749
|
return `
|
|
1715
1750
|
<label class="${r}__field">
|
|
1716
1751
|
<span class="${r}__label">${this.escape(s)}</span>
|
|
@@ -1719,7 +1754,7 @@ class It {
|
|
|
1719
1754
|
name="${this.escape(e)}"
|
|
1720
1755
|
type="${this.escape(i)}"
|
|
1721
1756
|
value="${this.escape(n)}"
|
|
1722
|
-
autocomplete="${this.escape(
|
|
1757
|
+
autocomplete="${this.escape(o)}"
|
|
1723
1758
|
${this.state.busy ? "disabled" : ""}
|
|
1724
1759
|
/>
|
|
1725
1760
|
</label>
|
|
@@ -1727,19 +1762,19 @@ class It {
|
|
|
1727
1762
|
}
|
|
1728
1763
|
bindDOM() {
|
|
1729
1764
|
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1730
|
-
n.addEventListener("submit", (
|
|
1731
|
-
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1765
|
+
n.addEventListener("submit", (o) => {
|
|
1766
|
+
o.preventDefault();
|
|
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
|
-
const
|
|
1742
|
-
|
|
1776
|
+
const o = n.dataset.action;
|
|
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 It {
|
|
|
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 It {
|
|
|
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
|
-
callbackURL: this.getManagedReturnURL(
|
|
1802
|
+
callbackURL: this.getManagedReturnURL(N, this.state.email.trim())
|
|
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()
|
|
1763
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
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
|
}
|
|
@@ -1796,7 +1886,7 @@ class It {
|
|
|
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
1891
|
if (i.error)
|
|
1802
1892
|
throw i.error;
|
|
@@ -1810,7 +1900,7 @@ class It {
|
|
|
1810
1900
|
});
|
|
1811
1901
|
}
|
|
1812
1902
|
async handleOAuthSignIn(e) {
|
|
1813
|
-
await this.runAction(`Redirecting to ${
|
|
1903
|
+
await this.runAction(`Redirecting to ${ie[e]}…`, async () => {
|
|
1814
1904
|
const s = await this.auth.signIn.social({
|
|
1815
1905
|
provider: e,
|
|
1816
1906
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
@@ -1820,18 +1910,18 @@ class It {
|
|
|
1820
1910
|
throw s.error;
|
|
1821
1911
|
const i = this.extractRedirectURL(s.data);
|
|
1822
1912
|
if (!i)
|
|
1823
|
-
throw new
|
|
1824
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
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
|
}
|
|
@@ -1844,7 +1934,7 @@ class It {
|
|
|
1844
1934
|
throw e.error;
|
|
1845
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 i = await
|
|
1937
|
+
const i = await wt(this.state.email.trim());
|
|
1848
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()}.`;
|
|
@@ -1858,11 +1948,11 @@ class It {
|
|
|
1858
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
|
}
|
|
@@ -1914,7 +2004,7 @@ class It {
|
|
|
1914
2004
|
async tryDevAutoVerify(e, s) {
|
|
1915
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
|
}
|
|
@@ -1924,7 +2014,7 @@ class It {
|
|
|
1924
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
|
});
|
|
@@ -1942,12 +2032,12 @@ class It {
|
|
|
1942
2032
|
if (!i.user || !i.session) {
|
|
1943
2033
|
if (this.destroyed)
|
|
1944
2034
|
return;
|
|
1945
|
-
if (i.lookupError &&
|
|
2035
|
+
if (i.lookupError && U(this.options)) {
|
|
1946
2036
|
this.navigateToRedirect();
|
|
1947
2037
|
return;
|
|
1948
2038
|
}
|
|
1949
2039
|
if (e === "sign-in")
|
|
1950
|
-
throw i.lookupError ?? new
|
|
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();
|
|
@@ -1959,11 +2049,11 @@ class It {
|
|
|
1959
2049
|
session: i.session
|
|
1960
2050
|
};
|
|
1961
2051
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1962
|
-
if (
|
|
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
|
}
|
|
@@ -1973,10 +2063,10 @@ class It {
|
|
|
1973
2063
|
if (e.session)
|
|
1974
2064
|
return e;
|
|
1975
2065
|
let s = e.lookupError;
|
|
1976
|
-
for (let i = 0; i <
|
|
1977
|
-
await new Promise((n) => setTimeout(n,
|
|
2066
|
+
for (let i = 0; i < se; i++) {
|
|
2067
|
+
await new Promise((n) => setTimeout(n, Le));
|
|
1978
2068
|
try {
|
|
1979
|
-
const n = await
|
|
2069
|
+
const n = await V(this.auth);
|
|
1980
2070
|
if (n.user && n.session)
|
|
1981
2071
|
return {
|
|
1982
2072
|
user: n.user,
|
|
@@ -2000,7 +2090,7 @@ class It {
|
|
|
2000
2090
|
}
|
|
2001
2091
|
async resolveAuthCompletionData(e) {
|
|
2002
2092
|
try {
|
|
2003
|
-
const s = await
|
|
2093
|
+
const s = await V(this.auth), i = this.extractUser(e);
|
|
2004
2094
|
return {
|
|
2005
2095
|
user: s.user ?? i,
|
|
2006
2096
|
session: s.session
|
|
@@ -2020,7 +2110,7 @@ class It {
|
|
|
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
|
}
|
|
@@ -2028,12 +2118,12 @@ class It {
|
|
|
2028
2118
|
}
|
|
2029
2119
|
}
|
|
2030
2120
|
handleExistingSessionOnMount() {
|
|
2031
|
-
if (
|
|
2121
|
+
if (U(this.options)) {
|
|
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
|
}
|
|
@@ -2050,28 +2140,28 @@ class It {
|
|
|
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
2145
|
handleVerificationEmailSent(e, s) {
|
|
2056
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
2149
|
var s, i;
|
|
2060
|
-
if (!(!
|
|
2150
|
+
if (!(!U(this.options) || !this.options.onSuccess))
|
|
2061
2151
|
try {
|
|
2062
2152
|
this.options.onSuccess(e);
|
|
2063
2153
|
} catch (n) {
|
|
2064
|
-
const
|
|
2154
|
+
const o = Q(n, "Post-auth callback failed.");
|
|
2065
2155
|
try {
|
|
2066
|
-
(i = (s = this.options).onError) == null || i.call(s,
|
|
2156
|
+
(i = (s = this.options).onError) == null || i.call(s, o);
|
|
2067
2157
|
} catch {
|
|
2068
2158
|
}
|
|
2069
2159
|
}
|
|
2070
2160
|
}
|
|
2071
2161
|
handleError(e, s) {
|
|
2072
|
-
var n,
|
|
2073
|
-
const i =
|
|
2074
|
-
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (
|
|
2162
|
+
var n, o;
|
|
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();
|
|
@@ -2080,15 +2170,15 @@ class It {
|
|
|
2080
2170
|
if (!e)
|
|
2081
2171
|
return window.location.href;
|
|
2082
2172
|
const i = new URL(window.location.href);
|
|
2083
|
-
return i.searchParams.set(
|
|
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), s = e.searchParams.get(
|
|
2087
|
-
return (i || n) && (e.searchParams.delete(
|
|
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())), {
|
|
2088
2178
|
marker: i,
|
|
2089
2179
|
email: n,
|
|
2090
|
-
error:
|
|
2091
|
-
errorDescription:
|
|
2180
|
+
error: o,
|
|
2181
|
+
errorDescription: c
|
|
2092
2182
|
};
|
|
2093
2183
|
}
|
|
2094
2184
|
startCountdown(e = 60) {
|
|
@@ -2135,6 +2225,20 @@ class It {
|
|
|
2135
2225
|
passwordResetEndpoints() {
|
|
2136
2226
|
return this.auth;
|
|
2137
2227
|
}
|
|
2228
|
+
emailOtpSignInEndpoints() {
|
|
2229
|
+
return this.auth;
|
|
2230
|
+
}
|
|
2231
|
+
resolveInitialSignInMethod() {
|
|
2232
|
+
var e, s;
|
|
2233
|
+
return (e = this.config) != null && e.emailPasswordEnabled ? "password" : (s = this.config) != null && s.emailOtpSignInEnabled ? "otp" : "password";
|
|
2234
|
+
}
|
|
2235
|
+
setSignInMethod(e) {
|
|
2236
|
+
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());
|
|
2237
|
+
}
|
|
2238
|
+
canUseEmailOtpSignIn() {
|
|
2239
|
+
var e;
|
|
2240
|
+
return !!((e = this.config) != null && e.emailOtpSignInEnabled);
|
|
2241
|
+
}
|
|
2138
2242
|
extractRedirectURL(e) {
|
|
2139
2243
|
if (!e || typeof e != "object")
|
|
2140
2244
|
return null;
|
|
@@ -2152,10 +2256,10 @@ class It {
|
|
|
2152
2256
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
2153
2257
|
}
|
|
2154
2258
|
handleSessionlessManagedReturn(e) {
|
|
2155
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
2259
|
+
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
2260
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
2157
2261
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
2158
|
-
)) : this.render(), !0) : e.marker ===
|
|
2262
|
+
)) : 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
2263
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
2160
2264
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
2161
2265
|
)), !0) : !1;
|
|
@@ -2171,139 +2275,367 @@ class It {
|
|
|
2171
2275
|
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2172
2276
|
}
|
|
2173
2277
|
escape(e) {
|
|
2174
|
-
return e.replace(/[&<>"']/g, (s) =>
|
|
2278
|
+
return e.replace(/[&<>"']/g, (s) => Ut[s]);
|
|
2175
2279
|
}
|
|
2176
2280
|
}
|
|
2177
|
-
function
|
|
2281
|
+
function Bt(t) {
|
|
2178
2282
|
return "data" in t && t.data ? t.data : t;
|
|
2179
2283
|
}
|
|
2180
|
-
const
|
|
2284
|
+
const Mt = [
|
|
2181
2285
|
{ id: "google", key: "providerGoogle" },
|
|
2182
2286
|
{ id: "apple", key: "providerApple" },
|
|
2183
2287
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2184
2288
|
{ id: "github", key: "providerGithub" },
|
|
2185
2289
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2186
2290
|
{ id: "discord", key: "providerDiscord" }
|
|
2187
|
-
],
|
|
2188
|
-
async function
|
|
2189
|
-
const t = `${window.location.origin}${
|
|
2291
|
+
], Te = 2, Dt = 500;
|
|
2292
|
+
async function Nt() {
|
|
2293
|
+
const t = `${window.location.origin}${ke}/config`;
|
|
2190
2294
|
let e;
|
|
2191
|
-
for (let s = 0; s <=
|
|
2295
|
+
for (let s = 0; s <= Te; s++)
|
|
2192
2296
|
try {
|
|
2193
2297
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2194
2298
|
if (!i.ok)
|
|
2195
|
-
throw new
|
|
2196
|
-
const n = await i.json(),
|
|
2197
|
-
return
|
|
2299
|
+
throw new b(`Failed to load auth config: HTTP ${i.status}`);
|
|
2300
|
+
const n = await i.json(), o = Bt(n);
|
|
2301
|
+
return Vt(o, gt());
|
|
2198
2302
|
} catch (i) {
|
|
2199
|
-
e = i, s <
|
|
2303
|
+
e = i, s < Te && await new Promise((n) => setTimeout(n, Dt));
|
|
2200
2304
|
}
|
|
2201
2305
|
throw e;
|
|
2202
2306
|
}
|
|
2203
|
-
let
|
|
2204
|
-
async function
|
|
2205
|
-
return
|
|
2206
|
-
throw
|
|
2207
|
-
})),
|
|
2208
|
-
}
|
|
2209
|
-
function
|
|
2210
|
-
var
|
|
2211
|
-
const s =
|
|
2212
|
-
const
|
|
2213
|
-
return typeof
|
|
2214
|
-
}).map(({ id:
|
|
2307
|
+
let H = null;
|
|
2308
|
+
async function Ce() {
|
|
2309
|
+
return H || (H = Nt().catch((t) => {
|
|
2310
|
+
throw H = null, t;
|
|
2311
|
+
})), H;
|
|
2312
|
+
}
|
|
2313
|
+
function Vt(t, e = !1) {
|
|
2314
|
+
var o, c, h, p, P, w, g, S, l;
|
|
2315
|
+
const s = Mt.filter(({ key: _ }) => {
|
|
2316
|
+
const A = t[_];
|
|
2317
|
+
return typeof A == "object" && A !== null && "enabled" in A && !!A.enabled;
|
|
2318
|
+
}).map(({ id: _ }) => _), i = t.providerGoogle, n = i != null && i.enabled && typeof ((o = i.config) == null ? void 0 : o.clientId) == "string" ? i.config.clientId : null;
|
|
2215
2319
|
return {
|
|
2216
2320
|
disableSignUp: !!t.disableSignUp,
|
|
2217
|
-
emailPasswordEnabled: !!((
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2321
|
+
emailPasswordEnabled: !!((c = t.providerEmailPassword) != null && c.enabled),
|
|
2322
|
+
emailOtpSignInEnabled: !!((h = t.providerEmailOtp) != null && h.enabled),
|
|
2323
|
+
minPasswordLength: ((P = (p = t.providerEmailPassword) == null ? void 0 : p.config) == null ? void 0 : P.minPasswordLength) ?? 8,
|
|
2324
|
+
requireEmailVerification: !!((g = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && g.requireEmailVerification),
|
|
2325
|
+
passwordResetEmailOtpEnabled: !!((l = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && l.requirePasswordResetEmailVerification),
|
|
2221
2326
|
oauthProviders: s,
|
|
2327
|
+
googleClientId: n,
|
|
2222
2328
|
isLocalDev: e
|
|
2223
2329
|
};
|
|
2224
2330
|
}
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2331
|
+
const Ft = "https://accounts.google.com/gsi/client", Re = "data-edgespark-gsi";
|
|
2332
|
+
let z = null;
|
|
2333
|
+
function re() {
|
|
2334
|
+
var t, e;
|
|
2335
|
+
return (e = (t = window.google) == null ? void 0 : t.accounts) == null ? void 0 : e.id;
|
|
2336
|
+
}
|
|
2337
|
+
function Gt() {
|
|
2338
|
+
if (typeof window > "u")
|
|
2339
|
+
return Promise.reject(new Error("Google Identity Services is unavailable outside the browser."));
|
|
2340
|
+
const t = re();
|
|
2341
|
+
return t ? Promise.resolve(t) : (z || (z = new Promise((e, s) => {
|
|
2342
|
+
const i = document.querySelector(
|
|
2343
|
+
`script[${Re}]`
|
|
2344
|
+
);
|
|
2345
|
+
if (i) {
|
|
2346
|
+
const o = re();
|
|
2347
|
+
if (o) {
|
|
2348
|
+
e(o);
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
i.remove();
|
|
2352
|
+
}
|
|
2353
|
+
const n = document.createElement("script");
|
|
2354
|
+
n.src = Ft, n.async = !0, n.defer = !0, n.setAttribute(Re, ""), n.addEventListener(
|
|
2355
|
+
"load",
|
|
2356
|
+
() => {
|
|
2357
|
+
const o = re();
|
|
2358
|
+
o ? e(o) : (n.remove(), s(new Error("Google Identity Services loaded but did not expose google.accounts.id.")));
|
|
2359
|
+
},
|
|
2360
|
+
{ once: !0 }
|
|
2361
|
+
), n.addEventListener(
|
|
2362
|
+
"error",
|
|
2363
|
+
() => {
|
|
2364
|
+
n.remove(), s(new Error("Failed to load Google Identity Services."));
|
|
2365
|
+
},
|
|
2366
|
+
{ once: !0 }
|
|
2367
|
+
), document.head.appendChild(n);
|
|
2368
|
+
}).catch((e) => {
|
|
2369
|
+
throw z = null, e;
|
|
2370
|
+
})), z);
|
|
2371
|
+
}
|
|
2372
|
+
function Ht() {
|
|
2373
|
+
return { cancel: () => {
|
|
2374
|
+
} };
|
|
2375
|
+
}
|
|
2376
|
+
function zt(t) {
|
|
2377
|
+
let e = null;
|
|
2378
|
+
return function(i) {
|
|
2379
|
+
if (typeof window > "u")
|
|
2380
|
+
return console.error(
|
|
2381
|
+
"[edgespark] promptGoogleOneTap() requires a browser environment."
|
|
2382
|
+
), Ht();
|
|
2383
|
+
if (e)
|
|
2384
|
+
return console.warn(
|
|
2385
|
+
"[edgespark] promptGoogleOneTap() is already in flight; returning the existing handle. Call cancel() on the original before re-prompting."
|
|
2386
|
+
), e;
|
|
2387
|
+
let n = !1, o = null;
|
|
2388
|
+
const c = () => {
|
|
2389
|
+
n || (n = !0, e === h && (e = null));
|
|
2390
|
+
}, h = {
|
|
2391
|
+
cancel() {
|
|
2392
|
+
if (!n && (c(), o))
|
|
2393
|
+
try {
|
|
2394
|
+
o.cancel();
|
|
2395
|
+
} catch {
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
}, p = () => {
|
|
2399
|
+
var g;
|
|
2400
|
+
if (!n) {
|
|
2401
|
+
c();
|
|
2402
|
+
try {
|
|
2403
|
+
(g = i == null ? void 0 : i.onUnavailable) == null || g.call(i);
|
|
2404
|
+
} catch (S) {
|
|
2405
|
+
console.error("[edgespark] onUnavailable threw:", S);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
}, P = (g, S) => {
|
|
2409
|
+
var _;
|
|
2410
|
+
if (n) return;
|
|
2411
|
+
c();
|
|
2412
|
+
const l = de(g, S);
|
|
2413
|
+
try {
|
|
2414
|
+
(_ = i == null ? void 0 : i.onError) == null || _.call(i, l);
|
|
2415
|
+
} catch (A) {
|
|
2416
|
+
console.error("[edgespark] onError threw:", A);
|
|
2417
|
+
}
|
|
2418
|
+
}, w = (g, S) => {
|
|
2419
|
+
var l;
|
|
2420
|
+
if (!n) {
|
|
2421
|
+
c();
|
|
2422
|
+
try {
|
|
2423
|
+
(l = i == null ? void 0 : i.onSuccess) == null || l.call(i, { action: "sign-in", user: g, session: S });
|
|
2424
|
+
} catch (_) {
|
|
2425
|
+
console.error("[edgespark] onSuccess threw:", _);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
return e = h, (async () => {
|
|
2430
|
+
let g;
|
|
2431
|
+
try {
|
|
2432
|
+
g = await t.loadConfig();
|
|
2433
|
+
} catch (l) {
|
|
2434
|
+
P(l, "Failed to load auth config for Google One Tap.");
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2437
|
+
if (n) return;
|
|
2438
|
+
if (g.isLocalDev) {
|
|
2439
|
+
console.error(
|
|
2440
|
+
"[edgespark] promptGoogleOneTap() is disabled in local dev mode — Google Identity Services cannot run against mock OAuth."
|
|
2441
|
+
), c();
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
const S = g.googleClientId;
|
|
2445
|
+
if (!S) {
|
|
2446
|
+
console.error(
|
|
2447
|
+
"[edgespark] promptGoogleOneTap() called but Google is not configured. Set `providerGoogle` in `auth-config.yaml` with resolvable credentials."
|
|
2448
|
+
), c();
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
try {
|
|
2452
|
+
o = await Gt();
|
|
2453
|
+
} catch (l) {
|
|
2454
|
+
console.warn(
|
|
2455
|
+
"[edgespark] Google Identity Services failed to load; treating as unavailable.",
|
|
2456
|
+
l
|
|
2457
|
+
), p();
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
if (!n) {
|
|
2461
|
+
o.initialize({
|
|
2462
|
+
client_id: S,
|
|
2463
|
+
callback: (l) => {
|
|
2464
|
+
n || typeof (l == null ? void 0 : l.credential) != "string" || l.credential.length === 0 || xt(l.credential, t, {
|
|
2465
|
+
emitSuccess: w,
|
|
2466
|
+
emitError: P,
|
|
2467
|
+
isDone: () => n
|
|
2468
|
+
});
|
|
2469
|
+
},
|
|
2470
|
+
cancel_on_tap_outside: !1,
|
|
2471
|
+
use_fedcm_for_prompt: !0,
|
|
2472
|
+
context: "signin"
|
|
2473
|
+
});
|
|
2474
|
+
try {
|
|
2475
|
+
o.prompt((l) => {
|
|
2476
|
+
var _, A, D, a;
|
|
2477
|
+
if (!n) {
|
|
2478
|
+
if ((_ = l.isDismissedMoment) != null && _.call(l)) {
|
|
2479
|
+
const m = (A = l.getDismissedReason) == null ? void 0 : A.call(l);
|
|
2480
|
+
if (m === "credential_returned" || m === "cancel_called") return;
|
|
2481
|
+
p();
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
((D = l.isNotDisplayed) != null && D.call(l) || (a = l.isSkippedMoment) != null && a.call(l)) && p();
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
} catch (l) {
|
|
2488
|
+
P(l, "Failed to prompt Google One Tap.");
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
})(), h;
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
async function xt(t, e, s) {
|
|
2495
|
+
var P;
|
|
2496
|
+
const { emitSuccess: i, emitError: n, isDone: o } = s, c = e.authClient;
|
|
2497
|
+
if (!((P = c.oneTap) != null && P.callback)) {
|
|
2498
|
+
n(
|
|
2499
|
+
new L(
|
|
2500
|
+
"Google One Tap endpoint not registered. Update the EdgeSpark sidecar.",
|
|
2501
|
+
{ code: "ONE_TAP_UNAVAILABLE" }
|
|
2502
|
+
),
|
|
2503
|
+
"Google One Tap endpoint not registered."
|
|
2504
|
+
);
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
try {
|
|
2508
|
+
const w = await c.oneTap.callback({ idToken: t });
|
|
2509
|
+
if (o()) return;
|
|
2510
|
+
if (w.error) {
|
|
2511
|
+
n(
|
|
2512
|
+
new L(
|
|
2513
|
+
w.error.message ?? "Google One Tap sign-in failed.",
|
|
2514
|
+
{
|
|
2515
|
+
code: w.error.code ?? "ONE_TAP_FAILED",
|
|
2516
|
+
status: w.error.status,
|
|
2517
|
+
cause: w.error
|
|
2518
|
+
}
|
|
2519
|
+
),
|
|
2520
|
+
"Google One Tap sign-in failed."
|
|
2521
|
+
);
|
|
2522
|
+
return;
|
|
2523
|
+
}
|
|
2524
|
+
} catch (w) {
|
|
2525
|
+
if (o()) return;
|
|
2526
|
+
n(w, "Google One Tap sign-in failed.");
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2529
|
+
let h = null, p = null;
|
|
2530
|
+
try {
|
|
2531
|
+
const w = await V(e.authClient);
|
|
2532
|
+
if (o()) return;
|
|
2533
|
+
h = w.user, p = w.session;
|
|
2534
|
+
} catch (w) {
|
|
2535
|
+
if (o()) return;
|
|
2536
|
+
n(w, "Sign-in succeeded but session lookup failed.");
|
|
2537
|
+
return;
|
|
2538
|
+
}
|
|
2539
|
+
if (!h || !p) {
|
|
2540
|
+
n(
|
|
2541
|
+
new L(
|
|
2542
|
+
"Google One Tap completed without an authenticated session.",
|
|
2543
|
+
{ code: "ONE_TAP_NO_SESSION" }
|
|
2544
|
+
),
|
|
2545
|
+
"Google One Tap completed without an authenticated session."
|
|
2546
|
+
);
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
i(h, p);
|
|
2550
|
+
}
|
|
2551
|
+
const x = /* @__PURE__ */ new WeakMap();
|
|
2552
|
+
function jt(t) {
|
|
2227
2553
|
if (!t)
|
|
2228
|
-
throw new
|
|
2554
|
+
throw new b(
|
|
2229
2555
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2230
2556
|
);
|
|
2231
2557
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2232
2558
|
if (!e && !s)
|
|
2233
|
-
throw new
|
|
2559
|
+
throw new b(
|
|
2234
2560
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2235
2561
|
);
|
|
2236
2562
|
if ("redirectTo" in t) {
|
|
2237
2563
|
const i = t.redirectTo;
|
|
2238
2564
|
if (!(typeof i == "string" || i instanceof URL))
|
|
2239
|
-
throw new
|
|
2565
|
+
throw new b(
|
|
2240
2566
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2241
2567
|
);
|
|
2242
2568
|
}
|
|
2243
2569
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2244
|
-
throw new
|
|
2570
|
+
throw new b(
|
|
2245
2571
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2246
2572
|
);
|
|
2247
2573
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2248
|
-
throw new
|
|
2574
|
+
throw new b(
|
|
2249
2575
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2250
2576
|
);
|
|
2251
2577
|
if ("appearance" in t && t.appearance !== void 0) {
|
|
2252
2578
|
const i = t.appearance;
|
|
2253
2579
|
if (!i || typeof i != "object" || Array.isArray(i))
|
|
2254
|
-
throw new
|
|
2580
|
+
throw new b(
|
|
2255
2581
|
"authUI.mount(container, options) expected appearance to be an object."
|
|
2256
2582
|
);
|
|
2257
|
-
if ("theme" in i && i.theme !== void 0 && !
|
|
2258
|
-
throw new
|
|
2259
|
-
`authUI.mount(container, options) expected appearance.theme to be one of: ${
|
|
2583
|
+
if ("theme" in i && i.theme !== void 0 && !Lt(i.theme))
|
|
2584
|
+
throw new b(
|
|
2585
|
+
`authUI.mount(container, options) expected appearance.theme to be one of: ${Ge.join(", ")}.`
|
|
2260
2586
|
);
|
|
2261
2587
|
if ("className" in i && i.className !== void 0 && typeof i.className != "string")
|
|
2262
|
-
throw new
|
|
2588
|
+
throw new b(
|
|
2263
2589
|
"authUI.mount(container, options) expected appearance.className to be a string."
|
|
2264
2590
|
);
|
|
2265
2591
|
if ("variables" in i && i.variables !== void 0) {
|
|
2266
2592
|
if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
|
|
2267
|
-
throw new
|
|
2593
|
+
throw new b(
|
|
2268
2594
|
"authUI.mount(container, options) expected appearance.variables to be an object."
|
|
2269
2595
|
);
|
|
2270
|
-
for (const [n,
|
|
2271
|
-
if (!
|
|
2272
|
-
throw new
|
|
2596
|
+
for (const [n, o] of Object.entries(i.variables)) {
|
|
2597
|
+
if (!At(n))
|
|
2598
|
+
throw new b(
|
|
2273
2599
|
`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
|
|
2274
2600
|
);
|
|
2275
|
-
if (
|
|
2276
|
-
throw new
|
|
2601
|
+
if (o !== void 0 && typeof o != "string")
|
|
2602
|
+
throw new b(
|
|
2277
2603
|
`authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
|
|
2278
2604
|
);
|
|
2279
2605
|
}
|
|
2280
2606
|
}
|
|
2281
2607
|
}
|
|
2282
2608
|
}
|
|
2283
|
-
function
|
|
2609
|
+
function qt(t) {
|
|
2284
2610
|
if (!(t instanceof HTMLElement))
|
|
2285
|
-
throw new
|
|
2611
|
+
throw new b("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2286
2612
|
}
|
|
2287
|
-
function
|
|
2613
|
+
function Wt(t, e) {
|
|
2614
|
+
const s = zt({
|
|
2615
|
+
authClient: e.publicAuthClient,
|
|
2616
|
+
loadConfig: Ce
|
|
2617
|
+
});
|
|
2288
2618
|
return {
|
|
2289
|
-
mount(
|
|
2290
|
-
var
|
|
2291
|
-
|
|
2292
|
-
const
|
|
2619
|
+
mount(i, n) {
|
|
2620
|
+
var p;
|
|
2621
|
+
jt(n), qt(i), (p = x.get(i)) == null || p.destroy();
|
|
2622
|
+
const o = new Ot(i, t, n, Ce, e), c = o.destroy.bind(o), h = {
|
|
2293
2623
|
destroy() {
|
|
2294
|
-
|
|
2624
|
+
c(), x.get(i) === h && x.delete(i);
|
|
2295
2625
|
}
|
|
2296
2626
|
};
|
|
2297
|
-
return
|
|
2298
|
-
}
|
|
2627
|
+
return x.set(i, h), h;
|
|
2628
|
+
},
|
|
2629
|
+
promptGoogleOneTap: s
|
|
2299
2630
|
};
|
|
2300
2631
|
}
|
|
2301
|
-
function
|
|
2302
|
-
|
|
2303
|
-
const t =
|
|
2632
|
+
function Yt() {
|
|
2633
|
+
$e();
|
|
2634
|
+
const t = mt(), e = ft(), s = je(), i = Wt(e, {
|
|
2304
2635
|
syncPublicSession: async () => {
|
|
2305
|
-
await
|
|
2306
|
-
}
|
|
2636
|
+
await ht(t);
|
|
2637
|
+
},
|
|
2638
|
+
publicAuthClient: t
|
|
2307
2639
|
});
|
|
2308
2640
|
return {
|
|
2309
2641
|
auth: t,
|
|
@@ -2312,29 +2644,29 @@ function Ft() {
|
|
|
2312
2644
|
};
|
|
2313
2645
|
}
|
|
2314
2646
|
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
|
-
|
|
2647
|
+
_t as AUTH_UI_APPEARANCE_VARIABLE,
|
|
2648
|
+
It as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
|
|
2649
|
+
Pt as AUTH_UI_DEFAULT_THEME,
|
|
2650
|
+
Ve as AUTH_UI_THEME,
|
|
2651
|
+
Ge as AUTH_UI_THEMES,
|
|
2652
|
+
Et as AUTH_UI_THEME_DARK,
|
|
2653
|
+
Fe as AUTH_UI_THEME_LIGHT,
|
|
2654
|
+
L as EdgeSparkAuthError,
|
|
2655
|
+
b as EdgeSparkConfigError,
|
|
2656
|
+
le as EdgeSparkError,
|
|
2657
|
+
Ue as EdgeSparkRuntimeError,
|
|
2658
|
+
Pe as ar,
|
|
2659
|
+
Yt as createEdgeSpark,
|
|
2660
|
+
ye as de,
|
|
2661
|
+
St as detectLocale,
|
|
2662
|
+
j as enUS,
|
|
2663
|
+
Z as es,
|
|
2664
|
+
ve as fr,
|
|
2665
|
+
_e as hi,
|
|
2666
|
+
Se as it,
|
|
2667
|
+
pe as ja,
|
|
2668
|
+
we as ko,
|
|
2669
|
+
be as ptBR,
|
|
2670
|
+
Ee as ru,
|
|
2671
|
+
X as zhCN
|
|
2340
2672
|
};
|