/** * #365 (integrator review): `access_ack.hash` alone is a PUBLIC drift check * — anything that can write an org's JSON (a mono-agent chat org-design * tool, an agent with file access to `.monomind/orgs`, a hand-crafted * import) could recompute the same SHA-256 and forge a "human" grant. * This module adds the missing authentication: a machine-local secret key, * created only by the operator's own commands (`org role set-access * full`, and since #502 `org sign` / `org create`, which sign org * definitions with it — org-signature.ts), stored in the operator-credential directory * (`broker.ts`'s `defaultOperatorDir()`, the same directory * `authority-mask.ts`'s `authorityDirs()` denies Read/Edit on for every * scoped/sandboxed role — see `role-sandbox-restrictions.ts`'s * `disallowedTools`/`denyRead`). `access-grant.ts`'s `resolveRoleAccess` * verifies the HMAC signature before it ever trusts `hash`. * * Residual risk, same as every other authority-dir guarantee in this * codebase (role-sandbox.ts's git guard, the dashboard auth secret): an * ACTIVE full-access role runs with no sandbox and no authority mask, so it * CAN read this file, same as it can read any other credential on the * machine as the same OS user. The barrier this key adds is against a * SCOPED role, or an agent-reachable config-writing path with no shell * access at all, forging a NEW grant — not against a role that already has * one steering itself further (that role can already do anything). */ import { type Stats } from 'node:fs'; export declare function fullAccessGrantKeyPath(dir?: string): string; /** #502 review: why a file holding operator authority (the key, a signature) * must not be trusted, or undefined when it may be: a symlink, not a plain * file (or dir), another user's, or with group/other permission bits. */ export declare function untrustedFileReason(st: Stats, what: string, opts?: { dir?: boolean; getuid?: () => number; }): string | undefined; /** The operator dir's problem, if any. A dir of ours with looser bits is * tightened to 0700 first: broker.ts creates it with the default umask. */ export declare function checkOperatorDir(dir: string, getuid?: () => number): string | undefined; export type OperatorKey = { key: Buffer; problem?: undefined; } | { key?: undefined; problem: string; }; /** The operator key or why it can't be used. Never throws, never creates it. */ export declare function loadOperatorKey(dir?: string, opts?: { getuid?: () => number; }): OperatorKey; /** Read the signing key, or `undefined` when it doesn't exist or can't be * trusted (loadOperatorKey) — never throws and NEVER creates it. A role * whose grant hinges on a missing key is exactly the 'invalid-signature' * suspended case (access-grant.ts). */ export declare function readFullAccessGrantKey(dir?: string): Buffer | undefined; /** Create the key on first use (idempotent — returns the existing one if * present). Called only from the operator's own commands (`org role * set-access … full`, `org sign`, `org create`). 32 random bytes, mode 0600 * in a 0700 dir, written atomically (tmp file + same-directory rename) so a * concurrent grant never observes a half-written key. Throws when a key * exists but can't be trusted: overwriting it would hide that. */ export declare function ensureFullAccessGrantKey(dir?: string): Buffer; export declare function signAccessAck(args: { org: string; role: string; hash: string; at: string; by: string; key: Buffer; }): string; /** Timing-safe verification. Returns `false` for ANY failure — no key, no * `sig`, a malformed `sig`, or a mismatch — and never throws. */ export declare function verifyAccessAckSignature(args: { org: string; role: string; hash: string; at: string; by: string; sig: string | undefined; key: Buffer | undefined; }): boolean; //# sourceMappingURL=access-grant-key.d.ts.map