@base44-preview/sdk 0.8.44-pr.264.d146bf4 → 0.8.44-pr.264.d98f3ac
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/modules/auth.js +5 -15
- package/package.json +1 -1
package/dist/modules/auth.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { removeAccessToken } from "../utils/auth-utils.js";
|
|
1
2
|
import { resetAnalyticsSessionContext } from "./analytics.js";
|
|
2
3
|
function isInsideIframe() {
|
|
3
4
|
if (typeof window === "undefined")
|
|
@@ -53,19 +54,6 @@ function loginViaPopup(url, redirectUrl, expectedOrigin) {
|
|
|
53
54
|
}, 500);
|
|
54
55
|
window.addEventListener("message", onMessage);
|
|
55
56
|
}
|
|
56
|
-
function removeStoredAccessToken() {
|
|
57
|
-
if (typeof window === "undefined" || !window.localStorage) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
window.localStorage.removeItem("base44_access_token");
|
|
62
|
-
// "token" is the key the platform-v2 built-in SDK used
|
|
63
|
-
window.localStorage.removeItem("token");
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
console.error("Failed to remove token from localStorage:", e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
57
|
/**
|
|
70
58
|
* Creates the auth module for the Base44 SDK.
|
|
71
59
|
*
|
|
@@ -130,7 +118,8 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
130
118
|
const loginUrl = `${options.appBaseUrl}/login?from_url=${encodeURIComponent(redirectUrl)}`;
|
|
131
119
|
// The login page must not boot with the token that just got us here,
|
|
132
120
|
// or a rejected token redirects to /login forever.
|
|
133
|
-
|
|
121
|
+
removeAccessToken({});
|
|
122
|
+
removeAccessToken({ storageKey: "token" });
|
|
134
123
|
window.location.href = loginUrl;
|
|
135
124
|
},
|
|
136
125
|
// Redirects the user to a provider's login page
|
|
@@ -169,7 +158,8 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
169
158
|
hasAccessToken = false;
|
|
170
159
|
// Only do the rest if in a browser environment
|
|
171
160
|
if (typeof window !== "undefined") {
|
|
172
|
-
|
|
161
|
+
removeAccessToken({});
|
|
162
|
+
removeAccessToken({ storageKey: "token" });
|
|
173
163
|
// Determine the from_url parameter
|
|
174
164
|
const fromUrl = redirectUrl || window.location.href;
|
|
175
165
|
// Redirect to server-side logout endpoint to clear HTTP-only cookies
|