@base44-preview/sdk 0.8.4-pr.43.a6c7baf → 0.8.4-pr.44.71a0993
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 -68
- package/dist/client.js +0 -6
- package/dist/index.d.ts +1 -0
- package/dist/modules/auth.d.ts +34 -47
- package/dist/modules/auth.js +0 -36
- package/package.json +6 -1
package/dist/client.d.ts
CHANGED
|
@@ -71,40 +71,7 @@ export declare function createClient(config: {
|
|
|
71
71
|
};
|
|
72
72
|
entities: {};
|
|
73
73
|
integrations: {};
|
|
74
|
-
auth:
|
|
75
|
-
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
76
|
-
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
77
|
-
redirectToLogin(nextUrl: string): void;
|
|
78
|
-
logout(redirectUrl?: string): void;
|
|
79
|
-
setToken(token: string, saveToStorage?: boolean): void;
|
|
80
|
-
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
81
|
-
access_token: string;
|
|
82
|
-
user: any;
|
|
83
|
-
}>;
|
|
84
|
-
isAuthenticated(): Promise<boolean>;
|
|
85
|
-
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
86
|
-
register(payload: {
|
|
87
|
-
email: string;
|
|
88
|
-
password: string;
|
|
89
|
-
turnstile_token?: string | null;
|
|
90
|
-
referral_code?: string | null;
|
|
91
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
92
|
-
verifyOtp({ email, otpCode }: {
|
|
93
|
-
email: string;
|
|
94
|
-
otpCode: string;
|
|
95
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
96
|
-
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
97
|
-
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
98
|
-
resetPassword({ resetToken, newPassword, }: {
|
|
99
|
-
resetToken: string;
|
|
100
|
-
newPassword: string;
|
|
101
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
102
|
-
changePassword({ userId, currentPassword, newPassword, }: {
|
|
103
|
-
userId: string;
|
|
104
|
-
currentPassword: string;
|
|
105
|
-
newPassword: string;
|
|
106
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
107
|
-
};
|
|
74
|
+
auth: import("./modules/auth.js").AuthMethods;
|
|
108
75
|
functions: {
|
|
109
76
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
110
77
|
};
|
|
@@ -175,40 +142,7 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
175
142
|
};
|
|
176
143
|
entities: {};
|
|
177
144
|
integrations: {};
|
|
178
|
-
auth:
|
|
179
|
-
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
180
|
-
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
181
|
-
redirectToLogin(nextUrl: string): void;
|
|
182
|
-
logout(redirectUrl?: string): void;
|
|
183
|
-
setToken(token: string, saveToStorage?: boolean): void;
|
|
184
|
-
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
185
|
-
access_token: string;
|
|
186
|
-
user: any;
|
|
187
|
-
}>;
|
|
188
|
-
isAuthenticated(): Promise<boolean>;
|
|
189
|
-
inviteUser(userEmail: string, role: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
190
|
-
register(payload: {
|
|
191
|
-
email: string;
|
|
192
|
-
password: string;
|
|
193
|
-
turnstile_token?: string | null;
|
|
194
|
-
referral_code?: string | null;
|
|
195
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
196
|
-
verifyOtp({ email, otpCode }: {
|
|
197
|
-
email: string;
|
|
198
|
-
otpCode: string;
|
|
199
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
200
|
-
resendOtp(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
201
|
-
resetPasswordRequest(email: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
202
|
-
resetPassword({ resetToken, newPassword, }: {
|
|
203
|
-
resetToken: string;
|
|
204
|
-
newPassword: string;
|
|
205
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
206
|
-
changePassword({ userId, currentPassword, newPassword, }: {
|
|
207
|
-
userId: string;
|
|
208
|
-
currentPassword: string;
|
|
209
|
-
newPassword: string;
|
|
210
|
-
}): Promise<import("axios").AxiosResponse<any, any>>;
|
|
211
|
-
};
|
|
145
|
+
auth: import("./modules/auth.js").AuthMethods;
|
|
212
146
|
functions: {
|
|
213
147
|
invoke(functionName: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
214
148
|
};
|
package/dist/client.js
CHANGED
|
@@ -172,7 +172,6 @@ export function createClientFromRequest(request) {
|
|
|
172
172
|
const appId = request.headers.get("Base44-App-Id");
|
|
173
173
|
const serverUrlHeader = request.headers.get("Base44-Api-Url");
|
|
174
174
|
const functionsVersion = request.headers.get("Base44-Functions-Version");
|
|
175
|
-
const userCountry = request.headers.get("Base44-User-Country");
|
|
176
175
|
if (!appId) {
|
|
177
176
|
throw new Error("Base44-App-Id header is required, but is was not found on the request");
|
|
178
177
|
}
|
|
@@ -195,12 +194,7 @@ export function createClientFromRequest(request) {
|
|
|
195
194
|
}
|
|
196
195
|
userToken = authHeader.split(" ")[1];
|
|
197
196
|
}
|
|
198
|
-
const forwardHeaders = {};
|
|
199
|
-
if (userCountry) {
|
|
200
|
-
forwardHeaders["Base44-User-Country"] = userCountry;
|
|
201
|
-
}
|
|
202
197
|
return createClient({
|
|
203
|
-
headers: forwardHeaders,
|
|
204
198
|
serverUrl: serverUrlHeader || "https://base44.app",
|
|
205
199
|
appId,
|
|
206
200
|
token: userToken,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
|
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
5
|
export type { Base44Client };
|
|
6
6
|
export * from "./types.js";
|
|
7
|
+
export type { AuthMethods } from "./modules/auth.js";
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -1,81 +1,68 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param {string|number} appId - Application ID
|
|
6
|
-
* @param {string} serverUrl - Server URL
|
|
7
|
-
* @returns {Object} Auth module with authentication methods
|
|
3
|
+
* Public auth methods available from the SDK.
|
|
4
|
+
* Document only the methods you want to expose and support.
|
|
8
5
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
me(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
18
|
-
/**
|
|
19
|
-
* Update current user data
|
|
20
|
-
* @param {Object} data - Updated user data
|
|
21
|
-
* @returns {Promise<Object>} Updated user
|
|
22
|
-
*/
|
|
23
|
-
updateMe(data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
24
|
-
/**
|
|
25
|
-
* Redirects the user to the app's login page
|
|
26
|
-
* @param {string} nextUrl - URL to redirect to after successful login
|
|
27
|
-
* @throws {Error} When not in a browser environment
|
|
28
|
-
*/
|
|
6
|
+
export interface AuthMethods {
|
|
7
|
+
/** Get current user information */
|
|
8
|
+
me(): Promise<any>;
|
|
9
|
+
/** Update current user data */
|
|
10
|
+
/** @internal */
|
|
11
|
+
updateMe(data: Record<string, any>): Promise<any>;
|
|
12
|
+
/** Redirects the user to the app's login page */
|
|
29
13
|
redirectToLogin(nextUrl: string): void;
|
|
30
14
|
/**
|
|
31
15
|
* Logout the current user
|
|
32
16
|
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
33
|
-
* @param redirectUrl - Optional URL to redirect to after logout. Reloads the page if not provided
|
|
34
|
-
* @returns {Promise<void>}
|
|
35
17
|
*/
|
|
36
18
|
logout(redirectUrl?: string): void;
|
|
37
19
|
/**
|
|
38
20
|
* Set authentication token
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
21
|
+
* @param token - Auth token
|
|
22
|
+
* @param saveToStorage - Whether to save the token to localStorage (default true)
|
|
41
23
|
*/
|
|
42
24
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
43
25
|
/**
|
|
44
26
|
* Login via username and password
|
|
45
|
-
* @param email - User email
|
|
46
|
-
* @param password - User password
|
|
47
|
-
* @param turnstileToken - Optional Turnstile captcha token
|
|
48
27
|
* @returns Login response with access_token and user
|
|
49
28
|
*/
|
|
50
29
|
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
51
30
|
access_token: string;
|
|
52
31
|
user: any;
|
|
53
32
|
}>;
|
|
54
|
-
/**
|
|
55
|
-
* Verify if the current token is valid
|
|
56
|
-
* @returns {Promise<boolean>} True if token is valid
|
|
57
|
-
*/
|
|
33
|
+
/** Verify if the current token is valid */
|
|
58
34
|
isAuthenticated(): Promise<boolean>;
|
|
59
|
-
inviteUser(userEmail: string, role: string): Promise<
|
|
35
|
+
inviteUser(userEmail: string, role: string): Promise<any>;
|
|
60
36
|
register(payload: {
|
|
61
37
|
email: string;
|
|
62
38
|
password: string;
|
|
63
39
|
turnstile_token?: string | null;
|
|
64
40
|
referral_code?: string | null;
|
|
65
|
-
}): Promise<
|
|
66
|
-
verifyOtp(
|
|
41
|
+
}): Promise<any>;
|
|
42
|
+
verifyOtp(args: {
|
|
67
43
|
email: string;
|
|
68
44
|
otpCode: string;
|
|
69
|
-
}): Promise<
|
|
70
|
-
resendOtp(email: string): Promise<
|
|
71
|
-
resetPasswordRequest(email: string): Promise<
|
|
72
|
-
resetPassword(
|
|
45
|
+
}): Promise<any>;
|
|
46
|
+
resendOtp(email: string): Promise<any>;
|
|
47
|
+
resetPasswordRequest(email: string): Promise<any>;
|
|
48
|
+
resetPassword(args: {
|
|
73
49
|
resetToken: string;
|
|
74
50
|
newPassword: string;
|
|
75
|
-
}): Promise<
|
|
76
|
-
changePassword(
|
|
51
|
+
}): Promise<any>;
|
|
52
|
+
changePassword(args: {
|
|
77
53
|
userId: string;
|
|
78
54
|
currentPassword: string;
|
|
79
55
|
newPassword: string;
|
|
80
|
-
}): Promise<
|
|
81
|
-
}
|
|
56
|
+
}): Promise<any>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates the auth module for the Base44 SDK
|
|
60
|
+
* @param {import('axios').AxiosInstance} axios - Axios instance
|
|
61
|
+
* @param {string|number} appId - Application ID
|
|
62
|
+
* @param {string} serverUrl - Server URL
|
|
63
|
+
* @returns {Object} Auth module with authentication methods
|
|
64
|
+
*/
|
|
65
|
+
export declare function createAuthModule(axios: AxiosInstance, functionsAxiosClient: AxiosInstance, appId: string, options: {
|
|
66
|
+
serverUrl: string;
|
|
67
|
+
appBaseUrl?: string;
|
|
68
|
+
}): AuthMethods;
|
package/dist/modules/auth.js
CHANGED
|
@@ -7,26 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
9
9
|
return {
|
|
10
|
-
/**
|
|
11
|
-
* Get current user information
|
|
12
|
-
* @returns {Promise<Object>} Current user data
|
|
13
|
-
*/
|
|
14
10
|
async me() {
|
|
15
11
|
return axios.get(`/apps/${appId}/entities/User/me`);
|
|
16
12
|
},
|
|
17
|
-
/**
|
|
18
|
-
* Update current user data
|
|
19
|
-
* @param {Object} data - Updated user data
|
|
20
|
-
* @returns {Promise<Object>} Updated user
|
|
21
|
-
*/
|
|
22
13
|
async updateMe(data) {
|
|
23
14
|
return axios.put(`/apps/${appId}/entities/User/me`, data);
|
|
24
15
|
},
|
|
25
|
-
/**
|
|
26
|
-
* Redirects the user to the app's login page
|
|
27
|
-
* @param {string} nextUrl - URL to redirect to after successful login
|
|
28
|
-
* @throws {Error} When not in a browser environment
|
|
29
|
-
*/
|
|
30
16
|
redirectToLogin(nextUrl) {
|
|
31
17
|
var _a;
|
|
32
18
|
// This function only works in a browser environment
|
|
@@ -42,12 +28,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
42
28
|
// Redirect to the login page
|
|
43
29
|
window.location.href = loginUrl;
|
|
44
30
|
},
|
|
45
|
-
/**
|
|
46
|
-
* Logout the current user
|
|
47
|
-
* Removes the token from localStorage and optionally redirects to a URL or reloads the page
|
|
48
|
-
* @param redirectUrl - Optional URL to redirect to after logout. Reloads the page if not provided
|
|
49
|
-
* @returns {Promise<void>}
|
|
50
|
-
*/
|
|
51
31
|
logout(redirectUrl) {
|
|
52
32
|
// Remove token from axios headers
|
|
53
33
|
delete axios.defaults.headers.common["Authorization"];
|
|
@@ -72,11 +52,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
72
52
|
}
|
|
73
53
|
}
|
|
74
54
|
},
|
|
75
|
-
/**
|
|
76
|
-
* Set authentication token
|
|
77
|
-
* @param {string} token - Auth token
|
|
78
|
-
* @param {boolean} [saveToStorage=true] - Whether to save the token to localStorage
|
|
79
|
-
*/
|
|
80
55
|
setToken(token, saveToStorage = true) {
|
|
81
56
|
if (!token)
|
|
82
57
|
return;
|
|
@@ -97,13 +72,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
97
72
|
}
|
|
98
73
|
}
|
|
99
74
|
},
|
|
100
|
-
/**
|
|
101
|
-
* Login via username and password
|
|
102
|
-
* @param email - User email
|
|
103
|
-
* @param password - User password
|
|
104
|
-
* @param turnstileToken - Optional Turnstile captcha token
|
|
105
|
-
* @returns Login response with access_token and user
|
|
106
|
-
*/
|
|
107
75
|
async loginViaEmailPassword(email, password, turnstileToken) {
|
|
108
76
|
var _a;
|
|
109
77
|
try {
|
|
@@ -129,10 +97,6 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
129
97
|
throw error;
|
|
130
98
|
}
|
|
131
99
|
},
|
|
132
|
-
/**
|
|
133
|
-
* Verify if the current token is valid
|
|
134
|
-
* @returns {Promise<boolean>} True if token is valid
|
|
135
|
-
*/
|
|
136
100
|
async isAuthenticated() {
|
|
137
101
|
try {
|
|
138
102
|
await this.me();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.4-pr.
|
|
3
|
+
"version": "0.8.4-pr.44.71a0993",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"test:e2e": "vitest run tests/e2e",
|
|
17
17
|
"test:watch": "vitest",
|
|
18
18
|
"test:coverage": "vitest run --coverage",
|
|
19
|
+
"docs": "npm run docs:generate && npm run docs:process",
|
|
20
|
+
"docs:generate": "typedoc",
|
|
21
|
+
"docs:process": "node scripts/process-docs-for-mintlify.js",
|
|
19
22
|
"prepublishOnly": "npm run build"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
@@ -30,6 +33,8 @@
|
|
|
30
33
|
"dotenv": "^16.3.1",
|
|
31
34
|
"eslint": "^8.54.0",
|
|
32
35
|
"nock": "^13.4.0",
|
|
36
|
+
"typedoc": "^0.25.0",
|
|
37
|
+
"typedoc-plugin-markdown": "^3.17.0",
|
|
33
38
|
"typescript": "^5.3.2",
|
|
34
39
|
"vitest": "^1.0.0"
|
|
35
40
|
},
|