@base44/sdk 0.2.0 → 0.3.0
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 +2 -1
- package/dist/client.js +2 -2
- package/dist/modules/auth.d.ts +6 -1
- package/dist/modules/auth.js +8 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -19,8 +19,9 @@ export declare function createClient(config: {
|
|
|
19
19
|
integrations: {};
|
|
20
20
|
auth: {
|
|
21
21
|
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
22
|
+
getSsoAccessToken(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
22
23
|
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
23
|
-
|
|
24
|
+
redirectToLogin(nextUrl: string): void;
|
|
24
25
|
logout(redirectUrl?: string): void;
|
|
25
26
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
26
27
|
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
|
@@ -12,6 +12,11 @@ export declare function createAuthModule(axios: AxiosInstance, appId: string, se
|
|
|
12
12
|
* @returns {Promise<Object>} Current user data
|
|
13
13
|
*/
|
|
14
14
|
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
15
|
+
/**
|
|
16
|
+
* Get current user sso access token
|
|
17
|
+
* @returns {Promise<Object>} Current user sso access_token
|
|
18
|
+
*/
|
|
19
|
+
getSsoAccessToken(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
15
20
|
/**
|
|
16
21
|
* Update current user data
|
|
17
22
|
* @param {Object} data - Updated user data
|
|
@@ -23,7 +28,7 @@ export declare function createAuthModule(axios: AxiosInstance, appId: string, se
|
|
|
23
28
|
* @param {string} nextUrl - URL to redirect to after successful login
|
|
24
29
|
* @throws {Error} When not in a browser environment
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
redirectToLogin(nextUrl: string): void;
|
|
27
32
|
/**
|
|
28
33
|
* Logout the current user
|
|
29
34
|
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
package/dist/modules/auth.js
CHANGED
|
@@ -14,6 +14,13 @@ export function createAuthModule(axios, appId, serverUrl) {
|
|
|
14
14
|
async me() {
|
|
15
15
|
return axios.get(`/apps/${appId}/entities/User/me`);
|
|
16
16
|
},
|
|
17
|
+
/**
|
|
18
|
+
* Get current user sso access token
|
|
19
|
+
* @returns {Promise<Object>} Current user sso access_token
|
|
20
|
+
*/
|
|
21
|
+
async getSsoAccessToken() {
|
|
22
|
+
return axios.get(`/apps/${appId}/auth/sso/accesstoken`);
|
|
23
|
+
},
|
|
17
24
|
/**
|
|
18
25
|
* Update current user data
|
|
19
26
|
* @param {Object} data - Updated user data
|
|
@@ -27,7 +34,7 @@ export function createAuthModule(axios, appId, serverUrl) {
|
|
|
27
34
|
* @param {string} nextUrl - URL to redirect to after successful login
|
|
28
35
|
* @throws {Error} When not in a browser environment
|
|
29
36
|
*/
|
|
30
|
-
|
|
37
|
+
redirectToLogin(nextUrl) {
|
|
31
38
|
// This function only works in a browser environment
|
|
32
39
|
if (typeof window === "undefined") {
|
|
33
40
|
throw new Error("Login method can only be used in a browser environment");
|