@base44-preview/sdk 0.7.0-pr.28.d052301 → 0.7.0-pr.29.7a5b54e
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 +3 -8
- package/dist/client.js +14 -13
- package/dist/modules/auth.d.ts +2 -7
- package/dist/modules/auth.js +3 -6
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare function createClient(config: {
|
|
|
14
14
|
token?: string;
|
|
15
15
|
serviceToken?: string;
|
|
16
16
|
requiresAuth?: boolean;
|
|
17
|
+
functionsVersion?: string;
|
|
17
18
|
}): {
|
|
18
19
|
/**
|
|
19
20
|
* Set authentication token for all requests
|
|
@@ -47,10 +48,7 @@ export declare function createClient(config: {
|
|
|
47
48
|
redirectToLogin(nextUrl: string): void;
|
|
48
49
|
logout(redirectUrl?: string): void;
|
|
49
50
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
50
|
-
loginViaEmailPassword(email: string, password: string,
|
|
51
|
-
turnstileToken?: string;
|
|
52
|
-
fromUrl?: string;
|
|
53
|
-
}): Promise<{
|
|
51
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
54
52
|
access_token: string;
|
|
55
53
|
user: any;
|
|
56
54
|
}>;
|
|
@@ -93,10 +91,7 @@ export declare function createClientFromRequest(request: Request): {
|
|
|
93
91
|
redirectToLogin(nextUrl: string): void;
|
|
94
92
|
logout(redirectUrl?: string): void;
|
|
95
93
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
96
|
-
loginViaEmailPassword(email: string, password: string,
|
|
97
|
-
turnstileToken?: string;
|
|
98
|
-
fromUrl?: string;
|
|
99
|
-
}): Promise<{
|
|
94
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
100
95
|
access_token: string;
|
|
101
96
|
user: any;
|
|
102
97
|
}>;
|
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,
|
|
@@ -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/auth.d.ts
CHANGED
|
@@ -41,15 +41,10 @@ export declare function createAuthModule(axios: AxiosInstance, functionsAxiosCli
|
|
|
41
41
|
* Login via username and password
|
|
42
42
|
* @param email - User email
|
|
43
43
|
* @param password - User password
|
|
44
|
-
* @param
|
|
45
|
-
* @param options.turnstileToken - Optional Turnstile captcha token
|
|
46
|
-
* @param options.fromUrl - Optional URL to redirect to after login
|
|
44
|
+
* @param turnstileToken - Optional Turnstile captcha token
|
|
47
45
|
* @returns Login response with access_token and user
|
|
48
46
|
*/
|
|
49
|
-
loginViaEmailPassword(email: string, password: string,
|
|
50
|
-
turnstileToken?: string;
|
|
51
|
-
fromUrl?: string;
|
|
52
|
-
}): Promise<{
|
|
47
|
+
loginViaEmailPassword(email: string, password: string, turnstileToken?: string): Promise<{
|
|
53
48
|
access_token: string;
|
|
54
49
|
user: any;
|
|
55
50
|
}>;
|
package/dist/modules/auth.js
CHANGED
|
@@ -95,19 +95,16 @@ export function createAuthModule(axios, functionsAxiosClient, appId) {
|
|
|
95
95
|
* Login via username and password
|
|
96
96
|
* @param email - User email
|
|
97
97
|
* @param password - User password
|
|
98
|
-
* @param
|
|
99
|
-
* @param options.turnstileToken - Optional Turnstile captcha token
|
|
100
|
-
* @param options.fromUrl - Optional URL to redirect to after login
|
|
98
|
+
* @param turnstileToken - Optional Turnstile captcha token
|
|
101
99
|
* @returns Login response with access_token and user
|
|
102
100
|
*/
|
|
103
|
-
async loginViaEmailPassword(email, password,
|
|
101
|
+
async loginViaEmailPassword(email, password, turnstileToken) {
|
|
104
102
|
var _a;
|
|
105
103
|
try {
|
|
106
104
|
const response = await axios.post(`/apps/${appId}/auth/login`, {
|
|
107
105
|
email,
|
|
108
106
|
password,
|
|
109
|
-
...(
|
|
110
|
-
...((options === null || options === void 0 ? void 0 : options.fromUrl) && { from_url: options.fromUrl }),
|
|
107
|
+
...(turnstileToken && { turnstile_token: turnstileToken }),
|
|
111
108
|
});
|
|
112
109
|
const { access_token, user } = response;
|
|
113
110
|
if (access_token) {
|