UNPKG

@agent-base/secret-client

Version:
54 lines 2.76 kB
import { GoogleSecretManagerConfigError, SecretNotFoundError, GoogleCloudSecretManagerApiError } from './errors.js'; import type { GoogleSecretManagerConfig } from './types.js'; import { generateSecretManagerId } from './utils.js'; /** * A client for interacting with Google Cloud Secret Manager. * Provides methods to store, retrieve, and check for the existence of secrets. */ export declare class GoogleSecretManager { private client; private projectParent; private projectId; /** * Creates an instance of the GoogleSecretManager client. * @param config Configuration for the client, including projectId and optional credentials. * @throws {GoogleSecretManagerConfigError} If projectId is not provided. */ constructor(config: GoogleSecretManagerConfig); /** * Retrieves the latest version of a secret's value. * @param secretId The ID of the secret (not the full path). * @returns The secret value as a string, or null if the secret or version is not found or has no data. * @throws {GoogleCloudSecretManagerApiError} If an API error occurs other than NOT_FOUND. */ getSecret(secretId: string): Promise<string | null>; /** * Stores a secret value. * If the secret does not exist, it creates the secret and adds the value as the first version. * If the secret exists, it adds a new version with the provided value. * The secret ID should only contain alphanumeric characters, hyphens, and underscores. * @param secretId The ID of the secret (e.g., 'my-api-key'). Max 255 chars. * @param value The string value of the secret to store. * @throws {GoogleSecretManagerConfigError} If secretId is invalid. * @throws {GoogleCloudSecretManagerApiError} If an API error occurs. */ storeSecret(secretId: string, value: string): Promise<void>; /** * Checks if a secret with the given ID exists. * @param secretId The ID of the secret. * @returns True if the secret exists, false otherwise. * @throws {GoogleCloudSecretManagerApiError} If an API error occurs other than NOT_FOUND. */ secretExists(secretId: string): Promise<boolean>; /** * Deletes a secret and all its versions. * Use with caution, this operation is irreversible without backups. * @param secretId The ID of the secret to delete. * @throws {SecretNotFoundError} If the secret does not exist. * @throws {GoogleCloudSecretManagerApiError} If an API error occurs. */ deleteSecret(secretId: string): Promise<void>; } export * from './types.js'; export { GoogleSecretManagerConfigError, SecretNotFoundError, GoogleCloudSecretManagerApiError, generateSecretManagerId }; //# sourceMappingURL=index.d.ts.map