import { z } from 'zod'; export declare const storedOAuthCredentialSchema: z.ZodObject<{ kind: z.ZodLiteral<"oauth">; issuer: z.ZodString; resource: z.ZodString; clientId: z.ZodString; tokenEndpoint: z.ZodString; scope: z.ZodString; accessToken: z.ZodString; refreshToken: z.ZodOptional; expiresAt: z.ZodNumber; generation: z.ZodNumber; }, z.core.$strip>; export declare const storedAccessKeySchema: z.ZodObject<{ kind: z.ZodLiteral<"access-key">; secret: z.ZodString; }, z.core.$strip>; export declare const storedCredentialSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"oauth">; issuer: z.ZodString; resource: z.ZodString; clientId: z.ZodString; tokenEndpoint: z.ZodString; scope: z.ZodString; accessToken: z.ZodString; refreshToken: z.ZodOptional; expiresAt: z.ZodNumber; generation: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"access-key">; secret: z.ZodString; }, z.core.$strip>], "kind">; export type StoredOAuthCredential = z.infer; export type StoredAccessKey = z.infer; export type StoredCredential = z.infer; /** Where a connection's secret lives. `environment` stores nothing. */ export type CredentialBackendKind = 'keychain' | 'file' | 'environment'; export interface CredentialStore { get(reference: string): Promise; set(reference: string, credential: StoredCredential): Promise; delete(reference: string): Promise; } /** An opaque, non-secret handle for a stored secret. Never derived from names. */ export declare function newSecretReference(): string; export declare function parseStoredCredential(value: string): StoredCredential; interface CommandResult { stdout: string; stderr: string; code: number; } export type CredentialCommandRunner = (executable: string, arguments_: string[], input?: string) => Promise; /** macOS Keychain or Linux Secret Service. */ export declare class OsCredentialStore implements CredentialStore { private readonly platform; private readonly run; constructor(options?: { platform?: NodeJS.Platform; run?: CredentialCommandRunner; }); get(reference: string): Promise; set(reference: string, credential: StoredCredential): Promise; delete(reference: string): Promise; private unsupported; } /** * One restricted file per secret under `/credentials/`, mode 0600 in a * 0700 directory. Chosen explicitly (`--store file`), never as a fallback. */ export declare class FileCredentialStore implements CredentialStore { private readonly directory; constructor(home: string); private path; get(reference: string): Promise; set(reference: string, credential: StoredCredential): Promise; delete(reference: string): Promise; } export interface CredentialStores { keychain: CredentialStore; file: CredentialStore; } export declare function defaultCredentialStores(home: string): CredentialStores; /** * A cross-process lock around one credential's refresh. * * `O_EXCL` creation is the mutual exclusion. The lock file records its owner * (pid, host) and a random token. A lock is broken only when its owner is * provably gone — a dead pid on this host — or, for an owner on another host * or an unreadable file, once it is older than `staleMs`. A live owner is never * preempted however long its refresh takes (the refresh request itself times * out well inside `staleMs`). * * Breaking renames the file aside first and checks the token: if another * process already broke and re-acquired it in between, the fresh lock is put * back rather than deleted. Correctness against a concurrent writer is still * the generation compare-and-swap in the refresh path; the lock exists so that * only one process ever spends a given refresh token. Locks assume one host's * filesystem; a home shared over a network filesystem is not supported. */ export declare function withCredentialLock(home: string, name: string, operation: () => Promise, options?: { staleMs?: number; timeoutMs?: number; pollMs?: number; }): Promise; export {}; //# sourceMappingURL=credentials.d.ts.map