@bardioc/app-sdk 0.4.5 → 0.4.7
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/dev-proxy.d.ts +0 -2
- package/dist/dev-proxy.js +25 -20
- package/dist/vite.js +3 -2
- package/package.json +1 -1
package/dist/dev-proxy.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export interface DevAuthProxyOptions {
|
|
|
4
4
|
apiBaseUrl: string;
|
|
5
5
|
/** Dev secret copied from the backend. */
|
|
6
6
|
devSecret: string;
|
|
7
|
-
/** App slug stamped as `X-App-ID`, mirroring how the host identifies iframe apps. */
|
|
8
|
-
appId?: string;
|
|
9
7
|
/** Optional CORS origin (e.g. `*`). */
|
|
10
8
|
allowOrigin?: string;
|
|
11
9
|
}
|
package/dist/dev-proxy.js
CHANGED
|
@@ -33,7 +33,7 @@ function addDevSecretHeader(req, headers, devSecret) {
|
|
|
33
33
|
}
|
|
34
34
|
export function createDevAuthProxyHandler(options) {
|
|
35
35
|
const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
|
|
36
|
-
const { devSecret, allowOrigin
|
|
36
|
+
const { devSecret, allowOrigin } = options;
|
|
37
37
|
return async (req, res) => {
|
|
38
38
|
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
39
39
|
if (req.method === 'OPTIONS') {
|
|
@@ -49,31 +49,36 @@ export function createDevAuthProxyHandler(options) {
|
|
|
49
49
|
const upstreamPath = url.pathname.slice('/rest'.length) + url.search;
|
|
50
50
|
const upstreamUrl = `${apiBaseUrl}${upstreamPath}`;
|
|
51
51
|
const headers = new Headers();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (const name of forwardedHeaders) {
|
|
67
|
-
const value = req.headers[name];
|
|
68
|
-
if (typeof value === 'string') {
|
|
69
|
-
headers.set(name, value);
|
|
52
|
+
// Forward headers from the browser so the BFF sees the same request the host would relay
|
|
53
|
+
// (cookies, origin, referer, etc.). Skip hop-by-hop headers; fetch sets Host from the URL.
|
|
54
|
+
const skipHeaders = new Set([
|
|
55
|
+
'connection',
|
|
56
|
+
'content-length',
|
|
57
|
+
'host',
|
|
58
|
+
'keep-alive',
|
|
59
|
+
'te',
|
|
60
|
+
'transfer-encoding',
|
|
61
|
+
'upgrade',
|
|
62
|
+
]);
|
|
63
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
64
|
+
if (value == null || skipHeaders.has(name.toLowerCase())) {
|
|
65
|
+
continue;
|
|
70
66
|
}
|
|
71
|
-
|
|
67
|
+
if (Array.isArray(value)) {
|
|
72
68
|
for (const v of value) {
|
|
73
69
|
headers.append(name, v);
|
|
74
70
|
}
|
|
75
71
|
}
|
|
72
|
+
else {
|
|
73
|
+
headers.set(name, value);
|
|
74
|
+
}
|
|
76
75
|
}
|
|
76
|
+
addDevSecretHeader(req, headers, devSecret);
|
|
77
|
+
// Dev auth is dev-secret only: never forward X-App-Id, so the BFF app-token
|
|
78
|
+
// exchange (which would also demand X-Scope-ID) can never be triggered here.
|
|
79
|
+
headers.delete('X-App-Id');
|
|
80
|
+
// BFF rejects /bardioc/ calls without this CSRF marker header; stamp it like the host does.
|
|
81
|
+
headers.set('X-Requested-With', 'XMLHttpRequest');
|
|
77
82
|
let body;
|
|
78
83
|
try {
|
|
79
84
|
body = await readRequestBody(req);
|
package/dist/vite.js
CHANGED
|
@@ -260,7 +260,6 @@ export function bardiocDevAuth(options) {
|
|
|
260
260
|
proxyOptions = {
|
|
261
261
|
apiBaseUrl: env.API_BASE_URL,
|
|
262
262
|
devSecret: env.DEV_SECRET,
|
|
263
|
-
appId: options.appName,
|
|
264
263
|
};
|
|
265
264
|
}
|
|
266
265
|
const handler = createDevAuthProxyHandler(proxyOptions);
|
|
@@ -316,7 +315,9 @@ export function bardiocApp(opts) {
|
|
|
316
315
|
config(_config, env) {
|
|
317
316
|
const isDev = env.command === 'serve';
|
|
318
317
|
return {
|
|
319
|
-
|
|
318
|
+
// Dev runs standalone without the host, so a root base avoids a
|
|
319
|
+
// base path in the Referer/Origin that the BFF may reject.
|
|
320
|
+
base: isDev ? '/' : './',
|
|
320
321
|
server: {
|
|
321
322
|
port,
|
|
322
323
|
allowedHosts: true,
|