UNPKG

envilder

Version:

A CLI and GitHub Action that securely centralizes your environment variables from AWS SSM or Azure Key Vault as a single source of truth

32 lines 1.05 kB
/** * Thrown when resolved secrets contain missing or empty values. */ export class SecretValidationError extends Error { constructor(missingKeys) { super(missingKeys.length === 0 ? 'No secrets were resolved' : `The following secrets have empty or missing values: ${missingKeys.join(', ')}`); this.missingKeys = missingKeys; this.name = 'SecretValidationError'; } } /** * Validates that all resolved secrets have non-empty values. * * @throws {SecretValidationError} When the map is empty or any value is empty/whitespace. */ export function validateSecrets(secrets) { if (secrets.size === 0) { throw new SecretValidationError([]); } const missingKeys = []; for (const [key, value] of secrets) { if (!(value === null || value === void 0 ? void 0 : value.trim())) { missingKeys.push(key); } } if (missingKeys.length > 0) { throw new SecretValidationError(missingKeys); } } //# sourceMappingURL=secret-validation.js.map