@8wave/ai-elements 0.126.0-beta.5 → 0.126.0-beta.6
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/ai-elements.es.js +376 -359
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/apps/web-component/src/composables/useChatbotAuth.d.ts +18 -1
- package/dist-vue/apps/web-component/src/utils/cookie.d.ts +3 -3
- package/dist-vue/composables.js +108 -91
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/packages/auth/src/anonymous-reauth-plugin.d.ts +8 -6
- package/package.json +1 -1
|
@@ -8,8 +8,9 @@ declare function anonymousReauthClient(): {
|
|
|
8
8
|
id: "anonymous-reauth";
|
|
9
9
|
getActions: ($fetch: BetterFetch) => {
|
|
10
10
|
signIn: {
|
|
11
|
+
/** A new session for the anonymous user the proof names. */
|
|
11
12
|
anonymousReauth: (data: {
|
|
12
|
-
|
|
13
|
+
proof: string;
|
|
13
14
|
}) => Promise<{
|
|
14
15
|
data: null;
|
|
15
16
|
error: {
|
|
@@ -25,6 +26,22 @@ declare function anonymousReauthClient(): {
|
|
|
25
26
|
error: null;
|
|
26
27
|
}>;
|
|
27
28
|
};
|
|
29
|
+
anonymousReauth: {
|
|
30
|
+
/** The proof that brings the current anonymous user back. */
|
|
31
|
+
proof: () => Promise<{
|
|
32
|
+
data: null;
|
|
33
|
+
error: {
|
|
34
|
+
message?: string | undefined;
|
|
35
|
+
status: number;
|
|
36
|
+
statusText: string;
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
data: {
|
|
40
|
+
proof: string;
|
|
41
|
+
};
|
|
42
|
+
error: null;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
28
45
|
};
|
|
29
46
|
pathMethods: {
|
|
30
47
|
'/sign-in/anonymous-reauth': "POST";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function setSessionCookie(token: string, cookieName?: string): void;
|
|
2
2
|
export declare function getSessionCookie(cookieName?: string): string;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
export declare function setAnonymousReauthProofCookie(proof: string, cookieName?: string): void;
|
|
4
|
+
export declare function getAnonymousReauthProofCookie(cookieName?: string): string;
|
|
5
|
+
export declare function clearAnonymousReauthProofCookie(cookieName?: string): void;
|
package/dist-vue/composables.js
CHANGED
|
@@ -5266,10 +5266,13 @@ async function te({ response: e }) {
|
|
|
5266
5266
|
function ne() {
|
|
5267
5267
|
return {
|
|
5268
5268
|
id: "anonymous-reauth",
|
|
5269
|
-
getActions: (e) => ({
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5269
|
+
getActions: (e) => ({
|
|
5270
|
+
signIn: { anonymousReauth: async (t) => e("/sign-in/anonymous-reauth", {
|
|
5271
|
+
method: "POST",
|
|
5272
|
+
body: t
|
|
5273
|
+
}) },
|
|
5274
|
+
anonymousReauth: { proof: async () => e("/anonymous-reauth/proof", { method: "GET" }) }
|
|
5275
|
+
}),
|
|
5273
5276
|
pathMethods: { "/sign-in/anonymous-reauth": "POST" }
|
|
5274
5277
|
};
|
|
5275
5278
|
}
|
|
@@ -5364,82 +5367,96 @@ function Y(e = {}) {
|
|
|
5364
5367
|
isAnonymous: !!t.isAnonymous
|
|
5365
5368
|
}), !t && n && e.onSignedOut?.();
|
|
5366
5369
|
});
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
+
let S = /* @__PURE__ */ new Set();
|
|
5371
|
+
function C(t) {
|
|
5372
|
+
return O(e.cookieName).startsWith(`${t}.`);
|
|
5373
|
+
}
|
|
5374
|
+
async function w(t) {
|
|
5375
|
+
if (!S.has(t)) {
|
|
5376
|
+
S.add(t);
|
|
5377
|
+
try {
|
|
5378
|
+
let { data: n } = await a.anonymousReauth.proof();
|
|
5379
|
+
n?.proof?.startsWith(`${t}.`) && D(n.proof, e.cookieName);
|
|
5380
|
+
} catch {}
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
async function A() {
|
|
5384
|
+
let { data: e } = await a.signIn.anonymous();
|
|
5385
|
+
e?.token && (r.value = e.token, e.user?.id && await w(e.user.id));
|
|
5370
5386
|
}
|
|
5371
|
-
async function
|
|
5387
|
+
async function j() {
|
|
5372
5388
|
let t = O(e.cookieName);
|
|
5373
5389
|
if (!t) return !1;
|
|
5390
|
+
if (!t.includes(".")) return k(e.cookieName), !1;
|
|
5374
5391
|
try {
|
|
5375
|
-
let { data: e } = await a.signIn.anonymousReauth({
|
|
5392
|
+
let { data: e } = await a.signIn.anonymousReauth({ proof: t });
|
|
5376
5393
|
if (e?.token) return r.value = e.token, await o.value.refetch(), !0;
|
|
5377
5394
|
} catch {}
|
|
5378
5395
|
return !1;
|
|
5379
5396
|
}
|
|
5380
|
-
async function
|
|
5381
|
-
await
|
|
5397
|
+
async function M() {
|
|
5398
|
+
await j() || await A();
|
|
5382
5399
|
}
|
|
5383
|
-
async function
|
|
5384
|
-
f.value === t && (e.onExternalAuthExpired?.(), !e.awaitExternalToken && (
|
|
5400
|
+
async function N(t) {
|
|
5401
|
+
f.value === t && (e.onExternalAuthExpired?.(), !e.awaitExternalToken && (R(void 0), await M()));
|
|
5385
5402
|
}
|
|
5386
|
-
let
|
|
5387
|
-
function
|
|
5388
|
-
return
|
|
5403
|
+
let P, F, I;
|
|
5404
|
+
function L() {
|
|
5405
|
+
return F === r.value ? P : void 0;
|
|
5389
5406
|
}
|
|
5390
|
-
function
|
|
5391
|
-
|
|
5407
|
+
function R(t) {
|
|
5408
|
+
P = t, F = t ? r.value : void 0, clearTimeout(I), I = void 0;
|
|
5392
5409
|
let n = t ? J(t)?.exp : void 0, i = typeof n == "number" ? q(n) : void 0;
|
|
5393
|
-
i !== void 0 && e.onExternalTokenExpiring && (
|
|
5394
|
-
|
|
5410
|
+
i !== void 0 && e.onExternalTokenExpiring && (I = setTimeout(() => {
|
|
5411
|
+
L() === t && e.onExternalTokenExpiring?.();
|
|
5395
5412
|
}, i));
|
|
5396
5413
|
}
|
|
5397
|
-
u() && p(() => clearTimeout(
|
|
5398
|
-
async function
|
|
5414
|
+
u() && p(() => clearTimeout(I));
|
|
5415
|
+
async function z(e) {
|
|
5399
5416
|
try {
|
|
5400
5417
|
let { error: t } = await a.externalToken.refresh({ token: e });
|
|
5401
|
-
return !t && (f.value === e &&
|
|
5418
|
+
return !t && (f.value === e && R(e), !0);
|
|
5402
5419
|
} catch {
|
|
5403
5420
|
return !1;
|
|
5404
5421
|
}
|
|
5405
5422
|
}
|
|
5406
|
-
async function
|
|
5423
|
+
async function B(e) {
|
|
5407
5424
|
s.value = !0;
|
|
5408
5425
|
try {
|
|
5409
|
-
let t =
|
|
5410
|
-
if (o.value.data && t && ie(t, e) && (await
|
|
5426
|
+
let t = L();
|
|
5427
|
+
if (o.value.data && t && ie(t, e) && (await z(e) || f.value !== e)) return;
|
|
5411
5428
|
let { data: n } = await a.signIn.externalToken({ token: e });
|
|
5412
5429
|
if (f.value !== e) return;
|
|
5413
5430
|
if (n?.token) {
|
|
5414
|
-
r.value = n.token,
|
|
5431
|
+
r.value = n.token, R(e), await o.value.refetch();
|
|
5415
5432
|
return;
|
|
5416
5433
|
}
|
|
5417
|
-
await
|
|
5434
|
+
await N(e);
|
|
5418
5435
|
} catch {
|
|
5419
|
-
await
|
|
5436
|
+
await N(e);
|
|
5420
5437
|
} finally {
|
|
5421
5438
|
s.value = !1;
|
|
5422
5439
|
}
|
|
5423
5440
|
}
|
|
5424
|
-
let
|
|
5425
|
-
async function
|
|
5426
|
-
if (e &&
|
|
5427
|
-
f.value = e,
|
|
5441
|
+
let V, H, U = !1;
|
|
5442
|
+
async function W(e) {
|
|
5443
|
+
if (e && V !== e) {
|
|
5444
|
+
f.value = e, H = e, V = e;
|
|
5428
5445
|
try {
|
|
5429
5446
|
await x(async () => {
|
|
5430
|
-
f.value === e && await
|
|
5447
|
+
f.value === e && await B(e);
|
|
5431
5448
|
});
|
|
5432
5449
|
} finally {
|
|
5433
|
-
|
|
5450
|
+
V = void 0;
|
|
5434
5451
|
}
|
|
5435
5452
|
}
|
|
5436
5453
|
}
|
|
5437
|
-
async function
|
|
5454
|
+
async function G() {
|
|
5438
5455
|
s.value || await x(async () => {
|
|
5439
5456
|
if (!(f.value || n.value)) {
|
|
5440
5457
|
s.value = !0;
|
|
5441
5458
|
try {
|
|
5442
|
-
await
|
|
5459
|
+
await M();
|
|
5443
5460
|
} finally {
|
|
5444
5461
|
s.value = !1;
|
|
5445
5462
|
}
|
|
@@ -5451,53 +5468,53 @@ function Y(e = {}) {
|
|
|
5451
5468
|
if (!r.isPending && !r.isRefetching && !s.value && !r.data) {
|
|
5452
5469
|
if (n.value) return;
|
|
5453
5470
|
if (f.value) {
|
|
5454
|
-
|
|
5471
|
+
W(f.value);
|
|
5455
5472
|
return;
|
|
5456
5473
|
}
|
|
5457
5474
|
if (e.awaitExternalToken) return;
|
|
5458
|
-
|
|
5475
|
+
G();
|
|
5459
5476
|
return;
|
|
5460
5477
|
}
|
|
5461
5478
|
let i = r.data?.user;
|
|
5462
5479
|
if (n.value) return;
|
|
5463
|
-
if (r.data?.session?.hardExpiresAt && !
|
|
5464
|
-
if (
|
|
5480
|
+
if (r.data?.session?.hardExpiresAt && !U) {
|
|
5481
|
+
if (U = !0, !f.value) {
|
|
5465
5482
|
$();
|
|
5466
5483
|
return;
|
|
5467
5484
|
}
|
|
5468
|
-
if (
|
|
5469
|
-
|
|
5485
|
+
if (H !== f.value) {
|
|
5486
|
+
W(f.value);
|
|
5470
5487
|
return;
|
|
5471
5488
|
}
|
|
5472
5489
|
}
|
|
5473
|
-
let a =
|
|
5474
|
-
i && !i.isAnonymous && a && f.value && f.value !== a &&
|
|
5490
|
+
let a = L();
|
|
5491
|
+
i && !i.isAnonymous && a && f.value && f.value !== a && H !== f.value || i?.isAnonymous && f.value && H !== f.value ? W(f.value) : i?.isAnonymous && i.id && !C(i.id) && w(i.id);
|
|
5475
5492
|
}, { immediate: !0 }), g(n, () => {
|
|
5476
5493
|
o.value.refetch();
|
|
5477
5494
|
}), g(l, (e, t) => {
|
|
5478
|
-
e ? (f.value = e, d.value &&
|
|
5495
|
+
e ? (f.value = e, d.value && W(e)) : t && f.value === t && $();
|
|
5479
5496
|
});
|
|
5480
|
-
function
|
|
5481
|
-
t.status === 401 && (n.value ? o.value.refetch() : f.value ?
|
|
5497
|
+
function K(t) {
|
|
5498
|
+
t.status === 401 && (n.value ? o.value.refetch() : f.value ? W(f.value) : e.awaitExternalToken || G());
|
|
5482
5499
|
}
|
|
5483
|
-
let
|
|
5484
|
-
async function
|
|
5500
|
+
let Y = c(() => o.value.data?.user?.id), X = m();
|
|
5501
|
+
async function se(t, n, i) {
|
|
5485
5502
|
let o = await a.signIn.email({
|
|
5486
5503
|
email: t,
|
|
5487
5504
|
password: n,
|
|
5488
5505
|
rememberMe: i
|
|
5489
5506
|
}), s = o.data;
|
|
5490
|
-
return s?.twoFactorRedirect ? (
|
|
5507
|
+
return s?.twoFactorRedirect ? (X.value = s.twoFactorToken ? {
|
|
5491
5508
|
token: s.twoFactorToken,
|
|
5492
5509
|
methods: s.twoFactorMethods ?? []
|
|
5493
|
-
} : void 0,
|
|
5510
|
+
} : void 0, o) : (o.data?.token && (r.value = o.data.token, k(e.cookieName)), o);
|
|
5494
5511
|
}
|
|
5495
|
-
let
|
|
5512
|
+
let ce = {
|
|
5496
5513
|
totp: "/two-factor/verify-totp",
|
|
5497
5514
|
otp: "/two-factor/verify-otp",
|
|
5498
5515
|
backup: "/two-factor/verify-backup-code"
|
|
5499
5516
|
};
|
|
5500
|
-
function
|
|
5517
|
+
function Z(e) {
|
|
5501
5518
|
return {
|
|
5502
5519
|
method: "POST",
|
|
5503
5520
|
headers: { "x-two-factor-token": e.token },
|
|
@@ -5507,58 +5524,58 @@ function Y(e = {}) {
|
|
|
5507
5524
|
}
|
|
5508
5525
|
};
|
|
5509
5526
|
}
|
|
5510
|
-
let
|
|
5527
|
+
let Q = {
|
|
5511
5528
|
data: null,
|
|
5512
5529
|
error: {
|
|
5513
5530
|
code: "INVALID_TWO_FACTOR_COOKIE",
|
|
5514
5531
|
message: void 0
|
|
5515
5532
|
}
|
|
5516
5533
|
};
|
|
5517
|
-
async function
|
|
5518
|
-
let
|
|
5519
|
-
if (!
|
|
5520
|
-
let
|
|
5521
|
-
...
|
|
5522
|
-
body: { code:
|
|
5534
|
+
async function le(t, n) {
|
|
5535
|
+
let i = X.value;
|
|
5536
|
+
if (!i) return Q;
|
|
5537
|
+
let o = await a.$fetch(ce[t], {
|
|
5538
|
+
...Z(i),
|
|
5539
|
+
body: { code: n }
|
|
5523
5540
|
});
|
|
5524
|
-
return
|
|
5541
|
+
return o.data?.token && (r.value = o.data.token, X.value = void 0, k(e.cookieName)), o;
|
|
5525
5542
|
}
|
|
5526
|
-
async function
|
|
5527
|
-
let e =
|
|
5528
|
-
return e ? a.$fetch("/two-factor/send-otp",
|
|
5543
|
+
async function ue() {
|
|
5544
|
+
let e = X.value;
|
|
5545
|
+
return e ? a.$fetch("/two-factor/send-otp", Z(e)) : Q;
|
|
5529
5546
|
}
|
|
5530
|
-
function
|
|
5531
|
-
|
|
5547
|
+
function de() {
|
|
5548
|
+
X.value = void 0;
|
|
5532
5549
|
}
|
|
5533
|
-
function
|
|
5550
|
+
function fe(e) {
|
|
5534
5551
|
return a.signUp.email(e);
|
|
5535
5552
|
}
|
|
5536
|
-
function
|
|
5553
|
+
function pe(e, t) {
|
|
5537
5554
|
return a.requestPasswordReset({
|
|
5538
5555
|
email: e,
|
|
5539
5556
|
redirectTo: t
|
|
5540
5557
|
});
|
|
5541
5558
|
}
|
|
5542
|
-
async function
|
|
5559
|
+
async function me(t, n) {
|
|
5543
5560
|
let i = e.baseUrl ?? "https://ai-api.8wave.it", a = e.basePath ?? "auth", s = oe(), c = new URL(`${i}/${a}/oauth-popup/start`);
|
|
5544
5561
|
c.searchParams.set("provider", t), c.searchParams.set("popupOrigin", window.location.origin), c.searchParams.set("popupNonce", s);
|
|
5545
5562
|
let l = window.open(c.toString(), "eightwave-oauth", "width=600,height=700,menubar=no,toolbar=no");
|
|
5546
|
-
return l ? new Promise((
|
|
5547
|
-
let
|
|
5548
|
-
l?.closed &&
|
|
5563
|
+
return l ? new Promise((e) => {
|
|
5564
|
+
let t = new URL(i).origin, a = setInterval(() => {
|
|
5565
|
+
l?.closed && c();
|
|
5549
5566
|
}, 500);
|
|
5550
|
-
function
|
|
5551
|
-
window.removeEventListener("message",
|
|
5567
|
+
function c() {
|
|
5568
|
+
window.removeEventListener("message", u), clearInterval(a), e({ popupBlocked: !1 });
|
|
5552
5569
|
}
|
|
5553
|
-
function
|
|
5554
|
-
|
|
5570
|
+
function u(e) {
|
|
5571
|
+
e.origin === t && e.source === l && e.data?.type === ae && e.data.nonce === s && (l?.close(), typeof e.data.token == "string" && e.data.token && (r.value = e.data.token, o.value.refetch().then(() => n?.())), c());
|
|
5555
5572
|
}
|
|
5556
|
-
window.addEventListener("message",
|
|
5573
|
+
window.addEventListener("message", u);
|
|
5557
5574
|
}) : { popupBlocked: !0 };
|
|
5558
5575
|
}
|
|
5559
5576
|
async function $() {
|
|
5560
5577
|
if (n.value) return;
|
|
5561
|
-
f.value = void 0,
|
|
5578
|
+
f.value = void 0, R(void 0);
|
|
5562
5579
|
let e = r.value;
|
|
5563
5580
|
try {
|
|
5564
5581
|
await a.signOut();
|
|
@@ -5573,18 +5590,18 @@ function Y(e = {}) {
|
|
|
5573
5590
|
isExternalAuth: _,
|
|
5574
5591
|
token: r,
|
|
5575
5592
|
headers: i,
|
|
5576
|
-
onError:
|
|
5577
|
-
userId:
|
|
5578
|
-
signInWithEmail:
|
|
5579
|
-
twoFactorChallenge:
|
|
5580
|
-
verifyTwoFactor:
|
|
5581
|
-
sendTwoFactorCode:
|
|
5582
|
-
cancelTwoFactor:
|
|
5583
|
-
signUpWithEmail:
|
|
5584
|
-
requestPasswordReset:
|
|
5593
|
+
onError: K,
|
|
5594
|
+
userId: Y,
|
|
5595
|
+
signInWithEmail: se,
|
|
5596
|
+
twoFactorChallenge: X,
|
|
5597
|
+
verifyTwoFactor: le,
|
|
5598
|
+
sendTwoFactorCode: ue,
|
|
5599
|
+
cancelTwoFactor: de,
|
|
5600
|
+
signUpWithEmail: fe,
|
|
5601
|
+
requestPasswordReset: pe,
|
|
5585
5602
|
signInSocial: a.signIn.social,
|
|
5586
|
-
signInWithSocialPopup:
|
|
5587
|
-
signInWithExternalToken:
|
|
5603
|
+
signInWithSocialPopup: me,
|
|
5604
|
+
signInWithExternalToken: W,
|
|
5588
5605
|
signOut: $
|
|
5589
5606
|
};
|
|
5590
5607
|
}
|
|
@@ -5600,6 +5617,6 @@ function X() {
|
|
|
5600
5617
|
e &&= (e.removeEventListener("focusin", t), null);
|
|
5601
5618
|
});
|
|
5602
5619
|
}
|
|
5603
|
-
export { F as AUTH_BASE_PATH, I as DEFAULT_BACKEND_URL, k as
|
|
5620
|
+
export { F as AUTH_BASE_PATH, I as DEFAULT_BACKEND_URL, k as clearAnonymousReauthProofCookie, q as externalTokenExpiringDelay, O as getAnonymousReauthProofCookie, E as getSessionCookie, P as resolveWidgetAppearance, N as resolveWidgetLayout, D as setAnonymousReauthProofCookie, T as setSessionCookie, L as useChatbotAgent, Y as useChatbotAuth, r as useChatbotStore, X as useFocusTrapBypass, s as useLocalizedString };
|
|
5604
5621
|
|
|
5605
5622
|
//# sourceMappingURL=composables.js.map
|