@edgespark/web 0.0.1-beta.6 → 0.0.1
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 +10 -0
- package/dist/auth/types.d.ts +23 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +2 -2
- package/dist/auth-ui/mount.d.ts +1 -4
- package/dist/client.d.ts +4 -0
- package/dist/errors.d.ts +9 -0
- package/dist/index.cjs +3 -3
- package/dist/index.es.js +370 -321
- package/package.json +8 -9
package/dist/index.es.js
CHANGED
|
@@ -1,60 +1,77 @@
|
|
|
1
|
-
import { createAuthClient as
|
|
2
|
-
class
|
|
1
|
+
import { createAuthClient as Be } from "better-auth/client";
|
|
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 p extends te {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
class Se extends
|
|
12
|
+
class Se extends te {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class v 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 Pe() {
|
|
22
|
+
function Pe(t, e = "Authentication failed.", s) {
|
|
23
|
+
if (t instanceof v)
|
|
24
|
+
return t;
|
|
25
|
+
if (typeof t == "object" && t !== null) {
|
|
26
|
+
const i = t;
|
|
27
|
+
return new v(i.message || e, {
|
|
28
|
+
code: i.code ?? s,
|
|
29
|
+
status: i.status,
|
|
30
|
+
cause: t
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return typeof t == "string" ? new v(t, { code: s }) : new v(e, { code: s, cause: t });
|
|
34
|
+
}
|
|
35
|
+
function Ee() {
|
|
23
36
|
if (typeof window > "u" || typeof document > "u")
|
|
24
37
|
throw new Se(
|
|
25
38
|
"@edgespark/web is browser-only. Create the client from a real browser runtime."
|
|
26
39
|
);
|
|
27
40
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
41
|
+
function X() {
|
|
42
|
+
return Ee(), window.location.origin;
|
|
30
43
|
}
|
|
31
|
-
function
|
|
44
|
+
function ke(t) {
|
|
32
45
|
return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
|
|
33
46
|
}
|
|
34
|
-
function
|
|
35
|
-
if (t.origin !==
|
|
36
|
-
throw new
|
|
37
|
-
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${
|
|
47
|
+
function Me(t) {
|
|
48
|
+
if (t.origin !== X())
|
|
49
|
+
throw new p(
|
|
50
|
+
`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${X()}.`
|
|
38
51
|
);
|
|
39
52
|
}
|
|
40
|
-
function
|
|
53
|
+
function Oe() {
|
|
41
54
|
return {
|
|
42
55
|
async fetch(t, e) {
|
|
43
|
-
const s =
|
|
44
|
-
return
|
|
56
|
+
const s = ke(t);
|
|
57
|
+
return Me(s), fetch(t, {
|
|
45
58
|
...e,
|
|
46
59
|
credentials: "include"
|
|
47
60
|
});
|
|
48
61
|
}
|
|
49
62
|
};
|
|
50
63
|
}
|
|
51
|
-
const
|
|
64
|
+
const Le = "/api/_es/auth", Ve = "edgespark-auth-session", _e = "__edgespark_auth_sync__", F = "__edgespark_auth_pending_sign_in__", Re = Symbol("edgespark.notifyAuthTabs"), Ne = 10 * 60 * 1e3, Fe = /* @__PURE__ */ new Set([
|
|
52
65
|
"signOut",
|
|
53
66
|
"revokeSession",
|
|
54
67
|
"revokeSessions",
|
|
55
68
|
"revokeOtherSessions"
|
|
69
|
+
]), ze = /* @__PURE__ */ new Map([
|
|
70
|
+
["changeEmail", "changeEmail() is not currently supported by EdgeSpark platform auth."],
|
|
71
|
+
["deleteUser", "deleteUser() is not currently supported by EdgeSpark platform auth."],
|
|
72
|
+
["deleteUserCallback", "deleteUserCallback() is not currently supported by EdgeSpark platform auth."]
|
|
56
73
|
]);
|
|
57
|
-
class
|
|
74
|
+
class De {
|
|
58
75
|
constructor(e) {
|
|
59
76
|
this.value = e;
|
|
60
77
|
}
|
|
@@ -62,32 +79,32 @@ class Ne {
|
|
|
62
79
|
return this.value;
|
|
63
80
|
}
|
|
64
81
|
}
|
|
65
|
-
const
|
|
66
|
-
let z,
|
|
67
|
-
const
|
|
68
|
-
|
|
82
|
+
const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
|
|
83
|
+
let z, oe = !1;
|
|
84
|
+
const $ = /* @__PURE__ */ new Map(), D = re ? new re((t) => {
|
|
85
|
+
$.delete(t);
|
|
69
86
|
}) : null;
|
|
70
|
-
function
|
|
71
|
-
return
|
|
72
|
-
baseURL:
|
|
73
|
-
basePath:
|
|
87
|
+
function Te(t) {
|
|
88
|
+
return Be({
|
|
89
|
+
baseURL: X(),
|
|
90
|
+
basePath: Le,
|
|
74
91
|
...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
|
|
75
92
|
fetchOptions: {
|
|
76
93
|
credentials: "include"
|
|
77
94
|
}
|
|
78
95
|
});
|
|
79
96
|
}
|
|
80
|
-
function
|
|
97
|
+
function U(t) {
|
|
81
98
|
var e, s;
|
|
82
99
|
return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
|
|
83
100
|
}
|
|
84
|
-
function
|
|
101
|
+
function qe(t) {
|
|
85
102
|
return JSON.stringify({
|
|
86
103
|
source: t,
|
|
87
104
|
timestamp: Date.now()
|
|
88
105
|
});
|
|
89
106
|
}
|
|
90
|
-
function
|
|
107
|
+
function He(t) {
|
|
91
108
|
if (typeof t != "string")
|
|
92
109
|
return null;
|
|
93
110
|
try {
|
|
@@ -97,59 +114,70 @@ function ze(t) {
|
|
|
97
114
|
return null;
|
|
98
115
|
}
|
|
99
116
|
}
|
|
100
|
-
|
|
117
|
+
function je(t) {
|
|
118
|
+
return t.join(".");
|
|
119
|
+
}
|
|
120
|
+
function xe(t) {
|
|
121
|
+
const e = je(t), s = ze.get(e);
|
|
122
|
+
return s ? new v(s, {
|
|
123
|
+
code: "UNSUPPORTED_AUTH_METHOD"
|
|
124
|
+
}) : null;
|
|
125
|
+
}
|
|
126
|
+
async function ee(t) {
|
|
101
127
|
var e;
|
|
102
128
|
try {
|
|
103
|
-
return await ((e =
|
|
129
|
+
return await ((e = U(t)) == null ? void 0 : e.get().refetch()), !0;
|
|
104
130
|
} catch {
|
|
105
131
|
return !1;
|
|
106
132
|
}
|
|
107
133
|
}
|
|
108
|
-
function
|
|
109
|
-
return z === void 0 && (z = typeof BroadcastChannel < "u" ? new BroadcastChannel(
|
|
134
|
+
function Ie() {
|
|
135
|
+
return z === void 0 && (z = typeof BroadcastChannel < "u" ? new BroadcastChannel(Ve) : null), z;
|
|
110
136
|
}
|
|
111
|
-
function
|
|
112
|
-
const e =
|
|
137
|
+
function ae(t) {
|
|
138
|
+
const e = He(t);
|
|
113
139
|
if (e)
|
|
114
|
-
for (const [s, i] of
|
|
140
|
+
for (const [s, i] of $) {
|
|
115
141
|
if (s === e.source)
|
|
116
142
|
continue;
|
|
117
143
|
const n = i.deref();
|
|
118
144
|
if (!n) {
|
|
119
|
-
|
|
145
|
+
$.delete(s);
|
|
120
146
|
continue;
|
|
121
147
|
}
|
|
122
|
-
|
|
148
|
+
ee(n);
|
|
123
149
|
}
|
|
124
150
|
}
|
|
125
|
-
function
|
|
151
|
+
function We() {
|
|
126
152
|
var t;
|
|
127
|
-
|
|
128
|
-
|
|
153
|
+
oe || (oe = !0, (t = Ie()) == null || t.addEventListener("message", (e) => {
|
|
154
|
+
ae(e.data);
|
|
129
155
|
}), typeof window < "u" && window.addEventListener("storage", (e) => {
|
|
130
|
-
e.key !==
|
|
156
|
+
e.key !== _e || e.newValue === null || ae(e.newValue);
|
|
131
157
|
}));
|
|
132
158
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
159
|
+
function Ge(t, e) {
|
|
160
|
+
ne ? $.set(t, new ne(e)) : ($.clear(), $.set(t, new De(e))), D == null || D.register(e, t), We();
|
|
135
161
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
function C(t) {
|
|
163
|
+
const e = qe(t), s = Ie();
|
|
164
|
+
let i = !1;
|
|
165
|
+
if (s)
|
|
166
|
+
try {
|
|
167
|
+
s.postMessage(e), i = !0;
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
if (!i)
|
|
171
|
+
try {
|
|
172
|
+
window.localStorage.setItem(_e, e);
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
147
175
|
}
|
|
148
176
|
function q(t) {
|
|
149
177
|
if (!(typeof window > "u"))
|
|
150
178
|
try {
|
|
151
179
|
window.sessionStorage.setItem(
|
|
152
|
-
|
|
180
|
+
F,
|
|
153
181
|
JSON.stringify({
|
|
154
182
|
path: t,
|
|
155
183
|
createdAt: Date.now()
|
|
@@ -158,263 +186,287 @@ function q(t) {
|
|
|
158
186
|
} catch {
|
|
159
187
|
}
|
|
160
188
|
}
|
|
161
|
-
function
|
|
189
|
+
function A() {
|
|
162
190
|
if (!(typeof window > "u"))
|
|
163
191
|
try {
|
|
164
|
-
window.sessionStorage.removeItem(
|
|
192
|
+
window.sessionStorage.removeItem(F);
|
|
165
193
|
} catch {
|
|
166
194
|
}
|
|
167
195
|
}
|
|
168
|
-
function
|
|
196
|
+
function Ke(t) {
|
|
169
197
|
return !!(t != null && t.session && (t != null && t.user));
|
|
170
198
|
}
|
|
171
|
-
function
|
|
199
|
+
function h(t) {
|
|
200
|
+
return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
|
|
201
|
+
}
|
|
202
|
+
function Ye(t) {
|
|
203
|
+
return t ? JSON.stringify({
|
|
204
|
+
session: {
|
|
205
|
+
createdAt: h(t.session.createdAt),
|
|
206
|
+
expiresAt: h(t.session.expiresAt),
|
|
207
|
+
id: h(t.session.id),
|
|
208
|
+
impersonatedBy: h(t.session.impersonatedBy),
|
|
209
|
+
ipAddress: h(t.session.ipAddress),
|
|
210
|
+
token: h(t.session.token),
|
|
211
|
+
updatedAt: h(t.session.updatedAt),
|
|
212
|
+
userAgent: h(t.session.userAgent),
|
|
213
|
+
userId: h(t.session.userId)
|
|
214
|
+
},
|
|
215
|
+
user: {
|
|
216
|
+
banExpires: h(t.user.banExpires),
|
|
217
|
+
banReason: h(t.user.banReason),
|
|
218
|
+
banned: h(t.user.banned),
|
|
219
|
+
createdAt: h(t.user.createdAt),
|
|
220
|
+
email: h(t.user.email),
|
|
221
|
+
emailVerified: h(t.user.emailVerified),
|
|
222
|
+
id: h(t.user.id),
|
|
223
|
+
image: h(t.user.image),
|
|
224
|
+
lastLoginAt: h(t.user.lastLoginAt),
|
|
225
|
+
name: h(t.user.name),
|
|
226
|
+
role: h(t.user.role),
|
|
227
|
+
updatedAt: h(t.user.updatedAt)
|
|
228
|
+
}
|
|
229
|
+
}) : "__null__";
|
|
230
|
+
}
|
|
231
|
+
function Ce() {
|
|
172
232
|
if (typeof window > "u")
|
|
173
|
-
return
|
|
233
|
+
return null;
|
|
174
234
|
try {
|
|
175
|
-
const t = window.sessionStorage.getItem(
|
|
235
|
+
const t = window.sessionStorage.getItem(F);
|
|
176
236
|
if (!t)
|
|
177
|
-
return
|
|
178
|
-
window.sessionStorage.removeItem(S);
|
|
237
|
+
return null;
|
|
179
238
|
const e = JSON.parse(t);
|
|
180
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number"
|
|
239
|
+
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ne ? null : { createdAt: e.createdAt };
|
|
181
240
|
} catch {
|
|
182
|
-
return
|
|
241
|
+
return null;
|
|
183
242
|
}
|
|
184
243
|
}
|
|
185
|
-
function
|
|
186
|
-
if (
|
|
244
|
+
function le() {
|
|
245
|
+
if (!Ce())
|
|
187
246
|
return !1;
|
|
188
247
|
try {
|
|
189
|
-
|
|
190
|
-
if (!t)
|
|
191
|
-
return !1;
|
|
192
|
-
const e = JSON.parse(t);
|
|
193
|
-
return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ie ? (window.sessionStorage.removeItem(S), !1) : !0;
|
|
248
|
+
window.sessionStorage.removeItem(F);
|
|
194
249
|
} catch {
|
|
195
|
-
return !1;
|
|
196
250
|
}
|
|
251
|
+
return !0;
|
|
197
252
|
}
|
|
198
|
-
function
|
|
253
|
+
function Je() {
|
|
254
|
+
return Ce() !== null;
|
|
255
|
+
}
|
|
256
|
+
function Ze(t) {
|
|
199
257
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
200
258
|
return !1;
|
|
201
259
|
const e = "data" in t ? t.data : t;
|
|
202
260
|
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;
|
|
203
261
|
}
|
|
204
|
-
function
|
|
262
|
+
function Qe(t) {
|
|
205
263
|
if (!(t && typeof t == "object") || "error" in t && t.error)
|
|
206
264
|
return !1;
|
|
207
265
|
const e = "data" in t ? t.data : t;
|
|
208
266
|
return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
|
|
209
267
|
}
|
|
210
|
-
function
|
|
211
|
-
if (
|
|
268
|
+
function Xe(t) {
|
|
269
|
+
if (L(t) || !(t && typeof t == "object"))
|
|
212
270
|
return !1;
|
|
213
271
|
const e = "data" in t ? t.data : t;
|
|
214
272
|
return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
|
|
215
273
|
}
|
|
216
|
-
function
|
|
274
|
+
function et(t, e) {
|
|
217
275
|
if (t.length !== 1 || t[0] !== "changePassword")
|
|
218
276
|
return !1;
|
|
219
277
|
const [s] = e;
|
|
220
278
|
return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
|
|
221
279
|
}
|
|
222
|
-
function
|
|
280
|
+
function L(t) {
|
|
223
281
|
return !!(t && typeof t == "object" && "error" in t && t.error);
|
|
224
282
|
}
|
|
225
|
-
function
|
|
226
|
-
if (
|
|
283
|
+
function tt(t) {
|
|
284
|
+
if (L(t) || !(t && typeof t == "object"))
|
|
227
285
|
return !1;
|
|
228
286
|
const e = "data" in t ? t.data : t;
|
|
229
287
|
return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
|
|
230
288
|
}
|
|
231
|
-
function
|
|
289
|
+
function st(t) {
|
|
232
290
|
return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
|
|
233
291
|
}
|
|
234
292
|
function H(t) {
|
|
235
|
-
|
|
236
|
-
return t;
|
|
237
|
-
const e = t;
|
|
238
|
-
return new y(
|
|
239
|
-
(e == null ? void 0 : e.message) || "Failed to load the current session.",
|
|
240
|
-
{
|
|
241
|
-
code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
|
|
242
|
-
cause: t,
|
|
243
|
-
status: e == null ? void 0 : e.status
|
|
244
|
-
}
|
|
245
|
-
);
|
|
293
|
+
return Pe(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
|
|
246
294
|
}
|
|
247
|
-
async function
|
|
295
|
+
async function it(t) {
|
|
248
296
|
var s, i;
|
|
249
297
|
let e = null;
|
|
250
298
|
try {
|
|
251
|
-
await ((s =
|
|
299
|
+
await ((s = U(t)) == null ? void 0 : s.get().refetch());
|
|
252
300
|
} catch (n) {
|
|
253
301
|
e = n;
|
|
254
302
|
} finally {
|
|
255
|
-
(i = t[
|
|
303
|
+
(i = t[Re]) == null || i.call(t);
|
|
256
304
|
}
|
|
257
305
|
if (e)
|
|
258
306
|
throw e;
|
|
259
307
|
}
|
|
260
|
-
function
|
|
261
|
-
const t =
|
|
262
|
-
|
|
308
|
+
function nt() {
|
|
309
|
+
const t = Te(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
310
|
+
Ge(e, t);
|
|
263
311
|
const s = 2, i = 500;
|
|
264
|
-
let n = null, a = !1,
|
|
265
|
-
const
|
|
312
|
+
let n = null, a = !1, m;
|
|
313
|
+
const b = (o) => (m = o, o), _ = () => {
|
|
266
314
|
var c;
|
|
267
|
-
const o = (c =
|
|
268
|
-
return o != null && o.error && !o.data &&
|
|
269
|
-
},
|
|
270
|
-
var l, u,
|
|
315
|
+
const o = (c = U(t)) == null ? void 0 : c.get();
|
|
316
|
+
return o != null && o.error && !o.data && m !== void 0 ? m : (o == null ? void 0 : o.data) ?? m ?? null;
|
|
317
|
+
}, R = () => a ? Promise.resolve(_()) : (n || (n = (async () => {
|
|
318
|
+
var l, u, y;
|
|
271
319
|
let o = !1, c = null;
|
|
272
320
|
try {
|
|
273
|
-
for (let
|
|
321
|
+
for (let g = 0; g <= s; g++) {
|
|
274
322
|
let d = null;
|
|
275
323
|
try {
|
|
276
324
|
d = await t.getSession();
|
|
277
|
-
} catch (
|
|
278
|
-
c =
|
|
325
|
+
} catch (S) {
|
|
326
|
+
c = S;
|
|
279
327
|
}
|
|
280
|
-
const
|
|
281
|
-
if ((u = d == null ? void 0 : d.data) != null && u.session && ((
|
|
282
|
-
return a = !0,
|
|
283
|
-
if (
|
|
284
|
-
return a = !0,
|
|
285
|
-
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error &&
|
|
328
|
+
const w = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
|
|
329
|
+
if ((u = d == null ? void 0 : d.data) != null && u.session && ((y = d.data) != null && y.user))
|
|
330
|
+
return a = !0, le() && C(e), b(d.data);
|
|
331
|
+
if (w != null && w.session && (w != null && w.user))
|
|
332
|
+
return a = !0, le() && C(e), b(w);
|
|
333
|
+
if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && Je() && g < s) {
|
|
286
334
|
await new Promise(
|
|
287
|
-
(
|
|
335
|
+
(S) => setTimeout(S, i)
|
|
288
336
|
);
|
|
289
337
|
continue;
|
|
290
338
|
}
|
|
291
339
|
if (d && !d.error) {
|
|
292
|
-
const
|
|
293
|
-
return a = !0,
|
|
340
|
+
const S = _();
|
|
341
|
+
return a = !0, b(S);
|
|
294
342
|
}
|
|
295
|
-
|
|
296
|
-
(
|
|
343
|
+
g < s && await new Promise(
|
|
344
|
+
(S) => setTimeout(S, i)
|
|
297
345
|
);
|
|
298
346
|
}
|
|
299
347
|
if (!o)
|
|
300
|
-
throw n = null, new
|
|
348
|
+
throw n = null, new v("Failed to load the current session.", {
|
|
301
349
|
code: "SESSION_LOOKUP_FAILED",
|
|
302
350
|
cause: c
|
|
303
351
|
});
|
|
304
|
-
const f =
|
|
305
|
-
return a = !0,
|
|
352
|
+
const f = _();
|
|
353
|
+
return a = !0, b(f);
|
|
306
354
|
} catch (f) {
|
|
307
355
|
throw n = null, H(f);
|
|
308
356
|
}
|
|
309
357
|
})()), n);
|
|
310
|
-
|
|
358
|
+
R().catch(() => {
|
|
311
359
|
});
|
|
312
|
-
const
|
|
360
|
+
const T = async () => {
|
|
313
361
|
var o, c;
|
|
314
362
|
try {
|
|
315
363
|
const l = await t.getSession();
|
|
316
364
|
if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
|
|
317
365
|
return l.data;
|
|
318
|
-
throw l.error ? H(l.error) : new
|
|
366
|
+
throw l.error ? H(l.error) : new v("No authenticated session is available.", {
|
|
319
367
|
code: "UNAUTHENTICATED"
|
|
320
368
|
});
|
|
321
369
|
} catch (l) {
|
|
322
370
|
throw H(l);
|
|
323
371
|
}
|
|
324
|
-
},
|
|
325
|
-
await
|
|
326
|
-
},
|
|
372
|
+
}, I = async () => {
|
|
373
|
+
await ee(t), C(e);
|
|
374
|
+
}, Ae = async () => {
|
|
327
375
|
var l;
|
|
328
|
-
const o = await
|
|
329
|
-
|
|
330
|
-
},
|
|
376
|
+
const o = await ee(t), c = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
|
|
377
|
+
Ke(c) ? (A(), C(e)) : o || C(e);
|
|
378
|
+
}, Ue = (o) => {
|
|
331
379
|
let c = !1, l = !1, u;
|
|
332
|
-
const
|
|
333
|
-
|
|
380
|
+
const y = (d) => {
|
|
381
|
+
const w = Ye(d);
|
|
382
|
+
w !== u && (u = w, o(d));
|
|
334
383
|
};
|
|
335
|
-
|
|
336
|
-
c || (l = !0,
|
|
384
|
+
R().then((d) => {
|
|
385
|
+
c || (l = !0, y(b(d)));
|
|
337
386
|
}).catch(() => {
|
|
338
387
|
c || (l = !0);
|
|
339
388
|
});
|
|
340
|
-
const f =
|
|
389
|
+
const f = U(t);
|
|
341
390
|
if (!f)
|
|
342
391
|
return () => {
|
|
343
392
|
c = !0;
|
|
344
393
|
};
|
|
345
|
-
const
|
|
394
|
+
const g = f.subscribe((d) => {
|
|
346
395
|
if (c || !l || d.error && !d.data)
|
|
347
396
|
return;
|
|
348
|
-
const
|
|
349
|
-
|
|
397
|
+
const w = d.data ?? null;
|
|
398
|
+
y(b(w));
|
|
350
399
|
});
|
|
351
400
|
return () => {
|
|
352
|
-
c = !0,
|
|
401
|
+
c = !0, g();
|
|
353
402
|
};
|
|
354
403
|
}, $e = async (o, c, l) => {
|
|
355
|
-
const u = o[0],
|
|
356
|
-
return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? (
|
|
357
|
-
},
|
|
404
|
+
const u = o[0], y = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail", f = o.length >= 2 && u === "emailOtp" && o[1] === "resetPassword", g = o.length >= 2 && u === "resetPassword" && o[1] === "emailOtp";
|
|
405
|
+
return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? (A(), tt(l) && await I(), l) : o.length === 1 && u && Fe.has(u) ? (A(), L(l) || await I(), l) : et(o, c) && !L(l) ? (A(), await I(), l) : (f || g) && !L(l) ? (A(), await I(), l) : o.length === 1 && u === "changeEmail" && !L(l) ? (await I(), l) : ((u === "signIn" || u === "signUp" || y) && Ze(l) ? (A(), await I()) : (u === "signIn" || u === "signUp") && Qe(l) || u === "signUp" && Xe(l) ? q(o) : u === "verifyEmail" && !L(l) && (q(o), await Ae()), l);
|
|
406
|
+
}, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
|
|
358
407
|
if (!o || typeof o != "object" && typeof o != "function")
|
|
359
408
|
return o;
|
|
360
|
-
const l =
|
|
409
|
+
const l = se.get(o);
|
|
361
410
|
if (l)
|
|
362
411
|
return l;
|
|
363
412
|
const u = new Proxy(o, {
|
|
364
|
-
get(
|
|
413
|
+
get(y, f, g) {
|
|
365
414
|
if (c.length === 0) {
|
|
366
415
|
if (f === "requireSession")
|
|
367
|
-
return
|
|
416
|
+
return T;
|
|
368
417
|
if (f === "onSessionChange")
|
|
369
|
-
return
|
|
370
|
-
if (f ===
|
|
418
|
+
return Ue;
|
|
419
|
+
if (f === Re)
|
|
371
420
|
return () => {
|
|
372
|
-
|
|
421
|
+
C(e);
|
|
373
422
|
};
|
|
374
423
|
}
|
|
375
|
-
const d = Reflect.get(
|
|
376
|
-
return typeof f != "string" ? d :
|
|
424
|
+
const d = Reflect.get(y, f, g);
|
|
425
|
+
return typeof f != "string" ? d : ie(d, [...c, f]);
|
|
377
426
|
},
|
|
378
|
-
apply(
|
|
379
|
-
const d =
|
|
380
|
-
|
|
427
|
+
apply(y, f, g) {
|
|
428
|
+
const d = xe(c);
|
|
429
|
+
if (d)
|
|
430
|
+
throw d;
|
|
431
|
+
const w = Reflect.apply(
|
|
432
|
+
y,
|
|
381
433
|
f,
|
|
382
|
-
|
|
434
|
+
g
|
|
383
435
|
);
|
|
384
|
-
return
|
|
385
|
-
(
|
|
386
|
-
) :
|
|
436
|
+
return st(w) ? Promise.resolve(w).then(
|
|
437
|
+
(S) => $e(c, g, S)
|
|
438
|
+
) : w;
|
|
387
439
|
}
|
|
388
440
|
});
|
|
389
|
-
return
|
|
441
|
+
return se.set(o, u), u;
|
|
390
442
|
};
|
|
391
|
-
return
|
|
443
|
+
return ie(t, []);
|
|
392
444
|
}
|
|
393
|
-
function
|
|
394
|
-
return
|
|
445
|
+
function rt() {
|
|
446
|
+
return Te({ disableDefaultRedirectPlugin: !0 });
|
|
395
447
|
}
|
|
396
|
-
function
|
|
448
|
+
function ot(t) {
|
|
397
449
|
const e = (() => {
|
|
398
450
|
if (t instanceof URL)
|
|
399
451
|
return t;
|
|
400
452
|
const s = t.trim();
|
|
401
453
|
if (!s)
|
|
402
|
-
throw new
|
|
454
|
+
throw new p("redirectTo must not be an empty string.");
|
|
403
455
|
try {
|
|
404
456
|
return new URL(s, window.location.href);
|
|
405
457
|
} catch {
|
|
406
|
-
throw new
|
|
458
|
+
throw new p(
|
|
407
459
|
`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
|
|
408
460
|
);
|
|
409
461
|
}
|
|
410
462
|
})();
|
|
411
463
|
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
412
|
-
throw new
|
|
464
|
+
throw new p(
|
|
413
465
|
`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
|
|
414
466
|
);
|
|
415
467
|
return e;
|
|
416
468
|
}
|
|
417
|
-
function
|
|
469
|
+
function at(t, e) {
|
|
418
470
|
return e ? {
|
|
419
471
|
common: { ...t.common, ...e.common },
|
|
420
472
|
signIn: { ...t.signIn, ...e.signIn },
|
|
@@ -426,7 +478,7 @@ function et(t, e) {
|
|
|
426
478
|
errors: { ...t.errors, ...e.errors }
|
|
427
479
|
} : t;
|
|
428
480
|
}
|
|
429
|
-
const
|
|
481
|
+
const N = {
|
|
430
482
|
common: {
|
|
431
483
|
loading: "Loading sign-in…",
|
|
432
484
|
redirecting: "Redirecting…",
|
|
@@ -552,7 +604,7 @@ const F = {
|
|
|
552
604
|
invalidCode: "请输入 6 位验证码",
|
|
553
605
|
generic: "出现错误,请稍后重试"
|
|
554
606
|
}
|
|
555
|
-
},
|
|
607
|
+
}, de = {
|
|
556
608
|
common: {
|
|
557
609
|
loading: "サインインを読み込み中…",
|
|
558
610
|
redirecting: "リダイレクト中…",
|
|
@@ -615,7 +667,7 @@ const F = {
|
|
|
615
667
|
invalidCode: "6桁の認証コードを入力してください",
|
|
616
668
|
generic: "エラーが発生しました。もう一度お試しください"
|
|
617
669
|
}
|
|
618
|
-
},
|
|
670
|
+
}, ce = {
|
|
619
671
|
common: {
|
|
620
672
|
loading: "로그인 로딩 중…",
|
|
621
673
|
redirecting: "리디렉션 중…",
|
|
@@ -741,7 +793,7 @@ const F = {
|
|
|
741
793
|
invalidCode: "Ingresa el código de verificación de 6 dígitos.",
|
|
742
794
|
generic: "Algo salió mal. Por favor, inténtalo de nuevo."
|
|
743
795
|
}
|
|
744
|
-
},
|
|
796
|
+
}, ue = {
|
|
745
797
|
common: {
|
|
746
798
|
loading: "Carregando login…",
|
|
747
799
|
redirecting: "Redirecionando…",
|
|
@@ -804,7 +856,7 @@ const F = {
|
|
|
804
856
|
invalidCode: "Insira o código de verificação de 6 dígitos.",
|
|
805
857
|
generic: "Algo deu errado. Por favor, tente novamente."
|
|
806
858
|
}
|
|
807
|
-
},
|
|
859
|
+
}, he = {
|
|
808
860
|
common: {
|
|
809
861
|
loading: "Chargement de la connexion…",
|
|
810
862
|
redirecting: "Redirection…",
|
|
@@ -867,7 +919,7 @@ const F = {
|
|
|
867
919
|
invalidCode: "Saisissez le code de vérification à 6 chiffres.",
|
|
868
920
|
generic: "Une erreur est survenue. Veuillez réessayer."
|
|
869
921
|
}
|
|
870
|
-
},
|
|
922
|
+
}, me = {
|
|
871
923
|
common: {
|
|
872
924
|
loading: "Anmeldung wird geladen…",
|
|
873
925
|
redirecting: "Weiterleitung…",
|
|
@@ -930,7 +982,7 @@ const F = {
|
|
|
930
982
|
invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
|
|
931
983
|
generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
|
|
932
984
|
}
|
|
933
|
-
},
|
|
985
|
+
}, fe = {
|
|
934
986
|
common: {
|
|
935
987
|
loading: "Caricamento accesso…",
|
|
936
988
|
redirecting: "Reindirizzamento…",
|
|
@@ -993,7 +1045,7 @@ const F = {
|
|
|
993
1045
|
invalidCode: "Inserisci il codice di verifica a 6 cifre.",
|
|
994
1046
|
generic: "Qualcosa è andato storto. Riprova."
|
|
995
1047
|
}
|
|
996
|
-
},
|
|
1048
|
+
}, we = {
|
|
997
1049
|
common: {
|
|
998
1050
|
loading: "Загрузка входа…",
|
|
999
1051
|
redirecting: "Перенаправление…",
|
|
@@ -1056,7 +1108,7 @@ const F = {
|
|
|
1056
1108
|
invalidCode: "Введите 6-значный код подтверждения.",
|
|
1057
1109
|
generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
|
|
1058
1110
|
}
|
|
1059
|
-
},
|
|
1111
|
+
}, pe = {
|
|
1060
1112
|
common: {
|
|
1061
1113
|
loading: "جارٍ تحميل تسجيل الدخول…",
|
|
1062
1114
|
redirecting: "جارٍ إعادة التوجيه…",
|
|
@@ -1182,62 +1234,52 @@ const F = {
|
|
|
1182
1234
|
invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
|
|
1183
1235
|
generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
|
|
1184
1236
|
}
|
|
1185
|
-
},
|
|
1186
|
-
en:
|
|
1187
|
-
"en-US":
|
|
1237
|
+
}, be = {
|
|
1238
|
+
en: N,
|
|
1239
|
+
"en-US": N,
|
|
1188
1240
|
zh: j,
|
|
1189
1241
|
"zh-CN": j,
|
|
1190
1242
|
"zh-TW": j,
|
|
1191
|
-
ja:
|
|
1192
|
-
"ja-JP":
|
|
1193
|
-
ko:
|
|
1194
|
-
"ko-KR":
|
|
1243
|
+
ja: de,
|
|
1244
|
+
"ja-JP": de,
|
|
1245
|
+
ko: ce,
|
|
1246
|
+
"ko-KR": ce,
|
|
1195
1247
|
es: x,
|
|
1196
1248
|
"es-ES": x,
|
|
1197
1249
|
"es-MX": x,
|
|
1198
|
-
pt:
|
|
1199
|
-
"pt-BR":
|
|
1200
|
-
fr:
|
|
1201
|
-
"fr-FR":
|
|
1202
|
-
de:
|
|
1203
|
-
"de-DE":
|
|
1204
|
-
it:
|
|
1205
|
-
"it-IT":
|
|
1206
|
-
ru:
|
|
1207
|
-
"ru-RU":
|
|
1208
|
-
ar:
|
|
1209
|
-
"ar-SA":
|
|
1250
|
+
pt: ue,
|
|
1251
|
+
"pt-BR": ue,
|
|
1252
|
+
fr: he,
|
|
1253
|
+
"fr-FR": he,
|
|
1254
|
+
de: me,
|
|
1255
|
+
"de-DE": me,
|
|
1256
|
+
it: fe,
|
|
1257
|
+
"it-IT": fe,
|
|
1258
|
+
ru: we,
|
|
1259
|
+
"ru-RU": we,
|
|
1260
|
+
ar: pe,
|
|
1261
|
+
"ar-SA": pe,
|
|
1210
1262
|
hi: ge,
|
|
1211
1263
|
"hi-IN": ge
|
|
1212
1264
|
};
|
|
1213
|
-
function
|
|
1265
|
+
function lt() {
|
|
1214
1266
|
if (typeof navigator > "u")
|
|
1215
|
-
return
|
|
1267
|
+
return N;
|
|
1216
1268
|
const t = navigator.languages ?? [navigator.language];
|
|
1217
1269
|
for (const e of t) {
|
|
1218
|
-
const s =
|
|
1270
|
+
const s = be[e] ?? be[e.split("-")[0]];
|
|
1219
1271
|
if (s) return s;
|
|
1220
1272
|
}
|
|
1221
|
-
return
|
|
1273
|
+
return N;
|
|
1222
1274
|
}
|
|
1223
1275
|
function W(t, e = "Authentication failed.") {
|
|
1224
|
-
|
|
1225
|
-
return t;
|
|
1226
|
-
if (typeof t == "object" && t !== null) {
|
|
1227
|
-
const s = t;
|
|
1228
|
-
return new y(s.message || e, {
|
|
1229
|
-
code: s.code,
|
|
1230
|
-
status: s.status,
|
|
1231
|
-
cause: t
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
return typeof t == "string" ? new y(t) : new y(e, { cause: t });
|
|
1276
|
+
return Pe(t, e);
|
|
1235
1277
|
}
|
|
1236
1278
|
async function k(t) {
|
|
1237
1279
|
var s, i;
|
|
1238
1280
|
const e = await t.getSession();
|
|
1239
1281
|
if (e.error)
|
|
1240
|
-
throw new
|
|
1282
|
+
throw new v(
|
|
1241
1283
|
e.error.message || "Failed to load the current session.",
|
|
1242
1284
|
{
|
|
1243
1285
|
code: e.error.code ?? "SESSION_LOOKUP_FAILED",
|
|
@@ -1253,7 +1295,13 @@ async function k(t) {
|
|
|
1253
1295
|
session: null
|
|
1254
1296
|
};
|
|
1255
1297
|
}
|
|
1256
|
-
const
|
|
1298
|
+
const dt = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion", M = "es_auth_email", K = "oauth", B = "verify-sign-in", P = "verify-sign-up", ye = 200, Y = 2, ct = {
|
|
1299
|
+
"&": "&",
|
|
1300
|
+
"<": "<",
|
|
1301
|
+
">": ">",
|
|
1302
|
+
'"': """,
|
|
1303
|
+
"'": "'"
|
|
1304
|
+
}, J = {
|
|
1257
1305
|
google: "Google",
|
|
1258
1306
|
apple: "Apple",
|
|
1259
1307
|
microsoft: "Microsoft",
|
|
@@ -1261,27 +1309,27 @@ const st = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion"
|
|
|
1261
1309
|
gitlab: "GitLab",
|
|
1262
1310
|
discord: "Discord"
|
|
1263
1311
|
};
|
|
1264
|
-
function
|
|
1312
|
+
function E(t) {
|
|
1265
1313
|
return "redirectTo" in t;
|
|
1266
1314
|
}
|
|
1267
|
-
function
|
|
1315
|
+
function Z(t) {
|
|
1268
1316
|
return "onSuccess" in t && !("redirectTo" in t);
|
|
1269
1317
|
}
|
|
1270
|
-
function
|
|
1318
|
+
function Q(t) {
|
|
1271
1319
|
return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
|
|
1272
1320
|
}
|
|
1273
|
-
function
|
|
1321
|
+
function ut(t) {
|
|
1274
1322
|
return /^\d{6}$/.test(t.trim());
|
|
1275
1323
|
}
|
|
1276
|
-
function
|
|
1324
|
+
function ht(t) {
|
|
1277
1325
|
return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
|
|
1278
1326
|
}
|
|
1279
|
-
function
|
|
1327
|
+
function mt(t) {
|
|
1280
1328
|
return !!(t.error || t.errorDescription);
|
|
1281
1329
|
}
|
|
1282
|
-
class
|
|
1330
|
+
class ft {
|
|
1283
1331
|
constructor(e, s, i, n, a) {
|
|
1284
|
-
|
|
1332
|
+
this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
|
|
1285
1333
|
view: "loading",
|
|
1286
1334
|
busy: !0,
|
|
1287
1335
|
busyLabel: void 0,
|
|
@@ -1293,9 +1341,7 @@ class ot {
|
|
|
1293
1341
|
confirmPassword: "",
|
|
1294
1342
|
code: "",
|
|
1295
1343
|
newPassword: ""
|
|
1296
|
-
}, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null,
|
|
1297
|
-
throw new m("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
1298
|
-
this.labels = et(tt(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(st, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
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, this.labels = at(lt(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(dt, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
|
|
1299
1345
|
}
|
|
1300
1346
|
destroy() {
|
|
1301
1347
|
this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
|
|
@@ -1310,7 +1356,7 @@ class ot {
|
|
|
1310
1356
|
if (this.destroyed)
|
|
1311
1357
|
return;
|
|
1312
1358
|
if (i.status === "rejected") {
|
|
1313
|
-
if (e.marker && !
|
|
1359
|
+
if (e.marker && !mt(e) && E(this.options)) {
|
|
1314
1360
|
this.redirectAfterManagedReturnLookupFailure();
|
|
1315
1361
|
return;
|
|
1316
1362
|
}
|
|
@@ -1318,17 +1364,17 @@ class ot {
|
|
|
1318
1364
|
const a = i.value;
|
|
1319
1365
|
if (a.user && a.session) {
|
|
1320
1366
|
switch (e.marker) {
|
|
1321
|
-
case
|
|
1322
|
-
case
|
|
1367
|
+
case K:
|
|
1368
|
+
case B:
|
|
1323
1369
|
await this.completeAuth("sign-in", a);
|
|
1324
1370
|
return;
|
|
1325
|
-
case
|
|
1371
|
+
case P:
|
|
1326
1372
|
await this.completeAuth("sign-up", a);
|
|
1327
1373
|
return;
|
|
1328
1374
|
default:
|
|
1329
1375
|
break;
|
|
1330
1376
|
}
|
|
1331
|
-
this.handleExistingSessionOnMount(
|
|
1377
|
+
this.handleExistingSessionOnMount();
|
|
1332
1378
|
return;
|
|
1333
1379
|
}
|
|
1334
1380
|
}
|
|
@@ -1345,7 +1391,10 @@ class ot {
|
|
|
1345
1391
|
}
|
|
1346
1392
|
}
|
|
1347
1393
|
redirectAfterManagedReturnLookupFailure() {
|
|
1348
|
-
|
|
1394
|
+
E(this.options) && this.navigateToRedirect();
|
|
1395
|
+
}
|
|
1396
|
+
navigateToRedirect() {
|
|
1397
|
+
E(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(ot(this.options.redirectTo).toString()));
|
|
1349
1398
|
}
|
|
1350
1399
|
async readMountSession(e) {
|
|
1351
1400
|
if (!e.marker)
|
|
@@ -1568,7 +1617,7 @@ class ot {
|
|
|
1568
1617
|
<div class="${r}__stack">
|
|
1569
1618
|
${e.map((i) => `
|
|
1570
1619
|
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
|
|
1571
|
-
${this.escape(`${this.labels.oauth.continueWith} ${
|
|
1620
|
+
${this.escape(`${this.labels.oauth.continueWith} ${J[i]}`)}
|
|
1572
1621
|
</button>
|
|
1573
1622
|
`).join("")}
|
|
1574
1623
|
</div>
|
|
@@ -1593,12 +1642,12 @@ class ot {
|
|
|
1593
1642
|
this.root.querySelectorAll("form[data-view]").forEach((n) => {
|
|
1594
1643
|
n.addEventListener("submit", (a) => {
|
|
1595
1644
|
a.preventDefault();
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1645
|
+
const m = n.dataset.view;
|
|
1646
|
+
m === "sign-in" && this.handleSignIn(), m === "sign-up" && this.handleSignUp(), m === "forgot-password" && this.handleForgotPassword(), m === "reset-password" && this.handleResetPassword();
|
|
1598
1647
|
});
|
|
1599
1648
|
}), this.root.querySelectorAll("input[name]").forEach((n) => {
|
|
1600
1649
|
n.addEventListener("input", () => {
|
|
1601
|
-
|
|
1650
|
+
ht(n.name) && (this.state[n.name] = n.value);
|
|
1602
1651
|
});
|
|
1603
1652
|
}), this.root.querySelectorAll("[data-action]").forEach((n) => {
|
|
1604
1653
|
n.addEventListener("click", () => {
|
|
@@ -1611,7 +1660,7 @@ class ot {
|
|
|
1611
1660
|
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();
|
|
1612
1661
|
}
|
|
1613
1662
|
async handleSignIn() {
|
|
1614
|
-
if (!
|
|
1663
|
+
if (!Q(this.state.email)) {
|
|
1615
1664
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1616
1665
|
return;
|
|
1617
1666
|
}
|
|
@@ -1623,7 +1672,7 @@ class ot {
|
|
|
1623
1672
|
const e = await this.auth.signIn.email({
|
|
1624
1673
|
email: this.state.email.trim(),
|
|
1625
1674
|
password: this.state.password,
|
|
1626
|
-
callbackURL: this.getManagedReturnURL(
|
|
1675
|
+
callbackURL: this.getManagedReturnURL(B, this.state.email.trim())
|
|
1627
1676
|
});
|
|
1628
1677
|
if (e.error)
|
|
1629
1678
|
throw e.error;
|
|
@@ -1636,7 +1685,7 @@ class ot {
|
|
|
1636
1685
|
this.failValidation(this.labels.errors.requiredField);
|
|
1637
1686
|
return;
|
|
1638
1687
|
}
|
|
1639
|
-
if (!
|
|
1688
|
+
if (!Q(this.state.email)) {
|
|
1640
1689
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1641
1690
|
return;
|
|
1642
1691
|
}
|
|
@@ -1660,7 +1709,7 @@ class ot {
|
|
|
1660
1709
|
name: this.state.name.trim(),
|
|
1661
1710
|
email: this.state.email.trim(),
|
|
1662
1711
|
password: this.state.password,
|
|
1663
|
-
callbackURL: this.getManagedReturnURL(
|
|
1712
|
+
callbackURL: this.getManagedReturnURL(P, this.state.email.trim())
|
|
1664
1713
|
});
|
|
1665
1714
|
if (i.error)
|
|
1666
1715
|
throw i.error;
|
|
@@ -1672,7 +1721,7 @@ class ot {
|
|
|
1672
1721
|
});
|
|
1673
1722
|
}
|
|
1674
1723
|
async handleOAuthSignIn(e) {
|
|
1675
|
-
await this.runAction(`Redirecting to ${
|
|
1724
|
+
await this.runAction(`Redirecting to ${J[e]}…`, async () => {
|
|
1676
1725
|
const s = await this.auth.signIn.social({
|
|
1677
1726
|
provider: e,
|
|
1678
1727
|
callbackURL: this.getManagedReturnURL("oauth"),
|
|
@@ -1682,18 +1731,18 @@ class ot {
|
|
|
1682
1731
|
throw s.error;
|
|
1683
1732
|
const i = this.extractRedirectURL(s.data);
|
|
1684
1733
|
if (!i)
|
|
1685
|
-
throw new
|
|
1686
|
-
this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${
|
|
1734
|
+
throw new p(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
|
|
1735
|
+
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);
|
|
1687
1736
|
});
|
|
1688
1737
|
}
|
|
1689
1738
|
async handleForgotPassword() {
|
|
1690
1739
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1691
1740
|
this.handleError(
|
|
1692
|
-
new
|
|
1741
|
+
new p("Password reset via email OTP is not enabled for this project.")
|
|
1693
1742
|
);
|
|
1694
1743
|
return;
|
|
1695
1744
|
}
|
|
1696
|
-
if (!
|
|
1745
|
+
if (!Q(this.state.email)) {
|
|
1697
1746
|
this.failValidation(this.labels.errors.invalidEmail);
|
|
1698
1747
|
return;
|
|
1699
1748
|
}
|
|
@@ -1713,11 +1762,11 @@ class ot {
|
|
|
1713
1762
|
var e, s;
|
|
1714
1763
|
if (!this.canUsePasswordResetEmailOtp()) {
|
|
1715
1764
|
this.handleError(
|
|
1716
|
-
new
|
|
1765
|
+
new p("Password reset via email OTP is not enabled for this project.")
|
|
1717
1766
|
);
|
|
1718
1767
|
return;
|
|
1719
1768
|
}
|
|
1720
|
-
if (!
|
|
1769
|
+
if (!ut(this.state.code)) {
|
|
1721
1770
|
this.failValidation(this.labels.errors.invalidCode);
|
|
1722
1771
|
return;
|
|
1723
1772
|
}
|
|
@@ -1754,7 +1803,7 @@ class ot {
|
|
|
1754
1803
|
const s = await this.auth.sendVerificationEmail({
|
|
1755
1804
|
email: this.state.email.trim(),
|
|
1756
1805
|
callbackURL: this.getManagedReturnURL(
|
|
1757
|
-
this.verificationCompletionAction === "sign-up" ?
|
|
1806
|
+
this.verificationCompletionAction === "sign-up" ? P : B,
|
|
1758
1807
|
this.state.email.trim()
|
|
1759
1808
|
)
|
|
1760
1809
|
});
|
|
@@ -1772,8 +1821,8 @@ class ot {
|
|
|
1772
1821
|
if (!i.user || !i.session) {
|
|
1773
1822
|
if (this.destroyed)
|
|
1774
1823
|
return;
|
|
1775
|
-
if (i.lookupError &&
|
|
1776
|
-
this.
|
|
1824
|
+
if (i.lookupError && E(this.options)) {
|
|
1825
|
+
this.navigateToRedirect();
|
|
1777
1826
|
return;
|
|
1778
1827
|
}
|
|
1779
1828
|
if (e === "sign-in")
|
|
@@ -1789,11 +1838,11 @@ class ot {
|
|
|
1789
1838
|
session: i.session
|
|
1790
1839
|
};
|
|
1791
1840
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1792
|
-
if (
|
|
1793
|
-
this.
|
|
1841
|
+
if (E(this.options)) {
|
|
1842
|
+
this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
|
|
1794
1843
|
return;
|
|
1795
1844
|
}
|
|
1796
|
-
if (
|
|
1845
|
+
if (Z(this.options)) {
|
|
1797
1846
|
this.options.onSuccess(n), this.terminalActionInProgress = !0;
|
|
1798
1847
|
return;
|
|
1799
1848
|
}
|
|
@@ -1850,20 +1899,20 @@ class ot {
|
|
|
1850
1899
|
session: null
|
|
1851
1900
|
};
|
|
1852
1901
|
if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
|
|
1853
|
-
if (
|
|
1902
|
+
if (Z(this.options)) {
|
|
1854
1903
|
this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
|
|
1855
1904
|
return;
|
|
1856
1905
|
}
|
|
1857
1906
|
this.invokeRedirectModeSuccessHook(e), this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.newPassword = "", this.state.code = "", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = "Password updated. Sign in with your new password.", this.render();
|
|
1858
1907
|
}
|
|
1859
1908
|
}
|
|
1860
|
-
handleExistingSessionOnMount(
|
|
1861
|
-
if (
|
|
1862
|
-
this.
|
|
1909
|
+
handleExistingSessionOnMount() {
|
|
1910
|
+
if (E(this.options)) {
|
|
1911
|
+
this.navigateToRedirect();
|
|
1863
1912
|
return;
|
|
1864
1913
|
}
|
|
1865
|
-
if (
|
|
1866
|
-
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new
|
|
1914
|
+
if (Z(this.options))
|
|
1915
|
+
throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new p(
|
|
1867
1916
|
"authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
|
|
1868
1917
|
);
|
|
1869
1918
|
}
|
|
@@ -1887,7 +1936,7 @@ class ot {
|
|
|
1887
1936
|
}
|
|
1888
1937
|
invokeRedirectModeSuccessHook(e) {
|
|
1889
1938
|
var s, i;
|
|
1890
|
-
if (!(!
|
|
1939
|
+
if (!(!E(this.options) || !this.options.onSuccess))
|
|
1891
1940
|
try {
|
|
1892
1941
|
this.options.onSuccess(e);
|
|
1893
1942
|
} catch (n) {
|
|
@@ -1913,12 +1962,12 @@ class ot {
|
|
|
1913
1962
|
return i.searchParams.set(G, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
|
|
1914
1963
|
}
|
|
1915
1964
|
consumeManagedReturnContext() {
|
|
1916
|
-
const e = new URL(window.location.href), s = e.searchParams.get(G), i = e.searchParams.get(M),
|
|
1917
|
-
return (
|
|
1918
|
-
marker:
|
|
1919
|
-
email:
|
|
1920
|
-
error:
|
|
1921
|
-
errorDescription:
|
|
1965
|
+
const e = new URL(window.location.href), s = e.searchParams.get(G), i = s === K || s === B || s === P ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, m = i ? e.searchParams.get("error_description") : null;
|
|
1966
|
+
return (i || n) && (e.searchParams.delete(G), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
|
|
1967
|
+
marker: i,
|
|
1968
|
+
email: n,
|
|
1969
|
+
error: a,
|
|
1970
|
+
errorDescription: m
|
|
1922
1971
|
};
|
|
1923
1972
|
}
|
|
1924
1973
|
startCountdown(e = 60) {
|
|
@@ -1982,10 +2031,10 @@ class ot {
|
|
|
1982
2031
|
return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
|
|
1983
2032
|
}
|
|
1984
2033
|
handleSessionlessManagedReturn(e) {
|
|
1985
|
-
return e.email && (this.state.email = e.email), e.marker ===
|
|
2034
|
+
return e.email && (this.state.email = e.email), e.marker === P && !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 === B || e.marker === P ? (this.verificationCompletionAction = e.marker === P ? "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 v(
|
|
1986
2035
|
e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
|
|
1987
2036
|
{ code: e.error ?? "VERIFY_EMAIL_ERROR" }
|
|
1988
|
-
)) : this.render(), !0) : e.marker ===
|
|
2037
|
+
)) : this.render(), !0) : e.marker === K && (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 v(
|
|
1989
2038
|
e.errorDescription ?? "OAuth sign-in failed.",
|
|
1990
2039
|
{ code: e.error ?? "OAUTH_ERROR" }
|
|
1991
2040
|
)), !0) : !1;
|
|
@@ -2001,106 +2050,106 @@ class ot {
|
|
|
2001
2050
|
return i <= 0 ? e : s.replace("{seconds}", String(i));
|
|
2002
2051
|
}
|
|
2003
2052
|
escape(e) {
|
|
2004
|
-
return e.replace(
|
|
2053
|
+
return e.replace(/[&<>"']/g, (s) => ct[s]);
|
|
2005
2054
|
}
|
|
2006
2055
|
}
|
|
2007
|
-
function
|
|
2056
|
+
function wt(t) {
|
|
2008
2057
|
return "data" in t && t.data ? t.data : t;
|
|
2009
2058
|
}
|
|
2010
|
-
const
|
|
2059
|
+
const pt = [
|
|
2011
2060
|
{ id: "google", key: "providerGoogle" },
|
|
2012
2061
|
{ id: "apple", key: "providerApple" },
|
|
2013
2062
|
{ id: "microsoft", key: "providerMicrosoft" },
|
|
2014
2063
|
{ id: "github", key: "providerGithub" },
|
|
2015
2064
|
{ id: "gitlab", key: "providerGitlab" },
|
|
2016
2065
|
{ id: "discord", key: "providerDiscord" }
|
|
2017
|
-
], ve = 2,
|
|
2018
|
-
async function
|
|
2019
|
-
const t = `${window.location.origin}${
|
|
2066
|
+
], ve = 2, gt = 500;
|
|
2067
|
+
async function bt() {
|
|
2068
|
+
const t = `${window.location.origin}${Le}/config`;
|
|
2020
2069
|
let e;
|
|
2021
2070
|
for (let s = 0; s <= ve; s++)
|
|
2022
2071
|
try {
|
|
2023
2072
|
const i = await fetch(t, { method: "GET", credentials: "include" });
|
|
2024
2073
|
if (!i.ok)
|
|
2025
|
-
throw new
|
|
2074
|
+
throw new p(`Failed to load auth config: HTTP ${i.status}`);
|
|
2026
2075
|
const n = await i.json();
|
|
2027
|
-
return
|
|
2076
|
+
return vt(wt(n));
|
|
2028
2077
|
} catch (i) {
|
|
2029
|
-
e = i, s < ve && await new Promise((n) => setTimeout(n,
|
|
2078
|
+
e = i, s < ve && await new Promise((n) => setTimeout(n, gt));
|
|
2030
2079
|
}
|
|
2031
2080
|
throw e;
|
|
2032
2081
|
}
|
|
2033
|
-
let
|
|
2034
|
-
async function
|
|
2035
|
-
return
|
|
2036
|
-
throw
|
|
2037
|
-
})),
|
|
2082
|
+
let O = null;
|
|
2083
|
+
async function yt() {
|
|
2084
|
+
return O || (O = bt().catch((t) => {
|
|
2085
|
+
throw O = null, t;
|
|
2086
|
+
})), O;
|
|
2038
2087
|
}
|
|
2039
|
-
function
|
|
2040
|
-
var s, i, n, a,
|
|
2041
|
-
const e =
|
|
2042
|
-
const
|
|
2043
|
-
return typeof
|
|
2044
|
-
}).map(({ id:
|
|
2088
|
+
function vt(t) {
|
|
2089
|
+
var s, i, n, a, m, b, _;
|
|
2090
|
+
const e = pt.filter(({ key: R }) => {
|
|
2091
|
+
const T = t[R];
|
|
2092
|
+
return typeof T == "object" && T !== null && "enabled" in T && !!T.enabled;
|
|
2093
|
+
}).map(({ id: R }) => R);
|
|
2045
2094
|
return {
|
|
2046
2095
|
disableSignUp: !!t.disableSignUp,
|
|
2047
2096
|
emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
|
|
2048
2097
|
minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
|
|
2049
|
-
requireEmailVerification: !!((
|
|
2050
|
-
passwordResetEmailOtpEnabled: !!((
|
|
2098
|
+
requireEmailVerification: !!((m = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && m.requireEmailVerification),
|
|
2099
|
+
passwordResetEmailOtpEnabled: !!((_ = (b = t.providerEmailPassword) == null ? void 0 : b.config) != null && _.requirePasswordResetEmailVerification),
|
|
2051
2100
|
oauthProviders: e
|
|
2052
2101
|
};
|
|
2053
2102
|
}
|
|
2054
|
-
const
|
|
2055
|
-
function
|
|
2103
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
2104
|
+
function St(t) {
|
|
2056
2105
|
if (!t)
|
|
2057
|
-
throw new
|
|
2106
|
+
throw new p(
|
|
2058
2107
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2059
2108
|
);
|
|
2060
2109
|
const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
|
|
2061
2110
|
if (!e && !s)
|
|
2062
|
-
throw new
|
|
2111
|
+
throw new p(
|
|
2063
2112
|
"authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
|
|
2064
2113
|
);
|
|
2065
2114
|
if ("redirectTo" in t) {
|
|
2066
2115
|
const i = t.redirectTo;
|
|
2067
2116
|
if (!(typeof i == "string" || i instanceof URL))
|
|
2068
|
-
throw new
|
|
2117
|
+
throw new p(
|
|
2069
2118
|
"authUI.mount(container, options) expected redirectTo to be a string or URL."
|
|
2070
2119
|
);
|
|
2071
2120
|
}
|
|
2072
2121
|
if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
|
|
2073
|
-
throw new
|
|
2122
|
+
throw new p(
|
|
2074
2123
|
"authUI.mount(container, options) expected onSuccess to be a function."
|
|
2075
2124
|
);
|
|
2076
2125
|
if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
|
|
2077
|
-
throw new
|
|
2126
|
+
throw new p(
|
|
2078
2127
|
"authUI.mount(container, options) expected onError to be a function."
|
|
2079
2128
|
);
|
|
2080
2129
|
}
|
|
2081
|
-
function
|
|
2130
|
+
function Pt(t) {
|
|
2082
2131
|
if (!(t instanceof HTMLElement))
|
|
2083
|
-
throw new
|
|
2132
|
+
throw new p("authUI.mount(container, options) requires a real HTMLElement container.");
|
|
2084
2133
|
}
|
|
2085
|
-
function
|
|
2134
|
+
function Et(t, e) {
|
|
2086
2135
|
return {
|
|
2087
2136
|
mount(s, i) {
|
|
2088
|
-
var
|
|
2089
|
-
|
|
2090
|
-
const n = new
|
|
2137
|
+
var b;
|
|
2138
|
+
St(i), Pt(s), (b = V.get(s)) == null || b.destroy();
|
|
2139
|
+
const n = new ft(s, t, i, yt, e), a = n.destroy.bind(n), m = {
|
|
2091
2140
|
destroy() {
|
|
2092
|
-
a(),
|
|
2141
|
+
a(), V.get(s) === m && V.delete(s);
|
|
2093
2142
|
}
|
|
2094
2143
|
};
|
|
2095
|
-
return
|
|
2144
|
+
return V.set(s, m), m;
|
|
2096
2145
|
}
|
|
2097
2146
|
};
|
|
2098
2147
|
}
|
|
2099
|
-
function
|
|
2100
|
-
|
|
2101
|
-
const t =
|
|
2148
|
+
function _t() {
|
|
2149
|
+
Ee();
|
|
2150
|
+
const t = nt(), e = rt(), s = Oe(), i = Et(e, {
|
|
2102
2151
|
syncPublicSession: async () => {
|
|
2103
|
-
await
|
|
2152
|
+
await it(t);
|
|
2104
2153
|
}
|
|
2105
2154
|
});
|
|
2106
2155
|
return {
|
|
@@ -2110,22 +2159,22 @@ function pt() {
|
|
|
2110
2159
|
};
|
|
2111
2160
|
}
|
|
2112
2161
|
export {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2162
|
+
v as EdgeSparkAuthError,
|
|
2163
|
+
p as EdgeSparkConfigError,
|
|
2164
|
+
te as EdgeSparkError,
|
|
2116
2165
|
Se as EdgeSparkRuntimeError,
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2166
|
+
pe as ar,
|
|
2167
|
+
_t as createEdgeSpark,
|
|
2168
|
+
me as de,
|
|
2169
|
+
lt as detectLocale,
|
|
2170
|
+
N as enUS,
|
|
2122
2171
|
x as es,
|
|
2123
|
-
|
|
2172
|
+
he as fr,
|
|
2124
2173
|
ge as hi,
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2174
|
+
fe as it,
|
|
2175
|
+
de as ja,
|
|
2176
|
+
ce as ko,
|
|
2177
|
+
ue as ptBR,
|
|
2178
|
+
we as ru,
|
|
2130
2179
|
j as zhCN
|
|
2131
2180
|
};
|