UNPKG

@adonis-agora/agent

Version:

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

47 lines • 2.63 kB
/** * The remote JWT access-token check shared by the dev hub's `jwtAuth` and the product endpoints' * `oidcAuth`: signature against the issuer's JWKS (discovered from its metadata, keys cached), `iss`, * `aud`, `exp`/`nbf`. Needs nothing of the authorization server in this process. */ /** An absolute http(s) URL, or a config error naming the option. */ export declare function absoluteUrl(value: string, option: string): URL; /** Same issuer up to a trailing slash. */ export declare const sameIssuer: (a: string, b: string) => boolean; /** The well-known metadata documents of an issuer, in the order they are tried. */ export declare function issuerMetadataUrls(issuer: string): string[]; /** Fetch the issuer's metadata (OIDC discovery, then RFC 8414) and return its `jwks_uri`. */ export declare function discoverJwksUri(issuer: string, fetcher?: typeof fetch): Promise<string>; export interface JwtVerifierOptions { issuer: string; jwksUri?: string; algorithms?: string[]; /** Seconds. Default `30`. */ clockTolerance?: number; } /** * Verify a token for `audiences`: its claims; `null` when it is not a JWT or names another issuer * (not this verifier's token). Throws {@link McpAuthError} for a token it refuses (signature, * audience, expiry…), a plain `Error` when the JWKS cannot be fetched (an outage). */ export type JwtVerifier = (token: string, audiences: string[]) => Promise<Record<string, unknown> | null>; export declare function createJwtVerifier(options: JwtVerifierOptions): JwtVerifier; /** The algorithms {@link createJwtVerifier} accepts unless a caller narrows the list. */ export declare const DEFAULT_JWT_ALGORITHMS: string[]; /** * Whether jose refused the token itself (claims, signature, format, no matching key) — as opposed to * a JWKS it could not fetch, which is an outage and surfaces as a `503`. */ export declare function isTokenFailure(jose: typeof import('jose'), error: unknown): boolean; /** Scopes granted to a token (`scope` string or `scp` array). */ export declare function scopesFrom(claims: Record<string, unknown>): string[]; /** Roles from a claim, when it is a string array (or a space-separated string). */ export declare function rolesFrom(value: unknown): string[] | undefined; /** * The real actor of an impersonation token: its RFC 8693 `act` claim (`{ sub, email? }`), or * `undefined` when the token acts for its own subject (no `act`, or `act.sub` = `sub`). */ export declare function actorFromClaims(claims: Record<string, unknown>): { sub: string; email?: string; } | undefined; //# sourceMappingURL=jwt-verifier.d.ts.map