import SecretsManager from 'aws-sdk/clients/secretsmanager' ; /**
 * Class provides cached access to the Secret Manager.
 */ export class SecretProvider { private readonly cache : { secretId : string ; secret : string ; } = { secretId : null , secret : null } ; constructor ( private readonly secretsManager ) { } param secretId returns async getSecret ( secretId ) { if ( this . cache . secretId === secretId && this . cache . secret ) { return this . cache . secret ; } else { const response = await this . secretsManager . getSecretValue ( { SecretId : secretId } ) . promise ( ) ; this . cache . secretId = secretId ; this . cache . secret = response . SecretString ; return this . cache . secret ; } } }