@cal.macconnachie/web-components 0.0.7 → 0.0.8
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/cals-auth.js +178 -147
- package/dist/components/index.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +178 -147
- package/package.json +1 -1
|
@@ -85,8 +85,8 @@ let U = class extends HTMLElement {
|
|
|
85
85
|
this[s] = a;
|
|
86
86
|
} };
|
|
87
87
|
return { get: r, set(a) {
|
|
88
|
-
const
|
|
89
|
-
o?.call(this, a), this.requestUpdate(t,
|
|
88
|
+
const c = r?.call(this);
|
|
89
|
+
o?.call(this, a), this.requestUpdate(t, c, i);
|
|
90
90
|
}, configurable: !0, enumerable: !0 };
|
|
91
91
|
}
|
|
92
92
|
static getPropertyOptions(t) {
|
|
@@ -171,8 +171,8 @@ let U = class extends HTMLElement {
|
|
|
171
171
|
if (r !== void 0 && this._$Em !== r) {
|
|
172
172
|
const o = i.getPropertyOptions(r), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : Y;
|
|
173
173
|
this._$Em = r;
|
|
174
|
-
const
|
|
175
|
-
this[r] =
|
|
174
|
+
const c = a.fromAttribute(s, o.type);
|
|
175
|
+
this[r] = c ?? this._$Ej?.get(r) ?? c, this._$Em = null;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
requestUpdate(t, s, i) {
|
|
@@ -208,8 +208,8 @@ let U = class extends HTMLElement {
|
|
|
208
208
|
}
|
|
209
209
|
const i = this.constructor.elementProperties;
|
|
210
210
|
if (i.size > 0) for (const [r, o] of i) {
|
|
211
|
-
const { wrapped: a } = o,
|
|
212
|
-
a !== !0 || this._$AL.has(r) ||
|
|
211
|
+
const { wrapped: a } = o, c = this[r];
|
|
212
|
+
a !== !0 || this._$AL.has(r) || c === void 0 || this.C(r, void 0, o, c);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
let t = !1;
|
|
@@ -257,12 +257,12 @@ function _t(e, t) {
|
|
|
257
257
|
const qt = (e, t) => {
|
|
258
258
|
const s = e.length - 1, i = [];
|
|
259
259
|
let r, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = N;
|
|
260
|
-
for (let
|
|
261
|
-
const n = e[
|
|
262
|
-
let
|
|
263
|
-
for (;
|
|
264
|
-
const u = a === T && e[
|
|
265
|
-
o += a === N ? n + Mt : l >= 0 ? (i.push(
|
|
260
|
+
for (let c = 0; c < s; c++) {
|
|
261
|
+
const n = e[c];
|
|
262
|
+
let h, d, l = -1, p = 0;
|
|
263
|
+
for (; p < n.length && (a.lastIndex = p, d = a.exec(n), d !== null); ) p = a.lastIndex, a === N ? d[1] === "!--" ? a = ct : d[1] !== void 0 ? a = dt : d[2] !== void 0 ? (At.test(d[2]) && (r = RegExp("</" + d[2], "g")), a = T) : d[3] !== void 0 && (a = T) : a === T ? d[0] === ">" ? (a = r ?? N, l = -1) : d[1] === void 0 ? l = -2 : (l = a.lastIndex - d[2].length, h = d[1], a = d[3] === void 0 ? T : d[3] === '"' ? ut : pt) : a === ut || a === pt ? a = T : a === ct || a === dt ? a = N : (a = T, r = void 0);
|
|
264
|
+
const u = a === T && e[c + 1].startsWith("/>") ? " " : "";
|
|
265
|
+
o += a === N ? n + Mt : l >= 0 ? (i.push(h), n.slice(0, l) + bt + n.slice(l) + C + u) : n + C + (l === -2 ? c : u);
|
|
266
266
|
}
|
|
267
267
|
return [_t(e, o + (e[s] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), i];
|
|
268
268
|
};
|
|
@@ -271,23 +271,23 @@ class B {
|
|
|
271
271
|
let r;
|
|
272
272
|
this.parts = [];
|
|
273
273
|
let o = 0, a = 0;
|
|
274
|
-
const
|
|
275
|
-
if (this.el = B.createElement(
|
|
274
|
+
const c = t.length - 1, n = this.parts, [h, d] = qt(t, s);
|
|
275
|
+
if (this.el = B.createElement(h, i), O.currentNode = this.el.content, s === 2 || s === 3) {
|
|
276
276
|
const l = this.el.content.firstChild;
|
|
277
277
|
l.replaceWith(...l.childNodes);
|
|
278
278
|
}
|
|
279
|
-
for (; (r = O.nextNode()) !== null && n.length <
|
|
279
|
+
for (; (r = O.nextNode()) !== null && n.length < c; ) {
|
|
280
280
|
if (r.nodeType === 1) {
|
|
281
281
|
if (r.hasAttributes()) for (const l of r.getAttributeNames()) if (l.endsWith(bt)) {
|
|
282
|
-
const
|
|
282
|
+
const p = d[a++], u = r.getAttribute(l).split(C), $ = /([.?@])?(.*)/.exec(p);
|
|
283
283
|
n.push({ type: 1, index: o, name: $[2], strings: u, ctor: $[1] === "." ? zt : $[1] === "?" ? Yt : $[1] === "@" ? Kt : V }), r.removeAttribute(l);
|
|
284
284
|
} else l.startsWith(C) && (n.push({ type: 6, index: o }), r.removeAttribute(l));
|
|
285
285
|
if (At.test(r.tagName)) {
|
|
286
|
-
const l = r.textContent.split(C),
|
|
287
|
-
if (
|
|
286
|
+
const l = r.textContent.split(C), p = l.length - 1;
|
|
287
|
+
if (p > 0) {
|
|
288
288
|
r.textContent = K ? K.emptyScript : "";
|
|
289
|
-
for (let u = 0; u <
|
|
290
|
-
r.append(l[
|
|
289
|
+
for (let u = 0; u < p; u++) r.append(l[u], j()), O.nextNode(), n.push({ type: 2, index: ++o });
|
|
290
|
+
r.append(l[p], j());
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
} else if (r.nodeType === 8) if (r.data === vt) n.push({ type: 2, index: o });
|
|
@@ -322,11 +322,11 @@ let Bt = class {
|
|
|
322
322
|
u(t) {
|
|
323
323
|
const { el: { content: s }, parts: i } = this._$AD, r = (t?.creationScope ?? D).importNode(s, !0);
|
|
324
324
|
O.currentNode = r;
|
|
325
|
-
let o = O.nextNode(), a = 0,
|
|
325
|
+
let o = O.nextNode(), a = 0, c = 0, n = i[0];
|
|
326
326
|
for (; n !== void 0; ) {
|
|
327
327
|
if (a === n.index) {
|
|
328
|
-
let
|
|
329
|
-
n.type === 2 ?
|
|
328
|
+
let h;
|
|
329
|
+
n.type === 2 ? h = new I(o, o.nextSibling, this, t) : n.type === 1 ? h = new n.ctor(o, n.name, n.strings, this, t) : n.type === 6 && (h = new Ft(o, this, t)), this._$AV.push(h), n = i[++c];
|
|
330
330
|
}
|
|
331
331
|
a !== n?.index && (o = O.nextNode(), a++);
|
|
332
332
|
}
|
|
@@ -411,9 +411,9 @@ class V {
|
|
|
411
411
|
let a = !1;
|
|
412
412
|
if (o === void 0) t = R(this, t, s, 0), a = !q(t) || t !== this._$AH && t !== x, a && (this._$AH = t);
|
|
413
413
|
else {
|
|
414
|
-
const
|
|
415
|
-
let n,
|
|
416
|
-
for (t = o[0], n = 0; n < o.length - 1; n++)
|
|
414
|
+
const c = t;
|
|
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 === x && (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
|
}
|
|
@@ -509,18 +509,18 @@ const Qt = { attribute: !0, type: String, converter: Y, reflect: !1, hasChanged:
|
|
|
509
509
|
let o = globalThis.litPropertyMetadata.get(r);
|
|
510
510
|
if (o === void 0 && globalThis.litPropertyMetadata.set(r, o = /* @__PURE__ */ new Map()), i === "setter" && ((e = Object.create(e)).wrapped = !0), o.set(s.name, e), i === "accessor") {
|
|
511
511
|
const { name: a } = s;
|
|
512
|
-
return { set(
|
|
512
|
+
return { set(c) {
|
|
513
513
|
const n = t.get.call(this);
|
|
514
|
-
t.set.call(this,
|
|
515
|
-
}, init(
|
|
516
|
-
return
|
|
514
|
+
t.set.call(this, c), this.requestUpdate(a, n, e);
|
|
515
|
+
}, init(c) {
|
|
516
|
+
return c !== void 0 && this.C(a, void 0, e, c), c;
|
|
517
517
|
} };
|
|
518
518
|
}
|
|
519
519
|
if (i === "setter") {
|
|
520
520
|
const { name: a } = s;
|
|
521
|
-
return function(
|
|
521
|
+
return function(c) {
|
|
522
522
|
const n = this[a];
|
|
523
|
-
t.call(this,
|
|
523
|
+
t.call(this, c), this.requestUpdate(a, n, e);
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
526
|
throw Error("Unsupported decorator location: " + i);
|
|
@@ -588,16 +588,16 @@ const { I: ee } = Vt, ft = () => document.createComment(""), L = (e, t, s) => {
|
|
|
588
588
|
const o = i.insertBefore(ft(), r), a = i.insertBefore(ft(), r);
|
|
589
589
|
s = new ee(o, a, e, e.options);
|
|
590
590
|
} else {
|
|
591
|
-
const o = s._$AB.nextSibling, a = s._$AM,
|
|
592
|
-
if (
|
|
591
|
+
const o = s._$AB.nextSibling, a = s._$AM, c = a !== e;
|
|
592
|
+
if (c) {
|
|
593
593
|
let n;
|
|
594
594
|
s._$AQ?.(e), s._$AM = e, s._$AP !== void 0 && (n = e._$AU) !== a._$AU && s._$AP(n);
|
|
595
595
|
}
|
|
596
|
-
if (o !== r ||
|
|
596
|
+
if (o !== r || c) {
|
|
597
597
|
let n = s._$AA;
|
|
598
598
|
for (; n !== o; ) {
|
|
599
|
-
const
|
|
600
|
-
i.insertBefore(n, r), n =
|
|
599
|
+
const h = n.nextSibling;
|
|
600
|
+
i.insertBefore(n, r), n = h;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
}
|
|
@@ -618,7 +618,7 @@ const yt = (e, t, s) => {
|
|
|
618
618
|
s === void 0 ? s = t : t !== void 0 && (i = t);
|
|
619
619
|
const r = [], o = [];
|
|
620
620
|
let a = 0;
|
|
621
|
-
for (const
|
|
621
|
+
for (const c of e) r[a] = i ? i(c, a) : a, o[a] = s(c, a), a++;
|
|
622
622
|
return { values: o, keys: r };
|
|
623
623
|
}
|
|
624
624
|
render(e, t, s) {
|
|
@@ -627,28 +627,28 @@ const yt = (e, t, s) => {
|
|
|
627
627
|
update(e, [t, s, i]) {
|
|
628
628
|
const r = re(e), { values: o, keys: a } = this.dt(t, s, i);
|
|
629
629
|
if (!Array.isArray(r)) return this.ut = a, o;
|
|
630
|
-
const
|
|
631
|
-
let
|
|
632
|
-
for (; l <=
|
|
633
|
-
else if (r[
|
|
634
|
-
else if (
|
|
635
|
-
else if (
|
|
636
|
-
else if (
|
|
637
|
-
else if (
|
|
638
|
-
else if (
|
|
639
|
-
const v =
|
|
630
|
+
const c = this.ut ??= [], n = [];
|
|
631
|
+
let h, d, l = 0, p = r.length - 1, u = 0, $ = o.length - 1;
|
|
632
|
+
for (; l <= p && u <= $; ) if (r[l] === null) l++;
|
|
633
|
+
else if (r[p] === null) p--;
|
|
634
|
+
else if (c[l] === a[u]) n[u] = P(r[l], o[u]), l++, u++;
|
|
635
|
+
else if (c[p] === a[$]) n[$] = P(r[p], o[$]), p--, $--;
|
|
636
|
+
else if (c[l] === a[$]) n[$] = P(r[l], o[$]), L(e, n[$ + 1], r[l]), l++, $--;
|
|
637
|
+
else if (c[p] === a[u]) n[u] = P(r[p], o[u]), L(e, r[l], r[p]), p--, u++;
|
|
638
|
+
else if (h === void 0 && (h = yt(a, u, $), d = yt(c, l, p)), h.has(c[l])) if (h.has(c[p])) {
|
|
639
|
+
const v = d.get(a[u]), A = v !== void 0 ? r[v] : null;
|
|
640
640
|
if (A === null) {
|
|
641
641
|
const w = L(e, r[l]);
|
|
642
642
|
P(w, o[u]), n[u] = w;
|
|
643
643
|
} else n[u] = P(A, o[u]), L(e, r[l], A), r[v] = null;
|
|
644
644
|
u++;
|
|
645
|
-
} else G(r[
|
|
645
|
+
} else G(r[p]), p--;
|
|
646
646
|
else G(r[l]), l++;
|
|
647
647
|
for (; u <= $; ) {
|
|
648
648
|
const v = L(e, n[$ + 1]);
|
|
649
649
|
P(v, o[u]), n[u++] = v;
|
|
650
650
|
}
|
|
651
|
-
for (; l <=
|
|
651
|
+
for (; l <= p; ) {
|
|
652
652
|
const v = r[l++];
|
|
653
653
|
v !== null && G(v);
|
|
654
654
|
}
|
|
@@ -668,10 +668,10 @@ const yt = (e, t, s) => {
|
|
|
668
668
|
};
|
|
669
669
|
return {
|
|
670
670
|
login: async ({
|
|
671
|
-
email:
|
|
672
|
-
password:
|
|
671
|
+
email: h,
|
|
672
|
+
password: d,
|
|
673
673
|
accessToken: l,
|
|
674
|
-
refreshToken:
|
|
674
|
+
refreshToken: p,
|
|
675
675
|
idToken: u
|
|
676
676
|
}) => {
|
|
677
677
|
const $ = await fetch(`${e}${t.login}`, {
|
|
@@ -680,10 +680,10 @@ const yt = (e, t, s) => {
|
|
|
680
680
|
"Content-Type": "application/json"
|
|
681
681
|
},
|
|
682
682
|
body: JSON.stringify({
|
|
683
|
-
email:
|
|
684
|
-
password:
|
|
683
|
+
email: h,
|
|
684
|
+
password: d,
|
|
685
685
|
accessToken: l,
|
|
686
|
-
refreshToken:
|
|
686
|
+
refreshToken: p,
|
|
687
687
|
idToken: u
|
|
688
688
|
})
|
|
689
689
|
});
|
|
@@ -694,64 +694,64 @@ const yt = (e, t, s) => {
|
|
|
694
694
|
return $.json();
|
|
695
695
|
},
|
|
696
696
|
logout: async ({
|
|
697
|
-
accessToken:
|
|
698
|
-
refreshToken:
|
|
697
|
+
accessToken: h,
|
|
698
|
+
refreshToken: d,
|
|
699
699
|
authToken: l
|
|
700
700
|
}) => {
|
|
701
|
-
const
|
|
701
|
+
const p = await fetch(`${e}${t.logout}`, {
|
|
702
702
|
method: "POST",
|
|
703
703
|
headers: {
|
|
704
704
|
"Content-Type": "application/json",
|
|
705
705
|
Authorization: `Bearer ${l}`
|
|
706
706
|
},
|
|
707
707
|
body: JSON.stringify({
|
|
708
|
-
accessToken:
|
|
709
|
-
refreshToken:
|
|
708
|
+
accessToken: h,
|
|
709
|
+
refreshToken: d
|
|
710
710
|
})
|
|
711
711
|
});
|
|
712
|
-
if (!
|
|
713
|
-
const u = await
|
|
712
|
+
if (!p.ok) {
|
|
713
|
+
const u = await p.json();
|
|
714
714
|
throw new Error(u.message || u.error || "Logout failed");
|
|
715
715
|
}
|
|
716
|
-
return
|
|
716
|
+
return p.json();
|
|
717
717
|
},
|
|
718
|
-
refresh: async ({ refreshToken:
|
|
719
|
-
const
|
|
718
|
+
refresh: async ({ refreshToken: h }) => {
|
|
719
|
+
const d = await fetch(`${e}${t.refresh}`, {
|
|
720
720
|
method: "POST",
|
|
721
721
|
headers: {
|
|
722
722
|
"Content-Type": "application/json"
|
|
723
723
|
},
|
|
724
724
|
body: JSON.stringify({
|
|
725
|
-
refreshToken:
|
|
725
|
+
refreshToken: h
|
|
726
726
|
})
|
|
727
727
|
});
|
|
728
|
-
if (!
|
|
729
|
-
const l = await
|
|
728
|
+
if (!d.ok) {
|
|
729
|
+
const l = await d.json();
|
|
730
730
|
throw new Error(l.message || l.error || "Failed to refresh token");
|
|
731
731
|
}
|
|
732
|
-
return
|
|
732
|
+
return d.json();
|
|
733
733
|
},
|
|
734
|
-
requestRegisterOtp: async ({ email:
|
|
735
|
-
const
|
|
734
|
+
requestRegisterOtp: async ({ email: h }) => {
|
|
735
|
+
const d = await fetch(`${e}${t.requestRegisterOtp}`, {
|
|
736
736
|
method: "POST",
|
|
737
737
|
headers: {
|
|
738
738
|
"Content-Type": "application/json"
|
|
739
739
|
},
|
|
740
740
|
body: JSON.stringify({
|
|
741
|
-
email:
|
|
741
|
+
email: h
|
|
742
742
|
})
|
|
743
743
|
});
|
|
744
|
-
if (!
|
|
745
|
-
const l = await
|
|
744
|
+
if (!d.ok) {
|
|
745
|
+
const l = await d.json();
|
|
746
746
|
throw new Error(l.message || l.error || "Failed to request OTP");
|
|
747
747
|
}
|
|
748
|
-
return
|
|
748
|
+
return d.json();
|
|
749
749
|
},
|
|
750
750
|
register: async ({
|
|
751
|
-
email:
|
|
752
|
-
password:
|
|
751
|
+
email: h,
|
|
752
|
+
password: d,
|
|
753
753
|
phone_number: l,
|
|
754
|
-
family_name:
|
|
754
|
+
family_name: p,
|
|
755
755
|
given_name: u,
|
|
756
756
|
code: $
|
|
757
757
|
}) => {
|
|
@@ -761,10 +761,10 @@ const yt = (e, t, s) => {
|
|
|
761
761
|
"Content-Type": "application/json"
|
|
762
762
|
},
|
|
763
763
|
body: JSON.stringify({
|
|
764
|
-
email:
|
|
765
|
-
password:
|
|
764
|
+
email: h,
|
|
765
|
+
password: d,
|
|
766
766
|
phone_number: l,
|
|
767
|
-
family_name:
|
|
767
|
+
family_name: p,
|
|
768
768
|
given_name: u,
|
|
769
769
|
code: $
|
|
770
770
|
})
|
|
@@ -775,43 +775,43 @@ const yt = (e, t, s) => {
|
|
|
775
775
|
}
|
|
776
776
|
return v.json();
|
|
777
777
|
},
|
|
778
|
-
requestResetPassword: async ({ email:
|
|
779
|
-
const
|
|
778
|
+
requestResetPassword: async ({ email: h }) => {
|
|
779
|
+
const d = await fetch(`${e}${t.requestResetPassword}`, {
|
|
780
780
|
method: "POST",
|
|
781
781
|
headers: {
|
|
782
782
|
"Content-Type": "application/json"
|
|
783
783
|
},
|
|
784
784
|
body: JSON.stringify({
|
|
785
|
-
email:
|
|
785
|
+
email: h
|
|
786
786
|
})
|
|
787
787
|
});
|
|
788
|
-
if (!
|
|
789
|
-
const l = await
|
|
788
|
+
if (!d.ok) {
|
|
789
|
+
const l = await d.json();
|
|
790
790
|
throw new Error(l.message || l.error || "Failed to request password reset");
|
|
791
791
|
}
|
|
792
|
-
return
|
|
792
|
+
return d.json();
|
|
793
793
|
},
|
|
794
794
|
resetPassword: async ({
|
|
795
|
-
email:
|
|
796
|
-
otp:
|
|
795
|
+
email: h,
|
|
796
|
+
otp: d,
|
|
797
797
|
newPassword: l
|
|
798
798
|
}) => {
|
|
799
|
-
const
|
|
799
|
+
const p = await fetch(`${e}${t.resetPassword}`, {
|
|
800
800
|
method: "POST",
|
|
801
801
|
headers: {
|
|
802
802
|
"Content-Type": "application/json"
|
|
803
803
|
},
|
|
804
804
|
body: JSON.stringify({
|
|
805
|
-
email:
|
|
806
|
-
otp:
|
|
805
|
+
email: h,
|
|
806
|
+
otp: d,
|
|
807
807
|
newPassword: l
|
|
808
808
|
})
|
|
809
809
|
});
|
|
810
|
-
if (!
|
|
811
|
-
const u = await
|
|
810
|
+
if (!p.ok) {
|
|
811
|
+
const u = await p.json();
|
|
812
812
|
throw new Error(u.message || u.error || "Failed to reset password");
|
|
813
813
|
}
|
|
814
|
-
return
|
|
814
|
+
return p.json();
|
|
815
815
|
}
|
|
816
816
|
};
|
|
817
817
|
}, J = {
|
|
@@ -825,33 +825,33 @@ const yt = (e, t, s) => {
|
|
|
825
825
|
sameSite: "lax",
|
|
826
826
|
path: "/"
|
|
827
827
|
}, ne = () => {
|
|
828
|
-
const e = (n,
|
|
828
|
+
const e = (n, h, d = {}) => {
|
|
829
829
|
const {
|
|
830
830
|
maxAge: l,
|
|
831
|
-
path:
|
|
831
|
+
path: p = "/",
|
|
832
832
|
secure: u = window.location.protocol === "https:",
|
|
833
833
|
sameSite: $ = "lax",
|
|
834
834
|
domain: v
|
|
835
|
-
} =
|
|
836
|
-
let A = `${encodeURIComponent(n)}=${encodeURIComponent(
|
|
837
|
-
l !== void 0 && (A += `; Max-Age=${l}`), A += `; Path=${
|
|
835
|
+
} = d;
|
|
836
|
+
let A = `${encodeURIComponent(n)}=${encodeURIComponent(h)}`;
|
|
837
|
+
l !== void 0 && (A += `; Max-Age=${l}`), A += `; Path=${p}`, u && (A += "; Secure"), A += `; SameSite=${$}`, v && (A += `; Domain=${v}`), document.cookie = A;
|
|
838
838
|
}, t = (n) => {
|
|
839
|
-
const
|
|
840
|
-
for (let l = 0; l <
|
|
841
|
-
let
|
|
842
|
-
for (;
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
return decodeURIComponent(
|
|
839
|
+
const h = encodeURIComponent(n) + "=", d = document.cookie.split(";");
|
|
840
|
+
for (let l = 0; l < d.length; l++) {
|
|
841
|
+
let p = d[l];
|
|
842
|
+
for (; p.charAt(0) === " "; )
|
|
843
|
+
p = p.substring(1);
|
|
844
|
+
if (p.indexOf(h) === 0)
|
|
845
|
+
return decodeURIComponent(p.substring(h.length));
|
|
846
846
|
}
|
|
847
847
|
return null;
|
|
848
|
-
}, s = (n,
|
|
848
|
+
}, s = (n, h = {}) => {
|
|
849
849
|
e(n, "", {
|
|
850
|
-
...
|
|
850
|
+
...h,
|
|
851
851
|
maxAge: -1
|
|
852
852
|
});
|
|
853
|
-
}, i = (n) => t(n) !== null, r = (n,
|
|
854
|
-
e(J[n],
|
|
853
|
+
}, i = (n) => t(n) !== null, r = (n, h) => {
|
|
854
|
+
e(J[n], h, ae);
|
|
855
855
|
}, o = (n) => t(J[n]), a = (n) => {
|
|
856
856
|
s(J[n]);
|
|
857
857
|
};
|
|
@@ -885,17 +885,17 @@ const yt = (e, t, s) => {
|
|
|
885
885
|
}, a = (w) => {
|
|
886
886
|
const _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", k = new Uint8Array(w);
|
|
887
887
|
return crypto.getRandomValues(k), Array.from(k).map((E) => _[E % _.length]).join("");
|
|
888
|
-
},
|
|
888
|
+
}, c = async (w) => {
|
|
889
889
|
const k = new TextEncoder().encode(w), E = await crypto.subtle.digest("SHA-256", k);
|
|
890
890
|
return btoa(String.fromCharCode(...new Uint8Array(E))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
891
891
|
}, n = async () => {
|
|
892
|
-
const w = a(128), _ = await
|
|
892
|
+
const w = a(128), _ = await c(w);
|
|
893
893
|
return sessionStorage.setItem("pkce_code_verifier", w), { codeVerifier: w, codeChallenge: _ };
|
|
894
|
-
},
|
|
894
|
+
}, h = () => {
|
|
895
895
|
const w = a(32);
|
|
896
896
|
return sessionStorage.setItem("oauth_state", w), w;
|
|
897
|
-
},
|
|
898
|
-
const { codeChallenge: w } = await n(), _ =
|
|
897
|
+
}, d = async () => {
|
|
898
|
+
const { codeChallenge: w } = await n(), _ = h(), k = new URLSearchParams({
|
|
899
899
|
response_type: "code",
|
|
900
900
|
client_id: o.clientId,
|
|
901
901
|
redirect_uri: o.redirectUri,
|
|
@@ -908,10 +908,10 @@ const yt = (e, t, s) => {
|
|
|
908
908
|
});
|
|
909
909
|
return `${o.domain}/oauth2/authorize?${k.toString()}`;
|
|
910
910
|
}, l = async () => {
|
|
911
|
-
const w = await
|
|
911
|
+
const w = await d();
|
|
912
912
|
window.location.href = w;
|
|
913
|
-
},
|
|
914
|
-
const { codeChallenge: w } = await n(), _ =
|
|
913
|
+
}, p = async () => {
|
|
914
|
+
const { codeChallenge: w } = await n(), _ = h(), k = new URLSearchParams({
|
|
915
915
|
response_type: "code",
|
|
916
916
|
client_id: o.clientId,
|
|
917
917
|
redirect_uri: o.redirectUri,
|
|
@@ -923,7 +923,7 @@ const yt = (e, t, s) => {
|
|
|
923
923
|
});
|
|
924
924
|
return `${o.domain}/oauth2/authorize?${k.toString()}`;
|
|
925
925
|
}, u = async () => {
|
|
926
|
-
const w = await
|
|
926
|
+
const w = await p();
|
|
927
927
|
window.location.href = w;
|
|
928
928
|
}, $ = (w) => {
|
|
929
929
|
const _ = sessionStorage.getItem("oauth_state");
|
|
@@ -1466,10 +1466,20 @@ var pe = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, y = (e, t,
|
|
|
1466
1466
|
(a = e[o]) && (r = (i ? a(t, s, r) : a(r)) || r);
|
|
1467
1467
|
return i && r && pe(t, s, r), r;
|
|
1468
1468
|
};
|
|
1469
|
-
const ge = [
|
|
1469
|
+
const ge = [
|
|
1470
|
+
"code",
|
|
1471
|
+
"state",
|
|
1472
|
+
"error",
|
|
1473
|
+
"error_description",
|
|
1474
|
+
"access_token",
|
|
1475
|
+
"id_token",
|
|
1476
|
+
"refresh_token",
|
|
1477
|
+
"token_type",
|
|
1478
|
+
"expires_in"
|
|
1479
|
+
];
|
|
1470
1480
|
let m = class extends H {
|
|
1471
1481
|
constructor() {
|
|
1472
|
-
super(...arguments), this.open = !1, this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.size = "sm", this.theme = "light", this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isClosing = !1, this.isVisible = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.lastDragEndTime = 0, this.cookies = ne(), this.scrollPosition = 0, this.transitionDuration = 300, this.hasHandledOAuthCallback = !1, this.boundKeyHandler = (e) => {
|
|
1482
|
+
super(...arguments), this.open = !1, this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.oauthSpaDomain = "", this.size = "sm", this.theme = "light", this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isClosing = !1, this.isVisible = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.lastDragEndTime = 0, this.cookies = ne(), this.scrollPosition = 0, this.transitionDuration = 300, this.hasHandledOAuthCallback = !1, this.boundKeyHandler = (e) => {
|
|
1473
1483
|
e.key === "Escape" && this.isVisible && this.handleClose();
|
|
1474
1484
|
}, this.baseUrlErrorMessage = "Authentication service is not configured correctly. Please add an API domain or contact support.", this.handleClose = () => {
|
|
1475
1485
|
this.isClosing || !this.isVisible || (this.cleanupInlineStyles(), this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.isClosing = !0, setTimeout(() => {
|
|
@@ -1493,9 +1503,9 @@ let m = class extends H {
|
|
|
1493
1503
|
e > 5 && (this.lastDragEndTime = Date.now());
|
|
1494
1504
|
const t = Date.now() - this.dragStartTime, s = e / t, i = this.modalContainer.offsetHeight, r = Math.max(150, i * 0.3), a = e > r || s > 0.5;
|
|
1495
1505
|
this.isDragging = !1;
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
|
|
1506
|
+
const c = this.modalContainer, n = a ? i + i * 0.1 : 0;
|
|
1507
|
+
c.style.transition = "none", c.style.transform = `translateY(${e}px)`, requestAnimationFrame(() => {
|
|
1508
|
+
c.style.transition = `transform ${this.transitionDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`, c.style.transform = `translateY(${n}px)`;
|
|
1499
1509
|
}), setTimeout(() => {
|
|
1500
1510
|
this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, a ? (this.isVisible = !1, this.open = !1) : this.modalContainer && (this.modalContainer.style.transition = "", this.modalContainer.style.transform = "");
|
|
1501
1511
|
}, this.transitionDuration);
|
|
@@ -1693,31 +1703,41 @@ let m = class extends H {
|
|
|
1693
1703
|
}
|
|
1694
1704
|
}
|
|
1695
1705
|
async handleOAuthCallbackIfPresent() {
|
|
1696
|
-
const e = new URLSearchParams(window.location.search), t = e.get("
|
|
1697
|
-
if (
|
|
1706
|
+
const e = new URLSearchParams(window.location.search), t = e.get("access_token"), s = e.get("id_token"), i = e.get("refresh_token"), r = e.get("code"), o = e.get("state"), a = e.get("error"), c = e.get("error_description");
|
|
1707
|
+
if ((t || s || r || a) && !this.hasHandledOAuthCallback) {
|
|
1698
1708
|
if (!this.hasApiBaseUrl()) {
|
|
1699
1709
|
this.error = this.baseUrlErrorMessage;
|
|
1700
1710
|
return;
|
|
1701
1711
|
}
|
|
1702
1712
|
this.hasHandledOAuthCallback = !0, this.isLoading = !0, this.error = "";
|
|
1703
1713
|
try {
|
|
1704
|
-
if (
|
|
1705
|
-
throw new Error(
|
|
1706
|
-
if (
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1714
|
+
if (a)
|
|
1715
|
+
throw new Error(c || `OAuth error: ${a}`);
|
|
1716
|
+
if (t && s && i) {
|
|
1717
|
+
const { accessToken: h, idToken: d, refreshToken: l } = await this.getApiService().login({
|
|
1718
|
+
accessToken: t,
|
|
1719
|
+
refreshToken: i,
|
|
1720
|
+
idToken: s
|
|
1721
|
+
});
|
|
1722
|
+
this.setAuthTokens(h, d, l ?? i);
|
|
1723
|
+
} else if (r && o) {
|
|
1724
|
+
if (!this.isOAuthConfigured())
|
|
1725
|
+
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1726
|
+
const h = this.getOAuthService();
|
|
1727
|
+
if (!h)
|
|
1728
|
+
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1729
|
+
if (!h.validateState(o))
|
|
1730
|
+
throw new Error("Invalid state parameter. Please try signing in again.");
|
|
1731
|
+
const d = await h.exchangeCodeForTokens(r), { accessToken: l, idToken: p, refreshToken: u } = await this.getApiService().login({
|
|
1732
|
+
accessToken: d.access_token,
|
|
1733
|
+
refreshToken: d.refresh_token,
|
|
1734
|
+
idToken: d.id_token
|
|
1735
|
+
});
|
|
1736
|
+
this.setAuthTokens(l, p, u ?? d.refresh_token);
|
|
1737
|
+
} else
|
|
1738
|
+
throw new Error("Missing required OAuth parameters");
|
|
1739
|
+
} catch (h) {
|
|
1740
|
+
this.error = h.message || "An unexpected error occurred during authentication";
|
|
1721
1741
|
} finally {
|
|
1722
1742
|
this.stripOAuthParamsFromUrl(), this.isLoading = !1;
|
|
1723
1743
|
}
|
|
@@ -1789,10 +1809,18 @@ let m = class extends H {
|
|
|
1789
1809
|
}
|
|
1790
1810
|
// OAuth handlers
|
|
1791
1811
|
handleGoogleSignIn() {
|
|
1792
|
-
this.
|
|
1812
|
+
this.handleOAuthSignIn("google");
|
|
1793
1813
|
}
|
|
1794
1814
|
handleAppleSignIn() {
|
|
1795
|
-
this.
|
|
1815
|
+
this.handleOAuthSignIn("apple");
|
|
1816
|
+
}
|
|
1817
|
+
handleOAuthSignIn(e) {
|
|
1818
|
+
if (this.oauthSpaDomain?.trim()) {
|
|
1819
|
+
const t = this.oauthSpaDomain.trim(), s = t.startsWith("http://") || t.startsWith("https://") ? t : `https://${t}`, i = s.endsWith("/") ? s.slice(0, -1) : s, r = window.location.href, o = `${i}?return_url=${encodeURIComponent(r)}&provider=${e}`;
|
|
1820
|
+
window.location.href = o;
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
e === "google" ? this.getOAuthService()?.redirectToGoogleAuth() : this.getOAuthService()?.redirectToAppleAuth();
|
|
1796
1824
|
}
|
|
1797
1825
|
// OTP input handlers
|
|
1798
1826
|
handleOtpInput(e, t, s) {
|
|
@@ -2387,6 +2415,9 @@ y([
|
|
|
2387
2415
|
y([
|
|
2388
2416
|
S({ type: String, attribute: "oauth-redirect-uri" })
|
|
2389
2417
|
], m.prototype, "oauthRedirectUri", 2);
|
|
2418
|
+
y([
|
|
2419
|
+
S({ type: String, attribute: "oauth-spa-domain" })
|
|
2420
|
+
], m.prototype, "oauthSpaDomain", 2);
|
|
2390
2421
|
y([
|
|
2391
2422
|
S({ type: String, attribute: "size" })
|
|
2392
2423
|
], m.prototype, "size", 2);
|
|
@@ -16,6 +16,7 @@ export declare class CalsAuth extends LitElement {
|
|
|
16
16
|
oauthUserPoolId: string;
|
|
17
17
|
oauthClientId: string;
|
|
18
18
|
oauthRedirectUri: string;
|
|
19
|
+
oauthSpaDomain: string;
|
|
19
20
|
size: 'sm' | 'md' | 'lg';
|
|
20
21
|
theme: 'light' | 'dark';
|
|
21
22
|
private mode;
|
|
@@ -89,6 +90,7 @@ export declare class CalsAuth extends LitElement {
|
|
|
89
90
|
logout(): Promise<void>;
|
|
90
91
|
private handleGoogleSignIn;
|
|
91
92
|
private handleAppleSignIn;
|
|
93
|
+
private handleOAuthSignIn;
|
|
92
94
|
private handleOtpInput;
|
|
93
95
|
private handleOtpKeydown;
|
|
94
96
|
private handleOtpPaste;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class CalsAuth extends LitElement {
|
|
|
16
16
|
oauthUserPoolId: string;
|
|
17
17
|
oauthClientId: string;
|
|
18
18
|
oauthRedirectUri: string;
|
|
19
|
+
oauthSpaDomain: string;
|
|
19
20
|
size: 'sm' | 'md' | 'lg';
|
|
20
21
|
theme: 'light' | 'dark';
|
|
21
22
|
private mode;
|
|
@@ -89,6 +90,7 @@ export declare class CalsAuth extends LitElement {
|
|
|
89
90
|
logout(): Promise<void>;
|
|
90
91
|
private handleGoogleSignIn;
|
|
91
92
|
private handleAppleSignIn;
|
|
93
|
+
private handleOAuthSignIn;
|
|
92
94
|
private handleOtpInput;
|
|
93
95
|
private handleOtpKeydown;
|
|
94
96
|
private handleOtpPaste;
|
package/dist/index.js
CHANGED
|
@@ -85,8 +85,8 @@ let U = class extends HTMLElement {
|
|
|
85
85
|
this[s] = a;
|
|
86
86
|
} };
|
|
87
87
|
return { get: r, set(a) {
|
|
88
|
-
const
|
|
89
|
-
o?.call(this, a), this.requestUpdate(t,
|
|
88
|
+
const c = r?.call(this);
|
|
89
|
+
o?.call(this, a), this.requestUpdate(t, c, i);
|
|
90
90
|
}, configurable: !0, enumerable: !0 };
|
|
91
91
|
}
|
|
92
92
|
static getPropertyOptions(t) {
|
|
@@ -171,8 +171,8 @@ let U = class extends HTMLElement {
|
|
|
171
171
|
if (r !== void 0 && this._$Em !== r) {
|
|
172
172
|
const o = i.getPropertyOptions(r), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : Y;
|
|
173
173
|
this._$Em = r;
|
|
174
|
-
const
|
|
175
|
-
this[r] =
|
|
174
|
+
const c = a.fromAttribute(s, o.type);
|
|
175
|
+
this[r] = c ?? this._$Ej?.get(r) ?? c, this._$Em = null;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
requestUpdate(t, s, i) {
|
|
@@ -208,8 +208,8 @@ let U = class extends HTMLElement {
|
|
|
208
208
|
}
|
|
209
209
|
const i = this.constructor.elementProperties;
|
|
210
210
|
if (i.size > 0) for (const [r, o] of i) {
|
|
211
|
-
const { wrapped: a } = o,
|
|
212
|
-
a !== !0 || this._$AL.has(r) ||
|
|
211
|
+
const { wrapped: a } = o, c = this[r];
|
|
212
|
+
a !== !0 || this._$AL.has(r) || c === void 0 || this.C(r, void 0, o, c);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
let t = !1;
|
|
@@ -257,12 +257,12 @@ function _t(e, t) {
|
|
|
257
257
|
const qt = (e, t) => {
|
|
258
258
|
const s = e.length - 1, i = [];
|
|
259
259
|
let r, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = N;
|
|
260
|
-
for (let
|
|
261
|
-
const n = e[
|
|
262
|
-
let
|
|
263
|
-
for (;
|
|
264
|
-
const u = a === T && e[
|
|
265
|
-
o += a === N ? n + Mt : l >= 0 ? (i.push(
|
|
260
|
+
for (let c = 0; c < s; c++) {
|
|
261
|
+
const n = e[c];
|
|
262
|
+
let h, d, l = -1, p = 0;
|
|
263
|
+
for (; p < n.length && (a.lastIndex = p, d = a.exec(n), d !== null); ) p = a.lastIndex, a === N ? d[1] === "!--" ? a = ct : d[1] !== void 0 ? a = dt : d[2] !== void 0 ? (At.test(d[2]) && (r = RegExp("</" + d[2], "g")), a = T) : d[3] !== void 0 && (a = T) : a === T ? d[0] === ">" ? (a = r ?? N, l = -1) : d[1] === void 0 ? l = -2 : (l = a.lastIndex - d[2].length, h = d[1], a = d[3] === void 0 ? T : d[3] === '"' ? ut : pt) : a === ut || a === pt ? a = T : a === ct || a === dt ? a = N : (a = T, r = void 0);
|
|
264
|
+
const u = a === T && e[c + 1].startsWith("/>") ? " " : "";
|
|
265
|
+
o += a === N ? n + Mt : l >= 0 ? (i.push(h), n.slice(0, l) + bt + n.slice(l) + C + u) : n + C + (l === -2 ? c : u);
|
|
266
266
|
}
|
|
267
267
|
return [_t(e, o + (e[s] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), i];
|
|
268
268
|
};
|
|
@@ -271,23 +271,23 @@ class B {
|
|
|
271
271
|
let r;
|
|
272
272
|
this.parts = [];
|
|
273
273
|
let o = 0, a = 0;
|
|
274
|
-
const
|
|
275
|
-
if (this.el = B.createElement(
|
|
274
|
+
const c = t.length - 1, n = this.parts, [h, d] = qt(t, s);
|
|
275
|
+
if (this.el = B.createElement(h, i), O.currentNode = this.el.content, s === 2 || s === 3) {
|
|
276
276
|
const l = this.el.content.firstChild;
|
|
277
277
|
l.replaceWith(...l.childNodes);
|
|
278
278
|
}
|
|
279
|
-
for (; (r = O.nextNode()) !== null && n.length <
|
|
279
|
+
for (; (r = O.nextNode()) !== null && n.length < c; ) {
|
|
280
280
|
if (r.nodeType === 1) {
|
|
281
281
|
if (r.hasAttributes()) for (const l of r.getAttributeNames()) if (l.endsWith(bt)) {
|
|
282
|
-
const
|
|
282
|
+
const p = d[a++], u = r.getAttribute(l).split(C), $ = /([.?@])?(.*)/.exec(p);
|
|
283
283
|
n.push({ type: 1, index: o, name: $[2], strings: u, ctor: $[1] === "." ? zt : $[1] === "?" ? Yt : $[1] === "@" ? Kt : V }), r.removeAttribute(l);
|
|
284
284
|
} else l.startsWith(C) && (n.push({ type: 6, index: o }), r.removeAttribute(l));
|
|
285
285
|
if (At.test(r.tagName)) {
|
|
286
|
-
const l = r.textContent.split(C),
|
|
287
|
-
if (
|
|
286
|
+
const l = r.textContent.split(C), p = l.length - 1;
|
|
287
|
+
if (p > 0) {
|
|
288
288
|
r.textContent = K ? K.emptyScript : "";
|
|
289
|
-
for (let u = 0; u <
|
|
290
|
-
r.append(l[
|
|
289
|
+
for (let u = 0; u < p; u++) r.append(l[u], j()), O.nextNode(), n.push({ type: 2, index: ++o });
|
|
290
|
+
r.append(l[p], j());
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
} else if (r.nodeType === 8) if (r.data === vt) n.push({ type: 2, index: o });
|
|
@@ -322,11 +322,11 @@ let Bt = class {
|
|
|
322
322
|
u(t) {
|
|
323
323
|
const { el: { content: s }, parts: i } = this._$AD, r = (t?.creationScope ?? D).importNode(s, !0);
|
|
324
324
|
O.currentNode = r;
|
|
325
|
-
let o = O.nextNode(), a = 0,
|
|
325
|
+
let o = O.nextNode(), a = 0, c = 0, n = i[0];
|
|
326
326
|
for (; n !== void 0; ) {
|
|
327
327
|
if (a === n.index) {
|
|
328
|
-
let
|
|
329
|
-
n.type === 2 ?
|
|
328
|
+
let h;
|
|
329
|
+
n.type === 2 ? h = new I(o, o.nextSibling, this, t) : n.type === 1 ? h = new n.ctor(o, n.name, n.strings, this, t) : n.type === 6 && (h = new Ft(o, this, t)), this._$AV.push(h), n = i[++c];
|
|
330
330
|
}
|
|
331
331
|
a !== n?.index && (o = O.nextNode(), a++);
|
|
332
332
|
}
|
|
@@ -411,9 +411,9 @@ class V {
|
|
|
411
411
|
let a = !1;
|
|
412
412
|
if (o === void 0) t = R(this, t, s, 0), a = !q(t) || t !== this._$AH && t !== x, a && (this._$AH = t);
|
|
413
413
|
else {
|
|
414
|
-
const
|
|
415
|
-
let n,
|
|
416
|
-
for (t = o[0], n = 0; n < o.length - 1; n++)
|
|
414
|
+
const c = t;
|
|
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 === x && (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
|
}
|
|
@@ -509,18 +509,18 @@ const Qt = { attribute: !0, type: String, converter: Y, reflect: !1, hasChanged:
|
|
|
509
509
|
let o = globalThis.litPropertyMetadata.get(r);
|
|
510
510
|
if (o === void 0 && globalThis.litPropertyMetadata.set(r, o = /* @__PURE__ */ new Map()), i === "setter" && ((e = Object.create(e)).wrapped = !0), o.set(s.name, e), i === "accessor") {
|
|
511
511
|
const { name: a } = s;
|
|
512
|
-
return { set(
|
|
512
|
+
return { set(c) {
|
|
513
513
|
const n = t.get.call(this);
|
|
514
|
-
t.set.call(this,
|
|
515
|
-
}, init(
|
|
516
|
-
return
|
|
514
|
+
t.set.call(this, c), this.requestUpdate(a, n, e);
|
|
515
|
+
}, init(c) {
|
|
516
|
+
return c !== void 0 && this.C(a, void 0, e, c), c;
|
|
517
517
|
} };
|
|
518
518
|
}
|
|
519
519
|
if (i === "setter") {
|
|
520
520
|
const { name: a } = s;
|
|
521
|
-
return function(
|
|
521
|
+
return function(c) {
|
|
522
522
|
const n = this[a];
|
|
523
|
-
t.call(this,
|
|
523
|
+
t.call(this, c), this.requestUpdate(a, n, e);
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
526
|
throw Error("Unsupported decorator location: " + i);
|
|
@@ -588,16 +588,16 @@ const { I: ee } = Vt, ft = () => document.createComment(""), L = (e, t, s) => {
|
|
|
588
588
|
const o = i.insertBefore(ft(), r), a = i.insertBefore(ft(), r);
|
|
589
589
|
s = new ee(o, a, e, e.options);
|
|
590
590
|
} else {
|
|
591
|
-
const o = s._$AB.nextSibling, a = s._$AM,
|
|
592
|
-
if (
|
|
591
|
+
const o = s._$AB.nextSibling, a = s._$AM, c = a !== e;
|
|
592
|
+
if (c) {
|
|
593
593
|
let n;
|
|
594
594
|
s._$AQ?.(e), s._$AM = e, s._$AP !== void 0 && (n = e._$AU) !== a._$AU && s._$AP(n);
|
|
595
595
|
}
|
|
596
|
-
if (o !== r ||
|
|
596
|
+
if (o !== r || c) {
|
|
597
597
|
let n = s._$AA;
|
|
598
598
|
for (; n !== o; ) {
|
|
599
|
-
const
|
|
600
|
-
i.insertBefore(n, r), n =
|
|
599
|
+
const h = n.nextSibling;
|
|
600
|
+
i.insertBefore(n, r), n = h;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
}
|
|
@@ -618,7 +618,7 @@ const yt = (e, t, s) => {
|
|
|
618
618
|
s === void 0 ? s = t : t !== void 0 && (i = t);
|
|
619
619
|
const r = [], o = [];
|
|
620
620
|
let a = 0;
|
|
621
|
-
for (const
|
|
621
|
+
for (const c of e) r[a] = i ? i(c, a) : a, o[a] = s(c, a), a++;
|
|
622
622
|
return { values: o, keys: r };
|
|
623
623
|
}
|
|
624
624
|
render(e, t, s) {
|
|
@@ -627,28 +627,28 @@ const yt = (e, t, s) => {
|
|
|
627
627
|
update(e, [t, s, i]) {
|
|
628
628
|
const r = re(e), { values: o, keys: a } = this.dt(t, s, i);
|
|
629
629
|
if (!Array.isArray(r)) return this.ut = a, o;
|
|
630
|
-
const
|
|
631
|
-
let
|
|
632
|
-
for (; l <=
|
|
633
|
-
else if (r[
|
|
634
|
-
else if (
|
|
635
|
-
else if (
|
|
636
|
-
else if (
|
|
637
|
-
else if (
|
|
638
|
-
else if (
|
|
639
|
-
const v =
|
|
630
|
+
const c = this.ut ??= [], n = [];
|
|
631
|
+
let h, d, l = 0, p = r.length - 1, u = 0, $ = o.length - 1;
|
|
632
|
+
for (; l <= p && u <= $; ) if (r[l] === null) l++;
|
|
633
|
+
else if (r[p] === null) p--;
|
|
634
|
+
else if (c[l] === a[u]) n[u] = P(r[l], o[u]), l++, u++;
|
|
635
|
+
else if (c[p] === a[$]) n[$] = P(r[p], o[$]), p--, $--;
|
|
636
|
+
else if (c[l] === a[$]) n[$] = P(r[l], o[$]), L(e, n[$ + 1], r[l]), l++, $--;
|
|
637
|
+
else if (c[p] === a[u]) n[u] = P(r[p], o[u]), L(e, r[l], r[p]), p--, u++;
|
|
638
|
+
else if (h === void 0 && (h = yt(a, u, $), d = yt(c, l, p)), h.has(c[l])) if (h.has(c[p])) {
|
|
639
|
+
const v = d.get(a[u]), A = v !== void 0 ? r[v] : null;
|
|
640
640
|
if (A === null) {
|
|
641
641
|
const w = L(e, r[l]);
|
|
642
642
|
P(w, o[u]), n[u] = w;
|
|
643
643
|
} else n[u] = P(A, o[u]), L(e, r[l], A), r[v] = null;
|
|
644
644
|
u++;
|
|
645
|
-
} else G(r[
|
|
645
|
+
} else G(r[p]), p--;
|
|
646
646
|
else G(r[l]), l++;
|
|
647
647
|
for (; u <= $; ) {
|
|
648
648
|
const v = L(e, n[$ + 1]);
|
|
649
649
|
P(v, o[u]), n[u++] = v;
|
|
650
650
|
}
|
|
651
|
-
for (; l <=
|
|
651
|
+
for (; l <= p; ) {
|
|
652
652
|
const v = r[l++];
|
|
653
653
|
v !== null && G(v);
|
|
654
654
|
}
|
|
@@ -668,10 +668,10 @@ const yt = (e, t, s) => {
|
|
|
668
668
|
};
|
|
669
669
|
return {
|
|
670
670
|
login: async ({
|
|
671
|
-
email:
|
|
672
|
-
password:
|
|
671
|
+
email: h,
|
|
672
|
+
password: d,
|
|
673
673
|
accessToken: l,
|
|
674
|
-
refreshToken:
|
|
674
|
+
refreshToken: p,
|
|
675
675
|
idToken: u
|
|
676
676
|
}) => {
|
|
677
677
|
const $ = await fetch(`${e}${t.login}`, {
|
|
@@ -680,10 +680,10 @@ const yt = (e, t, s) => {
|
|
|
680
680
|
"Content-Type": "application/json"
|
|
681
681
|
},
|
|
682
682
|
body: JSON.stringify({
|
|
683
|
-
email:
|
|
684
|
-
password:
|
|
683
|
+
email: h,
|
|
684
|
+
password: d,
|
|
685
685
|
accessToken: l,
|
|
686
|
-
refreshToken:
|
|
686
|
+
refreshToken: p,
|
|
687
687
|
idToken: u
|
|
688
688
|
})
|
|
689
689
|
});
|
|
@@ -694,64 +694,64 @@ const yt = (e, t, s) => {
|
|
|
694
694
|
return $.json();
|
|
695
695
|
},
|
|
696
696
|
logout: async ({
|
|
697
|
-
accessToken:
|
|
698
|
-
refreshToken:
|
|
697
|
+
accessToken: h,
|
|
698
|
+
refreshToken: d,
|
|
699
699
|
authToken: l
|
|
700
700
|
}) => {
|
|
701
|
-
const
|
|
701
|
+
const p = await fetch(`${e}${t.logout}`, {
|
|
702
702
|
method: "POST",
|
|
703
703
|
headers: {
|
|
704
704
|
"Content-Type": "application/json",
|
|
705
705
|
Authorization: `Bearer ${l}`
|
|
706
706
|
},
|
|
707
707
|
body: JSON.stringify({
|
|
708
|
-
accessToken:
|
|
709
|
-
refreshToken:
|
|
708
|
+
accessToken: h,
|
|
709
|
+
refreshToken: d
|
|
710
710
|
})
|
|
711
711
|
});
|
|
712
|
-
if (!
|
|
713
|
-
const u = await
|
|
712
|
+
if (!p.ok) {
|
|
713
|
+
const u = await p.json();
|
|
714
714
|
throw new Error(u.message || u.error || "Logout failed");
|
|
715
715
|
}
|
|
716
|
-
return
|
|
716
|
+
return p.json();
|
|
717
717
|
},
|
|
718
|
-
refresh: async ({ refreshToken:
|
|
719
|
-
const
|
|
718
|
+
refresh: async ({ refreshToken: h }) => {
|
|
719
|
+
const d = await fetch(`${e}${t.refresh}`, {
|
|
720
720
|
method: "POST",
|
|
721
721
|
headers: {
|
|
722
722
|
"Content-Type": "application/json"
|
|
723
723
|
},
|
|
724
724
|
body: JSON.stringify({
|
|
725
|
-
refreshToken:
|
|
725
|
+
refreshToken: h
|
|
726
726
|
})
|
|
727
727
|
});
|
|
728
|
-
if (!
|
|
729
|
-
const l = await
|
|
728
|
+
if (!d.ok) {
|
|
729
|
+
const l = await d.json();
|
|
730
730
|
throw new Error(l.message || l.error || "Failed to refresh token");
|
|
731
731
|
}
|
|
732
|
-
return
|
|
732
|
+
return d.json();
|
|
733
733
|
},
|
|
734
|
-
requestRegisterOtp: async ({ email:
|
|
735
|
-
const
|
|
734
|
+
requestRegisterOtp: async ({ email: h }) => {
|
|
735
|
+
const d = await fetch(`${e}${t.requestRegisterOtp}`, {
|
|
736
736
|
method: "POST",
|
|
737
737
|
headers: {
|
|
738
738
|
"Content-Type": "application/json"
|
|
739
739
|
},
|
|
740
740
|
body: JSON.stringify({
|
|
741
|
-
email:
|
|
741
|
+
email: h
|
|
742
742
|
})
|
|
743
743
|
});
|
|
744
|
-
if (!
|
|
745
|
-
const l = await
|
|
744
|
+
if (!d.ok) {
|
|
745
|
+
const l = await d.json();
|
|
746
746
|
throw new Error(l.message || l.error || "Failed to request OTP");
|
|
747
747
|
}
|
|
748
|
-
return
|
|
748
|
+
return d.json();
|
|
749
749
|
},
|
|
750
750
|
register: async ({
|
|
751
|
-
email:
|
|
752
|
-
password:
|
|
751
|
+
email: h,
|
|
752
|
+
password: d,
|
|
753
753
|
phone_number: l,
|
|
754
|
-
family_name:
|
|
754
|
+
family_name: p,
|
|
755
755
|
given_name: u,
|
|
756
756
|
code: $
|
|
757
757
|
}) => {
|
|
@@ -761,10 +761,10 @@ const yt = (e, t, s) => {
|
|
|
761
761
|
"Content-Type": "application/json"
|
|
762
762
|
},
|
|
763
763
|
body: JSON.stringify({
|
|
764
|
-
email:
|
|
765
|
-
password:
|
|
764
|
+
email: h,
|
|
765
|
+
password: d,
|
|
766
766
|
phone_number: l,
|
|
767
|
-
family_name:
|
|
767
|
+
family_name: p,
|
|
768
768
|
given_name: u,
|
|
769
769
|
code: $
|
|
770
770
|
})
|
|
@@ -775,43 +775,43 @@ const yt = (e, t, s) => {
|
|
|
775
775
|
}
|
|
776
776
|
return v.json();
|
|
777
777
|
},
|
|
778
|
-
requestResetPassword: async ({ email:
|
|
779
|
-
const
|
|
778
|
+
requestResetPassword: async ({ email: h }) => {
|
|
779
|
+
const d = await fetch(`${e}${t.requestResetPassword}`, {
|
|
780
780
|
method: "POST",
|
|
781
781
|
headers: {
|
|
782
782
|
"Content-Type": "application/json"
|
|
783
783
|
},
|
|
784
784
|
body: JSON.stringify({
|
|
785
|
-
email:
|
|
785
|
+
email: h
|
|
786
786
|
})
|
|
787
787
|
});
|
|
788
|
-
if (!
|
|
789
|
-
const l = await
|
|
788
|
+
if (!d.ok) {
|
|
789
|
+
const l = await d.json();
|
|
790
790
|
throw new Error(l.message || l.error || "Failed to request password reset");
|
|
791
791
|
}
|
|
792
|
-
return
|
|
792
|
+
return d.json();
|
|
793
793
|
},
|
|
794
794
|
resetPassword: async ({
|
|
795
|
-
email:
|
|
796
|
-
otp:
|
|
795
|
+
email: h,
|
|
796
|
+
otp: d,
|
|
797
797
|
newPassword: l
|
|
798
798
|
}) => {
|
|
799
|
-
const
|
|
799
|
+
const p = await fetch(`${e}${t.resetPassword}`, {
|
|
800
800
|
method: "POST",
|
|
801
801
|
headers: {
|
|
802
802
|
"Content-Type": "application/json"
|
|
803
803
|
},
|
|
804
804
|
body: JSON.stringify({
|
|
805
|
-
email:
|
|
806
|
-
otp:
|
|
805
|
+
email: h,
|
|
806
|
+
otp: d,
|
|
807
807
|
newPassword: l
|
|
808
808
|
})
|
|
809
809
|
});
|
|
810
|
-
if (!
|
|
811
|
-
const u = await
|
|
810
|
+
if (!p.ok) {
|
|
811
|
+
const u = await p.json();
|
|
812
812
|
throw new Error(u.message || u.error || "Failed to reset password");
|
|
813
813
|
}
|
|
814
|
-
return
|
|
814
|
+
return p.json();
|
|
815
815
|
}
|
|
816
816
|
};
|
|
817
817
|
}, J = {
|
|
@@ -825,33 +825,33 @@ const yt = (e, t, s) => {
|
|
|
825
825
|
sameSite: "lax",
|
|
826
826
|
path: "/"
|
|
827
827
|
}, ne = () => {
|
|
828
|
-
const e = (n,
|
|
828
|
+
const e = (n, h, d = {}) => {
|
|
829
829
|
const {
|
|
830
830
|
maxAge: l,
|
|
831
|
-
path:
|
|
831
|
+
path: p = "/",
|
|
832
832
|
secure: u = window.location.protocol === "https:",
|
|
833
833
|
sameSite: $ = "lax",
|
|
834
834
|
domain: v
|
|
835
|
-
} =
|
|
836
|
-
let A = `${encodeURIComponent(n)}=${encodeURIComponent(
|
|
837
|
-
l !== void 0 && (A += `; Max-Age=${l}`), A += `; Path=${
|
|
835
|
+
} = d;
|
|
836
|
+
let A = `${encodeURIComponent(n)}=${encodeURIComponent(h)}`;
|
|
837
|
+
l !== void 0 && (A += `; Max-Age=${l}`), A += `; Path=${p}`, u && (A += "; Secure"), A += `; SameSite=${$}`, v && (A += `; Domain=${v}`), document.cookie = A;
|
|
838
838
|
}, t = (n) => {
|
|
839
|
-
const
|
|
840
|
-
for (let l = 0; l <
|
|
841
|
-
let
|
|
842
|
-
for (;
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
return decodeURIComponent(
|
|
839
|
+
const h = encodeURIComponent(n) + "=", d = document.cookie.split(";");
|
|
840
|
+
for (let l = 0; l < d.length; l++) {
|
|
841
|
+
let p = d[l];
|
|
842
|
+
for (; p.charAt(0) === " "; )
|
|
843
|
+
p = p.substring(1);
|
|
844
|
+
if (p.indexOf(h) === 0)
|
|
845
|
+
return decodeURIComponent(p.substring(h.length));
|
|
846
846
|
}
|
|
847
847
|
return null;
|
|
848
|
-
}, s = (n,
|
|
848
|
+
}, s = (n, h = {}) => {
|
|
849
849
|
e(n, "", {
|
|
850
|
-
...
|
|
850
|
+
...h,
|
|
851
851
|
maxAge: -1
|
|
852
852
|
});
|
|
853
|
-
}, i = (n) => t(n) !== null, r = (n,
|
|
854
|
-
e(J[n],
|
|
853
|
+
}, i = (n) => t(n) !== null, r = (n, h) => {
|
|
854
|
+
e(J[n], h, ae);
|
|
855
855
|
}, o = (n) => t(J[n]), a = (n) => {
|
|
856
856
|
s(J[n]);
|
|
857
857
|
};
|
|
@@ -885,17 +885,17 @@ const yt = (e, t, s) => {
|
|
|
885
885
|
}, a = (w) => {
|
|
886
886
|
const _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", k = new Uint8Array(w);
|
|
887
887
|
return crypto.getRandomValues(k), Array.from(k).map((E) => _[E % _.length]).join("");
|
|
888
|
-
},
|
|
888
|
+
}, c = async (w) => {
|
|
889
889
|
const k = new TextEncoder().encode(w), E = await crypto.subtle.digest("SHA-256", k);
|
|
890
890
|
return btoa(String.fromCharCode(...new Uint8Array(E))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
891
891
|
}, n = async () => {
|
|
892
|
-
const w = a(128), _ = await
|
|
892
|
+
const w = a(128), _ = await c(w);
|
|
893
893
|
return sessionStorage.setItem("pkce_code_verifier", w), { codeVerifier: w, codeChallenge: _ };
|
|
894
|
-
},
|
|
894
|
+
}, h = () => {
|
|
895
895
|
const w = a(32);
|
|
896
896
|
return sessionStorage.setItem("oauth_state", w), w;
|
|
897
|
-
},
|
|
898
|
-
const { codeChallenge: w } = await n(), _ =
|
|
897
|
+
}, d = async () => {
|
|
898
|
+
const { codeChallenge: w } = await n(), _ = h(), k = new URLSearchParams({
|
|
899
899
|
response_type: "code",
|
|
900
900
|
client_id: o.clientId,
|
|
901
901
|
redirect_uri: o.redirectUri,
|
|
@@ -908,10 +908,10 @@ const yt = (e, t, s) => {
|
|
|
908
908
|
});
|
|
909
909
|
return `${o.domain}/oauth2/authorize?${k.toString()}`;
|
|
910
910
|
}, l = async () => {
|
|
911
|
-
const w = await
|
|
911
|
+
const w = await d();
|
|
912
912
|
window.location.href = w;
|
|
913
|
-
},
|
|
914
|
-
const { codeChallenge: w } = await n(), _ =
|
|
913
|
+
}, p = async () => {
|
|
914
|
+
const { codeChallenge: w } = await n(), _ = h(), k = new URLSearchParams({
|
|
915
915
|
response_type: "code",
|
|
916
916
|
client_id: o.clientId,
|
|
917
917
|
redirect_uri: o.redirectUri,
|
|
@@ -923,7 +923,7 @@ const yt = (e, t, s) => {
|
|
|
923
923
|
});
|
|
924
924
|
return `${o.domain}/oauth2/authorize?${k.toString()}`;
|
|
925
925
|
}, u = async () => {
|
|
926
|
-
const w = await
|
|
926
|
+
const w = await p();
|
|
927
927
|
window.location.href = w;
|
|
928
928
|
}, $ = (w) => {
|
|
929
929
|
const _ = sessionStorage.getItem("oauth_state");
|
|
@@ -1466,10 +1466,20 @@ var pe = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, y = (e, t,
|
|
|
1466
1466
|
(a = e[o]) && (r = (i ? a(t, s, r) : a(r)) || r);
|
|
1467
1467
|
return i && r && pe(t, s, r), r;
|
|
1468
1468
|
};
|
|
1469
|
-
const ge = [
|
|
1469
|
+
const ge = [
|
|
1470
|
+
"code",
|
|
1471
|
+
"state",
|
|
1472
|
+
"error",
|
|
1473
|
+
"error_description",
|
|
1474
|
+
"access_token",
|
|
1475
|
+
"id_token",
|
|
1476
|
+
"refresh_token",
|
|
1477
|
+
"token_type",
|
|
1478
|
+
"expires_in"
|
|
1479
|
+
];
|
|
1470
1480
|
let m = class extends H {
|
|
1471
1481
|
constructor() {
|
|
1472
|
-
super(...arguments), this.open = !1, this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.size = "sm", this.theme = "light", this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isClosing = !1, this.isVisible = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.lastDragEndTime = 0, this.cookies = ne(), this.scrollPosition = 0, this.transitionDuration = 300, this.hasHandledOAuthCallback = !1, this.boundKeyHandler = (e) => {
|
|
1482
|
+
super(...arguments), this.open = !1, this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.oauthSpaDomain = "", this.size = "sm", this.theme = "light", this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isClosing = !1, this.isVisible = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.lastDragEndTime = 0, this.cookies = ne(), this.scrollPosition = 0, this.transitionDuration = 300, this.hasHandledOAuthCallback = !1, this.boundKeyHandler = (e) => {
|
|
1473
1483
|
e.key === "Escape" && this.isVisible && this.handleClose();
|
|
1474
1484
|
}, this.baseUrlErrorMessage = "Authentication service is not configured correctly. Please add an API domain or contact support.", this.handleClose = () => {
|
|
1475
1485
|
this.isClosing || !this.isVisible || (this.cleanupInlineStyles(), this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.isClosing = !0, setTimeout(() => {
|
|
@@ -1493,9 +1503,9 @@ let m = class extends H {
|
|
|
1493
1503
|
e > 5 && (this.lastDragEndTime = Date.now());
|
|
1494
1504
|
const t = Date.now() - this.dragStartTime, s = e / t, i = this.modalContainer.offsetHeight, r = Math.max(150, i * 0.3), a = e > r || s > 0.5;
|
|
1495
1505
|
this.isDragging = !1;
|
|
1496
|
-
const
|
|
1497
|
-
|
|
1498
|
-
|
|
1506
|
+
const c = this.modalContainer, n = a ? i + i * 0.1 : 0;
|
|
1507
|
+
c.style.transition = "none", c.style.transform = `translateY(${e}px)`, requestAnimationFrame(() => {
|
|
1508
|
+
c.style.transition = `transform ${this.transitionDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`, c.style.transform = `translateY(${n}px)`;
|
|
1499
1509
|
}), setTimeout(() => {
|
|
1500
1510
|
this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, a ? (this.isVisible = !1, this.open = !1) : this.modalContainer && (this.modalContainer.style.transition = "", this.modalContainer.style.transform = "");
|
|
1501
1511
|
}, this.transitionDuration);
|
|
@@ -1693,31 +1703,41 @@ let m = class extends H {
|
|
|
1693
1703
|
}
|
|
1694
1704
|
}
|
|
1695
1705
|
async handleOAuthCallbackIfPresent() {
|
|
1696
|
-
const e = new URLSearchParams(window.location.search), t = e.get("
|
|
1697
|
-
if (
|
|
1706
|
+
const e = new URLSearchParams(window.location.search), t = e.get("access_token"), s = e.get("id_token"), i = e.get("refresh_token"), r = e.get("code"), o = e.get("state"), a = e.get("error"), c = e.get("error_description");
|
|
1707
|
+
if ((t || s || r || a) && !this.hasHandledOAuthCallback) {
|
|
1698
1708
|
if (!this.hasApiBaseUrl()) {
|
|
1699
1709
|
this.error = this.baseUrlErrorMessage;
|
|
1700
1710
|
return;
|
|
1701
1711
|
}
|
|
1702
1712
|
this.hasHandledOAuthCallback = !0, this.isLoading = !0, this.error = "";
|
|
1703
1713
|
try {
|
|
1704
|
-
if (
|
|
1705
|
-
throw new Error(
|
|
1706
|
-
if (
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1714
|
+
if (a)
|
|
1715
|
+
throw new Error(c || `OAuth error: ${a}`);
|
|
1716
|
+
if (t && s && i) {
|
|
1717
|
+
const { accessToken: h, idToken: d, refreshToken: l } = await this.getApiService().login({
|
|
1718
|
+
accessToken: t,
|
|
1719
|
+
refreshToken: i,
|
|
1720
|
+
idToken: s
|
|
1721
|
+
});
|
|
1722
|
+
this.setAuthTokens(h, d, l ?? i);
|
|
1723
|
+
} else if (r && o) {
|
|
1724
|
+
if (!this.isOAuthConfigured())
|
|
1725
|
+
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1726
|
+
const h = this.getOAuthService();
|
|
1727
|
+
if (!h)
|
|
1728
|
+
throw new Error("OAuth is not configured correctly. Please try again later.");
|
|
1729
|
+
if (!h.validateState(o))
|
|
1730
|
+
throw new Error("Invalid state parameter. Please try signing in again.");
|
|
1731
|
+
const d = await h.exchangeCodeForTokens(r), { accessToken: l, idToken: p, refreshToken: u } = await this.getApiService().login({
|
|
1732
|
+
accessToken: d.access_token,
|
|
1733
|
+
refreshToken: d.refresh_token,
|
|
1734
|
+
idToken: d.id_token
|
|
1735
|
+
});
|
|
1736
|
+
this.setAuthTokens(l, p, u ?? d.refresh_token);
|
|
1737
|
+
} else
|
|
1738
|
+
throw new Error("Missing required OAuth parameters");
|
|
1739
|
+
} catch (h) {
|
|
1740
|
+
this.error = h.message || "An unexpected error occurred during authentication";
|
|
1721
1741
|
} finally {
|
|
1722
1742
|
this.stripOAuthParamsFromUrl(), this.isLoading = !1;
|
|
1723
1743
|
}
|
|
@@ -1789,10 +1809,18 @@ let m = class extends H {
|
|
|
1789
1809
|
}
|
|
1790
1810
|
// OAuth handlers
|
|
1791
1811
|
handleGoogleSignIn() {
|
|
1792
|
-
this.
|
|
1812
|
+
this.handleOAuthSignIn("google");
|
|
1793
1813
|
}
|
|
1794
1814
|
handleAppleSignIn() {
|
|
1795
|
-
this.
|
|
1815
|
+
this.handleOAuthSignIn("apple");
|
|
1816
|
+
}
|
|
1817
|
+
handleOAuthSignIn(e) {
|
|
1818
|
+
if (this.oauthSpaDomain?.trim()) {
|
|
1819
|
+
const t = this.oauthSpaDomain.trim(), s = t.startsWith("http://") || t.startsWith("https://") ? t : `https://${t}`, i = s.endsWith("/") ? s.slice(0, -1) : s, r = window.location.href, o = `${i}?return_url=${encodeURIComponent(r)}&provider=${e}`;
|
|
1820
|
+
window.location.href = o;
|
|
1821
|
+
return;
|
|
1822
|
+
}
|
|
1823
|
+
e === "google" ? this.getOAuthService()?.redirectToGoogleAuth() : this.getOAuthService()?.redirectToAppleAuth();
|
|
1796
1824
|
}
|
|
1797
1825
|
// OTP input handlers
|
|
1798
1826
|
handleOtpInput(e, t, s) {
|
|
@@ -2387,6 +2415,9 @@ y([
|
|
|
2387
2415
|
y([
|
|
2388
2416
|
S({ type: String, attribute: "oauth-redirect-uri" })
|
|
2389
2417
|
], m.prototype, "oauthRedirectUri", 2);
|
|
2418
|
+
y([
|
|
2419
|
+
S({ type: String, attribute: "oauth-spa-domain" })
|
|
2420
|
+
], m.prototype, "oauthSpaDomain", 2);
|
|
2390
2421
|
y([
|
|
2391
2422
|
S({ type: String, attribute: "size" })
|
|
2392
2423
|
], m.prototype, "size", 2);
|