tevrocsdk 0.1.80 → 0.1.81
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/package.json +1 -1
- package/tevroc-sdk.esm.js +819 -153
- package/tevroc-sdk.min.js +51 -51
- package/tevroc-sdk.umd.js +692 -23
package/tevroc-sdk.esm.js
CHANGED
|
@@ -3657,6 +3657,7 @@ __export(useGoogleAuth_exports, {
|
|
|
3657
3657
|
subscribeGoogleLogin: () => subscribeGoogleLogin
|
|
3658
3658
|
});
|
|
3659
3659
|
function emitGoogleLogin(user, err2 = null) {
|
|
3660
|
+
debugAuth("Emitting login result", { success: Boolean(user), error: err2?.message || null });
|
|
3660
3661
|
googleListeners.forEach((cb) => {
|
|
3661
3662
|
try {
|
|
3662
3663
|
cb(user, err2);
|
|
@@ -3666,13 +3667,15 @@ function emitGoogleLogin(user, err2 = null) {
|
|
|
3666
3667
|
});
|
|
3667
3668
|
}
|
|
3668
3669
|
function subscribeGoogleLogin(cb) {
|
|
3670
|
+
debugAuth("Listener subscribed", { count: googleListeners.length + 1 });
|
|
3669
3671
|
googleListeners.push(cb);
|
|
3670
3672
|
return () => {
|
|
3671
3673
|
const i4 = googleListeners.indexOf(cb);
|
|
3672
3674
|
if (i4 !== -1) googleListeners.splice(i4, 1);
|
|
3675
|
+
debugAuth("Listener unsubscribed", { count: googleListeners.length });
|
|
3673
3676
|
};
|
|
3674
3677
|
}
|
|
3675
|
-
var capacitorPluginsPromise, tauriWebviewWindowPromise, getCapacitorPlugins, getTauriWebviewWindow, googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
3678
|
+
var capacitorPluginsPromise, tauriWebviewWindowPromise, getCapacitorPlugins, debugAuth, debugAuthWarn, debugAuthError, getTauriWebviewWindow, googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
3676
3679
|
var init_useGoogleAuth = __esm({
|
|
3677
3680
|
"src/services/useGoogleAuth.js"() {
|
|
3678
3681
|
init_usePlatform();
|
|
@@ -3681,6 +3684,9 @@ var init_useGoogleAuth = __esm({
|
|
|
3681
3684
|
capacitorPluginsPromise ??= Promise.all([Promise.resolve().then(() => (init_esm(), esm_exports)), Promise.resolve().then(() => (init_esm2(), esm_exports2))]).then(([appModule, browserModule]) => ({ App: appModule.App, Browser: browserModule.Browser }));
|
|
3682
3685
|
return capacitorPluginsPromise;
|
|
3683
3686
|
};
|
|
3687
|
+
debugAuth = (...args) => debugLog("[tevrocsdk][google-auth]", ...args);
|
|
3688
|
+
debugAuthWarn = (...args) => debugWarn("[tevrocsdk][google-auth]", ...args);
|
|
3689
|
+
debugAuthError = (...args) => debugError("[tevrocsdk][google-auth]", ...args);
|
|
3684
3690
|
getTauriWebviewWindow = async () => {
|
|
3685
3691
|
tauriWebviewWindowPromise ??= Promise.resolve().then(() => (init_webviewWindow(), webviewWindow_exports)).then((module) => module.WebviewWindow);
|
|
3686
3692
|
return tauriWebviewWindowPromise;
|
|
@@ -3719,6 +3725,7 @@ var init_useGoogleAuth = __esm({
|
|
|
3719
3725
|
}
|
|
3720
3726
|
};
|
|
3721
3727
|
cleanupAuthWindow = async () => {
|
|
3728
|
+
debugAuth("Cleaning up auth window", { hasWindow: Boolean(authWindowRef), isTauri, isCapacitor });
|
|
3722
3729
|
if (authCleanupTimer) {
|
|
3723
3730
|
clearInterval(authCleanupTimer);
|
|
3724
3731
|
authCleanupTimer = null;
|
|
@@ -3762,11 +3769,15 @@ var init_useGoogleAuth = __esm({
|
|
|
3762
3769
|
};
|
|
3763
3770
|
handleCallback = async (url) => {
|
|
3764
3771
|
try {
|
|
3772
|
+
debugAuth("Callback received", { hasUrl: Boolean(url), hasToken: Boolean(url?.includes("token=")) });
|
|
3765
3773
|
await cleanupAuthWindow();
|
|
3766
|
-
if (!url?.includes("token="))
|
|
3774
|
+
if (!url?.includes("token=")) {
|
|
3775
|
+
debugAuthWarn("Callback did not include a token");
|
|
3776
|
+
return;
|
|
3777
|
+
}
|
|
3767
3778
|
const params = new URLSearchParams(url.split("?")[1]);
|
|
3768
3779
|
const token = params.get("token");
|
|
3769
|
-
|
|
3780
|
+
debugAuth("Verifying provider token", { tokenPresent: Boolean(token) });
|
|
3770
3781
|
const res = await fetch(
|
|
3771
3782
|
"https://www.googleapis.com/oauth2/v3/userinfo",
|
|
3772
3783
|
{
|
|
@@ -3776,6 +3787,7 @@ var init_useGoogleAuth = __esm({
|
|
|
3776
3787
|
}
|
|
3777
3788
|
);
|
|
3778
3789
|
const googleUser = await res.json();
|
|
3790
|
+
debugAuth("Provider profile received", { idPresent: Boolean(googleUser.sub), emailPresent: Boolean(googleUser.email) });
|
|
3779
3791
|
const profile = {
|
|
3780
3792
|
id: googleUser.sub,
|
|
3781
3793
|
firstName: googleUser.given_name,
|
|
@@ -3789,19 +3801,26 @@ var init_useGoogleAuth = __esm({
|
|
|
3789
3801
|
localStorage.setItem("idToken", token);
|
|
3790
3802
|
emitGoogleLogin(profile, null);
|
|
3791
3803
|
} catch (err2) {
|
|
3804
|
+
debugAuthError("Callback failed", err2);
|
|
3792
3805
|
emitGoogleLogin(null, err2);
|
|
3793
3806
|
}
|
|
3794
3807
|
};
|
|
3795
3808
|
initializeGoogleLogin = async () => {
|
|
3796
|
-
if (googleInitialized)
|
|
3809
|
+
if (googleInitialized) {
|
|
3810
|
+
debugAuth("Already initialized");
|
|
3811
|
+
return;
|
|
3812
|
+
}
|
|
3797
3813
|
googleInitialized = true;
|
|
3814
|
+
debugAuth("Initializing listeners", { isCapacitor, isTauri });
|
|
3798
3815
|
if (isCapacitor) {
|
|
3816
|
+
debugAuth("Registering Capacitor appUrlOpen listener");
|
|
3799
3817
|
const { App: App2 } = await getCapacitorPlugins();
|
|
3800
3818
|
App2.addListener("appUrlOpen", (event) => {
|
|
3801
3819
|
handleCallback(event.url);
|
|
3802
3820
|
});
|
|
3803
3821
|
}
|
|
3804
3822
|
if (isTauri) {
|
|
3823
|
+
debugAuth("Registering Tauri deep-link listener");
|
|
3805
3824
|
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
3806
3825
|
await listen2("deep-link://open-url", async (event) => {
|
|
3807
3826
|
let url = event.payload;
|
|
@@ -3818,16 +3837,17 @@ var init_useGoogleAuth = __esm({
|
|
|
3818
3837
|
appName = "Tevroc",
|
|
3819
3838
|
serviceUrl = "https://tevrocsoftapi.netlify.app"
|
|
3820
3839
|
} = {}) => {
|
|
3821
|
-
|
|
3822
|
-
debugLog(isCapacitor, isTauri);
|
|
3840
|
+
debugAuth("Creating login", { appId, appName, serviceUrl, isCapacitor, isTauri });
|
|
3823
3841
|
await initializeGoogleLogin();
|
|
3824
3842
|
let authUrl = `${serviceUrl}/auth/google/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
3825
3843
|
if (isCapacitor) {
|
|
3844
|
+
debugAuth("Opening mobile auth browser");
|
|
3826
3845
|
const { Browser: Browser3 } = await getCapacitorPlugins();
|
|
3827
3846
|
await Browser3.open({ url: authUrl });
|
|
3828
3847
|
return;
|
|
3829
3848
|
}
|
|
3830
3849
|
if (isTauri) {
|
|
3850
|
+
debugAuth("Opening desktop auth window");
|
|
3831
3851
|
const WebviewWindow2 = await getTauriWebviewWindow();
|
|
3832
3852
|
await closeAllTauriWebviews();
|
|
3833
3853
|
const url = `${serviceUrl}/auth/google/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
@@ -3841,10 +3861,10 @@ var init_useGoogleAuth = __esm({
|
|
|
3841
3861
|
});
|
|
3842
3862
|
authWindowRef = win;
|
|
3843
3863
|
win.once("tauri://created", () => {
|
|
3844
|
-
|
|
3864
|
+
debugAuth("Auth window opened");
|
|
3845
3865
|
});
|
|
3846
3866
|
win.once("tauri://error", (e2) => {
|
|
3847
|
-
|
|
3867
|
+
debugAuthError("Auth window error", e2);
|
|
3848
3868
|
});
|
|
3849
3869
|
return;
|
|
3850
3870
|
}
|
|
@@ -3855,19 +3875,21 @@ var init_useGoogleAuth = __esm({
|
|
|
3855
3875
|
detectedAppId
|
|
3856
3876
|
)}&name=${encodeURIComponent(appName)}`;
|
|
3857
3877
|
if (isLocalhost) {
|
|
3878
|
+
debugAuth("Opening web auth popup", { mode, appId: detectedAppId });
|
|
3858
3879
|
const popup = window.open(
|
|
3859
3880
|
finalUrl,
|
|
3860
3881
|
"googleLogin",
|
|
3861
3882
|
"width=500,height=650"
|
|
3862
3883
|
);
|
|
3863
3884
|
if (!popup) {
|
|
3864
|
-
|
|
3885
|
+
debugAuthError("Popup blocked");
|
|
3865
3886
|
}
|
|
3866
3887
|
authWindowRef = popup;
|
|
3867
3888
|
authMessageListener = async (event) => {
|
|
3868
3889
|
const serviceOrigin = new URL(serviceUrl).origin;
|
|
3869
3890
|
if (event.origin !== serviceOrigin) return;
|
|
3870
3891
|
if (event.data?.type === "google-auth") {
|
|
3892
|
+
debugAuth("Received popup auth message", { origin: event.origin });
|
|
3871
3893
|
const token = event.data?.token || null;
|
|
3872
3894
|
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
3873
3895
|
await handleCallback(url);
|
|
@@ -3886,6 +3908,521 @@ var init_useGoogleAuth = __esm({
|
|
|
3886
3908
|
}
|
|
3887
3909
|
});
|
|
3888
3910
|
|
|
3911
|
+
// src/services/useFacebookAuth.js
|
|
3912
|
+
var useFacebookAuth_exports = {};
|
|
3913
|
+
__export(useFacebookAuth_exports, {
|
|
3914
|
+
createFacebookLogin: () => createFacebookLogin,
|
|
3915
|
+
initializeFacebookLogin: () => initializeFacebookLogin,
|
|
3916
|
+
subscribeFacebookLogin: () => subscribeFacebookLogin
|
|
3917
|
+
});
|
|
3918
|
+
function emitFacebookLogin(user, err2 = null) {
|
|
3919
|
+
debugAuth2("Emitting login result", { success: Boolean(user), error: err2?.message || null });
|
|
3920
|
+
facebookListeners.forEach((cb) => {
|
|
3921
|
+
try {
|
|
3922
|
+
cb(user, err2);
|
|
3923
|
+
} catch (e2) {
|
|
3924
|
+
debugError("Facebook listener error:", e2);
|
|
3925
|
+
}
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
function subscribeFacebookLogin(cb) {
|
|
3929
|
+
debugAuth2("Listener subscribed", { count: facebookListeners.length + 1 });
|
|
3930
|
+
facebookListeners.push(cb);
|
|
3931
|
+
return () => {
|
|
3932
|
+
const i4 = facebookListeners.indexOf(cb);
|
|
3933
|
+
if (i4 !== -1) facebookListeners.splice(i4, 1);
|
|
3934
|
+
debugAuth2("Listener unsubscribed", { count: facebookListeners.length });
|
|
3935
|
+
};
|
|
3936
|
+
}
|
|
3937
|
+
var capacitorPluginsPromise2, tauriWebviewWindowPromise2, getCapacitorPlugins2, debugAuth2, debugAuthWarn2, debugAuthError2, getTauriWebviewWindow2, facebookInitialized, facebookListeners, authWindowRef2, authCleanupTimer2, authMessageListener2, closeAllTauriWebviews2, cleanupAuthWindow2, handleCallback2, initializeFacebookLogin, createFacebookLogin;
|
|
3938
|
+
var init_useFacebookAuth = __esm({
|
|
3939
|
+
"src/services/useFacebookAuth.js"() {
|
|
3940
|
+
init_usePlatform();
|
|
3941
|
+
init_debug();
|
|
3942
|
+
getCapacitorPlugins2 = () => {
|
|
3943
|
+
capacitorPluginsPromise2 ??= Promise.all([Promise.resolve().then(() => (init_esm(), esm_exports)), Promise.resolve().then(() => (init_esm2(), esm_exports2))]).then(([appModule, browserModule]) => ({ App: appModule.App, Browser: browserModule.Browser }));
|
|
3944
|
+
return capacitorPluginsPromise2;
|
|
3945
|
+
};
|
|
3946
|
+
debugAuth2 = (...args) => debugLog("[tevrocsdk][facebook-auth]", ...args);
|
|
3947
|
+
debugAuthWarn2 = (...args) => debugWarn("[tevrocsdk][facebook-auth]", ...args);
|
|
3948
|
+
debugAuthError2 = (...args) => debugError("[tevrocsdk][facebook-auth]", ...args);
|
|
3949
|
+
getTauriWebviewWindow2 = async () => {
|
|
3950
|
+
tauriWebviewWindowPromise2 ??= Promise.resolve().then(() => (init_webviewWindow(), webviewWindow_exports)).then((module) => module.WebviewWindow);
|
|
3951
|
+
return tauriWebviewWindowPromise2;
|
|
3952
|
+
};
|
|
3953
|
+
facebookInitialized = false;
|
|
3954
|
+
facebookListeners = [];
|
|
3955
|
+
authWindowRef2 = null;
|
|
3956
|
+
authCleanupTimer2 = null;
|
|
3957
|
+
authMessageListener2 = null;
|
|
3958
|
+
closeAllTauriWebviews2 = async () => {
|
|
3959
|
+
if (!isTauri) return;
|
|
3960
|
+
const WebviewWindow2 = await getTauriWebviewWindow2();
|
|
3961
|
+
try {
|
|
3962
|
+
if (typeof WebviewWindow2.getAll === "function") {
|
|
3963
|
+
const windows = await WebviewWindow2.getAll();
|
|
3964
|
+
for (const webview of windows || []) {
|
|
3965
|
+
try {
|
|
3966
|
+
if (webview?.label && webview.label !== "main") {
|
|
3967
|
+
await webview.close();
|
|
3968
|
+
}
|
|
3969
|
+
} catch (e2) {
|
|
3970
|
+
debugWarn("Error closing Tauri webview:", e2);
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
} catch (e2) {
|
|
3975
|
+
debugWarn("Error listing Tauri webviews:", e2);
|
|
3976
|
+
}
|
|
3977
|
+
try {
|
|
3978
|
+
const tauriAuthWindow = await WebviewWindow2.getByLabel("auth");
|
|
3979
|
+
if (tauriAuthWindow) {
|
|
3980
|
+
await tauriAuthWindow.close();
|
|
3981
|
+
}
|
|
3982
|
+
} catch (e2) {
|
|
3983
|
+
debugWarn("Error closing Tauri auth window by label:", e2);
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
3986
|
+
cleanupAuthWindow2 = async () => {
|
|
3987
|
+
debugAuth2("Cleaning up auth window", { hasWindow: Boolean(authWindowRef2), isTauri, isCapacitor });
|
|
3988
|
+
if (authCleanupTimer2) {
|
|
3989
|
+
clearInterval(authCleanupTimer2);
|
|
3990
|
+
authCleanupTimer2 = null;
|
|
3991
|
+
}
|
|
3992
|
+
if (authMessageListener2 && typeof window !== "undefined") {
|
|
3993
|
+
window.removeEventListener("message", authMessageListener2);
|
|
3994
|
+
authMessageListener2 = null;
|
|
3995
|
+
}
|
|
3996
|
+
if (authWindowRef2) {
|
|
3997
|
+
const currentAuthWindow = authWindowRef2;
|
|
3998
|
+
authWindowRef2 = null;
|
|
3999
|
+
try {
|
|
4000
|
+
if (typeof currentAuthWindow?.close === "function") {
|
|
4001
|
+
await currentAuthWindow.close();
|
|
4002
|
+
}
|
|
4003
|
+
} catch (e2) {
|
|
4004
|
+
debugWarn("Error closing auth window:", e2);
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
if (isTauri) {
|
|
4008
|
+
const WebviewWindow2 = await getTauriWebviewWindow2();
|
|
4009
|
+
await closeAllTauriWebviews2();
|
|
4010
|
+
}
|
|
4011
|
+
if (isCapacitor) {
|
|
4012
|
+
try {
|
|
4013
|
+
const { Browser: Browser3 } = await getCapacitorPlugins2();
|
|
4014
|
+
await Browser3.close();
|
|
4015
|
+
} catch (e2) {
|
|
4016
|
+
debugWarn("Error closing Capacitor browser:", e2);
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
if (typeof window !== "undefined" && window !== window.parent) {
|
|
4020
|
+
try {
|
|
4021
|
+
if (authWindowRef2 && typeof authWindowRef2.close === "function") {
|
|
4022
|
+
await authWindowRef2.close();
|
|
4023
|
+
}
|
|
4024
|
+
} catch (e2) {
|
|
4025
|
+
debugWarn("Error closing popup fallback:", e2);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
handleCallback2 = async (url) => {
|
|
4030
|
+
try {
|
|
4031
|
+
debugAuth2("Callback received", { hasUrl: Boolean(url), hasToken: Boolean(url?.includes("token=")) });
|
|
4032
|
+
await cleanupAuthWindow2();
|
|
4033
|
+
if (!url?.includes("token=")) {
|
|
4034
|
+
debugAuthWarn2("Callback did not include a token");
|
|
4035
|
+
return;
|
|
4036
|
+
}
|
|
4037
|
+
const params = new URLSearchParams(url.split("?")[1]);
|
|
4038
|
+
const token = params.get("token");
|
|
4039
|
+
debugAuth2("Verifying provider token", { tokenPresent: Boolean(token) });
|
|
4040
|
+
const res = await fetch(
|
|
4041
|
+
`https://graph.facebook.com/me?fields=id,first_name,last_name,email,picture&access_token=${encodeURIComponent(token)}`
|
|
4042
|
+
);
|
|
4043
|
+
if (!res.ok) {
|
|
4044
|
+
throw new Error(`Facebook profile request failed: ${res.status}`);
|
|
4045
|
+
}
|
|
4046
|
+
const facebookUser = await res.json();
|
|
4047
|
+
debugAuth2("Provider profile received", { idPresent: Boolean(facebookUser.id), emailPresent: Boolean(facebookUser.email) });
|
|
4048
|
+
const profile = {
|
|
4049
|
+
id: facebookUser.id,
|
|
4050
|
+
firstName: facebookUser.first_name,
|
|
4051
|
+
lastName: facebookUser.last_name,
|
|
4052
|
+
email: facebookUser.email,
|
|
4053
|
+
photo: facebookUser.picture?.data?.url,
|
|
4054
|
+
accessToken: token
|
|
4055
|
+
};
|
|
4056
|
+
debugLog("Facebook user profile:", profile);
|
|
4057
|
+
localStorage.setItem("user", JSON.stringify(profile));
|
|
4058
|
+
localStorage.setItem("idToken", token);
|
|
4059
|
+
emitFacebookLogin(profile, null);
|
|
4060
|
+
} catch (err2) {
|
|
4061
|
+
debugAuthError2("Callback failed", err2);
|
|
4062
|
+
emitFacebookLogin(null, err2);
|
|
4063
|
+
}
|
|
4064
|
+
};
|
|
4065
|
+
initializeFacebookLogin = async () => {
|
|
4066
|
+
if (facebookInitialized) {
|
|
4067
|
+
debugAuth2("Already initialized");
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
facebookInitialized = true;
|
|
4071
|
+
debugAuth2("Initializing listeners", { isCapacitor, isTauri });
|
|
4072
|
+
if (isCapacitor) {
|
|
4073
|
+
debugAuth2("Registering Capacitor appUrlOpen listener");
|
|
4074
|
+
const { App: App2 } = await getCapacitorPlugins2();
|
|
4075
|
+
App2.addListener("appUrlOpen", (event) => {
|
|
4076
|
+
handleCallback2(event.url);
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4079
|
+
if (isTauri) {
|
|
4080
|
+
debugAuth2("Registering Tauri deep-link listener");
|
|
4081
|
+
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
4082
|
+
await listen2("deep-link://open-url", async (event) => {
|
|
4083
|
+
let url = event.payload;
|
|
4084
|
+
if (typeof url === "object") {
|
|
4085
|
+
url = url?.url || url?.payload || null;
|
|
4086
|
+
}
|
|
4087
|
+
if (!url) return;
|
|
4088
|
+
await handleCallback2(url);
|
|
4089
|
+
});
|
|
4090
|
+
}
|
|
4091
|
+
};
|
|
4092
|
+
createFacebookLogin = async ({
|
|
4093
|
+
appId = "tevrocsoft",
|
|
4094
|
+
appName = "Tevroc",
|
|
4095
|
+
serviceUrl = "https://tevrocsoftapi.netlify.app"
|
|
4096
|
+
} = {}) => {
|
|
4097
|
+
debugAuth2("Creating login", { appId, appName, serviceUrl, isCapacitor, isTauri });
|
|
4098
|
+
await initializeFacebookLogin();
|
|
4099
|
+
let authUrl = `${serviceUrl}/auth/facebook/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
4100
|
+
if (isCapacitor) {
|
|
4101
|
+
debugAuth2("Opening mobile auth browser");
|
|
4102
|
+
const { Browser: Browser3 } = await getCapacitorPlugins2();
|
|
4103
|
+
await Browser3.open({ url: authUrl });
|
|
4104
|
+
return;
|
|
4105
|
+
}
|
|
4106
|
+
if (isTauri) {
|
|
4107
|
+
debugAuth2("Opening desktop auth window");
|
|
4108
|
+
const WebviewWindow2 = await getTauriWebviewWindow2();
|
|
4109
|
+
await closeAllTauriWebviews2();
|
|
4110
|
+
const url = `${serviceUrl}/auth/facebook/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
4111
|
+
const win = new WebviewWindow2("auth", {
|
|
4112
|
+
url,
|
|
4113
|
+
title: `${appName} Login`,
|
|
4114
|
+
width: 550,
|
|
4115
|
+
height: 500,
|
|
4116
|
+
resizable: true,
|
|
4117
|
+
center: true
|
|
4118
|
+
});
|
|
4119
|
+
authWindowRef2 = win;
|
|
4120
|
+
win.once("tauri://created", () => {
|
|
4121
|
+
debugAuth2("Auth window opened");
|
|
4122
|
+
});
|
|
4123
|
+
win.once("tauri://error", (e2) => {
|
|
4124
|
+
debugAuthError2("Auth window error", e2);
|
|
4125
|
+
});
|
|
4126
|
+
return;
|
|
4127
|
+
}
|
|
4128
|
+
const isLocalhost = true;
|
|
4129
|
+
const detectedAppId = typeof window !== "undefined" ? window.location.host : appId;
|
|
4130
|
+
const mode = isLocalhost ? "localhost" : "netlify";
|
|
4131
|
+
const finalUrl = `${serviceUrl}/auth/facebook/login?mode=${mode}&app=${encodeURIComponent(
|
|
4132
|
+
detectedAppId
|
|
4133
|
+
)}&name=${encodeURIComponent(appName)}`;
|
|
4134
|
+
if (isLocalhost) {
|
|
4135
|
+
debugAuth2("Opening web auth popup", { mode, appId: detectedAppId });
|
|
4136
|
+
const popup = window.open(
|
|
4137
|
+
finalUrl,
|
|
4138
|
+
"facebookLogin",
|
|
4139
|
+
"width=500,height=650"
|
|
4140
|
+
);
|
|
4141
|
+
if (!popup) {
|
|
4142
|
+
debugAuthError2("Popup blocked");
|
|
4143
|
+
throw new Error("Facebook sign-in popup was blocked. Allow popups and try again.");
|
|
4144
|
+
}
|
|
4145
|
+
authWindowRef2 = popup;
|
|
4146
|
+
authMessageListener2 = async (event) => {
|
|
4147
|
+
const serviceOrigin = new URL(serviceUrl).origin;
|
|
4148
|
+
if (event.origin !== serviceOrigin) return;
|
|
4149
|
+
if (event.data?.type === "facebook-auth") {
|
|
4150
|
+
debugAuth2("Received popup auth message", { origin: event.origin });
|
|
4151
|
+
const token = event.data?.token || null;
|
|
4152
|
+
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
4153
|
+
await handleCallback2(url);
|
|
4154
|
+
}
|
|
4155
|
+
};
|
|
4156
|
+
window.addEventListener("message", authMessageListener2);
|
|
4157
|
+
authCleanupTimer2 = setInterval(() => {
|
|
4158
|
+
if (popup.closed) {
|
|
4159
|
+
cleanupAuthWindow2().catch(() => {
|
|
4160
|
+
});
|
|
4161
|
+
}
|
|
4162
|
+
}, 500);
|
|
4163
|
+
return;
|
|
4164
|
+
}
|
|
4165
|
+
};
|
|
4166
|
+
}
|
|
4167
|
+
});
|
|
4168
|
+
|
|
4169
|
+
// src/services/useMetaAuth.js
|
|
4170
|
+
var useMetaAuth_exports = {};
|
|
4171
|
+
__export(useMetaAuth_exports, {
|
|
4172
|
+
createMetaLogin: () => createMetaLogin,
|
|
4173
|
+
initializeMetaLogin: () => initializeMetaLogin,
|
|
4174
|
+
subscribeMetaLogin: () => subscribeMetaLogin
|
|
4175
|
+
});
|
|
4176
|
+
function emitMetaLogin(user, err2 = null) {
|
|
4177
|
+
debugAuth3("Emitting login result", { success: Boolean(user), error: err2?.message || null });
|
|
4178
|
+
metaListeners.forEach((cb) => {
|
|
4179
|
+
try {
|
|
4180
|
+
cb(user, err2);
|
|
4181
|
+
} catch (e2) {
|
|
4182
|
+
debugError("Meta listener error:", e2);
|
|
4183
|
+
}
|
|
4184
|
+
});
|
|
4185
|
+
}
|
|
4186
|
+
function subscribeMetaLogin(cb) {
|
|
4187
|
+
debugAuth3("Listener subscribed", { count: metaListeners.length + 1 });
|
|
4188
|
+
metaListeners.push(cb);
|
|
4189
|
+
return () => {
|
|
4190
|
+
const i4 = metaListeners.indexOf(cb);
|
|
4191
|
+
if (i4 !== -1) metaListeners.splice(i4, 1);
|
|
4192
|
+
debugAuth3("Listener unsubscribed", { count: metaListeners.length });
|
|
4193
|
+
};
|
|
4194
|
+
}
|
|
4195
|
+
var capacitorPluginsPromise3, tauriWebviewWindowPromise3, getCapacitorPlugins3, debugAuth3, debugAuthWarn3, debugAuthError3, getTauriWebviewWindow3, metaInitialized, metaListeners, authWindowRef3, authCleanupTimer3, authMessageListener3, closeAllTauriWebviews3, cleanupAuthWindow3, handleCallback3, initializeMetaLogin, createMetaLogin;
|
|
4196
|
+
var init_useMetaAuth = __esm({
|
|
4197
|
+
"src/services/useMetaAuth.js"() {
|
|
4198
|
+
init_usePlatform();
|
|
4199
|
+
init_debug();
|
|
4200
|
+
getCapacitorPlugins3 = () => {
|
|
4201
|
+
capacitorPluginsPromise3 ??= Promise.all([Promise.resolve().then(() => (init_esm(), esm_exports)), Promise.resolve().then(() => (init_esm2(), esm_exports2))]).then(([appModule, browserModule]) => ({ App: appModule.App, Browser: browserModule.Browser }));
|
|
4202
|
+
return capacitorPluginsPromise3;
|
|
4203
|
+
};
|
|
4204
|
+
debugAuth3 = (...args) => debugLog("[tevrocsdk][meta-auth]", ...args);
|
|
4205
|
+
debugAuthWarn3 = (...args) => debugWarn("[tevrocsdk][meta-auth]", ...args);
|
|
4206
|
+
debugAuthError3 = (...args) => debugError("[tevrocsdk][meta-auth]", ...args);
|
|
4207
|
+
getTauriWebviewWindow3 = async () => {
|
|
4208
|
+
tauriWebviewWindowPromise3 ??= Promise.resolve().then(() => (init_webviewWindow(), webviewWindow_exports)).then((module) => module.WebviewWindow);
|
|
4209
|
+
return tauriWebviewWindowPromise3;
|
|
4210
|
+
};
|
|
4211
|
+
metaInitialized = false;
|
|
4212
|
+
metaListeners = [];
|
|
4213
|
+
authWindowRef3 = null;
|
|
4214
|
+
authCleanupTimer3 = null;
|
|
4215
|
+
authMessageListener3 = null;
|
|
4216
|
+
closeAllTauriWebviews3 = async () => {
|
|
4217
|
+
if (!isTauri) return;
|
|
4218
|
+
const WebviewWindow2 = await getTauriWebviewWindow3();
|
|
4219
|
+
try {
|
|
4220
|
+
if (typeof WebviewWindow2.getAll === "function") {
|
|
4221
|
+
const windows = await WebviewWindow2.getAll();
|
|
4222
|
+
for (const webview of windows || []) {
|
|
4223
|
+
try {
|
|
4224
|
+
if (webview?.label && webview.label !== "main") {
|
|
4225
|
+
await webview.close();
|
|
4226
|
+
}
|
|
4227
|
+
} catch (e2) {
|
|
4228
|
+
debugWarn("Error closing Tauri webview:", e2);
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
} catch (e2) {
|
|
4233
|
+
debugWarn("Error listing Tauri webviews:", e2);
|
|
4234
|
+
}
|
|
4235
|
+
try {
|
|
4236
|
+
const tauriAuthWindow = await WebviewWindow2.getByLabel("auth");
|
|
4237
|
+
if (tauriAuthWindow) {
|
|
4238
|
+
await tauriAuthWindow.close();
|
|
4239
|
+
}
|
|
4240
|
+
} catch (e2) {
|
|
4241
|
+
debugWarn("Error closing Tauri auth window by label:", e2);
|
|
4242
|
+
}
|
|
4243
|
+
};
|
|
4244
|
+
cleanupAuthWindow3 = async () => {
|
|
4245
|
+
debugAuth3("Cleaning up auth window", { hasWindow: Boolean(authWindowRef3), isTauri, isCapacitor });
|
|
4246
|
+
if (authCleanupTimer3) {
|
|
4247
|
+
clearInterval(authCleanupTimer3);
|
|
4248
|
+
authCleanupTimer3 = null;
|
|
4249
|
+
}
|
|
4250
|
+
if (authMessageListener3 && typeof window !== "undefined") {
|
|
4251
|
+
window.removeEventListener("message", authMessageListener3);
|
|
4252
|
+
authMessageListener3 = null;
|
|
4253
|
+
}
|
|
4254
|
+
if (authWindowRef3) {
|
|
4255
|
+
const currentAuthWindow = authWindowRef3;
|
|
4256
|
+
authWindowRef3 = null;
|
|
4257
|
+
try {
|
|
4258
|
+
if (typeof currentAuthWindow?.close === "function") {
|
|
4259
|
+
await currentAuthWindow.close();
|
|
4260
|
+
}
|
|
4261
|
+
} catch (e2) {
|
|
4262
|
+
debugWarn("Error closing auth window:", e2);
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
if (isTauri) {
|
|
4266
|
+
const WebviewWindow2 = await getTauriWebviewWindow3();
|
|
4267
|
+
await closeAllTauriWebviews3();
|
|
4268
|
+
}
|
|
4269
|
+
if (isCapacitor) {
|
|
4270
|
+
try {
|
|
4271
|
+
const { Browser: Browser3 } = await getCapacitorPlugins3();
|
|
4272
|
+
await Browser3.close();
|
|
4273
|
+
} catch (e2) {
|
|
4274
|
+
debugWarn("Error closing Capacitor browser:", e2);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
if (typeof window !== "undefined" && window !== window.parent) {
|
|
4278
|
+
try {
|
|
4279
|
+
if (authWindowRef3 && typeof authWindowRef3.close === "function") {
|
|
4280
|
+
await authWindowRef3.close();
|
|
4281
|
+
}
|
|
4282
|
+
} catch (e2) {
|
|
4283
|
+
debugWarn("Error closing popup fallback:", e2);
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
};
|
|
4287
|
+
handleCallback3 = async (url) => {
|
|
4288
|
+
try {
|
|
4289
|
+
debugAuth3("Callback received", { hasUrl: Boolean(url), hasToken: Boolean(url?.includes("token=")) });
|
|
4290
|
+
await cleanupAuthWindow3();
|
|
4291
|
+
if (!url?.includes("token=")) {
|
|
4292
|
+
debugAuthWarn3("Callback did not include a token");
|
|
4293
|
+
return;
|
|
4294
|
+
}
|
|
4295
|
+
const params = new URLSearchParams(url.split("?")[1]);
|
|
4296
|
+
const token = params.get("token");
|
|
4297
|
+
debugAuth3("Verifying provider token", { tokenPresent: Boolean(token) });
|
|
4298
|
+
const res = await fetch(
|
|
4299
|
+
`https://graph.facebook.com/me?fields=id,name,first_name,last_name,email,picture&access_token=${encodeURIComponent(token)}`
|
|
4300
|
+
);
|
|
4301
|
+
if (!res.ok) throw new Error(`Meta profile request failed: ${res.status}`);
|
|
4302
|
+
const metaUser = await res.json();
|
|
4303
|
+
debugAuth3("Provider profile received", { idPresent: Boolean(metaUser.id), emailPresent: Boolean(metaUser.email) });
|
|
4304
|
+
const profile = {
|
|
4305
|
+
id: metaUser.id,
|
|
4306
|
+
name: metaUser.name,
|
|
4307
|
+
firstName: metaUser.first_name,
|
|
4308
|
+
lastName: metaUser.last_name,
|
|
4309
|
+
email: metaUser.email,
|
|
4310
|
+
photo: metaUser.picture?.data?.url,
|
|
4311
|
+
accessToken: token
|
|
4312
|
+
};
|
|
4313
|
+
debugLog("Meta user profile:", profile);
|
|
4314
|
+
localStorage.setItem("user", JSON.stringify(profile));
|
|
4315
|
+
localStorage.setItem("idToken", token);
|
|
4316
|
+
emitMetaLogin(profile, null);
|
|
4317
|
+
} catch (err2) {
|
|
4318
|
+
debugAuthError3("Callback failed", err2);
|
|
4319
|
+
emitMetaLogin(null, err2);
|
|
4320
|
+
}
|
|
4321
|
+
};
|
|
4322
|
+
initializeMetaLogin = async () => {
|
|
4323
|
+
if (metaInitialized) {
|
|
4324
|
+
debugAuth3("Already initialized");
|
|
4325
|
+
return;
|
|
4326
|
+
}
|
|
4327
|
+
metaInitialized = true;
|
|
4328
|
+
debugAuth3("Initializing listeners", { isCapacitor, isTauri });
|
|
4329
|
+
if (isCapacitor) {
|
|
4330
|
+
debugAuth3("Registering Capacitor appUrlOpen listener");
|
|
4331
|
+
const { App: App2 } = await getCapacitorPlugins3();
|
|
4332
|
+
App2.addListener("appUrlOpen", (event) => {
|
|
4333
|
+
handleCallback3(event.url);
|
|
4334
|
+
});
|
|
4335
|
+
}
|
|
4336
|
+
if (isTauri) {
|
|
4337
|
+
debugAuth3("Registering Tauri deep-link listener");
|
|
4338
|
+
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
4339
|
+
await listen2("deep-link://open-url", async (event) => {
|
|
4340
|
+
let url = event.payload;
|
|
4341
|
+
if (typeof url === "object") {
|
|
4342
|
+
url = url?.url || url?.payload || null;
|
|
4343
|
+
}
|
|
4344
|
+
if (!url) return;
|
|
4345
|
+
await handleCallback3(url);
|
|
4346
|
+
});
|
|
4347
|
+
}
|
|
4348
|
+
};
|
|
4349
|
+
createMetaLogin = async ({
|
|
4350
|
+
appId = "tevrocsoft",
|
|
4351
|
+
appName = "Tevroc",
|
|
4352
|
+
serviceUrl = "https://tevrocsoftapi.netlify.app"
|
|
4353
|
+
} = {}) => {
|
|
4354
|
+
debugAuth3("Creating login", { appId, appName, serviceUrl, isCapacitor, isTauri });
|
|
4355
|
+
await initializeMetaLogin();
|
|
4356
|
+
const authUrl = `${serviceUrl}/auth/meta/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
4357
|
+
if (isCapacitor) {
|
|
4358
|
+
debugAuth3("Opening mobile auth browser");
|
|
4359
|
+
const { Browser: Browser3 } = await getCapacitorPlugins3();
|
|
4360
|
+
await Browser3.open({ url: authUrl });
|
|
4361
|
+
return;
|
|
4362
|
+
}
|
|
4363
|
+
if (isTauri) {
|
|
4364
|
+
debugAuth3("Opening desktop auth window");
|
|
4365
|
+
const WebviewWindow2 = await getTauriWebviewWindow3();
|
|
4366
|
+
await closeAllTauriWebviews3();
|
|
4367
|
+
const url = `${serviceUrl}/auth/meta/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
4368
|
+
const win = new WebviewWindow2("auth", {
|
|
4369
|
+
url,
|
|
4370
|
+
title: `${appName} Login`,
|
|
4371
|
+
width: 550,
|
|
4372
|
+
height: 500,
|
|
4373
|
+
resizable: true,
|
|
4374
|
+
center: true
|
|
4375
|
+
});
|
|
4376
|
+
authWindowRef3 = win;
|
|
4377
|
+
win.once("tauri://created", () => {
|
|
4378
|
+
debugAuth3("Auth window opened");
|
|
4379
|
+
});
|
|
4380
|
+
win.once("tauri://error", (e2) => {
|
|
4381
|
+
debugAuthError3("Auth window error", e2);
|
|
4382
|
+
});
|
|
4383
|
+
return;
|
|
4384
|
+
}
|
|
4385
|
+
const isLocalhost = true;
|
|
4386
|
+
const detectedAppId = typeof window !== "undefined" ? window.location.host : appId;
|
|
4387
|
+
const mode = isLocalhost ? "localhost" : "netlify";
|
|
4388
|
+
const finalUrl = `${serviceUrl}/auth/meta/login?mode=${mode}&app=${encodeURIComponent(
|
|
4389
|
+
detectedAppId
|
|
4390
|
+
)}&name=${encodeURIComponent(appName)}`;
|
|
4391
|
+
if (isLocalhost) {
|
|
4392
|
+
debugAuth3("Opening web auth popup", { mode, appId: detectedAppId });
|
|
4393
|
+
const popup = window.open(
|
|
4394
|
+
finalUrl,
|
|
4395
|
+
"metaLogin",
|
|
4396
|
+
"width=500,height=650"
|
|
4397
|
+
);
|
|
4398
|
+
if (!popup) {
|
|
4399
|
+
debugAuthError3("Popup blocked");
|
|
4400
|
+
throw new Error("Meta sign-in popup was blocked. Allow popups and try again.");
|
|
4401
|
+
}
|
|
4402
|
+
authWindowRef3 = popup;
|
|
4403
|
+
authMessageListener3 = async (event) => {
|
|
4404
|
+
const serviceOrigin = new URL(serviceUrl).origin;
|
|
4405
|
+
if (event.origin !== serviceOrigin) return;
|
|
4406
|
+
if (event.data?.type === "meta-auth") {
|
|
4407
|
+
debugAuth3("Received popup auth message", { origin: event.origin });
|
|
4408
|
+
const token = event.data?.token || null;
|
|
4409
|
+
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
4410
|
+
await handleCallback3(url);
|
|
4411
|
+
}
|
|
4412
|
+
};
|
|
4413
|
+
window.addEventListener("message", authMessageListener3);
|
|
4414
|
+
authCleanupTimer3 = setInterval(() => {
|
|
4415
|
+
if (popup.closed) {
|
|
4416
|
+
cleanupAuthWindow3().catch(() => {
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
}, 500);
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
};
|
|
4423
|
+
}
|
|
4424
|
+
});
|
|
4425
|
+
|
|
3889
4426
|
// src/services/useYocoPayment.js
|
|
3890
4427
|
function emitPaymentStatus(status, err2 = null) {
|
|
3891
4428
|
paymentStatusListeners.forEach((cb) => {
|
|
@@ -3903,18 +4440,18 @@ function subscribePaymentStatus(cb) {
|
|
|
3903
4440
|
if (i4 !== -1) paymentStatusListeners.splice(i4, 1);
|
|
3904
4441
|
};
|
|
3905
4442
|
}
|
|
3906
|
-
var
|
|
4443
|
+
var capacitorPluginsPromise4, tauriWebviewWindowPromise4, getCapacitorPlugins4, getTauriWebviewWindow4, paymentInitialized, paymentStatusListeners, paymentWindowRef, logs, addLog, handlePaymentCallback, initializePayment, createPayment;
|
|
3907
4444
|
var init_useYocoPayment = __esm({
|
|
3908
4445
|
"src/services/useYocoPayment.js"() {
|
|
3909
4446
|
init_usePlatform();
|
|
3910
4447
|
init_debug();
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
return
|
|
4448
|
+
getCapacitorPlugins4 = () => {
|
|
4449
|
+
capacitorPluginsPromise4 ??= Promise.all([Promise.resolve().then(() => (init_esm(), esm_exports)), Promise.resolve().then(() => (init_esm2(), esm_exports2))]).then(([appModule, browserModule]) => ({ App: appModule.App, Browser: browserModule.Browser }));
|
|
4450
|
+
return capacitorPluginsPromise4;
|
|
3914
4451
|
};
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
return
|
|
4452
|
+
getTauriWebviewWindow4 = async () => {
|
|
4453
|
+
tauriWebviewWindowPromise4 ??= Promise.resolve().then(() => (init_webviewWindow(), webviewWindow_exports)).then((module) => module.WebviewWindow);
|
|
4454
|
+
return tauriWebviewWindowPromise4;
|
|
3918
4455
|
};
|
|
3919
4456
|
paymentInitialized = false;
|
|
3920
4457
|
paymentStatusListeners = [];
|
|
@@ -3956,7 +4493,7 @@ var init_useYocoPayment = __esm({
|
|
|
3956
4493
|
if (paymentInitialized) return;
|
|
3957
4494
|
paymentInitialized = true;
|
|
3958
4495
|
if (isCapacitor) {
|
|
3959
|
-
const { App: App2 } = await
|
|
4496
|
+
const { App: App2 } = await getCapacitorPlugins4();
|
|
3960
4497
|
App2.addListener("appUrlOpen", (event) => {
|
|
3961
4498
|
handlePaymentCallback(
|
|
3962
4499
|
event.url,
|
|
@@ -3999,14 +4536,14 @@ var init_useYocoPayment = __esm({
|
|
|
3999
4536
|
const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
4000
4537
|
debugLog(basePaymentUrl, paymentUrl);
|
|
4001
4538
|
if (isCapacitor) {
|
|
4002
|
-
const { Browser: Browser3 } = await
|
|
4539
|
+
const { Browser: Browser3 } = await getCapacitorPlugins4();
|
|
4003
4540
|
await Browser3.open({
|
|
4004
4541
|
url: paymentUrl
|
|
4005
4542
|
});
|
|
4006
4543
|
return;
|
|
4007
4544
|
}
|
|
4008
4545
|
if (isTauri) {
|
|
4009
|
-
const WebviewWindow2 = await
|
|
4546
|
+
const WebviewWindow2 = await getTauriWebviewWindow4();
|
|
4010
4547
|
const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
4011
4548
|
const win = new WebviewWindow2("payment", {
|
|
4012
4549
|
url,
|
|
@@ -26939,6 +27476,8 @@ var init_esm6 = __esm({
|
|
|
26939
27476
|
|
|
26940
27477
|
// src/index.js
|
|
26941
27478
|
init_useGoogleAuth();
|
|
27479
|
+
init_useFacebookAuth();
|
|
27480
|
+
init_useMetaAuth();
|
|
26942
27481
|
init_useYocoPayment();
|
|
26943
27482
|
init_debug();
|
|
26944
27483
|
|
|
@@ -40762,131 +41301,6 @@ function createPdfApi() {
|
|
|
40762
41301
|
};
|
|
40763
41302
|
}
|
|
40764
41303
|
|
|
40765
|
-
// src/services/notifications.js
|
|
40766
|
-
var isBrowser = () => typeof window !== "undefined" && typeof Notification !== "undefined";
|
|
40767
|
-
function createNotificationService() {
|
|
40768
|
-
const listeners2 = /* @__PURE__ */ new Set();
|
|
40769
|
-
const scheduled = /* @__PURE__ */ new Map();
|
|
40770
|
-
let nativeListenerInstalled = false;
|
|
40771
|
-
const emit2 = (event) => listeners2.forEach((listener) => listener(event));
|
|
40772
|
-
const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
|
|
40773
|
-
const installNativeListener = () => {
|
|
40774
|
-
if (nativeListenerInstalled) return;
|
|
40775
|
-
const plugin = appPlugin();
|
|
40776
|
-
if (!plugin?.addListener) return;
|
|
40777
|
-
nativeListenerInstalled = true;
|
|
40778
|
-
plugin.addListener("notificationAction", (event) => {
|
|
40779
|
-
let data = event?.data || {};
|
|
40780
|
-
if (typeof data === "string") {
|
|
40781
|
-
try {
|
|
40782
|
-
data = JSON.parse(data);
|
|
40783
|
-
} catch {
|
|
40784
|
-
data = {};
|
|
40785
|
-
}
|
|
40786
|
-
}
|
|
40787
|
-
emit2({
|
|
40788
|
-
id: event?.id,
|
|
40789
|
-
action: event?.action || "open",
|
|
40790
|
-
reply: event?.reply || "",
|
|
40791
|
-
data,
|
|
40792
|
-
platform: "capacitor"
|
|
40793
|
-
});
|
|
40794
|
-
});
|
|
40795
|
-
plugin.consumePendingAction?.().catch?.(() => {
|
|
40796
|
-
});
|
|
40797
|
-
};
|
|
40798
|
-
const permission = async () => {
|
|
40799
|
-
const plugin = appPlugin();
|
|
40800
|
-
if (plugin?.checkPermissions) return plugin.checkPermissions();
|
|
40801
|
-
if (globalThis?.__TAURI_INTERNALS__) {
|
|
40802
|
-
try {
|
|
40803
|
-
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
40804
|
-
return { display: await tauri.isPermissionGranted() ? "granted" : "prompt" };
|
|
40805
|
-
} catch {
|
|
40806
|
-
return { display: "denied" };
|
|
40807
|
-
}
|
|
40808
|
-
}
|
|
40809
|
-
return { display: isBrowser() ? Notification.permission : "denied" };
|
|
40810
|
-
};
|
|
40811
|
-
const requestPermission = async () => {
|
|
40812
|
-
const plugin = appPlugin();
|
|
40813
|
-
if (plugin?.requestPermissions) return plugin.requestPermissions();
|
|
40814
|
-
if (globalThis?.__TAURI_INTERNALS__) {
|
|
40815
|
-
try {
|
|
40816
|
-
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
40817
|
-
return { display: await tauri.requestPermission() };
|
|
40818
|
-
} catch {
|
|
40819
|
-
return { display: "denied" };
|
|
40820
|
-
}
|
|
40821
|
-
}
|
|
40822
|
-
return { display: isBrowser() ? await Notification.requestPermission() : "denied" };
|
|
40823
|
-
};
|
|
40824
|
-
const show = async (options = {}) => {
|
|
40825
|
-
const id = String(options.id || `notification_${Date.now()}_${Math.random().toString(36).slice(2)}`);
|
|
40826
|
-
const request = {
|
|
40827
|
-
id,
|
|
40828
|
-
title: options.title || "Notification",
|
|
40829
|
-
body: options.body || "",
|
|
40830
|
-
data: options.data || {},
|
|
40831
|
-
actions: options.actions || [],
|
|
40832
|
-
silent: Boolean(options.silent),
|
|
40833
|
-
channel: options.channel || "general",
|
|
40834
|
-
style: options.style || {}
|
|
40835
|
-
};
|
|
40836
|
-
const plugin = appPlugin();
|
|
40837
|
-
if (plugin?.show) {
|
|
40838
|
-
installNativeListener();
|
|
40839
|
-
await plugin.show(request);
|
|
40840
|
-
return { id, platform: "capacitor" };
|
|
40841
|
-
}
|
|
40842
|
-
if (globalThis?.__TAURI_INTERNALS__) {
|
|
40843
|
-
try {
|
|
40844
|
-
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
40845
|
-
const current = await tauri.isPermissionGranted() ? "granted" : await tauri.requestPermission();
|
|
40846
|
-
if (current === "granted") {
|
|
40847
|
-
tauri.sendNotification({ title: request.title, body: request.body, extra: request.data });
|
|
40848
|
-
return { id, platform: "tauri" };
|
|
40849
|
-
}
|
|
40850
|
-
} catch {
|
|
40851
|
-
}
|
|
40852
|
-
}
|
|
40853
|
-
if (!isBrowser()) throw new Error("Notifications are not supported on this platform.");
|
|
40854
|
-
const state = Notification.permission === "default" ? await Notification.requestPermission() : Notification.permission;
|
|
40855
|
-
if (state !== "granted") throw new Error("Notification permission was not granted.");
|
|
40856
|
-
const notification = new Notification(request.title, { body: request.body, tag: id, data: request.data, silent: request.silent });
|
|
40857
|
-
notification.onclick = () => emit2({ id, action: "open", data: request.data, platform: "web" });
|
|
40858
|
-
return { id, platform: "web", notification };
|
|
40859
|
-
};
|
|
40860
|
-
const schedule = async (options = {}) => {
|
|
40861
|
-
const at2 = new Date(options.at || Date.now()).getTime();
|
|
40862
|
-
const delay = Math.max(0, at2 - Date.now());
|
|
40863
|
-
const id = String(options.id || `notification_${at2}_${Math.random().toString(36).slice(2)}`);
|
|
40864
|
-
const timeout = setTimeout(() => {
|
|
40865
|
-
scheduled.delete(id);
|
|
40866
|
-
show({ ...options, id }).catch((error) => emit2({ type: "error", error }));
|
|
40867
|
-
}, delay);
|
|
40868
|
-
scheduled.set(id, timeout);
|
|
40869
|
-
return { id, at: at2 };
|
|
40870
|
-
};
|
|
40871
|
-
const cancel = async (id) => {
|
|
40872
|
-
const timeout = scheduled.get(String(id));
|
|
40873
|
-
if (timeout) clearTimeout(timeout);
|
|
40874
|
-
scheduled.delete(String(id));
|
|
40875
|
-
await appPlugin()?.cancel?.({ id: String(id) });
|
|
40876
|
-
};
|
|
40877
|
-
const cancelAll = async () => {
|
|
40878
|
-
for (const timeout of scheduled.values()) clearTimeout(timeout);
|
|
40879
|
-
scheduled.clear();
|
|
40880
|
-
await appPlugin()?.cancelAll?.();
|
|
40881
|
-
};
|
|
40882
|
-
const onAction = (listener) => {
|
|
40883
|
-
installNativeListener();
|
|
40884
|
-
listeners2.add(listener);
|
|
40885
|
-
return () => listeners2.delete(listener);
|
|
40886
|
-
};
|
|
40887
|
-
return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
|
|
40888
|
-
}
|
|
40889
|
-
|
|
40890
41304
|
// src/services/agentNotifications.js
|
|
40891
41305
|
var toList = (result) => Array.isArray(result) ? result : result?.data || [];
|
|
40892
41306
|
var latestByTime = (records) => [...records].sort((a3, b2) => {
|
|
@@ -40895,7 +41309,6 @@ var latestByTime = (records) => [...records].sort((a3, b2) => {
|
|
|
40895
41309
|
return right - left;
|
|
40896
41310
|
})[0] || null;
|
|
40897
41311
|
function createAgentNotificationService(client) {
|
|
40898
|
-
const notifications = client.notifications || createNotificationService();
|
|
40899
41312
|
let timer = null;
|
|
40900
41313
|
let stopped = true;
|
|
40901
41314
|
const seen = /* @__PURE__ */ new Map();
|
|
@@ -40976,7 +41389,7 @@ function createAgentNotificationService(client) {
|
|
|
40976
41389
|
if (action === "reject") return reject(session);
|
|
40977
41390
|
if (action === "reply") return reply(session, text2);
|
|
40978
41391
|
};
|
|
40979
|
-
const showNative = (request) => notifications.show({
|
|
41392
|
+
const showNative = (request) => client.notifications.show({
|
|
40980
41393
|
id: `agent-request-${request.sessionId}`,
|
|
40981
41394
|
title: request.title,
|
|
40982
41395
|
body: request.body,
|
|
@@ -41055,7 +41468,7 @@ function createAgentNotificationService(client) {
|
|
|
41055
41468
|
listeners2.add(listener);
|
|
41056
41469
|
return () => listeners2.delete(listener);
|
|
41057
41470
|
};
|
|
41058
|
-
notifications.onAction(({ action, data, reply: text2 }) => {
|
|
41471
|
+
client.notifications.onAction(({ action, data, reply: text2 }) => {
|
|
41059
41472
|
if (data?.sessionId && String(data.kind || "").startsWith("agent_")) {
|
|
41060
41473
|
dispatchAction({ action, sessionId: data.sessionId, reply: text2 }).catch((error) => notify({ type: "error", error }));
|
|
41061
41474
|
}
|
|
@@ -41063,14 +41476,138 @@ function createAgentNotificationService(client) {
|
|
|
41063
41476
|
return { start, stop, check, onEvent, accept, reject, reply, dispatchAction };
|
|
41064
41477
|
}
|
|
41065
41478
|
|
|
41479
|
+
// src/services/notifications.js
|
|
41480
|
+
var isBrowser = () => typeof window !== "undefined" && typeof Notification !== "undefined";
|
|
41481
|
+
function createNotificationService() {
|
|
41482
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
41483
|
+
const scheduled = /* @__PURE__ */ new Map();
|
|
41484
|
+
let nativeListenerInstalled = false;
|
|
41485
|
+
const emit2 = (event) => listeners2.forEach((listener) => listener(event));
|
|
41486
|
+
const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
|
|
41487
|
+
const installNativeListener = () => {
|
|
41488
|
+
if (nativeListenerInstalled) return;
|
|
41489
|
+
const plugin = appPlugin();
|
|
41490
|
+
if (!plugin?.addListener) return;
|
|
41491
|
+
nativeListenerInstalled = true;
|
|
41492
|
+
plugin.addListener("notificationAction", (event) => {
|
|
41493
|
+
let data = event?.data || {};
|
|
41494
|
+
if (typeof data === "string") {
|
|
41495
|
+
try {
|
|
41496
|
+
data = JSON.parse(data);
|
|
41497
|
+
} catch {
|
|
41498
|
+
data = {};
|
|
41499
|
+
}
|
|
41500
|
+
}
|
|
41501
|
+
emit2({
|
|
41502
|
+
id: event?.id,
|
|
41503
|
+
action: event?.action || "open",
|
|
41504
|
+
reply: event?.reply || "",
|
|
41505
|
+
data,
|
|
41506
|
+
platform: "capacitor"
|
|
41507
|
+
});
|
|
41508
|
+
});
|
|
41509
|
+
plugin.consumePendingAction?.().catch?.(() => {
|
|
41510
|
+
});
|
|
41511
|
+
};
|
|
41512
|
+
const permission = async () => {
|
|
41513
|
+
const plugin = appPlugin();
|
|
41514
|
+
if (plugin?.checkPermissions) return plugin.checkPermissions();
|
|
41515
|
+
if (globalThis?.__TAURI_INTERNALS__) {
|
|
41516
|
+
try {
|
|
41517
|
+
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
41518
|
+
return { display: await tauri.isPermissionGranted() ? "granted" : "prompt" };
|
|
41519
|
+
} catch {
|
|
41520
|
+
return { display: "denied" };
|
|
41521
|
+
}
|
|
41522
|
+
}
|
|
41523
|
+
return { display: isBrowser() ? Notification.permission : "denied" };
|
|
41524
|
+
};
|
|
41525
|
+
const requestPermission = async () => {
|
|
41526
|
+
const plugin = appPlugin();
|
|
41527
|
+
if (plugin?.requestPermissions) return plugin.requestPermissions();
|
|
41528
|
+
if (globalThis?.__TAURI_INTERNALS__) {
|
|
41529
|
+
try {
|
|
41530
|
+
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
41531
|
+
return { display: await tauri.requestPermission() };
|
|
41532
|
+
} catch {
|
|
41533
|
+
return { display: "denied" };
|
|
41534
|
+
}
|
|
41535
|
+
}
|
|
41536
|
+
return { display: isBrowser() ? await Notification.requestPermission() : "denied" };
|
|
41537
|
+
};
|
|
41538
|
+
const show = async (options = {}) => {
|
|
41539
|
+
const id = String(options.id || `notification_${Date.now()}_${Math.random().toString(36).slice(2)}`);
|
|
41540
|
+
const request = {
|
|
41541
|
+
id,
|
|
41542
|
+
title: options.title || "Notification",
|
|
41543
|
+
body: options.body || "",
|
|
41544
|
+
data: options.data || {},
|
|
41545
|
+
actions: options.actions || [],
|
|
41546
|
+
silent: Boolean(options.silent),
|
|
41547
|
+
channel: options.channel || "general",
|
|
41548
|
+
style: options.style || {}
|
|
41549
|
+
};
|
|
41550
|
+
const plugin = appPlugin();
|
|
41551
|
+
if (plugin?.show) {
|
|
41552
|
+
installNativeListener();
|
|
41553
|
+
await plugin.show(request);
|
|
41554
|
+
return { id, platform: "capacitor" };
|
|
41555
|
+
}
|
|
41556
|
+
if (globalThis?.__TAURI_INTERNALS__) {
|
|
41557
|
+
try {
|
|
41558
|
+
const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
|
|
41559
|
+
const current = await tauri.isPermissionGranted() ? "granted" : await tauri.requestPermission();
|
|
41560
|
+
if (current === "granted") {
|
|
41561
|
+
tauri.sendNotification({ title: request.title, body: request.body, extra: request.data });
|
|
41562
|
+
return { id, platform: "tauri" };
|
|
41563
|
+
}
|
|
41564
|
+
} catch {
|
|
41565
|
+
}
|
|
41566
|
+
}
|
|
41567
|
+
if (!isBrowser()) throw new Error("Notifications are not supported on this platform.");
|
|
41568
|
+
const state = Notification.permission === "default" ? await Notification.requestPermission() : Notification.permission;
|
|
41569
|
+
if (state !== "granted") throw new Error("Notification permission was not granted.");
|
|
41570
|
+
const notification = new Notification(request.title, { body: request.body, tag: id, data: request.data, silent: request.silent });
|
|
41571
|
+
notification.onclick = () => emit2({ id, action: "open", data: request.data, platform: "web" });
|
|
41572
|
+
return { id, platform: "web", notification };
|
|
41573
|
+
};
|
|
41574
|
+
const schedule = async (options = {}) => {
|
|
41575
|
+
const at2 = new Date(options.at || Date.now()).getTime();
|
|
41576
|
+
const delay = Math.max(0, at2 - Date.now());
|
|
41577
|
+
const id = String(options.id || `notification_${at2}_${Math.random().toString(36).slice(2)}`);
|
|
41578
|
+
const timeout = setTimeout(() => {
|
|
41579
|
+
scheduled.delete(id);
|
|
41580
|
+
show({ ...options, id }).catch((error) => emit2({ type: "error", error }));
|
|
41581
|
+
}, delay);
|
|
41582
|
+
scheduled.set(id, timeout);
|
|
41583
|
+
return { id, at: at2 };
|
|
41584
|
+
};
|
|
41585
|
+
const cancel = async (id) => {
|
|
41586
|
+
const timeout = scheduled.get(String(id));
|
|
41587
|
+
if (timeout) clearTimeout(timeout);
|
|
41588
|
+
scheduled.delete(String(id));
|
|
41589
|
+
await appPlugin()?.cancel?.({ id: String(id) });
|
|
41590
|
+
};
|
|
41591
|
+
const cancelAll = async () => {
|
|
41592
|
+
for (const timeout of scheduled.values()) clearTimeout(timeout);
|
|
41593
|
+
scheduled.clear();
|
|
41594
|
+
await appPlugin()?.cancelAll?.();
|
|
41595
|
+
};
|
|
41596
|
+
const onAction = (listener) => {
|
|
41597
|
+
installNativeListener();
|
|
41598
|
+
listeners2.add(listener);
|
|
41599
|
+
return () => listeners2.delete(listener);
|
|
41600
|
+
};
|
|
41601
|
+
return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
|
|
41602
|
+
}
|
|
41603
|
+
|
|
41066
41604
|
// src/services/chatNotifications.js
|
|
41067
41605
|
function createChatNotificationService(client) {
|
|
41068
|
-
const notifications = client.notifications || createNotificationService();
|
|
41069
41606
|
const listeners2 = /* @__PURE__ */ new Set();
|
|
41070
41607
|
const emit2 = (event) => listeners2.forEach((listener) => listener(event));
|
|
41071
41608
|
const showMessage = async ({ sessionId, title = "New chat message", body = "", data = {}, style } = {}) => {
|
|
41072
41609
|
if (!sessionId) return null;
|
|
41073
|
-
return notifications.show({
|
|
41610
|
+
return client.notifications.show({
|
|
41074
41611
|
id: `chat-message-${sessionId}-${Date.now()}`,
|
|
41075
41612
|
title,
|
|
41076
41613
|
body,
|
|
@@ -41085,7 +41622,7 @@ function createChatNotificationService(client) {
|
|
|
41085
41622
|
};
|
|
41086
41623
|
const showStatus = async ({ sessionId, title = "Chat update", body = "", data = {}, style } = {}) => {
|
|
41087
41624
|
if (!sessionId) return null;
|
|
41088
|
-
return notifications.show({
|
|
41625
|
+
return client.notifications.show({
|
|
41089
41626
|
id: `chat-status-${sessionId}-${Date.now()}`,
|
|
41090
41627
|
title,
|
|
41091
41628
|
body,
|
|
@@ -41099,7 +41636,7 @@ function createChatNotificationService(client) {
|
|
|
41099
41636
|
listeners2.add(listener);
|
|
41100
41637
|
return () => listeners2.delete(listener);
|
|
41101
41638
|
};
|
|
41102
|
-
notifications.onAction(({ action, data, reply }) => {
|
|
41639
|
+
client.notifications.onAction(({ action, data, reply }) => {
|
|
41103
41640
|
if (data?.sessionId && ["chat_message", "chat_status"].includes(data.kind)) {
|
|
41104
41641
|
emit2({ type: action === "reply" ? "reply" : action, action, sessionId: data.sessionId, reply: reply || "", data });
|
|
41105
41642
|
}
|
|
@@ -42110,6 +42647,20 @@ async function getGoogleModule() {
|
|
|
42110
42647
|
}
|
|
42111
42648
|
return googleModule;
|
|
42112
42649
|
}
|
|
42650
|
+
var facebookModule = null;
|
|
42651
|
+
async function getFacebookModule() {
|
|
42652
|
+
if (!facebookModule) {
|
|
42653
|
+
facebookModule = await Promise.resolve().then(() => (init_useFacebookAuth(), useFacebookAuth_exports));
|
|
42654
|
+
}
|
|
42655
|
+
return facebookModule;
|
|
42656
|
+
}
|
|
42657
|
+
var metaModule = null;
|
|
42658
|
+
async function getMetaModule() {
|
|
42659
|
+
if (!metaModule) {
|
|
42660
|
+
metaModule = await Promise.resolve().then(() => (init_useMetaAuth(), useMetaAuth_exports));
|
|
42661
|
+
}
|
|
42662
|
+
return metaModule;
|
|
42663
|
+
}
|
|
42113
42664
|
var TevrocError = class extends Error {
|
|
42114
42665
|
constructor(message2, options = {}) {
|
|
42115
42666
|
super(message2);
|
|
@@ -42522,6 +43073,7 @@ function createAuthApi(client) {
|
|
|
42522
43073
|
// base44
|
|
42523
43074
|
loginWithProvider: async (provider, redirectTo, setToken = async () => {
|
|
42524
43075
|
}) => {
|
|
43076
|
+
console.log(client, "loginWithProvider called", { provider, redirectTo });
|
|
42525
43077
|
if (provider === "google") {
|
|
42526
43078
|
const { createGoogleLogin: createGoogleLogin2, subscribeGoogleLogin: subscribeGoogleLogin2 } = await getGoogleModule();
|
|
42527
43079
|
debugLog2(client, {
|
|
@@ -42529,7 +43081,7 @@ function createAuthApi(client) {
|
|
|
42529
43081
|
appId: client.appId,
|
|
42530
43082
|
appName: client.appName
|
|
42531
43083
|
});
|
|
42532
|
-
createGoogleLogin2({
|
|
43084
|
+
await createGoogleLogin2({
|
|
42533
43085
|
serviceUrl: client.serviceUrl,
|
|
42534
43086
|
appId: client.appId,
|
|
42535
43087
|
appName: client.appName
|
|
@@ -42551,12 +43103,100 @@ function createAuthApi(client) {
|
|
|
42551
43103
|
});
|
|
42552
43104
|
}
|
|
42553
43105
|
}
|
|
43106
|
+
if (provider === "facebook") {
|
|
43107
|
+
const { createFacebookLogin: createFacebookLogin2, subscribeFacebookLogin: subscribeFacebookLogin2 } = await getFacebookModule();
|
|
43108
|
+
debugLog2(client, {
|
|
43109
|
+
serviceUrl: client.serviceUrl,
|
|
43110
|
+
appId: client.appId,
|
|
43111
|
+
appName: client.appName
|
|
43112
|
+
});
|
|
43113
|
+
if (redirectTo) {
|
|
43114
|
+
const unsub = subscribeFacebookLogin2(async (user, err2) => {
|
|
43115
|
+
debugLog2(client, "Facebook callback:", user, err2);
|
|
43116
|
+
unsub();
|
|
43117
|
+
if (!user) return;
|
|
43118
|
+
const result = await client.request("/auth/facebook", {
|
|
43119
|
+
method: "POST",
|
|
43120
|
+
body: buildAuthPayload({ accessToken: user.accessToken }, client),
|
|
43121
|
+
auth: false
|
|
43122
|
+
});
|
|
43123
|
+
debugLog2(client, result);
|
|
43124
|
+
await setToken(result.token, result.user);
|
|
43125
|
+
debugLog2(client, "Redirecting to:", redirectTo);
|
|
43126
|
+
window.location.href = redirectTo;
|
|
43127
|
+
});
|
|
43128
|
+
try {
|
|
43129
|
+
await createFacebookLogin2({
|
|
43130
|
+
serviceUrl: client.serviceUrl,
|
|
43131
|
+
appId: client.appId,
|
|
43132
|
+
appName: client.appName
|
|
43133
|
+
});
|
|
43134
|
+
} catch (error) {
|
|
43135
|
+
unsub();
|
|
43136
|
+
throw error;
|
|
43137
|
+
}
|
|
43138
|
+
} else {
|
|
43139
|
+
await createFacebookLogin2({
|
|
43140
|
+
serviceUrl: client.serviceUrl,
|
|
43141
|
+
appId: client.appId,
|
|
43142
|
+
appName: client.appName
|
|
43143
|
+
});
|
|
43144
|
+
}
|
|
43145
|
+
}
|
|
43146
|
+
if (provider === "meta") {
|
|
43147
|
+
const { createMetaLogin: createMetaLogin2, subscribeMetaLogin: subscribeMetaLogin2 } = await getMetaModule();
|
|
43148
|
+
debugLog2(client, {
|
|
43149
|
+
serviceUrl: client.serviceUrl,
|
|
43150
|
+
appId: client.appId,
|
|
43151
|
+
appName: client.appName
|
|
43152
|
+
});
|
|
43153
|
+
if (redirectTo) {
|
|
43154
|
+
const unsub = subscribeMetaLogin2(async (user, err2) => {
|
|
43155
|
+
debugLog2(client, "Meta callback:", user, err2);
|
|
43156
|
+
unsub();
|
|
43157
|
+
if (!user) return;
|
|
43158
|
+
const result = await client.request("/auth/meta", {
|
|
43159
|
+
method: "POST",
|
|
43160
|
+
body: buildAuthPayload({ accessToken: user.accessToken }, client),
|
|
43161
|
+
auth: false
|
|
43162
|
+
});
|
|
43163
|
+
debugLog2(client, result);
|
|
43164
|
+
await setToken(result.token, result.user);
|
|
43165
|
+
debugLog2(client, "Redirecting to:", redirectTo);
|
|
43166
|
+
window.location.href = redirectTo;
|
|
43167
|
+
});
|
|
43168
|
+
try {
|
|
43169
|
+
await createMetaLogin2({
|
|
43170
|
+
serviceUrl: client.serviceUrl,
|
|
43171
|
+
appId: client.appId,
|
|
43172
|
+
appName: client.appName
|
|
43173
|
+
});
|
|
43174
|
+
} catch (error) {
|
|
43175
|
+
unsub();
|
|
43176
|
+
throw error;
|
|
43177
|
+
}
|
|
43178
|
+
} else {
|
|
43179
|
+
await createMetaLogin2({
|
|
43180
|
+
serviceUrl: client.serviceUrl,
|
|
43181
|
+
appId: client.appId,
|
|
43182
|
+
appName: client.appName
|
|
43183
|
+
});
|
|
43184
|
+
}
|
|
43185
|
+
}
|
|
42554
43186
|
},
|
|
42555
43187
|
// extra
|
|
42556
43188
|
googleLogin: (params) => createGoogleLogin(params),
|
|
42557
43189
|
onGoogleLogin: (callback) => {
|
|
42558
43190
|
return subscribeGoogleLogin(callback);
|
|
42559
43191
|
},
|
|
43192
|
+
facebookLogin: (params) => createFacebookLogin(params),
|
|
43193
|
+
onFacebookLogin: (callback) => {
|
|
43194
|
+
return subscribeFacebookLogin(callback);
|
|
43195
|
+
},
|
|
43196
|
+
metaLogin: (params) => createMetaLogin(params),
|
|
43197
|
+
onMetaLogin: (callback) => {
|
|
43198
|
+
return subscribeMetaLogin(callback);
|
|
43199
|
+
},
|
|
42560
43200
|
//
|
|
42561
43201
|
async login(input) {
|
|
42562
43202
|
const body = buildAuthPayload(input, client);
|
|
@@ -42564,6 +43204,33 @@ function createAuthApi(client) {
|
|
|
42564
43204
|
if (result.token) client.setToken(result.token);
|
|
42565
43205
|
return result;
|
|
42566
43206
|
},
|
|
43207
|
+
async loginWithGoogle(input) {
|
|
43208
|
+
const result = await client.request("/auth/google", {
|
|
43209
|
+
method: "POST",
|
|
43210
|
+
body: buildAuthPayload(input, client),
|
|
43211
|
+
auth: false
|
|
43212
|
+
});
|
|
43213
|
+
if (result.token) client.setToken(result.token);
|
|
43214
|
+
return result;
|
|
43215
|
+
},
|
|
43216
|
+
async loginWithFacebook(input) {
|
|
43217
|
+
const result = await client.request("/auth/facebook", {
|
|
43218
|
+
method: "POST",
|
|
43219
|
+
body: buildAuthPayload(input, client),
|
|
43220
|
+
auth: false
|
|
43221
|
+
});
|
|
43222
|
+
if (result.token) client.setToken(result.token);
|
|
43223
|
+
return result;
|
|
43224
|
+
},
|
|
43225
|
+
async loginWithMeta(input) {
|
|
43226
|
+
const result = await client.request("/auth/meta", {
|
|
43227
|
+
method: "POST",
|
|
43228
|
+
body: buildAuthPayload(input, client),
|
|
43229
|
+
auth: false
|
|
43230
|
+
});
|
|
43231
|
+
if (result.token) client.setToken(result.token);
|
|
43232
|
+
return result;
|
|
43233
|
+
},
|
|
42567
43234
|
async logout() {
|
|
42568
43235
|
const result = await client.request("/auth/logout", { method: "POST", body: buildAuthPayload({}, client) });
|
|
42569
43236
|
client.clearToken();
|
|
@@ -43610,4 +44277,3 @@ jspdf/dist/jspdf.es.min.js:
|
|
|
43610
44277
|
* ====================================================================
|
|
43611
44278
|
*)
|
|
43612
44279
|
*/
|
|
43613
|
-
//# sourceMappingURL=tevroc-sdk.esm.js.map
|