Skip to main content

Node.js API reference

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

Every export is fully typed. The signatures and props below come from the package's own reference documentation, so what is listed here is what the installed version ships.

Clients​

ThunderIDNodeClient​

export

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.

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

Config​

ThunderIDNodeConfig​

export

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

import { ThunderIDNodeConfig } from '@thunderid/node'

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

Utilities​

CookieConfig​

export

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

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,
})

CookieOptions​

export

CookieOptions defines the shape of cookie configuration options used in the Choreo Identity & Access Management Node.js SDK. Pass a CookieOptions object to getSessionCookieOptions to override the default cookie settings.

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

generateSessionId()​

export

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.

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,
)
})

getSessionCookieOptions()​

export

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

Parameters

| Name | Type | Description |

|---|---|---|

| options (required) | Partial | Cookie options to apply. Unspecified properties use the defaults from CookieConfig. |

import { getSessionCookieOptions } from '@thunderid/node'

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

Was this page helpful?