@base44/sdk 0.2.0 → 0.2.1
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/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/modules/auth.d.ts +1 -1
- package/dist/modules/auth.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function createClient(config: {
|
|
|
20
20
|
auth: {
|
|
21
21
|
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
22
22
|
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
23
|
-
|
|
23
|
+
redirectToLogin(nextUrl: string): void;
|
|
24
24
|
logout(redirectUrl?: string): void;
|
|
25
25
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
26
26
|
loginViaUsernamePassword(email: string, password: string, turnstileToken?: string): Promise<{
|
package/dist/client.js
CHANGED
|
@@ -60,12 +60,12 @@ export function createClient(config) {
|
|
|
60
60
|
try {
|
|
61
61
|
const isAuthenticated = await auth.isAuthenticated();
|
|
62
62
|
if (!isAuthenticated) {
|
|
63
|
-
auth.
|
|
63
|
+
auth.redirectToLogin(window.location.href);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
catch (error) {
|
|
67
67
|
console.error("Authentication check failed:", error);
|
|
68
|
-
auth.
|
|
68
|
+
auth.redirectToLogin(window.location.href);
|
|
69
69
|
}
|
|
70
70
|
}, 0);
|
|
71
71
|
}
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare function createAuthModule(axios: AxiosInstance, appId: string, se
|
|
|
23
23
|
* @param {string} nextUrl - URL to redirect to after successful login
|
|
24
24
|
* @throws {Error} When not in a browser environment
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
redirectToLogin(nextUrl: string): void;
|
|
27
27
|
/**
|
|
28
28
|
* Logout the current user
|
|
29
29
|
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
package/dist/modules/auth.js
CHANGED
|
@@ -27,7 +27,7 @@ export function createAuthModule(axios, appId, serverUrl) {
|
|
|
27
27
|
* @param {string} nextUrl - URL to redirect to after successful login
|
|
28
28
|
* @throws {Error} When not in a browser environment
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
redirectToLogin(nextUrl) {
|
|
31
31
|
// This function only works in a browser environment
|
|
32
32
|
if (typeof window === "undefined") {
|
|
33
33
|
throw new Error("Login method can only be used in a browser environment");
|