JavaScript API reference
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.
Flows
Embedded Recovery Flow (V2)
export
executeEmbeddedRecoveryFlowV2 drives a step-by-step account recovery flow (e.g., password reset) without a browser redirect.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.payload (required) | EmbeddedRecoveryFlowRequestV2 | Flow request body |
| config.payload.applicationId (optional) | string | Application ID. Required for the first step |
| config.payload.flowType (optional) | string | Recovery flow type (e.g., 'PASSWORD_RECOVERY'). Required for first step |
| config.payload.executionId (optional) | string | Execution ID from a prior response |
| config.payload.action (optional) | string | Action to take at the current step |
| config.payload.inputs (optional) | Record | Step input fields |
| config.payload.challengeToken (optional) | string | Challenge token from a prior step |
import { executeEmbeddedRecoveryFlowV2, EmbeddedRecoveryFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate recovery
const step1 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
applicationId: '<your-app-id>',
flowType: 'PASSWORD_RECOVERY',
},
})
// Step 2 — Provide the username/email to recover
const step2 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
executionId: step1.executionId,
inputs: {
},
},
})
// Step 3 — Submit the OTP/token received by email
const step3 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
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)
export
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().
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://<DATA_PLANE_URL>/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)
export
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.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.payload (required) | EmbeddedSignInFlowRequestV2 | Flow request body |
| config.payload.applicationId (optional) | string | Application ID. Required for the first step |
| config.payload.flowType (optional) | string | Flow type. Required for the first step (e.g., 'SIGN_IN') |
| config.payload.executionId (optional) | string | Execution ID from a prior response. Required for subsequent steps |
| config.payload.action (optional) | string | Action to take at the current step |
| config.payload.inputs (optional) | Record | Step-specific input fields (e.g., credentials) |
| config.payload.challengeToken (optional) | string | Challenge token from a prior step (e.g., for MFA) |
| config.authId (optional) | string | Optional authentication context ID |
import { executeEmbeddedSignInFlowV2, EmbeddedSignInFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate the flow
const step1 = await executeEmbeddedSignInFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
applicationId: '<your-app-id>',
flowType: 'SIGN_IN',
},
})
// Step 2 — Submit credentials
const step2 = await executeEmbeddedSignInFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
executionId: step1.executionId,
inputs: {
password: '<password>',
},
},
})
if (step2.flowStatus === EmbeddedSignInFlowStatusV2.Complete) {
const assertion = step2.assertion // Use to complete the OAuth code exchange
}
Embedded Sign-Up Flow (V1)
export
executeEmbeddedSignUpFlow drives a step-by-step registration flow without a browser redirect.
For new integrations, prefer executeEmbeddedSignUpFlowV2.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.payload (required) | EmbeddedFlowExecuteRequestPayload | Flow step payload |
| config.payload.flowType (required) | EmbeddedFlowType | Must be EmbeddedFlowType.Registration |
| config.payload.flowId (optional) | string | Flow ID from a previous step response |
| config.payload.selectedAuthenticator (optional) | object | Authenticator selection (for later steps) |
import { executeEmbeddedSignUpFlow, EmbeddedFlowType } from '@thunderid/javascript'
const response = await executeEmbeddedSignUpFlow({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
flowType: EmbeddedFlowType.Registration,
// step-specific fields
},
})
Embedded Sign-Up Flow (V2)
export
executeEmbeddedSignUpFlowV2 drives a step-by-step user registration flow using the V2 protocol.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.payload (required) | EmbeddedSignUpFlowRequestV2 | Flow request body |
| config.payload.applicationId (optional) | string | Application ID. Required for the first step |
| config.payload.flowType (optional) | string | Flow type. Required for the first step (e.g., 'REGISTRATION') |
| config.payload.executionId (optional) | string | Execution ID from a prior response |
| config.payload.action (optional) | string | Action to perform at the current step |
| config.payload.inputs (optional) | Record | Registration field values |
| config.payload.challengeToken (optional) | string | Challenge token for verification steps |
| config.authId (optional) | string | Optional authentication context ID |
import { executeEmbeddedSignUpFlowV2, EmbeddedSignUpFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate
const step1 = await executeEmbeddedSignUpFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
applicationId: '<your-app-id>',
flowType: 'REGISTRATION',
},
})
// Step 2 — Provide registration details
const step2 = await executeEmbeddedSignUpFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
executionId: step1.executionId,
inputs: {
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)
export
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.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.type (optional) | FlowMetaType | Scope the metadata to an application (App) or organization unit (Ou) |
| config.id (optional) | string | Application ID or OU ID, depending on type |
| config.language (optional) | string | BCP 47 language tag for the i18n metadata (e.g., 'en-US') |
| config.namespace (optional) | string | Translation namespace filter |
import { getFlowMetaV2, FlowMetaType } from '@thunderid/javascript'
const meta = await getFlowMetaV2({
baseUrl: 'https://<DATA_PLANE_URL>',
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)
export
executeEmbeddedUserOnboardingFlowV2 drives a post-sign-in onboarding sequence (e.g., profile completion, consent collection) without a browser redirect.
Parameters
| Name | Type | Description |
|---|---|---|
| config.url (required) | string | Full endpoint URL. Mutually exclusive with baseUrl |
| config.baseUrl (required) | string | Choreo Identity & Access Management base URL |
| config.payload (required) | EmbeddedFlowExecuteRequestConfigV2 | Flow request body |
| config.payload.applicationId (optional) | string | Application ID. Required for the first step |
| config.payload.flowType (optional) | string | Must be 'USER_ONBOARDING' for the first step |
| config.payload.executionId (optional) | string | Execution ID from a prior response |
| config.payload.inputs (optional) | Record | Step input values |
| config.payload.challengeToken (optional) | string | Challenge token from a prior step |
import { executeEmbeddedUserOnboardingFlowV2, EmbeddedSignUpFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate onboarding
const step1 = await executeEmbeddedUserOnboardingFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
applicationId: '<your-app-id>',
flowType: 'USER_ONBOARDING',
},
})
// Step 2 — Complete profile
const step2 = await executeEmbeddedUserOnboardingFlowV2({
baseUrl: 'https://<DATA_PLANE_URL>',
payload: {
executionId: step1.executionId,
inputs: {
'http://wso2.org/claims/mobile': '+1-555-0100',
},
},
})
Functions
Branding
function
The branding functions fetch the visual configuration (colors, logos, typography) defined in the Choreo Identity & Access Management Console and apply it to your UI.
import { getBrandingPreference } from '@thunderid/javascript'
const branding = await getBrandingPreference({
baseUrl: 'https://<DATA_PLANE_URL>',
locale: 'en-US',
})
console.log(branding.preference?.theme?.LIGHT?.colors?.primary?.main)
Configuration
function
The initialize() method accepts a configuration object (AuthClientConfig) that controls how the SDK connects to your Choreo Identity & Access Management instance and manages authentication.
import ThunderIDJavaScriptClient from "@thunderid/javascript"
const client = new ThunderIDJavaScriptClient()
await client.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://<DATA_PLANE_URL>',
})
Errors
function
The 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
function
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()),
}
}
}
Internationalization
function
The SDK ships with built-in translation bundles for Choreo Identity & Access Management 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']) // I18nBundle
StorageManager
function
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)
Theme
function
The theme system provides a structured way to define colors, typography, spacing, and other visual properties used by Choreo Identity & Access Management 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
function
ThunderIDJavaScriptClient is the base class that all platform-specific Choreo Identity & Access Management 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?)
Utilities
function
The 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
User Profile
export
These functions read and update user profile data from the OIDC userinfo endpoint.
import { getUserInfo } from '@thunderid/javascript'
const user = await getUserInfo({
url: 'https://<DATA_PLANE_URL>/oauth2/userinfo',
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
console.log(user.email, user.displayName)
User Schemas
export
The SDK provides helpers for working with user schema data.
import { flattenUserSchema } from '@thunderid/javascript'
const flat = flattenUserSchema(schemas, userProfile)
Was this page helpful?