@cal.macconnachie/web-components 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth.js +31 -28
- package/dist/components/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -47
- package/package.json +1 -1
package/dist/components/auth.js
CHANGED
|
@@ -17,7 +17,7 @@ let wt = class {
|
|
|
17
17
|
return this.cssText;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const Et = (e) => new wt(typeof e == "string" ? e : e + "", void 0, Q), xt = (e, ...t) => {
|
|
21
21
|
const s = e.length === 1 ? e[0] : t.reduce(((i, r, o) => i + ((a) => {
|
|
22
22
|
if (a._$cssResult$ === !0) return a.cssText;
|
|
23
23
|
if (typeof a == "number") return a;
|
|
@@ -33,7 +33,7 @@ const xt = (e) => new wt(typeof e == "string" ? e : e + "", void 0, Q), Et = (e,
|
|
|
33
33
|
}, at = Z ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => {
|
|
34
34
|
let s = "";
|
|
35
35
|
for (const i of t.cssRules) s += i.cssText;
|
|
36
|
-
return
|
|
36
|
+
return Et(s);
|
|
37
37
|
})(e) : e;
|
|
38
38
|
const { is: Pt, defineProperty: Ot, getOwnPropertyDescriptor: Dt, getOwnPropertyNames: Ut, getOwnPropertySymbols: Rt, getPrototypeOf: It } = Object, F = globalThis, nt = F.trustedTypes, Nt = nt ? nt.emptyScript : "", Lt = F.reactiveElementPolyfillSupport, M = (e, t) => e, Y = { toAttribute(e, t) {
|
|
39
39
|
switch (t) {
|
|
@@ -249,7 +249,7 @@ let U = class extends HTMLElement {
|
|
|
249
249
|
U.elementStyles = [], U.shadowRootOptions = { mode: "open" }, U[M("elementProperties")] = /* @__PURE__ */ new Map(), U[M("finalized")] = /* @__PURE__ */ new Map(), Lt?.({ ReactiveElement: U }), (F.reactiveElementVersions ??= []).push("2.1.1");
|
|
250
250
|
const tt = globalThis, K = tt.trustedTypes, ht = K ? K.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, bt = "$lit$", C = `lit$${Math.random().toFixed(9).slice(2)}$`, vt = "?" + C, Mt = `<${vt}>`, D = document, j = () => D.createComment(""), q = (e) => e === null || typeof e != "object" && typeof e != "function", et = Array.isArray, Ht = (e) => et(e) || typeof e?.[Symbol.iterator] == "function", W = `[
|
|
251
251
|
\f\r]`, N = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ct = /-->/g, dt = />/g, T = RegExp(`>|${W}(?:([^\\s"'>=/]+)(${W}*=${W}*(?:[^
|
|
252
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"), pt = /'/g, ut = /"/g, At = /^(?:script|style|textarea|title)$/i, jt = (e) => (t, ...s) => ({ _$litType$: e, strings: t, values: s }), f = jt(1),
|
|
252
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), pt = /'/g, ut = /"/g, At = /^(?:script|style|textarea|title)$/i, jt = (e) => (t, ...s) => ({ _$litType$: e, strings: t, values: s }), f = jt(1), E = Symbol.for("lit-noChange"), g = Symbol.for("lit-nothing"), gt = /* @__PURE__ */ new WeakMap(), O = D.createTreeWalker(D, 129);
|
|
253
253
|
function _t(e, t) {
|
|
254
254
|
if (!et(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
255
255
|
return ht !== void 0 ? ht.createHTML(t) : t;
|
|
@@ -304,7 +304,7 @@ class B {
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
function R(e, t, s = e, i) {
|
|
307
|
-
if (t ===
|
|
307
|
+
if (t === E) return t;
|
|
308
308
|
let r = i !== void 0 ? s._$Co?.[i] : s._$Cl;
|
|
309
309
|
const o = q(t) ? void 0 : t._$litDirective$;
|
|
310
310
|
return r?.constructor !== o && (r?._$AO?.(!1), o === void 0 ? r = void 0 : (r = new o(e), r._$AT(e, s, i)), i !== void 0 ? (s._$Co ??= [])[i] = r : s._$Cl = r), r !== void 0 && (t = R(e, r._$AS(e, t.values), r, i)), t;
|
|
@@ -356,7 +356,7 @@ class I {
|
|
|
356
356
|
return this._$AB;
|
|
357
357
|
}
|
|
358
358
|
_$AI(t, s = this) {
|
|
359
|
-
t = R(this, t, s), q(t) ? t === g || t == null || t === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : t !== this._$AH && t !==
|
|
359
|
+
t = R(this, t, s), q(t) ? t === g || t == null || t === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : t !== this._$AH && t !== E && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Ht(t) ? this.k(t) : this._(t);
|
|
360
360
|
}
|
|
361
361
|
O(t) {
|
|
362
362
|
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
|
@@ -409,11 +409,11 @@ class V {
|
|
|
409
409
|
_$AI(t, s = this, i, r) {
|
|
410
410
|
const o = this.strings;
|
|
411
411
|
let a = !1;
|
|
412
|
-
if (o === void 0) t = R(this, t, s, 0), a = !q(t) || t !== this._$AH && t !==
|
|
412
|
+
if (o === void 0) t = R(this, t, s, 0), a = !q(t) || t !== this._$AH && t !== E, a && (this._$AH = t);
|
|
413
413
|
else {
|
|
414
414
|
const c = t;
|
|
415
415
|
let n, h;
|
|
416
|
-
for (t = o[0], n = 0; n < o.length - 1; n++) h = R(this, c[i + n], s, n), h ===
|
|
416
|
+
for (t = o[0], n = 0; n < o.length - 1; n++) h = R(this, c[i + n], s, n), h === E && (h = this._$AH[n]), a ||= !q(h) || h !== this._$AH[n], h === g ? t = g : t !== g && (t += (h ?? "") + o[n + 1]), this._$AH[n] = h;
|
|
417
417
|
}
|
|
418
418
|
a && !r && this.j(t);
|
|
419
419
|
}
|
|
@@ -442,7 +442,7 @@ class Kt extends V {
|
|
|
442
442
|
super(t, s, i, r, o), this.type = 5;
|
|
443
443
|
}
|
|
444
444
|
_$AI(t, s = this) {
|
|
445
|
-
if ((t = R(this, t, s, 0) ?? g) ===
|
|
445
|
+
if ((t = R(this, t, s, 0) ?? g) === E) return;
|
|
446
446
|
const i = this._$AH, r = t === g && i !== g || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, o = t !== g && (i === g || r);
|
|
447
447
|
r && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
|
|
448
448
|
}
|
|
@@ -492,7 +492,7 @@ let H = class extends U {
|
|
|
492
492
|
super.disconnectedCallback(), this._$Do?.setConnected(!1);
|
|
493
493
|
}
|
|
494
494
|
render() {
|
|
495
|
-
return
|
|
495
|
+
return E;
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
498
|
H._$litElement$ = !0, H.finalized = !0, st.litElementHydrateSupport?.({ LitElement: H });
|
|
@@ -579,7 +579,7 @@ const mt = kt(class extends Ct {
|
|
|
579
579
|
const r = !!t[i];
|
|
580
580
|
r === this.st.has(i) || this.nt?.has(i) || (r ? (s.add(i), this.st.add(i)) : (s.remove(i), this.st.delete(i)));
|
|
581
581
|
}
|
|
582
|
-
return
|
|
582
|
+
return E;
|
|
583
583
|
}
|
|
584
584
|
});
|
|
585
585
|
const { I: ee } = Vt, ft = () => document.createComment(""), L = (e, t, s) => {
|
|
@@ -652,7 +652,7 @@ const yt = (e, t, s) => {
|
|
|
652
652
|
const v = r[l++];
|
|
653
653
|
v !== null && G(v);
|
|
654
654
|
}
|
|
655
|
-
return this.ut = a, ie(e, n),
|
|
655
|
+
return this.ut = a, ie(e, n), E;
|
|
656
656
|
}
|
|
657
657
|
}), oe = ({
|
|
658
658
|
baseUrl: e
|
|
@@ -884,10 +884,10 @@ const yt = (e, t, s) => {
|
|
|
884
884
|
redirectUri: he(r)
|
|
885
885
|
}, a = (w) => {
|
|
886
886
|
const _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", k = new Uint8Array(w);
|
|
887
|
-
return crypto.getRandomValues(k), Array.from(k).map((
|
|
887
|
+
return crypto.getRandomValues(k), Array.from(k).map((x) => _[x % _.length]).join("");
|
|
888
888
|
}, c = async (w) => {
|
|
889
|
-
const k = new TextEncoder().encode(w),
|
|
890
|
-
return btoa(String.fromCharCode(...new Uint8Array(
|
|
889
|
+
const k = new TextEncoder().encode(w), x = await crypto.subtle.digest("SHA-256", k);
|
|
890
|
+
return btoa(String.fromCharCode(...new Uint8Array(x))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
891
891
|
}, n = async () => {
|
|
892
892
|
const w = a(128), _ = await c(w);
|
|
893
893
|
return sessionStorage.setItem("pkce_code_verifier", w), { codeVerifier: w, codeChallenge: _ };
|
|
@@ -947,21 +947,21 @@ const yt = (e, t, s) => {
|
|
|
947
947
|
code: w,
|
|
948
948
|
redirect_uri: o.redirectUri,
|
|
949
949
|
code_verifier: _
|
|
950
|
-
}),
|
|
950
|
+
}), x = await fetch(`${o.domain}/oauth2/token`, {
|
|
951
951
|
method: "POST",
|
|
952
952
|
headers: {
|
|
953
953
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
954
954
|
},
|
|
955
955
|
body: k.toString()
|
|
956
956
|
});
|
|
957
|
-
if (!
|
|
958
|
-
const rt = await
|
|
957
|
+
if (!x.ok) {
|
|
958
|
+
const rt = await x.text();
|
|
959
959
|
throw new Error(`Token exchange failed: ${rt}`);
|
|
960
960
|
}
|
|
961
|
-
return
|
|
961
|
+
return x.json();
|
|
962
962
|
}
|
|
963
963
|
};
|
|
964
|
-
}, de = () =>
|
|
964
|
+
}, de = () => xt`
|
|
965
965
|
:host {
|
|
966
966
|
display: inline-block;
|
|
967
967
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
@@ -1662,8 +1662,8 @@ let m = class extends H {
|
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
|
-
setAuthTokens(e, t, s) {
|
|
1666
|
-
this.cookies.setAuthToken("ACCESS_TOKEN", e), this.cookies.setAuthToken("AUTH_TOKEN", t), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.isLoggedIn = !0, this.dispatchEvent(
|
|
1665
|
+
setAuthTokens(e, t, s, i) {
|
|
1666
|
+
this.cookies.setAuthToken("ACCESS_TOKEN", e), this.cookies.setAuthToken("AUTH_TOKEN", t), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.cookies.setCookie("USER_EMAIL", i.email), this.isLoggedIn = !0, this.dispatchEvent(
|
|
1667
1667
|
new CustomEvent("auth-success", {
|
|
1668
1668
|
bubbles: !0,
|
|
1669
1669
|
composed: !0
|
|
@@ -1674,8 +1674,8 @@ let m = class extends H {
|
|
|
1674
1674
|
const e = {
|
|
1675
1675
|
email: this.email.trim(),
|
|
1676
1676
|
password: this.password
|
|
1677
|
-
}, { accessToken: t, idToken: s, refreshToken: i } = await this.getApiService().login(e);
|
|
1678
|
-
this.setAuthTokens(t, s, i), this.handleClose();
|
|
1677
|
+
}, { accessToken: t, idToken: s, refreshToken: i, user: r } = await this.getApiService().login(e);
|
|
1678
|
+
this.setAuthTokens(t, s, i, r), this.handleClose();
|
|
1679
1679
|
}
|
|
1680
1680
|
isOAuthConfigured() {
|
|
1681
1681
|
return [this.oauthDomain, this.oauthRegion, this.oauthUserPoolId, this.oauthClientId].every(
|
|
@@ -1719,12 +1719,12 @@ let m = class extends H {
|
|
|
1719
1719
|
if (a)
|
|
1720
1720
|
throw new Error(c || `OAuth error: ${a}`);
|
|
1721
1721
|
if (t && s && i) {
|
|
1722
|
-
const { accessToken: h, idToken: d, refreshToken: l } = await this.getApiService().login({
|
|
1722
|
+
const { accessToken: h, idToken: d, refreshToken: l, user: p } = await this.getApiService().login({
|
|
1723
1723
|
accessToken: t,
|
|
1724
1724
|
refreshToken: i,
|
|
1725
1725
|
idToken: s
|
|
1726
1726
|
});
|
|
1727
|
-
this.setAuthTokens(h, d, l ?? i), this.handleClose();
|
|
1727
|
+
this.setAuthTokens(h, d, l ?? i, p), this.handleClose();
|
|
1728
1728
|
} else if (r && o) {
|
|
1729
1729
|
if (!this.isOAuthConfigured())
|
|
1730
1730
|
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
@@ -1733,12 +1733,12 @@ let m = class extends H {
|
|
|
1733
1733
|
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1734
1734
|
if (!h.validateState(o))
|
|
1735
1735
|
throw new Error("Invalid state parameter. Please try signing in again.");
|
|
1736
|
-
const d = await h.exchangeCodeForTokens(r), { accessToken: l, idToken: p, refreshToken: u } = await this.getApiService().login({
|
|
1736
|
+
const d = await h.exchangeCodeForTokens(r), { accessToken: l, idToken: p, refreshToken: u, user: $ } = await this.getApiService().login({
|
|
1737
1737
|
accessToken: d.access_token,
|
|
1738
1738
|
refreshToken: d.refresh_token,
|
|
1739
1739
|
idToken: d.id_token
|
|
1740
1740
|
});
|
|
1741
|
-
this.setAuthTokens(l, p, u ?? d.refresh_token), this.handleClose();
|
|
1741
|
+
this.setAuthTokens(l, p, u ?? d.refresh_token, $), this.handleClose();
|
|
1742
1742
|
} else
|
|
1743
1743
|
throw new Error("Missing required OAuth parameters");
|
|
1744
1744
|
} catch (h) {
|
|
@@ -1790,7 +1790,7 @@ let m = class extends H {
|
|
|
1790
1790
|
}), await this.handleSignIn();
|
|
1791
1791
|
}
|
|
1792
1792
|
isUserLoggedIn() {
|
|
1793
|
-
return this.isLoggedIn;
|
|
1793
|
+
return this.isLoggedIn || !!this.cookies.getAuthToken("ACCESS_TOKEN") && !!this.cookies.getAuthToken("REFRESH_TOKEN") && !!this.cookies.getAuthToken("AUTH_TOKEN");
|
|
1794
1794
|
}
|
|
1795
1795
|
async logout() {
|
|
1796
1796
|
const e = this.cookies.getAuthToken("ACCESS_TOKEN"), t = this.cookies.getAuthToken("AUTH_TOKEN"), s = this.cookies.getAuthToken("REFRESH_TOKEN");
|
|
@@ -2422,6 +2422,9 @@ let m = class extends H {
|
|
|
2422
2422
|
this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
|
|
2423
2423
|
}
|
|
2424
2424
|
}
|
|
2425
|
+
getUserEmail() {
|
|
2426
|
+
return this.cookies.getCookie("USER_EMAIL") || null;
|
|
2427
|
+
}
|
|
2425
2428
|
};
|
|
2426
2429
|
m.styles = de();
|
|
2427
2430
|
y([
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -247,14 +247,14 @@ let Q = class extends HTMLElement {
|
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
249
|
Q.elementStyles = [], Q.shadowRootOptions = { mode: "open" }, Q[de("elementProperties")] = /* @__PURE__ */ new Map(), Q[de("finalized")] = /* @__PURE__ */ new Map(), Ns?.({ ReactiveElement: Q }), (xe.reactiveElementVersions ??= []).push("2.1.1");
|
|
250
|
-
const Xe = globalThis, Ce = Xe.trustedTypes, yt = Ce ? Ce.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, Vt = "$lit$",
|
|
251
|
-
\f\r]`, le = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, bt = /-->/g, wt = />/g, K = RegExp(`>|${
|
|
250
|
+
const Xe = globalThis, Ce = Xe.trustedTypes, yt = Ce ? Ce.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, Vt = "$lit$", j = `lit$${Math.random().toFixed(9).slice(2)}$`, Wt = "?" + j, Ls = `<${Wt}>`, G = document, ue = () => G.createComment(""), pe = (t) => t === null || typeof t != "object" && typeof t != "function", Qe = Array.isArray, Is = (t) => Qe(t) || typeof t?.[Symbol.iterator] == "function", He = `[
|
|
251
|
+
\f\r]`, le = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, bt = /-->/g, wt = />/g, K = RegExp(`>|${He}(?:([^\\s"'>=/]+)(${He}*=${He}*(?:[^
|
|
252
252
|
\f\r"'\`<>=]|("|')|))|$)`, "g"), St = /'/g, $t = /"/g, Yt = /^(?:script|style|textarea|title)$/i, Bs = (t) => (e, ...s) => ({ _$litType$: t, strings: e, values: s }), w = Bs(1), M = Symbol.for("lit-noChange"), S = Symbol.for("lit-nothing"), At = /* @__PURE__ */ new WeakMap(), W = G.createTreeWalker(G, 129);
|
|
253
253
|
function Jt(t, e) {
|
|
254
254
|
if (!Qe(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
255
255
|
return yt !== void 0 ? yt.createHTML(e) : e;
|
|
256
256
|
}
|
|
257
|
-
const
|
|
257
|
+
const Hs = (t, e) => {
|
|
258
258
|
const s = t.length - 1, r = [];
|
|
259
259
|
let i, o = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = le;
|
|
260
260
|
for (let a = 0; a < s; a++) {
|
|
@@ -262,7 +262,7 @@ const js = (t, e) => {
|
|
|
262
262
|
let h, c, u = -1, f = 0;
|
|
263
263
|
for (; f < l.length && (n.lastIndex = f, c = n.exec(l), c !== null); ) f = n.lastIndex, n === le ? c[1] === "!--" ? n = bt : c[1] !== void 0 ? n = wt : c[2] !== void 0 ? (Yt.test(c[2]) && (i = RegExp("</" + c[2], "g")), n = K) : c[3] !== void 0 && (n = K) : n === K ? c[0] === ">" ? (n = i ?? le, u = -1) : c[1] === void 0 ? u = -2 : (u = n.lastIndex - c[2].length, h = c[1], n = c[3] === void 0 ? K : c[3] === '"' ? $t : St) : n === $t || n === St ? n = K : n === bt || n === wt ? n = le : (n = K, i = void 0);
|
|
264
264
|
const y = n === K && t[a + 1].startsWith("/>") ? " " : "";
|
|
265
|
-
o += n === le ? l + Ls : u >= 0 ? (r.push(h), l.slice(0, u) + Vt + l.slice(u) +
|
|
265
|
+
o += n === le ? l + Ls : u >= 0 ? (r.push(h), l.slice(0, u) + Vt + l.slice(u) + j + y) : l + j + (u === -2 ? a : y);
|
|
266
266
|
}
|
|
267
267
|
return [Jt(t, o + (t[s] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
|
|
268
268
|
};
|
|
@@ -271,7 +271,7 @@ class fe {
|
|
|
271
271
|
let i;
|
|
272
272
|
this.parts = [];
|
|
273
273
|
let o = 0, n = 0;
|
|
274
|
-
const a = e.length - 1, l = this.parts, [h, c] =
|
|
274
|
+
const a = e.length - 1, l = this.parts, [h, c] = Hs(e, s);
|
|
275
275
|
if (this.el = fe.createElement(h, r), W.currentNode = this.el.content, s === 2 || s === 3) {
|
|
276
276
|
const u = this.el.content.firstChild;
|
|
277
277
|
u.replaceWith(...u.childNodes);
|
|
@@ -279,11 +279,11 @@ class fe {
|
|
|
279
279
|
for (; (i = W.nextNode()) !== null && l.length < a; ) {
|
|
280
280
|
if (i.nodeType === 1) {
|
|
281
281
|
if (i.hasAttributes()) for (const u of i.getAttributeNames()) if (u.endsWith(Vt)) {
|
|
282
|
-
const f = c[n++], y = i.getAttribute(u).split(
|
|
282
|
+
const f = c[n++], y = i.getAttribute(u).split(j), p = /([.?@])?(.*)/.exec(f);
|
|
283
283
|
l.push({ type: 1, index: o, name: p[2], strings: y, ctor: p[1] === "." ? Ms : p[1] === "?" ? Fs : p[1] === "@" ? qs : Re }), i.removeAttribute(u);
|
|
284
|
-
} else u.startsWith(
|
|
284
|
+
} else u.startsWith(j) && (l.push({ type: 6, index: o }), i.removeAttribute(u));
|
|
285
285
|
if (Yt.test(i.tagName)) {
|
|
286
|
-
const u = i.textContent.split(
|
|
286
|
+
const u = i.textContent.split(j), f = u.length - 1;
|
|
287
287
|
if (f > 0) {
|
|
288
288
|
i.textContent = Ce ? Ce.emptyScript : "";
|
|
289
289
|
for (let y = 0; y < f; y++) i.append(u[y], ue()), W.nextNode(), l.push({ type: 2, index: ++o });
|
|
@@ -293,7 +293,7 @@ class fe {
|
|
|
293
293
|
} else if (i.nodeType === 8) if (i.data === Wt) l.push({ type: 2, index: o });
|
|
294
294
|
else {
|
|
295
295
|
let u = -1;
|
|
296
|
-
for (; (u = i.data.indexOf(
|
|
296
|
+
for (; (u = i.data.indexOf(j, u + 1)) !== -1; ) l.push({ type: 7, index: o }), u += j.length - 1;
|
|
297
297
|
}
|
|
298
298
|
o++;
|
|
299
299
|
}
|
|
@@ -309,7 +309,7 @@ function te(t, e, s = t, r) {
|
|
|
309
309
|
const o = pe(e) ? void 0 : e._$litDirective$;
|
|
310
310
|
return i?.constructor !== o && (i?._$AO?.(!1), o === void 0 ? i = void 0 : (i = new o(t), i._$AT(t, s, r)), r !== void 0 ? (s._$Co ??= [])[r] = i : s._$Cl = i), i !== void 0 && (e = te(t, i._$AS(t, e.values), i, r)), e;
|
|
311
311
|
}
|
|
312
|
-
let
|
|
312
|
+
let js = class {
|
|
313
313
|
constructor(e, s) {
|
|
314
314
|
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = s;
|
|
315
315
|
}
|
|
@@ -371,7 +371,7 @@ class re {
|
|
|
371
371
|
const { values: s, _$litType$: r } = e, i = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = fe.createElement(Jt(r.h, r.h[0]), this.options)), r);
|
|
372
372
|
if (this._$AH?._$AD === i) this._$AH.p(s);
|
|
373
373
|
else {
|
|
374
|
-
const o = new
|
|
374
|
+
const o = new js(i, this), n = o.u(this.options);
|
|
375
375
|
o.p(s), this.T(n), this._$AH = o;
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -602,7 +602,7 @@ const { I: Xs } = Ks, Et = () => document.createComment(""), ce = (t, e, s) => {
|
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
return s;
|
|
605
|
-
}, V = (t, e, s = t) => (t._$AI(e, s), t), Qs = {}, er = (t, e = Qs) => t._$AH = e, tr = (t) => t._$AH,
|
|
605
|
+
}, V = (t, e, s = t) => (t._$AI(e, s), t), Qs = {}, er = (t, e = Qs) => t._$AH = e, tr = (t) => t._$AH, je = (t) => {
|
|
606
606
|
t._$AR(), t._$AA.remove();
|
|
607
607
|
};
|
|
608
608
|
const _t = (t, e, s) => {
|
|
@@ -642,15 +642,15 @@ const _t = (t, e, s) => {
|
|
|
642
642
|
V(b, o[y]), l[y] = b;
|
|
643
643
|
} else l[y] = V(m, o[y]), ce(t, i[u], m), i[g] = null;
|
|
644
644
|
y++;
|
|
645
|
-
} else
|
|
646
|
-
else
|
|
645
|
+
} else je(i[f]), f--;
|
|
646
|
+
else je(i[u]), u++;
|
|
647
647
|
for (; y <= p; ) {
|
|
648
648
|
const g = ce(t, l[p + 1]);
|
|
649
649
|
V(g, o[y]), l[y++] = g;
|
|
650
650
|
}
|
|
651
651
|
for (; u <= f; ) {
|
|
652
652
|
const g = i[u++];
|
|
653
|
-
g !== null &&
|
|
653
|
+
g !== null && je(g);
|
|
654
654
|
}
|
|
655
655
|
return this.ut = n, er(t, l), M;
|
|
656
656
|
}
|
|
@@ -1662,8 +1662,8 @@ let A = class extends ee {
|
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
|
-
setAuthTokens(t, e, s) {
|
|
1666
|
-
this.cookies.setAuthToken("ACCESS_TOKEN", t), this.cookies.setAuthToken("AUTH_TOKEN", e), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.isLoggedIn = !0, this.dispatchEvent(
|
|
1665
|
+
setAuthTokens(t, e, s, r) {
|
|
1666
|
+
this.cookies.setAuthToken("ACCESS_TOKEN", t), this.cookies.setAuthToken("AUTH_TOKEN", e), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.cookies.setCookie("USER_EMAIL", r.email), this.isLoggedIn = !0, this.dispatchEvent(
|
|
1667
1667
|
new CustomEvent("auth-success", {
|
|
1668
1668
|
bubbles: !0,
|
|
1669
1669
|
composed: !0
|
|
@@ -1674,8 +1674,8 @@ let A = class extends ee {
|
|
|
1674
1674
|
const t = {
|
|
1675
1675
|
email: this.email.trim(),
|
|
1676
1676
|
password: this.password
|
|
1677
|
-
}, { accessToken: e, idToken: s, refreshToken: r } = await this.getApiService().login(t);
|
|
1678
|
-
this.setAuthTokens(e, s, r), this.handleClose();
|
|
1677
|
+
}, { accessToken: e, idToken: s, refreshToken: r, user: i } = await this.getApiService().login(t);
|
|
1678
|
+
this.setAuthTokens(e, s, r, i), this.handleClose();
|
|
1679
1679
|
}
|
|
1680
1680
|
isOAuthConfigured() {
|
|
1681
1681
|
return [this.oauthDomain, this.oauthRegion, this.oauthUserPoolId, this.oauthClientId].every(
|
|
@@ -1719,12 +1719,12 @@ let A = class extends ee {
|
|
|
1719
1719
|
if (n)
|
|
1720
1720
|
throw new Error(a || `OAuth error: ${n}`);
|
|
1721
1721
|
if (e && s && r) {
|
|
1722
|
-
const { accessToken: h, idToken: c, refreshToken: u } = await this.getApiService().login({
|
|
1722
|
+
const { accessToken: h, idToken: c, refreshToken: u, user: f } = await this.getApiService().login({
|
|
1723
1723
|
accessToken: e,
|
|
1724
1724
|
refreshToken: r,
|
|
1725
1725
|
idToken: s
|
|
1726
1726
|
});
|
|
1727
|
-
this.setAuthTokens(h, c, u ?? r), this.handleClose();
|
|
1727
|
+
this.setAuthTokens(h, c, u ?? r, f), this.handleClose();
|
|
1728
1728
|
} else if (i && o) {
|
|
1729
1729
|
if (!this.isOAuthConfigured())
|
|
1730
1730
|
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
@@ -1733,12 +1733,12 @@ let A = class extends ee {
|
|
|
1733
1733
|
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1734
1734
|
if (!h.validateState(o))
|
|
1735
1735
|
throw new Error("Invalid state parameter. Please try signing in again.");
|
|
1736
|
-
const c = await h.exchangeCodeForTokens(i), { accessToken: u, idToken: f, refreshToken: y } = await this.getApiService().login({
|
|
1736
|
+
const c = await h.exchangeCodeForTokens(i), { accessToken: u, idToken: f, refreshToken: y, user: p } = await this.getApiService().login({
|
|
1737
1737
|
accessToken: c.access_token,
|
|
1738
1738
|
refreshToken: c.refresh_token,
|
|
1739
1739
|
idToken: c.id_token
|
|
1740
1740
|
});
|
|
1741
|
-
this.setAuthTokens(u, f, y ?? c.refresh_token), this.handleClose();
|
|
1741
|
+
this.setAuthTokens(u, f, y ?? c.refresh_token, p), this.handleClose();
|
|
1742
1742
|
} else
|
|
1743
1743
|
throw new Error("Missing required OAuth parameters");
|
|
1744
1744
|
} catch (h) {
|
|
@@ -1790,7 +1790,7 @@ let A = class extends ee {
|
|
|
1790
1790
|
}), await this.handleSignIn();
|
|
1791
1791
|
}
|
|
1792
1792
|
isUserLoggedIn() {
|
|
1793
|
-
return this.isLoggedIn;
|
|
1793
|
+
return this.isLoggedIn || !!this.cookies.getAuthToken("ACCESS_TOKEN") && !!this.cookies.getAuthToken("REFRESH_TOKEN") && !!this.cookies.getAuthToken("AUTH_TOKEN");
|
|
1794
1794
|
}
|
|
1795
1795
|
async logout() {
|
|
1796
1796
|
const t = this.cookies.getAuthToken("ACCESS_TOKEN"), e = this.cookies.getAuthToken("AUTH_TOKEN"), s = this.cookies.getAuthToken("REFRESH_TOKEN");
|
|
@@ -2422,6 +2422,9 @@ let A = class extends ee {
|
|
|
2422
2422
|
this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
|
|
2423
2423
|
}
|
|
2424
2424
|
}
|
|
2425
|
+
getUserEmail() {
|
|
2426
|
+
return this.cookies.getCookie("USER_EMAIL") || null;
|
|
2427
|
+
}
|
|
2425
2428
|
};
|
|
2426
2429
|
A.styles = nr();
|
|
2427
2430
|
v([
|
|
@@ -2906,12 +2909,12 @@ const Or = (t, e, s, { allOwnKeys: r } = {}) => (ye(e, (i, o) => {
|
|
|
2906
2909
|
for (; (s = t.exec(e)) !== null; )
|
|
2907
2910
|
r.push(s);
|
|
2908
2911
|
return r;
|
|
2909
|
-
}, Br = N("HTMLFormElement"),
|
|
2912
|
+
}, Br = N("HTMLFormElement"), Hr = (t) => t.toLowerCase().replace(
|
|
2910
2913
|
/[-_\s]([a-z\d])(\w*)/g,
|
|
2911
2914
|
function(s, r, i) {
|
|
2912
2915
|
return r.toUpperCase() + i;
|
|
2913
2916
|
}
|
|
2914
|
-
), kt = (({ hasOwnProperty: t }) => (e, s) => t.call(e, s))(Object.prototype),
|
|
2917
|
+
), kt = (({ hasOwnProperty: t }) => (e, s) => t.call(e, s))(Object.prototype), jr = N("RegExp"), ls = (t, e) => {
|
|
2915
2918
|
const s = Object.getOwnPropertyDescriptors(t), r = {};
|
|
2916
2919
|
ye(s, (i, o) => {
|
|
2917
2920
|
let n;
|
|
@@ -2990,7 +2993,7 @@ const Vr = (t) => {
|
|
|
2990
2993
|
isDate: yr,
|
|
2991
2994
|
isFile: br,
|
|
2992
2995
|
isBlob: wr,
|
|
2993
|
-
isRegExp:
|
|
2996
|
+
isRegExp: jr,
|
|
2994
2997
|
isFunction: P,
|
|
2995
2998
|
isStream: $r,
|
|
2996
2999
|
isURLSearchParams: vr,
|
|
@@ -3016,7 +3019,7 @@ const Vr = (t) => {
|
|
|
3016
3019
|
reduceDescriptors: ls,
|
|
3017
3020
|
freezeMethods: Mr,
|
|
3018
3021
|
toObjectSet: Fr,
|
|
3019
|
-
toCamelCase:
|
|
3022
|
+
toCamelCase: Hr,
|
|
3020
3023
|
noop: qr,
|
|
3021
3024
|
toFiniteNumber: zr,
|
|
3022
3025
|
findKey: ns,
|
|
@@ -3959,7 +3962,7 @@ const Ss = (t) => {
|
|
|
3959
3962
|
}))(d.global), {
|
|
3960
3963
|
ReadableStream: It,
|
|
3961
3964
|
TextEncoder: Bt
|
|
3962
|
-
} = d.global,
|
|
3965
|
+
} = d.global, Ht = (t, ...e) => {
|
|
3963
3966
|
try {
|
|
3964
3967
|
return !!t(...e);
|
|
3965
3968
|
} catch {
|
|
@@ -3972,7 +3975,7 @@ const Ss = (t) => {
|
|
|
3972
3975
|
const { fetch: e, Request: s, Response: r } = t, i = e ? Ae(e) : typeof fetch == "function", o = Ae(s), n = Ae(r);
|
|
3973
3976
|
if (!i)
|
|
3974
3977
|
return !1;
|
|
3975
|
-
const a = i && Ae(It), l = i && (typeof Bt == "function" ? /* @__PURE__ */ ((p) => (g) => p.encode(g))(new Bt()) : async (p) => new Uint8Array(await new s(p).arrayBuffer())), h = o && a &&
|
|
3978
|
+
const a = i && Ae(It), l = i && (typeof Bt == "function" ? /* @__PURE__ */ ((p) => (g) => p.encode(g))(new Bt()) : async (p) => new Uint8Array(await new s(p).arrayBuffer())), h = o && a && Ht(() => {
|
|
3976
3979
|
let p = !1;
|
|
3977
3980
|
const g = new s(x.origin, {
|
|
3978
3981
|
body: new It(),
|
|
@@ -3982,7 +3985,7 @@ const Ss = (t) => {
|
|
|
3982
3985
|
}
|
|
3983
3986
|
}).headers.has("Content-Type");
|
|
3984
3987
|
return p && !g;
|
|
3985
|
-
}), c = n && a &&
|
|
3988
|
+
}), c = n && a && Ht(() => d.isReadableStream(new r("").body)), u = {
|
|
3986
3989
|
stream: c && ((p) => p.body)
|
|
3987
3990
|
};
|
|
3988
3991
|
i && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((p) => {
|
|
@@ -4034,17 +4037,17 @@ const Ss = (t) => {
|
|
|
4034
4037
|
let ct;
|
|
4035
4038
|
try {
|
|
4036
4039
|
if (q && h && m !== "get" && m !== "head" && (ct = await y(Ie, b)) !== 0) {
|
|
4037
|
-
let
|
|
4040
|
+
let H = new s(g, {
|
|
4038
4041
|
method: "POST",
|
|
4039
4042
|
body: b,
|
|
4040
4043
|
duplex: "half"
|
|
4041
4044
|
}), X;
|
|
4042
|
-
if (d.isFormData(b) && (X =
|
|
4045
|
+
if (d.isFormData(b) && (X = H.headers.get("content-type")) && Ie.setContentType(X), H.body) {
|
|
4043
4046
|
const [Be, $e] = Pt(
|
|
4044
4047
|
ct,
|
|
4045
4048
|
Oe(Dt(q))
|
|
4046
4049
|
);
|
|
4047
|
-
b = Nt(
|
|
4050
|
+
b = Nt(H.body, Lt, Be, $e);
|
|
4048
4051
|
}
|
|
4049
4052
|
}
|
|
4050
4053
|
d.isString(we) || (we = we ? "include" : "omit");
|
|
@@ -4061,9 +4064,9 @@ const Ss = (t) => {
|
|
|
4061
4064
|
let B = await (o ? lt(ae, at) : lt(g, ht));
|
|
4062
4065
|
const dt = c && (U === "stream" || U === "response");
|
|
4063
4066
|
if (c && (R || dt && z)) {
|
|
4064
|
-
const
|
|
4067
|
+
const H = {};
|
|
4065
4068
|
["status", "statusText", "headers"].forEach((ut) => {
|
|
4066
|
-
|
|
4069
|
+
H[ut] = B[ut];
|
|
4067
4070
|
});
|
|
4068
4071
|
const X = d.toFiniteNumber(B.headers.get("content-length")), [Be, $e] = R && Pt(
|
|
4069
4072
|
X,
|
|
@@ -4073,13 +4076,13 @@ const Ss = (t) => {
|
|
|
4073
4076
|
Nt(B.body, Lt, Be, () => {
|
|
4074
4077
|
$e && $e(), z && z();
|
|
4075
4078
|
}),
|
|
4076
|
-
|
|
4079
|
+
H
|
|
4077
4080
|
);
|
|
4078
4081
|
}
|
|
4079
4082
|
U = U || "text";
|
|
4080
4083
|
let _s = await u[d.findKey(u, U) || "text"](B, p);
|
|
4081
|
-
return !dt && z && z(), await new Promise((
|
|
4082
|
-
bs(
|
|
4084
|
+
return !dt && z && z(), await new Promise((H, X) => {
|
|
4085
|
+
bs(H, X, {
|
|
4083
4086
|
data: _s,
|
|
4084
4087
|
headers: D.from(B.headers),
|
|
4085
4088
|
status: B.status,
|
|
@@ -4126,7 +4129,7 @@ d.forEach(ot, (t, e) => {
|
|
|
4126
4129
|
Object.defineProperty(t, "adapterName", { value: e });
|
|
4127
4130
|
}
|
|
4128
4131
|
});
|
|
4129
|
-
const
|
|
4132
|
+
const jt = (t) => `- ${t}`, Ni = (t) => d.isFunction(t) || t === null || t === !1;
|
|
4130
4133
|
function Li(t, e) {
|
|
4131
4134
|
t = d.isArray(t) ? t : [t];
|
|
4132
4135
|
const { length: s } = t;
|
|
@@ -4146,8 +4149,8 @@ function Li(t, e) {
|
|
|
4146
4149
|
([l, h]) => `adapter ${l} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
|
|
4147
4150
|
);
|
|
4148
4151
|
let a = s ? n.length > 1 ? `since :
|
|
4149
|
-
` + n.map(
|
|
4150
|
-
`) : " " +
|
|
4152
|
+
` + n.map(jt).join(`
|
|
4153
|
+
`) : " " + jt(n[0]) : "as no adapter specified";
|
|
4151
4154
|
throw new $(
|
|
4152
4155
|
"There is no suitable adapter to dispatch the request " + a,
|
|
4153
4156
|
"ERR_NOT_SUPPORT"
|
|
@@ -4435,7 +4438,7 @@ function Bi(t) {
|
|
|
4435
4438
|
return t.apply(null, s);
|
|
4436
4439
|
};
|
|
4437
4440
|
}
|
|
4438
|
-
function
|
|
4441
|
+
function Hi(t) {
|
|
4439
4442
|
return d.isObject(t) && t.isAxiosError === !0;
|
|
4440
4443
|
}
|
|
4441
4444
|
const Ye = {
|
|
@@ -4531,7 +4534,7 @@ C.all = function(e) {
|
|
|
4531
4534
|
return Promise.all(e);
|
|
4532
4535
|
};
|
|
4533
4536
|
C.spread = Bi;
|
|
4534
|
-
C.isAxiosError =
|
|
4537
|
+
C.isAxiosError = Hi;
|
|
4535
4538
|
C.mergeConfig = Z;
|
|
4536
4539
|
C.AxiosHeaders = D;
|
|
4537
4540
|
C.formToJSON = (t) => gs(d.isHTMLForm(t) ? new FormData(t) : t);
|
|
@@ -4543,7 +4546,7 @@ class qt extends Error {
|
|
|
4543
4546
|
super(e), this.name = "AuthRefreshError";
|
|
4544
4547
|
}
|
|
4545
4548
|
}
|
|
4546
|
-
const
|
|
4549
|
+
const ji = ({ baseUrl: t, apiBaseUrl: e }) => {
|
|
4547
4550
|
const s = ts(), r = e || t, i = C.create({
|
|
4548
4551
|
baseURL: t,
|
|
4549
4552
|
headers: {
|
|
@@ -4596,11 +4599,11 @@ const Hi = ({ baseUrl: t, apiBaseUrl: e }) => {
|
|
|
4596
4599
|
return Promise.reject(a);
|
|
4597
4600
|
}
|
|
4598
4601
|
), i;
|
|
4599
|
-
}, Ki =
|
|
4602
|
+
}, Ki = ji;
|
|
4600
4603
|
export {
|
|
4601
4604
|
A as Auth,
|
|
4602
4605
|
qt as AuthRefreshError,
|
|
4603
4606
|
F as ThemeToggle,
|
|
4604
4607
|
Ki as apiClient,
|
|
4605
|
-
|
|
4608
|
+
ji as createApiClient
|
|
4606
4609
|
};
|