@adobe/helix-config 2.18.2 → 3.0.0

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,15 @@
1
+ # [3.0.0](https://github.com/adobe/helix-config/compare/v2.18.2...v3.0.0) (2024-05-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * remove unused option and enforce scope ([#86](https://github.com/adobe/helix-config/issues/86)) ([4c9d26d](https://github.com/adobe/helix-config/commit/4c9d26d5579b289adb593b2ccfeae97d5ff5e3b6))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * ConfigContext.withFetch() was removed
12
+
1
13
  ## [2.18.2](https://github.com/adobe/helix-config/compare/v2.18.1...v2.18.2) (2024-05-13)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "2.18.2",
3
+ "version": "3.0.0",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -61,7 +61,7 @@
61
61
  "@adobe/fetch": "4.1.2",
62
62
  "@adobe/helix-shared-config": "10.4.4",
63
63
  "@adobe/helix-shared-git": "3.0.9",
64
- "@adobe/helix-shared-storage": "1.0.0",
64
+ "@adobe/helix-shared-storage": "1.0.1",
65
65
  "@adobe/helix-shared-utils": "3.0.2",
66
66
  "ajv": "8.13.0",
67
67
  "ajv-formats": "3.0.1",
@@ -11,8 +11,6 @@
11
11
  */
12
12
  import {S3Loader} from "./S3Loader";
13
13
 
14
- type Fetch = (url: string|Request, options?: RequestOptions) => Promise<Response>;
15
-
16
14
  export declare enum ConfigScope {
17
15
  delivery = 'delivery',
18
16
  pipeline = 'pipeline',
@@ -24,6 +22,5 @@ export declare class ConfigContext {
24
22
  withLog(log: Console): ConfigContext;
25
23
  withEnv(env: object): ConfigContext;
26
24
  withS3Loader(loader: S3Loader): ConfigContext;
27
- withFetch(fetch: Fetch): ConfigContext;
28
25
  }
29
26
 
@@ -39,7 +39,6 @@ export const SCOPE_RAW = 'raw';
39
39
  * Public / Custom Configs: Sidekick, Production Host, Custom Preview Page / Live Host, Custom JSON.
40
40
  * @type {string}
41
41
  */
42
- // eslint-disable-next-line no-unused-vars
43
42
  export const SCOPE_PUBLIC = 'public';
44
43
 
45
44
  /**
@@ -68,9 +67,4 @@ export class ConfigContext {
68
67
  this.loader = loader;
69
68
  return this;
70
69
  }
71
-
72
- withFetch(fetch) {
73
- this.fetch = fetch;
74
- return this;
75
- }
76
70
  }
@@ -17,7 +17,7 @@ import {
17
17
  SCOPE_ADMIN,
18
18
  SCOPE_PIPELINE,
19
19
  SCOPE_DELIVERY,
20
- SCOPE_RAW,
20
+ SCOPE_RAW, SCOPE_PUBLIC,
21
21
  } from './ConfigContext.js';
22
22
  import { resolveLegacyConfig, fetchRobotsTxt, toArray } from './config-legacy.js';
23
23
  import { getMergedConfig } from './config-merge.js';
@@ -47,6 +47,14 @@ const HELIX_CONFIG_BUS = 'helix-config-bus';
47
47
 
48
48
  const HELIX_CONTENT_BUS = 'helix-content-bus';
49
49
 
50
+ const VALID_SCOPES = [
51
+ SCOPE_ADMIN,
52
+ SCOPE_PIPELINE,
53
+ SCOPE_DELIVERY,
54
+ SCOPE_RAW,
55
+ SCOPE_PUBLIC,
56
+ ];
57
+
50
58
  /**
51
59
  * Creates a string representation of the given array that is suitable for substring matching by
52
60
  * delimiting each entry with `,` eg: ,foo@adobe.com,bar@adobe.com,
@@ -263,6 +271,15 @@ export async function getConfigResponse(ctx, opts) {
263
271
  const {
264
272
  ref, site, org, scope,
265
273
  } = opts;
274
+ if (!VALID_SCOPES.includes(scope)) {
275
+ return new PipelineResponse('', {
276
+ status: 400,
277
+ headers: {
278
+ 'x-error': 'invalid scope',
279
+ },
280
+ });
281
+ }
282
+
266
283
  const rso = { ref, site, org };
267
284
  const config = await resolveConfig(ctx, rso, scope);
268
285
  const surrogateHeaders = {