| | | 1 | | import type { SecretProviderType } from './secret-provider-type.js'; |
| | | 2 | | |
| | | 3 | | /** |
| | | 4 | | * Whether a secret declared in the map file can be resolved, checked without |
| | | 5 | | * reading its value. Same statuses as `envilder validate`: |
| | | 6 | | * |
| | | 7 | | * - `exists`: the secret is there and the identity can see it. |
| | | 8 | | * - `missing`: the provider answered that there is no such secret. |
| | | 9 | | * - `access_denied`: the identity is not allowed to check the secret, so |
| | | 10 | | * whether it exists is unknown. Never reported as `missing`. |
| | | 11 | | * - `authentication_failed`: the provider rejected the credentials. |
| | | 12 | | * - `provider_error`: anything else, for example an unreachable provider. |
| | | 13 | | */ |
| | | 14 | | export type SecretExistenceStatus = |
| | | 15 | | | 'exists' |
| | | 16 | | | 'missing' |
| | | 17 | | | 'access_denied' |
| | | 18 | | | 'authentication_failed' |
| | | 19 | | | 'provider_error'; |
| | | 20 | | |
| | | 21 | | /** |
| | | 22 | | * The outcome of checking one secret path. `reason` explains a status other |
| | | 23 | | * than `exists` or `missing` when the provider gave one; it never carries a |
| | | 24 | | * secret value. |
| | | 25 | | */ |
| | | 26 | | export interface SecretExistence { |
| | | 27 | | readonly status: SecretExistenceStatus; |
| | | 28 | | readonly reason?: string; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /** |
| | | 32 | | * One reason the map file cannot be used. `key` names the offending entry |
| | | 33 | | * (`DB_URL`, `$config.profile`, `withProfile()`, or `(root)` for the document |
| | | 34 | | * itself). Neither field ever carries a mapped value. |
| | | 35 | | */ |
| | | 36 | | export interface MapFileError { |
| | | 37 | | readonly key: string; |
| | | 38 | | readonly message: string; |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | /** One variable of the map file with the outcome for the path it maps to. */ |
| | | 42 | | export interface KeyCheck extends SecretExistence { |
| | | 43 | | readonly variable: string; |
| | | 44 | | readonly path: string; |
| | | 45 | | readonly provider: SecretProviderType; |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | /** |
| | | 49 | | * The outcome of checking a map file contract: the map file is valid and |
| | | 50 | | * every declared secret exists. When the map file is invalid, `keys` is empty |
| | | 51 | | * because no provider was called. |
| | | 52 | | */ |
| | | 53 | | export interface ContractValidationResult { |
| | | 54 | | readonly isValid: boolean; |
| | | 55 | | readonly mapFileErrors: readonly MapFileError[]; |
| | | 56 | | readonly keys: readonly KeyCheck[]; |
| | | 57 | | } |