Skip to main content

API reference

The public surface of

@thunderid/node, as documented in its reference pages.

exportThunderIDNodeClient

`ThunderIDNodeClient` is an abstract base class that extends `ThunderIDJavaScriptClient` with Node.js-specific configuration. Use this class as the foundation when building a new framework-specific authentication client for a Node.js runtime. Examples include adapters for other Node.js server frameworks.

Example
import { ThunderIDNodeClient, ThunderIDNodeConfig } from '@thunderid/node'

interface MyFrameworkConfig extends ThunderIDNodeConfig {
  customOption?: string
}

class MyFrameworkClient extends ThunderIDNodeClient<MyFrameworkConfig> {
  // Add framework-specific methods or override inherited ones here
}

export default MyFrameworkClient
exportThunderIDNodeConfig

`ThunderIDNodeConfig` is the configuration type for the ThunderID Node.js SDK. The type extends the base `Config` from `@thunderid/javascript` and adds a Node.js-specific option for controlling session cookie lifetime.

Example
import { ThunderIDNodeConfig } from '@thunderid/node'

const config: ThunderIDNodeConfig = {
  clientId: '<your-client-id>',
  serverOrigin: 'https://localhost:8090',
  afterSignInUrl: 'http://localhost:3000/callback',
  afterSignOutUrl: 'http://localhost:3000',
  sessionCookieExpiryTime: 28800, // 8 hours
}
exportCookieConfig

`CookieConfig` is a constants class that exposes the default values used for session cookie configuration in the ThunderID Node.js SDK. Use these constants when setting cookies for session management or when passing options to `getSessionCookieOptions`.

Example
import { CookieConfig } from '@thunderid/node'

// Use the default session cookie name
res.cookie(CookieConfig.SESSION_COOKIE_NAME, sessionId, {
  httpOnly: CookieConfig.DEFAULT_HTTP_ONLY,
  maxAge: CookieConfig.DEFAULT_MAX_AGE * 1000, // convert to milliseconds
  sameSite: CookieConfig.DEFAULT_SAME_SITE,
  secure: CookieConfig.DEFAULT_SECURE,
})
exportCookieOptions

`CookieOptions` defines the shape of cookie configuration options used in the ThunderID Node.js SDK. Pass a `CookieOptions` object to `getSessionCookieOptions` to override the default cookie settings.

Example
interface CookieOptions {
  httpOnly?: boolean
  maxAge?: number
  sameSite?: boolean | 'lax' | 'strict' | 'none'
  secure?: boolean
}
exportgenerateSessionId()

`generateSessionId` generates a unique session identifier string. Use this utility to create a new session ID when a user signs in and store the value in a cookie or server-side session store.

Example
import { generateSessionId, CookieConfig, getSessionCookieOptions } from '@thunderid/node'

app.get('/sign-in', (req, res) => {
  const sessionId = generateSessionId()

  res.cookie(
    CookieConfig.SESSION_COOKIE_NAME,
    sessionId,
    getSessionCookieOptions({ maxAge: 3600 }),
  )

  auth.signIn(
    (authUrl) => res.redirect(authUrl),
    sessionId,
  )
})
exportgetSessionCookieOptions()

`getSessionCookieOptions` merges the provided partial `CookieOptions` with the default values from `CookieConfig`. Any property you omit falls back to its default.

Parameters
optionsrequired
Partial

Cookie options to apply. Unspecified properties use the defaults from `CookieConfig`.

Example
import { getSessionCookieOptions } from '@thunderid/node'

// Override only maxAge; all other properties use defaults
const options = getSessionCookieOptions({ maxAge: 86400 }) // 24 hours
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.