/** * Minimal signing surface required to produce an envelope's * `proof.proofValue`. Intentionally narrower than {@link Signer} so * callers that don't want to construct a full `RawSeedSigner` can pass * a one-shot inline adapter. Every {@link Signer} satisfies this * interface structurally. */ export interface EnvelopeSigner { sign(message: Uint8Array): Promise; } /** * The wire-format envelope per spec §11.2. Apps that POST this to a * backend serialize the whole object as JSON (alongside the rest of * `params`) under `params._envelope`. */ export interface SignedEnvelope { readonly "aithos-envelope": "0.1.0"; readonly iss: string; readonly aud: string; readonly method: string; readonly iat: number; readonly exp: number; readonly nonce: string; readonly params_hash: string; /** * Full signed mandate — present ONLY for a delegate-signed envelope * (§11.6). When present, `proof.verificationMethod` is the delegate's * bare Ed25519 multibase (matching `mandate.grantee.pubkey`) and the * server resolves the signer to that key after verifying the mandate. * The field is part of the signed bytes (the signature commits to the * delegation context), so it cannot be swapped out in transit. */ readonly mandate?: unknown; readonly proof: { readonly type: "Ed25519Signature2020"; readonly verificationMethod: string; readonly created: string; readonly proofValue: string; }; } export interface SignOwnerEnvelopeArgs { /** Subject DID — issuer of the envelope (`iss` field). */ readonly iss: string; /** * Absolute URL of the target endpoint (scheme + host + path, no query, * no fragment). The server verifier rejects envelopes where `aud` * does not match the actual endpoint being called. */ readonly aud: string; /** Fully-qualified JSON-RPC method name. */ readonly method: string; /** Tool payload — what `params_hash` commits to. */ readonly params: unknown; /** * Anything that can produce an Ed25519 signature over a byte * sequence. In practice: one of the four owner sphere signers * loaded post sign-in, or an inline adapter wrapping a raw seed. */ readonly signer: EnvelopeSigner; /** * Verification method URL — typically `${did}#${sphere}`. The server * resolves this against the issuer's DID document to find the * matching public key. */ readonly verificationMethod: string; /** * Full signed mandate, attached to the envelope for a delegate-signed * call (§11.6). When set, `verificationMethod` MUST be the delegate's * bare Ed25519 multibase (matching `mandate.grantee.pubkey`) and * `signer` MUST be the delegate's key. Omit for owner-path envelopes. */ readonly mandate?: unknown; /** Envelope lifetime in seconds. Default 60. Server caps at 300. */ readonly ttlSeconds?: number; /** Clock override for deterministic tests. Defaults to `new Date()`. */ readonly now?: Date; /** Nonce override for deterministic tests. Defaults to a fresh ULID. */ readonly nonce?: string; } /** * Build, canonicalize and sign an owner-path envelope per spec §11.2. * * The unsigned envelope is JCS-canonicalized (RFC 8785 subset), the * bytes signed with Ed25519, and the resulting signature attached as * `proof.proofValue` (base64url). * * Async return type — even though `Signer.sign` may resolve * synchronously today (via `RawSeedSigner`), the interface is shaped * async so that future implementations backed by `crypto.subtle.sign` * (non-extractable keys) drop in without breaking callers. */ export declare function signOwnerEnvelope(args: SignOwnerEnvelopeArgs): Promise; //# sourceMappingURL=envelope.d.ts.map