@bardioc/app-sdk 0.4.6 → 0.4.8

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.
@@ -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
@@ -31,9 +31,19 @@ function addDevSecretHeader(req, headers, devSecret) {
31
31
  }
32
32
  return headers;
33
33
  }
34
+ // The BFF answers a bare 403 for any Origin outside its CORS allow-list, which no
35
+ // localhost dev server is in. Dropping Origin makes it a non-CORS request, and the
36
+ // dev-secret check then still passes via its Referer localhost fallback.
37
+ function dropOriginKeepReferer(headers) {
38
+ const origin = headers.get('Origin');
39
+ if (origin && !headers.has('Referer')) {
40
+ headers.set('Referer', `${origin}/`);
41
+ }
42
+ headers.delete('Origin');
43
+ }
34
44
  export function createDevAuthProxyHandler(options) {
35
45
  const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
36
- const { devSecret, allowOrigin, appId } = options;
46
+ const { devSecret, allowOrigin } = options;
37
47
  return async (req, res) => {
38
48
  const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
39
49
  if (req.method === 'OPTIONS') {
@@ -49,8 +59,8 @@ export function createDevAuthProxyHandler(options) {
49
59
  const upstreamPath = url.pathname.slice('/rest'.length) + url.search;
50
60
  const upstreamUrl = `${apiBaseUrl}${upstreamPath}`;
51
61
  const headers = new Headers();
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.
62
+ // Forward headers from the browser so the BFF sees the same request the host would
63
+ // relay (cookies, referer, etc.). Skip hop-by-hop headers; fetch sets Host from the URL.
54
64
  const skipHeaders = new Set([
55
65
  'connection',
56
66
  'content-length',
@@ -74,11 +84,10 @@ export function createDevAuthProxyHandler(options) {
74
84
  }
75
85
  }
76
86
  addDevSecretHeader(req, headers, devSecret);
77
- // The host stamps X-App-ID from its own registration data, never from the app — the
78
- // dev proxy does the same with the configured app slug.
79
- if (appId) {
80
- headers.set('X-App-ID', appId);
81
- }
87
+ dropOriginKeepReferer(headers);
88
+ // Dev auth is dev-secret only: never forward X-App-Id, so the BFF app-token
89
+ // exchange (which would also demand X-Scope-ID) can never be triggered here.
90
+ headers.delete('X-App-Id');
82
91
  // BFF rejects /bardioc/ calls without this CSRF marker header; stamp it like the host does.
83
92
  headers.set('X-Requested-With', 'XMLHttpRequest');
84
93
  let body;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bardioc/app-sdk",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "SDK for building apps for the Bardioc OS",
5
5
  "license": "MIT",
6
6
  "private": false,