UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

61 lines • 3.02 kB
import type { Keyring, SecretLike } from './keyring.js'; import { type SealOptions } from './seal.js'; /** An OKP JSON Web Key (RFC 8037): X25519 for encryption, Ed25519 for signatures. */ export interface OkpJwk { kty: 'OKP'; crv: 'X25519' | 'Ed25519'; x: string; /** Private part: present on a private key only. */ d?: string; kid: string; use?: 'enc' | 'sig'; alg?: 'EdDSA' | 'ECDH-ES'; } export interface Jwks { keys: OkpJwk[]; } /** One key, several (newest first), or a JWKS: lookup is by `kid`. */ export type JwkSource = OkpJwk | OkpJwk[] | Jwks; export declare const SEALED_TO_PREFIX = "agora:pk1:"; export declare const SIGNATURE_PREFIX = "agora:sig1:"; /** RFC 7638 thumbprint of an OKP key: a stable `kid`. */ export declare function jwkThumbprint(jwk: Pick<OkpJwk, 'crv' | 'x'>): string; /** A fresh key pair as JWKs. `kid` defaults to the thumbprint. */ export declare function generateKeyPair(type: 'x25519' | 'ed25519', options?: { kid?: string; }): { publicKey: OkpJwk; privateKey: OkpJwk; }; /** * The same key pair every time from `secret` (an app key): HKDF-SHA256(secret, salt = `purpose`) * → the 32-byte private key. No private key to store: every instance derives it. Changing the * secret changes the key (and its thumbprint `kid`). */ export declare function deriveKeyPair(type: 'x25519' | 'ed25519', secret: SecretLike, purpose: string, options?: { kid?: string; }): { publicKey: OkpJwk; privateKey: OkpJwk; }; /** The public half of a JWK (drops `d`). */ export declare function publicJwk(jwk: OkpJwk): OkpJwk; /** A JWKS of the public halves, for discovery. */ export declare function toJwks(keys: OkpJwk[]): Jwks; /** * Encrypts `value` so only the holder of the X25519 private key opens it: * `agora:pk1:<kid>:<ephemeral x>:<iv>:<tag>:<ciphertext>`. */ export declare function sealTo(recipient: OkpJwk, value: string, options?: SealOptions): string; /** The `kid` a {@link sealTo} value was sealed for, or `undefined` when it isn't one. */ export declare function sealedToKid(sealed: string): string | undefined; /** Opens a {@link sealTo} value with the private key whose `kid` it names. */ export declare function openWith(keys: JwkSource, sealed: string, options?: SealOptions): string; /** Ed25519 detached signature over `payload`: `agora:sig1:<kid>:<signature>`. */ export declare function sign(privateKey: OkpJwk, payload: string | Uint8Array): string; /** Checks a {@link sign} signature against the Ed25519 public key its `kid` names. Never throws. */ export declare function verify(keys: JwkSource, payload: string | Uint8Array, signature: string): boolean; /** A private JWK sealed at rest with the symmetric keyring (never stored plain). */ export declare function sealPrivateKey(keyring: Keyring, privateKey: OkpJwk, options?: SealOptions): Promise<string>; export declare function openPrivateKey(keyring: Keyring, sealed: string, options?: SealOptions): Promise<OkpJwk>; //# sourceMappingURL=asymmetric.d.ts.map