/** The independent readiness result for the exact staged credential. */ export interface CredentialReadinessResult { /** True when a run launched now with this exact credential would authenticate. */ ready: boolean; /** An optional non-secret reason code for a non-ready result. */ reason?: string; } /** Thrown when the independent readiness check does not return a ready result. * The service maps this to a failed session and still deletes the sandbox. */ export declare class DeviceLoginReadinessError extends Error { readonly reason: string; constructor(reason: string); } /** * The independent readiness check for a staged device-login credential. It runs * on the exact staged bytes, before any promotion write. It writes the bytes to * a throwaway private home and runs the same usable-auth predicate the execute * path uses. It always removes the throwaway home before it returns. * * A ready result means a run launched now with this exact credential would * authenticate. A non-ready result rejects the promotion, and the caller writes * nothing. The function reads and writes no company scope and logs no bytes. */ export declare function checkStagedCredentialReadiness(authBytes: Buffer): Promise; /** * The promotion outcome. * * - `promoted`: the helper wrote this account's own home (a seed for a first * login of this account, or a strictly-newer update for a repeat login). The * helper also best-effort writes the company default home: a seed when the * slot is absent or unusable, a refresh when this same account's login is * strictly newer than what the slot holds. * - `kept`: the login carried a credential that is not newer than what this * account's own home already holds, so the home was kept as-is. This is * still a successful authentication: a later run reads the same home. * - `not_sole_owner`: Decision H rejected the write. Nothing was written. * - `background_skipped`: Decision C rejected the write (an automatic background * path never seeds a home). Nothing was written. */ export type PromoteDeviceLoginCredentialOutcome = "promoted" | "kept" | "not_sole_owner" | "background_skipped"; /** * The promotion result. `accountId` and `accountHomeDir` are set once the * credential's identity is known — every outcome below the handle-validation * step carries `accountId`; only `promoted` and `kept` reach the write step and * carry `accountHomeDir`. * * `accountHomeCreated` is true only when this account's own home directory was * absent right before this call created it. The check and the creation run * under one lock, so a concurrent promotion for the same account (a second * login for the same Codex account) never also reports `created: true` for a * directory the first call already made. A caller that must undo a later * failure (for example, a failed secret write) should remove the directory * only when `accountHomeCreated` is true, and should still re-check that no * company secret now names this account's home before it deletes: the * absence of a company secret at the time this call started is not proof * that this login is the only login that used the directory. A user can also * delete the secret and keep the account home, so a repeat login then reads * no secret. `accountHomeCreated` is false for every outcome that does not * reach the write step (`not_sole_owner`, `background_skipped`). */ export interface PromoteDeviceLoginCredentialResult { outcome: PromoteDeviceLoginCredentialOutcome; accountId: string | null; accountHomeDir: string | null; accountHomeCreated: boolean; } export interface PromoteDeviceLoginCredentialInput { /** The exact staged credential bytes the login sandbox produced. */ authBytes: Buffer; /** The company that owns this login. It must be a single safe path segment. */ companyId: string; /** * True when a user started this login. Decision C: only a user-initiated login * seeds the company slot. An automatic background path never seeds it. */ userInitiated: boolean; /** * The independent, machine-readable readiness check. It runs on the exact * staged credential with the normal execution precedence, before any write. A * non-ready result rejects the promotion (the session fails), and the helper * writes nothing. */ checkReadiness: (authBytes: Buffer) => Promise | CredentialReadinessResult; /** * Decision H: resolves true only while this session still holds the sole active * claim on `(company_id, adapter_type)` (the internal `promoting` state). The * helper writes only when it resolves true. */ isSoleActiveOwner: () => Promise | boolean; /** A non-leaking progress sink. It receives only fixed status lines. */ log: (line: string) => void | Promise; env?: NodeJS.ProcessEnv; } /** * Promotes a device-login credential into the company scope. The order is fixed: * readiness check, credential validation, account-handle validation, Decision C, * Decision H, then the writes. The readiness check and the writes run while the * caller still holds the active claim, so a second session cannot race the same * slot. */ export declare function promoteDeviceLoginCredential(input: PromoteDeviceLoginCredentialInput): Promise; //# sourceMappingURL=adapter-auth-promotion.d.ts.map