import * as jose from "jose"; import "../authorization/check-action.js"; import type { A2AConfig, AgentSkill } from "./types.js"; /** * Result of verifying an inbound A2A JWT. `email` is present for deployment * user assertions or an explicitly opted-in org-member delegation. `orgDomain` * and `orgId` are bound to local organization metadata when present. */ export interface A2ATokenPayload { email: string | null; orgDomain: string | null; orgId?: string; identityAssurance?: "user" | "organization" | "org-member"; claims?: jose.JWTPayload; } export declare class A2AIdentityVerificationUnavailableError extends Error { readonly cause: unknown; constructor(cause: unknown); } export declare function isA2AIdentityVerificationUnavailableError(error: unknown): error is A2AIdentityVerificationUnavailableError; /** * Verify an inbound A2A bearer token (HS256) exactly as the * `/_agent-native/a2a` endpoint does: it peeks at the unverified `org_domain` * claim to locate an org credential after trying the global credential, then * verifies the JWT — checking * `aud`/`iss` when the token carries them and `exp` always. Returns the * caller's email (`sub`) and org domain on success, or an organization-only * identity with no email when an org secret verifies. Invalid tokens return * `{ email: null, orgDomain: null }`. If the organization credential cannot * be read, throws * `A2AIdentityVerificationUnavailableError` so callers cannot treat an * unreadable authorization lookup as an unauthenticated fallback. * * Exported so workspaces can accept A2A callers on the HTTP action route with * the same routine — including organization-only credentials — instead of * reimplementing a partial verifier. Pass the H3 `event` to enable org-domain → * org-secret lookup and audience derivation; it is optional. A custom mounted * JSON-RPC route also passes its prefix so endpoint-bound tokens verify against * the same audience the client derived from the advertised URL. */ export declare function verifyA2AToken(token: string, event?: any, audienceOptions?: { routePrefix?: string; /** Trusted audience(s) supplied by the mounted route that is verifying the token. */ expectedAudience?: string | string[]; allowBaseAudience?: boolean; includeClaims?: boolean; /** Only use the deployment-wide secret, never an org-domain secret. */ globalSecretOnly?: boolean; /** Only use this explicitly configured credential; never fall back. */ verificationSecret?: string; /** Dedicated verifier for the typed Anthropic continuation credential. */ allowAnthropicManagedContinuation?: boolean; requireAudience?: boolean; }): Promise; export type A2ATokenFailureCause = "malformed" | "secret-missing" | "audience-unresolvable" | "audience" | "issuer" | "expired" | "signature" | "algorithm" | "invalid-claims" | "mcp-credential" | "missing-subject" | "org-binding" | "org-lookup-failed" | "undetermined"; /** * Names why a token that `verifyA2AToken` resolved no identity for was * refused. `verifyA2AToken` collapses a wrong audience, a wrong secret and an * unbound organization into one empty identity; this re-checks the same inputs, * against the deploy secret and then the organization's, to tell them apart. * Diagnostic only: it never grants anything, and its answer must not be used as * an authorization result. */ export declare function diagnoseA2ATokenFailure(token: string, event?: any): Promise; export declare function mountA2A(nitroApp: any, config: A2AConfig, routePrefix?: string): void; export declare function filterPublicAgentCardSkills(config: A2AConfig): AgentSkill[];