TypeScript Types
Complete type reference for the Auth-Agent JavaScript/TypeScript SDK.Configuration Types
SDKConfig
Configuration object for initializing the AgentSDK.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
OAuth & Token Types
TokenResponse
OAuth 2.1 token response from the server.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
TokenManager
Interface for token manager state.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.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)
PKCEPair
PKCE code verifier and challenge pair.string
required
Random base64url-encoded string (stored for token exchange)
string
required
SHA-256 hash of code verifier (sent to authorization server)
User & Agent Types
UserInfo
OpenID Connect user information from/oauth2/userinfo endpoint.
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
AgentProfile
Agent profile information.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
Registration & Authentication Types
AgentRegistrationRequest
Request payload for registering a new agent.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
AgentRegistrationResponse
Response from agent registration.boolean
required
Whether registration was successful
string
required
The registered agent ID
string
required
Success or error message
AgentAuthRequest
Request payload for agent authentication (legacy challenge flow).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.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.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
ChallengeResponse
Response from requesting a verification challenge.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
VerificationConfirmRequest
Request payload for confirming verification.string
required
Challenge string from ChallengeResponse
number
required
Challenge expiration timestamp
string
required
Challenge signature
string
required
Verification context ID
IntrospectionResponse
Token introspection response.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
Error Types
AuthError
Extended error type for authentication errors.string
required
Error code (e.g., ‘token_expired’, ‘state_mismatch’)
string
Human-readable error description
number
HTTP status code (if applicable)
state_mismatch- State parameter mismatch (CSRF)pkce_missing- Code verifier not foundtoken_expired- Access token expiredforbidden- Insufficient permissionsno_refresh_token- Refresh token not providedrefresh_failed- Token refresh failedrevoke_failed- Token revocation failedintrospection_failed- Token introspection failedno_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