< Summary - Envilder Node.js SDK

Information
Class: src/sdks/nodejs/src/application/secret-validation.ts
Assembly: Default
File(s): src/sdks/nodejs/src/application/secret-validation.ts
Tag: 299_25910610327
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 42
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/sdks/nodejs/src/application/secret-validation.ts

#LineLine coverage
 1/**
 2 * Thrown when resolved secrets contain missing or empty values.
 3 */
 4export class SecretValidationError extends Error {
 5  /**
 6   * Keys whose values were empty or whitespace-only.
 7   * Empty array when no secrets were resolved at all.
 8   */
 9  readonly missingKeys: string[];
 10
 11  constructor(missingKeys: string[]) {
 612    super(
 13      missingKeys.length === 0
 14        ? 'No secrets were resolved'
 15        : `The following secrets have empty or missing values: ${missingKeys.join(', ')}`,
 16    );
 617    this.missingKeys = missingKeys;
 618    this.name = 'SecretValidationError';
 19  }
 20}
 21
 22/**
 23 * Validates that all resolved secrets have non-empty values.
 24 *
 25 * @throws {SecretValidationError} When the map is empty or any value is empty/whitespace.
 26 */
 27export function validateSecrets(secrets: ReadonlyMap<string, string>): void {
 728  if (secrets.size === 0) {
 229    throw new SecretValidationError([]);
 30  }
 31
 532  const missingKeys: string[] = [];
 533  for (const [key, value] of secrets) {
 1234    if (!value?.trim()) {
 635      missingKeys.push(key);
 36    }
 37  }
 38
 539  if (missingKeys.length > 0) {
 440    throw new SecretValidationError(missingKeys);
 41  }
 42}

Methods/Properties

(anonymous_0)
validateSecrets