@adobe/helix-config-storage 2.1.6 → 2.1.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/.nycrc.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "reporter": [
3
3
  "lcov",
4
- "text"
4
+ "text",
5
+ "text-summary"
5
6
  ],
6
7
  "check-coverage": true,
7
8
  "lines": 100,
8
9
  "branches": 100,
9
- "statements": 100
10
+ "statements": 100,
11
+ "skip-full": true
10
12
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.1.7](https://github.com/adobe/helix-config-storage/compare/v2.1.6...v2.1.7) (2025-04-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * reject duplicate users ([#114](https://github.com/adobe/helix-config-storage/issues/114)) ([5e064a0](https://github.com/adobe/helix-config-storage/commit/5e064a05fb213ebc1d86b77eea9c4680a7fb0096))
7
+
1
8
  ## [2.1.6](https://github.com/adobe/helix-config-storage/compare/v2.1.5...v2.1.6) (2025-04-10)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-config-storage",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "Helix Config Storage",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "husky": "9.1.7",
47
47
  "json-schema-to-typescript": "15.0.4",
48
48
  "junit-report-builder": "5.1.1",
49
- "lint-staged": "15.5.0",
49
+ "lint-staged": "15.5.1",
50
50
  "mocha": "11.1.0",
51
51
  "mocha-multi-reporters": "1.5.1",
52
52
  "mocha-suppress-logs": "0.5.1",
@@ -246,6 +246,22 @@ function updateSecret(type, id, oldData, data) {
246
246
  return prune(oldData);
247
247
  }
248
248
 
249
+ /**
250
+ * Ensures that the given email is not used by another user.
251
+ * @param {string} email
252
+ * @param {User[]} users
253
+ * @throws {StatusCodeError} a 400 status code error if the email is already used
254
+ */
255
+ function validateUniqueEmail(email, users) {
256
+ if (!email) {
257
+ throw new StatusCodeError(400, 'missing email');
258
+ }
259
+ const existing = users.find((user) => user.email === email);
260
+ if (existing) {
261
+ throw new StatusCodeError(400, `email already in use by '${existing.id}'`);
262
+ }
263
+ }
264
+
249
265
  /**
250
266
  * General purpose config store.
251
267
  */
@@ -593,6 +609,7 @@ export class ConfigStore {
593
609
  if (Array.isArray(data)) {
594
610
  const users = [...old.users];
595
611
  for (const userData of data) {
612
+ validateUniqueEmail(userData.email, users);
596
613
  users.push({
597
614
  ...createUser(),
598
615
  ...userData,
@@ -605,6 +622,7 @@ export class ConfigStore {
605
622
  ...data,
606
623
  ...user,
607
624
  };
625
+ validateUniqueEmail(data.email, old.users);
608
626
  frag.name = user.id;
609
627
  frag.relPath.push(user.id);
610
628
  frag.type = 'user';