@base44/sdk 0.5.0 → 0.6.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 +6 -2
- package/dist/client.js +2 -0
- package/dist/modules/auth.d.ts +0 -5
- package/dist/modules/auth.js +2 -7
- package/dist/modules/sso.d.ts +15 -0
- package/dist/modules/sso.js +19 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare function createClient(config: {
|
|
|
32
32
|
asServiceRole: {
|
|
33
33
|
entities: {};
|
|
34
34
|
integrations: {};
|
|
35
|
+
sso: {
|
|
36
|
+
getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
37
|
+
};
|
|
35
38
|
functions: {
|
|
36
39
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
37
40
|
};
|
|
@@ -40,7 +43,6 @@ export declare function createClient(config: {
|
|
|
40
43
|
integrations: {};
|
|
41
44
|
auth: {
|
|
42
45
|
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
43
|
-
getSsoAccessToken(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
44
46
|
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
45
47
|
redirectToLogin(nextUrl: string): void;
|
|
46
48
|
logout(redirectUrl?: string): void;
|
|
@@ -73,6 +75,9 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
73
75
|
asServiceRole: {
|
|
74
76
|
entities: {};
|
|
75
77
|
integrations: {};
|
|
78
|
+
sso: {
|
|
79
|
+
getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
80
|
+
};
|
|
76
81
|
functions: {
|
|
77
82
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
78
83
|
};
|
|
@@ -81,7 +86,6 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
81
86
|
integrations: {};
|
|
82
87
|
auth: {
|
|
83
88
|
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
84
|
-
getSsoAccessToken(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
85
89
|
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
86
90
|
redirectToLogin(nextUrl: string): void;
|
|
87
91
|
logout(redirectUrl?: string): void;
|
package/dist/client.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createAxiosClient } from "./utils/axios-client.js";
|
|
|
2
2
|
import { createEntitiesModule } from "./modules/entities.js";
|
|
3
3
|
import { createIntegrationsModule } from "./modules/integrations.js";
|
|
4
4
|
import { createAuthModule } from "./modules/auth.js";
|
|
5
|
+
import { createSsoModule } from "./modules/sso.js";
|
|
5
6
|
import { getAccessToken } from "./utils/auth-utils.js";
|
|
6
7
|
import { createFunctionsModule } from "./modules/functions.js";
|
|
7
8
|
/**
|
|
@@ -65,6 +66,7 @@ export function createClient(config) {
|
|
|
65
66
|
const serviceRoleModules = {
|
|
66
67
|
entities: createEntitiesModule(serviceRoleAxiosClient, appId),
|
|
67
68
|
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
|
|
69
|
+
sso: createSsoModule(serviceRoleAxiosClient, appId),
|
|
68
70
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
|
|
69
71
|
};
|
|
70
72
|
// Always try to get token from localStorage or URL parameters
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -12,11 +12,6 @@ export declare function createAuthModule(axios: AxiosInstance, functionsAxiosCli
|
|
|
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>>;
|
|
20
15
|
/**
|
|
21
16
|
* Update current user data
|
|
22
17
|
* @param {Object} data - Updated user data
|
package/dist/modules/auth.js
CHANGED
|
@@ -14,13 +14,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId) {
|
|
|
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
|
-
},
|
|
24
17
|
/**
|
|
25
18
|
* Update current user data
|
|
26
19
|
* @param {Object} data - Updated user data
|
|
@@ -59,6 +52,8 @@ export function createAuthModule(axios, functionsAxiosClient, appId) {
|
|
|
59
52
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
60
53
|
try {
|
|
61
54
|
window.localStorage.removeItem("base44_access_token");
|
|
55
|
+
// Remove "token" that is set by the built-in SDK of platform version 2
|
|
56
|
+
window.localStorage.removeItem("token");
|
|
62
57
|
}
|
|
63
58
|
catch (e) {
|
|
64
59
|
console.error("Failed to remove token from localStorage:", e);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the SSO module for the Base44 SDK
|
|
4
|
+
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
5
|
+
* @param {string} appId - Application ID
|
|
6
|
+
* @returns {Object} SSO module with SSO authentication methods
|
|
7
|
+
*/
|
|
8
|
+
export declare function createSsoModule(axios: AxiosInstance, appId: string): {
|
|
9
|
+
/**
|
|
10
|
+
* Get current user sso access token
|
|
11
|
+
* @param {string} userid - User ID to include as path parameter
|
|
12
|
+
* @returns {Promise<Object>} Current user sso access_token
|
|
13
|
+
*/
|
|
14
|
+
getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the SSO module for the Base44 SDK
|
|
3
|
+
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
4
|
+
* @param {string} appId - Application ID
|
|
5
|
+
* @returns {Object} SSO module with SSO authentication methods
|
|
6
|
+
*/
|
|
7
|
+
export function createSsoModule(axios, appId) {
|
|
8
|
+
return {
|
|
9
|
+
/**
|
|
10
|
+
* Get current user sso access token
|
|
11
|
+
* @param {string} userid - User ID to include as path parameter
|
|
12
|
+
* @returns {Promise<Object>} Current user sso access_token
|
|
13
|
+
*/
|
|
14
|
+
async getAccessToken(userid) {
|
|
15
|
+
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
|
|
16
|
+
return axios.get(url);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|