UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

38 lines (37 loc) • 1.93 kB
/** * Private file and directory creation for credential material. * * Every credential file under `~/.neurolink` used to be created through a * different path with a different idea of permissions: a temp file at umask * mode then chmod'd, a directory whose mode was asserted only on first * creation, a truncate-in-place write that followed symlinks. These helpers * are the one place that gets it right, and the token store, the CLI * credentials file and the update-state file all go through them. * * @module auth/secureFiles */ export declare const PRIVATE_FILE_MODE = 384; export declare const PRIVATE_DIR_MODE = 448; /** Everything a CLI entry point creates is owner-only unless it says otherwise. */ export declare const PRIVATE_UMASK = 63; /** * Tighten the process umask so no file this process creates is group- or * world-readable, whatever the shell's default was. Idempotent; returns the * mask that was in force. */ export declare function tightenProcessUmask(): number; /** Create `dir` owner-only, and re-assert the mode when it already existed. */ export declare function ensurePrivateDirectory(dir: string): Promise<void>; /** Synchronous twin of {@link ensurePrivateDirectory}, for CLI start-up paths. */ export declare function ensurePrivateDirectorySync(dir: string): void; /** * Write `content` to `targetPath` atomically and owner-only. * * The temp file is created with `wx` at 0600 — never at umask mode and then * chmod'd, which left a window in which another uid could open it — under an * unpredictable name, and renamed into place. A rename replaces a symlink at * the target rather than following it. */ export declare function writePrivateFileAtomically(targetPath: string, content: string): Promise<void>; /** Synchronous twin of {@link writePrivateFileAtomically}. */ export declare function writePrivateFileAtomicallySync(targetPath: string, content: string): void;