UNPKG

aws-secrets-manager-wrapper

Version:

A TypeScript wrapper for AWS Secrets Manager that simplifies common operations and provides a more user-friendly interface.

89 lines 4.34 kB
import { FilterNameStringType } from '@aws-sdk/client-secrets-manager'; import { AWSSecretsManagerConfig, BatchGetSecretOptions, BatchGetSecretResult, DeleteSecretOptions, GetSecretOptions, ListAllSecretOptions, SecretOptions } from './types'; export declare class AWSSecretsManager { private client; /** * Creates an instance of AWSSecretsManager. * @param {AWSSecretsManagerConfig} config - Configuration options including region and credentials */ constructor(config?: AWSSecretsManagerConfig); /** * Retrieves a secret value by its name. Can automatically parse JSON strings. * @param {string} secretName - Name or ARN of the secret to retrieve * @param {GetSecretOptions} options - Optional settings like version and parsing preference * @returns {Promise<T>} The secret value, parsed if requested */ getSecret<T = any>(secretName: string, options?: GetSecretOptions): Promise<T>; /** * Retrieves multiple secrets in a single request. * @param {BatchGetSecretOptions} options - Options including list of secret IDs and filters * @returns {Promise<BatchGetSecretResult>} Object containing retrieved secrets and any errors */ batchGetSecrets(options: BatchGetSecretOptions): Promise<BatchGetSecretResult>; /** * Creates a new secret with the specified name and value. * @param {string} secretName - Name for the new secret * @param {T} secretValue - Value to store (will be stringified if not a string) * @param {SecretOptions} options - Optional description and tags * @returns {Promise<string>} ARN of the created secret */ createSecret<T = any>(secretName: string, secretValue: T, options?: SecretOptions): Promise<string>; /** * Updates an existing secret's value. * @param {string} secretName - Name or ARN of the secret to update * @param {T} secretValue - New value to store * @param {SecretOptions} options - Optional description * @returns {Promise<string>} ARN of the updated secret */ updateSecret<T = any>(secretName: string, secretValue: T, options?: SecretOptions): Promise<string>; /** * Deletes a secret, optionally with a recovery window. * @param {string} secretName - Name or ARN of the secret to delete * @param {DeleteSecretOptions} options - Optional force delete and recovery window settings */ deleteSecret(secretName: string, options?: DeleteSecretOptions): Promise<void>; /** * Checks if a secret exists without retrieving its value. * @param {string} secretName - Name or ARN of the secret to check * @returns {Promise<boolean>} True if the secret exists, false otherwise */ secretExists(secretName: string): Promise<boolean>; /** * Lists all secrets with optional filtering. * @param {ListAllSecretOptions} options - Optional filtering, pagination, and result limit settings * @returns {Promise<{secretNames: string[], nextToken?: string}>} List of secret names and pagination token */ listSecrets(options?: ListAllSecretOptions): Promise<{ secretNames: string[]; nextToken?: string; }>; /** * Adds or updates tags for a secret. * @param {string} secretName - Name or ARN of the secret to tag * @param {Record<string, string>} tags - Key-value pairs of tags to apply * @returns {Promise<{ success: true; message: string }>} Success response with message */ tagSecret(secretName: string, tags: Record<string, string>): Promise<{ success: true; message: string; }>; /** * Gets all versions of a secret. * @param {string} secretName - Name or ARN of the secret * @returns {Promise<Array>} List of versions with their details */ getSecretVersions(secretName: string): Promise<Array<{ versionId: string; createdDate?: Date; isLatest: boolean; }>>; /** * Get all tags associated with a secret. * @param {string} secretName - Name or ARN of the secret * @returns {Promise<Record<string, string>>} Object containing tag key-value pairs */ getTags(secretName: string): Promise<Record<string, string>>; private formatError; } export { FilterNameStringType }; //# sourceMappingURL=aws-secret-manager.d.ts.map