/** * CredentialManager - Manages shared credentials for action execution * * This utility allows developers to set up credentials once per app/product/env * combination, and have those credentials automatically merged into action * inputs before resolution. * * @example * ```ts * // Set up shared credentials once * ductape.api.config({ * product: 'my-product', * app: 'stripe', * env: 'prd', * credentials: { * 'headers:Authorization': '$Secret{StripeApiKey}', * } * }); * * // Now all stripe actions in prd env automatically include credentials * const result = await ductape.api.run({ * product: 'my-product', * app: 'stripe', * env: 'prd', * event: 'create-charge', * input: { amount: 1000, currency: 'usd' } * }); * // Input automatically includes 'headers:Authorization' from shared credentials * ``` */ /** * Shared credentials configuration */ export interface IShareCredentialsConfig { /** Product tag */ product: string; /** App tag */ app: string; /** Environment slug */ env: string; /** Credentials to share (flat format with optional prefixes) */ credentials: Record; } /** * Options for getting shared credentials */ export interface IGetCredentialsOptions { product: string; app: string; env: string; } /** * Validation error thrown for invalid credential configurations */ export declare class CredentialError extends Error { readonly errorType: 'invalid_config' | 'not_found'; constructor(message: string, errorType: 'invalid_config' | 'not_found'); } /** * CredentialManager stores and retrieves shared credentials * for product/app/env combinations. */ export declare class CredentialManager { /** Storage for credentials, keyed by product:app:env */ private credentials; /** * Share credentials for a product/app/env combination * * @param config - Credential configuration * @throws CredentialError if configuration is invalid */ share(config: IShareCredentialsConfig): void; /** * Get shared credentials for a product/app/env combination * * @param options - Options specifying product, app, and env * @returns Shared credentials or undefined if not set */ get(options: IGetCredentialsOptions): Record | undefined; /** * Check if shared credentials exist for a product/app/env combination */ has(options: IGetCredentialsOptions): boolean; /** * Remove shared credentials for a product/app/env combination * * @param options - Options specifying product, app, and env * @returns true if credentials were removed, false if they didn't exist */ remove(options: IGetCredentialsOptions): boolean; /** * Clear all shared credentials */ clearAll(): void; /** * Clear all credentials for a specific product */ clearProduct(product: string): void; /** * Clear all credentials for a specific app (across all products) */ clearApp(app: string): void; /** * Clear all credentials for a specific environment (across all products and apps) */ clearEnv(env: string): void; /** * Get all registered product/app/env combinations */ list(): Array<{ product: string; app: string; env: string; }>; /** * Merge shared credentials with user-provided input * Shared credentials are used as defaults; user input takes precedence * * @param sharedCredentials - Shared credentials from manager * @param userInput - User-provided flat input * @returns Merged input with shared credentials as defaults */ mergeWithInput(sharedCredentials: Record, userInput: Record): Record; } /** * Singleton instance for convenience */ export declare const credentialManager: CredentialManager;