@edgespark/web 0.0.2 → 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/auth/styles/styles.css +10 -0
- package/dist/auth/local-dev.d.ts +31 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +15 -4
- package/dist/auth-ui/config.d.ts +17 -1
- 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 +14 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +844 -549
- 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 _e = "/api/_es/auth", Fe = "edgespark-auth-session", Le = "__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 Ge(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,287 +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
|
-
}, A = () =>
|
|
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
|
-
A().then((
|
|
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
|
|
453
|
-
}
|
|
454
|
-
function
|
|
455
|
-
return
|
|
452
|
+
return D(t, []);
|
|
453
|
+
}
|
|
454
|
+
function mt() {
|
|
455
|
+
return Be({ disableDefaultRedirectPlugin: !0 });
|
|
456
|
+
}
|
|
457
|
+
const De = "/api/_es/dev";
|
|
458
|
+
function ft() {
|
|
459
|
+
if (typeof document > "u") return !1;
|
|
460
|
+
const t = document.querySelector('meta[name="edgespark-local-dev"]');
|
|
461
|
+
return (t == null ? void 0 : t.getAttribute("content")) === "true";
|
|
462
|
+
}
|
|
463
|
+
async function wt(t) {
|
|
464
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
465
|
+
if (!e) return !1;
|
|
466
|
+
const i = await fetch(
|
|
467
|
+
`${e}${De}/auto-verify?email=${encodeURIComponent(t)}`,
|
|
468
|
+
{ credentials: "include" }
|
|
469
|
+
);
|
|
470
|
+
return i.ok ? (await i.json()).verified === !0 : !1;
|
|
471
|
+
}
|
|
472
|
+
async function gt(t) {
|
|
473
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
|
+
if (!e) return null;
|
|
475
|
+
try {
|
|
476
|
+
const i = await fetch(
|
|
477
|
+
`${e}${De}/pending-otp?email=${encodeURIComponent(t)}`,
|
|
478
|
+
{ credentials: "include" }
|
|
479
|
+
);
|
|
480
|
+
return i.ok ? (await i.json()).otp ?? null : null;
|
|
481
|
+
} catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
456
484
|
}
|
|
457
|
-
function
|
|
485
|
+
function pt(t) {
|
|
458
486
|
const e = (() => {
|
|
459
487
|
if (t instanceof URL)
|
|
460
488
|
return t;
|
|
461
|
-
const
|
|
462
|
-
if (!
|
|
463
|
-
throw new
|
|
489
|
+
const i = t.trim();
|
|
490
|
+
if (!i)
|
|
491
|
+
throw new g("redirectTo must not be an empty string.");
|
|
464
492
|
try {
|
|
465
|
-
return new URL(
|
|
493
|
+
return new URL(i, window.location.href);
|
|
466
494
|
} catch {
|
|
467
|
-
throw new
|
|
495
|
+
throw new g(
|
|
468
496
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
469
497
|
);
|
|
470
498
|
}
|
|
471
499
|
})();
|
|
472
500
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
473
|
-
throw new
|
|
501
|
+
throw new g(
|
|
474
502
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
475
503
|
);
|
|
476
504
|
return e;
|
|
477
505
|
}
|
|
478
|
-
function
|
|
506
|
+
function bt(t, e) {
|
|
479
507
|
return e ? {
|
|
480
508
|
common: { ...t.common, ...e.common },
|
|
481
509
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -487,7 +515,7 @@ function ct(t, e) {
|
|
|
487
515
|
errors: { ...t.errors, ...e.errors }
|
|
488
516
|
} : t;
|
|
489
517
|
}
|
|
490
|
-
const
|
|
518
|
+
const x = {
|
|
491
519
|
common: {
|
|
492
520
|
loading: "Loading sign-in…",
|
|
493
521
|
redirecting: "Redirecting…",
|
|
@@ -550,7 +578,7 @@ const V = {
|
|
|
550
578
|
invalidCode: "Enter the 6-digit verification code.",
|
|
551
579
|
generic: "Something went wrong. Please try again."
|
|
552
580
|
}
|
|
553
|
-
},
|
|
581
|
+
}, J = {
|
|
554
582
|
common: {
|
|
555
583
|
loading: "加载中…",
|
|
556
584
|
redirecting: "跳转中…",
|
|
@@ -613,7 +641,7 @@ const V = {
|
|
|
613
641
|
invalidCode: "请输入 6 位验证码",
|
|
614
642
|
generic: "出现错误,请稍后重试"
|
|
615
643
|
}
|
|
616
|
-
},
|
|
644
|
+
}, we = {
|
|
617
645
|
common: {
|
|
618
646
|
loading: "サインインを読み込み中…",
|
|
619
647
|
redirecting: "リダイレクト中…",
|
|
@@ -676,7 +704,7 @@ const V = {
|
|
|
676
704
|
invalidCode: "6桁の認証コードを入力してください",
|
|
677
705
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
678
706
|
}
|
|
679
|
-
},
|
|
707
|
+
}, ge = {
|
|
680
708
|
common: {
|
|
681
709
|
loading: "로그인 로딩 중…",
|
|
682
710
|
redirecting: "리디렉션 중…",
|
|
@@ -739,7 +767,7 @@ const V = {
|
|
|
739
767
|
invalidCode: "6자리 인증 코드를 입력해 주세요",
|
|
740
768
|
generic: "문제가 발생했습니다. 다시 시도해 주세요"
|
|
741
769
|
}
|
|
742
|
-
},
|
|
770
|
+
}, X = {
|
|
743
771
|
common: {
|
|
744
772
|
loading: "Cargando inicio de sesión…",
|
|
745
773
|
redirecting: "Redirigiendo…",
|
|
@@ -802,7 +830,7 @@ const V = {
|
|
|
802
830
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
803
831
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
804
832
|
}
|
|
805
|
-
},
|
|
833
|
+
}, pe = {
|
|
806
834
|
common: {
|
|
807
835
|
loading: "Carregando login…",
|
|
808
836
|
redirecting: "Redirecionando…",
|
|
@@ -865,7 +893,7 @@ const V = {
|
|
|
865
893
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
866
894
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
867
895
|
}
|
|
868
|
-
},
|
|
896
|
+
}, be = {
|
|
869
897
|
common: {
|
|
870
898
|
loading: "Chargement de la connexion…",
|
|
871
899
|
redirecting: "Redirection…",
|
|
@@ -928,7 +956,7 @@ const V = {
|
|
|
928
956
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
929
957
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
930
958
|
}
|
|
931
|
-
},
|
|
959
|
+
}, ve = {
|
|
932
960
|
common: {
|
|
933
961
|
loading: "Anmeldung wird geladen…",
|
|
934
962
|
redirecting: "Weiterleitung…",
|
|
@@ -991,7 +1019,7 @@ const V = {
|
|
|
991
1019
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
992
1020
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
993
1021
|
}
|
|
994
|
-
},
|
|
1022
|
+
}, ye = {
|
|
995
1023
|
common: {
|
|
996
1024
|
loading: "Caricamento accesso…",
|
|
997
1025
|
redirecting: "Reindirizzamento…",
|
|
@@ -1054,7 +1082,7 @@ const V = {
|
|
|
1054
1082
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
1055
1083
|
generic: "Qualcosa è andato storto. Riprova."
|
|
1056
1084
|
}
|
|
1057
|
-
},
|
|
1085
|
+
}, Ee = {
|
|
1058
1086
|
common: {
|
|
1059
1087
|
loading: "Загрузка входа…",
|
|
1060
1088
|
redirecting: "Перенаправление…",
|
|
@@ -1117,7 +1145,7 @@ const V = {
|
|
|
1117
1145
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
1118
1146
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
1119
1147
|
}
|
|
1120
|
-
},
|
|
1148
|
+
}, Se = {
|
|
1121
1149
|
common: {
|
|
1122
1150
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
1123
1151
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -1180,7 +1208,7 @@ const V = {
|
|
|
1180
1208
|
invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
|
|
1181
1209
|
generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
|
|
1182
1210
|
}
|
|
1183
|
-
},
|
|
1211
|
+
}, Pe = {
|
|
1184
1212
|
common: {
|
|
1185
1213
|
loading: "सधाइन की जुलातीअ लोड हो रही है…",
|
|
1186
1214
|
redirecting: "रीडायरेक्ट हो रहا है…",
|
|
@@ -1243,48 +1271,48 @@ const V = {
|
|
|
1243
1271
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
1244
1272
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1245
1273
|
}
|
|
1246
|
-
},
|
|
1247
|
-
en:
|
|
1248
|
-
"en-US":
|
|
1249
|
-
zh:
|
|
1250
|
-
"zh-CN":
|
|
1251
|
-
"zh-TW":
|
|
1252
|
-
ja:
|
|
1253
|
-
"ja-JP":
|
|
1254
|
-
ko:
|
|
1255
|
-
"ko-KR":
|
|
1256
|
-
es:
|
|
1257
|
-
"es-ES":
|
|
1258
|
-
"es-MX":
|
|
1259
|
-
pt:
|
|
1260
|
-
"pt-BR":
|
|
1261
|
-
fr:
|
|
1262
|
-
"fr-FR":
|
|
1263
|
-
de:
|
|
1264
|
-
"de-DE":
|
|
1265
|
-
it:
|
|
1266
|
-
"it-IT":
|
|
1267
|
-
ru:
|
|
1268
|
-
"ru-RU":
|
|
1269
|
-
ar:
|
|
1270
|
-
"ar-SA":
|
|
1271
|
-
hi:
|
|
1272
|
-
"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
|
|
1273
1301
|
};
|
|
1274
|
-
function
|
|
1302
|
+
function vt() {
|
|
1275
1303
|
if (typeof navigator > "u")
|
|
1276
|
-
return
|
|
1304
|
+
return x;
|
|
1277
1305
|
const t = navigator.languages ?? [navigator.language];
|
|
1278
1306
|
for (const e of t) {
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1307
|
+
const i = _e[e] ?? _e[e.split("-")[0]];
|
|
1308
|
+
if (i) return i;
|
|
1281
1309
|
}
|
|
1282
|
-
return
|
|
1310
|
+
return x;
|
|
1283
1311
|
}
|
|
1284
|
-
const
|
|
1312
|
+
const Ne = {
|
|
1285
1313
|
LIGHT: "light",
|
|
1286
1314
|
DARK: "dark"
|
|
1287
|
-
},
|
|
1315
|
+
}, Ve = Ne.LIGHT, yt = Ne.DARK, Fe = [Ve, yt], Et = Ve, St = {
|
|
1288
1316
|
BACKGROUND: "--edgespark-auth-bg",
|
|
1289
1317
|
BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
|
|
1290
1318
|
CARD_BACKGROUND: "--edgespark-auth-card-bg",
|
|
@@ -1304,31 +1332,31 @@ const Ce = {
|
|
|
1304
1332
|
MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
|
|
1305
1333
|
MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
|
|
1306
1334
|
MODAL_SHADOW: "--edgespark-auth-modal-shadow"
|
|
1307
|
-
},
|
|
1308
|
-
|
|
1335
|
+
}, Pt = Object.values(
|
|
1336
|
+
St
|
|
1309
1337
|
);
|
|
1310
|
-
function
|
|
1311
|
-
return typeof t == "string" &&
|
|
1338
|
+
function _t(t) {
|
|
1339
|
+
return typeof t == "string" && Fe.includes(t);
|
|
1312
1340
|
}
|
|
1313
|
-
function
|
|
1314
|
-
return
|
|
1341
|
+
function Lt(t) {
|
|
1342
|
+
return Pt.includes(t);
|
|
1315
1343
|
}
|
|
1316
|
-
function
|
|
1344
|
+
function At(t) {
|
|
1317
1345
|
var e;
|
|
1318
1346
|
return {
|
|
1319
|
-
theme: (t == null ? void 0 : t.theme) ??
|
|
1347
|
+
theme: (t == null ? void 0 : t.theme) ?? Et,
|
|
1320
1348
|
className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
|
|
1321
1349
|
variables: { ...(t == null ? void 0 : t.variables) ?? {} }
|
|
1322
1350
|
};
|
|
1323
1351
|
}
|
|
1324
|
-
function
|
|
1325
|
-
return
|
|
1352
|
+
function Z(t, e = "Authentication failed.") {
|
|
1353
|
+
return de(t, e);
|
|
1326
1354
|
}
|
|
1327
|
-
async function
|
|
1328
|
-
var
|
|
1355
|
+
async function V(t) {
|
|
1356
|
+
var i, s;
|
|
1329
1357
|
const e = await t.getSession();
|
|
1330
1358
|
if (e.error)
|
|
1331
|
-
throw new
|
|
1359
|
+
throw new L(
|
|
1332
1360
|
e.error.message || "Failed to load the current session.",
|
|
1333
1361
|
{
|
|
1334
1362
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1336,7 +1364,7 @@ async function k(t) {
|
|
|
1336
1364
|
cause: e.error
|
|
1337
1365
|
}
|
|
1338
1366
|
);
|
|
1339
|
-
return (
|
|
1367
|
+
return (i = e.data) != null && i.user && ((s = e.data) != null && s.session) ? {
|
|
1340
1368
|
user: e.data.user,
|
|
1341
1369
|
session: e.data
|
|
1342
1370
|
} : {
|
|
@@ -1344,13 +1372,13 @@ async function k(t) {
|
|
|
1344
1372
|
session: null
|
|
1345
1373
|
};
|
|
1346
1374
|
}
|
|
1347
|
-
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 = {
|
|
1348
1376
|
"&": "&",
|
|
1349
1377
|
"<": "<",
|
|
1350
1378
|
">": ">",
|
|
1351
1379
|
'"': """,
|
|
1352
1380
|
"'": "'"
|
|
1353
|
-
},
|
|
1381
|
+
}, se = {
|
|
1354
1382
|
google: "Google",
|
|
1355
1383
|
apple: "Apple",
|
|
1356
1384
|
microsoft: "Microsoft",
|
|
@@ -1358,27 +1386,27 @@ const yt = "data-edgespark-auth", vt = "data-edgespark-auth-theme", r = "edgespa
|
|
|
1358
1386
|
gitlab: "GitLab",
|
|
1359
1387
|
discord: "Discord"
|
|
1360
1388
|
};
|
|
1361
|
-
function
|
|
1389
|
+
function U(t) {
|
|
1362
1390
|
return "redirectTo" in t;
|
|
1363
1391
|
}
|
|
1364
|
-
function
|
|
1392
|
+
function ie(t) {
|
|
1365
1393
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1366
1394
|
}
|
|
1367
|
-
function
|
|
1395
|
+
function ne(t) {
|
|
1368
1396
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1369
1397
|
}
|
|
1370
|
-
function
|
|
1398
|
+
function Ct(t) {
|
|
1371
1399
|
return /^\d{6}$/.test(t.trim());
|
|
1372
1400
|
}
|
|
1373
|
-
function
|
|
1401
|
+
function Ut(t) {
|
|
1374
1402
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1375
1403
|
}
|
|
1376
|
-
function
|
|
1404
|
+
function $t(t) {
|
|
1377
1405
|
return !!(t.error || t.errorDescription);
|
|
1378
1406
|
}
|
|
1379
|
-
class
|
|
1380
|
-
constructor(e,
|
|
1381
|
-
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 = {
|
|
1382
1410
|
view: "loading",
|
|
1383
1411
|
busy: !0,
|
|
1384
1412
|
busyLabel: void 0,
|
|
@@ -1391,39 +1419,39 @@ class Lt {
|
|
|
1391
1419
|
code: "",
|
|
1392
1420
|
newPassword: ""
|
|
1393
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;
|
|
1394
|
-
const u =
|
|
1395
|
-
this.labels =
|
|
1396
|
-
for (const [
|
|
1397
|
-
|
|
1398
|
-
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();
|
|
1399
1427
|
}
|
|
1400
1428
|
destroy() {
|
|
1401
|
-
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.
|
|
1429
|
+
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.root.remove());
|
|
1402
1430
|
}
|
|
1403
1431
|
async initialize() {
|
|
1404
1432
|
const e = this.consumeManagedReturnContext();
|
|
1405
1433
|
try {
|
|
1406
|
-
const [
|
|
1434
|
+
const [i, s] = await Promise.allSettled([
|
|
1407
1435
|
this.loadConfig(),
|
|
1408
1436
|
this.readMountSession(e)
|
|
1409
1437
|
]);
|
|
1410
1438
|
if (this.destroyed)
|
|
1411
1439
|
return;
|
|
1412
|
-
if (
|
|
1413
|
-
if (e.marker &&
|
|
1440
|
+
if (s.status === "rejected") {
|
|
1441
|
+
if (e.marker && !$t(e) && U(this.options)) {
|
|
1414
1442
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1415
1443
|
return;
|
|
1416
1444
|
}
|
|
1417
1445
|
} else {
|
|
1418
|
-
const
|
|
1419
|
-
if (
|
|
1446
|
+
const o = s.value;
|
|
1447
|
+
if (o.user && o.session) {
|
|
1420
1448
|
switch (e.marker) {
|
|
1421
|
-
case
|
|
1422
|
-
case
|
|
1423
|
-
await this.completeAuth("sign-in",
|
|
1449
|
+
case ee:
|
|
1450
|
+
case N:
|
|
1451
|
+
await this.completeAuth("sign-in", o);
|
|
1424
1452
|
return;
|
|
1425
|
-
case
|
|
1426
|
-
await this.completeAuth("sign-up",
|
|
1453
|
+
case C:
|
|
1454
|
+
await this.completeAuth("sign-up", o);
|
|
1427
1455
|
return;
|
|
1428
1456
|
default:
|
|
1429
1457
|
break;
|
|
@@ -1432,40 +1460,40 @@ class Lt {
|
|
|
1432
1460
|
return;
|
|
1433
1461
|
}
|
|
1434
1462
|
}
|
|
1435
|
-
if (s.status === "rejected")
|
|
1436
|
-
throw i.status === "rejected" ? i.reason : s.reason;
|
|
1437
|
-
if (this.config = s.value, this.handleSessionlessManagedReturn(e))
|
|
1438
|
-
return;
|
|
1439
1463
|
if (i.status === "rejected")
|
|
1440
|
-
throw i.reason;
|
|
1441
|
-
|
|
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;
|
|
1442
1470
|
this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.render();
|
|
1443
|
-
} catch (
|
|
1444
|
-
this.handleError(
|
|
1471
|
+
} catch (i) {
|
|
1472
|
+
this.handleError(i, "Failed to load the authentication UI.");
|
|
1445
1473
|
}
|
|
1446
1474
|
}
|
|
1447
1475
|
redirectAfterManagedReturnLookupFailure() {
|
|
1448
|
-
|
|
1476
|
+
U(this.options) && this.navigateToRedirect();
|
|
1449
1477
|
}
|
|
1450
1478
|
navigateToRedirect() {
|
|
1451
|
-
|
|
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()));
|
|
1452
1480
|
}
|
|
1453
1481
|
async readMountSession(e) {
|
|
1454
1482
|
if (!e.marker)
|
|
1455
|
-
return
|
|
1456
|
-
let
|
|
1457
|
-
for (let
|
|
1483
|
+
return V(this.auth);
|
|
1484
|
+
let i = null;
|
|
1485
|
+
for (let s = 0; s <= te; s++) {
|
|
1458
1486
|
try {
|
|
1459
|
-
const n = await
|
|
1487
|
+
const n = await V(this.auth);
|
|
1460
1488
|
if (n.user && n.session)
|
|
1461
1489
|
return n;
|
|
1462
1490
|
} catch (n) {
|
|
1463
|
-
|
|
1491
|
+
i = n;
|
|
1464
1492
|
}
|
|
1465
|
-
|
|
1493
|
+
s < te && await new Promise((n) => setTimeout(n, Le));
|
|
1466
1494
|
}
|
|
1467
|
-
if (
|
|
1468
|
-
throw
|
|
1495
|
+
if (i)
|
|
1496
|
+
throw i;
|
|
1469
1497
|
return {
|
|
1470
1498
|
user: null,
|
|
1471
1499
|
session: null
|
|
@@ -1481,6 +1509,7 @@ class Lt {
|
|
|
1481
1509
|
}
|
|
1482
1510
|
this.root.innerHTML = `
|
|
1483
1511
|
<div class="${r}__shell">
|
|
1512
|
+
${this.renderDevModeBanner()}
|
|
1484
1513
|
<div class="${r}__card">
|
|
1485
1514
|
${this.renderStatus()}
|
|
1486
1515
|
${this.renderCurrentView()}
|
|
@@ -1498,6 +1527,10 @@ class Lt {
|
|
|
1498
1527
|
</div>
|
|
1499
1528
|
`;
|
|
1500
1529
|
}
|
|
1530
|
+
renderDevModeBanner() {
|
|
1531
|
+
var e;
|
|
1532
|
+
return (e = this.config) != null && e.isLocalDev ? `<div class="${r}__dev-banner">Local dev mode — emails are mocked, OAuth uses test identities</div>` : "";
|
|
1533
|
+
}
|
|
1501
1534
|
renderStatus() {
|
|
1502
1535
|
const e = [];
|
|
1503
1536
|
return this.state.error && e.push(
|
|
@@ -1526,8 +1559,8 @@ class Lt {
|
|
|
1526
1559
|
}
|
|
1527
1560
|
}
|
|
1528
1561
|
renderSignInView() {
|
|
1529
|
-
var
|
|
1530
|
-
const e = this.renderOAuthProviders(),
|
|
1562
|
+
var s, n;
|
|
1563
|
+
const e = this.renderOAuthProviders(), i = ((s = this.config) == null ? void 0 : s.emailPasswordEnabled) ?? !0;
|
|
1531
1564
|
return `
|
|
1532
1565
|
<section class="${r}__section">
|
|
1533
1566
|
<header class="${r}__header">
|
|
@@ -1535,8 +1568,8 @@ class Lt {
|
|
|
1535
1568
|
<p class="${r}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
|
|
1536
1569
|
</header>
|
|
1537
1570
|
${e}
|
|
1538
|
-
${e &&
|
|
1539
|
-
${
|
|
1571
|
+
${e && i ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
|
|
1572
|
+
${i ? `
|
|
1540
1573
|
<form class="${r}__form" data-view="sign-in" novalidate>
|
|
1541
1574
|
${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
|
|
1542
1575
|
${this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
|
|
@@ -1665,28 +1698,28 @@ class Lt {
|
|
|
1665
1698
|
`;
|
|
1666
1699
|
}
|
|
1667
1700
|
renderOAuthProviders() {
|
|
1668
|
-
var
|
|
1669
|
-
const e = ((
|
|
1701
|
+
var i;
|
|
1702
|
+
const e = ((i = this.config) == null ? void 0 : i.oauthProviders) ?? [];
|
|
1670
1703
|
return e.length === 0 ? "" : `
|
|
1671
1704
|
<div class="${r}__stack">
|
|
1672
|
-
${e.map((
|
|
1673
|
-
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${
|
|
1674
|
-
${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]}`)}
|
|
1675
1708
|
</button>
|
|
1676
1709
|
`).join("")}
|
|
1677
1710
|
</div>
|
|
1678
1711
|
`;
|
|
1679
1712
|
}
|
|
1680
|
-
renderInput(e,
|
|
1713
|
+
renderInput(e, i, s, n, o) {
|
|
1681
1714
|
return `
|
|
1682
1715
|
<label class="${r}__field">
|
|
1683
|
-
<span class="${r}__label">${this.escape(
|
|
1716
|
+
<span class="${r}__label">${this.escape(i)}</span>
|
|
1684
1717
|
<input
|
|
1685
1718
|
class="${r}__input"
|
|
1686
1719
|
name="${this.escape(e)}"
|
|
1687
|
-
type="${this.escape(
|
|
1720
|
+
type="${this.escape(s)}"
|
|
1688
1721
|
value="${this.escape(n)}"
|
|
1689
|
-
autocomplete="${this.escape(
|
|
1722
|
+
autocomplete="${this.escape(o)}"
|
|
1690
1723
|
${this.state.busy ? "disabled" : ""}
|
|
1691
1724
|
/>
|
|
1692
1725
|
</label>
|
|
@@ -1694,19 +1727,19 @@ class Lt {
|
|
|
1694
1727
|
}
|
|
1695
1728
|
bindDOM() {
|
|
1696
1729
|
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1697
|
-
n.addEventListener("submit", (
|
|
1698
|
-
|
|
1730
|
+
n.addEventListener("submit", (o) => {
|
|
1731
|
+
o.preventDefault();
|
|
1699
1732
|
const u = n.dataset.view;
|
|
1700
1733
|
u === "sign-in" && this.handleSignIn(), u === "sign-up" && this.handleSignUp(), u === "forgot-password" && this.handleForgotPassword(), u === "reset-password" && this.handleResetPassword();
|
|
1701
1734
|
});
|
|
1702
1735
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1703
1736
|
n.addEventListener("input", () => {
|
|
1704
|
-
|
|
1737
|
+
Ut(n.name) && (this.state[n.name] = n.value);
|
|
1705
1738
|
});
|
|
1706
1739
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1707
1740
|
n.addEventListener("click", () => {
|
|
1708
|
-
const
|
|
1709
|
-
|
|
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);
|
|
1710
1743
|
});
|
|
1711
1744
|
});
|
|
1712
1745
|
}
|
|
@@ -1714,7 +1747,7 @@ class Lt {
|
|
|
1714
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();
|
|
1715
1748
|
}
|
|
1716
1749
|
async handleSignIn() {
|
|
1717
|
-
if (!
|
|
1750
|
+
if (!ne(this.state.email)) {
|
|
1718
1751
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1719
1752
|
return;
|
|
1720
1753
|
}
|
|
@@ -1726,7 +1759,7 @@ class Lt {
|
|
|
1726
1759
|
const e = await this.auth.signIn.email({
|
|
1727
1760
|
email: this.state.email.trim(),
|
|
1728
1761
|
password: this.state.password,
|
|
1729
|
-
callbackURL: this.getManagedReturnURL(
|
|
1762
|
+
callbackURL: this.getManagedReturnURL(N, this.state.email.trim())
|
|
1730
1763
|
});
|
|
1731
1764
|
if (e.error)
|
|
1732
1765
|
throw e.error;
|
|
@@ -1734,12 +1767,12 @@ class Lt {
|
|
|
1734
1767
|
});
|
|
1735
1768
|
}
|
|
1736
1769
|
async handleSignUp() {
|
|
1737
|
-
var e,
|
|
1770
|
+
var e, i;
|
|
1738
1771
|
if (!this.state.name.trim()) {
|
|
1739
1772
|
this.failValidation(this.labels.errors.requiredField);
|
|
1740
1773
|
return;
|
|
1741
1774
|
}
|
|
1742
|
-
if (!
|
|
1775
|
+
if (!ne(this.state.email)) {
|
|
1743
1776
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1744
1777
|
return;
|
|
1745
1778
|
}
|
|
@@ -1749,7 +1782,7 @@ class Lt {
|
|
|
1749
1782
|
}
|
|
1750
1783
|
if (this.state.password.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1751
1784
|
this.failValidation(
|
|
1752
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1785
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((i = this.config) == null ? void 0 : i.minPasswordLength) ?? 8))
|
|
1753
1786
|
);
|
|
1754
1787
|
return;
|
|
1755
1788
|
}
|
|
@@ -1759,68 +1792,77 @@ class Lt {
|
|
|
1759
1792
|
}
|
|
1760
1793
|
await this.runAction("Creating account…", async () => {
|
|
1761
1794
|
var n;
|
|
1762
|
-
const
|
|
1795
|
+
const s = await this.auth.signUp.email({
|
|
1763
1796
|
name: this.state.name.trim(),
|
|
1764
1797
|
email: this.state.email.trim(),
|
|
1765
1798
|
password: this.state.password,
|
|
1766
|
-
callbackURL: this.getManagedReturnURL(
|
|
1799
|
+
callbackURL: this.getManagedReturnURL(C, this.state.email.trim())
|
|
1767
1800
|
});
|
|
1768
|
-
if (
|
|
1769
|
-
throw
|
|
1801
|
+
if (s.error)
|
|
1802
|
+
throw s.error;
|
|
1770
1803
|
if ((n = this.config) != null && n.requireEmailVerification) {
|
|
1771
|
-
|
|
1804
|
+
if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", s.data))
|
|
1805
|
+
return;
|
|
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();
|
|
1772
1807
|
return;
|
|
1773
1808
|
}
|
|
1774
|
-
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(
|
|
1809
|
+
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(s.data));
|
|
1775
1810
|
});
|
|
1776
1811
|
}
|
|
1777
1812
|
async handleOAuthSignIn(e) {
|
|
1778
|
-
await this.runAction(`Redirecting to ${
|
|
1779
|
-
const
|
|
1813
|
+
await this.runAction(`Redirecting to ${se[e]}…`, async () => {
|
|
1814
|
+
const i = await this.auth.signIn.social({
|
|
1780
1815
|
provider: e,
|
|
1781
1816
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
1782
1817
|
errorCallbackURL: this.getManagedReturnURL("oauth")
|
|
1783
1818
|
});
|
|
1784
|
-
if (
|
|
1785
|
-
throw
|
|
1786
|
-
const
|
|
1787
|
-
if (!
|
|
1788
|
-
throw new
|
|
1789
|
-
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);
|
|
1790
1825
|
});
|
|
1791
1826
|
}
|
|
1792
1827
|
async handleForgotPassword() {
|
|
1793
1828
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1794
1829
|
this.handleError(
|
|
1795
|
-
new
|
|
1830
|
+
new g("Password reset via email OTP is not enabled for this project.")
|
|
1796
1831
|
);
|
|
1797
1832
|
return;
|
|
1798
1833
|
}
|
|
1799
|
-
if (!
|
|
1834
|
+
if (!ne(this.state.email)) {
|
|
1800
1835
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1801
1836
|
return;
|
|
1802
1837
|
}
|
|
1803
1838
|
await this.runAction("Sending reset code…", async () => {
|
|
1839
|
+
var i;
|
|
1804
1840
|
const e = await this.passwordResetEndpoints().forgetPassword.emailOtp({
|
|
1805
1841
|
email: this.state.email.trim()
|
|
1806
1842
|
});
|
|
1807
1843
|
if (e.error)
|
|
1808
1844
|
throw e.error;
|
|
1809
|
-
this.state.view = "reset-password",
|
|
1845
|
+
if (this.state.view = "reset-password", (i = this.config) != null && i.isLocalDev) {
|
|
1846
|
+
this.state.busyLabel = "Dev mode: fetching reset code…", this.render();
|
|
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
|
+
} else
|
|
1850
|
+
this.state.notice = `We sent a reset code to ${this.state.email.trim()}.`;
|
|
1851
|
+
this.startCountdown();
|
|
1810
1852
|
});
|
|
1811
1853
|
}
|
|
1812
1854
|
async resendResetCode() {
|
|
1813
1855
|
this.isCountdownActive() || await this.handleForgotPassword();
|
|
1814
1856
|
}
|
|
1815
1857
|
async handleResetPassword() {
|
|
1816
|
-
var e,
|
|
1858
|
+
var e, i;
|
|
1817
1859
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1818
1860
|
this.handleError(
|
|
1819
|
-
new
|
|
1861
|
+
new g("Password reset via email OTP is not enabled for this project.")
|
|
1820
1862
|
);
|
|
1821
1863
|
return;
|
|
1822
1864
|
}
|
|
1823
|
-
if (!
|
|
1865
|
+
if (!Ct(this.state.code)) {
|
|
1824
1866
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1825
1867
|
return;
|
|
1826
1868
|
}
|
|
@@ -1830,7 +1872,7 @@ class Lt {
|
|
|
1830
1872
|
}
|
|
1831
1873
|
if (this.state.newPassword.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
|
|
1832
1874
|
this.failValidation(
|
|
1833
|
-
this.labels.errors.passwordTooShort.replace("{min}", String(((
|
|
1875
|
+
this.labels.errors.passwordTooShort.replace("{min}", String(((i = this.config) == null ? void 0 : i.minPasswordLength) ?? 8))
|
|
1834
1876
|
);
|
|
1835
1877
|
return;
|
|
1836
1878
|
}
|
|
@@ -1839,48 +1881,73 @@ class Lt {
|
|
|
1839
1881
|
return;
|
|
1840
1882
|
}
|
|
1841
1883
|
await this.runAction("Updating password…", async () => {
|
|
1842
|
-
const
|
|
1884
|
+
const s = await this.passwordResetEndpoints().emailOtp.resetPassword({
|
|
1843
1885
|
email: this.state.email.trim(),
|
|
1844
1886
|
otp: this.state.code.trim(),
|
|
1845
1887
|
password: this.state.newPassword
|
|
1846
1888
|
});
|
|
1847
|
-
if (
|
|
1848
|
-
throw
|
|
1889
|
+
if (s.error)
|
|
1890
|
+
throw s.error;
|
|
1849
1891
|
await this.completePasswordReset();
|
|
1850
1892
|
});
|
|
1851
1893
|
}
|
|
1852
1894
|
async resendVerificationEmail() {
|
|
1895
|
+
var e;
|
|
1896
|
+
if ((e = this.config) != null && e.isLocalDev) {
|
|
1897
|
+
if (this.isCountdownActive()) return;
|
|
1898
|
+
await this.runAction("Dev mode: retrying auto-verify…", async () => {
|
|
1899
|
+
const i = this.verificationCompletionAction ?? "sign-in";
|
|
1900
|
+
if (!await this.tryDevAutoVerify(i))
|
|
1901
|
+
throw new Error(
|
|
1902
|
+
"Dev auto-verify did not complete. Check the edgespark dev logs and try again."
|
|
1903
|
+
);
|
|
1904
|
+
});
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1853
1907
|
await this.sendVerificationEmail(!1);
|
|
1854
1908
|
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Drive the local-dev auto-verify endpoint and, on success, complete the
|
|
1911
|
+
* auth flow. Returns whether auto-verify completed — callers decide what
|
|
1912
|
+
* to do on `false` (sign-up falls through to a retry UI; resend throws).
|
|
1913
|
+
*/
|
|
1914
|
+
async tryDevAutoVerify(e, i) {
|
|
1915
|
+
const s = this.state.email.trim();
|
|
1916
|
+
try {
|
|
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
|
+
} catch (n) {
|
|
1919
|
+
return console.warn("[edgespark] Dev auto-verify failed:", n), !1;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1855
1922
|
async sendVerificationEmail(e) {
|
|
1856
1923
|
!e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
|
|
1857
|
-
const
|
|
1924
|
+
const i = await this.auth.sendVerificationEmail({
|
|
1858
1925
|
email: this.state.email.trim(),
|
|
1859
1926
|
callbackURL: this.getManagedReturnURL(
|
|
1860
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1927
|
+
this.verificationCompletionAction === "sign-up" ? C : N,
|
|
1861
1928
|
this.state.email.trim()
|
|
1862
1929
|
)
|
|
1863
1930
|
});
|
|
1864
|
-
if (
|
|
1865
|
-
throw
|
|
1931
|
+
if (i.error)
|
|
1932
|
+
throw i.error;
|
|
1866
1933
|
this.handleVerificationEmailSent(this.state.email.trim(), !0);
|
|
1867
1934
|
});
|
|
1868
1935
|
}
|
|
1869
|
-
async completeAuth(e,
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1936
|
+
async completeAuth(e, i) {
|
|
1937
|
+
const s = await this.retryAuthCompletionDataIfNeeded(
|
|
1938
|
+
i ?? await this.resolveAuthCompletionData()
|
|
1872
1939
|
);
|
|
1873
1940
|
if (this.destroyed)
|
|
1874
1941
|
return;
|
|
1875
|
-
if (!
|
|
1942
|
+
if (!s.user || !s.session) {
|
|
1876
1943
|
if (this.destroyed)
|
|
1877
1944
|
return;
|
|
1878
|
-
if (
|
|
1945
|
+
if (s.lookupError && U(this.options)) {
|
|
1879
1946
|
this.navigateToRedirect();
|
|
1880
1947
|
return;
|
|
1881
1948
|
}
|
|
1882
1949
|
if (e === "sign-in")
|
|
1883
|
-
throw
|
|
1950
|
+
throw s.lookupError ?? new Re(
|
|
1884
1951
|
"Managed sign-in completed without an authenticated session."
|
|
1885
1952
|
);
|
|
1886
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();
|
|
@@ -1888,15 +1955,15 @@ class Lt {
|
|
|
1888
1955
|
}
|
|
1889
1956
|
const n = {
|
|
1890
1957
|
action: e,
|
|
1891
|
-
user:
|
|
1892
|
-
session:
|
|
1958
|
+
user: s.user,
|
|
1959
|
+
session: s.session
|
|
1893
1960
|
};
|
|
1894
1961
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1895
|
-
if (
|
|
1962
|
+
if (U(this.options)) {
|
|
1896
1963
|
this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
|
|
1897
1964
|
return;
|
|
1898
1965
|
}
|
|
1899
|
-
if (
|
|
1966
|
+
if (ie(this.options)) {
|
|
1900
1967
|
this.options.onSuccess(n), this.terminalActionInProgress = !0;
|
|
1901
1968
|
return;
|
|
1902
1969
|
}
|
|
@@ -1905,44 +1972,44 @@ class Lt {
|
|
|
1905
1972
|
async retryAuthCompletionDataIfNeeded(e) {
|
|
1906
1973
|
if (e.session)
|
|
1907
1974
|
return e;
|
|
1908
|
-
let
|
|
1909
|
-
for (let
|
|
1910
|
-
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));
|
|
1911
1978
|
try {
|
|
1912
|
-
const n = await
|
|
1979
|
+
const n = await V(this.auth);
|
|
1913
1980
|
if (n.user && n.session)
|
|
1914
1981
|
return {
|
|
1915
1982
|
user: n.user,
|
|
1916
1983
|
session: n.session
|
|
1917
1984
|
};
|
|
1918
1985
|
} catch (n) {
|
|
1919
|
-
|
|
1986
|
+
i = n;
|
|
1920
1987
|
}
|
|
1921
1988
|
}
|
|
1922
1989
|
return {
|
|
1923
1990
|
...e,
|
|
1924
|
-
lookupError:
|
|
1991
|
+
lookupError: i ?? e.lookupError
|
|
1925
1992
|
};
|
|
1926
1993
|
}
|
|
1927
1994
|
async syncPublicSessionBestEffort() {
|
|
1928
|
-
var e,
|
|
1995
|
+
var e, i;
|
|
1929
1996
|
try {
|
|
1930
|
-
await ((
|
|
1997
|
+
await ((i = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : i.call(e));
|
|
1931
1998
|
} catch {
|
|
1932
1999
|
}
|
|
1933
2000
|
}
|
|
1934
2001
|
async resolveAuthCompletionData(e) {
|
|
1935
2002
|
try {
|
|
1936
|
-
const
|
|
2003
|
+
const i = await V(this.auth), s = this.extractUser(e);
|
|
1937
2004
|
return {
|
|
1938
|
-
user:
|
|
1939
|
-
session:
|
|
2005
|
+
user: i.user ?? s,
|
|
2006
|
+
session: i.session
|
|
1940
2007
|
};
|
|
1941
|
-
} catch (
|
|
2008
|
+
} catch (i) {
|
|
1942
2009
|
return {
|
|
1943
2010
|
user: this.extractUser(e),
|
|
1944
2011
|
session: null,
|
|
1945
|
-
lookupError:
|
|
2012
|
+
lookupError: i
|
|
1946
2013
|
};
|
|
1947
2014
|
}
|
|
1948
2015
|
}
|
|
@@ -1953,7 +2020,7 @@ class Lt {
|
|
|
1953
2020
|
session: null
|
|
1954
2021
|
};
|
|
1955
2022
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1956
|
-
if (
|
|
2023
|
+
if (ie(this.options)) {
|
|
1957
2024
|
this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
|
|
1958
2025
|
return;
|
|
1959
2026
|
}
|
|
@@ -1961,66 +2028,66 @@ class Lt {
|
|
|
1961
2028
|
}
|
|
1962
2029
|
}
|
|
1963
2030
|
handleExistingSessionOnMount() {
|
|
1964
|
-
if (
|
|
2031
|
+
if (U(this.options)) {
|
|
1965
2032
|
this.navigateToRedirect();
|
|
1966
2033
|
return;
|
|
1967
2034
|
}
|
|
1968
|
-
if (
|
|
1969
|
-
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(
|
|
1970
2037
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1971
2038
|
);
|
|
1972
2039
|
}
|
|
1973
|
-
async runAction(e,
|
|
2040
|
+
async runAction(e, i) {
|
|
1974
2041
|
this.state.busy = !0, this.state.busyLabel = e, this.state.error = null, this.state.notice = null, this.render();
|
|
1975
2042
|
try {
|
|
1976
|
-
await
|
|
1977
|
-
} catch (
|
|
1978
|
-
if (this.maybeHandleVerificationRequired(
|
|
2043
|
+
await i();
|
|
2044
|
+
} catch (s) {
|
|
2045
|
+
if (this.maybeHandleVerificationRequired(s))
|
|
1979
2046
|
return;
|
|
1980
|
-
this.handleError(
|
|
2047
|
+
this.handleError(s);
|
|
1981
2048
|
return;
|
|
1982
2049
|
}
|
|
1983
2050
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1984
2051
|
}
|
|
1985
2052
|
maybeHandleVerificationRequired(e) {
|
|
1986
|
-
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);
|
|
1987
2054
|
}
|
|
1988
|
-
handleVerificationEmailSent(e,
|
|
1989
|
-
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();
|
|
1990
2057
|
}
|
|
1991
2058
|
invokeRedirectModeSuccessHook(e) {
|
|
1992
|
-
var
|
|
1993
|
-
if (!(!
|
|
2059
|
+
var i, s;
|
|
2060
|
+
if (!(!U(this.options) || !this.options.onSuccess))
|
|
1994
2061
|
try {
|
|
1995
2062
|
this.options.onSuccess(e);
|
|
1996
2063
|
} catch (n) {
|
|
1997
|
-
const
|
|
2064
|
+
const o = Z(n, "Post-auth callback failed.");
|
|
1998
2065
|
try {
|
|
1999
|
-
(
|
|
2066
|
+
(s = (i = this.options).onError) == null || s.call(i, o);
|
|
2000
2067
|
} catch {
|
|
2001
2068
|
}
|
|
2002
2069
|
}
|
|
2003
2070
|
}
|
|
2004
|
-
handleError(e,
|
|
2005
|
-
var n,
|
|
2006
|
-
const
|
|
2007
|
-
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);
|
|
2008
2075
|
}
|
|
2009
2076
|
failValidation(e) {
|
|
2010
2077
|
this.state.error = e, this.state.notice = null, this.render();
|
|
2011
2078
|
}
|
|
2012
|
-
getManagedReturnURL(e,
|
|
2079
|
+
getManagedReturnURL(e, i) {
|
|
2013
2080
|
if (!e)
|
|
2014
2081
|
return window.location.href;
|
|
2015
|
-
const
|
|
2016
|
-
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();
|
|
2017
2084
|
}
|
|
2018
2085
|
consumeManagedReturnContext() {
|
|
2019
|
-
const e = new URL(window.location.href),
|
|
2020
|
-
return (
|
|
2021
|
-
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,
|
|
2022
2089
|
email: n,
|
|
2023
|
-
error:
|
|
2090
|
+
error: o,
|
|
2024
2091
|
errorDescription: u
|
|
2025
2092
|
};
|
|
2026
2093
|
}
|
|
@@ -2049,14 +2116,14 @@ class Lt {
|
|
|
2049
2116
|
this.pendingFocusSnapshot && (this.clearFocusRestoreTimer(), this.focusRestoreTimer = window.setTimeout(() => {
|
|
2050
2117
|
if (this.focusRestoreTimer = null, this.destroyed || !this.pendingFocusSnapshot)
|
|
2051
2118
|
return;
|
|
2052
|
-
const e = this.pendingFocusSnapshot,
|
|
2053
|
-
if (!(!
|
|
2054
|
-
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)
|
|
2055
2122
|
try {
|
|
2056
|
-
|
|
2123
|
+
s.setSelectionRange(e.selectionStart, e.selectionEnd);
|
|
2057
2124
|
} catch {
|
|
2058
|
-
const n =
|
|
2059
|
-
|
|
2125
|
+
const n = s.value.length;
|
|
2126
|
+
s.setSelectionRange(n, n);
|
|
2060
2127
|
}
|
|
2061
2128
|
this.pendingFocusSnapshot = null;
|
|
2062
2129
|
}
|
|
@@ -2071,24 +2138,24 @@ class Lt {
|
|
|
2071
2138
|
extractRedirectURL(e) {
|
|
2072
2139
|
if (!e || typeof e != "object")
|
|
2073
2140
|
return null;
|
|
2074
|
-
const
|
|
2075
|
-
return
|
|
2141
|
+
const i = e;
|
|
2142
|
+
return i.redirect && typeof i.url == "string" && i.url.length > 0 ? i.url : null;
|
|
2076
2143
|
}
|
|
2077
2144
|
extractUser(e) {
|
|
2078
2145
|
if (!e || typeof e != "object")
|
|
2079
2146
|
return null;
|
|
2080
|
-
const
|
|
2081
|
-
return
|
|
2147
|
+
const i = e;
|
|
2148
|
+
return i.user && typeof i.user == "object" ? i.user : null;
|
|
2082
2149
|
}
|
|
2083
2150
|
canUsePasswordResetEmailOtp() {
|
|
2084
2151
|
var e;
|
|
2085
2152
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
2086
2153
|
}
|
|
2087
2154
|
handleSessionlessManagedReturn(e) {
|
|
2088
|
-
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(
|
|
2089
2156
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
2090
2157
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
2091
|
-
)) : 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(
|
|
2092
2159
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
2093
2160
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
2094
2161
|
)), !0) : !1;
|
|
@@ -2099,174 +2166,402 @@ class Lt {
|
|
|
2099
2166
|
getCountdownSecondsRemaining() {
|
|
2100
2167
|
return this.countdownUntil ? Math.max(0, Math.ceil((this.countdownUntil - Date.now()) / 1e3)) : 0;
|
|
2101
2168
|
}
|
|
2102
|
-
countdownText(e,
|
|
2103
|
-
const
|
|
2104
|
-
return
|
|
2169
|
+
countdownText(e, i) {
|
|
2170
|
+
const s = this.getCountdownSecondsRemaining();
|
|
2171
|
+
return s <= 0 ? e : i.replace("{seconds}", String(s));
|
|
2105
2172
|
}
|
|
2106
2173
|
escape(e) {
|
|
2107
|
-
return e.replace(/[&<>"']/g, (
|
|
2174
|
+
return e.replace(/[&<>"']/g, (i) => Rt[i]);
|
|
2108
2175
|
}
|
|
2109
2176
|
}
|
|
2110
|
-
function
|
|
2177
|
+
function Bt(t) {
|
|
2111
2178
|
return "data" in t && t.data ? t.data : t;
|
|
2112
2179
|
}
|
|
2113
|
-
const
|
|
2180
|
+
const Ot = [
|
|
2114
2181
|
{ id: "google", key: "providerGoogle" },
|
|
2115
2182
|
{ id: "apple", key: "providerApple" },
|
|
2116
2183
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2117
2184
|
{ id: "github", key: "providerGithub" },
|
|
2118
2185
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2119
2186
|
{ id: "discord", key: "providerDiscord" }
|
|
2120
|
-
],
|
|
2121
|
-
async function
|
|
2122
|
-
const t = `${window.location.origin}${
|
|
2187
|
+
], Ae = 2, Mt = 500;
|
|
2188
|
+
async function Dt() {
|
|
2189
|
+
const t = `${window.location.origin}${Ue}/config`;
|
|
2123
2190
|
let e;
|
|
2124
|
-
for (let
|
|
2191
|
+
for (let i = 0; i <= Ae; i++)
|
|
2125
2192
|
try {
|
|
2126
|
-
const
|
|
2127
|
-
if (!
|
|
2128
|
-
throw new
|
|
2129
|
-
const n = await
|
|
2130
|
-
return
|
|
2131
|
-
} catch (
|
|
2132
|
-
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));
|
|
2133
2200
|
}
|
|
2134
2201
|
throw e;
|
|
2135
2202
|
}
|
|
2136
|
-
let
|
|
2137
|
-
async function
|
|
2138
|
-
return
|
|
2139
|
-
throw
|
|
2140
|
-
})),
|
|
2141
|
-
}
|
|
2142
|
-
function
|
|
2143
|
-
var
|
|
2144
|
-
const
|
|
2145
|
-
const
|
|
2146
|
-
return typeof
|
|
2147
|
-
}).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;
|
|
2148
2215
|
return {
|
|
2149
2216
|
disableSignUp: !!t.disableSignUp,
|
|
2150
|
-
emailPasswordEnabled: !!((
|
|
2151
|
-
minPasswordLength: ((
|
|
2152
|
-
requireEmailVerification: !!((
|
|
2153
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2154
|
-
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,
|
|
2223
|
+
isLocalDev: e
|
|
2155
2224
|
};
|
|
2156
2225
|
}
|
|
2157
|
-
const
|
|
2158
|
-
|
|
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) {
|
|
2159
2448
|
if (!t)
|
|
2160
|
-
throw new
|
|
2449
|
+
throw new g(
|
|
2161
2450
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2162
2451
|
);
|
|
2163
|
-
const e = "redirectTo" in t,
|
|
2164
|
-
if (!e && !
|
|
2165
|
-
throw new
|
|
2452
|
+
const e = "redirectTo" in t, i = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2453
|
+
if (!e && !i)
|
|
2454
|
+
throw new g(
|
|
2166
2455
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2167
2456
|
);
|
|
2168
2457
|
if ("redirectTo" in t) {
|
|
2169
|
-
const
|
|
2170
|
-
if (!(typeof
|
|
2171
|
-
throw new
|
|
2458
|
+
const s = t.redirectTo;
|
|
2459
|
+
if (!(typeof s == "string" || s instanceof URL))
|
|
2460
|
+
throw new g(
|
|
2172
2461
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2173
2462
|
);
|
|
2174
2463
|
}
|
|
2175
2464
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2176
|
-
throw new
|
|
2465
|
+
throw new g(
|
|
2177
2466
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2178
2467
|
);
|
|
2179
2468
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2180
|
-
throw new
|
|
2469
|
+
throw new g(
|
|
2181
2470
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2182
2471
|
);
|
|
2183
2472
|
if ("appearance" in t && t.appearance !== void 0) {
|
|
2184
|
-
const
|
|
2185
|
-
if (!
|
|
2186
|
-
throw new
|
|
2473
|
+
const s = t.appearance;
|
|
2474
|
+
if (!s || typeof s != "object" || Array.isArray(s))
|
|
2475
|
+
throw new g(
|
|
2187
2476
|
"authUI.mount(container, options) expected appearance to be an object."
|
|
2188
2477
|
);
|
|
2189
|
-
if ("theme" in
|
|
2190
|
-
throw new
|
|
2191
|
-
`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(", ")}.`
|
|
2192
2481
|
);
|
|
2193
|
-
if ("className" in
|
|
2194
|
-
throw new
|
|
2482
|
+
if ("className" in s && s.className !== void 0 && typeof s.className != "string")
|
|
2483
|
+
throw new g(
|
|
2195
2484
|
"authUI.mount(container, options) expected appearance.className to be a string."
|
|
2196
2485
|
);
|
|
2197
|
-
if ("variables" in
|
|
2198
|
-
if (!
|
|
2199
|
-
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(
|
|
2200
2489
|
"authUI.mount(container, options) expected appearance.variables to be an object."
|
|
2201
2490
|
);
|
|
2202
|
-
for (const [n,
|
|
2203
|
-
if (!
|
|
2204
|
-
throw new
|
|
2491
|
+
for (const [n, o] of Object.entries(s.variables)) {
|
|
2492
|
+
if (!Lt(n))
|
|
2493
|
+
throw new g(
|
|
2205
2494
|
`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
|
|
2206
2495
|
);
|
|
2207
|
-
if (
|
|
2208
|
-
throw new
|
|
2496
|
+
if (o !== void 0 && typeof o != "string")
|
|
2497
|
+
throw new g(
|
|
2209
2498
|
`authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
|
|
2210
2499
|
);
|
|
2211
2500
|
}
|
|
2212
2501
|
}
|
|
2213
2502
|
}
|
|
2214
2503
|
}
|
|
2215
|
-
function
|
|
2504
|
+
function jt(t) {
|
|
2216
2505
|
if (!(t instanceof HTMLElement))
|
|
2217
|
-
throw new
|
|
2506
|
+
throw new g("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2218
2507
|
}
|
|
2219
|
-
function
|
|
2508
|
+
function qt(t, e) {
|
|
2509
|
+
const i = Ht({
|
|
2510
|
+
authClient: e.publicAuthClient,
|
|
2511
|
+
loadConfig: Te
|
|
2512
|
+
});
|
|
2220
2513
|
return {
|
|
2221
|
-
mount(s,
|
|
2222
|
-
var
|
|
2223
|
-
|
|
2224
|
-
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 = {
|
|
2225
2518
|
destroy() {
|
|
2226
|
-
|
|
2519
|
+
u(), z.get(s) === f && z.delete(s);
|
|
2227
2520
|
}
|
|
2228
2521
|
};
|
|
2229
|
-
return
|
|
2230
|
-
}
|
|
2522
|
+
return z.set(s, f), f;
|
|
2523
|
+
},
|
|
2524
|
+
promptGoogleOneTap: i
|
|
2231
2525
|
};
|
|
2232
2526
|
}
|
|
2233
|
-
function
|
|
2234
|
-
|
|
2235
|
-
const t =
|
|
2527
|
+
function Wt() {
|
|
2528
|
+
Ce();
|
|
2529
|
+
const t = ht(), e = mt(), i = xe(), s = qt(e, {
|
|
2236
2530
|
syncPublicSession: async () => {
|
|
2237
|
-
await
|
|
2238
|
-
}
|
|
2531
|
+
await ut(t);
|
|
2532
|
+
},
|
|
2533
|
+
publicAuthClient: t
|
|
2239
2534
|
});
|
|
2240
2535
|
return {
|
|
2241
2536
|
auth: t,
|
|
2242
|
-
api:
|
|
2243
|
-
authUI:
|
|
2537
|
+
api: i,
|
|
2538
|
+
authUI: s
|
|
2244
2539
|
};
|
|
2245
2540
|
}
|
|
2246
2541
|
export {
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
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
|
|
2272
2567
|
};
|