@base44/sdk 0.6.1 → 0.7.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 -0
- package/dist/client.js +15 -14
- package/dist/modules/sso.d.ts +3 -1
- package/dist/modules/sso.js +9 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -16,12 +16,17 @@ import { createFunctionsModule } from "./modules/functions.js";
|
|
|
16
16
|
* @returns {Object} Base44 client instance
|
|
17
17
|
*/
|
|
18
18
|
export function createClient(config) {
|
|
19
|
-
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, } = config;
|
|
19
|
+
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, functionsVersion } = config;
|
|
20
|
+
const headers = {
|
|
21
|
+
"X-App-Id": String(appId),
|
|
22
|
+
};
|
|
23
|
+
const functionHeaders = functionsVersion ? {
|
|
24
|
+
...headers,
|
|
25
|
+
"Base44-Functions-Version": functionsVersion
|
|
26
|
+
} : headers;
|
|
20
27
|
const axiosClient = createAxiosClient({
|
|
21
28
|
baseURL: `${serverUrl}/api`,
|
|
22
|
-
headers
|
|
23
|
-
"X-App-Id": String(appId),
|
|
24
|
-
},
|
|
29
|
+
headers,
|
|
25
30
|
token,
|
|
26
31
|
requiresAuth,
|
|
27
32
|
appId,
|
|
@@ -29,9 +34,7 @@ export function createClient(config) {
|
|
|
29
34
|
});
|
|
30
35
|
const functionsAxiosClient = createAxiosClient({
|
|
31
36
|
baseURL: `${serverUrl}/api`,
|
|
32
|
-
headers:
|
|
33
|
-
"X-App-Id": String(appId),
|
|
34
|
-
},
|
|
37
|
+
headers: functionHeaders,
|
|
35
38
|
token,
|
|
36
39
|
requiresAuth,
|
|
37
40
|
appId,
|
|
@@ -40,18 +43,14 @@ export function createClient(config) {
|
|
|
40
43
|
});
|
|
41
44
|
const serviceRoleAxiosClient = createAxiosClient({
|
|
42
45
|
baseURL: `${serverUrl}/api`,
|
|
43
|
-
headers
|
|
44
|
-
"X-App-Id": String(appId),
|
|
45
|
-
},
|
|
46
|
+
headers,
|
|
46
47
|
token: serviceToken,
|
|
47
48
|
serverUrl,
|
|
48
49
|
appId,
|
|
49
50
|
});
|
|
50
51
|
const serviceRoleFunctionsAxiosClient = createAxiosClient({
|
|
51
52
|
baseURL: `${serverUrl}/api`,
|
|
52
|
-
headers:
|
|
53
|
-
"X-App-Id": String(appId),
|
|
54
|
-
},
|
|
53
|
+
headers: functionHeaders,
|
|
55
54
|
token: serviceToken,
|
|
56
55
|
serverUrl,
|
|
57
56
|
appId,
|
|
@@ -66,7 +65,7 @@ export function createClient(config) {
|
|
|
66
65
|
const serviceRoleModules = {
|
|
67
66
|
entities: createEntitiesModule(serviceRoleAxiosClient, appId),
|
|
68
67
|
integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
|
|
69
|
-
sso: createSsoModule(serviceRoleAxiosClient, appId),
|
|
68
|
+
sso: createSsoModule(serviceRoleAxiosClient, appId, token),
|
|
70
69
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
|
|
71
70
|
};
|
|
72
71
|
// Always try to get token from localStorage or URL parameters
|
|
@@ -132,6 +131,7 @@ export function createClientFromRequest(request) {
|
|
|
132
131
|
const serviceRoleAuthHeader = request.headers.get("Base44-Service-Authorization");
|
|
133
132
|
const appId = request.headers.get("Base44-App-Id");
|
|
134
133
|
const serverUrlHeader = request.headers.get("Base44-Api-Url");
|
|
134
|
+
const functionsVersion = request.headers.get("Base44-Functions-Version");
|
|
135
135
|
if (!appId) {
|
|
136
136
|
throw new Error("Base44-App-Id header is required, but is was not found on the request");
|
|
137
137
|
}
|
|
@@ -155,5 +155,6 @@ export function createClientFromRequest(request) {
|
|
|
155
155
|
appId,
|
|
156
156
|
token: userToken,
|
|
157
157
|
serviceToken: serviceRoleToken,
|
|
158
|
+
functionsVersion: functionsVersion !== null && functionsVersion !== void 0 ? functionsVersion : undefined
|
|
158
159
|
});
|
|
159
160
|
}
|
package/dist/modules/sso.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import { AxiosInstance } from "axios";
|
|
|
3
3
|
* Creates the SSO module for the Base44 SDK
|
|
4
4
|
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
5
5
|
* @param {string} appId - Application ID
|
|
6
|
+
* @param {string} [userToken] - User authentication token
|
|
7
|
+
* @param {string} [serviceToken] - Service role authentication token
|
|
6
8
|
* @returns {Object} SSO module with SSO authentication methods
|
|
7
9
|
*/
|
|
8
|
-
export declare function createSsoModule(axios: AxiosInstance, appId: string): {
|
|
10
|
+
export declare function createSsoModule(axios: AxiosInstance, appId: string, userToken?: string): {
|
|
9
11
|
/**
|
|
10
12
|
* Get current user sso access token
|
|
11
13
|
* @param {string} userid - User ID to include as path parameter
|
package/dist/modules/sso.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Creates the SSO module for the Base44 SDK
|
|
3
3
|
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
4
4
|
* @param {string} appId - Application ID
|
|
5
|
+
* @param {string} [userToken] - User authentication token
|
|
6
|
+
* @param {string} [serviceToken] - Service role authentication token
|
|
5
7
|
* @returns {Object} SSO module with SSO authentication methods
|
|
6
8
|
*/
|
|
7
|
-
export function createSsoModule(axios, appId) {
|
|
9
|
+
export function createSsoModule(axios, appId, userToken) {
|
|
8
10
|
return {
|
|
9
11
|
/**
|
|
10
12
|
* Get current user sso access token
|
|
@@ -13,7 +15,12 @@ export function createSsoModule(axios, appId) {
|
|
|
13
15
|
*/
|
|
14
16
|
async getAccessToken(userid) {
|
|
15
17
|
const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
|
|
16
|
-
|
|
18
|
+
// Prepare headers with both tokens if available
|
|
19
|
+
const headers = {};
|
|
20
|
+
if (userToken) {
|
|
21
|
+
headers['on-behalf-of'] = `Bearer ${userToken}`;
|
|
22
|
+
}
|
|
23
|
+
return axios.get(url, { headers });
|
|
17
24
|
},
|
|
18
25
|
};
|
|
19
26
|
}
|