Skip to content

OidcClient

Defined in: client/src/client.ts:49

Browser OIDC client that wraps oidc-js-core with fetch and sessionStorage.

Handles the full Authorization Code + PKCE flow: discovery, redirect-based login, callback handling, token refresh, userinfo fetching, and logout. Exposes reactive AuthState via a subscribe/notify pattern.

new OidcClient(config): OidcClient

Defined in: client/src/client.ts:68

Creates a new OidcClient instance.

OidcClientConfig

OIDC configuration including issuer, clientId, and redirectUri.

OidcClient

get state(): AuthState

Defined in: client/src/client.ts:73

The current authentication state.

AuthState

destroy(): void

Defined in: client/src/client.ts:302

Tears down the client by aborting any in-flight requests and removing all subscribers.

void


fetchProfile(): Promise<void>

Defined in: client/src/client.ts:288

Fetches the user’s profile from the userinfo endpoint using the current access token.

Updates the user.profile field in the auth state with the response.

Promise<void>

Error if no access token is available or discovery has not been fetched.


init(): Promise<{ returnTo?: string; }>

Defined in: client/src/client.ts:107

Initializes the client by fetching OIDC discovery and processing any callback parameters.

If the current URL contains an authorization code, it completes the token exchange, optionally fetches the userinfo profile, and returns the returnTo path saved before login. If the URL contains an error, it sets the error state.

Promise<{ returnTo?: string; }>

An object with an optional returnTo path indicating where the app should navigate.


login(options?): Promise<void>

Defined in: client/src/client.ts:187

Starts the Authorization Code + PKCE login flow by redirecting the browser to the authorization endpoint.

Generates PKCE, state, and nonce values, persists them in sessionStorage, then navigates away. Does nothing if discovery has not been fetched yet (i.e., init was not called).

LoginOptions

Optional login parameters such as returnTo and extraParams.

Promise<void>


logout(): void

Defined in: client/src/client.ts:215

Logs the user out by clearing local auth state and redirecting to the OP’s end-session endpoint.

If the discovery document has an end_session_endpoint, the browser is redirected there with the current ID token hint and postLogoutRedirectUri from config.

void


refresh(): Promise<void>

Defined in: client/src/client.ts:245

Uses the stored refresh token to obtain a new set of tokens from the token endpoint.

Updates the auth state with the new tokens and, if an ID token is returned, re-decodes the claims and optionally re-fetches the userinfo profile.

Promise<void>

Error if no refresh token is available or discovery has not been fetched.


subscribe(fn): () => void

Defined in: client/src/client.ts:83

Registers a callback that fires whenever the auth state changes.

Subscriber

Subscriber function receiving the updated AuthState.

An unsubscribe function that removes the listener.

() => void