API reference
The public surface of
@thunderid/javascript, as documented in its reference pages.Embedded Recovery Flow (V2)`executeEmbeddedRecoveryFlowV2` drives a step-by-step account recovery flow (e.g., password reset) without a browser redirect.
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedRecoveryFlowRequestV2Flow request body
config.payload.applicationIdoptionalstringApplication ID. Required for the first step
config.payload.flowTypeoptionalstringRecovery flow type (e.g., `'PASSWORD_RECOVERY'`). Required for first step
config.payload.executionIdoptionalstringExecution ID from a prior response
config.payload.actionoptionalstringAction to take at the current step
config.payload.inputsoptionalRecordStep input fields
config.payload.challengeTokenoptionalstringChallenge token from a prior step
import { executeEmbeddedRecoveryFlowV2, EmbeddedRecoveryFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate recovery
const step1 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
applicationId: '<your-app-id>',
flowType: 'PASSWORD_RECOVERY',
},
})
// Step 2 — Provide the username/email to recover
const step2 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step1.executionId,
inputs: {
username: 'user@example.com',
},
},
})
// Step 3 — Submit the OTP/token received by email
const step3 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step2.executionId,
inputs: {
otp: '123456',
},
challengeToken: step2.challengeToken,
},
})
if (step3.flowStatus === EmbeddedRecoveryFlowStatusV2.Complete) {
// Recovery complete — prompt user for new password
}Embedded Sign-In Flow (V1)These functions implement app-native (embedded) sign-in for the V1 flow protocol. They allow you to drive the authentication sequence step-by-step without a browser redirect to the identity provider. Used internally by `ThunderIDJavaScriptClient.getAgentToken()`. :::note For new integrations, prefer the V2 flow functions, which offer a richer response model and better error handling. :::
import { initializeEmbeddedSignInFlow } from '@thunderid/javascript'
const response = await initializeEmbeddedSignInFlow({
url: 'https://localhost:8090/oauth2/authorize',
payload: {
response_type: 'code',
client_id: '<your-client-id>',
redirect_uri: 'http://localhost:3000',
scope: 'openid profile',
state: '<random-state>',
code_challenge: '<pkce-code-challenge>',
code_challenge_method: 'S256',
response_mode: 'direct',
},
})Embedded Sign-In Flow (V2)`executeEmbeddedSignInFlowV2` drives a step-by-step sign-in sequence using the V2 flow protocol. It supports a richer response model with explicit error states, challenge tokens for multi-factor flows, and assertion-based completion.
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedSignInFlowRequestV2Flow request body
config.payload.applicationIdoptionalstringApplication ID. Required for the first step
config.payload.flowTypeoptionalstringFlow type. Required for the first step (e.g., `'SIGN_IN'`)
config.payload.executionIdoptionalstringExecution ID from a prior response. Required for subsequent steps
config.payload.actionoptionalstringAction to take at the current step
config.payload.inputsoptionalRecordStep-specific input fields (e.g., credentials)
config.payload.challengeTokenoptionalstringChallenge token from a prior step (e.g., for MFA)
config.authIdoptionalstringOptional authentication context ID
import { executeEmbeddedSignInFlowV2, EmbeddedSignInFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate the flow
const step1 = await executeEmbeddedSignInFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
applicationId: '<your-app-id>',
flowType: 'SIGN_IN',
},
})
// Step 2 — Submit credentials
const step2 = await executeEmbeddedSignInFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step1.executionId,
inputs: {
username: 'user@example.com',
password: 'password123',
},
},
})
if (step2.flowStatus === EmbeddedSignInFlowStatusV2.Complete) {
const assertion = step2.assertion // Use to complete the OAuth code exchange
}Embedded Sign-Up Flow (V1)`executeEmbeddedSignUpFlow` drives a step-by-step registration flow without a browser redirect. :::note For new integrations, prefer `executeEmbeddedSignUpFlowV2`. :::
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedFlowExecuteRequestPayloadFlow step payload
config.payload.flowTyperequiredEmbeddedFlowTypeMust be `EmbeddedFlowType.Registration`
config.payload.flowIdoptionalstringFlow ID from a previous step response
config.payload.selectedAuthenticatoroptionalobjectAuthenticator selection (for later steps)
import { executeEmbeddedSignUpFlow, EmbeddedFlowType } from '@thunderid/javascript'
const response = await executeEmbeddedSignUpFlow({
baseUrl: 'https://localhost:8090',
payload: {
flowType: EmbeddedFlowType.Registration,
// step-specific fields
},
})Embedded Sign-Up Flow (V2)`executeEmbeddedSignUpFlowV2` drives a step-by-step user registration flow using the V2 protocol.
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedSignUpFlowRequestV2Flow request body
config.payload.applicationIdoptionalstringApplication ID. Required for the first step
config.payload.flowTypeoptionalstringFlow type. Required for the first step (e.g., `'REGISTRATION'`)
config.payload.executionIdoptionalstringExecution ID from a prior response
config.payload.actionoptionalstringAction to perform at the current step
config.payload.inputsoptionalRecordRegistration field values
config.payload.challengeTokenoptionalstringChallenge token for verification steps
config.authIdoptionalstringOptional authentication context ID
import { executeEmbeddedSignUpFlowV2, EmbeddedSignUpFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate
const step1 = await executeEmbeddedSignUpFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
applicationId: '<your-app-id>',
flowType: 'REGISTRATION',
},
})
// Step 2 — Provide registration details
const step2 = await executeEmbeddedSignUpFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step1.executionId,
inputs: {
username: 'newuser@example.com',
password: 'SecurePass123!',
'http://wso2.org/claims/givenname': 'New',
'http://wso2.org/claims/lastname': 'User',
},
},
})
if (step2.flowStatus === EmbeddedSignUpFlowStatusV2.Complete) {
// Registration complete — redirect or sign in
}Flow Meta (V2)`getFlowMetaV2` fetches aggregated metadata for a V2 flow context, including application branding, organization unit details, theme configuration, and available translations. Use it to pre-load everything needed to render a custom sign-in or sign-up UI.
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.typeoptionalFlowMetaTypeScope the metadata to an application (`App`) or organization unit (`Ou`)
config.idoptionalstringApplication ID or OU ID, depending on `type`
config.languageoptionalstringBCP 47 language tag for the i18n metadata (e.g., `'en-US'`)
config.namespaceoptionalstringTranslation namespace filter
import { getFlowMetaV2, FlowMetaType } from '@thunderid/javascript'
const meta = await getFlowMetaV2({
baseUrl: 'https://localhost:8090',
type: FlowMetaType.App,
id: '<your-app-id>',
language: 'en-US',
})
console.log(meta.application?.name)
console.log(meta.design.theme.colorSchemes)
console.log(meta.i18n.translations)User Onboarding Flow (V2)`executeEmbeddedUserOnboardingFlowV2` drives a post-sign-in onboarding sequence (e.g., profile completion, consent collection) without a browser redirect.
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedFlowExecuteRequestConfigV2Flow request body
config.payload.applicationIdoptionalstringApplication ID. Required for the first step
config.payload.flowTypeoptionalstringMust be `'USER_ONBOARDING'` for the first step
config.payload.executionIdoptionalstringExecution ID from a prior response
config.payload.inputsoptionalRecordStep input values
config.payload.challengeTokenoptionalstringChallenge token from a prior step
import { executeEmbeddedUserOnboardingFlowV2, EmbeddedSignUpFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate onboarding
const step1 = await executeEmbeddedUserOnboardingFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
applicationId: '<your-app-id>',
flowType: 'USER_ONBOARDING',
},
})
// Step 2 — Complete profile
const step2 = await executeEmbeddedUserOnboardingFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step1.executionId,
inputs: {
'http://wso2.org/claims/mobile': '+1-555-0100',
},
},
})BrandingThe branding functions fetch the visual configuration (colors, logos, typography) defined in the ThunderID Console and apply it to your UI.
import { getBrandingPreference } from '@thunderid/javascript'
const branding = await getBrandingPreference({
baseUrl: 'https://localhost:8090',
locale: 'en-US',
})
console.log(branding.preference?.theme?.LIGHT?.colors?.primary?.main)ConfigurationThe `initialize()` method accepts a configuration object (`AuthClientConfig`) that controls how the SDK connects to your ThunderID instance and manages authentication.
import ThunderIDJavaScriptClient from '@thunderid/javascript'
const client = new ThunderIDJavaScriptClient()
await client.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://localhost:8090',
})ErrorsThe SDK uses a hierarchy of typed error classes. Catch specific classes to handle different failure modes distinctly.
Error
└── ThunderIDError
├── ThunderIDAPIError
└── ThunderIDRuntimeError
ThunderIDAuthException (separate — thrown by auth flow internals)HttpClient`HttpClient` is an abstract base class that provides handler lifecycle management, request/response callbacks, and parallel request utilities. Platform SDKs extend it to add token attachment, retry logic, or custom transport implementations.
import { HttpClient } from '@thunderid/javascript'
import type { HttpRequestConfig, HttpResponse } from '@thunderid/javascript'
class FetchHttpClient extends HttpClient {
async transport<T>(config: HttpRequestConfig): Promise<HttpResponse<T>> {
const response = await fetch(config.url, {
method: config.method,
headers: config.headers as HeadersInit,
body: config.data ? JSON.stringify(config.data) : undefined,
})
return {
data: await response.json(),
status: response.status,
statusText: response.statusText,
headers: Object.fromEntries(response.headers.entries()),
}
}
}InternationalizationThe SDK ships with built-in translation bundles for ThunderID UI components and provides utilities for loading, extending, and normalizing translations.
import { getDefaultI18nBundles } from '@thunderid/javascript'
const bundles = getDefaultI18nBundles()
console.log(bundles['en-US']) // I18nBundle
console.log(bundles['fr-FR']) // I18nBundleStorageManager`StorageManager` is the typed storage layer used internally by `ThunderIDJavaScriptClient`. It namespaces all stored data under a storage key derived from the client ID and instance ID. The storage layer provides typed methods for each data category: configuration, OIDC provider metadata, session data, and temporary (PKCE/state) data. Use it directly only when building platform adapters that need fine-grained control over stored auth state.
import StorageManager from '@thunderid/javascript'
const storage = new StorageManager<Config>('instance_0-my-client-id', store)ThemeThe theme system provides a structured way to define colors, typography, spacing, and other visual properties used by ThunderID UI components. Use `createTheme()` to build a theme from scratch or apply partial overrides on top of the defaults.
import { createTheme } from '@thunderid/javascript'
const theme = createTheme({
colors: {
primary: {
main: '#6200ea',
contrastText: '#ffffff',
},
},
})
// Apply CSS variables to the document root
Object.entries(theme.cssVariables).forEach(([key, value]) => {
document.documentElement.style.setProperty(key, value)
})ThunderIDJavaScriptClient`ThunderIDJavaScriptClient` is the base class that all platform-specific ThunderID clients extend. It provides OIDC discovery, PKCE, token exchange, session management, JWT decoding, and agent/OBO authentication. Instantiate it directly only when writing a custom platform adapter: for browser use, prefer `@thunderid/browser`; for React, use `@thunderid/react`.
const client = new ThunderIDJavaScriptClient(storage?, cryptoUtils?)
UtilitiesThe SDK exports a set of utility functions used internally by platform SDKs and available to custom integrations.
import { arrayBufferToBase64url } from '@thunderid/javascript'
const encoded = arrayBufferToBase64url(buffer)User ProfileThese functions read and update user profile data from the OIDC userinfo endpoint.
import { getUserInfo } from '@thunderid/javascript'
const user = await getUserInfo({
url: 'https://localhost:8090/oauth2/userinfo',
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
console.log(user.email, user.displayName)User SchemasThe SDK provides helpers for working with user schema data.
import { flattenUserSchema } from '@thunderid/javascript'
const flat = flattenUserSchema(schemas, userProfile)