@adobe/helix-config 3.9.4 → 3.10.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,17 @@
1
+ ## [3.10.1](https://github.com/adobe/helix-config/compare/v3.10.0...v3.10.1) (2024-07-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update adobe fixes ([b87d6ee](https://github.com/adobe/helix-config/commit/b87d6ee8e5c94d89f4a0623d465c953c39470204))
7
+
8
+ # [3.10.0](https://github.com/adobe/helix-config/compare/v3.9.4...v3.10.0) (2024-07-25)
9
+
10
+
11
+ ### Features
12
+
13
+ * move tokens from org to sites/profiles ([#151](https://github.com/adobe/helix-config/issues/151)) ([4eb3073](https://github.com/adobe/helix-config/commit/4eb3073386b951c88d5318d7511a41e0fb8a0eb5))
14
+
1
15
  ## [3.9.4](https://github.com/adobe/helix-config/compare/v3.9.3...v3.9.4) (2024-07-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config",
3
- "version": "3.9.4",
3
+ "version": "3.10.1",
4
4
  "description": "Helix Config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  "@semantic-release/npm": "12.0.1",
44
44
  "c8": "10.1.2",
45
45
  "eslint": "8.57.0",
46
- "husky": "9.1.1",
46
+ "husky": "9.1.3",
47
47
  "json-schema-to-typescript": "15.0.0",
48
48
  "junit-report-builder": "3.2.1",
49
49
  "lint-staged": "15.2.7",
@@ -60,8 +60,8 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@adobe/fetch": "4.1.8",
63
- "@adobe/helix-shared-config": "10.6.4",
64
- "@adobe/helix-shared-git": "3.0.12",
63
+ "@adobe/helix-shared-config": "10.6.5",
64
+ "@adobe/helix-shared-git": "3.0.13",
65
65
  "@adobe/helix-shared-storage": "1.0.4",
66
66
  "@adobe/helix-shared-utils": "3.0.2",
67
67
  "ajv": "8.17.1",
@@ -210,6 +210,15 @@ function retainProperty(obj, prop) {
210
210
  }
211
211
  }
212
212
 
213
+ async function loadProfile(ctx, rso, name) {
214
+ const profileKey = `orgs/${rso.org}/profiles/${name}.json`;
215
+ const res = await ctx.loader.getObject(HELIX_CONFIG_BUS, profileKey);
216
+ if (res.body) {
217
+ return res.json();
218
+ }
219
+ return null;
220
+ }
221
+
213
222
  /**
214
223
  * Returns the config for the given RSO
215
224
  * @param ctx
@@ -220,16 +229,20 @@ function retainProperty(obj, prop) {
220
229
  async function resolveConfig(ctx, rso, scope) {
221
230
  // try to load site config from config-bus
222
231
  const key = `orgs/${rso.org}/sites/${rso.site}.json`;
223
- let res = await ctx.loader.getObject(HELIX_CONFIG_BUS, key);
232
+ const res = await ctx.loader.getObject(HELIX_CONFIG_BUS, key);
224
233
  if (!res.body) {
225
234
  if (scope !== SCOPE_ADMIN) {
226
- return resolveLegacyConfig(ctx, rso, scope);
235
+ const config = await resolveLegacyConfig(ctx, rso, scope);
236
+ if (config) {
237
+ const profile = await loadProfile(ctx, rso, 'default');
238
+ config.tokens = profile?.tokens || {};
239
+ }
240
+ return config;
227
241
  } else {
228
242
  return null;
229
243
  }
230
244
  }
231
245
  const site = res.json();
232
- let profile;
233
246
 
234
247
  // always load default profile if available
235
248
  if (!site.extends?.profile) {
@@ -237,11 +250,7 @@ async function resolveConfig(ctx, rso, scope) {
237
250
  profile: 'default',
238
251
  };
239
252
  }
240
- const profileKey = `orgs/${rso.org}/profiles/${site.extends.profile}.json`;
241
- res = await ctx.loader.getObject(HELIX_CONFIG_BUS, profileKey);
242
- if (res.body) {
243
- profile = res.json();
244
- }
253
+ const profile = await loadProfile(ctx, rso, site.extends.profile);
245
254
  const config = getMergedConfig(site, profile);
246
255
  if (scope === SCOPE_PIPELINE) {
247
256
  config.metadata = {
@@ -383,10 +392,6 @@ export async function getConfigResponse(ctx, opts) {
383
392
  }
384
393
 
385
394
  const orgConfig = await loadOrgConfig(ctx, org);
386
- if (orgConfig?.tokens) {
387
- config.tokens = orgConfig.tokens;
388
- }
389
-
390
395
  if (config.access) {
391
396
  // normalize access config
392
397
  const { admin = {} } = config.access;
@@ -22,9 +22,6 @@
22
22
  },
23
23
  "title": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/title" },
24
24
  "description": { "$ref": "https://ns.adobe.com/helix/config/common#/definitions/description" },
25
- "tokens": {
26
- "$ref": "https://ns.adobe.com/helix/config/tokens"
27
- },
28
25
  "users": {
29
26
  "$ref": "https://ns.adobe.com/helix/config/users"
30
27
  },
@@ -41,6 +41,12 @@
41
41
  "access": {
42
42
  "$ref": "https://ns.adobe.com/helix/config/access"
43
43
  },
44
+ "tokens": {
45
+ "$ref": "https://ns.adobe.com/helix/config/tokens"
46
+ },
47
+ "groups": {
48
+ "$ref": "https://ns.adobe.com/helix/config/groups"
49
+ },
44
50
  "sidekick": {
45
51
  "$ref": "https://ns.adobe.com/helix/config/sidekick"
46
52
  },
@@ -46,6 +46,9 @@
46
46
  "access": {
47
47
  "$ref": "https://ns.adobe.com/helix/config/access"
48
48
  },
49
+ "tokens": {
50
+ "$ref": "https://ns.adobe.com/helix/config/tokens"
51
+ },
49
52
  "groups": {
50
53
  "$ref": "https://ns.adobe.com/helix/config/groups"
51
54
  },
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "$schema": "http://json-schema.org/draft-07/schema#",
14
14
  "$id": "https://ns.adobe.com/helix/config/user",
15
+ "title": "user",
15
16
  "type": "object",
16
17
  "properties": {
17
18
  "id": {
@@ -41,6 +41,20 @@ const FRAGMENTS_COMMON = {
41
41
  preview: 'object',
42
42
  live: 'object',
43
43
  },
44
+ tokens: {
45
+ '.': 'tokens',
46
+ '.param': {
47
+ name: 'id',
48
+ '.': 'token',
49
+ },
50
+ },
51
+ groups: {
52
+ '.': 'object',
53
+ '.param': {
54
+ '.': 'object',
55
+ members: 'object',
56
+ },
57
+ },
44
58
  public: 'object',
45
59
  robots: 'object',
46
60
  };
@@ -49,23 +63,9 @@ const FRAGMENTS = {
49
63
  sites: {
50
64
  ...FRAGMENTS_COMMON,
51
65
  extends: 'object',
52
- groups: {
53
- '.': 'object',
54
- '.param': {
55
- '.': 'object',
56
- members: 'object',
57
- },
58
- },
59
66
  },
60
67
  profiles: FRAGMENTS_COMMON,
61
68
  org: {
62
- tokens: {
63
- '.': 'tokens',
64
- '.param': {
65
- name: 'id',
66
- '.': 'token',
67
- },
68
- },
69
69
  users: {
70
70
  '.': 'users',
71
71
  '.param': {
@@ -195,8 +195,8 @@ export class ConfigStore {
195
195
  if (await storage.head(this.key)) {
196
196
  throw new StatusCodeError(409, 'config already exists.');
197
197
  }
198
- if (this.type === 'org' && data.tokens) {
199
- throw new StatusCodeError(400, 'creating org config with tokens not supported yet.');
198
+ if (data.tokens) {
199
+ throw new StatusCodeError(400, 'creating config with tokens not supported yet.');
200
200
  }
201
201
  if (this.type === 'org' && data.users) {
202
202
  throw new StatusCodeError(400, 'creating org config with users is not supported yet.');
@@ -264,7 +264,7 @@ export class ConfigStore {
264
264
  }
265
265
  if (frag) {
266
266
  if (!old) {
267
- if (this.type === 'org' && frag.type === 'tokens') {
267
+ if (this.type === 'profiles' && frag.type === 'tokens') {
268
268
  old = {};
269
269
  } else {
270
270
  throw new StatusCodeError(404, 'config not found.');
@@ -12,7 +12,7 @@
12
12
 
13
13
  // NOTE: this file is autogenerated via 'npm run docs:types'
14
14
 
15
- export type Users = HttpsNsAdobeComHelixConfigUser[];
15
+ export type Users = User[];
16
16
 
17
17
  export interface HelixOrgConfig {
18
18
  version: 1;
@@ -24,22 +24,10 @@ export interface HelixOrgConfig {
24
24
  * description for clarity. has no influence on the configuration.
25
25
  */
26
26
  description?: string;
27
- tokens?: Tokens;
28
27
  users?: Users;
29
28
  groups?: Groups;
30
29
  }
31
- export interface Tokens {
32
- /**
33
- * This interface was referenced by `Tokens`'s JSON-Schema definition
34
- * via the `patternProperty` "^[a-zA-Z0-9-_=]+$".
35
- */
36
- [k: string]: {
37
- id?: string;
38
- hash?: string;
39
- created?: string;
40
- };
41
- }
42
- export interface HttpsNsAdobeComHelixConfigUser {
30
+ export interface User {
43
31
  id: string;
44
32
  email: string;
45
33
  name?: string;
@@ -28,6 +28,8 @@ export interface HelixProfileConfig {
28
28
  headers?: HelixHeadersConfig;
29
29
  cdn?: CDNConfig;
30
30
  access?: Access;
31
+ tokens?: Tokens;
32
+ groups?: Groups;
31
33
  sidekick?: SidekickConfig;
32
34
  metadata?: Metadata;
33
35
  robots?: Robots;
@@ -254,6 +256,33 @@ export interface SiteAccessConfig {
254
256
  */
255
257
  clientCertDN?: string[];
256
258
  }
259
+ export interface Tokens {
260
+ /**
261
+ * This interface was referenced by `Tokens`'s JSON-Schema definition
262
+ * via the `patternProperty` "^[a-zA-Z0-9-_=]+$".
263
+ */
264
+ [k: string]: {
265
+ id?: string;
266
+ hash?: string;
267
+ created?: string;
268
+ };
269
+ }
270
+ export interface Groups {
271
+ [k: string]: Group;
272
+ }
273
+ /**
274
+ * A group of members. Can be referenced in access.admin.role.
275
+ *
276
+ * This interface was referenced by `Groups`'s JSON-Schema definition
277
+ * via the `patternProperty` "^[a-zA-Z0-9-_=]+$".
278
+ */
279
+ export interface Group {
280
+ members: {
281
+ email: string;
282
+ name?: string;
283
+ [k: string]: unknown;
284
+ }[];
285
+ }
257
286
  export interface SidekickConfig {
258
287
  plugins?: SidekickPlugin[];
259
288
  [k: string]: unknown;
@@ -32,6 +32,7 @@ export interface HelixSiteConfig {
32
32
  headers?: HelixHeadersConfig;
33
33
  cdn?: CDNConfig;
34
34
  access?: Access;
35
+ tokens?: Tokens;
35
36
  groups?: Groups;
36
37
  sidekick?: SidekickConfig;
37
38
  metadata?: Metadata;
@@ -262,6 +263,17 @@ export interface SiteAccessConfig {
262
263
  */
263
264
  clientCertDN?: string[];
264
265
  }
266
+ export interface Tokens {
267
+ /**
268
+ * This interface was referenced by `Tokens`'s JSON-Schema definition
269
+ * via the `patternProperty` "^[a-zA-Z0-9-_=]+$".
270
+ */
271
+ [k: string]: {
272
+ id?: string;
273
+ hash?: string;
274
+ created?: string;
275
+ };
276
+ }
265
277
  export interface Groups {
266
278
  [k: string]: Group;
267
279
  }