< Summary - Envilder Core (TypeScript)

Information
Class: src/envilder/core/infrastructure/azure/AzureSecretProviderFactory.ts
Assembly: Default
File(s): src/envilder/core/infrastructure/azure/AzureSecretProviderFactory.ts
Tag: 151_24479375065
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 40
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/infrastructure/azure/AzureSecretProviderFactory.ts

#LineLine coverage
 1import { DefaultAzureCredential } from '@azure/identity';
 2import { SecretClient } from '@azure/keyvault-secrets';
 3import { DependencyMissingError } from '../../domain/errors/DomainErrors.js';
 4import type { MapFileConfig } from '../../domain/MapFileConfig.js';
 5import type { ISecretProvider } from '../../domain/ports/ISecretProvider.js';
 6import { AzureKeyVaultSecretProvider } from './AzureKeyVaultSecretProvider.js';
 7import {
 8  DEFAULT_VAULT_HOSTS,
 9  validateAzureVaultUrl,
 10} from './AzureVaultUrlValidator.js';
 11
 12export { DEFAULT_VAULT_HOSTS } from './AzureVaultUrlValidator.js';
 13
 14export type AzureProviderOptions = {
 15  allowedVaultHosts?: string[];
 16  disableChallengeResourceVerification?: boolean;
 17};
 18
 19export function createAzureSecretProvider(
 20  config: MapFileConfig,
 21  options?: AzureProviderOptions,
 22): ISecretProvider {
 1923  const { vaultUrl } = config;
 1924  if (!vaultUrl) {
 225    throw new DependencyMissingError(
 26      'vaultUrl is required when using Azure provider.' +
 27        ' Set it in $config.vaultUrl in your map file' +
 28        ' or via --vault-url flag.',
 29    );
 30  }
 1731  const allowedVaultHosts = options?.allowedVaultHosts ?? DEFAULT_VAULT_HOSTS;
 32  const disableChallengeResourceVerification =
 1933    options?.disableChallengeResourceVerification ?? false;
 1934  validateAzureVaultUrl(vaultUrl, allowedVaultHosts);
 1935  const credential = new DefaultAzureCredential();
 1936  const client = new SecretClient(vaultUrl, credential, {
 37    disableChallengeResourceVerification,
 38  });
 1939  return new AzureKeyVaultSecretProvider(client);
 40}

Methods/Properties

createAzureSecretProvider