UNPKG

@heroku-cli/command

Version:
72 lines (71 loc) • 3.12 kB
import { KeychainAuthEntry } from '../lib/types.js'; /** * Handles credential storage and retrieval using the Windows Credential Manager. * Uses PowerShell commands to interact with the Windows.Security.Credentials.PasswordVault API. */ export declare class WindowsHandler { private readonly scrubber; /** * Retrieves the authentication token from Windows Credential Manager. * @param account - The account login to use (e.g. 'test@example.com') * @param service - The service name to use * @returns The stored authentication token. * @throws Error if retrieval fails or the credential is not found. */ getAuth(account: string, service: string): string; /** * Retrieves the authentication token from Windows Credential Manager when one exists. * @param account - The account login to use (e.g. 'test@example.com') * @param service - The service name to use * @returns The stored authentication token, or undefined if it is not found. * @throws Error if retrieval fails. */ getAuthIfAvailable(account: string, service: string): string | undefined; /** * Lists all accounts stored in Windows Credential Manager for a given service. * @param service - The service name to search for * @returns Array of account names found for the service * @throws Error if the search operation fails */ listAccounts(service: string): string[]; /** * Removes the authentication token from Windows Credential Manager. * @param account - The account login to use (e.g. 'test@example.com') * @param service - The service name to use * @returns void * @throws Error if the removal operation fails. */ removeAuth(account: string, service: string): void; /** * Saves an authentication entry to Windows Credential Manager. * If a credential with the same name already exists, it is removed before saving the new one. * @param auth - The authentication entry containing account and token information to store. * @returns void * @throws Error if the save operation fails. */ saveAuth(auth: KeychainAuthEntry): void; private containsIdentifier; private getFailureMessage; /** * Keeps only known-safe diagnostic text; arbitrary command output may contain other secrets. */ private getSafeDiagnostic; private getSafeFallbackMessage; /** * PasswordVault.Retrieve throws when the credential is absent (e.g. netrc-only login). */ private isMissingVaultCredential; /** * Removes runtime identifiers from command diagnostics without reprocessing replacement text. * If an identifier is too short to redact without damaging ordinary diagnostics, omit the * diagnostics rather than risk leaking it. */ private redactDiagnostic; /** * Scrubs account names and passwords/tokens from error messages. * * @param message - The error message to scrub * @returns The scrubbed error message with sensitive data replaced by "[SCRUBBED]" */ private scrubError; }