@8wave/ai-elements 0.114.0-beta.7 → 0.114.0-beta.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/ai-elements.es.js +545 -556
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/apps/web-component/src/composables/useChatbotAuth.d.ts +1 -3
- package/dist-vue/composables.js +77 -88
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +2 -2
- package/dist-vue/packages/auth/src/social-redirect-plugin.d.ts +18 -12
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { auth } from '../../../../packages/auth/src';
|
|
3
|
-
import { socialRedirectClient } from 'auth/src/social-redirect-client-plugin';
|
|
4
3
|
import { createAuthClient, VueAuthClient } from 'better-auth/vue';
|
|
5
4
|
import { inferAdditionalFields, anonymousClient } from 'better-auth/client/plugins';
|
|
6
5
|
import { BetterFetch, BetterFetchError, BetterFetchResponse } from 'better-auth/client';
|
|
@@ -68,8 +67,7 @@ type AuthClientOptions = {
|
|
|
68
67
|
ReturnType<typeof inferAdditionalFields<typeof auth>>,
|
|
69
68
|
ReturnType<typeof anonymousClient>,
|
|
70
69
|
ReturnType<typeof anonymousReauthClient>,
|
|
71
|
-
ReturnType<typeof externalAuthClient
|
|
72
|
-
ReturnType<typeof socialRedirectClient>
|
|
70
|
+
ReturnType<typeof externalAuthClient>
|
|
73
71
|
];
|
|
74
72
|
};
|
|
75
73
|
export type AuthClient = ReturnType<typeof createAuthClient<AuthClientOptions>>;
|
package/dist-vue/composables.js
CHANGED
|
@@ -92,21 +92,7 @@ function k(t) {
|
|
|
92
92
|
} : void 0)
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
//#region ../../packages/auth/src/social-redirect-client-plugin.ts
|
|
97
|
-
function A() {
|
|
98
|
-
return {
|
|
99
|
-
id: "social-redirect",
|
|
100
|
-
getActions: (e, t, n) => ({ signIn: { socialRedirect: (e) => {
|
|
101
|
-
let t = n?.baseURL ?? "", r = n?.basePath ?? "auth", i = new URLSearchParams({
|
|
102
|
-
provider: e.provider,
|
|
103
|
-
callbackURL: e.callbackURL
|
|
104
|
-
});
|
|
105
|
-
return e.errorCallbackURL && i.set("errorCallbackURL", e.errorCallbackURL), `${t}/${r}/sign-in/social-redirect?${i}`;
|
|
106
|
-
} } })
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
var j = {
|
|
95
|
+
var A = {
|
|
110
96
|
action: {
|
|
111
97
|
accept: "Accetto",
|
|
112
98
|
acceptRedundancy: "Conferma ridondante",
|
|
@@ -1244,7 +1230,7 @@ var j = {
|
|
|
1244
1230
|
feelsLike: "Percepita",
|
|
1245
1231
|
today: "Oggi"
|
|
1246
1232
|
}
|
|
1247
|
-
},
|
|
1233
|
+
}, j = {
|
|
1248
1234
|
action: {
|
|
1249
1235
|
accept: "Accept",
|
|
1250
1236
|
acceptRedundancy: "Confirm redundant",
|
|
@@ -2380,7 +2366,7 @@ var j = {
|
|
|
2380
2366
|
feelsLike: "Feels like",
|
|
2381
2367
|
today: "Today"
|
|
2382
2368
|
}
|
|
2383
|
-
},
|
|
2369
|
+
}, M = {
|
|
2384
2370
|
invalidType: "Expected {expected}, received {received}",
|
|
2385
2371
|
invalidTypeReceivedUndefined: "Required",
|
|
2386
2372
|
invalidTypeReceivedNull: "Required",
|
|
@@ -2512,7 +2498,7 @@ var j = {
|
|
|
2512
2498
|
jwt: "JWT",
|
|
2513
2499
|
template_literal: "input"
|
|
2514
2500
|
}
|
|
2515
|
-
},
|
|
2501
|
+
}, N = {
|
|
2516
2502
|
invalidType: "Previsto {expected}, ricevuto {received}",
|
|
2517
2503
|
invalidTypeReceivedUndefined: "Obbligatorio",
|
|
2518
2504
|
invalidTypeReceivedNull: "Obbligatorio",
|
|
@@ -2644,29 +2630,29 @@ var j = {
|
|
|
2644
2630
|
jwt: "JWT",
|
|
2645
2631
|
template_literal: "input"
|
|
2646
2632
|
}
|
|
2647
|
-
},
|
|
2648
|
-
function
|
|
2633
|
+
}, P = ["it", "en"];
|
|
2634
|
+
function F() {
|
|
2649
2635
|
let e = navigator.language.split("-")[0];
|
|
2650
|
-
return
|
|
2636
|
+
return P.includes(e) ? e : "en";
|
|
2651
2637
|
}
|
|
2652
|
-
var
|
|
2653
|
-
locale:
|
|
2638
|
+
var I = f({
|
|
2639
|
+
locale: F(),
|
|
2654
2640
|
legacy: !1,
|
|
2655
2641
|
globalInjection: !0,
|
|
2656
2642
|
fallbackWarn: !1,
|
|
2657
2643
|
messages: {
|
|
2658
2644
|
it: {
|
|
2659
|
-
...
|
|
2645
|
+
...A,
|
|
2660
2646
|
errors: {
|
|
2661
|
-
...
|
|
2662
|
-
...
|
|
2647
|
+
...N,
|
|
2648
|
+
...A.errors
|
|
2663
2649
|
}
|
|
2664
2650
|
},
|
|
2665
2651
|
en: {
|
|
2666
|
-
...
|
|
2652
|
+
...j,
|
|
2667
2653
|
errors: {
|
|
2668
|
-
...
|
|
2669
|
-
...
|
|
2654
|
+
...M,
|
|
2655
|
+
...j.errors
|
|
2670
2656
|
}
|
|
2671
2657
|
}
|
|
2672
2658
|
},
|
|
@@ -2831,7 +2817,7 @@ var L = f({
|
|
|
2831
2817
|
}
|
|
2832
2818
|
}
|
|
2833
2819
|
});
|
|
2834
|
-
async function
|
|
2820
|
+
async function L({ response: e }) {
|
|
2835
2821
|
if (!e.ok) try {
|
|
2836
2822
|
let t;
|
|
2837
2823
|
try {
|
|
@@ -2841,9 +2827,9 @@ async function R({ response: e }) {
|
|
|
2841
2827
|
t = void 0;
|
|
2842
2828
|
}
|
|
2843
2829
|
let n = typeof t?.code == "string" ? t.code : void 0, r = `errors.${n}`;
|
|
2844
|
-
return e.status === 429 ? r = "errors.TOO_MANY_REQUESTS" : n?.startsWith("YOU_ARE_NOT_ALLOWED_TO_") ? r = "errors.NOT_ALLOWED" : t || (r = "auth.genericError"),
|
|
2830
|
+
return e.status === 429 ? r = "errors.TOO_MANY_REQUESTS" : n?.startsWith("YOU_ARE_NOT_ALLOWED_TO_") ? r = "errors.NOT_ALLOWED" : t || (r = "auth.genericError"), I.global.te(r) ? new Response(JSON.stringify({
|
|
2845
2831
|
...t,
|
|
2846
|
-
message:
|
|
2832
|
+
message: I.global.t(r)
|
|
2847
2833
|
}), {
|
|
2848
2834
|
status: e.status,
|
|
2849
2835
|
statusText: e.statusText,
|
|
@@ -2855,7 +2841,7 @@ async function R({ response: e }) {
|
|
|
2855
2841
|
}
|
|
2856
2842
|
//#endregion
|
|
2857
2843
|
//#region src/composables/useChatbotAuth.ts
|
|
2858
|
-
function
|
|
2844
|
+
function R() {
|
|
2859
2845
|
return {
|
|
2860
2846
|
id: "anonymous-reauth",
|
|
2861
2847
|
getActions: (e) => ({ signIn: { anonymousReauth: async (t) => e("/sign-in/anonymous-reauth", {
|
|
@@ -2865,7 +2851,7 @@ function z() {
|
|
|
2865
2851
|
pathMethods: { "/sign-in/anonymous-reauth": "POST" }
|
|
2866
2852
|
};
|
|
2867
2853
|
}
|
|
2868
|
-
function
|
|
2854
|
+
function z() {
|
|
2869
2855
|
return {
|
|
2870
2856
|
id: "external-auth",
|
|
2871
2857
|
getActions: (e) => ({ signIn: { externalToken: async (t) => e("/sign-in/external-token", {
|
|
@@ -2879,7 +2865,12 @@ function B() {
|
|
|
2879
2865
|
}]
|
|
2880
2866
|
};
|
|
2881
2867
|
}
|
|
2882
|
-
|
|
2868
|
+
var B = "better-auth:oauth-popup";
|
|
2869
|
+
function V() {
|
|
2870
|
+
let e = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
2871
|
+
return Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
2872
|
+
}
|
|
2873
|
+
function H(e = {}) {
|
|
2883
2874
|
let t = l(S(e.cookieName)), n = a(() => u(e.useHostSession) ?? !1), r = a({
|
|
2884
2875
|
get: () => t.value,
|
|
2885
2876
|
set: (n) => {
|
|
@@ -2891,9 +2882,8 @@ function V(e = {}) {
|
|
|
2891
2882
|
plugins: [
|
|
2892
2883
|
h(),
|
|
2893
2884
|
m(),
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
A()
|
|
2885
|
+
R(),
|
|
2886
|
+
z()
|
|
2897
2887
|
],
|
|
2898
2888
|
fetchOptions: {
|
|
2899
2889
|
onSuccess: (e) => {
|
|
@@ -2901,7 +2891,7 @@ function V(e = {}) {
|
|
|
2901
2891
|
let t = e.response.headers.get("set-auth-token");
|
|
2902
2892
|
t && (r.value = t);
|
|
2903
2893
|
},
|
|
2904
|
-
onResponse:
|
|
2894
|
+
onResponse: L,
|
|
2905
2895
|
auth: {
|
|
2906
2896
|
type: "Bearer",
|
|
2907
2897
|
token: () => n.value ? "" : r.value
|
|
@@ -2941,7 +2931,7 @@ function V(e = {}) {
|
|
|
2941
2931
|
async function k(t) {
|
|
2942
2932
|
_.value === t && (e.onExternalAuthExpired?.(), !e.awaitExternalToken && await O());
|
|
2943
2933
|
}
|
|
2944
|
-
async function
|
|
2934
|
+
async function A(e) {
|
|
2945
2935
|
c.value = !0;
|
|
2946
2936
|
try {
|
|
2947
2937
|
let { data: t } = await o.signIn.externalToken({ token: e });
|
|
@@ -2957,20 +2947,20 @@ function V(e = {}) {
|
|
|
2957
2947
|
c.value = !1;
|
|
2958
2948
|
}
|
|
2959
2949
|
}
|
|
2960
|
-
let M, N
|
|
2961
|
-
async function
|
|
2962
|
-
if (e &&
|
|
2963
|
-
_.value = e,
|
|
2950
|
+
let j, M, N = !1;
|
|
2951
|
+
async function P(e) {
|
|
2952
|
+
if (e && j !== e) {
|
|
2953
|
+
_.value = e, M = e, j = e;
|
|
2964
2954
|
try {
|
|
2965
2955
|
await b(async () => {
|
|
2966
|
-
_.value === e && await
|
|
2956
|
+
_.value === e && await A(e);
|
|
2967
2957
|
});
|
|
2968
2958
|
} finally {
|
|
2969
|
-
|
|
2959
|
+
j = void 0;
|
|
2970
2960
|
}
|
|
2971
2961
|
}
|
|
2972
2962
|
}
|
|
2973
|
-
async function
|
|
2963
|
+
async function F() {
|
|
2974
2964
|
c.value || await b(async () => {
|
|
2975
2965
|
if (!(_.value || n.value)) {
|
|
2976
2966
|
c.value = !0;
|
|
@@ -2987,27 +2977,27 @@ function V(e = {}) {
|
|
|
2987
2977
|
if (!r.isPending && !r.isRefetching && !c.value && !r.data) {
|
|
2988
2978
|
if (n.value) return;
|
|
2989
2979
|
if (_.value) {
|
|
2990
|
-
|
|
2980
|
+
P(_.value);
|
|
2991
2981
|
return;
|
|
2992
2982
|
}
|
|
2993
2983
|
if (e.awaitExternalToken) return;
|
|
2994
|
-
|
|
2984
|
+
F();
|
|
2995
2985
|
return;
|
|
2996
2986
|
}
|
|
2997
2987
|
let i = r.data?.user;
|
|
2998
2988
|
if (!n.value) {
|
|
2999
|
-
if (r.data?.session?.hardExpiresAt && !
|
|
3000
|
-
if (
|
|
3001
|
-
|
|
2989
|
+
if (r.data?.session?.hardExpiresAt && !N) {
|
|
2990
|
+
if (N = !0, !_.value) {
|
|
2991
|
+
q();
|
|
3002
2992
|
return;
|
|
3003
2993
|
}
|
|
3004
|
-
if (
|
|
3005
|
-
|
|
2994
|
+
if (M !== _.value) {
|
|
2995
|
+
P(_.value);
|
|
3006
2996
|
return;
|
|
3007
2997
|
}
|
|
3008
2998
|
}
|
|
3009
|
-
if (i?.isAnonymous && _.value &&
|
|
3010
|
-
|
|
2999
|
+
if (i?.isAnonymous && _.value && M !== _.value) {
|
|
3000
|
+
P(_.value);
|
|
3011
3001
|
return;
|
|
3012
3002
|
}
|
|
3013
3003
|
i?.isAnonymous && i.id && !w(e.cookieName) && C(i.id, e.cookieName);
|
|
@@ -3016,26 +3006,26 @@ function V(e = {}) {
|
|
|
3016
3006
|
s.value.refetch();
|
|
3017
3007
|
}), d(f, (e, t) => {
|
|
3018
3008
|
if (e) {
|
|
3019
|
-
_.value = e, g.value &&
|
|
3009
|
+
_.value = e, g.value && P(e);
|
|
3020
3010
|
return;
|
|
3021
3011
|
}
|
|
3022
|
-
t && _.value === t &&
|
|
3012
|
+
t && _.value === t && q();
|
|
3023
3013
|
});
|
|
3024
|
-
function
|
|
3014
|
+
function I(t) {
|
|
3025
3015
|
if (t.status === 401) {
|
|
3026
3016
|
if (n.value) {
|
|
3027
3017
|
s.value.refetch();
|
|
3028
3018
|
return;
|
|
3029
3019
|
}
|
|
3030
3020
|
if (_.value) {
|
|
3031
|
-
|
|
3021
|
+
P(_.value);
|
|
3032
3022
|
return;
|
|
3033
3023
|
}
|
|
3034
|
-
e.awaitExternalToken ||
|
|
3024
|
+
e.awaitExternalToken || F();
|
|
3035
3025
|
}
|
|
3036
3026
|
}
|
|
3037
|
-
let
|
|
3038
|
-
async function
|
|
3027
|
+
let H = a(() => s.value.data?.user?.id);
|
|
3028
|
+
async function U(t, n, i) {
|
|
3039
3029
|
let a = await o.signIn.email({
|
|
3040
3030
|
email: t,
|
|
3041
3031
|
password: n,
|
|
@@ -3043,34 +3033,33 @@ function V(e = {}) {
|
|
|
3043
3033
|
});
|
|
3044
3034
|
return a.data?.token && (r.value = a.data.token, T(e.cookieName)), a;
|
|
3045
3035
|
}
|
|
3046
|
-
function
|
|
3036
|
+
function W(e) {
|
|
3047
3037
|
return o.signUp.email(e);
|
|
3048
3038
|
}
|
|
3049
|
-
function
|
|
3039
|
+
function G(e, t) {
|
|
3050
3040
|
return o.requestPasswordReset({
|
|
3051
3041
|
email: e,
|
|
3052
3042
|
redirectTo: t
|
|
3053
3043
|
});
|
|
3054
3044
|
}
|
|
3055
|
-
async function
|
|
3056
|
-
let i = e.baseUrl ?? void 0, a =
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
}), l = window.open(c, "eightwave-oauth", "width=600,height=700,menubar=no,toolbar=no");
|
|
3045
|
+
async function K(t, n) {
|
|
3046
|
+
let i = e.baseUrl ?? void 0, a = e.basePath ?? "auth", o = V(), c = new URL(`${i}/${a}/oauth-popup/start`);
|
|
3047
|
+
c.searchParams.set("provider", t), c.searchParams.set("popupOrigin", window.location.origin), c.searchParams.set("popupNonce", o);
|
|
3048
|
+
let l = window.open(c.toString(), "eightwave-oauth", "width=600,height=700,menubar=no,toolbar=no");
|
|
3060
3049
|
return l ? new Promise((t) => {
|
|
3061
|
-
let a = new URL(i).origin,
|
|
3062
|
-
l?.closed &&
|
|
3050
|
+
let a = new URL(i).origin, c = setInterval(() => {
|
|
3051
|
+
l?.closed && u();
|
|
3063
3052
|
}, 500);
|
|
3064
|
-
function
|
|
3065
|
-
window.removeEventListener("message",
|
|
3053
|
+
function u() {
|
|
3054
|
+
window.removeEventListener("message", d), clearInterval(c), t({ popupBlocked: !1 });
|
|
3066
3055
|
}
|
|
3067
|
-
function
|
|
3068
|
-
t.origin === a && t.data?.type ===
|
|
3056
|
+
function d(t) {
|
|
3057
|
+
t.origin === a && t.source === l && t.data?.type === B && t.data.nonce === o && (l?.close(), typeof t.data.token == "string" && t.data.token && (r.value = t.data.token, T(e.cookieName), s.value.refetch().then(() => n?.())), u());
|
|
3069
3058
|
}
|
|
3070
|
-
window.addEventListener("message",
|
|
3059
|
+
window.addEventListener("message", d);
|
|
3071
3060
|
}) : { popupBlocked: !0 };
|
|
3072
3061
|
}
|
|
3073
|
-
async function
|
|
3062
|
+
async function q() {
|
|
3074
3063
|
if (n.value) return;
|
|
3075
3064
|
_.value = void 0;
|
|
3076
3065
|
let e = r.value;
|
|
@@ -3087,20 +3076,20 @@ function V(e = {}) {
|
|
|
3087
3076
|
isExternalAuth: v,
|
|
3088
3077
|
token: r,
|
|
3089
3078
|
headers: i,
|
|
3090
|
-
onError:
|
|
3091
|
-
userId:
|
|
3092
|
-
signInWithEmail:
|
|
3093
|
-
signUpWithEmail:
|
|
3094
|
-
requestPasswordReset:
|
|
3079
|
+
onError: I,
|
|
3080
|
+
userId: H,
|
|
3081
|
+
signInWithEmail: U,
|
|
3082
|
+
signUpWithEmail: W,
|
|
3083
|
+
requestPasswordReset: G,
|
|
3095
3084
|
signInSocial: o.signIn.social,
|
|
3096
|
-
signInWithSocialPopup:
|
|
3097
|
-
signInWithExternalToken:
|
|
3098
|
-
signOut:
|
|
3085
|
+
signInWithSocialPopup: K,
|
|
3086
|
+
signInWithExternalToken: P,
|
|
3087
|
+
signOut: q
|
|
3099
3088
|
};
|
|
3100
3089
|
}
|
|
3101
3090
|
//#endregion
|
|
3102
3091
|
//#region src/composables/useFocusTrapBypass.ts
|
|
3103
|
-
function
|
|
3092
|
+
function U() {
|
|
3104
3093
|
let e = null, t = (e) => {
|
|
3105
3094
|
e.stopPropagation();
|
|
3106
3095
|
};
|
|
@@ -3112,6 +3101,6 @@ function H() {
|
|
|
3112
3101
|
});
|
|
3113
3102
|
}
|
|
3114
3103
|
//#endregion
|
|
3115
|
-
export { O as AUTH_BASE_PATH, E as BACKEND_URL, D as FRONTEND_URL, T as clearAnonymousUserIdCookie, w as getAnonymousUserIdCookie, S as getSessionCookie, C as setAnonymousUserIdCookie, x as setSessionCookie, k as useChatbotAgent,
|
|
3104
|
+
export { O as AUTH_BASE_PATH, E as BACKEND_URL, D as FRONTEND_URL, T as clearAnonymousUserIdCookie, w as getAnonymousUserIdCookie, S as getSessionCookie, C as setAnonymousUserIdCookie, x as setSessionCookie, k as useChatbotAgent, H as useChatbotAuth, t as useChatbotStore, U as useFocusTrapBypass, r as useLocalizedString };
|
|
3116
3105
|
|
|
3117
3106
|
//# sourceMappingURL=composables.js.map
|