@edgespark/web 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -2
- package/auth/styles/styles.css +43 -8
- package/dist/auth/local-dev.d.ts +31 -0
- package/dist/auth/types.d.ts +4 -2
- package/dist/auth-ui/ManagedAuthUI.d.ts +7 -0
- package/dist/auth-ui/appearance.d.ts +64 -0
- package/dist/auth-ui/config.d.ts +2 -1
- package/dist/auth-ui/index.d.ts +2 -0
- package/dist/auth-ui/types.d.ts +15 -6
- package/dist/index.cjs +5 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +449 -289
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,77 +1,86 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
1
|
+
import { createAuthClient as De } from "better-auth/client";
|
|
2
2
|
class te 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 f extends te {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class Ee extends te {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class E extends te {
|
|
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 Se(t, e = "Authentication failed.", s) {
|
|
23
|
+
if (t instanceof E)
|
|
24
24
|
return t;
|
|
25
25
|
if (typeof t == "object" && t !== null) {
|
|
26
26
|
const i = t;
|
|
27
|
-
return new
|
|
27
|
+
return new E(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 E(t, { code: s }) : new E(e, { code: s, cause: t });
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Pe() {
|
|
36
36
|
if (typeof window > "u" || typeof document > "u")
|
|
37
|
-
throw new
|
|
37
|
+
throw new Ee(
|
|
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 Q() {
|
|
42
|
+
return Pe(), window.location.origin;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Ne(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 Ve(t) {
|
|
48
|
+
if (t.origin !== Q())
|
|
49
|
+
throw new f(
|
|
50
|
+
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Fe() {
|
|
54
54
|
return {
|
|
55
55
|
async fetch(t, e) {
|
|
56
|
-
const s =
|
|
57
|
-
return
|
|
56
|
+
const s = Ne(t);
|
|
57
|
+
return Ve(s), fetch(t, {
|
|
58
58
|
...e,
|
|
59
59
|
credentials: "include"
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
const Le = "/api/_es/auth",
|
|
64
|
+
const Le = "/api/_es/auth", He = "edgespark-auth-session", _e = "__edgespark_auth_sync__", V = "__edgespark_auth_pending_sign_in__", Ae = Symbol("edgespark.notifyAuthTabs"), ze = 10 * 60 * 1e3, je = /* @__PURE__ */ new Set([
|
|
65
65
|
"signOut",
|
|
66
66
|
"revokeSession",
|
|
67
67
|
"revokeSessions",
|
|
68
68
|
"revokeOtherSessions"
|
|
69
|
-
]),
|
|
70
|
-
[
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
]), qe = /* @__PURE__ */ new Map([
|
|
70
|
+
[
|
|
71
|
+
"changeEmail",
|
|
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."
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
"deleteUser",
|
|
76
|
+
"deleteUser() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"deleteUserCallback",
|
|
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
|
+
]
|
|
73
82
|
]);
|
|
74
|
-
class
|
|
83
|
+
class xe {
|
|
75
84
|
constructor(e) {
|
|
76
85
|
this.value = e;
|
|
77
86
|
}
|
|
@@ -80,13 +89,13 @@ class De {
|
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
91
|
const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
|
|
83
|
-
let
|
|
84
|
-
const
|
|
85
|
-
|
|
92
|
+
let F, oe = !1;
|
|
93
|
+
const C = /* @__PURE__ */ new Map(), H = re ? new re((t) => {
|
|
94
|
+
C.delete(t);
|
|
86
95
|
}) : null;
|
|
87
|
-
function
|
|
88
|
-
return
|
|
89
|
-
baseURL:
|
|
96
|
+
function Re(t) {
|
|
97
|
+
return De({
|
|
98
|
+
baseURL: Q(),
|
|
90
99
|
basePath: Le,
|
|
91
100
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
92
101
|
fetchOptions: {
|
|
@@ -94,17 +103,17 @@ function Te(t) {
|
|
|
94
103
|
}
|
|
95
104
|
});
|
|
96
105
|
}
|
|
97
|
-
function
|
|
106
|
+
function I(t) {
|
|
98
107
|
var e, s;
|
|
99
108
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
100
109
|
}
|
|
101
|
-
function
|
|
110
|
+
function Ge(t) {
|
|
102
111
|
return JSON.stringify({
|
|
103
112
|
source: t,
|
|
104
113
|
timestamp: Date.now()
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
|
-
function
|
|
116
|
+
function Ke(t) {
|
|
108
117
|
if (typeof t != "string")
|
|
109
118
|
return null;
|
|
110
119
|
try {
|
|
@@ -114,53 +123,53 @@ function He(t) {
|
|
|
114
123
|
return null;
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
|
-
function
|
|
126
|
+
function We(t) {
|
|
118
127
|
return t.join(".");
|
|
119
128
|
}
|
|
120
|
-
function
|
|
121
|
-
const e =
|
|
122
|
-
return s ? new
|
|
129
|
+
function Ye(t) {
|
|
130
|
+
const e = We(t), s = qe.get(e);
|
|
131
|
+
return s ? new E(s, {
|
|
123
132
|
code: "UNSUPPORTED_AUTH_METHOD"
|
|
124
133
|
}) : null;
|
|
125
134
|
}
|
|
126
135
|
async function ee(t) {
|
|
127
136
|
var e;
|
|
128
137
|
try {
|
|
129
|
-
return await ((e =
|
|
138
|
+
return await ((e = I(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
130
139
|
} catch {
|
|
131
140
|
return !1;
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
143
|
+
function Te() {
|
|
144
|
+
return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(He) : null), F;
|
|
136
145
|
}
|
|
137
146
|
function ae(t) {
|
|
138
|
-
const e =
|
|
147
|
+
const e = Ke(t);
|
|
139
148
|
if (e)
|
|
140
|
-
for (const [s, i] of
|
|
149
|
+
for (const [s, i] of C) {
|
|
141
150
|
if (s === e.source)
|
|
142
151
|
continue;
|
|
143
152
|
const n = i.deref();
|
|
144
153
|
if (!n) {
|
|
145
|
-
|
|
154
|
+
C.delete(s);
|
|
146
155
|
continue;
|
|
147
156
|
}
|
|
148
157
|
ee(n);
|
|
149
158
|
}
|
|
150
159
|
}
|
|
151
|
-
function
|
|
160
|
+
function Je() {
|
|
152
161
|
var t;
|
|
153
|
-
oe || (oe = !0, (t =
|
|
162
|
+
oe || (oe = !0, (t = Te()) == null || t.addEventListener("message", (e) => {
|
|
154
163
|
ae(e.data);
|
|
155
164
|
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
156
165
|
e.key !== _e || e.newValue === null || ae(e.newValue);
|
|
157
166
|
}));
|
|
158
167
|
}
|
|
159
|
-
function
|
|
160
|
-
ne ?
|
|
168
|
+
function Xe(t, e) {
|
|
169
|
+
ne ? C.set(t, new ne(e)) : (C.clear(), C.set(t, new xe(e))), H == null || H.register(e, t), Je();
|
|
161
170
|
}
|
|
162
|
-
function
|
|
163
|
-
const e =
|
|
171
|
+
function R(t) {
|
|
172
|
+
const e = Ge(t), s = Te();
|
|
164
173
|
let i = !1;
|
|
165
174
|
if (s)
|
|
166
175
|
try {
|
|
@@ -173,11 +182,11 @@ function C(t) {
|
|
|
173
182
|
} catch {
|
|
174
183
|
}
|
|
175
184
|
}
|
|
176
|
-
function
|
|
185
|
+
function z(t) {
|
|
177
186
|
if (!(typeof window > "u"))
|
|
178
187
|
try {
|
|
179
188
|
window.sessionStorage.setItem(
|
|
180
|
-
|
|
189
|
+
V,
|
|
181
190
|
JSON.stringify({
|
|
182
191
|
path: t,
|
|
183
192
|
createdAt: Date.now()
|
|
@@ -186,287 +195,315 @@ function q(t) {
|
|
|
186
195
|
} catch {
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
|
-
function
|
|
198
|
+
function T() {
|
|
190
199
|
if (!(typeof window > "u"))
|
|
191
200
|
try {
|
|
192
|
-
window.sessionStorage.removeItem(
|
|
201
|
+
window.sessionStorage.removeItem(V);
|
|
193
202
|
} catch {
|
|
194
203
|
}
|
|
195
204
|
}
|
|
196
|
-
function
|
|
205
|
+
function Ze(t) {
|
|
197
206
|
return !!(t != null && t.session && (t != null && t.user));
|
|
198
207
|
}
|
|
199
|
-
function
|
|
208
|
+
function m(t) {
|
|
200
209
|
return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
|
|
201
210
|
}
|
|
202
|
-
function
|
|
211
|
+
function Qe(t) {
|
|
203
212
|
return t ? JSON.stringify({
|
|
204
213
|
session: {
|
|
205
|
-
createdAt:
|
|
206
|
-
expiresAt:
|
|
207
|
-
id:
|
|
208
|
-
impersonatedBy:
|
|
209
|
-
ipAddress:
|
|
210
|
-
token:
|
|
211
|
-
updatedAt:
|
|
212
|
-
userAgent:
|
|
213
|
-
userId:
|
|
214
|
+
createdAt: m(t.session.createdAt),
|
|
215
|
+
expiresAt: m(t.session.expiresAt),
|
|
216
|
+
id: m(t.session.id),
|
|
217
|
+
impersonatedBy: m(t.session.impersonatedBy),
|
|
218
|
+
ipAddress: m(t.session.ipAddress),
|
|
219
|
+
token: m(t.session.token),
|
|
220
|
+
updatedAt: m(t.session.updatedAt),
|
|
221
|
+
userAgent: m(t.session.userAgent),
|
|
222
|
+
userId: m(t.session.userId)
|
|
214
223
|
},
|
|
215
224
|
user: {
|
|
216
|
-
banExpires:
|
|
217
|
-
banReason:
|
|
218
|
-
banned:
|
|
219
|
-
createdAt:
|
|
220
|
-
email:
|
|
221
|
-
emailVerified:
|
|
222
|
-
id:
|
|
223
|
-
image:
|
|
224
|
-
lastLoginAt:
|
|
225
|
-
name:
|
|
226
|
-
role:
|
|
227
|
-
updatedAt:
|
|
225
|
+
banExpires: m(t.user.banExpires),
|
|
226
|
+
banReason: m(t.user.banReason),
|
|
227
|
+
banned: m(t.user.banned),
|
|
228
|
+
createdAt: m(t.user.createdAt),
|
|
229
|
+
email: m(t.user.email),
|
|
230
|
+
emailVerified: m(t.user.emailVerified),
|
|
231
|
+
id: m(t.user.id),
|
|
232
|
+
image: m(t.user.image),
|
|
233
|
+
lastLoginAt: m(t.user.lastLoginAt),
|
|
234
|
+
name: m(t.user.name),
|
|
235
|
+
role: m(t.user.role),
|
|
236
|
+
updatedAt: m(t.user.updatedAt)
|
|
228
237
|
}
|
|
229
238
|
}) : "__null__";
|
|
230
239
|
}
|
|
231
|
-
function
|
|
240
|
+
function Ie() {
|
|
232
241
|
if (typeof window > "u")
|
|
233
242
|
return null;
|
|
234
243
|
try {
|
|
235
|
-
const t = window.sessionStorage.getItem(
|
|
244
|
+
const t = window.sessionStorage.getItem(V);
|
|
236
245
|
if (!t)
|
|
237
246
|
return null;
|
|
238
247
|
const e = JSON.parse(t);
|
|
239
|
-
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 > ze ? null : { createdAt: e.createdAt };
|
|
240
249
|
} catch {
|
|
241
250
|
return null;
|
|
242
251
|
}
|
|
243
252
|
}
|
|
244
253
|
function le() {
|
|
245
|
-
if (!
|
|
254
|
+
if (!Ie())
|
|
246
255
|
return !1;
|
|
247
256
|
try {
|
|
248
|
-
window.sessionStorage.removeItem(
|
|
257
|
+
window.sessionStorage.removeItem(V);
|
|
249
258
|
} catch {
|
|
250
259
|
}
|
|
251
260
|
return !0;
|
|
252
261
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
262
|
+
function et() {
|
|
263
|
+
return Ie() !== null;
|
|
255
264
|
}
|
|
256
|
-
function
|
|
265
|
+
function tt(t) {
|
|
257
266
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
258
267
|
return !1;
|
|
259
268
|
const e = "data" in t ? t.data : t;
|
|
260
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;
|
|
261
270
|
}
|
|
262
|
-
function
|
|
271
|
+
function st(t) {
|
|
263
272
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
264
273
|
return !1;
|
|
265
274
|
const e = "data" in t ? t.data : t;
|
|
266
275
|
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
267
276
|
}
|
|
268
|
-
function
|
|
269
|
-
if (
|
|
277
|
+
function it(t) {
|
|
278
|
+
if (A(t) || !(t && typeof t == "object"))
|
|
270
279
|
return !1;
|
|
271
280
|
const e = "data" in t ? t.data : t;
|
|
272
281
|
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
273
282
|
}
|
|
274
|
-
function
|
|
283
|
+
function nt(t, e) {
|
|
275
284
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
276
285
|
return !1;
|
|
277
286
|
const [s] = e;
|
|
278
287
|
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
279
288
|
}
|
|
280
|
-
function
|
|
289
|
+
function A(t) {
|
|
281
290
|
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
282
291
|
}
|
|
283
|
-
function
|
|
284
|
-
if (
|
|
292
|
+
function rt(t) {
|
|
293
|
+
if (A(t) || !(t && typeof t == "object"))
|
|
285
294
|
return !1;
|
|
286
295
|
const e = "data" in t ? t.data : t;
|
|
287
296
|
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
288
297
|
}
|
|
289
|
-
function
|
|
298
|
+
function ot(t) {
|
|
290
299
|
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
291
300
|
}
|
|
292
|
-
function
|
|
293
|
-
return
|
|
301
|
+
function j(t) {
|
|
302
|
+
return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
294
303
|
}
|
|
295
|
-
async function
|
|
304
|
+
async function at(t) {
|
|
296
305
|
var s, i;
|
|
297
306
|
let e = null;
|
|
298
307
|
try {
|
|
299
|
-
await ((s =
|
|
308
|
+
await ((s = I(t)) == null ? void 0 : s.get().refetch());
|
|
300
309
|
} catch (n) {
|
|
301
310
|
e = n;
|
|
302
311
|
} finally {
|
|
303
|
-
(i = t[
|
|
312
|
+
(i = t[Ae]) == null || i.call(t);
|
|
304
313
|
}
|
|
305
314
|
if (e)
|
|
306
315
|
throw e;
|
|
307
316
|
}
|
|
308
|
-
function
|
|
309
|
-
const t =
|
|
310
|
-
|
|
317
|
+
function lt() {
|
|
318
|
+
const t = Re(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
319
|
+
Xe(e, t);
|
|
311
320
|
const s = 2, i = 500;
|
|
312
|
-
let n = null, a = !1,
|
|
313
|
-
const
|
|
321
|
+
let n = null, a = !1, u;
|
|
322
|
+
const g = (o) => (u = o, o), S = () => {
|
|
314
323
|
var c;
|
|
315
|
-
const o = (c =
|
|
316
|
-
return o != null && o.error && !o.data &&
|
|
317
|
-
},
|
|
318
|
-
var l,
|
|
324
|
+
const o = (c = I(t)) == null ? void 0 : c.get();
|
|
325
|
+
return o != null && o.error && !o.data && u !== void 0 ? u : (o == null ? void 0 : o.data) ?? u ?? null;
|
|
326
|
+
}, U = () => a ? Promise.resolve(S()) : (n || (n = (async () => {
|
|
327
|
+
var l, h, y;
|
|
319
328
|
let o = !1, c = null;
|
|
320
329
|
try {
|
|
321
|
-
for (let
|
|
330
|
+
for (let b = 0; b <= s; b++) {
|
|
322
331
|
let d = null;
|
|
323
332
|
try {
|
|
324
333
|
d = await t.getSession();
|
|
325
|
-
} catch (
|
|
326
|
-
c =
|
|
334
|
+
} catch (P) {
|
|
335
|
+
c = P;
|
|
327
336
|
}
|
|
328
|
-
const
|
|
329
|
-
if ((
|
|
330
|
-
return a = !0, le() &&
|
|
331
|
-
if (
|
|
332
|
-
return a = !0, le() &&
|
|
333
|
-
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error &&
|
|
337
|
+
const p = ((l = I(t)) == null ? void 0 : l.get().data) ?? null;
|
|
338
|
+
if ((h = d == null ? void 0 : d.data) != null && h.session && ((y = d.data) != null && y.user))
|
|
339
|
+
return a = !0, le() && R(e), g(d.data);
|
|
340
|
+
if (p != null && p.session && (p != null && p.user))
|
|
341
|
+
return a = !0, le() && R(e), g(p);
|
|
342
|
+
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && et() && b < s) {
|
|
334
343
|
await new Promise(
|
|
335
|
-
(
|
|
344
|
+
(P) => setTimeout(P, i)
|
|
336
345
|
);
|
|
337
346
|
continue;
|
|
338
347
|
}
|
|
339
348
|
if (d && !d.error) {
|
|
340
|
-
const
|
|
341
|
-
return a = !0,
|
|
349
|
+
const P = S();
|
|
350
|
+
return a = !0, g(P);
|
|
342
351
|
}
|
|
343
|
-
|
|
344
|
-
(
|
|
352
|
+
b < s && await new Promise(
|
|
353
|
+
(P) => setTimeout(P, i)
|
|
345
354
|
);
|
|
346
355
|
}
|
|
347
356
|
if (!o)
|
|
348
|
-
throw n = null, new
|
|
357
|
+
throw n = null, new E("Failed to load the current session.", {
|
|
349
358
|
code: "SESSION_LOOKUP_FAILED",
|
|
350
359
|
cause: c
|
|
351
360
|
});
|
|
352
|
-
const
|
|
353
|
-
return a = !0,
|
|
354
|
-
} catch (
|
|
355
|
-
throw n = null,
|
|
361
|
+
const w = S();
|
|
362
|
+
return a = !0, g(w);
|
|
363
|
+
} catch (w) {
|
|
364
|
+
throw n = null, j(w);
|
|
356
365
|
}
|
|
357
366
|
})()), n);
|
|
358
|
-
|
|
367
|
+
U().catch(() => {
|
|
359
368
|
});
|
|
360
|
-
const
|
|
369
|
+
const $ = async () => {
|
|
361
370
|
var o, c;
|
|
362
371
|
try {
|
|
363
372
|
const l = await t.getSession();
|
|
364
373
|
if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
|
|
365
374
|
return l.data;
|
|
366
|
-
throw l.error ?
|
|
375
|
+
throw l.error ? j(l.error) : new E("No authenticated session is available.", {
|
|
367
376
|
code: "UNAUTHENTICATED"
|
|
368
377
|
});
|
|
369
378
|
} catch (l) {
|
|
370
|
-
throw
|
|
379
|
+
throw j(l);
|
|
371
380
|
}
|
|
372
|
-
},
|
|
373
|
-
await ee(t),
|
|
374
|
-
},
|
|
381
|
+
}, v = async () => {
|
|
382
|
+
await ee(t), R(e);
|
|
383
|
+
}, Be = async () => {
|
|
375
384
|
var l;
|
|
376
|
-
const o = await ee(t), c = ((l =
|
|
377
|
-
|
|
378
|
-
},
|
|
379
|
-
let c = !1, l = !1,
|
|
385
|
+
const o = await ee(t), c = ((l = I(t)) == null ? void 0 : l.get().data) ?? null;
|
|
386
|
+
Ze(c) ? (T(), R(e)) : o || R(e);
|
|
387
|
+
}, Me = (o) => {
|
|
388
|
+
let c = !1, l = !1, h;
|
|
380
389
|
const y = (d) => {
|
|
381
|
-
const
|
|
382
|
-
|
|
390
|
+
const p = Qe(d);
|
|
391
|
+
p !== h && (h = p, o(d));
|
|
383
392
|
};
|
|
384
|
-
|
|
385
|
-
c || (l = !0, y(
|
|
393
|
+
U().then((d) => {
|
|
394
|
+
c || (l = !0, y(g(d)));
|
|
386
395
|
}).catch(() => {
|
|
387
396
|
c || (l = !0);
|
|
388
397
|
});
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
398
|
+
const w = I(t);
|
|
399
|
+
if (!w)
|
|
391
400
|
return () => {
|
|
392
401
|
c = !0;
|
|
393
402
|
};
|
|
394
|
-
const
|
|
403
|
+
const b = w.subscribe((d) => {
|
|
395
404
|
if (c || !l || d.error && !d.data)
|
|
396
405
|
return;
|
|
397
|
-
const
|
|
398
|
-
y(
|
|
406
|
+
const p = d.data ?? null;
|
|
407
|
+
y(g(p));
|
|
399
408
|
});
|
|
400
409
|
return () => {
|
|
401
|
-
c = !0,
|
|
410
|
+
c = !0, b();
|
|
402
411
|
};
|
|
403
|
-
},
|
|
404
|
-
const
|
|
405
|
-
return o.length === 1 && (
|
|
412
|
+
}, Oe = async (o, c, l) => {
|
|
413
|
+
const h = o[0], y = o.length >= 2 && h === "emailOtp" && o[1] === "verifyEmail", w = o.length >= 2 && h === "emailOtp" && o[1] === "resetPassword", b = o.length >= 2 && h === "resetPassword" && o[1] === "emailOtp";
|
|
414
|
+
return o.length === 1 && (h === "deleteUser" || h === "deleteUserCallback") ? (T(), rt(l) && await v(), l) : o.length === 1 && h && je.has(h) ? (T(), A(l) || await v(), l) : nt(o, c) && !A(l) ? (T(), await v(), l) : (w || b) && !A(l) ? (T(), await v(), l) : o.length === 1 && h === "changeEmail" && !A(l) ? (await v(), l) : ((h === "signIn" || h === "signUp" || y) && tt(l) ? (T(), await v()) : (h === "signIn" || h === "signUp") && st(l) || h === "signUp" && it(l) ? z(o) : h === "verifyEmail" && !A(l) && (z(o), await Be()), l);
|
|
406
415
|
}, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
|
|
407
416
|
if (!o || typeof o != "object" && typeof o != "function")
|
|
408
417
|
return o;
|
|
409
418
|
const l = se.get(o);
|
|
410
419
|
if (l)
|
|
411
420
|
return l;
|
|
412
|
-
const
|
|
413
|
-
get(y,
|
|
421
|
+
const h = new Proxy(o, {
|
|
422
|
+
get(y, w, b) {
|
|
414
423
|
if (c.length === 0) {
|
|
415
|
-
if (
|
|
416
|
-
return
|
|
417
|
-
if (
|
|
418
|
-
return
|
|
419
|
-
if (
|
|
424
|
+
if (w === "requireSession")
|
|
425
|
+
return $;
|
|
426
|
+
if (w === "onSessionChange")
|
|
427
|
+
return Me;
|
|
428
|
+
if (w === Ae)
|
|
420
429
|
return () => {
|
|
421
|
-
|
|
430
|
+
R(e);
|
|
422
431
|
};
|
|
423
432
|
}
|
|
424
|
-
const d = Reflect.get(y,
|
|
425
|
-
return typeof
|
|
433
|
+
const d = Reflect.get(y, w, b);
|
|
434
|
+
return typeof w != "string" ? d : ie(d, [...c, w]);
|
|
426
435
|
},
|
|
427
|
-
apply(y,
|
|
428
|
-
const d =
|
|
436
|
+
apply(y, w, b) {
|
|
437
|
+
const d = Ye(c);
|
|
429
438
|
if (d)
|
|
430
439
|
throw d;
|
|
431
|
-
const
|
|
440
|
+
const p = Reflect.apply(
|
|
432
441
|
y,
|
|
433
|
-
|
|
434
|
-
|
|
442
|
+
w,
|
|
443
|
+
b
|
|
435
444
|
);
|
|
436
|
-
return
|
|
437
|
-
(
|
|
438
|
-
) :
|
|
445
|
+
return ot(p) ? Promise.resolve(p).then(
|
|
446
|
+
(P) => Oe(c, b, P)
|
|
447
|
+
) : p;
|
|
439
448
|
}
|
|
440
449
|
});
|
|
441
|
-
return se.set(o,
|
|
450
|
+
return se.set(o, h), h;
|
|
442
451
|
};
|
|
443
452
|
return ie(t, []);
|
|
444
453
|
}
|
|
445
|
-
function
|
|
446
|
-
return
|
|
454
|
+
function dt() {
|
|
455
|
+
return Re({ disableDefaultRedirectPlugin: !0 });
|
|
447
456
|
}
|
|
448
|
-
|
|
457
|
+
const Ce = "/api/_es/dev";
|
|
458
|
+
function ct() {
|
|
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 ut(t) {
|
|
464
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
465
|
+
if (!e) return !1;
|
|
466
|
+
const s = await fetch(
|
|
467
|
+
`${e}${Ce}/auto-verify?email=${encodeURIComponent(t)}`,
|
|
468
|
+
{ credentials: "include" }
|
|
469
|
+
);
|
|
470
|
+
return s.ok ? (await s.json()).verified === !0 : !1;
|
|
471
|
+
}
|
|
472
|
+
async function ht(t) {
|
|
473
|
+
const e = typeof window < "u" ? window.location.origin : "";
|
|
474
|
+
if (!e) return null;
|
|
475
|
+
try {
|
|
476
|
+
const s = await fetch(
|
|
477
|
+
`${e}${Ce}/pending-otp?email=${encodeURIComponent(t)}`,
|
|
478
|
+
{ credentials: "include" }
|
|
479
|
+
);
|
|
480
|
+
return s.ok ? (await s.json()).otp ?? null : null;
|
|
481
|
+
} catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function mt(t) {
|
|
449
486
|
const e = (() => {
|
|
450
487
|
if (t instanceof URL)
|
|
451
488
|
return t;
|
|
452
489
|
const s = t.trim();
|
|
453
490
|
if (!s)
|
|
454
|
-
throw new
|
|
491
|
+
throw new f("redirectTo must not be an empty string.");
|
|
455
492
|
try {
|
|
456
493
|
return new URL(s, window.location.href);
|
|
457
494
|
} catch {
|
|
458
|
-
throw new
|
|
495
|
+
throw new f(
|
|
459
496
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
460
497
|
);
|
|
461
498
|
}
|
|
462
499
|
})();
|
|
463
500
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
464
|
-
throw new
|
|
501
|
+
throw new f(
|
|
465
502
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
466
503
|
);
|
|
467
504
|
return e;
|
|
468
505
|
}
|
|
469
|
-
function
|
|
506
|
+
function ft(t, e) {
|
|
470
507
|
return e ? {
|
|
471
508
|
common: { ...t.common, ...e.common },
|
|
472
509
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -541,7 +578,7 @@ const N = {
|
|
|
541
578
|
invalidCode: "Enter the 6-digit verification code.",
|
|
542
579
|
generic: "Something went wrong. Please try again."
|
|
543
580
|
}
|
|
544
|
-
},
|
|
581
|
+
}, q = {
|
|
545
582
|
common: {
|
|
546
583
|
loading: "加载中…",
|
|
547
584
|
redirecting: "跳转中…",
|
|
@@ -1237,9 +1274,9 @@ const N = {
|
|
|
1237
1274
|
}, be = {
|
|
1238
1275
|
en: N,
|
|
1239
1276
|
"en-US": N,
|
|
1240
|
-
zh:
|
|
1241
|
-
"zh-CN":
|
|
1242
|
-
"zh-TW":
|
|
1277
|
+
zh: q,
|
|
1278
|
+
"zh-CN": q,
|
|
1279
|
+
"zh-TW": q,
|
|
1243
1280
|
ja: de,
|
|
1244
1281
|
"ja-JP": de,
|
|
1245
1282
|
ko: ce,
|
|
@@ -1262,7 +1299,7 @@ const N = {
|
|
|
1262
1299
|
hi: ge,
|
|
1263
1300
|
"hi-IN": ge
|
|
1264
1301
|
};
|
|
1265
|
-
function
|
|
1302
|
+
function wt() {
|
|
1266
1303
|
if (typeof navigator > "u")
|
|
1267
1304
|
return N;
|
|
1268
1305
|
const t = navigator.languages ?? [navigator.language];
|
|
@@ -1272,14 +1309,54 @@ function lt() {
|
|
|
1272
1309
|
}
|
|
1273
1310
|
return N;
|
|
1274
1311
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1312
|
+
const Ue = {
|
|
1313
|
+
LIGHT: "light",
|
|
1314
|
+
DARK: "dark"
|
|
1315
|
+
}, $e = Ue.LIGHT, pt = Ue.DARK, ke = [$e, pt], gt = $e, bt = {
|
|
1316
|
+
BACKGROUND: "--edgespark-auth-bg",
|
|
1317
|
+
BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
|
|
1318
|
+
CARD_BACKGROUND: "--edgespark-auth-card-bg",
|
|
1319
|
+
BORDER: "--edgespark-auth-border",
|
|
1320
|
+
TEXT: "--edgespark-auth-text",
|
|
1321
|
+
TEXT_MUTED: "--edgespark-auth-text-muted",
|
|
1322
|
+
DIVIDER_BACKGROUND: "--edgespark-auth-divider-bg",
|
|
1323
|
+
PRIMARY: "--edgespark-auth-primary",
|
|
1324
|
+
PRIMARY_HOVER: "--edgespark-auth-primary-hover",
|
|
1325
|
+
PRIMARY_CONTRAST: "--edgespark-auth-primary-contrast",
|
|
1326
|
+
ERROR: "--edgespark-auth-error",
|
|
1327
|
+
INFO: "--edgespark-auth-info",
|
|
1328
|
+
CARD_RADIUS: "--edgespark-auth-radius-card",
|
|
1329
|
+
CONTROL_RADIUS: "--edgespark-auth-radius-control",
|
|
1330
|
+
SHADOW: "--edgespark-auth-shadow",
|
|
1331
|
+
FONT: "--edgespark-auth-font",
|
|
1332
|
+
MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
|
|
1333
|
+
MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
|
|
1334
|
+
MODAL_SHADOW: "--edgespark-auth-modal-shadow"
|
|
1335
|
+
}, vt = Object.values(
|
|
1336
|
+
bt
|
|
1337
|
+
);
|
|
1338
|
+
function yt(t) {
|
|
1339
|
+
return typeof t == "string" && ke.includes(t);
|
|
1340
|
+
}
|
|
1341
|
+
function Et(t) {
|
|
1342
|
+
return vt.includes(t);
|
|
1277
1343
|
}
|
|
1278
|
-
|
|
1344
|
+
function St(t) {
|
|
1345
|
+
var e;
|
|
1346
|
+
return {
|
|
1347
|
+
theme: (t == null ? void 0 : t.theme) ?? gt,
|
|
1348
|
+
className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
|
|
1349
|
+
variables: { ...(t == null ? void 0 : t.variables) ?? {} }
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function G(t, e = "Authentication failed.") {
|
|
1353
|
+
return Se(t, e);
|
|
1354
|
+
}
|
|
1355
|
+
async function B(t) {
|
|
1279
1356
|
var s, i;
|
|
1280
1357
|
const e = await t.getSession();
|
|
1281
1358
|
if (e.error)
|
|
1282
|
-
throw new
|
|
1359
|
+
throw new E(
|
|
1283
1360
|
e.error.message || "Failed to load the current session.",
|
|
1284
1361
|
{
|
|
1285
1362
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1295,7 +1372,7 @@ async function k(t) {
|
|
|
1295
1372
|
session: null
|
|
1296
1373
|
};
|
|
1297
1374
|
}
|
|
1298
|
-
const
|
|
1375
|
+
const Pt = "data-edgespark-auth", Lt = "data-edgespark-auth-theme", r = "edgespark-auth", K = "es_auth_completion", M = "es_auth_email", W = "oauth", k = "verify-sign-in", L = "verify-sign-up", ve = 200, Y = 2, _t = {
|
|
1299
1376
|
"&": "&",
|
|
1300
1377
|
"<": "<",
|
|
1301
1378
|
">": ">",
|
|
@@ -1309,25 +1386,25 @@ const dt = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion"
|
|
|
1309
1386
|
gitlab: "GitLab",
|
|
1310
1387
|
discord: "Discord"
|
|
1311
1388
|
};
|
|
1312
|
-
function
|
|
1389
|
+
function _(t) {
|
|
1313
1390
|
return "redirectTo" in t;
|
|
1314
1391
|
}
|
|
1315
|
-
function
|
|
1392
|
+
function X(t) {
|
|
1316
1393
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1317
1394
|
}
|
|
1318
|
-
function
|
|
1395
|
+
function Z(t) {
|
|
1319
1396
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1320
1397
|
}
|
|
1321
|
-
function
|
|
1398
|
+
function At(t) {
|
|
1322
1399
|
return /^\d{6}$/.test(t.trim());
|
|
1323
1400
|
}
|
|
1324
|
-
function
|
|
1401
|
+
function Rt(t) {
|
|
1325
1402
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1326
1403
|
}
|
|
1327
|
-
function
|
|
1404
|
+
function Tt(t) {
|
|
1328
1405
|
return !!(t.error || t.errorDescription);
|
|
1329
1406
|
}
|
|
1330
|
-
class
|
|
1407
|
+
class It {
|
|
1331
1408
|
constructor(e, s, i, n, a) {
|
|
1332
1409
|
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
|
|
1333
1410
|
view: "loading",
|
|
@@ -1341,7 +1418,12 @@ class ft {
|
|
|
1341
1418
|
confirmPassword: "",
|
|
1342
1419
|
code: "",
|
|
1343
1420
|
newPassword: ""
|
|
1344
|
-
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null
|
|
1421
|
+
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
|
|
1422
|
+
const u = St(i.appearance);
|
|
1423
|
+
this.labels = ft(wt(), i.labels), this.root = document.createElement("div"), this.root.className = u.className ? `${r} ${u.className}` : r, this.root.setAttribute(Pt, ""), this.root.setAttribute(Lt, u.theme);
|
|
1424
|
+
for (const [g, S] of Object.entries(u.variables))
|
|
1425
|
+
S !== void 0 && this.root.style.setProperty(g, S);
|
|
1426
|
+
e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1345
1427
|
}
|
|
1346
1428
|
destroy() {
|
|
1347
1429
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
@@ -1356,7 +1438,7 @@ class ft {
|
|
|
1356
1438
|
if (this.destroyed)
|
|
1357
1439
|
return;
|
|
1358
1440
|
if (i.status === "rejected") {
|
|
1359
|
-
if (e.marker && !
|
|
1441
|
+
if (e.marker && !Tt(e) && _(this.options)) {
|
|
1360
1442
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1361
1443
|
return;
|
|
1362
1444
|
}
|
|
@@ -1364,11 +1446,11 @@ class ft {
|
|
|
1364
1446
|
const a = i.value;
|
|
1365
1447
|
if (a.user && a.session) {
|
|
1366
1448
|
switch (e.marker) {
|
|
1367
|
-
case
|
|
1368
|
-
case
|
|
1449
|
+
case W:
|
|
1450
|
+
case k:
|
|
1369
1451
|
await this.completeAuth("sign-in", a);
|
|
1370
1452
|
return;
|
|
1371
|
-
case
|
|
1453
|
+
case L:
|
|
1372
1454
|
await this.completeAuth("sign-up", a);
|
|
1373
1455
|
return;
|
|
1374
1456
|
default:
|
|
@@ -1391,24 +1473,24 @@ class ft {
|
|
|
1391
1473
|
}
|
|
1392
1474
|
}
|
|
1393
1475
|
redirectAfterManagedReturnLookupFailure() {
|
|
1394
|
-
|
|
1476
|
+
_(this.options) && this.navigateToRedirect();
|
|
1395
1477
|
}
|
|
1396
1478
|
navigateToRedirect() {
|
|
1397
|
-
|
|
1479
|
+
_(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(mt(this.options.redirectTo).toString()));
|
|
1398
1480
|
}
|
|
1399
1481
|
async readMountSession(e) {
|
|
1400
1482
|
if (!e.marker)
|
|
1401
|
-
return
|
|
1483
|
+
return B(this.auth);
|
|
1402
1484
|
let s = null;
|
|
1403
1485
|
for (let i = 0; i <= Y; i++) {
|
|
1404
1486
|
try {
|
|
1405
|
-
const n = await
|
|
1487
|
+
const n = await B(this.auth);
|
|
1406
1488
|
if (n.user && n.session)
|
|
1407
1489
|
return n;
|
|
1408
1490
|
} catch (n) {
|
|
1409
1491
|
s = n;
|
|
1410
1492
|
}
|
|
1411
|
-
i < Y && await new Promise((n) => setTimeout(n,
|
|
1493
|
+
i < Y && await new Promise((n) => setTimeout(n, ve));
|
|
1412
1494
|
}
|
|
1413
1495
|
if (s)
|
|
1414
1496
|
throw s;
|
|
@@ -1427,6 +1509,7 @@ class ft {
|
|
|
1427
1509
|
}
|
|
1428
1510
|
this.root.innerHTML = `
|
|
1429
1511
|
<div class="${r}__shell">
|
|
1512
|
+
${this.renderDevModeBanner()}
|
|
1430
1513
|
<div class="${r}__card">
|
|
1431
1514
|
${this.renderStatus()}
|
|
1432
1515
|
${this.renderCurrentView()}
|
|
@@ -1444,6 +1527,10 @@ class ft {
|
|
|
1444
1527
|
</div>
|
|
1445
1528
|
`;
|
|
1446
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
|
+
}
|
|
1447
1534
|
renderStatus() {
|
|
1448
1535
|
const e = [];
|
|
1449
1536
|
return this.state.error && e.push(
|
|
@@ -1642,12 +1729,12 @@ class ft {
|
|
|
1642
1729
|
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1643
1730
|
n.addEventListener("submit", (a) => {
|
|
1644
1731
|
a.preventDefault();
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1732
|
+
const u = n.dataset.view;
|
|
1733
|
+
u === "sign-in" && this.handleSignIn(), u === "sign-up" && this.handleSignUp(), u === "forgot-password" && this.handleForgotPassword(), u === "reset-password" && this.handleResetPassword();
|
|
1647
1734
|
});
|
|
1648
1735
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1649
1736
|
n.addEventListener("input", () => {
|
|
1650
|
-
|
|
1737
|
+
Rt(n.name) && (this.state[n.name] = n.value);
|
|
1651
1738
|
});
|
|
1652
1739
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1653
1740
|
n.addEventListener("click", () => {
|
|
@@ -1660,7 +1747,7 @@ class ft {
|
|
|
1660
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();
|
|
1661
1748
|
}
|
|
1662
1749
|
async handleSignIn() {
|
|
1663
|
-
if (!
|
|
1750
|
+
if (!Z(this.state.email)) {
|
|
1664
1751
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1665
1752
|
return;
|
|
1666
1753
|
}
|
|
@@ -1672,7 +1759,7 @@ class ft {
|
|
|
1672
1759
|
const e = await this.auth.signIn.email({
|
|
1673
1760
|
email: this.state.email.trim(),
|
|
1674
1761
|
password: this.state.password,
|
|
1675
|
-
callbackURL: this.getManagedReturnURL(
|
|
1762
|
+
callbackURL: this.getManagedReturnURL(k, this.state.email.trim())
|
|
1676
1763
|
});
|
|
1677
1764
|
if (e.error)
|
|
1678
1765
|
throw e.error;
|
|
@@ -1685,7 +1772,7 @@ class ft {
|
|
|
1685
1772
|
this.failValidation(this.labels.errors.requiredField);
|
|
1686
1773
|
return;
|
|
1687
1774
|
}
|
|
1688
|
-
if (!
|
|
1775
|
+
if (!Z(this.state.email)) {
|
|
1689
1776
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1690
1777
|
return;
|
|
1691
1778
|
}
|
|
@@ -1709,12 +1796,14 @@ class ft {
|
|
|
1709
1796
|
name: this.state.name.trim(),
|
|
1710
1797
|
email: this.state.email.trim(),
|
|
1711
1798
|
password: this.state.password,
|
|
1712
|
-
callbackURL: this.getManagedReturnURL(
|
|
1799
|
+
callbackURL: this.getManagedReturnURL(L, this.state.email.trim())
|
|
1713
1800
|
});
|
|
1714
1801
|
if (i.error)
|
|
1715
1802
|
throw i.error;
|
|
1716
1803
|
if ((n = this.config) != null && n.requireEmailVerification) {
|
|
1717
|
-
|
|
1804
|
+
if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", i.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();
|
|
1718
1807
|
return;
|
|
1719
1808
|
}
|
|
1720
1809
|
await this.completeAuth("sign-up", await this.resolveAuthCompletionData(i.data));
|
|
@@ -1731,28 +1820,35 @@ class ft {
|
|
|
1731
1820
|
throw s.error;
|
|
1732
1821
|
const i = this.extractRedirectURL(s.data);
|
|
1733
1822
|
if (!i)
|
|
1734
|
-
throw new
|
|
1823
|
+
throw new f(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1735
1824
|
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${J[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
|
|
1736
1825
|
});
|
|
1737
1826
|
}
|
|
1738
1827
|
async handleForgotPassword() {
|
|
1739
1828
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1740
1829
|
this.handleError(
|
|
1741
|
-
new
|
|
1830
|
+
new f("Password reset via email OTP is not enabled for this project.")
|
|
1742
1831
|
);
|
|
1743
1832
|
return;
|
|
1744
1833
|
}
|
|
1745
|
-
if (!
|
|
1834
|
+
if (!Z(this.state.email)) {
|
|
1746
1835
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1747
1836
|
return;
|
|
1748
1837
|
}
|
|
1749
1838
|
await this.runAction("Sending reset code…", async () => {
|
|
1839
|
+
var s;
|
|
1750
1840
|
const e = await this.passwordResetEndpoints().forgetPassword.emailOtp({
|
|
1751
1841
|
email: this.state.email.trim()
|
|
1752
1842
|
});
|
|
1753
1843
|
if (e.error)
|
|
1754
1844
|
throw e.error;
|
|
1755
|
-
this.state.view = "reset-password",
|
|
1845
|
+
if (this.state.view = "reset-password", (s = this.config) != null && s.isLocalDev) {
|
|
1846
|
+
this.state.busyLabel = "Dev mode: fetching reset code…", this.render();
|
|
1847
|
+
const i = await ht(this.state.email.trim());
|
|
1848
|
+
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
|
+
} else
|
|
1850
|
+
this.state.notice = `We sent a reset code to ${this.state.email.trim()}.`;
|
|
1851
|
+
this.startCountdown();
|
|
1756
1852
|
});
|
|
1757
1853
|
}
|
|
1758
1854
|
async resendResetCode() {
|
|
@@ -1762,11 +1858,11 @@ class ft {
|
|
|
1762
1858
|
var e, s;
|
|
1763
1859
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1764
1860
|
this.handleError(
|
|
1765
|
-
new
|
|
1861
|
+
new f("Password reset via email OTP is not enabled for this project.")
|
|
1766
1862
|
);
|
|
1767
1863
|
return;
|
|
1768
1864
|
}
|
|
1769
|
-
if (!
|
|
1865
|
+
if (!At(this.state.code)) {
|
|
1770
1866
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1771
1867
|
return;
|
|
1772
1868
|
}
|
|
@@ -1796,14 +1892,39 @@ class ft {
|
|
|
1796
1892
|
});
|
|
1797
1893
|
}
|
|
1798
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 s = this.verificationCompletionAction ?? "sign-in";
|
|
1900
|
+
if (!await this.tryDevAutoVerify(s))
|
|
1901
|
+
throw new Error(
|
|
1902
|
+
"Dev auto-verify did not complete. Check the edgespark dev logs and try again."
|
|
1903
|
+
);
|
|
1904
|
+
});
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1799
1907
|
await this.sendVerificationEmail(!1);
|
|
1800
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, s) {
|
|
1915
|
+
const i = this.state.email.trim();
|
|
1916
|
+
try {
|
|
1917
|
+
return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await ut(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
|
+
} catch (n) {
|
|
1919
|
+
return console.warn("[edgespark] Dev auto-verify failed:", n), !1;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1801
1922
|
async sendVerificationEmail(e) {
|
|
1802
1923
|
!e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
|
|
1803
1924
|
const s = await this.auth.sendVerificationEmail({
|
|
1804
1925
|
email: this.state.email.trim(),
|
|
1805
1926
|
callbackURL: this.getManagedReturnURL(
|
|
1806
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1927
|
+
this.verificationCompletionAction === "sign-up" ? L : k,
|
|
1807
1928
|
this.state.email.trim()
|
|
1808
1929
|
)
|
|
1809
1930
|
});
|
|
@@ -1821,12 +1942,12 @@ class ft {
|
|
|
1821
1942
|
if (!i.user || !i.session) {
|
|
1822
1943
|
if (this.destroyed)
|
|
1823
1944
|
return;
|
|
1824
|
-
if (i.lookupError &&
|
|
1945
|
+
if (i.lookupError && _(this.options)) {
|
|
1825
1946
|
this.navigateToRedirect();
|
|
1826
1947
|
return;
|
|
1827
1948
|
}
|
|
1828
1949
|
if (e === "sign-in")
|
|
1829
|
-
throw i.lookupError ?? new
|
|
1950
|
+
throw i.lookupError ?? new Ee(
|
|
1830
1951
|
"Managed sign-in completed without an authenticated session."
|
|
1831
1952
|
);
|
|
1832
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();
|
|
@@ -1838,11 +1959,11 @@ class ft {
|
|
|
1838
1959
|
session: i.session
|
|
1839
1960
|
};
|
|
1840
1961
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1841
|
-
if (
|
|
1962
|
+
if (_(this.options)) {
|
|
1842
1963
|
this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
|
|
1843
1964
|
return;
|
|
1844
1965
|
}
|
|
1845
|
-
if (
|
|
1966
|
+
if (X(this.options)) {
|
|
1846
1967
|
this.options.onSuccess(n), this.terminalActionInProgress = !0;
|
|
1847
1968
|
return;
|
|
1848
1969
|
}
|
|
@@ -1853,9 +1974,9 @@ class ft {
|
|
|
1853
1974
|
return e;
|
|
1854
1975
|
let s = e.lookupError;
|
|
1855
1976
|
for (let i = 0; i < Y; i++) {
|
|
1856
|
-
await new Promise((n) => setTimeout(n,
|
|
1977
|
+
await new Promise((n) => setTimeout(n, ve));
|
|
1857
1978
|
try {
|
|
1858
|
-
const n = await
|
|
1979
|
+
const n = await B(this.auth);
|
|
1859
1980
|
if (n.user && n.session)
|
|
1860
1981
|
return {
|
|
1861
1982
|
user: n.user,
|
|
@@ -1879,7 +2000,7 @@ class ft {
|
|
|
1879
2000
|
}
|
|
1880
2001
|
async resolveAuthCompletionData(e) {
|
|
1881
2002
|
try {
|
|
1882
|
-
const s = await
|
|
2003
|
+
const s = await B(this.auth), i = this.extractUser(e);
|
|
1883
2004
|
return {
|
|
1884
2005
|
user: s.user ?? i,
|
|
1885
2006
|
session: s.session
|
|
@@ -1899,7 +2020,7 @@ class ft {
|
|
|
1899
2020
|
session: null
|
|
1900
2021
|
};
|
|
1901
2022
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1902
|
-
if (
|
|
2023
|
+
if (X(this.options)) {
|
|
1903
2024
|
this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
|
|
1904
2025
|
return;
|
|
1905
2026
|
}
|
|
@@ -1907,12 +2028,12 @@ class ft {
|
|
|
1907
2028
|
}
|
|
1908
2029
|
}
|
|
1909
2030
|
handleExistingSessionOnMount() {
|
|
1910
|
-
if (
|
|
2031
|
+
if (_(this.options)) {
|
|
1911
2032
|
this.navigateToRedirect();
|
|
1912
2033
|
return;
|
|
1913
2034
|
}
|
|
1914
|
-
if (
|
|
1915
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
2035
|
+
if (X(this.options))
|
|
2036
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
|
|
1916
2037
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1917
2038
|
);
|
|
1918
2039
|
}
|
|
@@ -1929,18 +2050,18 @@ class ft {
|
|
|
1929
2050
|
!this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
|
|
1930
2051
|
}
|
|
1931
2052
|
maybeHandleVerificationRequired(e) {
|
|
1932
|
-
return
|
|
2053
|
+
return G(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);
|
|
1933
2054
|
}
|
|
1934
2055
|
handleVerificationEmailSent(e, s) {
|
|
1935
2056
|
this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
|
|
1936
2057
|
}
|
|
1937
2058
|
invokeRedirectModeSuccessHook(e) {
|
|
1938
2059
|
var s, i;
|
|
1939
|
-
if (!(!
|
|
2060
|
+
if (!(!_(this.options) || !this.options.onSuccess))
|
|
1940
2061
|
try {
|
|
1941
2062
|
this.options.onSuccess(e);
|
|
1942
2063
|
} catch (n) {
|
|
1943
|
-
const a =
|
|
2064
|
+
const a = G(n, "Post-auth callback failed.");
|
|
1944
2065
|
try {
|
|
1945
2066
|
(i = (s = this.options).onError) == null || i.call(s, a);
|
|
1946
2067
|
} catch {
|
|
@@ -1949,7 +2070,7 @@ class ft {
|
|
|
1949
2070
|
}
|
|
1950
2071
|
handleError(e, s) {
|
|
1951
2072
|
var n, a;
|
|
1952
|
-
const i =
|
|
2073
|
+
const i = G(e, s);
|
|
1953
2074
|
this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (n = this.options).onError) == null || a.call(n, i);
|
|
1954
2075
|
}
|
|
1955
2076
|
failValidation(e) {
|
|
@@ -1959,15 +2080,15 @@ class ft {
|
|
|
1959
2080
|
if (!e)
|
|
1960
2081
|
return window.location.href;
|
|
1961
2082
|
const i = new URL(window.location.href);
|
|
1962
|
-
return i.searchParams.set(
|
|
2083
|
+
return i.searchParams.set(K, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
|
|
1963
2084
|
}
|
|
1964
2085
|
consumeManagedReturnContext() {
|
|
1965
|
-
const e = new URL(window.location.href), s = e.searchParams.get(
|
|
1966
|
-
return (i || n) && (e.searchParams.delete(
|
|
2086
|
+
const e = new URL(window.location.href), s = e.searchParams.get(K), i = s === W || s === k || s === L ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, u = i ? e.searchParams.get("error_description") : null;
|
|
2087
|
+
return (i || n) && (e.searchParams.delete(K), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1967
2088
|
marker: i,
|
|
1968
2089
|
email: n,
|
|
1969
2090
|
error: a,
|
|
1970
|
-
errorDescription:
|
|
2091
|
+
errorDescription: u
|
|
1971
2092
|
};
|
|
1972
2093
|
}
|
|
1973
2094
|
startCountdown(e = 60) {
|
|
@@ -2031,10 +2152,10 @@ class ft {
|
|
|
2031
2152
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
2032
2153
|
}
|
|
2033
2154
|
handleSessionlessManagedReturn(e) {
|
|
2034
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
2155
|
+
return e.email && (this.state.email = e.email), e.marker === L && !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 === k || e.marker === L ? (this.verificationCompletionAction = e.marker === L ? "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 E(
|
|
2035
2156
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
2036
2157
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
2037
|
-
)) : this.render(), !0) : e.marker ===
|
|
2158
|
+
)) : this.render(), !0) : e.marker === W && (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 E(
|
|
2038
2159
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
2039
2160
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
2040
2161
|
)), !0) : !1;
|
|
@@ -2050,106 +2171,138 @@ class ft {
|
|
|
2050
2171
|
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2051
2172
|
}
|
|
2052
2173
|
escape(e) {
|
|
2053
|
-
return e.replace(/[&<>"']/g, (s) =>
|
|
2174
|
+
return e.replace(/[&<>"']/g, (s) => _t[s]);
|
|
2054
2175
|
}
|
|
2055
2176
|
}
|
|
2056
|
-
function
|
|
2177
|
+
function Ct(t) {
|
|
2057
2178
|
return "data" in t && t.data ? t.data : t;
|
|
2058
2179
|
}
|
|
2059
|
-
const
|
|
2180
|
+
const Ut = [
|
|
2060
2181
|
{ id: "google", key: "providerGoogle" },
|
|
2061
2182
|
{ id: "apple", key: "providerApple" },
|
|
2062
2183
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2063
2184
|
{ id: "github", key: "providerGithub" },
|
|
2064
2185
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2065
2186
|
{ id: "discord", key: "providerDiscord" }
|
|
2066
|
-
],
|
|
2067
|
-
async function
|
|
2187
|
+
], ye = 2, $t = 500;
|
|
2188
|
+
async function kt() {
|
|
2068
2189
|
const t = `${window.location.origin}${Le}/config`;
|
|
2069
2190
|
let e;
|
|
2070
|
-
for (let s = 0; s <=
|
|
2191
|
+
for (let s = 0; s <= ye; s++)
|
|
2071
2192
|
try {
|
|
2072
2193
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2073
2194
|
if (!i.ok)
|
|
2074
|
-
throw new
|
|
2075
|
-
const n = await i.json();
|
|
2076
|
-
return
|
|
2195
|
+
throw new f(`Failed to load auth config: HTTP ${i.status}`);
|
|
2196
|
+
const n = await i.json(), a = Ct(n);
|
|
2197
|
+
return Mt(a, ct());
|
|
2077
2198
|
} catch (i) {
|
|
2078
|
-
e = i, s <
|
|
2199
|
+
e = i, s < ye && await new Promise((n) => setTimeout(n, $t));
|
|
2079
2200
|
}
|
|
2080
2201
|
throw e;
|
|
2081
2202
|
}
|
|
2082
2203
|
let O = null;
|
|
2083
|
-
async function
|
|
2084
|
-
return O || (O =
|
|
2204
|
+
async function Bt() {
|
|
2205
|
+
return O || (O = kt().catch((t) => {
|
|
2085
2206
|
throw O = null, t;
|
|
2086
2207
|
})), O;
|
|
2087
2208
|
}
|
|
2088
|
-
function
|
|
2089
|
-
var
|
|
2090
|
-
const
|
|
2091
|
-
const
|
|
2092
|
-
return typeof
|
|
2093
|
-
}).map(({ id:
|
|
2209
|
+
function Mt(t, e = !1) {
|
|
2210
|
+
var i, n, a, u, g, S, U;
|
|
2211
|
+
const s = Ut.filter(({ key: $ }) => {
|
|
2212
|
+
const v = t[$];
|
|
2213
|
+
return typeof v == "object" && v !== null && "enabled" in v && !!v.enabled;
|
|
2214
|
+
}).map(({ id: $ }) => $);
|
|
2094
2215
|
return {
|
|
2095
2216
|
disableSignUp: !!t.disableSignUp,
|
|
2096
|
-
emailPasswordEnabled: !!((
|
|
2097
|
-
minPasswordLength: ((
|
|
2098
|
-
requireEmailVerification: !!((
|
|
2099
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2100
|
-
oauthProviders:
|
|
2217
|
+
emailPasswordEnabled: !!((i = t.providerEmailPassword) != null && i.enabled),
|
|
2218
|
+
minPasswordLength: ((a = (n = t.providerEmailPassword) == null ? void 0 : n.config) == null ? void 0 : a.minPasswordLength) ?? 8,
|
|
2219
|
+
requireEmailVerification: !!((g = (u = t.providerEmailPassword) == null ? void 0 : u.config) != null && g.requireEmailVerification),
|
|
2220
|
+
passwordResetEmailOtpEnabled: !!((U = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && U.requirePasswordResetEmailVerification),
|
|
2221
|
+
oauthProviders: s,
|
|
2222
|
+
isLocalDev: e
|
|
2101
2223
|
};
|
|
2102
2224
|
}
|
|
2103
|
-
const
|
|
2104
|
-
function
|
|
2225
|
+
const D = /* @__PURE__ */ new WeakMap();
|
|
2226
|
+
function Ot(t) {
|
|
2105
2227
|
if (!t)
|
|
2106
|
-
throw new
|
|
2228
|
+
throw new f(
|
|
2107
2229
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2108
2230
|
);
|
|
2109
2231
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2110
2232
|
if (!e && !s)
|
|
2111
|
-
throw new
|
|
2233
|
+
throw new f(
|
|
2112
2234
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2113
2235
|
);
|
|
2114
2236
|
if ("redirectTo" in t) {
|
|
2115
2237
|
const i = t.redirectTo;
|
|
2116
2238
|
if (!(typeof i == "string" || i instanceof URL))
|
|
2117
|
-
throw new
|
|
2239
|
+
throw new f(
|
|
2118
2240
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2119
2241
|
);
|
|
2120
2242
|
}
|
|
2121
2243
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2122
|
-
throw new
|
|
2244
|
+
throw new f(
|
|
2123
2245
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2124
2246
|
);
|
|
2125
2247
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2126
|
-
throw new
|
|
2248
|
+
throw new f(
|
|
2127
2249
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2128
2250
|
);
|
|
2251
|
+
if ("appearance" in t && t.appearance !== void 0) {
|
|
2252
|
+
const i = t.appearance;
|
|
2253
|
+
if (!i || typeof i != "object" || Array.isArray(i))
|
|
2254
|
+
throw new f(
|
|
2255
|
+
"authUI.mount(container, options) expected appearance to be an object."
|
|
2256
|
+
);
|
|
2257
|
+
if ("theme" in i && i.theme !== void 0 && !yt(i.theme))
|
|
2258
|
+
throw new f(
|
|
2259
|
+
`authUI.mount(container, options) expected appearance.theme to be one of: ${ke.join(", ")}.`
|
|
2260
|
+
);
|
|
2261
|
+
if ("className" in i && i.className !== void 0 && typeof i.className != "string")
|
|
2262
|
+
throw new f(
|
|
2263
|
+
"authUI.mount(container, options) expected appearance.className to be a string."
|
|
2264
|
+
);
|
|
2265
|
+
if ("variables" in i && i.variables !== void 0) {
|
|
2266
|
+
if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
|
|
2267
|
+
throw new f(
|
|
2268
|
+
"authUI.mount(container, options) expected appearance.variables to be an object."
|
|
2269
|
+
);
|
|
2270
|
+
for (const [n, a] of Object.entries(i.variables)) {
|
|
2271
|
+
if (!Et(n))
|
|
2272
|
+
throw new f(
|
|
2273
|
+
`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
|
|
2274
|
+
);
|
|
2275
|
+
if (a !== void 0 && typeof a != "string")
|
|
2276
|
+
throw new f(
|
|
2277
|
+
`authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2129
2282
|
}
|
|
2130
|
-
function
|
|
2283
|
+
function Dt(t) {
|
|
2131
2284
|
if (!(t instanceof HTMLElement))
|
|
2132
|
-
throw new
|
|
2285
|
+
throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2133
2286
|
}
|
|
2134
|
-
function
|
|
2287
|
+
function Nt(t, e) {
|
|
2135
2288
|
return {
|
|
2136
2289
|
mount(s, i) {
|
|
2137
|
-
var
|
|
2138
|
-
|
|
2139
|
-
const n = new
|
|
2290
|
+
var g;
|
|
2291
|
+
Ot(i), Dt(s), (g = D.get(s)) == null || g.destroy();
|
|
2292
|
+
const n = new It(s, t, i, Bt, e), a = n.destroy.bind(n), u = {
|
|
2140
2293
|
destroy() {
|
|
2141
|
-
a(),
|
|
2294
|
+
a(), D.get(s) === u && D.delete(s);
|
|
2142
2295
|
}
|
|
2143
2296
|
};
|
|
2144
|
-
return
|
|
2297
|
+
return D.set(s, u), u;
|
|
2145
2298
|
}
|
|
2146
2299
|
};
|
|
2147
2300
|
}
|
|
2148
|
-
function
|
|
2149
|
-
|
|
2150
|
-
const t =
|
|
2301
|
+
function Ft() {
|
|
2302
|
+
Pe();
|
|
2303
|
+
const t = lt(), e = dt(), s = Fe(), i = Nt(e, {
|
|
2151
2304
|
syncPublicSession: async () => {
|
|
2152
|
-
await
|
|
2305
|
+
await at(t);
|
|
2153
2306
|
}
|
|
2154
2307
|
});
|
|
2155
2308
|
return {
|
|
@@ -2159,14 +2312,21 @@ function _t() {
|
|
|
2159
2312
|
};
|
|
2160
2313
|
}
|
|
2161
2314
|
export {
|
|
2162
|
-
|
|
2163
|
-
|
|
2315
|
+
bt as AUTH_UI_APPEARANCE_VARIABLE,
|
|
2316
|
+
vt as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
|
|
2317
|
+
gt as AUTH_UI_DEFAULT_THEME,
|
|
2318
|
+
Ue as AUTH_UI_THEME,
|
|
2319
|
+
ke as AUTH_UI_THEMES,
|
|
2320
|
+
pt as AUTH_UI_THEME_DARK,
|
|
2321
|
+
$e as AUTH_UI_THEME_LIGHT,
|
|
2322
|
+
E as EdgeSparkAuthError,
|
|
2323
|
+
f as EdgeSparkConfigError,
|
|
2164
2324
|
te as EdgeSparkError,
|
|
2165
|
-
|
|
2325
|
+
Ee as EdgeSparkRuntimeError,
|
|
2166
2326
|
pe as ar,
|
|
2167
|
-
|
|
2327
|
+
Ft as createEdgeSpark,
|
|
2168
2328
|
me as de,
|
|
2169
|
-
|
|
2329
|
+
wt as detectLocale,
|
|
2170
2330
|
N as enUS,
|
|
2171
2331
|
x as es,
|
|
2172
2332
|
he as fr,
|
|
@@ -2176,5 +2336,5 @@ export {
|
|
|
2176
2336
|
ce as ko,
|
|
2177
2337
|
ue as ptBR,
|
|
2178
2338
|
we as ru,
|
|
2179
|
-
|
|
2339
|
+
q as zhCN
|
|
2180
2340
|
};
|