Auth Server

Interfaces

Interfaces

AuthStorageAdapter

ApiToken

Properties:

PropertyTypeRequiredDescription
idstringYes
serviceAccountIdstringYes
namestringYes
tokenHashstringYes
prefixstringYes
lastUsedAtstring | undefinedNo
expiresAtstring | undefinedNo
createdAtstringYes
revokedbooleanYes
domainIdstringYes
orgIdstringYes

MailAdapter

SendResult

Properties:

PropertyTypeRequiredDescription
successbooleanYes
messageIdstring | undefinedNo
errorstring | undefinedNo

AuthData

Authentication data attached to request after successful validation. Contains information about the authenticated user or service account.

Properties:

PropertyTypeRequiredDescription
type"jwt" | "api_token"YesThe type of authentication used
userIdstring | undefinedNoUser ID for JWT authentication
serviceAccountIdstring | undefinedNoService account ID for API token authentication
emailstring | undefinedNoUser email for JWT authentication
domainIdstringYesDomain ID the authentication is valid for
orgIdstringYesOrganization ID the authentication is valid for
scopesstring[]YesScopes/permissions granted to this authentication
tokenNamestring | undefinedNoToken name for API token authentication

AuthenticatedRequest

Express Request extended with authentication data. Use this type when you need to access req.authData in route handlers.

Properties:

PropertyTypeRequiredDescription
authDataAuthDataYesAuthentication data populated by requireAuth middleware

AuthRoutesConfig

Configuration for auth routes

Properties:

PropertyTypeRequiredDescription
tokenManagerTokenManagerYesTokenManager instance for JWT creation and verification
storageAuthStorageAdapterYesStorage adapter for users, sessions, and verification tokens
mailServiceMailServiceYesMail service for sending verification emails
defaultDomainIdstringYesDefault domain ID for multi-tenant support

TokenService

Token service interface for generating JWT tokens. This is injected into the OAuth router to decouple token generation from OAuth flow. Supports both sync methods (when tokens are pre-generated) and async methods.

TokenClaims

Claims included in access tokens.

Properties:

PropertyTypeRequiredDescription
userIdstringYes
domainIdstringYes
scopestringYes

RefreshTokenClaims

Claims included in refresh tokens.

Properties:

PropertyTypeRequiredDescription
userIdstringYes
domainIdstringYes

RefreshTokenVerificationResult

Result of verifying a refresh token.

Properties:

PropertyTypeRequiredDescription
validbooleanYes
userIdstring | undefinedNo
domainIdstring | undefinedNo
scopestring | undefinedNo
errorstring | undefinedNo

OAuthRouterConfig

Configuration for OAuth routes.

Properties:

PropertyTypeRequiredDescription
issuerstringYesToken issuer URL
accessTokenTTLnumberYesAccess token TTL in seconds

OAuthMetadata

OAuth Authorization Server Metadata as per RFC 8414. This metadata is used by OAuth clients for automatic discovery.

Properties:

PropertyTypeRequiredDescription
issuerstringYesThe authorization server's issuer identifier (URL)
authorization_endpointstringYesURL of the authorization endpoint
token_endpointstringYesURL of the token endpoint
response_types_supportedstring[]YesSupported response types
grant_types_supportedstring[]YesSupported grant types
code_challenge_methods_supportedstring[]YesSupported PKCE code challenge methods
token_endpoint_auth_methods_supportedstring[]YesSupported token endpoint authentication methods
scopes_supportedstring[]YesSupported OAuth scopes

OAuthCodeData

Data stored for an OAuth authorization code. Includes all information needed to validate and exchange the code.

Properties:

PropertyTypeRequiredDescription
codestringYesThe authorization code value
clientIdstringYesOAuth client ID that requested this code
userIdstringYesUser ID the code was issued for
domainIdstringYesDomain/tenant ID for multi-tenant support
redirectUristringYesRedirect URI that must match during token exchange
codeChallengestringYesPKCE code challenge provided during authorization
codeChallengeMethodCodeChallengeMethodYesPKCE code challenge method (S256 or plain)
scopestringYesOAuth scopes granted with this code
expiresAtnumberYesUnix timestamp (ms) when the code expires

CreateCodeParams

Parameters for creating a new authorization code.

Properties:

PropertyTypeRequiredDescription
clientIdstringYesOAuth client ID
userIdstringYesUser ID the code is being issued for
domainIdstringYesDomain/tenant ID
redirectUristringYesRedirect URI for the callback
codeChallengestringYesPKCE code challenge
codeChallengeMethodCodeChallengeMethodYesPKCE code challenge method
scopestringYesOAuth scopes being requested

ClientValidationResult

Result of validating an OAuth client.

Properties:

PropertyTypeRequiredDescription
validbooleanYesWhether the client is valid
clientIdstringYesClient ID
clientNamestring | undefinedNoHuman-readable client name (if valid)
redirectUrisstring[] | undefinedNoAllowed redirect URI patterns (if valid)

ExchangeCodeResult

Result of exchanging an authorization code for tokens.

Properties:

PropertyTypeRequiredDescription
successbooleanYesWhether the exchange was successful
userIdstring | undefinedNoUser ID (if successful)
domainIdstring | undefinedNoDomain ID (if successful)
scopestring | undefinedNoGranted scopes (if successful)
errorstring | undefinedNoOAuth error code (if failed)
errorDescriptionstring | undefinedNoHuman-readable error description (if failed)

OAuthStorage

Storage interface for OAuth codes. Implementations can use any backend (memory, database, etc.)

Previous
API Reference
Next
Types