updating-secrets 1.1.1 → 1.2.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.
@@ -63,7 +63,9 @@ export class SecretsJsonFileAdapter extends BaseSecretsAdapter {
63
63
  const secretValue = existingSecrets[key];
64
64
  const shapeDefinition = secrets[key]?.shapeDefinition;
65
65
  return shapeDefinition
66
- ? !checkValidShape(secretValue, shapeDefinition)
66
+ ? !checkValidShape(secretValue, shapeDefinition, {
67
+ allowExtraKeys: true,
68
+ })
67
69
  : !check.isString(secretValue);
68
70
  });
69
71
  if (invalidSecretKeys.length > 0) {
@@ -13,7 +13,9 @@ export class SecretLoadError extends Error {
13
13
  allErrors = [];
14
14
  constructor(originalError, { adapterName, secretName, }) {
15
15
  const message = `Failed to load secret '${secretName}' from adapter '${adapterName}': ${extractErrorMessage(originalError)}`;
16
- super(message, { cause: originalError });
16
+ super(message, {
17
+ cause: originalError,
18
+ });
17
19
  this.allErrors.push(originalError);
18
20
  }
19
21
  }
@@ -141,22 +141,26 @@ export class UpdatingSecrets {
141
141
  try {
142
142
  const rawSecrets = await adapter.loadSecrets(this.processedSecrets);
143
143
  return mapObjectValues(rawSecrets, async (secretName, loadedSecretValue) => {
144
+ const shapeDefinition = this.processedSecrets[secretName]?.shapeDefinition;
144
145
  try {
145
146
  const value = await loadedSecretValue;
146
147
  if (value instanceof Error) {
147
148
  throw value;
148
149
  }
149
- else if (this.processedSecrets[secretName]?.shapeDefinition) {
150
- assertValidShape(value, this.processedSecrets[secretName]
151
- .shapeDefinition,
152
- /** Allow extra keys for forwards compatibility. */
153
- {
150
+ else if (shapeDefinition) {
151
+ assertValidShape(value, shapeDefinition, {
154
152
  allowExtraKeys: true,
155
153
  });
156
154
  }
157
155
  return value;
158
156
  }
159
157
  catch (caught) {
158
+ if (shapeDefinition &&
159
+ checkValidShape(undefined, shapeDefinition, {
160
+ allowExtraKeys: true,
161
+ })) {
162
+ return undefined;
163
+ }
160
164
  const error = new SecretLoadError(ensureError(caught), {
161
165
  adapterName: adapter.adapterName,
162
166
  secretName,
@@ -300,7 +304,9 @@ export class UpdatingSecrets {
300
304
  async loadDynamicSecret(secretKey, shapeRequirement) {
301
305
  const cached = this.dynamicCache[secretKey];
302
306
  if (cached &&
303
- checkValidShape(cached.value, shapeRequirement) &&
307
+ checkValidShape(cached.value, shapeRequirement, {
308
+ allowExtraKeys: true,
309
+ }) &&
304
310
  !isDateAfter({
305
311
  fullDate: getNowInUtcTimezone(),
306
312
  relativeTo: calculateRelativeDate(cached.cachedAt, this.options.updateInterval),
@@ -323,13 +329,20 @@ export class UpdatingSecrets {
323
329
  if (!value) {
324
330
  throw new Error('Secret is empty');
325
331
  }
326
- assertValidShape(value, shapeRequirement);
332
+ assertValidShape(value, shapeRequirement, {
333
+ allowExtraKeys: true,
334
+ });
327
335
  return value;
328
336
  }
329
337
  catch (error) {
330
338
  errors.push(ensureErrorAndPrependMessage(error, `Failed to load secret '${secretKey}' from adapter '${adapter.adapterName}'`));
331
339
  }
332
340
  }
341
+ if (checkValidShape(undefined, shapeRequirement, {
342
+ allowExtraKeys: true,
343
+ })) {
344
+ return undefined;
345
+ }
333
346
  throw combineErrors(errors);
334
347
  }
335
348
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "updating-secrets",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Automatically update secrets on an interval with support for seamless secret rotation.",
5
5
  "keywords": [
6
6
  "secrets",
@@ -44,19 +44,19 @@
44
44
  "test:update": "npm run test update"
45
45
  },
46
46
  "dependencies": {
47
- "@augment-vir/assert": "^31.57.5",
48
- "@augment-vir/common": "^31.57.5",
49
- "date-vir": "^8.1.0",
50
- "object-shape-tester": "^6.11.0",
51
- "type-fest": "^5.3.1"
47
+ "@augment-vir/assert": "^31.69.0",
48
+ "@augment-vir/common": "^31.69.0",
49
+ "date-vir": "^8.3.2",
50
+ "object-shape-tester": "^6.12.1",
51
+ "type-fest": "^5.6.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@augment-vir/test": "^31.57.5",
55
- "@types/node": "^25.0.3",
56
- "c8": "^10.1.3",
54
+ "@augment-vir/test": "^31.69.0",
55
+ "@types/node": "^25.6.0",
56
+ "c8": "^11.0.0",
57
57
  "istanbul-smart-text-reporter": "^1.1.5",
58
- "markdown-code-example-inserter": "^3.0.3",
59
- "typedoc": "^0.28.15",
58
+ "markdown-code-example-inserter": "^3.0.5",
59
+ "typedoc": "^0.28.19",
60
60
  "typescript": "^5.9.3"
61
61
  },
62
62
  "engines": {