@base44-preview/sdk 0.8.4-pr.52.74aa9c1 → 0.8.4-pr.53.f19b952
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.js +7 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.js +1 -2
- package/package.json +1 -1
- package/dist/utils/app-params.d.ts +0 -13
- package/dist/utils/app-params.js +0 -44
package/dist/client.js
CHANGED
|
@@ -172,6 +172,7 @@ 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 clientIpHeader = request.headers.get("Base44-Client-IP");
|
|
175
176
|
if (!appId) {
|
|
176
177
|
throw new Error("Base44-App-Id header is required, but is was not found on the request");
|
|
177
178
|
}
|
|
@@ -194,11 +195,17 @@ export function createClientFromRequest(request) {
|
|
|
194
195
|
}
|
|
195
196
|
userToken = authHeader.split(" ")[1];
|
|
196
197
|
}
|
|
198
|
+
// Prepare additional headers to propagate
|
|
199
|
+
const additionalHeaders = {};
|
|
200
|
+
if (clientIpHeader) {
|
|
201
|
+
additionalHeaders["Base44-Client-IP"] = clientIpHeader;
|
|
202
|
+
}
|
|
197
203
|
return createClient({
|
|
198
204
|
serverUrl: serverUrlHeader || "https://base44.app",
|
|
199
205
|
appId,
|
|
200
206
|
token: userToken,
|
|
201
207
|
serviceToken: serviceRoleToken,
|
|
202
208
|
functionsVersion: functionsVersion !== null && functionsVersion !== void 0 ? functionsVersion : undefined,
|
|
209
|
+
headers: additionalHeaders,
|
|
203
210
|
});
|
|
204
211
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createClient, createClientFromRequest, type Base44Client } from "./client.js";
|
|
2
2
|
import { Base44Error } from "./utils/axios-client.js";
|
|
3
3
|
import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from "./utils/auth-utils.js";
|
|
4
|
-
|
|
5
|
-
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, appParams };
|
|
4
|
+
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
6
5
|
export type { Base44Client };
|
|
7
6
|
export * from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createClient, createClientFromRequest } from "./client.js";
|
|
2
2
|
import { Base44Error } from "./utils/axios-client.js";
|
|
3
3
|
import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, } from "./utils/auth-utils.js";
|
|
4
|
-
|
|
5
|
-
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, appParams };
|
|
4
|
+
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
6
5
|
export * from "./types.js";
|
package/dist/utils/common.d.ts
CHANGED
package/dist/utils/common.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const appParams: {
|
|
2
|
-
appId?: undefined;
|
|
3
|
-
serverUrl?: undefined;
|
|
4
|
-
token?: undefined;
|
|
5
|
-
fromUrl?: undefined;
|
|
6
|
-
functionsVersion?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
appId: any;
|
|
9
|
-
serverUrl: any;
|
|
10
|
-
token: any;
|
|
11
|
-
fromUrl: any;
|
|
12
|
-
functionsVersion: any;
|
|
13
|
-
};
|
package/dist/utils/app-params.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from './common';
|
|
2
|
-
const toSnakeCase = (str) => {
|
|
3
|
-
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
4
|
-
};
|
|
5
|
-
const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
|
|
6
|
-
const storageKey = `base44_${toSnakeCase(paramName)}`;
|
|
7
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
8
|
-
const searchParam = urlParams.get(paramName);
|
|
9
|
-
if (removeFromUrl) {
|
|
10
|
-
urlParams.delete(paramName);
|
|
11
|
-
const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""}${window.location.hash}`;
|
|
12
|
-
window.history.replaceState({}, document.title, newUrl);
|
|
13
|
-
}
|
|
14
|
-
if (searchParam) {
|
|
15
|
-
localStorage.setItem(storageKey, searchParam);
|
|
16
|
-
return searchParam;
|
|
17
|
-
}
|
|
18
|
-
if (defaultValue) {
|
|
19
|
-
localStorage.setItem(storageKey, defaultValue);
|
|
20
|
-
return defaultValue;
|
|
21
|
-
}
|
|
22
|
-
const storedValue = localStorage.getItem(storageKey);
|
|
23
|
-
if (storedValue) {
|
|
24
|
-
return storedValue;
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
};
|
|
28
|
-
const getAppParams = () => {
|
|
29
|
-
if (!isBrowser) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
if (getAppParamValue("clear_access_token") === 'true') {
|
|
33
|
-
localStorage.removeItem('base44_access_token');
|
|
34
|
-
localStorage.removeItem('token');
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
|
|
38
|
-
serverUrl: getAppParamValue("server_url", { defaultValue: import.meta.env.VITE_BASE44_BACKEND_URL }),
|
|
39
|
-
token: getAppParamValue("access_token", { removeFromUrl: true }),
|
|
40
|
-
fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
|
|
41
|
-
functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export const appParams = getAppParams();
|