Skip to main content

ExpressClientConfig

ExpressClientConfig is the main configuration type for @thunderid/express.

Type Relationships

The Express SDK exports these related types:

TypeDefinition
StrictExpressClientConfigExpress-specific callback fields
ExpressClientConfigThunderIDNodeConfig & StrictExpressClientConfig
ThunderIDExpressConfigAlias of ExpressClientConfig

ExpressClientConfig extends ThunderIDNodeConfig, which itself extends the base JavaScript SDK configuration. This page focuses on the fields that directly affect Express integration.

Usage

index.js
const {thunderID} = require('@thunderid/express');

app.use(
thunderID({
baseUrl: 'https://localhost:8090',
clientId: '<your-client-id>',
clientSecret: '<your-client-secret>',
afterSignInUrl: 'http://localhost:3000/login',
afterSignOutUrl: 'http://localhost:3000/logout',
sessionCookie: {
expiryTime: 28800,
httpOnly: true,
sameSite: 'lax',
secure: false,
},
}),
);

Core Fields

FieldTypeRequiredDescription
baseUrlstringBase URL of the ThunderID instance
clientIdstringClient ID for the application
clientSecretstringClient secret for confidential clients

Flow Fields

FieldTypeRequiredDefaultDescription
afterSignInUrlstring${origin}/loginCallback URL used after sign-in when not explicitly set
afterSignOutUrlstring${origin}/logoutCallback URL used after sign-out when not explicitly set
mode'redirect' | 'embedded''redirect'Authentication interaction mode
signInOptionsRecord<string, any>NoneAdditional authorize request parameters
signOutOptionsRecord<string, unknown>NoneAdditional sign-out request parameters
applicationIdstringNoneApplication identifier used by some flows such as embedded sign-in

Express Callbacks

These fields come from StrictExpressClientConfig.

FieldTypeDescription
onSignIn(res: express.Response, tokenResponse: TokenResponse) => voidCalled after a successful sign-in callback exchange
onSignOut(res: express.Response) => voidCalled after a successful sign-out completion request
onError(res: express.Response, exception: ThunderIDRuntimeError) => voidCalled when authentication-related work fails
onUnauthenticated(res: express.Response) => voidIntended callback for unauthenticated access handling
note

protect() accepts its own onUnauthenticated callback argument. The current protect() implementation does not read config.onUnauthenticated.

The sessionCookie field is inherited from ThunderIDNodeConfig.

FieldTypeDefaultDescription
expiryTimenumber86400Session lifetime in seconds
httpOnlybooleantrueMakes the cookie inaccessible to JavaScript
sameSite'lax' | 'strict' | 'none''lax'SameSite policy for the session cookie
securebooleanfalseRequires HTTPS when true

Notes

  • afterSignInUrl and afterSignOutUrl are optional because the Express middleware can derive defaults from the first incoming request origin
  • Use mode: 'embedded' only when you plan to mount handleFlow()
  • Other inherited ThunderIDNodeConfig and base JavaScript SDK options remain available, but they are outside the scope of this Express-first reference
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.