@adobe/helix-config 3.13.0 → 3.13.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.13.1](https://github.com/adobe/helix-config/compare/v3.13.0...v3.13.1) (2024-08-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * respect only original-site ([#162](https://github.com/adobe/helix-config/issues/162)) ([155c485](https://github.com/adobe/helix-config/commit/155c4853ed9d3f16b455a181d1340e9a01690033))
7
+
1
8
  # [3.13.0](https://github.com/adobe/helix-config/compare/v3.12.0...v3.13.0) (2024-08-13)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "3.13.0",
3
+ "version": "3.13.1",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -189,14 +189,18 @@ async function loadMetadata(ctx, config, partition) {
189
189
  * loads the original site information from the `.hlx.json` file
190
190
  * @param ctx the context
191
191
  * @param contentBusId the content bus id
192
+ * @param legacy if true, the original-repository is returned, otherwise the original-site.
192
193
  * @returns {Promise<string>} the original site.
193
194
  */
194
- async function fetchOriginalSite(ctx, contentBusId) {
195
+ async function fetchOriginalSite(ctx, contentBusId, legacy) {
195
196
  const key = `${contentBusId}/.hlx.json`;
196
197
  const res = await ctx.loader.getObject(HELIX_CONTENT_BUS, key);
197
198
  if (res.body) {
198
199
  const json = res.json();
199
- return json['original-site'] || json['original-repository'] || '';
200
+ if (legacy) {
201
+ return json['original-repository'];
202
+ }
203
+ return json['original-site'];
200
204
  }
201
205
  ctx.log.error(`failed to load ${key}: ${res.status}`);
202
206
  return '';
@@ -405,21 +409,19 @@ export async function getConfigResponse(ctx, opts) {
405
409
  });
406
410
  }
407
411
  // validate original-site
408
- if (!config.legacy) {
409
- const originalSite = await fetchOriginalSite(ctx, config.content.contentBusId);
410
- if (originalSite && originalSite !== `${org}/${site}`) {
411
- ctx.log.error(`original site ${originalSite} does not match requested ${org}/${site}.`);
412
- if (scope === SCOPE_ADMIN) {
413
- return new PipelineResponse('', {
414
- status: 403,
415
- headers: {
416
- 'x-error': 'original site mismatch',
417
- ...surrogateHeaders,
418
- },
419
- });
420
- }
421
- // todo: also send 403 for all scopes....but first observe only
412
+ const originalSite = await fetchOriginalSite(ctx, config.content.contentBusId, config.legacy);
413
+ if (originalSite && originalSite !== `${org}/${site}`) {
414
+ ctx.log.error(`original site ${originalSite} does not match requested ${org}/${site}.`);
415
+ if (scope === SCOPE_ADMIN) {
416
+ return new PipelineResponse('', {
417
+ status: 403,
418
+ headers: {
419
+ 'x-error': 'original site mismatch',
420
+ ...surrogateHeaders,
421
+ },
422
+ });
422
423
  }
424
+ // todo: also send 403 for all scopes....but first observe only
423
425
  }
424
426
 
425
427
  if (config.extends && scope !== SCOPE_RAW) {