@base44-preview/sdk 0.5.0-pr.22.d593016 → 0.6.0-pr.23.76c21f3

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 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(userid: string): 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(userid: string): 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, token, serviceToken),
68
70
  functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
69
71
  };
70
72
  // Always try to get token from localStorage or URL parameters
@@ -12,12 +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
- * @param {string} userid - User ID to include as path parameter
18
- * @returns {Promise<Object>} Current user sso access_token
19
- */
20
- getSsoAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
21
15
  /**
22
16
  * Update current user data
23
17
  * @param {Object} data - Updated user data
@@ -14,15 +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
- * @param {string} userid - User ID to include as path parameter
20
- * @returns {Promise<Object>} Current user sso access_token
21
- */
22
- async getSsoAccessToken(userid) {
23
- const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
24
- return axios.get(url);
25
- },
26
17
  /**
27
18
  * Update current user data
28
19
  * @param {Object} data - Updated user data
@@ -0,0 +1,17 @@
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
+ * @param {string} [userToken] - User authentication token
7
+ * @param {string} [serviceToken] - Service role authentication token
8
+ * @returns {Object} SSO module with SSO authentication methods
9
+ */
10
+ export declare function createSsoModule(axios: AxiosInstance, appId: string, userToken?: string, serviceToken?: string): {
11
+ /**
12
+ * Get current user sso access token
13
+ * @param {string} userid - User ID to include as path parameter
14
+ * @returns {Promise<Object>} Current user sso access_token
15
+ */
16
+ getAccessToken(userid: string): Promise<import("axios").AxiosResponse<any, any>>;
17
+ };
@@ -0,0 +1,29 @@
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
+ * @param {string} [userToken] - User authentication token
6
+ * @param {string} [serviceToken] - Service role authentication token
7
+ * @returns {Object} SSO module with SSO authentication methods
8
+ */
9
+ export function createSsoModule(axios, appId, userToken, serviceToken) {
10
+ return {
11
+ /**
12
+ * Get current user sso access token
13
+ * @param {string} userid - User ID to include as path parameter
14
+ * @returns {Promise<Object>} Current user sso access_token
15
+ */
16
+ async getAccessToken(userid) {
17
+ const url = `/apps/${appId}/auth/sso/accesstoken/${userid}`;
18
+ // Prepare headers with both tokens if available
19
+ const headers = {};
20
+ if (userToken) {
21
+ headers['Authorization'] = `Bearer ${userToken}`;
22
+ }
23
+ if (serviceToken) {
24
+ headers['Base44-Service-Authorization'] = `Bearer ${serviceToken}`;
25
+ }
26
+ return axios.get(url, { headers });
27
+ },
28
+ };
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.5.0-pr.22.d593016",
3
+ "version": "0.6.0-pr.23.76c21f3",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",