import type { PromptDefinition } from '../types/prompts.js'; /** A JSON Web Key, as Web Crypto exports one. */ export interface ContextJsonWebKey { /** The key type: `OKP` for Ed25519. */ kty?: string; /** The curve: `Ed25519`. */ crv?: string; /** The public key, in base64url. */ x?: string; /** The private key, in base64url, on a private key only. */ d?: string; /** Anything else the exporter wrote. */ [field: string]: unknown; } /** A Web Crypto key, as `crypto.subtle` returns one. Any runtime's `CryptoKey` is one. */ export interface ContextCryptoKey { /** Its algorithm. */ readonly algorithm: unknown; /** What it may do. */ readonly usages: readonly string[]; } /** One signature on a bundle version. Stored with it, and carried by its export. */ export interface ContextSignature { /** The id of the key that signed, which a keyring looks up. */ keyId: string; /** Always `Ed25519`. */ algorithm: 'Ed25519'; /** * What was signed: `sha256:` and the full SHA-256, in hex, of the bundle's content and the content * of every prompt it pins. A bundle's version is only the first 12 hex digits, enough to name a * version but not to stand behind a signature. */ digest: string; /** The signature over the digest, in base64url. */ signature: string; /** ISO-8601 time it was signed. */ signedAt: string; } /** Signs bundle digests with a private key, under a key id. */ export interface ContextSigner { /** The key's id, recorded on each signature so a keyring finds the public key. */ keyId: string; /** Signs bytes. */ sign(data: Uint8Array): Promise | Uint8Array; } /** Verifies signatures by key id. A signature by a key the keyring does not hold never verifies. */ export interface ContextKeyring { /** Whether `signature` is `keyId`'s signature over `data`. */ verify(keyId: string, data: Uint8Array, signature: Uint8Array): Promise | boolean; } /** A new signing key, with both halves as JSON Web Keys to keep in a secret store. */ export interface ContextSigningKey { /** The key's id. */ keyId: string; /** Signs with the new key. */ signer: ContextSigner; /** The public half, for every keyring that should trust it. */ publicKey: ContextJsonWebKey; /** The private half. Keep it where the signer runs, and nowhere else. */ privateKey: ContextJsonWebKey; } /** * Creates an Ed25519 signing key through Web Crypto, so on any runtime. The key id defaults to the * first 16 hex digits of the public key's SHA-256, which is stable for the key and names nothing * else. */ export declare function generateContextKey(keyId?: string): Promise; /** A signer from an Ed25519 private key, as a JSON Web Key or a Web Crypto key. */ export declare function ed25519Signer(keyId: string, privateKey: ContextJsonWebKey | ContextCryptoKey): Promise; /** A keyring of trusted Ed25519 public keys, by key id. */ export declare function ed25519Keyring(keys: Record): Promise; /** What a bundle signature covers: the bundle's versioned content, and its pinned prompts' content. */ export interface ContextSignedContent { /** The bundle's name and the content its version covers. */ bundle: { name: string; description?: string; prompts?: Record; instructions?: Record; tools?: unknown; skills?: unknown; config?: Record; }; /** Each pinned prompt's content, by role: what its own version covers. */ prompts: Record>; } /** The digest a signature covers, as `sha256:` and 64 hex digits. */ export declare function contextDigest(content: ContextSignedContent): Promise; /** Signs a digest. */ export declare function signDigest(signer: ContextSigner, digest: string, at: Date): Promise; /** The first signature that is a trusted key's signature over exactly this digest, if any. */ export declare function verifiedBy(keyring: ContextKeyring, digest: string, signatures?: readonly ContextSignature[]): Promise;