From 1e808ba6bb02a3b3cc2397ca7446183fa6ae5d1b Mon Sep 17 00:00:00 2001
From: AJ Ancheta <7781450+ancheetah@users.noreply.github.com>
Date: Thu, 5 Nov 2026 14:18:43 -0500
Subject: [PATCH] feat(oidc-client): add RAR support [SDKS-5435]
---
.changeset/big-kids-smash.md | 7 +
e2e/oidc-app/src/index.html | 2 +
e2e/oidc-app/src/par/main.ts | 46 +-
e2e/oidc-app/src/rar-par/index.html | 61 +
e2e/oidc-app/src/rar-par/main.ts | 52 +
e2e/oidc-app/src/rar/index.html | 28 +
e2e/oidc-app/src/rar/main.ts | 31 +
e2e/oidc-app/src/utils/journey-login.ts | 53 +
e2e/oidc-app/src/utils/oidc-app.ts | 20 +
e2e/oidc-suites/playwright.config.ts | 2 +
e2e/oidc-suites/src/par.spec.ts | 4 +-
e2e/oidc-suites/src/rar-par.spec.ts | 85 ++
e2e/oidc-suites/src/rar.spec.ts | 72 ++
packages/oidc-client/README.md | 99 +-
.../oidc-client/api-report/oidc-client.api.md | 1103 ++++++++++-------
.../api-report/oidc-client.types.api.md | 1097 +++++++++-------
.../src/lib/authorize.request.micros.test.ts | 39 +
.../src/lib/authorize.request.micros.ts | 3 +
.../oidc-client/src/lib/client.store.test.ts | 153 +++
packages/oidc-client/src/lib/client.store.ts | 19 +-
packages/oidc-client/src/lib/config.types.ts | 2 +
.../oidc-client/src/lib/exchange.request.ts | 1 +
.../oidc-client/src/lib/exchange.types.ts | 5 +-
packages/oidc-client/src/types.ts | 3 +-
.../oidc/src/lib/authorize.test.ts | 74 +-
.../oidc/src/lib/authorize.utils.ts | 20 +-
packages/sdk-types/src/lib/authorize.types.ts | 31 +-
packages/sdk-types/src/lib/config.types.ts | 9 +-
28 files changed, 2213 insertions(+), 908 deletions(-)
create mode 100644 .changeset/big-kids-smash.md
create mode 100644 e2e/oidc-app/src/rar-par/index.html
create mode 100644 e2e/oidc-app/src/rar-par/main.ts
create mode 100644 e2e/oidc-app/src/rar/index.html
create mode 100644 e2e/oidc-app/src/rar/main.ts
create mode 100644 e2e/oidc-app/src/utils/journey-login.ts
create mode 100644 e2e/oidc-suites/src/rar-par.spec.ts
create mode 100644 e2e/oidc-suites/src/rar.spec.ts
diff --git a/.changeset/big-kids-smash.md b/.changeset/big-kids-smash.md
new file mode 100644
index 00000000000..7e11344480c
--- /dev/null
+++ b/.changeset/big-kids-smash.md
@@ -0,0 +1,7 @@
+---
+'@forgerock/oidc-client': minor
+'@forgerock/sdk-oidc': minor
+'@forgerock/sdk-types': minor
+---
+
+Added RAR support through `authorizationDetails` parameter in OIDC config. Works with or without PAR.
diff --git a/e2e/oidc-app/src/index.html b/e2e/oidc-app/src/index.html
index dcc720ee3b0..c0fd57ee6a7 100644
--- a/e2e/oidc-app/src/index.html
+++ b/e2e/oidc-app/src/index.html
@@ -13,6 +13,8 @@
OIDC Client E2E Test Index | Ping Identity JavaScript SDK
Ping AM
Ping One
PAR (Pushed Authorization Request)
+ RAR (Rich Authorization Request)
+ RAR with PAR
diff --git a/e2e/oidc-app/src/par/main.ts b/e2e/oidc-app/src/par/main.ts
index 46ec6b3e367..ce5664181a8 100644
--- a/e2e/oidc-app/src/par/main.ts
+++ b/e2e/oidc-app/src/par/main.ts
@@ -6,13 +6,11 @@
* of the MIT license. See the LICENSE file for details.
*
*/
+import { runLoginJourney } from '../utils/journey-login.js';
import { oidcApp } from '../utils/oidc-app.js';
-const AM_BASE = 'https://openam-sdks.forgeblocks.com/am';
-const REALM = 'alpha';
-
const urlParams = new URLSearchParams(window.location.search);
-const wellknown = urlParams.get('wellknown');
+const AM_BASE = 'https://openam-sdks.forgeblocks.com/am';
const config = {
clientId: 'ParClient',
@@ -20,51 +18,15 @@ const config = {
scope: 'openid profile email',
par: true,
serverConfig: {
- wellknown:
- wellknown ||
- 'https://openam-sdks.forgeblocks.com/am/oauth2/alpha/.well-known/openid-configuration',
+ wellknown: `${AM_BASE}/oauth2/alpha/.well-known/openid-configuration`,
},
};
-// Run journey Login to establish an AM session before background PAR auth
-async function runLoginJourney(username: string, password: string): Promise {
- const authenticateUrl = `${AM_BASE}/json/realms/root/realms/${REALM}/authenticate?authIndexType=service&authIndexValue=Login`;
-
- // Step 1: start the journey
- const initRes = await fetch(authenticateUrl, {
- method: 'POST',
- credentials: 'include',
- headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' },
- body: '{}',
- });
- const initJson = await initRes.json();
-
- if (initJson.successUrl) return; // already authenticated
-
- // Fill NameCallback + PasswordCallback
- for (const cb of initJson.callbacks ?? []) {
- if (cb.type === 'NameCallback') cb.input[0].value = username;
- if (cb.type === 'PasswordCallback') cb.input[0].value = password;
- }
-
- // Step 2: submit credentials
- const submitRes = await fetch(authenticateUrl, {
- method: 'POST',
- credentials: 'include',
- headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' },
- body: JSON.stringify(initJson),
- });
- const submitJson = await submitRes.json();
-
- if (!submitJson.tokenId && !submitJson.successUrl) {
- throw new Error(submitJson.message || 'Login failed');
- }
-}
-
const journeyForm = document.getElementById('journey-form') as HTMLFormElement;
const journeyStatus = document.getElementById('journey-status') as HTMLParagraphElement;
const backgroundBtn = document.getElementById('login-background') as HTMLButtonElement;
+// Run journey Login to establish an AM session before background PAR auth
journeyForm.addEventListener('submit', async (e) => {
e.preventDefault();
const username = (document.getElementById('username') as HTMLInputElement).value;
diff --git a/e2e/oidc-app/src/rar-par/index.html b/e2e/oidc-app/src/rar-par/index.html
new file mode 100644
index 00000000000..58a2fc055d7
--- /dev/null
+++ b/e2e/oidc-app/src/rar-par/index.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+ E2E Test | Ping Identity JavaScript SDK
+
+
+
+
+
+
Home
+
OIDC App | RAR (Rich Authorization Request) + PAR Login
+
+ Client: rar — RAR enabled. authorization_details are
+ serialized and sent in the authorize url or PAR POST body.
+
+
+
Step 1: Establish AM Session (Journey: Login)
+
+ Background PAR + RAR auth requires an existing AM session. Log in via the Login journey
+ first.
+
+
+
+
+
Step 2: RAR OAuth
+
+
+
+
+
+
+
+
+
Start Over
+
+
+
+
diff --git a/e2e/oidc-app/src/rar-par/main.ts b/e2e/oidc-app/src/rar-par/main.ts
new file mode 100644
index 00000000000..6898093d846
--- /dev/null
+++ b/e2e/oidc-app/src/rar-par/main.ts
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright (c) 2026 Ping Identity Corporation. All right reserved.
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ *
+ */
+import { runLoginJourney } from '../utils/journey-login.js';
+import { oidcApp } from '../utils/oidc-app.js';
+
+const urlParams = new URLSearchParams(window.location.search);
+const AM_BASE = 'https://openam-stoyan.forgeblocks.com/am';
+
+const config = {
+ clientId: 'rar',
+ redirectUri: 'http://localhost:8443/rar-par/',
+ scope: 'openid profile email',
+ serverConfig: {
+ wellknown: `${AM_BASE}/oauth2/alpha/.well-known/openid-configuration`,
+ },
+ par: true,
+ authorizationDetails: [
+ {
+ type: 'account_information',
+ actions: ['list_accounts', 'read_balances'],
+ locations: ['https://example.com/accounts'],
+ datatypes: ['balances'],
+ },
+ ],
+};
+
+const journeyForm = document.getElementById('journey-form') as HTMLFormElement;
+const journeyStatus = document.getElementById('journey-status') as HTMLParagraphElement;
+const backgroundBtn = document.getElementById('login-background') as HTMLButtonElement;
+
+// Run journey Login to establish an AM session before background auth
+journeyForm.addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const username = (document.getElementById('username') as HTMLInputElement).value;
+ const password = (document.getElementById('password') as HTMLInputElement).value;
+ journeyStatus.textContent = 'Logging in…';
+ try {
+ await runLoginJourney(username, password, AM_BASE);
+ journeyStatus.textContent = '✓ Session established — background login now available.';
+ backgroundBtn.disabled = false;
+ } catch (err) {
+ journeyStatus.textContent = `✗ ${err instanceof Error ? err.message : 'Login failed'}`;
+ }
+});
+
+oidcApp({ config, urlParams });
diff --git a/e2e/oidc-app/src/rar/index.html b/e2e/oidc-app/src/rar/index.html
new file mode 100644
index 00000000000..2f344b1eeff
--- /dev/null
+++ b/e2e/oidc-app/src/rar/index.html
@@ -0,0 +1,28 @@
+
+
+
+ E2E Test | Ping Identity JavaScript SDK
+
+
+
+
+
+
Home
+
OIDC App | RAR Login
+
+
+
+
+
+
+
+
+
Start Over
+
+
+
+
diff --git a/e2e/oidc-app/src/rar/main.ts b/e2e/oidc-app/src/rar/main.ts
new file mode 100644
index 00000000000..59fc4de962a
--- /dev/null
+++ b/e2e/oidc-app/src/rar/main.ts
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2026 Ping Identity Corporation. All right reserved.
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ *
+ */
+import { oidcApp } from '../utils/oidc-app.js';
+
+const urlParams = new URLSearchParams(window.location.search);
+
+const config = {
+ clientId: 'rar',
+ redirectUri: 'http://localhost:8443/rar/',
+ scope: 'openid profile email',
+ serverConfig: {
+ wellknown:
+ 'https://openam-stoyan.forgeblocks.com/am/oauth2/alpha/.well-known/openid-configuration',
+ },
+ authorizationDetails: [
+ {
+ type: 'account_information',
+ actions: ['list_accounts', 'read_balances'],
+ locations: ['https://example.com/accounts'],
+ datatypes: ['balances'],
+ },
+ ],
+};
+
+oidcApp({ config, urlParams });
diff --git a/e2e/oidc-app/src/utils/journey-login.ts b/e2e/oidc-app/src/utils/journey-login.ts
new file mode 100644
index 00000000000..6dc6059e006
--- /dev/null
+++ b/e2e/oidc-app/src/utils/journey-login.ts
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright (c) 2026 Ping Identity Corporation. All right reserved.
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ *
+ */
+const urlParams = new URLSearchParams(window.location.search);
+const journeyParam = urlParams.get('journey');
+
+const AM_BASE = 'https://openam-sdks.forgeblocks.com/am';
+const REALM = 'alpha';
+const JOURNEY = journeyParam || 'Login';
+
+// Run journey Login to establish an AM session before background auth
+export async function runLoginJourney(
+ username: string,
+ password: string,
+ amBase?: string,
+): Promise {
+ const authenticateUrl = `${amBase || AM_BASE}/json/realms/root/realms/${REALM}/authenticate?authIndexType=service&authIndexValue=${JOURNEY}`;
+
+ // Step 1: start the journey
+ const initRes = await fetch(authenticateUrl, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' },
+ body: '{}',
+ });
+ const initJson = await initRes.json();
+
+ if (initJson.successUrl) return; // already authenticated
+
+ // Fill NameCallback + PasswordCallback
+ for (const cb of initJson.callbacks ?? []) {
+ if (cb.type === 'NameCallback') cb.input[0].value = username;
+ if (cb.type === 'PasswordCallback') cb.input[0].value = password;
+ }
+
+ // Step 2: submit credentials
+ const submitRes = await fetch(authenticateUrl, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json', 'Accept-API-Version': 'resource=2.1' },
+ body: JSON.stringify(initJson),
+ });
+ const submitJson = await submitRes.json();
+
+ if (!submitJson.tokenId && !submitJson.successUrl) {
+ throw new Error(submitJson.message || 'Login failed');
+ }
+}
diff --git a/e2e/oidc-app/src/utils/oidc-app.ts b/e2e/oidc-app/src/utils/oidc-app.ts
index 4114eaa072c..a9beb402fed 100644
--- a/e2e/oidc-app/src/utils/oidc-app.ts
+++ b/e2e/oidc-app/src/utils/oidc-app.ts
@@ -154,6 +154,16 @@ export async function oidcApp({
const response = await oidcClient.token?.get({ backgroundRenew: true });
if (response) {
displayTokenResponse(response);
+
+ if ('redirectUrl' in response) {
+ if (response.redirectUrl) {
+ const redirectLink = document.createElement('a');
+ redirectLink.textContent = 'Redirect Link';
+ redirectLink.href = response.redirectUrl;
+ redirectLink.id = 'background-redirect-url';
+ document.body.appendChild(redirectLink);
+ }
+ }
}
});
@@ -161,6 +171,16 @@ export async function oidcApp({
const response = await oidcClient.token?.get({ backgroundRenew: true, forceRenew: true });
if (response) {
displayTokenResponse(response);
+
+ if ('redirectUrl' in response) {
+ if (response.redirectUrl) {
+ const redirectLink = document.createElement('a');
+ redirectLink.textContent = 'Redirect Link';
+ redirectLink.href = response.redirectUrl;
+ redirectLink.id = 'renew-tokens-redirect-url';
+ document.body.appendChild(redirectLink);
+ }
+ }
}
});
diff --git a/e2e/oidc-suites/playwright.config.ts b/e2e/oidc-suites/playwright.config.ts
index c8cd917ed68..0a324049a6f 100644
--- a/e2e/oidc-suites/playwright.config.ts
+++ b/e2e/oidc-suites/playwright.config.ts
@@ -35,4 +35,6 @@ export default defineConfig({
reuseExistingServer: !process.env.CI,
cwd: workspaceRoot,
},
+ // RAR tests are ignored because they require a remote consent agent to be run through a cloudlfare tunnel
+ testIgnore: ['**/rar.spec.ts', '**/rar-par.spec.ts'],
});
diff --git a/e2e/oidc-suites/src/par.spec.ts b/e2e/oidc-suites/src/par.spec.ts
index 8d618d449da..a73a6896dee 100644
--- a/e2e/oidc-suites/src/par.spec.ts
+++ b/e2e/oidc-suites/src/par.spec.ts
@@ -11,7 +11,9 @@ import { expect, test } from '@playwright/test';
import { asyncEvents } from './utils/async-events.js';
import { pingAmPassword, pingAmUsername } from './utils/demo-users.js';
-async function loginJourney(page, username: string, password: string) {
+import type { Page } from '@playwright/test';
+
+async function loginJourney(page: Page, username: string, password: string) {
await page.getByLabel('User Name').fill(username);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Login (Journey)' }).click();
diff --git a/e2e/oidc-suites/src/rar-par.spec.ts b/e2e/oidc-suites/src/rar-par.spec.ts
new file mode 100644
index 00000000000..a8c930a4f73
--- /dev/null
+++ b/e2e/oidc-suites/src/rar-par.spec.ts
@@ -0,0 +1,85 @@
+/*
+ *
+ * Copyright 2026 Ping Identity Corporation. All right reserved.
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ *
+ */
+import { expect, test } from '@playwright/test';
+
+import { asyncEvents } from './utils/async-events.js';
+import { pingAmPassword, pingAmUsername } from './utils/demo-users.js';
+
+import type { Page } from '@playwright/test';
+
+const authorizationDetails = [
+ {
+ type: 'account_information',
+ actions: ['list_accounts', 'read_balances'],
+ locations: ['https://example.com/accounts'],
+ datatypes: ['balances'],
+ },
+];
+
+async function rarParFlow(buttonName: string, page: Page) {
+ const { clickWithRedirect } = asyncEvents(page);
+
+ await page.getByRole('button', { name: buttonName }).click();
+
+ // Token renewal doesn't automatically redirect on interaction errors so click the link manually
+ if (buttonName === 'Renew Tokens') {
+ await page.getByRole('link', { name: 'Redirect Link' }).click();
+ }
+
+ if (buttonName !== 'Login (Background — PAR + RAR)') {
+ await expect(await page.getByRole('heading', { name: 'Sign In' })).toBeVisible();
+ await page.getByLabel('User Name').fill(pingAmUsername);
+ await page.getByRole('textbox', { name: 'Password' }).fill(pingAmPassword);
+ await page.getByRole('button', { name: 'Next' }).click();
+ }
+
+ await page.getByRole('heading', { name: 'Consent Request' }).click();
+ expect(page.getByText(JSON.stringify(authorizationDetails))).toBeDefined();
+ await page.getByRole('button', { name: 'Next' }).click();
+
+ await page.getByRole('heading', { name: 'Consent Response' }).click();
+ expect(page.getByText(JSON.stringify(authorizationDetails))).toBeDefined();
+ const tokenResponsePromise = page.waitForResponse('**/access_token');
+ await clickWithRedirect('Continue', 'http://localhost:8443/rar-par/**');
+
+ expect(page.url()).toContain('http://localhost:8443/rar-par');
+ expect(page.url()).toContain('code=');
+ expect(page.url()).toContain('state=');
+ await expect(page.locator('#accessToken-0')).not.toBeEmpty();
+
+ const response = await tokenResponsePromise;
+ const tokenResponse = await response.json();
+ await expect(tokenResponse?.authorization_details).toEqual(authorizationDetails);
+}
+
+test.describe('Rich Authorization Request (RAR) tests with PAR', () => {
+ test('redirect-based auth with RAR + PAR obtains access token', async ({ page }) => {
+ const { navigate } = asyncEvents(page);
+ await navigate('/rar-par/');
+ await rarParFlow('Login (Redirect — PAR + RAR)', page);
+ });
+
+ test('background auth with RAR + PAR obtains access token', async ({ page }) => {
+ const { navigate } = asyncEvents(page);
+ await navigate('/rar-par/');
+
+ await page.getByRole('textbox', { name: 'User Name' }).fill(pingAmUsername);
+ await page.getByRole('textbox', { name: 'Password' }).fill(pingAmPassword);
+ await page.getByRole('button', { name: 'Login (Journey)' }).click();
+ await expect(page.getByText('Session established')).toBeVisible();
+
+ await rarParFlow('Login (Background — PAR + RAR)', page);
+ });
+
+ test('token renewal with RAR + PAR obtains access token', async ({ page }) => {
+ const { navigate } = asyncEvents(page);
+ await navigate('/rar-par/');
+ await rarParFlow('Renew Tokens', page);
+ });
+});
diff --git a/e2e/oidc-suites/src/rar.spec.ts b/e2e/oidc-suites/src/rar.spec.ts
new file mode 100644
index 00000000000..836ef690c2b
--- /dev/null
+++ b/e2e/oidc-suites/src/rar.spec.ts
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2026 Ping Identity Corporation. All right reserved.
+ *
+ * This software may be modified and distributed under the terms
+ * of the MIT license. See the LICENSE file for details.
+ *
+ */
+import { expect, test } from '@playwright/test';
+
+import { asyncEvents } from './utils/async-events.js';
+import { pingAmPassword, pingAmUsername } from './utils/demo-users.js';
+
+import type { Page } from '@playwright/test';
+
+const authorizationDetails = [
+ {
+ type: 'account_information',
+ actions: ['list_accounts', 'read_balances'],
+ locations: ['https://example.com/accounts'],
+ datatypes: ['balances'],
+ },
+];
+
+async function rarFlow(buttonName: string, page: Page) {
+ const { navigate, clickWithRedirect } = asyncEvents(page);
+
+ await navigate('/rar/');
+
+ await page.getByRole('button', { name: buttonName }).click();
+
+ // Token renewal doesn't automatically redirect on interaction errors so click the link manually
+ if (buttonName === 'Renew Tokens') {
+ await page.getByRole('link', { name: 'Redirect Link' }).click();
+ }
+
+ await page.getByLabel('User Name').fill(pingAmUsername);
+ await page.getByRole('textbox', { name: 'Password' }).fill(pingAmPassword);
+ await page.getByRole('button', { name: 'Next' }).click();
+
+ await page.getByRole('heading', { name: 'Consent Request' }).click();
+ expect(page.getByText(JSON.stringify(authorizationDetails))).toBeDefined();
+ await page.getByRole('button', { name: 'Next' }).click();
+
+ await page.getByRole('heading', { name: 'Consent Response' }).click();
+ expect(page.getByText(JSON.stringify(authorizationDetails))).toBeDefined();
+ const tokenResponsePromise = page.waitForResponse('**/access_token');
+ await clickWithRedirect('Continue', 'http://localhost:8443/rar/**');
+
+ expect(page.url()).toContain('http://localhost:8443/rar');
+ expect(page.url()).toContain('code=');
+ expect(page.url()).toContain('state=');
+ await expect(page.locator('#accessToken-0')).not.toBeEmpty();
+
+ const response = await tokenResponsePromise;
+ const tokenResponse = await response.json();
+ await expect(tokenResponse?.authorization_details).toEqual(authorizationDetails);
+}
+
+test.describe('Rich Authorization Request (RAR) tests (no PAR)', () => {
+ test('redirect-based auth with RAR obtains access token', async ({ page }) => {
+ await rarFlow('Login (Redirect)', page);
+ });
+
+ test('background auth with RAR obtains access token', async ({ page }) => {
+ await rarFlow('Login (Background)', page);
+ });
+
+ test('token renewal with RAR obtains access token', async ({ page }) => {
+ await rarFlow('Renew Tokens', page);
+ });
+});
diff --git a/packages/oidc-client/README.md b/packages/oidc-client/README.md
index 4119d84729e..cc276ef20f8 100644
--- a/packages/oidc-client/README.md
+++ b/packages/oidc-client/README.md
@@ -18,6 +18,8 @@ The oidc module follows the [OIDC](https://openid.net/specs/openid-connect-core-
- [Redirect-Based Login](#redirect-based-login-authorizeurl)
- [Background Authorization](#background-authorization-authorizebackground)
- [Automatic Token Renewal](#automatic-token-renewal)
+ - [Pushed Authorization Requests (PAR)](#pushed-authorization-requests-par)
+ - [Rich Authorization Requests (RAR)](#rich-authorization-requests-rar)
- [Error Handling](#error-handling)
## Installation
@@ -57,7 +59,10 @@ The `oidc()` initialization function accepts the following configuration:
- **scope** (required) - Space-separated list of requested scopes (e.g., `'openid profile email'`)
- **storage** (optional) - Storage configuration for tokens (defaults to localStorage)
- **timeout** (optional) - Request timeout in milliseconds
-- **additionalParameters** (optional) - Additional parameters to include in authorization requests
+- **par** (optional) - Use Pushed Authorization Requests (PAR) for the authorization flow; omitted auto-detects from the server's well-known configuration (see [Pushed Authorization Requests (PAR)](#pushed-authorization-requests-par))
+- **authorizationDetails** (optional) - Use Rich Authorization Requests (RAR) for the authorization flow. See [Rich Authorization Requests (RAR)](#rich-authorization-requests-rar).
+
+See `OidcConfig` interface for the full list of options.
## Quick Start
@@ -330,6 +335,98 @@ if ('error' in tokens) {
}
```
+### Pushed Authorization Requests (PAR)
+
+The client supports [Pushed Authorization Requests](https://datatracker.ietf.org/doc/html/rfc9126) (PAR, RFC 9126), an OAuth 2.0 extension that hardens the authorization flow.
+
+In a standard flow, all authorization parameters (`redirect_uri`, `scope`, PKCE `code_challenge`, `state`, and so on) are packed into the authorize URL and pass through the browser. With PAR, the client first POSTs those parameters directly to the server's PAR endpoint, receives a short-lived `request_uri`, and then sends the browser to the authorization endpoint with only `client_id` and `request_uri` in the URL:
+
+**Enabling PAR**
+
+PAR is enabled with the `par` configuration option:
+
+```js
+const config = {
+ serverConfig: { wellknown: 'https://example.com/.well-known/openid-configuration' },
+ clientId: 'example-client-id',
+ redirectUri: 'https://example-app/redirect-uri',
+ scope: 'openid profile email',
+ par: true,
+};
+```
+
+How it resolves:
+
+- `par: true` — always use PAR
+- `par: false` — never use PAR; OIDC Client initialization fails if the server's well-known configuration advertises `require_pushed_authorization_requests: true`
+- `par` omitted — PAR is used automatically when the server requires it, otherwise the standard flow is used
+
+Both `authorize.url()` and `authorize.background()` respect this setting. The `request_uri` is single-use and short-lived (typically 30–90 seconds), so the authorize navigation must complete before it expires.
+
+### Rich Authorization Requests (RAR)
+
+The client supports [Rich Authorization Requests](https://datatracker.ietf.org/doc/html/rfc9396) (RAR, RFC 9396), an OAuth 2.0 extension that lets the client request fine-grained, transaction-specific authorization instead of just scopes. Details are sent as the `authorization_details` request parameter — a JSON array describing _what_ the client wants to do rather than a coarse scope string.
+
+Each detail object has a `type` string defined by the authorization server, plus the standard fields `locations`, `actions`, `datatypes`, and `privileges`. Type-specific fields the SDK doesn't model go in `additionalFields`, whose entries are flattened onto the object before the request is sent.
+
+**Declaring authorization details**
+
+Details can be set at initialization, so they apply to every authorization request the client makes:
+
+```js
+const config = {
+ serverConfig: { wellknown: 'https://example.com/.well-known/openid-configuration' },
+ clientId: 'example-client-id',
+ redirectUri: 'https://example-app/redirect-uri',
+ scope: 'openid profile email',
+ authorizationDetails: [
+ {
+ type: 'payment_initiation',
+ actions: ['initiate', 'status'],
+ locations: ['https://example.com/payments'],
+ instructedAmount: { currency: 'EUR', amount: '123.50' },
+ creditorName: 'Merchant A',
+ },
+ ],
+};
+```
+
+Type-specific fields like `instructedAmount` and `creditorName` can be passed through `additionalFields`:
+
+```js
+const config = {
+ // ...other options
+ authorizationDetails: [
+ {
+ type: 'payment_initiation',
+ actions: ['initiate', 'status'],
+ locations: ['https://example.com/payments'],
+ additionalFields: {
+ instructedAmount: { currency: 'EUR', amount: '123.50' },
+ creditorName: 'Merchant A',
+ },
+ },
+ ],
+};
+```
+
+Authorization details can alternatively be supplied per call, which overrides the OIDC Client configuration for that request:
+
+```js
+const authResponse = await oidcClient.authorize.background({
+ authorizationDetails: [
+ {
+ type: 'account_information',
+ actions: ['list', 'read'],
+ locations: ['https://example.com/accounts'],
+ datatypes: ['balances', 'transactions'],
+ },
+ ],
+});
+```
+
+Details are serialized to JSON for the `authorization_details` parameter and are included in both the standard flow and the pushed (PAR) request body. Server support for RAR is required; consult your authorization server's documentation for the detail `type` values and fields it accepts.
+
### Error Handling
The library uses a consistent error handling pattern. All methods return either a success response or an error object. Check if the response contains an `error` property:
diff --git a/packages/oidc-client/api-report/oidc-client.api.md b/packages/oidc-client/api-report/oidc-client.api.md
index eab099abcbb..2f580283c87 100644
--- a/packages/oidc-client/api-report/oidc-client.api.md
+++ b/packages/oidc-client/api-report/oidc-client.api.md
@@ -1,428 +1,675 @@
-## API Report File for "@forgerock/oidc-client"
-
-> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
-
-```ts
-
-import { ActionTypes } from '@forgerock/sdk-request-middleware';
-import { BaseQueryFn } from '@reduxjs/toolkit/query';
-import { BrowserStorageConfig } from '@forgerock/storage';
-import { CombinedState } from '@reduxjs/toolkit/query';
-import { CustomLogger } from '@forgerock/sdk-logger';
-import { CustomStorageConfig } from '@forgerock/storage';
-import { CustomStorageObject } from '@forgerock/sdk-types';
-import { EnhancedStore } from '@reduxjs/toolkit';
-import { FetchArgs } from '@reduxjs/toolkit/query';
-import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
-import { FetchBaseQueryMeta } from '@reduxjs/toolkit/query';
-import { GenericError } from '@forgerock/sdk-types';
-import { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
-import type { JWTPayload } from 'jose';
-import type { logger } from '@forgerock/sdk-logger';
-import { LogLevel } from '@forgerock/sdk-logger';
-import { LogMessage } from '@forgerock/sdk-logger';
-import { makeOidcConfig } from '@forgerock/sdk-utilities';
-import { MutationDefinition } from '@reduxjs/toolkit/query';
-import { OidcConfig } from '@forgerock/sdk-types';
-import { QueryDefinition } from '@reduxjs/toolkit/query';
-import { RequestMiddleware } from '@forgerock/sdk-request-middleware';
-import { ResponseType as ResponseType_2 } from '@forgerock/sdk-types';
-import { StorageConfig } from '@forgerock/storage';
-import { StoreEnhancer } from '@reduxjs/toolkit';
-import { ThunkDispatch } from '@reduxjs/toolkit';
-import { Tuple } from '@reduxjs/toolkit';
-import { UnknownAction } from '@reduxjs/toolkit';
-import { Unsubscribe } from '@reduxjs/toolkit';
-import { WellknownResponse } from '@forgerock/sdk-types';
-
-export { ActionTypes }
-
-// @public (undocumented)
-export type AppDispatch = ReturnType;
-
-// @public (undocumented)
-export interface AuthorizationError {
- // (undocumented)
- error: string;
- // (undocumented)
- error_description: string;
- // (undocumented)
- redirectUrl?: string;
- // (undocumented)
- type: 'auth_error' | 'argument_error' | 'network_error' | 'unknown_error' | 'wellknown_error';
-}
-
-// @public (undocumented)
-export interface AuthorizationSuccess {
- // (undocumented)
- code: string;
- // (undocumented)
- state: string;
-}
-
-// @public (undocumented)
-export interface AuthorizeErrorResponse {
- // (undocumented)
- code?: string;
- // (undocumented)
- details?: [
- {
- code: string;
- message: string;
- }
- ];
- // (undocumented)
- id?: string;
- // (undocumented)
- message?: string;
-}
-
-// @public (undocumented)
-export interface AuthorizeSuccessResponse {
- // (undocumented)
- authorizeResponse?: {
- code: string;
- state: string;
- };
- // (undocumented)
- createdAt?: string;
- // (undocumented)
- _embedded?: {
- [key: string]: unknown;
- };
- // (undocumented)
- environment?: {
- id: string;
- };
- // (undocumented)
- expiresAt?: string;
- // (undocumented)
- id?: string;
- // (undocumented)
- _links?: {
- [key: string]: {
- href: string;
- };
- };
- // (undocumented)
- resumeUrl?: string;
- // (undocumented)
- session?: {
- id: string;
- };
- // (undocumented)
- status?: string;
-}
-
-export { BrowserStorageConfig }
-
-// @public (undocumented)
-export type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
-
-// @public (undocumented)
-export type ClientStore = ReturnType;
-
-// @public
-export function createClientStore(input: {
- requestMiddleware?: RequestMiddleware[];
- logger?: ReturnType;
-}): EnhancedStore< {
-oidc: CombinedState< {
-authorizeFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizeSuccessResponse, "oidc", unknown>;
-par: MutationDefinition< {
-endpoint: string;
-body: URLSearchParams;
-}, BaseQueryFn, never, PushAuthorizationResponse, "oidc", unknown>;
-sessionCheckIframe: MutationDefinition< {
-url: string;
-responseType: SessionCheckResponseType;
-}, BaseQueryFn, never, {
-params: Record;
-}, "oidc", unknown>;
-sessionCheckFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, {
-status: 204;
-}, "oidc", unknown>;
-authorizeIframe: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizationSuccess, "oidc", unknown>;
-endSession: MutationDefinition< {
-idToken: string;
-endpoint: string;
-signOutRedirectUri?: string;
-}, BaseQueryFn, never, null, "oidc", unknown>;
-exchange: MutationDefinition< {
-code: string;
-config: OidcConfig;
-endpoint: string;
-verifier?: string;
-}, BaseQueryFn, never, TokenExchangeResponse, "oidc", unknown>;
-revoke: MutationDefinition< {
-accessToken: string;
-clientId?: string;
-endpoint: string;
-}, BaseQueryFn, never, object, "oidc", unknown>;
-userInfo: MutationDefinition< {
-accessToken: string;
-endpoint: string;
-}, BaseQueryFn, never, UserInfoResponse, "oidc", unknown>;
-}, never, "oidc">;
-wellknown: CombinedState< {
-configuration: QueryDefinition, never, WellknownResponse, "wellknown", unknown>;
-}, never, "wellknown">;
-}, UnknownAction, Tuple<[StoreEnhancer< {
-dispatch: ThunkDispatch< {
-oidc: CombinedState< {
-authorizeFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizeSuccessResponse, "oidc", unknown>;
-par: MutationDefinition< {
-endpoint: string;
-body: URLSearchParams;
-}, BaseQueryFn, never, PushAuthorizationResponse, "oidc", unknown>;
-sessionCheckIframe: MutationDefinition< {
-url: string;
-responseType: SessionCheckResponseType;
-}, BaseQueryFn, never, {
-params: Record;
-}, "oidc", unknown>;
-sessionCheckFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, {
-status: 204;
-}, "oidc", unknown>;
-authorizeIframe: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizationSuccess, "oidc", unknown>;
-endSession: MutationDefinition< {
-idToken: string;
-endpoint: string;
-signOutRedirectUri?: string;
-}, BaseQueryFn, never, null, "oidc", unknown>;
-exchange: MutationDefinition< {
-code: string;
-config: OidcConfig;
-endpoint: string;
-verifier?: string;
-}, BaseQueryFn, never, TokenExchangeResponse, "oidc", unknown>;
-revoke: MutationDefinition< {
-accessToken: string;
-clientId?: string;
-endpoint: string;
-}, BaseQueryFn, never, object, "oidc", unknown>;
-userInfo: MutationDefinition< {
-accessToken: string;
-endpoint: string;
-}, BaseQueryFn, never, UserInfoResponse, "oidc", unknown>;
-}, never, "oidc">;
-wellknown: CombinedState< {
-configuration: QueryDefinition, never, WellknownResponse, "wellknown", unknown>;
-}, never, "wellknown">;
-}, {
-requestMiddleware: RequestMiddleware[] | undefined;
-logger: {
-changeLevel: (level: LogLevel) => void;
-error: (...args: LogMessage[]) => void;
-warn: (...args: LogMessage[]) => void;
-info: (...args: LogMessage[]) => void;
-debug: (...args: LogMessage[]) => void;
-} | undefined;
-}, UnknownAction>;
-}>, StoreEnhancer]>>;
-
-export { CustomLogger }
-
-export { CustomStorageConfig }
-
-export { CustomStorageObject }
-
-export { GenericError }
-
-export { GetAuthorizationUrlOptions }
-
-// @public (undocumented)
-export interface GetTokensOptions {
- // (undocumented)
- authorizeOptions?: GetAuthorizationUrlOptions;
- // (undocumented)
- backgroundRenew?: boolean;
- // (undocumented)
- forceRenew?: boolean;
- // (undocumented)
- storageOptions?: Partial;
-}
-
-export { LogLevel }
-
-// @public (undocumented)
-export type LogoutErrorResult = {
- error: string;
- sessionResponse: GenericError | null;
- revokeResponse: GenericError | null;
- deleteResponse: GenericError | null;
-};
-
-// @public (undocumented)
-export type LogoutSuccessResult = RevokeSuccessResult & {
- sessionResponse: null;
-};
-
-export { makeOidcConfig }
-
-// @public (undocumented)
-export interface OauthTokens {
- // (undocumented)
- accessToken: string;
- // (undocumented)
- expiresAt?: number;
- // (undocumented)
- expiryTimestamp?: number;
- // (undocumented)
- idToken: string;
- // (undocumented)
- refreshToken?: string;
-}
-
-// @public
-export function oidc(input: {
- config: OidcConfig;
- requestMiddleware?: RequestMiddleware[];
- logger?: {
- level: LogLevel;
- custom?: CustomLogger;
- };
- storage?: Partial;
-}): Promise<{
- error: string;
- type: string;
- subscribe?: undefined;
- authorize?: undefined;
- token?: undefined;
- user?: undefined;
-} | {
- subscribe: (listener: () => void) => Unsubscribe;
- authorize: {
- url: (options?: GetAuthorizationUrlOptions) => Promise;
- background: (options?: GetAuthorizationUrlOptions) => Promise;
- };
- token: {
- exchange: (code: string, state: string, options?: Partial) => Promise;
- get: (options?: GetTokensOptions) => Promise;
- revoke: () => Promise;
- };
- user: {
- info: () => Promise;
- logout: () => Promise;
- session: (options?: SessionCheckOptions) => Promise;
- };
- error?: undefined;
- type?: undefined;
-}>;
-
-// @public (undocumented)
-export type OidcClient = Awaited>;
-
-export { OidcConfig }
-
-// @public (undocumented)
-export type OptionalAuthorizeOptions = Partial;
-
-// @public (undocumented)
-export interface PushAuthorizationResponse {
- // (undocumented)
- expires_in: number;
- // (undocumented)
- request_uri: string;
-}
-
-export { RequestMiddleware }
-
-export { ResponseType_2 as ResponseType }
-
-// @public (undocumented)
-export type RevokeErrorResult = {
- error: string;
- revokeResponse: GenericError | null;
- deleteResponse: GenericError | null;
-};
-
-// @public (undocumented)
-export type RevokeSuccessResult = {
- revokeResponse: null;
- deleteResponse: null;
-};
-
-// @public (undocumented)
-export type RootState = ReturnType;
-
-// @public
-export interface SessionCheckOptions {
- redirectUri?: string;
- responseType?: SessionCheckResponseType;
- scope?: string;
- subject?: string;
-}
-
-// @public (undocumented)
-export type SessionCheckResponseType = 'id_token' | 'none';
-
-// @public (undocumented)
-export type SessionCheckSuccess = {
- responseType: SessionCheckResponseType;
- claims?: JWTPayload;
-};
-
-export { StorageConfig }
-
-// @public (undocumented)
-export interface TokenExchangeErrorResponse {
- // (undocumented)
- error: string;
- // (undocumented)
- message: string;
- // (undocumented)
- type: 'exchange_error' | 'network_error' | 'state_error' | 'unknown_error';
-}
-
-// @public (undocumented)
-export interface TokenExchangeResponse {
- // (undocumented)
- access_token: string;
- // (undocumented)
- expires_in?: number;
- // (undocumented)
- id_token: string;
- // (undocumented)
- refresh_token?: string;
- // (undocumented)
- scope?: string;
- // (undocumented)
- token_type?: string;
-}
-
-// @public (undocumented)
-export interface TokenRequestOptions {
- // (undocumented)
- code: string;
- // (undocumented)
- config: OidcConfig;
- // (undocumented)
- endpoint: string;
- // (undocumented)
- verifier?: string;
-}
-
-// @public (undocumented)
-export type UserInfoResponse = {
- sub: string;
- [key: string]: unknown;
-};
-
-export { WellknownResponse }
-
-// (No @packageDocumentation comment for this package)
-
-```
+## API Report File for "@forgerock/oidc-client"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+import { ActionTypes } from '@forgerock/sdk-request-middleware';
+import { AuthorizationDetail } from '@forgerock/sdk-types';
+import { BaseQueryFn } from '@reduxjs/toolkit/query';
+import { BrowserStorageConfig } from '@forgerock/storage';
+import { CombinedState } from '@reduxjs/toolkit/query';
+import { CustomLogger } from '@forgerock/sdk-logger';
+import { CustomStorageConfig } from '@forgerock/storage';
+import { CustomStorageObject } from '@forgerock/sdk-types';
+import { EnhancedStore } from '@reduxjs/toolkit';
+import { FetchArgs } from '@reduxjs/toolkit/query';
+import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
+import { FetchBaseQueryMeta } from '@reduxjs/toolkit/query';
+import { GenericError } from '@forgerock/sdk-types';
+import { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
+import type { JWTPayload } from 'jose';
+import type { logger } from '@forgerock/sdk-logger';
+import { LogLevel } from '@forgerock/sdk-logger';
+import { LogMessage } from '@forgerock/sdk-logger';
+import { makeOidcConfig } from '@forgerock/sdk-utilities';
+import { MutationDefinition } from '@reduxjs/toolkit/query';
+import { OidcConfig } from '@forgerock/sdk-types';
+import { QueryDefinition } from '@reduxjs/toolkit/query';
+import { RequestMiddleware } from '@forgerock/sdk-request-middleware';
+import { ResponseType as ResponseType_2 } from '@forgerock/sdk-types';
+import { StorageConfig } from '@forgerock/storage';
+import { StoreEnhancer } from '@reduxjs/toolkit';
+import { ThunkDispatch } from '@reduxjs/toolkit';
+import { Tuple } from '@reduxjs/toolkit';
+import { UnknownAction } from '@reduxjs/toolkit';
+import { Unsubscribe } from '@reduxjs/toolkit';
+import { WellknownResponse } from '@forgerock/sdk-types';
+
+export { ActionTypes };
+
+// @public (undocumented)
+export type AppDispatch = ReturnType;
+
+export { AuthorizationDetail };
+
+// @public (undocumented)
+export interface AuthorizationError {
+ // (undocumented)
+ error: string;
+ // (undocumented)
+ error_description: string;
+ // (undocumented)
+ redirectUrl?: string;
+ // (undocumented)
+ type: 'auth_error' | 'argument_error' | 'network_error' | 'unknown_error' | 'wellknown_error';
+}
+
+// @public (undocumented)
+export interface AuthorizationSuccess {
+ // (undocumented)
+ code: string;
+ // (undocumented)
+ state: string;
+}
+
+// @public (undocumented)
+export interface AuthorizeErrorResponse {
+ // (undocumented)
+ code?: string;
+ // (undocumented)
+ details?: [
+ {
+ code: string;
+ message: string;
+ },
+ ];
+ // (undocumented)
+ id?: string;
+ // (undocumented)
+ message?: string;
+}
+
+// @public (undocumented)
+export interface AuthorizeSuccessResponse {
+ // (undocumented)
+ authorizeResponse?: {
+ code: string;
+ state: string;
+ };
+ // (undocumented)
+ createdAt?: string;
+ // (undocumented)
+ _embedded?: {
+ [key: string]: unknown;
+ };
+ // (undocumented)
+ environment?: {
+ id: string;
+ };
+ // (undocumented)
+ expiresAt?: string;
+ // (undocumented)
+ id?: string;
+ // (undocumented)
+ _links?: {
+ [key: string]: {
+ href: string;
+ };
+ };
+ // (undocumented)
+ resumeUrl?: string;
+ // (undocumented)
+ session?: {
+ id: string;
+ };
+ // (undocumented)
+ status?: string;
+}
+
+export { BrowserStorageConfig };
+
+// @public (undocumented)
+export type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
+
+// @public (undocumented)
+export type ClientStore = ReturnType;
+
+// @public
+export function createClientStore(input: {
+ requestMiddleware?: RequestMiddleware[];
+ logger?: ReturnType;
+}): EnhancedStore<
+ {
+ oidc: CombinedState<
+ {
+ authorizeFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ AuthorizeSuccessResponse,
+ 'oidc',
+ unknown
+ >;
+ par: MutationDefinition<
+ {
+ endpoint: string;
+ body: URLSearchParams;
+ },
+ BaseQueryFn,
+ never,
+ PushAuthorizationResponse,
+ 'oidc',
+ unknown
+ >;
+ sessionCheckIframe: MutationDefinition<
+ {
+ url: string;
+ responseType: SessionCheckResponseType;
+ },
+ BaseQueryFn,
+ never,
+ {
+ params: Record;
+ },
+ 'oidc',
+ unknown
+ >;
+ sessionCheckFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ {
+ status: 204;
+ },
+ 'oidc',
+ unknown
+ >;
+ authorizeIframe: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ AuthorizationSuccess,
+ 'oidc',
+ unknown
+ >;
+ endSession: MutationDefinition<
+ {
+ idToken: string;
+ endpoint: string;
+ signOutRedirectUri?: string;
+ },
+ BaseQueryFn,
+ never,
+ null,
+ 'oidc',
+ unknown
+ >;
+ exchange: MutationDefinition<
+ {
+ code: string;
+ config: OidcConfig;
+ endpoint: string;
+ verifier?: string;
+ },
+ BaseQueryFn,
+ never,
+ TokenExchangeResponse,
+ 'oidc',
+ unknown
+ >;
+ revoke: MutationDefinition<
+ {
+ accessToken: string;
+ clientId?: string;
+ endpoint: string;
+ },
+ BaseQueryFn,
+ never,
+ object,
+ 'oidc',
+ unknown
+ >;
+ userInfo: MutationDefinition<
+ {
+ accessToken: string;
+ endpoint: string;
+ },
+ BaseQueryFn,
+ never,
+ UserInfoResponse,
+ 'oidc',
+ unknown
+ >;
+ },
+ never,
+ 'oidc'
+ >;
+ wellknown: CombinedState<
+ {
+ configuration: QueryDefinition<
+ string,
+ BaseQueryFn,
+ never,
+ WellknownResponse,
+ 'wellknown',
+ unknown
+ >;
+ },
+ never,
+ 'wellknown'
+ >;
+ },
+ UnknownAction,
+ Tuple<
+ [
+ StoreEnhancer<{
+ dispatch: ThunkDispatch<
+ {
+ oidc: CombinedState<
+ {
+ authorizeFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ AuthorizeSuccessResponse,
+ 'oidc',
+ unknown
+ >;
+ par: MutationDefinition<
+ {
+ endpoint: string;
+ body: URLSearchParams;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ PushAuthorizationResponse,
+ 'oidc',
+ unknown
+ >;
+ sessionCheckIframe: MutationDefinition<
+ {
+ url: string;
+ responseType: SessionCheckResponseType;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ {
+ params: Record;
+ },
+ 'oidc',
+ unknown
+ >;
+ sessionCheckFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ {
+ status: 204;
+ },
+ 'oidc',
+ unknown
+ >;
+ authorizeIframe: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ AuthorizationSuccess,
+ 'oidc',
+ unknown
+ >;
+ endSession: MutationDefinition<
+ {
+ idToken: string;
+ endpoint: string;
+ signOutRedirectUri?: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ null,
+ 'oidc',
+ unknown
+ >;
+ exchange: MutationDefinition<
+ {
+ code: string;
+ config: OidcConfig;
+ endpoint: string;
+ verifier?: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ TokenExchangeResponse,
+ 'oidc',
+ unknown
+ >;
+ revoke: MutationDefinition<
+ {
+ accessToken: string;
+ clientId?: string;
+ endpoint: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ object,
+ 'oidc',
+ unknown
+ >;
+ userInfo: MutationDefinition<
+ {
+ accessToken: string;
+ endpoint: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ UserInfoResponse,
+ 'oidc',
+ unknown
+ >;
+ },
+ never,
+ 'oidc'
+ >;
+ wellknown: CombinedState<
+ {
+ configuration: QueryDefinition<
+ string,
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ WellknownResponse,
+ 'wellknown',
+ unknown
+ >;
+ },
+ never,
+ 'wellknown'
+ >;
+ },
+ {
+ requestMiddleware: RequestMiddleware[] | undefined;
+ logger:
+ | {
+ changeLevel: (level: LogLevel) => void;
+ error: (...args: LogMessage[]) => void;
+ warn: (...args: LogMessage[]) => void;
+ info: (...args: LogMessage[]) => void;
+ debug: (...args: LogMessage[]) => void;
+ }
+ | undefined;
+ },
+ UnknownAction
+ >;
+ }>,
+ StoreEnhancer,
+ ]
+ >
+>;
+
+export { CustomLogger };
+
+export { CustomStorageConfig };
+
+export { CustomStorageObject };
+
+export { GenericError };
+
+export { GetAuthorizationUrlOptions };
+
+// @public (undocumented)
+export interface GetTokensOptions {
+ // (undocumented)
+ authorizeOptions?: GetAuthorizationUrlOptions;
+ // (undocumented)
+ backgroundRenew?: boolean;
+ // (undocumented)
+ forceRenew?: boolean;
+ // (undocumented)
+ storageOptions?: Partial;
+}
+
+export { LogLevel };
+
+// @public (undocumented)
+export type LogoutErrorResult = {
+ error: string;
+ sessionResponse: GenericError | null;
+ revokeResponse: GenericError | null;
+ deleteResponse: GenericError | null;
+};
+
+// @public (undocumented)
+export type LogoutSuccessResult = RevokeSuccessResult & {
+ sessionResponse: null;
+};
+
+export { makeOidcConfig };
+
+// @public (undocumented)
+export interface OauthTokens {
+ // (undocumented)
+ accessToken: string;
+ // (undocumented)
+ authorizationDetails?: AuthorizationDetail[];
+ // (undocumented)
+ expiresAt?: number;
+ // (undocumented)
+ expiryTimestamp?: number;
+ // (undocumented)
+ idToken: string;
+ // (undocumented)
+ refreshToken?: string;
+}
+
+// @public
+export function oidc(input: {
+ config: OidcConfig;
+ requestMiddleware?: RequestMiddleware[];
+ logger?: {
+ level: LogLevel;
+ custom?: CustomLogger;
+ };
+ storage?: Partial;
+}): Promise<
+ | {
+ error: string;
+ type: string;
+ subscribe?: undefined;
+ authorize?: undefined;
+ token?: undefined;
+ user?: undefined;
+ }
+ | {
+ subscribe: (listener: () => void) => Unsubscribe;
+ authorize: {
+ url: (options?: GetAuthorizationUrlOptions) => Promise;
+ background: (
+ options?: GetAuthorizationUrlOptions,
+ ) => Promise;
+ };
+ token: {
+ exchange: (
+ code: string,
+ state: string,
+ options?: Partial,
+ ) => Promise;
+ get: (
+ options?: GetTokensOptions,
+ ) => Promise;
+ revoke: () => Promise;
+ };
+ user: {
+ info: () => Promise;
+ logout: () => Promise;
+ session: (options?: SessionCheckOptions) => Promise;
+ };
+ error?: undefined;
+ type?: undefined;
+ }
+>;
+
+// @public (undocumented)
+export type OidcClient = Awaited>;
+
+export { OidcConfig };
+
+// @public (undocumented)
+export type OptionalAuthorizeOptions = Partial;
+
+// @public (undocumented)
+export interface PushAuthorizationResponse {
+ // (undocumented)
+ expires_in: number;
+ // (undocumented)
+ request_uri: string;
+}
+
+export { RequestMiddleware };
+
+export { ResponseType_2 as ResponseType };
+
+// @public (undocumented)
+export type RevokeErrorResult = {
+ error: string;
+ revokeResponse: GenericError | null;
+ deleteResponse: GenericError | null;
+};
+
+// @public (undocumented)
+export type RevokeSuccessResult = {
+ revokeResponse: null;
+ deleteResponse: null;
+};
+
+// @public (undocumented)
+export type RootState = ReturnType;
+
+// @public
+export interface SessionCheckOptions {
+ redirectUri?: string;
+ responseType?: SessionCheckResponseType;
+ scope?: string;
+ subject?: string;
+}
+
+// @public (undocumented)
+export type SessionCheckResponseType = 'id_token' | 'none';
+
+// @public (undocumented)
+export type SessionCheckSuccess = {
+ responseType: SessionCheckResponseType;
+ claims?: JWTPayload;
+};
+
+export { StorageConfig };
+
+// @public (undocumented)
+export interface TokenExchangeErrorResponse {
+ // (undocumented)
+ error: string;
+ // (undocumented)
+ message: string;
+ // (undocumented)
+ type: 'exchange_error' | 'network_error' | 'state_error' | 'unknown_error';
+}
+
+// @public (undocumented)
+export interface TokenExchangeResponse {
+ // (undocumented)
+ access_token: string;
+ // (undocumented)
+ authorization_details?: AuthorizationDetail[];
+ // (undocumented)
+ expires_in?: number;
+ // (undocumented)
+ id_token: string;
+ // (undocumented)
+ refresh_token?: string;
+ // (undocumented)
+ scope?: string;
+ // (undocumented)
+ token_type?: string;
+}
+
+// @public (undocumented)
+export interface TokenRequestOptions {
+ // (undocumented)
+ code: string;
+ // (undocumented)
+ config: OidcConfig;
+ // (undocumented)
+ endpoint: string;
+ // (undocumented)
+ verifier?: string;
+}
+
+// @public (undocumented)
+export type UserInfoResponse = {
+ sub: string;
+ [key: string]: unknown;
+};
+
+export { WellknownResponse };
+
+// (No @packageDocumentation comment for this package)
+```
diff --git a/packages/oidc-client/api-report/oidc-client.types.api.md b/packages/oidc-client/api-report/oidc-client.types.api.md
index 807f66f83ff..7af46aac74e 100644
--- a/packages/oidc-client/api-report/oidc-client.types.api.md
+++ b/packages/oidc-client/api-report/oidc-client.types.api.md
@@ -1,425 +1,672 @@
-## API Report File for "@forgerock/oidc-client"
-
-> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
-
-```ts
-
-import { ActionTypes } from '@forgerock/sdk-request-middleware';
-import { BaseQueryFn } from '@reduxjs/toolkit/query';
-import { BrowserStorageConfig } from '@forgerock/storage';
-import { CombinedState } from '@reduxjs/toolkit/query';
-import { CustomLogger } from '@forgerock/sdk-logger';
-import { CustomStorageConfig } from '@forgerock/storage';
-import { CustomStorageObject } from '@forgerock/sdk-types';
-import { EnhancedStore } from '@reduxjs/toolkit';
-import { FetchArgs } from '@reduxjs/toolkit/query';
-import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
-import { FetchBaseQueryMeta } from '@reduxjs/toolkit/query';
-import { GenericError } from '@forgerock/sdk-types';
-import { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
-import type { JWTPayload } from 'jose';
-import type { logger } from '@forgerock/sdk-logger';
-import { LogLevel } from '@forgerock/sdk-logger';
-import { LogMessage } from '@forgerock/sdk-logger';
-import { MutationDefinition } from '@reduxjs/toolkit/query';
-import { OidcConfig } from '@forgerock/sdk-types';
-import { QueryDefinition } from '@reduxjs/toolkit/query';
-import { RequestMiddleware } from '@forgerock/sdk-request-middleware';
-import { ResponseType as ResponseType_2 } from '@forgerock/sdk-types';
-import { StorageConfig } from '@forgerock/storage';
-import { StoreEnhancer } from '@reduxjs/toolkit';
-import { ThunkDispatch } from '@reduxjs/toolkit';
-import { Tuple } from '@reduxjs/toolkit';
-import { UnknownAction } from '@reduxjs/toolkit';
-import { Unsubscribe } from '@reduxjs/toolkit';
-import { WellknownResponse } from '@forgerock/sdk-types';
-
-export { ActionTypes }
-
-// @public (undocumented)
-export type AppDispatch = ReturnType;
-
-// @public (undocumented)
-export interface AuthorizationError {
- // (undocumented)
- error: string;
- // (undocumented)
- error_description: string;
- // (undocumented)
- redirectUrl?: string;
- // (undocumented)
- type: 'auth_error' | 'argument_error' | 'network_error' | 'unknown_error' | 'wellknown_error';
-}
-
-// @public (undocumented)
-export interface AuthorizationSuccess {
- // (undocumented)
- code: string;
- // (undocumented)
- state: string;
-}
-
-// @public (undocumented)
-export interface AuthorizeErrorResponse {
- // (undocumented)
- code?: string;
- // (undocumented)
- details?: [
- {
- code: string;
- message: string;
- }
- ];
- // (undocumented)
- id?: string;
- // (undocumented)
- message?: string;
-}
-
-// @public (undocumented)
-export interface AuthorizeSuccessResponse {
- // (undocumented)
- authorizeResponse?: {
- code: string;
- state: string;
- };
- // (undocumented)
- createdAt?: string;
- // (undocumented)
- _embedded?: {
- [key: string]: unknown;
- };
- // (undocumented)
- environment?: {
- id: string;
- };
- // (undocumented)
- expiresAt?: string;
- // (undocumented)
- id?: string;
- // (undocumented)
- _links?: {
- [key: string]: {
- href: string;
- };
- };
- // (undocumented)
- resumeUrl?: string;
- // (undocumented)
- session?: {
- id: string;
- };
- // (undocumented)
- status?: string;
-}
-
-export { BrowserStorageConfig }
-
-// @public (undocumented)
-export type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
-
-// @public (undocumented)
-export type ClientStore = ReturnType;
-
-// @public
-export function createClientStore(input: {
- requestMiddleware?: RequestMiddleware[];
- logger?: ReturnType;
-}): EnhancedStore< {
-oidc: CombinedState< {
-authorizeFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizeSuccessResponse, "oidc", unknown>;
-par: MutationDefinition< {
-endpoint: string;
-body: URLSearchParams;
-}, BaseQueryFn, never, PushAuthorizationResponse, "oidc", unknown>;
-sessionCheckIframe: MutationDefinition< {
-url: string;
-responseType: SessionCheckResponseType;
-}, BaseQueryFn, never, {
-params: Record;
-}, "oidc", unknown>;
-sessionCheckFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, {
-status: 204;
-}, "oidc", unknown>;
-authorizeIframe: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizationSuccess, "oidc", unknown>;
-endSession: MutationDefinition< {
-idToken: string;
-endpoint: string;
-signOutRedirectUri?: string;
-}, BaseQueryFn, never, null, "oidc", unknown>;
-exchange: MutationDefinition< {
-code: string;
-config: OidcConfig;
-endpoint: string;
-verifier?: string;
-}, BaseQueryFn, never, TokenExchangeResponse, "oidc", unknown>;
-revoke: MutationDefinition< {
-accessToken: string;
-clientId?: string;
-endpoint: string;
-}, BaseQueryFn, never, object, "oidc", unknown>;
-userInfo: MutationDefinition< {
-accessToken: string;
-endpoint: string;
-}, BaseQueryFn, never, UserInfoResponse, "oidc", unknown>;
-}, never, "oidc">;
-wellknown: CombinedState< {
-configuration: QueryDefinition, never, WellknownResponse, "wellknown", unknown>;
-}, never, "wellknown">;
-}, UnknownAction, Tuple<[StoreEnhancer< {
-dispatch: ThunkDispatch< {
-oidc: CombinedState< {
-authorizeFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizeSuccessResponse, "oidc", unknown>;
-par: MutationDefinition< {
-endpoint: string;
-body: URLSearchParams;
-}, BaseQueryFn, never, PushAuthorizationResponse, "oidc", unknown>;
-sessionCheckIframe: MutationDefinition< {
-url: string;
-responseType: SessionCheckResponseType;
-}, BaseQueryFn, never, {
-params: Record;
-}, "oidc", unknown>;
-sessionCheckFetch: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, {
-status: 204;
-}, "oidc", unknown>;
-authorizeIframe: MutationDefinition< {
-url: string;
-}, BaseQueryFn, never, AuthorizationSuccess, "oidc", unknown>;
-endSession: MutationDefinition< {
-idToken: string;
-endpoint: string;
-signOutRedirectUri?: string;
-}, BaseQueryFn, never, null, "oidc", unknown>;
-exchange: MutationDefinition< {
-code: string;
-config: OidcConfig;
-endpoint: string;
-verifier?: string;
-}, BaseQueryFn, never, TokenExchangeResponse, "oidc", unknown>;
-revoke: MutationDefinition< {
-accessToken: string;
-clientId?: string;
-endpoint: string;
-}, BaseQueryFn, never, object, "oidc", unknown>;
-userInfo: MutationDefinition< {
-accessToken: string;
-endpoint: string;
-}, BaseQueryFn, never, UserInfoResponse, "oidc", unknown>;
-}, never, "oidc">;
-wellknown: CombinedState< {
-configuration: QueryDefinition, never, WellknownResponse, "wellknown", unknown>;
-}, never, "wellknown">;
-}, {
-requestMiddleware: RequestMiddleware[] | undefined;
-logger: {
-changeLevel: (level: LogLevel) => void;
-error: (...args: LogMessage[]) => void;
-warn: (...args: LogMessage[]) => void;
-info: (...args: LogMessage[]) => void;
-debug: (...args: LogMessage[]) => void;
-} | undefined;
-}, UnknownAction>;
-}>, StoreEnhancer]>>;
-
-export { CustomLogger }
-
-export { CustomStorageConfig }
-
-export { CustomStorageObject }
-
-export { GenericError }
-
-export { GetAuthorizationUrlOptions }
-
-// @public (undocumented)
-export interface GetTokensOptions {
- // (undocumented)
- authorizeOptions?: GetAuthorizationUrlOptions;
- // (undocumented)
- backgroundRenew?: boolean;
- // (undocumented)
- forceRenew?: boolean;
- // (undocumented)
- storageOptions?: Partial;
-}
-
-export { LogLevel }
-
-// @public (undocumented)
-export type LogoutErrorResult = {
- error: string;
- sessionResponse: GenericError | null;
- revokeResponse: GenericError | null;
- deleteResponse: GenericError | null;
-};
-
-// @public (undocumented)
-export type LogoutSuccessResult = RevokeSuccessResult & {
- sessionResponse: null;
-};
-
-// @public (undocumented)
-export interface OauthTokens {
- // (undocumented)
- accessToken: string;
- // (undocumented)
- expiresAt?: number;
- // (undocumented)
- expiryTimestamp?: number;
- // (undocumented)
- idToken: string;
- // (undocumented)
- refreshToken?: string;
-}
-
-// @public
-export function oidc(input: {
- config: OidcConfig;
- requestMiddleware?: RequestMiddleware[];
- logger?: {
- level: LogLevel;
- custom?: CustomLogger;
- };
- storage?: Partial;
-}): Promise<{
- error: string;
- type: string;
- subscribe?: undefined;
- authorize?: undefined;
- token?: undefined;
- user?: undefined;
-} | {
- subscribe: (listener: () => void) => Unsubscribe;
- authorize: {
- url: (options?: GetAuthorizationUrlOptions) => Promise;
- background: (options?: GetAuthorizationUrlOptions) => Promise;
- };
- token: {
- exchange: (code: string, state: string, options?: Partial) => Promise;
- get: (options?: GetTokensOptions) => Promise;
- revoke: () => Promise;
- };
- user: {
- info: () => Promise;
- logout: () => Promise;
- session: (options?: SessionCheckOptions) => Promise;
- };
- error?: undefined;
- type?: undefined;
-}>;
-
-// @public (undocumented)
-export type OidcClient = Awaited>;
-
-export { OidcConfig }
-
-// @public (undocumented)
-export type OptionalAuthorizeOptions = Partial;
-
-// @public (undocumented)
-export interface PushAuthorizationResponse {
- // (undocumented)
- expires_in: number;
- // (undocumented)
- request_uri: string;
-}
-
-export { RequestMiddleware }
-
-export { ResponseType_2 as ResponseType }
-
-// @public (undocumented)
-export type RevokeErrorResult = {
- error: string;
- revokeResponse: GenericError | null;
- deleteResponse: GenericError | null;
-};
-
-// @public (undocumented)
-export type RevokeSuccessResult = {
- revokeResponse: null;
- deleteResponse: null;
-};
-
-// @public (undocumented)
-export type RootState = ReturnType;
-
-// @public
-export interface SessionCheckOptions {
- redirectUri?: string;
- responseType?: SessionCheckResponseType;
- scope?: string;
- subject?: string;
-}
-
-// @public (undocumented)
-export type SessionCheckResponseType = 'id_token' | 'none';
-
-// @public (undocumented)
-export type SessionCheckSuccess = {
- responseType: SessionCheckResponseType;
- claims?: JWTPayload;
-};
-
-export { StorageConfig }
-
-// @public (undocumented)
-export interface TokenExchangeErrorResponse {
- // (undocumented)
- error: string;
- // (undocumented)
- message: string;
- // (undocumented)
- type: 'exchange_error' | 'network_error' | 'state_error' | 'unknown_error';
-}
-
-// @public (undocumented)
-export interface TokenExchangeResponse {
- // (undocumented)
- access_token: string;
- // (undocumented)
- expires_in?: number;
- // (undocumented)
- id_token: string;
- // (undocumented)
- refresh_token?: string;
- // (undocumented)
- scope?: string;
- // (undocumented)
- token_type?: string;
-}
-
-// @public (undocumented)
-export interface TokenRequestOptions {
- // (undocumented)
- code: string;
- // (undocumented)
- config: OidcConfig;
- // (undocumented)
- endpoint: string;
- // (undocumented)
- verifier?: string;
-}
-
-// @public (undocumented)
-export type UserInfoResponse = {
- sub: string;
- [key: string]: unknown;
-};
-
-export { WellknownResponse }
-
-// (No @packageDocumentation comment for this package)
-
-```
+## API Report File for "@forgerock/oidc-client"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+import { ActionTypes } from '@forgerock/sdk-request-middleware';
+import { AuthorizationDetail } from '@forgerock/sdk-types';
+import { BaseQueryFn } from '@reduxjs/toolkit/query';
+import { BrowserStorageConfig } from '@forgerock/storage';
+import { CombinedState } from '@reduxjs/toolkit/query';
+import { CustomLogger } from '@forgerock/sdk-logger';
+import { CustomStorageConfig } from '@forgerock/storage';
+import { CustomStorageObject } from '@forgerock/sdk-types';
+import { EnhancedStore } from '@reduxjs/toolkit';
+import { FetchArgs } from '@reduxjs/toolkit/query';
+import type { FetchBaseQueryError } from '@reduxjs/toolkit/query';
+import { FetchBaseQueryMeta } from '@reduxjs/toolkit/query';
+import { GenericError } from '@forgerock/sdk-types';
+import { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
+import type { JWTPayload } from 'jose';
+import type { logger } from '@forgerock/sdk-logger';
+import { LogLevel } from '@forgerock/sdk-logger';
+import { LogMessage } from '@forgerock/sdk-logger';
+import { MutationDefinition } from '@reduxjs/toolkit/query';
+import { OidcConfig } from '@forgerock/sdk-types';
+import { QueryDefinition } from '@reduxjs/toolkit/query';
+import { RequestMiddleware } from '@forgerock/sdk-request-middleware';
+import { ResponseType as ResponseType_2 } from '@forgerock/sdk-types';
+import { StorageConfig } from '@forgerock/storage';
+import { StoreEnhancer } from '@reduxjs/toolkit';
+import { ThunkDispatch } from '@reduxjs/toolkit';
+import { Tuple } from '@reduxjs/toolkit';
+import { UnknownAction } from '@reduxjs/toolkit';
+import { Unsubscribe } from '@reduxjs/toolkit';
+import { WellknownResponse } from '@forgerock/sdk-types';
+
+export { ActionTypes };
+
+// @public (undocumented)
+export type AppDispatch = ReturnType;
+
+export { AuthorizationDetail };
+
+// @public (undocumented)
+export interface AuthorizationError {
+ // (undocumented)
+ error: string;
+ // (undocumented)
+ error_description: string;
+ // (undocumented)
+ redirectUrl?: string;
+ // (undocumented)
+ type: 'auth_error' | 'argument_error' | 'network_error' | 'unknown_error' | 'wellknown_error';
+}
+
+// @public (undocumented)
+export interface AuthorizationSuccess {
+ // (undocumented)
+ code: string;
+ // (undocumented)
+ state: string;
+}
+
+// @public (undocumented)
+export interface AuthorizeErrorResponse {
+ // (undocumented)
+ code?: string;
+ // (undocumented)
+ details?: [
+ {
+ code: string;
+ message: string;
+ },
+ ];
+ // (undocumented)
+ id?: string;
+ // (undocumented)
+ message?: string;
+}
+
+// @public (undocumented)
+export interface AuthorizeSuccessResponse {
+ // (undocumented)
+ authorizeResponse?: {
+ code: string;
+ state: string;
+ };
+ // (undocumented)
+ createdAt?: string;
+ // (undocumented)
+ _embedded?: {
+ [key: string]: unknown;
+ };
+ // (undocumented)
+ environment?: {
+ id: string;
+ };
+ // (undocumented)
+ expiresAt?: string;
+ // (undocumented)
+ id?: string;
+ // (undocumented)
+ _links?: {
+ [key: string]: {
+ href: string;
+ };
+ };
+ // (undocumented)
+ resumeUrl?: string;
+ // (undocumented)
+ session?: {
+ id: string;
+ };
+ // (undocumented)
+ status?: string;
+}
+
+export { BrowserStorageConfig };
+
+// @public (undocumented)
+export type BuildAuthorizationData = [string, GetAuthorizationUrlOptions];
+
+// @public (undocumented)
+export type ClientStore = ReturnType;
+
+// @public
+export function createClientStore(input: {
+ requestMiddleware?: RequestMiddleware[];
+ logger?: ReturnType;
+}): EnhancedStore<
+ {
+ oidc: CombinedState<
+ {
+ authorizeFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ AuthorizeSuccessResponse,
+ 'oidc',
+ unknown
+ >;
+ par: MutationDefinition<
+ {
+ endpoint: string;
+ body: URLSearchParams;
+ },
+ BaseQueryFn,
+ never,
+ PushAuthorizationResponse,
+ 'oidc',
+ unknown
+ >;
+ sessionCheckIframe: MutationDefinition<
+ {
+ url: string;
+ responseType: SessionCheckResponseType;
+ },
+ BaseQueryFn,
+ never,
+ {
+ params: Record;
+ },
+ 'oidc',
+ unknown
+ >;
+ sessionCheckFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ {
+ status: 204;
+ },
+ 'oidc',
+ unknown
+ >;
+ authorizeIframe: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn,
+ never,
+ AuthorizationSuccess,
+ 'oidc',
+ unknown
+ >;
+ endSession: MutationDefinition<
+ {
+ idToken: string;
+ endpoint: string;
+ signOutRedirectUri?: string;
+ },
+ BaseQueryFn,
+ never,
+ null,
+ 'oidc',
+ unknown
+ >;
+ exchange: MutationDefinition<
+ {
+ code: string;
+ config: OidcConfig;
+ endpoint: string;
+ verifier?: string;
+ },
+ BaseQueryFn,
+ never,
+ TokenExchangeResponse,
+ 'oidc',
+ unknown
+ >;
+ revoke: MutationDefinition<
+ {
+ accessToken: string;
+ clientId?: string;
+ endpoint: string;
+ },
+ BaseQueryFn,
+ never,
+ object,
+ 'oidc',
+ unknown
+ >;
+ userInfo: MutationDefinition<
+ {
+ accessToken: string;
+ endpoint: string;
+ },
+ BaseQueryFn,
+ never,
+ UserInfoResponse,
+ 'oidc',
+ unknown
+ >;
+ },
+ never,
+ 'oidc'
+ >;
+ wellknown: CombinedState<
+ {
+ configuration: QueryDefinition<
+ string,
+ BaseQueryFn,
+ never,
+ WellknownResponse,
+ 'wellknown',
+ unknown
+ >;
+ },
+ never,
+ 'wellknown'
+ >;
+ },
+ UnknownAction,
+ Tuple<
+ [
+ StoreEnhancer<{
+ dispatch: ThunkDispatch<
+ {
+ oidc: CombinedState<
+ {
+ authorizeFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ AuthorizeSuccessResponse,
+ 'oidc',
+ unknown
+ >;
+ par: MutationDefinition<
+ {
+ endpoint: string;
+ body: URLSearchParams;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ PushAuthorizationResponse,
+ 'oidc',
+ unknown
+ >;
+ sessionCheckIframe: MutationDefinition<
+ {
+ url: string;
+ responseType: SessionCheckResponseType;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ {
+ params: Record;
+ },
+ 'oidc',
+ unknown
+ >;
+ sessionCheckFetch: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ {
+ status: 204;
+ },
+ 'oidc',
+ unknown
+ >;
+ authorizeIframe: MutationDefinition<
+ {
+ url: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ AuthorizationSuccess,
+ 'oidc',
+ unknown
+ >;
+ endSession: MutationDefinition<
+ {
+ idToken: string;
+ endpoint: string;
+ signOutRedirectUri?: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ null,
+ 'oidc',
+ unknown
+ >;
+ exchange: MutationDefinition<
+ {
+ code: string;
+ config: OidcConfig;
+ endpoint: string;
+ verifier?: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ TokenExchangeResponse,
+ 'oidc',
+ unknown
+ >;
+ revoke: MutationDefinition<
+ {
+ accessToken: string;
+ clientId?: string;
+ endpoint: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ object,
+ 'oidc',
+ unknown
+ >;
+ userInfo: MutationDefinition<
+ {
+ accessToken: string;
+ endpoint: string;
+ },
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ UserInfoResponse,
+ 'oidc',
+ unknown
+ >;
+ },
+ never,
+ 'oidc'
+ >;
+ wellknown: CombinedState<
+ {
+ configuration: QueryDefinition<
+ string,
+ BaseQueryFn<
+ string | FetchArgs,
+ unknown,
+ FetchBaseQueryError,
+ {},
+ FetchBaseQueryMeta
+ >,
+ never,
+ WellknownResponse,
+ 'wellknown',
+ unknown
+ >;
+ },
+ never,
+ 'wellknown'
+ >;
+ },
+ {
+ requestMiddleware: RequestMiddleware[] | undefined;
+ logger:
+ | {
+ changeLevel: (level: LogLevel) => void;
+ error: (...args: LogMessage[]) => void;
+ warn: (...args: LogMessage[]) => void;
+ info: (...args: LogMessage[]) => void;
+ debug: (...args: LogMessage[]) => void;
+ }
+ | undefined;
+ },
+ UnknownAction
+ >;
+ }>,
+ StoreEnhancer,
+ ]
+ >
+>;
+
+export { CustomLogger };
+
+export { CustomStorageConfig };
+
+export { CustomStorageObject };
+
+export { GenericError };
+
+export { GetAuthorizationUrlOptions };
+
+// @public (undocumented)
+export interface GetTokensOptions {
+ // (undocumented)
+ authorizeOptions?: GetAuthorizationUrlOptions;
+ // (undocumented)
+ backgroundRenew?: boolean;
+ // (undocumented)
+ forceRenew?: boolean;
+ // (undocumented)
+ storageOptions?: Partial;
+}
+
+export { LogLevel };
+
+// @public (undocumented)
+export type LogoutErrorResult = {
+ error: string;
+ sessionResponse: GenericError | null;
+ revokeResponse: GenericError | null;
+ deleteResponse: GenericError | null;
+};
+
+// @public (undocumented)
+export type LogoutSuccessResult = RevokeSuccessResult & {
+ sessionResponse: null;
+};
+
+// @public (undocumented)
+export interface OauthTokens {
+ // (undocumented)
+ accessToken: string;
+ // (undocumented)
+ authorizationDetails?: AuthorizationDetail[];
+ // (undocumented)
+ expiresAt?: number;
+ // (undocumented)
+ expiryTimestamp?: number;
+ // (undocumented)
+ idToken: string;
+ // (undocumented)
+ refreshToken?: string;
+}
+
+// @public
+export function oidc(input: {
+ config: OidcConfig;
+ requestMiddleware?: RequestMiddleware[];
+ logger?: {
+ level: LogLevel;
+ custom?: CustomLogger;
+ };
+ storage?: Partial;
+}): Promise<
+ | {
+ error: string;
+ type: string;
+ subscribe?: undefined;
+ authorize?: undefined;
+ token?: undefined;
+ user?: undefined;
+ }
+ | {
+ subscribe: (listener: () => void) => Unsubscribe;
+ authorize: {
+ url: (options?: GetAuthorizationUrlOptions) => Promise;
+ background: (
+ options?: GetAuthorizationUrlOptions,
+ ) => Promise;
+ };
+ token: {
+ exchange: (
+ code: string,
+ state: string,
+ options?: Partial,
+ ) => Promise;
+ get: (
+ options?: GetTokensOptions,
+ ) => Promise;
+ revoke: () => Promise;
+ };
+ user: {
+ info: () => Promise;
+ logout: () => Promise;
+ session: (options?: SessionCheckOptions) => Promise;
+ };
+ error?: undefined;
+ type?: undefined;
+ }
+>;
+
+// @public (undocumented)
+export type OidcClient = Awaited>;
+
+export { OidcConfig };
+
+// @public (undocumented)
+export type OptionalAuthorizeOptions = Partial;
+
+// @public (undocumented)
+export interface PushAuthorizationResponse {
+ // (undocumented)
+ expires_in: number;
+ // (undocumented)
+ request_uri: string;
+}
+
+export { RequestMiddleware };
+
+export { ResponseType_2 as ResponseType };
+
+// @public (undocumented)
+export type RevokeErrorResult = {
+ error: string;
+ revokeResponse: GenericError | null;
+ deleteResponse: GenericError | null;
+};
+
+// @public (undocumented)
+export type RevokeSuccessResult = {
+ revokeResponse: null;
+ deleteResponse: null;
+};
+
+// @public (undocumented)
+export type RootState = ReturnType;
+
+// @public
+export interface SessionCheckOptions {
+ redirectUri?: string;
+ responseType?: SessionCheckResponseType;
+ scope?: string;
+ subject?: string;
+}
+
+// @public (undocumented)
+export type SessionCheckResponseType = 'id_token' | 'none';
+
+// @public (undocumented)
+export type SessionCheckSuccess = {
+ responseType: SessionCheckResponseType;
+ claims?: JWTPayload;
+};
+
+export { StorageConfig };
+
+// @public (undocumented)
+export interface TokenExchangeErrorResponse {
+ // (undocumented)
+ error: string;
+ // (undocumented)
+ message: string;
+ // (undocumented)
+ type: 'exchange_error' | 'network_error' | 'state_error' | 'unknown_error';
+}
+
+// @public (undocumented)
+export interface TokenExchangeResponse {
+ // (undocumented)
+ access_token: string;
+ // (undocumented)
+ authorization_details?: AuthorizationDetail[];
+ // (undocumented)
+ expires_in?: number;
+ // (undocumented)
+ id_token: string;
+ // (undocumented)
+ refresh_token?: string;
+ // (undocumented)
+ scope?: string;
+ // (undocumented)
+ token_type?: string;
+}
+
+// @public (undocumented)
+export interface TokenRequestOptions {
+ // (undocumented)
+ code: string;
+ // (undocumented)
+ config: OidcConfig;
+ // (undocumented)
+ endpoint: string;
+ // (undocumented)
+ verifier?: string;
+}
+
+// @public (undocumented)
+export type UserInfoResponse = {
+ sub: string;
+ [key: string]: unknown;
+};
+
+export { WellknownResponse };
+
+// (No @packageDocumentation comment for this package)
+```
diff --git a/packages/oidc-client/src/lib/authorize.request.micros.test.ts b/packages/oidc-client/src/lib/authorize.request.micros.test.ts
index 079ab93df0f..0aa7d037e44 100644
--- a/packages/oidc-client/src/lib/authorize.request.micros.test.ts
+++ b/packages/oidc-client/src/lib/authorize.request.micros.test.ts
@@ -133,6 +133,45 @@ it.effect('buildParBodyµ includes prompt when provided', () =>
}),
);
+it.effect('buildParBodyµ includes authorization_details from config', () =>
+ Micro.gen(function* () {
+ const authorizationDetails = [
+ {
+ type: 'payment_initiation',
+ additionalFields: { instructedAmount: { currency: 'EUR', amount: '100.00' } },
+ },
+ ];
+ const params = yield* buildParBodyµ({ ...config, authorizationDetails }, {}, 'ch', 'st');
+ expect(JSON.parse(params.get('authorization_details') as string)).toStrictEqual([
+ {
+ type: 'payment_initiation',
+ instructedAmount: { currency: 'EUR', amount: '100.00' },
+ },
+ ]);
+ }),
+);
+
+it.effect('buildParBodyµ omits authorization_details when config has none', () =>
+ Micro.gen(function* () {
+ const params = yield* buildParBodyµ(config, {}, 'ch', 'st');
+ expect(params.has('authorization_details')).toBe(false);
+ }),
+);
+
+it.effect('buildParBodyµ options override config authorizationDetails', () =>
+ Micro.gen(function* () {
+ const params = yield* buildParBodyµ(
+ { ...config, authorizationDetails: [{ type: 'from_config' }] },
+ { authorizationDetails: [{ type: 'from_options' }] },
+ 'ch',
+ 'st',
+ );
+ expect(JSON.parse(params.get('authorization_details') as string)).toStrictEqual([
+ { type: 'from_options' },
+ ]);
+ }),
+);
+
it.effect('buildParBodyµ fails with auth_error when buildAuthorizeParams throws', () =>
Micro.gen(function* () {
vi.spyOn(sdkOidc, 'buildAuthorizeParams').mockImplementation(() => {
diff --git a/packages/oidc-client/src/lib/authorize.request.micros.ts b/packages/oidc-client/src/lib/authorize.request.micros.ts
index 53098144839..0bdc6caa26a 100644
--- a/packages/oidc-client/src/lib/authorize.request.micros.ts
+++ b/packages/oidc-client/src/lib/authorize.request.micros.ts
@@ -100,6 +100,9 @@ export const buildParBodyµ = (
redirectUri: config.redirectUri,
scope: config.scope || 'openid',
responseType: config.responseType || 'code',
+ ...(config.authorizationDetails !== undefined && {
+ authorizationDetails: config.authorizationDetails,
+ }),
...parBodyOptions,
challenge,
state,
diff --git a/packages/oidc-client/src/lib/client.store.test.ts b/packages/oidc-client/src/lib/client.store.test.ts
index 64d5b6695c8..df148f86844 100644
--- a/packages/oidc-client/src/lib/client.store.test.ts
+++ b/packages/oidc-client/src/lib/client.store.test.ts
@@ -494,6 +494,159 @@ describe('authorize.background() dispatch error branches', async () => {
});
});
+describe('RAR authorizationDetails propagation', async () => {
+ const rarDetails = [
+ {
+ type: 'payment_initiation',
+ additionalFields: { instructedAmount: { currency: 'EUR', amount: '100.00' } },
+ },
+ ];
+ const baseConfig: OidcConfig = {
+ clientId: '123456789',
+ redirectUri: 'https://example.com/callback.html',
+ scope: 'openid profile',
+ serverConfig: { wellknown: 'https://api.example.com/wellknown' },
+ responseType: 'code',
+ };
+
+ beforeEach(() => {
+ customStorage.remove(storageKey);
+ });
+
+ it('authorize.url() includes authorization_details from config (standard flow)', async () => {
+ const oidcClient = await oidc({
+ config: { ...baseConfig, authorizationDetails: rarDetails },
+ storage: customStorageConfig,
+ });
+ if ('error' in oidcClient) throw new Error('Error creating OIDC Client');
+
+ const url = await oidcClient.authorize.url();
+ if (typeof url !== 'string') expect.fail(`Expected string URL, got: ${JSON.stringify(url)}`);
+
+ const details = JSON.parse(new URL(url).searchParams.get('authorization_details') as string);
+ expect(details).toStrictEqual([
+ {
+ type: 'payment_initiation',
+ instructedAmount: { currency: 'EUR', amount: '100.00' },
+ },
+ ]);
+ });
+
+ it('authorize.url() omits authorization_details when config has none', async () => {
+ const oidcClient = await oidc({ config: baseConfig, storage: customStorageConfig });
+ if ('error' in oidcClient) throw new Error('Error creating OIDC Client');
+
+ const url = await oidcClient.authorize.url();
+ if (typeof url !== 'string') expect.fail(`Expected string URL, got: ${JSON.stringify(url)}`);
+
+ expect(new URL(url).searchParams.has('authorization_details')).toBe(false);
+ });
+
+ it('authorize.url() includes authorization_details in the PAR request body', async () => {
+ let capturedParBody = '';
+ server.use(
+ http.post('*/as/par', async ({ request }) => {
+ capturedParBody = await request.text();
+ return HttpResponse.json({ request_uri: parRequestUri, expires_in: 60 }, { status: 201 });
+ }),
+ );
+
+ const oidcClient = await oidc({
+ config: { ...baseConfig, par: true, authorizationDetails: rarDetails },
+ storage: customStorageConfig,
+ });
+ if ('error' in oidcClient) throw new Error('Error creating OIDC Client');
+
+ const url = await oidcClient.authorize.url();
+ if (typeof url !== 'string') expect.fail(`Expected string URL, got: ${JSON.stringify(url)}`);
+
+ // Slim URL must NOT carry the details; the PAR body must
+ expect(new URL(url).searchParams.has('authorization_details')).toBe(false);
+ expect(
+ JSON.parse(new URLSearchParams(capturedParBody).get('authorization_details') as string),
+ ).toStrictEqual([
+ {
+ type: 'payment_initiation',
+ instructedAmount: { currency: 'EUR', amount: '100.00' },
+ },
+ ]);
+ });
+
+ it('authorize.background() sends authorization_details to the authorize endpoint (pi.flow)', async () => {
+ let capturedAuthorizeUrl = '';
+ server.use(
+ http.post('*/as/authorize', async ({ request }) => {
+ capturedAuthorizeUrl = request.url;
+ return HttpResponse.json({
+ authorizeResponse: {
+ code: 123,
+ state: 'NzUyNDUyMDAxOTMyNDUxNzI1NjkxNDc2MjEyMzUwMjQzMzQyMjE4OQ',
+ },
+ });
+ }),
+ );
+
+ const oidcClient = await oidc({
+ config: { ...baseConfig, authorizationDetails: rarDetails },
+ storage: customStorageConfig,
+ });
+ if ('error' in oidcClient) throw new Error('Error creating OIDC Client');
+
+ const result = await oidcClient.authorize.background({
+ clientId: baseConfig.clientId,
+ redirectUri: baseConfig.redirectUri,
+ scope: baseConfig.scope,
+ responseType: 'code',
+ responseMode: 'pi.flow',
+ });
+ if ('error' in result) {
+ expect.fail(`Expected success, got error: ${JSON.stringify(result)}`);
+ }
+
+ const details = JSON.parse(
+ new URL(capturedAuthorizeUrl).searchParams.get('authorization_details') as string,
+ );
+ expect(details).toStrictEqual([
+ {
+ type: 'payment_initiation',
+ instructedAmount: { currency: 'EUR', amount: '100.00' },
+ },
+ ]);
+ expect(result.code).toBeDefined();
+ });
+
+ it('token.exchange maps authorization_details from the token response onto stored tokens', async () => {
+ const state = 'NzUyNDUyMDAxOTMyNDUxNzI1NjkxNDc2MjEyMzUwMjQzMzQyMjE4OQ';
+
+ server.use(
+ http.post('*/as/token', async () =>
+ HttpResponse.json({
+ access_token: 'abcdefghijklmnop',
+ id_token: '0987654321',
+ authorization_details: rarDetails,
+ }),
+ ),
+ );
+
+ const oidcClient = await oidc({
+ config: { ...baseConfig, authorizationDetails: rarDetails },
+ storage: customStorageConfig,
+ });
+ if ('error' in oidcClient) throw new Error('Error creating OIDC Client');
+
+ await oidcClient.authorize.url(); // seeds state/verifier via the file's sessionStorage stub
+
+ const tokens = await oidcClient.token.exchange('abc123', state);
+ if ('error' in tokens || !('authorizationDetails' in tokens)) expect.fail();
+ expect(tokens.authorizationDetails).toStrictEqual(rarDetails);
+
+ // Round-trip: the persisted tokens carry the granted details (AC 1)
+ const stored = await oidcClient.token.get();
+ if ('error' in stored || !('authorizationDetails' in stored)) expect.fail();
+ expect(stored.authorizationDetails).toStrictEqual(rarDetails);
+ });
+});
+
describe('PAR factory validation', async () => {
it('returns argument_error when wellknown requires PAR but config.par is explicitly false', async () => {
server.use(
diff --git a/packages/oidc-client/src/lib/client.store.ts b/packages/oidc-client/src/lib/client.store.ts
index e971a35ea7d..af9fb9d84ca 100644
--- a/packages/oidc-client/src/lib/client.store.ts
+++ b/packages/oidc-client/src/lib/client.store.ts
@@ -175,6 +175,9 @@ export async function oidc({
redirectUri: config.redirectUri,
scope: config.scope || 'openid',
responseType: config.responseType || 'code',
+ ...(config.authorizationDetails !== undefined && {
+ authorizationDetails: config.authorizationDetails,
+ }),
...(config.loginHint !== undefined && { loginHint: config.loginHint }),
...(config.nonce !== undefined && { nonce: config.nonce }),
...(config.display !== undefined && { display: config.display }),
@@ -213,7 +216,13 @@ export async function oidc({
config,
log,
store,
- { ...(options ?? ({} as GetAuthorizationUrlOptions)), prompt: 'none' as const },
+ {
+ ...(config.authorizationDetails !== undefined && {
+ authorizationDetails: config.authorizationDetails,
+ }),
+ ...(options ?? ({} as GetAuthorizationUrlOptions)),
+ prompt: 'none' as const,
+ },
useParFlow,
),
);
@@ -335,7 +344,13 @@ export async function oidc({
config,
log,
store,
- { ...(authorizeOptions ?? ({} as GetAuthorizationUrlOptions)), prompt: 'none' as const },
+ {
+ ...(config.authorizationDetails !== undefined && {
+ authorizationDetails: config.authorizationDetails,
+ }),
+ ...(authorizeOptions ?? ({} as GetAuthorizationUrlOptions)),
+ prompt: 'none' as const,
+ },
useParFlow,
).pipe(
Micro.flatMap((response): Micro.Micro => {
diff --git a/packages/oidc-client/src/lib/config.types.ts b/packages/oidc-client/src/lib/config.types.ts
index c846a29292b..d26f2076459 100644
--- a/packages/oidc-client/src/lib/config.types.ts
+++ b/packages/oidc-client/src/lib/config.types.ts
@@ -5,6 +5,7 @@
* of the MIT license. See the LICENSE file for details.
*/
export type { OidcConfig } from '@forgerock/sdk-types';
+import type { AuthorizationDetail } from '@forgerock/sdk-types';
export interface OauthTokens {
accessToken: string;
@@ -12,4 +13,5 @@ export interface OauthTokens {
refreshToken?: string;
expiresAt?: number;
expiryTimestamp?: number;
+ authorizationDetails?: AuthorizationDetail[];
}
diff --git a/packages/oidc-client/src/lib/exchange.request.ts b/packages/oidc-client/src/lib/exchange.request.ts
index 4edded807c0..e2624522c64 100644
--- a/packages/oidc-client/src/lib/exchange.request.ts
+++ b/packages/oidc-client/src/lib/exchange.request.ts
@@ -56,6 +56,7 @@ export function buildTokenExchangeµ({
...(data.refresh_token && { refreshToken: data.refresh_token }),
...(data.expires_in && { expiresAt: data.expires_in }),
...(data.expires_in && { expiryTimestamp: Date.now() + data.expires_in * 1000 }),
+ ...(data.authorization_details && { authorizationDetails: data.authorization_details }),
};
return tokens;
diff --git a/packages/oidc-client/src/lib/exchange.types.ts b/packages/oidc-client/src/lib/exchange.types.ts
index 17fcc9ed505..6ddcabff26c 100644
--- a/packages/oidc-client/src/lib/exchange.types.ts
+++ b/packages/oidc-client/src/lib/exchange.types.ts
@@ -1,9 +1,11 @@
/*
- * Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
+ * Copyright (c) 2025 - 2026 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
+import type { AuthorizationDetail } from '@forgerock/sdk-types';
+
import type { OidcConfig } from './config.types.js';
export interface TokenExchangeResponse {
@@ -13,6 +15,7 @@ export interface TokenExchangeResponse {
expires_in?: number;
scope?: string;
token_type?: string;
+ authorization_details?: AuthorizationDetail[];
}
export interface TokenExchangeErrorResponse {
diff --git a/packages/oidc-client/src/types.ts b/packages/oidc-client/src/types.ts
index 9496a4ae6c4..ffefca33579 100644
--- a/packages/oidc-client/src/types.ts
+++ b/packages/oidc-client/src/types.ts
@@ -12,6 +12,8 @@ export * from './lib/session.types.js';
export type { PushAuthorizationResponse } from './lib/par.types.js';
export type {
+ AuthorizationDetail,
+ CustomStorageObject,
GenericError,
GetAuthorizationUrlOptions,
ResponseType,
@@ -20,7 +22,6 @@ export type {
export type { ActionTypes, RequestMiddleware } from '@forgerock/sdk-request-middleware';
export type { CustomLogger, LogLevel } from '@forgerock/sdk-logger';
export type { BrowserStorageConfig, CustomStorageConfig, StorageConfig } from '@forgerock/storage';
-export type { CustomStorageObject } from '@forgerock/sdk-types';
// Re-export functions needed to resolve OidcClient and ClientStore type aliases
export { oidc } from './lib/client.store.js';
diff --git a/packages/sdk-effects/oidc/src/lib/authorize.test.ts b/packages/sdk-effects/oidc/src/lib/authorize.test.ts
index 06df683cec3..7ccf1090ff9 100644
--- a/packages/sdk-effects/oidc/src/lib/authorize.test.ts
+++ b/packages/sdk-effects/oidc/src/lib/authorize.test.ts
@@ -8,7 +8,7 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { createAuthorizeUrl } from './authorize.effects.js';
-import { buildAuthorizeParams } from './authorize.utils.js';
+import { buildAuthorizeParams, serializeRarAuthDetails } from './authorize.utils.js';
import { getStorageKey } from './state-pkce.effects.js';
import type { GenerateAndStoreAuthUrlValues } from '@forgerock/sdk-types';
@@ -263,6 +263,35 @@ describe('buildAuthorizeParams', () => {
expect(params.get('acr_values')).toBe('Level3');
});
+ it('includes authorization_details when provided', () => {
+ const params = buildAuthorizeParams({
+ clientId: 'test-client',
+ redirectUri: 'https://example.com/cb',
+ scope: 'openid',
+ responseType: 'code',
+ challenge: 'abc123',
+ state: 'state1',
+ authorizationDetails: [{ type: 'payment_initiation' }],
+ });
+
+ const details = JSON.parse(params.get('authorization_details') as string);
+ expect(details).toStrictEqual([{ type: 'payment_initiation' }]);
+ });
+
+ it('omits authorization_details when empty', () => {
+ const params = buildAuthorizeParams({
+ clientId: 'test-client',
+ redirectUri: 'https://example.com/cb',
+ scope: 'openid',
+ responseType: 'code',
+ challenge: 'abc123',
+ state: 'state1',
+ authorizationDetails: [],
+ });
+
+ expect(params.has('authorization_details')).toBe(false);
+ });
+
it('includes all new OIDC params together', () => {
const params = buildAuthorizeParams({
clientId: 'test-client',
@@ -285,3 +314,46 @@ describe('buildAuthorizeParams', () => {
expect(params.get('acr_values')).toBe('Level2');
});
});
+
+describe('serializeRarAuthDetails', () => {
+ it('serializes a single detail with only a type', () => {
+ const json = serializeRarAuthDetails([{ type: 'payment_initiation' }]);
+ expect(json).toBe('[{"type":"payment_initiation"}]');
+ });
+
+ it('flattens additionalFields onto the detail', () => {
+ const json = serializeRarAuthDetails([
+ {
+ type: 'payment_initiation',
+ additionalFields: { instructedAmount: { currency: 'EUR', amount: '100.00' } },
+ },
+ ]);
+ expect(JSON.parse(json)).toStrictEqual([
+ {
+ type: 'payment_initiation',
+ instructedAmount: { currency: 'EUR', amount: '100.00' },
+ },
+ ]);
+ });
+
+ it('lets modeled properties override shadowing additionalFields entries', () => {
+ const json = serializeRarAuthDetails([
+ {
+ type: 'account_information',
+ locations: ['https://api.example.com'],
+ additionalFields: { locations: ['https://evil.example.com'] },
+ },
+ ]);
+ expect(JSON.parse(json)).toStrictEqual([
+ {
+ type: 'account_information',
+ locations: ['https://api.example.com'],
+ },
+ ]);
+ });
+
+ it('drops the additionalFields key from the serialized output', () => {
+ const json = serializeRarAuthDetails([{ type: 'payment_initiation', additionalFields: {} }]);
+ expect(json).toBe('[{"type":"payment_initiation"}]');
+ });
+});
diff --git a/packages/sdk-effects/oidc/src/lib/authorize.utils.ts b/packages/sdk-effects/oidc/src/lib/authorize.utils.ts
index 204749334d0..d97cfc062bc 100644
--- a/packages/sdk-effects/oidc/src/lib/authorize.utils.ts
+++ b/packages/sdk-effects/oidc/src/lib/authorize.utils.ts
@@ -4,8 +4,21 @@
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
+import type { AuthorizationDetail, GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
-import type { GetAuthorizationUrlOptions } from '@forgerock/sdk-types';
+/**
+ * Serializes RAR {@link AuthorizationDetail} objects to a JSON string for the
+ * `authorization_details` request parameter. Each detail's `additionalFields`
+ * is flattened onto the detail; entries in `additionalFields` that shadow a
+ * modeled property are overridden by the modeled entry.
+ */
+export function serializeRarAuthDetails(authDetails: AuthorizationDetail[]): string {
+ const flattenedDetails = authDetails.map((detail) => {
+ const { additionalFields, ...knownAuthDetails } = detail;
+ return { ...additionalFields, ...knownAuthDetails };
+ });
+ return JSON.stringify(flattenedDetails);
+}
/**
* Builds URLSearchParams for an OAuth2/OIDC authorization request.
@@ -35,5 +48,10 @@ export function buildAuthorizeParams(
if (options.uiLocales) params.set('ui_locales', options.uiLocales);
if (options.acrValues) params.set('acr_values', options.acrValues);
+ if (Array.isArray(options.authorizationDetails) && options.authorizationDetails?.length) {
+ const serializedAuthDetails = serializeRarAuthDetails(options.authorizationDetails);
+ params.set('authorization_details', serializedAuthDetails);
+ }
+
return params;
}
diff --git a/packages/sdk-types/src/lib/authorize.types.ts b/packages/sdk-types/src/lib/authorize.types.ts
index 014273d67f5..0a183459314 100644
--- a/packages/sdk-types/src/lib/authorize.types.ts
+++ b/packages/sdk-types/src/lib/authorize.types.ts
@@ -19,21 +19,23 @@ export type AuthPromptValue = (typeof AUTH_PROMPT_VALUES)[number];
/**
* Options for the authorization URL
+ *
+ * These four properties clientid, scope, responseType and redirectUri are required
+ * when using this type, which are not required when defining Config.
+ *
* @param clientId The client ID of the application
* @param redirectUri The redirect URI of the application
* @param responseType The response type of the authorization request
* @param scope The scope of the authorization request
*/
export interface GetAuthorizationUrlOptions extends LegacyConfigOptions {
- /**
- * These four properties clientid, scope, responseType and redirectUri are required
- * when using this type, which are not required when defining Config.
- */
clientId: string;
scope: string;
redirectUri: string;
responseType: ResponseType;
responseMode?: 'fragment' | 'form_post' | 'pi.flow' | 'query';
+ /** Authorization details for Rich Authorization Requests (RAR) */
+ authorizationDetails?: AuthorizationDetail[];
login?: 'redirect' | 'embedded';
state?: string;
verifier?: string;
@@ -56,3 +58,24 @@ export interface GenerateAndStoreAuthUrlValues extends GetAuthorizationUrlOption
clientId: string;
prefix?: string;
}
+
+/**
+ * A single object for the `authorization_details` request parameter as
+ * defined by RFC 9396 (Rich Authorization Requests). Type-specific fields
+ * not modeled below can be added to the catch-all `additionalFields` parameter,
+ * whose entries are flattened onto the object before sending the request.
+ */
+export interface AuthorizationDetail {
+ /** The type of authorization details as defined by the authorization server */
+ type: string;
+ /** Locations this authorization applies to */
+ locations?: string[];
+ /** Actions this authorization applies to */
+ actions?: string[];
+ /** Data types this authorization applies to */
+ datatypes?: string[];
+ /** Privileges this authorization applies to */
+ privileges?: string[];
+ /** Catch-all for type-specific fields not modeled above (e.g. `instructedAmount` for `payment_initiation`) */
+ additionalFields?: Record;
+}
diff --git a/packages/sdk-types/src/lib/config.types.ts b/packages/sdk-types/src/lib/config.types.ts
index ce2d9e84695..eb63a888bf2 100644
--- a/packages/sdk-types/src/lib/config.types.ts
+++ b/packages/sdk-types/src/lib/config.types.ts
@@ -4,7 +4,12 @@
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
-import type { AuthDisplayValue, AuthPromptValue, ResponseType } from './authorize.types.js';
+import type {
+ AuthDisplayValue,
+ AuthorizationDetail,
+ AuthPromptValue,
+ ResponseType,
+} from './authorize.types.js';
import type { AsyncLegacyConfigOptions } from './legacy-config.types.js';
import type { CustomStorageObject } from './tokens.types.js';
@@ -27,6 +32,8 @@ export interface OidcConfig extends AsyncLegacyConfigOptions {
responseType?: ResponseType;
/** Use Pushed Authorization Requests (PAR) for the authorization flow. */
par?: boolean;
+ /** Authorization details for Rich Authorization Requests (RAR) */
+ authorizationDetails?: AuthorizationDetail[];
/** URI to redirect to after logout; maps to `post_logout_redirect_uri` in the end-session request. */
signOutRedirectUri?: string;
loginHint?: string;