import type { FileHandle } from "node:fs/promises"; /** * One writer for every file that holds a token: the Relay config and the * Claude Code channel `.env`. Owner-only by the platform's own means: POSIX * mode bits (0o600 file, 0o700 folder) where they exist, and a private Windows * ACL (this account, SYSTEM, Administrators) where they do not. Windows has no * mode bits, so a chmod there proves nothing and is never used as proof. * * The write goes through an exclusive temporary file in the same folder that * is made private before any secret byte lands in it, then renamed over the * destination, then read back to confirm it is still private. * * A file that is already there is tightened, not refused, when it belongs to * this account and no other account can write it or its folder: other * programs make their own config files readable by everyone (VS Code writes * its `mcp.json` as 0644 on Linux), and those files are this person's own. * Relay refuses, and changes nothing, only when another account owns the file * or can write the file or its folder, because then that account could swap * the file or read the token as it lands. Relay's own config follows the same * rule. */ export declare const PRIVATE_FILE_MODE = 384; export declare const PRIVATE_DIR_MODE = 448; export interface PrivateDestination { path: string; directory: string; windows: boolean; /** The descriptor an existing file already had; the new file keeps it exactly. */ existingACL?: string; } /** Shared by preflight and the final write: no secret bytes are changed here. */ export declare const preparePrivateDestination: (path: string, what: string, platform?: NodeJS.Platform) => Promise; /** An exclusive, empty, already-private temporary file beside the destination. */ export declare const openPrivateTemp: (destination: PrivateDestination, prefix: string) => Promise<{ path: string; handle: FileHandle; }>; export declare const verifyPrivateACL: (path: string, destination: PrivateDestination) => Promise; export declare const removeTemp: (path: string) => Promise; /** Writes `contents` to `destination` so no reader ever sees it half-written or readable by anyone else. */ export declare const writePrivateDestination: (destination: PrivateDestination, prefix: string, contents: string) => Promise; /** * Writes a token-holding file some other program reads (an agent's MCP config), * with the same checks and the same writer as Relay's own config: a new file is * made owner-only before the token lands in it (POSIX 0o600, or a private * Windows ACL that does not inherit the folder's), an existing file of this * account that others can only read is tightened first, and a file another * account owns or can write, or a folder it can write, is refused with nothing * changed. A POSIX mode alone is not enough: Windows ignores it, so a file in a * folder that lets Users read would be readable (2026-09-26). */ export declare const writePrivateFile: (path: string, what: string, contents: string, platform?: NodeJS.Platform) => Promise; export interface PrivateFileReport { exists: boolean; /** Owner-only by the platform's own means; the folder counts too. */ secure: boolean; mode?: number; /** Windows only: whether the ACL could be read at all. */ aclChecked?: boolean; } /** How a file and its folder stand today, judged the way this platform judges it. */ export declare const inspectPrivateFile: (path: string, platform?: NodeJS.Platform) => Promise; //# sourceMappingURL=private-file.d.ts.map