/** The env var naming the launch-material file. It carries a PATH, never a secret. */ export declare const LAUNCH_MATERIAL_ENV = "COTAL_LAUNCH_MATERIAL"; /** What a launcher hands one spawned session. Every field is optional because the modes differ * (open mesh has no creds; a static-auth launch has no user-mode identity; a launch with no * control endpoint has no token), but an empty material file is refused at write time - an empty * file would be a launcher bug that reads downstream as "open mode". */ export type LaunchMaterial = { /** Broker URL(s) the session dials. */ servers?: string; /** Path to the session's NATS creds file (static auth). */ creds?: string; /** Auth token (token / open modes). */ token?: string; /** Shared secret authenticating the first frame on the session's local control socket. */ controlToken?: string; /** User-mode launch identity: principal, sentinel creds path, and the exec-able bearer command. */ userAuth?: { owner: string; actor: string; sentinelCredsPath: string; bearerCmd: string[]; }; }; /** * Write one launch's material to a fresh 0600 file in a fresh 0700 directory and return its path. * * `mkdtemp` rather than a predictable name: a pre-created or symlinked path in the world-writable * tmpdir cannot be raced, and a fresh file guarantees the private mode applies at CREATE (a mode * argument is ignored on an overwrite). {@link hardenPrivate} covers win32, where the Unix mode is * a no-op. * * REFUSES AN EMPTY MATERIAL rather than writing a file that says nothing. A launcher that computed * no material has a bug, and the downstream reader cannot tell that apart from a deliberate open * launch - which is precisely the silent-degradation this contract is not allowed to have. */ export declare function writeLaunchMaterial(material: LaunchMaterial): string; /** * Read a launch-material file, or throw a sentence naming the path. * * FAIL-CLOSED ON A PERMISSIVE MODE. A material file readable by group or other is not a material * file: it is the same disclosure this carrier exists to prevent, wearing a different hat. Refusing * is the only honest answer, because the alternative (read it anyway, warn) leaves the operator with * a session that works and a disclosure they will never look at again. Checked on POSIX only, where * the mode bits mean what they say; win32 privacy is the ACL {@link hardenPrivate} set at write. */ export declare function readLaunchMaterial(path: string): LaunchMaterial; /** * Discard one launch's material: unlink the file, and remove the private directory ONLY when this * module can tell it wrote that directory itself. * * THIS FUNCTION EXISTS BECAUSE ITS FIRST VERSION WAS DANGEROUS, and the shape of that mistake is * worth keeping in front of whoever edits it next. The first version removed the parent RECURSIVELY * whenever its basename began with the writer's prefix, under a comment claiming that proved the * directory came from here. It proved that a string starts with another string. A pointer set by * hand at any path whose parent happened to be named `cotal-launch-anything` took that parent and * every sibling file with it, and the gap between the unlink and the removal turned a concurrent * create into collateral deletion. A cleanup added to a security change must not be the most * destructive thing in it. * * So the directory removal is structural rather than a name test, and all four conditions hold or * the directory simply stays: * * - the file is named exactly what {@link writeLaunchMaterial} names it; * - its parent carries the writer's prefix; * - that parent sits DIRECTLY in the OS temp root, resolved through symlinks on both sides so * `/tmp` and a `/private/tmp` style real path compare equal; * - and the removal is `rmdir`, which cannot recurse at all, so a directory holding anything else * fails to go and is left exactly as it was found. That is the load-bearing one: the other three * are defence in depth, while this one makes "anything else in here means this is not ours" true * by construction rather than by intention. It is also what closes the race, because a file * created between the file's removal and the directory's makes the directory's FAIL rather than * making it destroy more. * * THE FILE, BY CONTRAST, IS UNLINKED UNCONDITIONALLY, and the asymmetry is deliberate rather than an * oversight. {@link LAUNCH_MATERIAL_ENV} names material for ONE launch, and by the time a discard * runs the session has already read it, so a pointer is a statement about a file that has served its * purpose, wherever it happens to live. A hand-set pointer at a file somebody wanted to keep is a * misuse of that variable rather than a case to defend. Deleting the named file is the operation the * caller asked for; deleting a directory is an inference about something the caller never named, and * an inference needs proof. * * Both halves are best effort: a discard that throws would turn tidy-up into a failed session, and * the state it would fail into is the state every launch had before this function existed. */ export declare function discardLaunchMaterial(path: string): void; //# sourceMappingURL=launch-material.d.ts.map