Skip to content

SDKS-5067: Standardize SDK Configuration#684

Open
SteinGabriel wants to merge 1 commit into
mainfrom
SDKS-5067
Open

SDKS-5067: Standardize SDK Configuration#684
SteinGabriel wants to merge 1 commit into
mainfrom
SDKS-5067

Conversation

@SteinGabriel

Copy link
Copy Markdown
Contributor

Summary

https://pingidentity.atlassian.net/browse/SDKS-5067

Implements a unified cross-platform JSON configuration schema for the JS
SDK. All three factories (oidc, journey, davinci) now accept the
unified JSON config, map it to internal shapes via a new sdk-utilities
config module, validate required fields, and throw/reject on invalid input.
Non-breaking: existing internal config shapes still accepted.

Changes

packages/sdk-utilities

  • New src/lib/config/ module: config.types.ts (unified type
    definitions), config.utils.ts (pure validation + mapping functions),
    config/index.ts barrel export
  • validateUnifiedSdkConfig — discriminated-union validation with typed
    field errors; strict mode for oidc/davinci, lenient for journey
  • isUnifiedSdkConfig — discriminator: 'oidc' in input || 'journey' in input
  • unifiedToOidcConfig, unifiedToJourneyConfig, unifiedToDavinciConfig
    — pure mapping functions returning ConfigValidationResult<T>; scopes[] →
    scope string, refreshThreshold (sec) → oauthThreshold (ms), log → logLevel
  • Exported from sdk-utilities/src/index.ts

packages/oidc-client

  • client.store.ts — detects unified JSON, validates, maps, throws on
    error; forwards new OIDC params (loginHint, state, nonce, display,
    prompt, uiLocales, acrValues, query) into getAuthorizationUrl call
  • config.types.tsOidcConfig extended with signOutRedirectUri,
    loginHint, state, nonce, display, prompt, uiLocales,
    acrValues, query, log
  • oidc.api.ts — appends post_logout_redirect_uri to endSession URL when
    signOutRedirectUri present

packages/journey-client

  • client.store.ts — detects unified JSON, validates, maps, throws on error
  • config.types.tsJourneyClientConfig extended with log?: LogLevel

packages/davinci-client

  • client.store.ts — detects unified JSON, validates, maps, throws on error
  • config.types.tsDaVinciConfig extended with log?: LogLevel

packages/sdk-types

  • authorize.types.tsGetAuthorizationUrlOptions extended with
    loginHint, nonce, display, uiLocales, acrValues; prompt widened
    to include 'select_account'

packages/sdk-effects/oidc

  • authorize.utils.tsbuildAuthorizeParams wires loginHint, nonce,
    display, uiLocales, acrValues into the authorize URL

Tests

  • 551-line config.test.ts in sdk-utilities: valid mapping for all three
    factories, each required-field-missing error, type-mismatch errors,
    unknown-field-ignored, refreshThresholdoauthThreshold conversion,
    scopes join, log field mapping, cookieName non-mapping
  • New client.store.test.ts in oidc-client, journey-client,
    davinci-client: success path + two throw cases each (validation failure,
    mapping failure)
  • authorize.test.ts in sdk-effects/oidc: 6 tests covering each new OIDC
    param individually and all together
  • Updated authorize.request.micros.test.ts,
    authorize.request.utils.test.ts, logout.request.test.ts in oidc-client
    for new config shape

How to test

1. Unit tests

pnpm --filter @forgerock/sdk-utilities test
pnpm --filter @forgerock/oidc-client test
pnpm --filter @forgerock/journey-client test
pnpm --filter @forgerock/davinci-client test

All suites should pass.

2. Unified JSON config — factory entry

import { oidc } from '@forgerock/oidc-client';

const client = await oidc({
  config: {
    oidc: {
      clientId: 'my-client',
      discoveryEndpoint:
'https://example.com/.well-known/openid-configuration',
      scopes: ['openid', 'profile', 'email'],
      redirectUri: 'https://localhost:3000/callback',
    },
  },
});

Factory should initialize successfully. Remove clientId → should throw
Invalid unified SDK config: oidc.clientId: ....

3. Legacy config — backward compat

Pass an existing OidcConfig / JourneyClientConfig / DaVinciConfig object
directly. Factory should initialize without change.

Verify OIDC authorize params

Call getAuthorizationUrl with loginHint, nonce, display, uiLocales,
acrValues set. Inspect the returned URL — each param should appear as a
query string key.

Call endSession with signOutRedirectUri set — verify
post_logout_redirect_uri appears in the URL.

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2a4fee2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@forgerock/sdk-utilities Minor
@forgerock/sdk-types Minor
@forgerock/sdk-oidc Minor
@forgerock/oidc-client Minor
@forgerock/journey-client Minor
@forgerock/davinci-client Minor
@forgerock/storage Minor
@forgerock/device-client Minor
@forgerock/protect Minor
@forgerock/iframe-manager Minor
@forgerock/sdk-logger Minor
@forgerock/sdk-request-middleware Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@nx-cloud

nx-cloud Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit dd2a363

Command Status Duration Result
nx affected -t build lint test typecheck e2e-ci ❌ Failed 4m 29s View ↗

💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.


☁️ Nx Cloud last updated this comment at 2026-06-09 21:24:04 UTC

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@SteinGabriel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 31629639-323f-49e2-8bbf-5e1452e201cf

📥 Commits

Reviewing files that changed from the base of the PR and between 48279d3 and 2a4fee2.

📒 Files selected for processing (30)
  • .changeset/sdks-5067-unified-config.md
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/client.store.test.ts
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/config.types.ts
  • packages/journey-client/api-report/journey-client.api.md
  • packages/journey-client/api-report/journey-client.types.api.md
  • packages/journey-client/src/lib/client.store.test.ts
  • packages/journey-client/src/lib/client.store.ts
  • packages/journey-client/src/lib/config.types.ts
  • packages/oidc-client/api-report/oidc-client.api.md
  • packages/oidc-client/api-report/oidc-client.types.api.md
  • packages/oidc-client/src/lib/authorize.request.micros.test.ts
  • packages/oidc-client/src/lib/authorize.request.utils.test.ts
  • packages/oidc-client/src/lib/authorize.request.utils.ts
  • packages/oidc-client/src/lib/client.store.test.ts
  • packages/oidc-client/src/lib/client.store.ts
  • packages/oidc-client/src/lib/config.types.ts
  • packages/oidc-client/src/lib/logout.request.test.ts
  • packages/oidc-client/src/lib/logout.request.ts
  • packages/oidc-client/src/lib/oidc.api.ts
  • packages/sdk-effects/oidc/src/lib/authorize.test.ts
  • packages/sdk-effects/oidc/src/lib/authorize.utils.ts
  • packages/sdk-types/src/lib/authorize.types.ts
  • packages/sdk-utilities/src/index.ts
  • packages/sdk-utilities/src/lib/config/config.test.ts
  • packages/sdk-utilities/src/lib/config/config.types.ts
  • packages/sdk-utilities/src/lib/config/config.utils.ts
  • packages/sdk-utilities/src/lib/config/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-5067

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/@forgerock/davinci-client@684

@forgerock/device-client

pnpm add https://pkg.pr.new/@forgerock/device-client@684

@forgerock/journey-client

pnpm add https://pkg.pr.new/@forgerock/journey-client@684

@forgerock/oidc-client

pnpm add https://pkg.pr.new/@forgerock/oidc-client@684

@forgerock/protect

pnpm add https://pkg.pr.new/@forgerock/protect@684

@forgerock/sdk-types

pnpm add https://pkg.pr.new/@forgerock/sdk-types@684

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/@forgerock/sdk-utilities@684

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/@forgerock/iframe-manager@684

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/@forgerock/sdk-logger@684

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/@forgerock/sdk-oidc@684

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/@forgerock/sdk-request-middleware@684

@forgerock/storage

pnpm add https://pkg.pr.new/@forgerock/storage@684

commit: dd2a363

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.21451% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.93%. Comparing base (eafe277) to head (dd2a363).
⚠️ Report is 28 commits behind head on main.

⚠️ Current head dd2a363 differs from pull request most recent head 5379e6f

Please upload reports for the commit 5379e6f to get more accurate results.

Files with missing lines Patch % Lines
...kages/sdk-utilities/src/lib/config/config.utils.ts 97.83% 5 Missing ⚠️
packages/davinci-client/src/lib/client.store.ts 90.47% 2 Missing ⚠️
packages/sdk-utilities/src/lib/config/index.ts 33.33% 2 Missing ⚠️
packages/journey-client/src/lib/client.store.ts 95.00% 1 Missing ⚠️
packages/oidc-client/src/lib/client.store.ts 96.55% 1 Missing ⚠️
packages/sdk-utilities/src/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #684       +/-   ##
===========================================
+ Coverage   18.07%   66.93%   +48.85%     
===========================================
  Files         155      133       -22     
  Lines       24398     7176    -17222     
  Branches     1203     1308      +105     
===========================================
+ Hits         4410     4803      +393     
+ Misses      19988     2373    -17615     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/config.types.ts 100.00% <ø> (ø)
packages/journey-client/src/lib/config.types.ts 100.00% <ø> (ø)
...ges/oidc-client/src/lib/authorize.request.utils.ts 100.00% <ø> (+56.66%) ⬆️
packages/oidc-client/src/lib/config.types.ts 100.00% <ø> (ø)
packages/oidc-client/src/lib/logout.request.ts 100.00% <100.00%> (ø)
packages/oidc-client/src/lib/oidc.api.ts 65.81% <100.00%> (+18.60%) ⬆️
...ckages/sdk-effects/oidc/src/lib/authorize.utils.ts 100.00% <100.00%> (ø)
packages/sdk-types/src/lib/authorize.types.ts 100.00% <ø> (ø)
...kages/sdk-utilities/src/lib/config/config.types.ts 100.00% <100.00%> (ø)
packages/journey-client/src/lib/client.store.ts 82.24% <95.00%> (+1.73%) ⬆️
... and 5 more

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Deployed 0272a8d to https://ForgeRock.github.io/ping-javascript-sdk/pr-684/0272a8d1b6bab91b1ddd0a8c0973d6ba2f1e3eb0 branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔺 @forgerock/sdk-utilities - 14.7 KB (+3.5 KB, +31.6%)
🔺 @forgerock/oidc-client - 31.6 KB (+1.1 KB, +3.5%)

🆕 New Packages

🆕 @forgerock/device-client - 10.0 KB (new)
🆕 @forgerock/device-client - 0.0 KB (new)
🆕 @forgerock/journey-client - 92.2 KB (new)
🆕 @forgerock/journey-client - 0.0 KB (new)

📊 Minor Changes

📈 @forgerock/sdk-types - 8.0 KB (+0.1 KB)
📈 @forgerock/sdk-oidc - 5.7 KB (+0.1 KB)
📈 @forgerock/davinci-client - 54.3 KB (+0.3 KB)

➖ No Changes

@forgerock/protect - 144.6 KB
@forgerock/iframe-manager - 2.4 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-request-middleware - 4.6 KB
@forgerock/sdk-logger - 1.6 KB


14 packages analyzed • Baseline from latest main build

Legend

🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change

ℹ️ How bundle sizes are calculated
  • Current Size: Total gzipped size of all files in the package's dist directory
  • Baseline: Comparison against the latest build from the main branch
  • Files included: All build outputs except source maps and TypeScript build cache
  • Exclusions: .map, .tsbuildinfo, and .d.ts.map files

🔄 Updated automatically on each push to this PR

feat(sdk-utilities): add pure unified config validation

feat(sdk-utilities): add unified config mapping functions

feat(sdk-utilities): export config module from sdk-utilities

test(sdk-utilities): add unit tests for config mapping and validation

feat(sdk-types): add OIDC authorize params to GetAuthorizationUrlOptions

feat(sdk-oidc): wire OIDC authorize params into buildAuthorizeParams

feat(oidc-client): add signOutRedirectUri to endSession URL

feat(oidc-client): accept unified JSON config in oidc factory

feat(journey-client): accept unified JSON config in journey factory

feat(davinci-client): accept unified JSON config in davinci factory

chore: update api-reports for unified config param widening

feat(sdk-utilities): align unified config schema with new journey
sub-object

refactor(sdk-utilities): mapper functions return ConfigMappingResult
with single error

fix(sdk-utilities): map log field and use config.log in factories

fix(sdk-utilities): tighten isUnifiedSdkConfig discriminant to require
object values

fix(oidc-client): use throw instead of Promise.reject in unified config
error paths

refactor(oidc-client): migrate logout.request.test.ts to it +
Micro.runPromise pattern

docs(oidc-client): add JSDoc to OidcConfig and all new fields

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a possible root cause for your failed CI:

This CI failure appears to be related to the environment or external dependencies rather than your code changes.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

Comment on lines +86 to +106
let config: DaVinciConfig;

if (isUnifiedSdkConfig(rawConfig)) {
const validation = validateUnifiedSdkConfig(rawConfig, true);
if (!validation.success) {
const messages = validation.errors.map((e) => `${e.field}: ${e.message}`).join(', ');
throw new Error(`Invalid unified SDK config: ${messages}`);
}
const mapped = unifiedToDavinciConfig(validation.data);
if (!mapped.success) {
throw new Error(`Invalid unified SDK config: ${mapped.error.field}: ${mapped.error.message}`);
}
config = mapped.data as DaVinciConfig;
} else {
config = rawConfig as DaVinciConfig;
}

const log = loggerFn({
level: logger?.level ?? config.log ?? 'error',
custom: logger?.custom,
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not a huge fan of this here. I think we should maybe write a separate validation function if we need to do some validation but i'm concerned about the type of Record<string,unknown> it will break the entire purpose of typing configs.

@@ -4,7 +4,7 @@
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use @effect/vitest if we're testing effect returning functions

* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { it, expect } from '@effect/vitest';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this?

return level.toLowerCase() as MappedLogLevel;
}

const REQUIRED_OIDC_FIELDS_STRICT: ReadonlyArray<keyof UnifiedOidcConfig> = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want an array here? we'd rather an array than a union?


const REQUIRED_OIDC_FIELDS_JOURNEY: ReadonlyArray<keyof UnifiedOidcConfig> = ['discoveryEndpoint'];

function validateType(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per our discussion today, this could be a worthwhile case for Either<_,ConfigValidationError]> and accumulate errors in the error channel

@ryanbas21 ryanbas21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we really need to think about this. I'm concerned about how safe some of our changes here are, breaking changes, and the path we're taking here. I personally feel like we should discuss this more as a team because i'm not positive that this is the right path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants