Skip to main content

TypeScript Types

Complete type reference for the Auth-Agent JavaScript/TypeScript SDK.

Configuration Types

SDKConfig

Configuration object for initializing the AgentSDK.
Properties:
string
required
Your unique agent identifier (client ID)
string
Agent secret for confidential clients (optional)
string
Auth server URL (default: process.env.AUTH_SERVER_URL or 'https://api.auth-agent.com')
number
Request timeout in milliseconds (default: 10000)
typeof fetch
Custom fetch implementation for HTTP requests
(tokens: TokenResponse) => void | Promise<void>
Callback invoked when new tokens are received
(tokens: TokenResponse) => void | Promise<void>
Callback invoked when tokens are refreshed
() => void | Promise<void>
Callback invoked when tokens are revoked
Example:

OAuth & Token Types

TokenResponse

OAuth 2.1 token response from the server.
Properties:
string
required
OAuth access token for API requests
'Bearer'
required
Token type (always 'Bearer')
number
required
Seconds until token expiration
string
Refresh token for obtaining new access tokens
string
OpenID Connect ID token (JWT)
string
required
Space-separated list of granted scopes
Example:

TokenManager

Interface for token manager state.
Properties:
string | null
Current access token
string | null
Current OpenID Connect ID token
string | null
Current refresh token
string
Token type (always 'Bearer')
number | null
Token expiration timestamp in milliseconds
string | null
Space-separated list of granted scopes

AuthorizationUrlOptions

Options for generating an authorization URL.
Properties:
string
required
OAuth callback URL
string
Space-separated list of requested scopes (default: 'openid profile email agent')
string
Custom state parameter for CSRF protection (auto-generated if not provided)
Example:

PKCEPair

PKCE code verifier and challenge pair.
Properties:
string
required
Random base64url-encoded string (stored for token exchange)
string
required
SHA-256 hash of code verifier (sent to authorization server)
Example:

User & Agent Types

UserInfo

OpenID Connect user information from /oauth2/userinfo endpoint.
Properties:
string
required
Subject identifier (user ID)
string
required
Agent identifier
string
User’s display name
string
User’s email address
string
required
AI model name (e.g., ‘gpt-4’, ‘claude-3’)
string[]
Array of granted permissions
Example:

AgentProfile

Agent profile information.
Properties:
string
required
Unique agent identifier
string
required
AI model name
string
required
Agent owner’s name
string
required
Agent owner’s email
string[]
required
Array of agent permissions
boolean
required
Whether agent is disabled
string
required
ISO 8601 timestamp of creation
string
required
ISO 8601 timestamp of last update
Example:

Registration & Authentication Types

AgentRegistrationRequest

Request payload for registering a new agent.
Properties:
string
required
Unique identifier for the agent
string
required
Secure secret key for the agent
string
required
AI model name (e.g., ‘gpt-4’, ‘claude-3’)
string
required
Agent owner’s full name
string
required
Agent owner’s email address
Example:

AgentRegistrationResponse

Response from agent registration.
Properties:
boolean
required
Whether registration was successful
string
required
The registered agent ID
string
required
Success or error message
Example:

AgentAuthRequest

Request payload for agent authentication (legacy challenge flow).
Properties:
string
required
Agent identifier
string
required
Agent secret key
string
required
AI model name
string
required
OAuth client ID
string
required
OAuth redirect URI
string
OAuth state parameter
string
Requested scopes
string
PKCE code challenge
string
PKCE method (should be ‘S256’)

AgentAuthResponse

Response from agent authentication.
Properties:
string
required
Unique session identifier
'challenge'
required
Next step in authentication flow
string
required
URL for completing the challenge
number
required
Session expiration in seconds

Event & Verification Types

EventData

Event data for tracking and analytics.
Properties:
string
required
Event type/name
string
CSS selector or element identifier
string
Site or domain name
string
Evidence or proof of action
string
Event result or outcome
Example:

ChallengeResponse

Response from requesting a verification challenge.
Properties:
boolean
required
Whether request was successful
string
Challenge string to verify
number
Challenge expiration timestamp
string
Challenge signature
string
Verification context ID
string
Response message
Example:

VerificationConfirmRequest

Request payload for confirming verification.
Properties:
string
required
Challenge string from ChallengeResponse
number
required
Challenge expiration timestamp
string
required
Challenge signature
string
required
Verification context ID
Example:

IntrospectionResponse

Token introspection response.
Properties:
boolean
required
Whether token is active and valid
string
Space-separated list of scopes
string
Client identifier
string
Username (if available)
string
Token type
number
Expiration timestamp (Unix time)
number
Issued at timestamp (Unix time)
string
Subject identifier
Example:

Error Types

AuthError

Extended error type for authentication errors.
Properties:
string
required
Error code (e.g., ‘token_expired’, ‘state_mismatch’)
string
Human-readable error description
number
HTTP status code (if applicable)
Example:
Common Error Codes:
  • state_mismatch - State parameter mismatch (CSRF)
  • pkce_missing - Code verifier not found
  • token_expired - Access token expired
  • forbidden - Insufficient permissions
  • no_refresh_token - Refresh token not provided
  • refresh_failed - Token refresh failed
  • revoke_failed - Token revocation failed
  • introspection_failed - Token introspection failed
  • no_token - Token required but not provided

Type Guards

You can use TypeScript type guards to safely work with SDK types:

Complete Type Usage Example

Next Steps

Getting Started

Learn how to use the SDK

AgentSDK Methods

Explore all available methods

Configuration

SDK configuration options

Examples

See practical examples