CrossmintAuth
TheCrossmintAuthServer class (exported as CrossmintAuth) provides server-side authentication functionality for managing user sessions, handling token refresh, and cookie management.
Installation
Initialization
Constructor options
Crossmint SDK instance initialized with your API key.
Configuration options for the authentication instance.
Static methods
from()
Creates a newCrossmintAuth instance.
Crossmint SDK instance.
Configuration options.
CrossmintAuthServer
Instance methods
See Session Methods for detailed documentation ofgetSession(), logout(), and handleCustomRefresh().
getJwksUri()
Returns the JWKS URI for JWT verification.string - The JWKS URI endpoint.
verifyCrossmintJwt()
Verifies a Crossmint JWT token.The JWT token to verify.
Optional JWKS for verification. If not provided, fetches from the JWKS URI.
Promise<JWTPayload> - The decoded and verified JWT payload.
storeAuthMaterial()
Stores authentication material in cookies.The HTTP response object (Node.js
ServerResponse or Web API Response).Authentication material containing JWT and refresh token.
getUser()
Retrieves user information by external user ID.The external user ID to look up.
Promise<SDKExternalUser> - The user object.
Type definitions
GenericRequest
Accepts either Node.jsIncomingMessage or Web API Request objects.
GenericResponse
Accepts either Node.jsServerResponse or Web API Response objects.
AuthMaterial
AuthMaterialBasic
AuthSession
Error handling
All methods may throwCrossmintAuthenticationError when authentication fails.