import type { Identity, IdentityMetadata } from "./identity.js"; import type { Sphere } from "./did.js"; import type { Mandate } from "./mandate.js"; import { type GammaSigner } from "./gamma.js"; /** * The subject themselves, fully decrypted. An OwnerAuthor can read and write * any zone and sign with any sphere key. */ export interface OwnerAuthor { kind: "owner"; identity: Identity; } /** * An agent acting under a mandate. Holds only the delegate Ed25519 seed plus * the subject's public metadata — never a sphere seed. */ export interface DelegateAuthor { kind: "delegate"; /** Public metadata of the subject (did.json-derived; works on tracked installs). */ subject: IdentityMetadata; /** 32-byte Ed25519 seed the delegate uses to sign. Never leaves this process. */ seed: Uint8Array; /** Multibase (z-prefixed, 0xed01 multicodec) pubkey matching `seed`. */ pubkeyMultibase: string; /** The signed mandate authorising this agent's writes/reads. */ mandate: Mandate; } export type Author = OwnerAuthor | DelegateAuthor; /** Wrap a fully-loaded Identity as an OwnerAuthor. Always succeeds. */ export declare function ownerAuthor(identity: Identity): OwnerAuthor; export interface DelegateAuthorInput { subject: IdentityMetadata; seed: Uint8Array; pubkeyMultibase: string; mandate: Mandate; } /** * Construct a DelegateAuthor, validating that: * - the seed produces the claimed pubkey * - the pubkey matches `mandate.grantee.pubkey` (if set) * - the mandate was issued by the subject we're going to act on behalf of * * Scope/sphere/window checks are deferred to the moment of use * (`authorGammaSigner`, `assertDelegateCanWrite`, `authorCanRead`) so that * one DelegateAuthor can be reused across multiple operations. */ export declare function delegateAuthor(input: DelegateAuthorInput): DelegateAuthor; /** Subject DID the author is writing on behalf of. */ export declare function authorSubjectDid(author: Author): string; /** Local handle under AITHOS_HOME the author is writing to. */ export declare function authorHandle(author: Author): string; /** The mandate id to record in `authorized_by`, or undefined for owner signs. */ export declare function authorMandateId(author: Author): string | undefined; /** * Throw unless the delegate's mandate authorises a write to `zone` at `now`. * Owner writes always pass. */ export declare function assertCanWrite(author: Author, zone: Sphere, now?: Date): void; /** * True if the author is authorised to read the given zone. Owner always yes; * delegate iff the mandate carries `ethos.read.`, `ethos.write.`, * or `ethos.read.all`. Does NOT enforce the validity window — reading stale * plaintext that's already on disk is a separate concern from new writes. */ export declare function authorCanRead(author: Author, zone: Sphere): boolean; /** * Build a GammaSigner appropriate for the author and target zone. * * For owners: the sphere key of `zone` (mirrors legacy behaviour). * For delegates: the delegate key, with `mandateId` set — this is what * causes `buildGammaEntry` to emit the `authorized_by` field. * * Enforces `assertCanWrite` before returning, so callers can assume the * signer is legitimate for the zone. */ export declare function authorGammaSigner(author: Author, zone: Sphere): GammaSigner;