@base44-preview/sdk 0.8.4-pr.47.aed2863 → 0.8.4-pr.49.216dd31

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
@@ -75,6 +75,7 @@ export declare function createClient(config: {
75
75
  me(): Promise<import("axios").AxiosResponse<any, any>>;
76
76
  updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
77
77
  redirectToLogin(nextUrl: string): void;
78
+ loginWithProvider(provider: string, fromUrl?: string): void;
78
79
  logout(redirectUrl?: string): void;
79
80
  setToken(token: string, saveToStorage?: boolean): void;
80
81
  loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
@@ -125,9 +126,6 @@ export declare function createClient(config: {
125
126
  fetchLogs(params?: Record<string, any>): Promise<any>;
126
127
  getStats(params?: Record<string, any>): Promise<any>;
127
128
  };
128
- users: {
129
- inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
130
- };
131
129
  cleanup: () => void;
132
130
  };
133
131
  export declare function createClientFromRequest(request: Request): {
@@ -182,6 +180,7 @@ export declare function createClientFromRequest(request: Request): {
182
180
  me(): Promise<import("axios").AxiosResponse<any, any>>;
183
181
  updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
184
182
  redirectToLogin(nextUrl: string): void;
183
+ loginWithProvider(provider: string, fromUrl?: string): void;
185
184
  logout(redirectUrl?: string): void;
186
185
  setToken(token: string, saveToStorage?: boolean): void;
187
186
  loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
@@ -232,8 +231,5 @@ export declare function createClientFromRequest(request: Request): {
232
231
  fetchLogs(params?: Record<string, any>): Promise<any>;
233
232
  getStats(params?: Record<string, any>): Promise<any>;
234
233
  };
235
- users: {
236
- inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
237
- };
238
234
  cleanup: () => void;
239
235
  };
package/dist/client.js CHANGED
@@ -8,7 +8,6 @@ import { getAccessToken } from "./utils/auth-utils.js";
8
8
  import { createFunctionsModule } from "./modules/functions.js";
9
9
  import { createAgentsModule } from "./modules/agents.js";
10
10
  import { createAppLogsModule } from "./modules/app-logs.js";
11
- import { createUsersModule } from "./modules/users.js";
12
11
  import { RoomsSocket } from "./utils/socket-utils.js";
13
12
  /**
14
13
  * Create a Base44 client instance
@@ -84,7 +83,6 @@ export function createClient(config) {
84
83
  token,
85
84
  }),
86
85
  appLogs: createAppLogsModule(axiosClient, appId),
87
- users: createUsersModule(axiosClient, appId),
88
86
  cleanup: () => {
89
87
  socket.disconnect();
90
88
  },
@@ -27,6 +27,13 @@ export declare function createAuthModule(axios: AxiosInstance, functionsAxiosCli
27
27
  * @throws {Error} When not in a browser environment
28
28
  */
29
29
  redirectToLogin(nextUrl: string): void;
30
+ /**
31
+ * Redirects the user to a provider's login page
32
+ * @param {string} provider - OAuth provider name (e.g., 'google', 'github')
33
+ * @param {string} fromUrl - Optional URL to redirect to after successful login (defaults to '/')
34
+ * @throws {Error} When not in a browser environment
35
+ */
36
+ loginWithProvider(provider: string, fromUrl?: string): void;
30
37
  /**
31
38
  * Logout the current user
32
39
  * Removes the token from localStorage and optionally redirects to a URL or reloads the page
@@ -42,6 +42,21 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
42
42
  // Redirect to the login page
43
43
  window.location.href = loginUrl;
44
44
  },
45
+ /**
46
+ * Redirects the user to a provider's login page
47
+ * @param {string} provider - OAuth provider name (e.g., 'google', 'github')
48
+ * @param {string} fromUrl - Optional URL to redirect to after successful login (defaults to '/')
49
+ * @throws {Error} When not in a browser environment
50
+ */
51
+ loginWithProvider(provider, fromUrl = "/") {
52
+ // Build the full redirect URL
53
+ const redirectUrl = new URL(fromUrl, window.location.origin).toString();
54
+ // Build the provider login URL (google is the default, so no provider path needed)
55
+ const providerPath = provider === "google" ? "" : `/${provider}`;
56
+ const loginUrl = `${options.serverUrl}/api/apps/auth${providerPath}/login?appId=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
57
+ // Redirect to the provider login page
58
+ window.location.href = loginUrl;
59
+ },
45
60
  /**
46
61
  * Logout the current user
47
62
  * Removes the token from localStorage and optionally redirects to a URL or reloads the page
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.4-pr.47.aed2863",
3
+ "version": "0.8.4-pr.49.216dd31",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,6 +24,7 @@
24
24
  "uuid": "^13.0.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "@types/node": "^25.0.1",
27
28
  "@vitest/coverage-istanbul": "^1.0.0",
28
29
  "@vitest/coverage-v8": "^1.0.0",
29
30
  "@vitest/ui": "^1.0.0",
@@ -1,16 +0,0 @@
1
- import { AxiosInstance } from "axios";
2
- /**
3
- * Creates the users module for the Base44 SDK
4
- * @param {AxiosInstance} axios - Axios instance
5
- * @param {string} appId - Application ID
6
- * @returns {Object} Users module
7
- */
8
- export declare function createUsersModule(axios: AxiosInstance, appId: string): {
9
- /**
10
- * Invite a user to the application
11
- * @param {string} user_email - User's email address
12
- * @param {'user'|'admin'} role - User's role (user or admin)
13
- * @returns {Promise<any>}
14
- */
15
- inviteUser(user_email: string, role: "user" | "admin"): Promise<any>;
16
- };
@@ -1,23 +0,0 @@
1
- /**
2
- * Creates the users module for the Base44 SDK
3
- * @param {AxiosInstance} axios - Axios instance
4
- * @param {string} appId - Application ID
5
- * @returns {Object} Users module
6
- */
7
- export function createUsersModule(axios, appId) {
8
- return {
9
- /**
10
- * Invite a user to the application
11
- * @param {string} user_email - User's email address
12
- * @param {'user'|'admin'} role - User's role (user or admin)
13
- * @returns {Promise<any>}
14
- */
15
- async inviteUser(user_email, role) {
16
- if (role !== "user" && role !== "admin") {
17
- throw new Error(`Invalid role: "${role}". Role must be either "user" or "admin".`);
18
- }
19
- const response = await axios.post(`/apps/${appId}/users/invite-user`, { user_email, role });
20
- return response;
21
- },
22
- };
23
- }