UNPKG

@adonis-agora/agent

Version:

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

72 lines • 3.44 kB
import type { DpopKey } from './dpop.js'; import { type PoppyHttp } from './http.js'; import type { AgentIdentity } from './identity.js'; import type { AuthServerMetadata, DeviceAuthorizationResponse, TokenResponse } from './types.js'; export declare const GRANT_DEVICE_CODE = "urn:ietf:params:oauth:grant-type:device_code"; export declare const GRANT_MEDIATED_SIGN_IN = "https://personalagentprotocol.org/grant/mediated-sign-in"; export declare const CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"; export interface NarrowingParams { /** Ask for fewer scopes than the refresh token has (4.4). */ scope?: string | undefined; /** RFC 8707 resource indicator (4.5). */ resource?: string | undefined; } /** * OAuth calls against the Company's authorization server (section 4): every request carries a * `private_key_jwt` client assertion addressed to the issuer (4.1). Token requests carry a DPoP * proof when one is given, and the response's `token_type` says what the Company did with it (4.5). */ export declare class TokenClient { private readonly identity; readonly metadata: AuthServerMetadata; private readonly http; constructor(identity: AgentIdentity, metadata: AuthServerMetadata, http: PoppyHttp); private clientAuth; /** POSTs a form; the builder runs per attempt so retries get fresh assertions. */ private post; private toError; /** * Any token-endpoint grant (4.7). `requested` is what `scope` means when the response leaves it * out: the Company granted exactly the scopes requested (RFC 6749 section 5.1). */ token(params: () => Promise<Record<string, string | undefined>>, requested: string | undefined, dpop?: DpopKey | undefined): Promise<TokenResponse>; /** Refresh (4.4). A token response may leave `refresh_token` out: keep using the one you have. */ refresh(input: { refreshToken: string; /** The refresh token's scopes: what `scope` means when the response omits it. */ grantedScope: string; dpop?: DpopKey | undefined; } & NarrowingParams): Promise<TokenResponse>; /** Direct Sign-In code exchange (4.2). */ authorizationCode(input: { code: string; redirectUri: string; codeVerifier: string; scope: string; dpop?: DpopKey | undefined; }): Promise<TokenResponse>; /** Device Sign-In step 1 (4.3). */ deviceAuthorization(scope: string): Promise<DeviceAuthorizationResponse>; /** Device Sign-In polling (4.3). Throws `authorization_pending` / `slow_down` etc. */ deviceToken(input: { deviceCode: string; scope: string; dpop?: DpopKey | undefined; }): Promise<TokenResponse>; /** The Mediated Sign-In grant (extension, section 3): credentials as form parameters. */ mediated(input: { scope: string; credentials: Record<string, string>; dpop?: DpopKey | undefined; }): Promise<TokenResponse>; /** The same grant again with the one-time code, without credentials or `scope` (section 4). */ mediatedCode(input: { signInId: string; code: string; scope: string; dpop?: DpopKey | undefined; }): Promise<TokenResponse>; /** RFC 7009 revocation of a refresh token (4.6). */ revoke(token: string, hint?: 'refresh_token' | 'access_token'): Promise<void>; } //# sourceMappingURL=token_client.d.ts.map