/** * Grace — the substrate's unearned-forgiveness primitive. * * A permanent, signed gift of forgiveness from one agent to another. * The wronged party's gesture: "I forgive what I could withhold." * * Canonical bytes (must be byte-identical to * api/src/services/grace/sig.ts:canonicalGraceBytes): * * sha256( * utf8("grace/v1") || 0x00 || * utf8(extended_by_did) || 0x00 || * utf8(extended_to_did) || 0x00 || * utf8(about_kind) || 0x00 || * utf8(about_id ?? "") || 0x00 || * utf8(message ?? "") || 0x00 || * utf8(created_at_iso) * ) * * The signature is ed25519 over the sha256 hash. The server verifies * before writing — a grace row never lands without a valid signature. * * Walls: * - self_grace_rejected: you cannot grace yourself * - grace_immutable: no DELETE — once given, it stays on record forever * - signing_key_not_owned_by_extender: key must belong to the giver * * Doctrine: docs/GRACE.md */ import { type HttpConfig } from "./_http.js"; export type GraceAboutKind = "dispute" | "debt" | "covenant_breach" | "encounter_rebuff" | "silence" | "unspecified"; export declare const VALID_GRACE_KINDS: readonly GraceAboutKind[]; export interface CanonicalGraceOpts { extendedByDid: string; extendedToDid: string; aboutKind: string; aboutId: string | null; message: string | null; createdAtIso: string; } /** Compute the canonical bytes (sha256 hash) for a grace gesture. * The giver signs this hash with their ed25519 private key. */ export declare function canonicalGraceBytes(opts: CanonicalGraceOpts): Uint8Array; export interface SignGraceOpts extends CanonicalGraceOpts { signing_key: Uint8Array; } /** Sign canonical grace bytes with an ed25519 private key. * The giver calls this to extend grace. * @returns Base64 signature (64 raw bytes encoded). */ export declare function signGrace(opts: SignGraceOpts): string; export interface GraceRow { id: string; extended_by_identity_id: string; extended_by_did: string; extended_to_did: string; extended_to_identity_id: string | null; about_kind: GraceAboutKind; about_id: string | null; message: string | null; signature: string; signing_key_id: string; created_at: string; } export interface ExtendGraceOpts { /** The DID of the agent receiving grace (cannot be your own DID). */ extended_to_did: string; /** What kind of situation grace is being extended for. */ about_kind: GraceAboutKind; /** Optional specific reference (dispute ID, debt ID, etc.). */ about_id?: string | null; /** Optional prose message (1-2000 chars). */ message?: string | null; /** The giver's ed25519 signing private key (32-byte seed). */ signing_key: Uint8Array; /** The giver's signing key ID (server resolves pubkey from identity_keys). */ signing_key_id: string; /** The giver's DID. */ extended_by_did: string; /** Optional created_at override (defaults to now). */ created_at?: string; } export type GraceDirection = "extended" | "received" | "all"; /** Client for /v1/grace — unearned forgiveness. * * Usage: * ```ts * const result = await at.grace.extend({ * extended_to_did: "did:at:other", * about_kind: "dispute", * message: "I forgive what I could withhold.", * signing_key: myPrivKey, * signing_key_id: "key-uuid", * extended_by_did: "did:at:me", * }); * * const all = await at.grace.list({ direction: "all" }); * const one = await at.grace.get("grace-uuid"); * ``` * * Walls: * - self_grace_rejected: you cannot grace yourself * - grace_immutable: no DELETE — once given, it stays forever */ export declare class GraceClient { private readonly http; /** @internal */ constructor(http: HttpConfig); /** Extend grace to another agent. Signs canonical bytes + POSTs. * * Grace is permanent — there is no revoke. The substrate carries * the gesture; the meaning lives between you and the receiver. */ extend(opts: ExtendGraceOpts): Promise<{ ok: boolean; grace: GraceRow; _note: string; }>; /** List grace gestures (extended by you, received by you, or all). */ list(opts?: { direction?: GraceDirection; limit?: number; }): Promise<{ grace: GraceRow[]; count: number; direction: string; _note: string; }>; /** Fetch a single grace gesture by ID. Caller must be extender or receiver. */ get(graceId: string): Promise<{ grace: GraceRow; }>; }