Skip to main content

JavaScript SDK

The ThunderID JavaScript SDK (@thunderid/javascript) is the framework-agnostic core library that powers platform-specific SDKs such as @thunderid/browser, @thunderid/react, and @thunderid/express. Use it directly when building custom integrations, writing platform adapters, or working in environments without a dedicated ThunderID SDK.

Installation

Install the ThunderID JavaScript SDK using your preferred package manager:

npm install @thunderid/javascript

When to use this SDK

Use caseRecommended SDK
React applications@thunderid/react
Vanilla JavaScript browser apps@thunderid/browser
Express.js middleware@thunderid/express
Custom platform adapter@thunderid/javascript (this SDK)
Building a new framework SDK@thunderid/javascript (this SDK)

Quick Example

Extend ThunderIDJavaScriptClient to build a platform-specific client:

src/my-client.ts
import ThunderIDJavaScriptClient from '@thunderid/javascript'

class MyCustomClient extends ThunderIDJavaScriptClient {
async signIn(options = {}) {
await this.loadOpenIDProviderConfiguration()
const url = await this.getSignInUrl(options)
window.location.href = url
}

async handleCallback() {
const params = new URLSearchParams(window.location.search)
return this.requestAccessToken(
params.get('code')!,
params.get('session_state') ?? '',
params.get('state')!,
)
}
}

const auth = new MyCustomClient()

await auth.initialize({
clientId: '<your-client-id>',
baseUrl: 'https://localhost:8090',
afterSignInUrl: window.location.origin,
})

Features

Core APIs

  • ThunderIDJavaScriptClient — Base class for all platform SDKs. Handles OIDC discovery, PKCE, token exchange, session storage, JWT decoding, and agent/OBO authentication.
  • Configuration — Full reference for all initialization options including auth, token validation, discovery, and preferences.
  • HttpClient — Abstract HTTP client base with handler lifecycle, request/response callbacks, and parallel request support.
  • StorageManager — Typed storage layer for config, OIDC metadata, session, and temporary PKCE data.

Auth Flow Functions

Standalone functions for driving authentication flows step-by-step without browser redirects.

V1 Flows

User & Profile

  • User ProfilegetUserInfo, getScim2Me, updateMeProfile
  • SCIM2 SchemasgetSchemas and schema utility functions (flattenUserSchema, generateUserProfile, resolveFieldType)

Organizations

  • OrganizationsgetAllOrganizations, getMeOrganizations, getOrganization, createOrganization, updateOrganization, createPatchOperations
  • Organization UnitsgetOrganizationUnitChildren

Branding & Theme

  • BrandinggetBrandingPreference, transformBrandingPreferenceToTheme
  • ThemecreateTheme, DEFAULT_THEME

Internationalization

  • InternationalizationgetDefaultI18nBundles, normalizeTranslations, TranslationBundleConstants. Built-in support for 9 locales.

Errors

  • ErrorsThunderIDError, ThunderIDAPIError, ThunderIDRuntimeError, ThunderIDAuthException

Utilities

  • Utilities — Encoding, auth helpers, URL utilities, data manipulation, V2 flow template literals, BEM styling, and structured logging.
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy