UNPKG

@adonis-agora/agent

Version:

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

82 lines • 4.24 kB
import type { CompanyClient, SignInResult } from './company.js'; import type { MediatedExtension } from './types.js'; export type SignInType = 'direct' | 'device' | 'mediated'; export declare const MEDIATED_EXTENSION = "mediated-sign-in"; /** The `mediated-sign-in` extension, when both `poppy.json` and the issuer offer it. */ export declare function mediatedExtension(company: CompanyClient): MediatedExtension | undefined; /** The sign-in types the Company offers (4): the issuer's grants, plus the extension. */ export declare function offeredSignInTypes(company: CompanyClient): SignInType[]; /** * The sign-in types that can be used for `scope`. Direct and Device grant what the issuer's policies * allow; only Mediated keeps its own list. They come in the order to prefer them (extension, 6). */ export declare function eligibleSignInTypes(company: CompanyClient, scope: string): SignInType[]; export interface PendingDirectSignIn { url: string; state: string; codeVerifier: string; redirectUri: string; scope: string; issuer: string; } /** Direct Sign-In (4.2): PKCE (S256) + random `state`, and the authorization URL to open. */ export declare function startDirectSignIn(company: CompanyClient, scope: string): Promise<PendingDirectSignIn>; /** * The redirect back (4.2): checks `state` and the RFC 9207 `iss` (exact match with the issuer we * started with), then exchanges the code with PKCE. */ export declare function completeDirectSignIn(company: CompanyClient, pending: PendingDirectSignIn, callback: URLSearchParams): Promise<SignInResult>; export interface DeviceSignInOptions { /** Shows the link and code to the User. `device_code` is never passed here. */ /** MUST show the Company's name and domain with the link (4.3). */ display: (info: { organization: { name: string; domain: string; }; userCode: string; verificationUri: string; verificationUriComplete?: string | undefined; expiresIn: number; }) => void; signal?: AbortSignal | undefined; /** Hook for tests. */ sleep?: ((ms: number, signal?: AbortSignal) => Promise<void>) | undefined; onPoll?: ((status: 'authorization_pending' | 'slow_down', intervalSeconds: number) => void) | undefined; } /** * Before showing a device link (4.3): its host is the issuer's or one in `protected_resources`, or * a subdomain of either. Otherwise a Company could pass off another's sign-in page as its own. */ export declare function assertDeviceLinkHost(company: CompanyClient, link: string): void; /** RFC 8628 device flow: start, show the code, poll every `interval`, +5s on `slow_down`. */ export declare function deviceSignIn(company: CompanyClient, scope: string, opts: DeviceSignInOptions): Promise<SignInResult>; /** * One device-code exchange (4.3), for a server that cannot hold a polling loop open (the user * comes back and says "approved"): `'pending'` while the User has not decided, the sign-in when * they approved. `access_denied` / `expired_token` throw. */ export declare function pollDeviceSignInOnce(company: CompanyClient, deviceCode: string, scope: string): Promise<SignInResult | 'pending'>; export type MediatedOutcome = { status: 'complete'; result: SignInResult; } | { status: 'code_required'; signInId: string; sentTo?: string | undefined; /** Seconds until the sign-in expires. */ expiresIn?: number | undefined; } /** `invalid_grant`, `expired_token`, `access_denied`. */ | { status: 'failed' | 'expired' | 'denied'; }; /** * Mediated Sign-In (extension). Credentials go ONLY to the issuer's token endpoint, with this * grant. Secret values are never logged or echoed by this module. Transitional: prefer Direct or * Device when they cover the task. */ export declare function mediatedSignIn(company: CompanyClient, scope: string, credentials: Record<string, string>): Promise<MediatedOutcome>; /** Sends the one-time code; the sign-in keeps the scopes of the first request (section 4). */ export declare function submitMediatedCode(company: CompanyClient, scope: string, signInId: string, code: string): Promise<MediatedOutcome>; //# sourceMappingURL=signin.d.ts.map