UNPKG

ai-auth

Version:

Complete Auth-Agent SDK - Agent authentication for AI developers + OAuth client integration for website developers

117 lines 3.8 kB
/** * Auth-Agent SDK for AI agents using OAuth 2.1 with PKCE * Server-side TypeScript SDK */ import type { SDKConfig, TokenResponse, UserInfo, AgentAuthRequest, AgentAuthResponse, AgentProfile, EventData, ChallengeResponse, VerificationConfirmRequest, IntrospectionResponse, AuthorizationUrlOptions } from './types'; export declare class AgentSDK { private agentId; private agentSecret; private modelName; private readonly serverUrl; private timeout; private customFetch; private tokenManager; private codeVerifier; private state; constructor(config: SDKConfig); /** * Generate OAuth 2.1 authorization URL with PKCE */ getAuthorizationUrl(options: AuthorizationUrlOptions): Promise<{ url: string; codeVerifier: string; state: string; }>; /** * Exchange authorization code for access token (OAuth 2.1 with PKCE) */ exchangeCode(code: string, state: string, redirectUri: string): Promise<TokenResponse>; /** * Refresh access token using refresh token */ refreshAccessToken(): Promise<TokenResponse>; /** * Headless authentication for automated agents (Resource Owner Password flow) * Note: Less secure than Authorization Code flow. Use only for trusted agents. */ authenticateHeadless(username: string, password: string, scope?: string): Promise<TokenResponse>; /** * Make authenticated request using OAuth access token */ private makeRequest; /** * Authenticate agent and create auth session * Note: Agents must be registered at https://console.auth-agent.com */ authenticateAgent(request: Omit<AgentAuthRequest, 'agent_id' | 'agent_secret' | 'model_name'>): Promise<AgentAuthResponse>; /** * Get agent profile information */ getAgentProfile(): Promise<AgentProfile>; /** * Update agent profile */ updateAgentProfile(updates: Partial<Pick<AgentProfile, 'owner_name' | 'model_name'>>): Promise<AgentProfile>; /** * Get user information from OIDC userinfo endpoint */ getUserInfo(): Promise<UserInfo>; /** * Send event data to Auth-Agent */ sendEvent(eventData: EventData): Promise<any>; /** * Send a verified click event */ sendVerifiedClick(selector: string, site?: string, evidence?: string): Promise<any>; /** * Send a post-run event with result */ sendPostRun(selector: string, site: string, result: string): Promise<any>; /** * Request a verification challenge */ requestChallenge(): Promise<ChallengeResponse>; /** * Confirm verification with challenge response */ confirmVerification(request: VerificationConfirmRequest): Promise<any>; /** * Get current verification status */ getVerifyStatus(): Promise<any>; /** * Poll for challenge and authenticate using verify_ctx_id * For challenge-based authentication flow */ pollAndAuthenticate(verifyCtxId: string, options?: { timeout?: number; interval?: number; }): Promise<boolean>; /** * Revoke access token or refresh token */ revokeToken(token?: string): Promise<any>; /** * Logout agent (revoke tokens and clear session) */ logout(): Promise<void>; /** * Introspect token to check validity and claims */ introspectToken(token?: string): Promise<IntrospectionResponse>; /** * Check if user is authenticated */ isAuthenticated(): boolean; /** * Get current access token */ getAccessToken(): string | null; /** * Get current refresh token */ getRefreshToken(): string | null; private createError; } //# sourceMappingURL=agent-sdk.d.ts.map