Skip to content

SDKS-4816: Fix device client type, update READMEs and e2e apps#543

Merged
ancheetah merged 2 commits intomainfrom
2.0-QA-pt2
Mar 6, 2026
Merged

SDKS-4816: Fix device client type, update READMEs and e2e apps#543
ancheetah merged 2 commits intomainfrom
2.0-QA-pt2

Conversation

@ancheetah
Copy link
Collaborator

@ancheetah ancheetah commented Mar 3, 2026

JIRA Ticket

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

Description

  • Fix device profile query type - realm should be optional.
  • Import client types into e2e apps to test type exports
  • Update READMEs with correct type imports
  • Improved OIDC client README

Summary by CodeRabbit

  • New Features

    • Device client now accepts realm as an optional parameter in device profile queries.
  • Documentation

    • Expanded OIDC client docs with installation, initialization, API reference, examples, and error-handling guidance.
    • Clarified device-client README import examples and simplified journey-client quickstart import for callback usage.
  • Chores

    • Bumped device-client patch version in release metadata.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

This PR adds TypeScript type annotations across several e2e apps and docs, makes the realm property optional in device profile types, updates README import patterns and expands the oidc-client README, and adds a changeset entry for @forgerock/device-client.

Changes

Cohort / File(s) Summary
Changeset Entry
.changeset/soft-moose-read.md
Adds a changeset bump for @forgerock/device-client with a note that realm is now optional in device profile queries.
E2E Type Annotations
e2e/davinci-app/components/fido.ts, e2e/device-client-app/src/utils/index.ts, e2e/oidc-app/src/utils/oidc-app.ts, e2e/protect-app/src/protect-native.ts
Adds/imports explicit client types (FidoClient, DeviceClient, OidcClient, Protect) and applies them to local variables — type-only changes, no runtime behavior changes.
Type Definitions
packages/device-client/src/lib/types/profile-device.types.ts
Makes realm optional in GetProfileDevices (realm?: string), impacting typings for device profile queries.
Documentation Updates
packages/device-client/README.md, packages/journey-client/README.md, packages/oidc-client/README.md
Adjusts imports to use type-only import for device-client, updates journey-client example to import callbackType from journey-client, and substantially expands oidc-client README with installation, examples, and API reference.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • ryanbas21
  • cerebrl

Poem

🐰 I hopped through types with gentle cheer,

Made realm optional, linted the rear.
READMEs shimmer, clients wear a name,
Small changeset, but tidy the game. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'SDKS-4816: Fix device client type, update READMEs and e2e apps' accurately summarizes the main changes: fixing device client typing, updating documentation, and modifying e2e applications.
Description check ✅ Passed The description provides the JIRA ticket link and clearly outlines all major changes: device type fix, e2e type imports, README updates, and OIDC documentation improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2.0-QA-pt2

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.

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: b4e6029

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

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

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
Copy link
Contributor

nx-cloud bot commented Mar 3, 2026

View your CI Pipeline Execution ↗ for commit b4e6029

Command Status Duration Result
nx run-many -t build --no-agents ✅ Succeeded <1s View ↗
nx affected -t build lint test typecheck e2e-ci ✅ Succeeded 1m 54s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-04 17:51:15 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/davinci-client@543

@forgerock/device-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/device-client@543

@forgerock/journey-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/journey-client@543

@forgerock/oidc-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/oidc-client@543

@forgerock/protect

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/protect@543

@forgerock/sdk-types

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-types@543

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-utilities@543

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/iframe-manager@543

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-logger@543

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-oidc@543

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-request-middleware@543

@forgerock/storage

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/storage@543

commit: b4e6029

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 14.75%. Comparing base (b89ad58) to head (b4e6029).
⚠️ Report is 55 commits behind head on main.

❌ Your project status has failed because the head coverage (14.75%) is below the target coverage (40.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #543      +/-   ##
==========================================
- Coverage   18.79%   14.75%   -4.05%     
==========================================
  Files         140      153      +13     
  Lines       27640    26265    -1375     
  Branches      980     1054      +74     
==========================================
- Hits         5195     3875    -1320     
+ Misses      22445    22390      -55     
Files with missing lines Coverage Δ
...evice-client/src/lib/types/profile-device.types.ts 100.00% <ø> (ø)

... and 49 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
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Deployed 828590d to https://ForgeRock.github.io/ping-javascript-sdk/pr-543/828590df5f7c103b09b3819efa1123809b0781f2 branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🆕 New Packages

🆕 @forgerock/journey-client - 87.3 KB (new)
🆕 @forgerock/journey-client - 0.0 KB (new)

📊 Minor Changes

📈 @forgerock/device-client - 9.2 KB (+0.0 KB)

➖ No Changes

@forgerock/sdk-logger - 1.6 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/iframe-manager - 2.4 KB
@forgerock/sdk-oidc - 4.8 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-types - 7.9 KB
@forgerock/protect - 150.1 KB
@forgerock/davinci-client - 41.3 KB
@forgerock/sdk-utilities - 11.2 KB
@forgerock/oidc-client - 24.9 KB


13 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

@ancheetah ancheetah marked this pull request as ready for review March 3, 2026 22:18
@ancheetah ancheetah requested review from cerebrl and ryanbas21 March 3, 2026 22:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/oidc-client/README.md (1)

19-35: ⚠️ Potential issue | 🟡 Minor

Fix the token.exchange quickstart call signature.

The quickstart shows passing a single object, but the API expects positional code and state arguments as per the actual implementation.

📘 Suggested README fix
-const newTokens = await oidcClient.token.exchange({
-  /* code, state */
-}); // Returns new tokens or error
+const code = '...';
+const state = '...';
+const newTokens = await oidcClient.token.exchange(code, state); // Returns new tokens or error
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/oidc-client/README.md` around lines 19 - 35, The README example
incorrectly calls oidcClient.token.exchange with a single object; update the
quickstart to call the actual implementation signature by passing code and state
as positional arguments to oidcClient.token.exchange (e.g., call exchange(code,
state)), and update the surrounding comment to reflect it returns new tokens or
an error; locate the example block using the symbol oidcClient.token.exchange
and replace the single-object call with the positional-argument form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/oidc-client/README.md`:
- Around line 19-35: The README example incorrectly calls
oidcClient.token.exchange with a single object; update the quickstart to call
the actual implementation signature by passing code and state as positional
arguments to oidcClient.token.exchange (e.g., call exchange(code, state)), and
update the surrounding comment to reflect it returns new tokens or an error;
locate the example block using the symbol oidcClient.token.exchange and replace
the single-object call with the positional-argument form.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea79b4 and 7bd1377.

📒 Files selected for processing (9)
  • .changeset/soft-moose-read.md
  • e2e/davinci-app/components/fido.ts
  • e2e/device-client-app/src/utils/index.ts
  • e2e/oidc-app/src/utils/oidc-app.ts
  • e2e/protect-app/src/protect-native.ts
  • packages/device-client/README.md
  • packages/device-client/src/lib/types/profile-device.types.ts
  • packages/journey-client/README.md
  • packages/oidc-client/README.md

@ancheetah ancheetah changed the title Fix device client type, update READMEs and e2e apps SDKS-4816: Fix device client type, update READMEs and e2e apps Mar 3, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/journey-client/README.md (1)

127-131: Narrow caught errors in TypeScript examples for robustness.

While strict mode alone doesn't require type narrowing of catch variables, narrowing with instanceof Error is a best practice that makes documentation examples more defensive and aligns with TypeScript ecosystem standards. This improves clarity for users working with strict configurations.

Suggested doc fix
 } catch (error) {
-  console.error('Initialization failed:', error.message);
+  console.error(
+    'Initialization failed:',
+    error instanceof Error ? error.message : String(error),
+  );
 }

Also applies to: 240-246

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/journey-client/README.md` around lines 127 - 131, The example's
catch block uses an un-narrowed catch variable; update the try/catch around the
journey({ config }) call to treat the caught value as unknown and narrow it with
instanceof Error before accessing message — reference the journey function and
the client variable in the example and replace direct error.message access with
a guarded check (e.g., if (error instanceof Error) {
console.error('Initialization failed:', error.message) } else {
console.error('Initialization failed:', error) }) so the TypeScript example is
robust under strict settings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/oidc-client/README.md`:
- Line 282: Change the phrase "error handling pattern" to the hyphenated
compound modifier "error-handling pattern" in the README sentence that starts
"The library uses a consistent error handling pattern..." so the line reads "The
library uses a consistent error-handling pattern." This is a simple grammar
update to the documentation string referencing the check for an `error`
property.
- Around line 206-213: The example calls oidcClient.token.exchange(code, state)
but URLSearchParams.get may return null; validate that the retrieved code and
state are non-null strings before calling token.exchange (check
urlParams.get('code') and urlParams.get('state') and handle the missing-case
with an error/log or redirect), and only pass the validated string values to
oidcClient.token.exchange to avoid runtime errors in the token exchange flow.
- Around line 73-77: The example uses authResponse.code and authResponse.state
without first checking that authorize.background() succeeded; update the sample
to guard the authorize.background() result (authResponse) and only call
oidcClient.token.exchange(authResponse.code, authResponse.state) when
authResponse indicates success (not an error), e.g., by branching on the result
type or presence of an error field before passing authResponse.code and
authResponse.state to token.exchange(); reference authorize.background(),
authResponse, and token.exchange() when implementing the guard.

---

Nitpick comments:
In `@packages/journey-client/README.md`:
- Around line 127-131: The example's catch block uses an un-narrowed catch
variable; update the try/catch around the journey({ config }) call to treat the
caught value as unknown and narrow it with instanceof Error before accessing
message — reference the journey function and the client variable in the example
and replace direct error.message access with a guarded check (e.g., if (error
instanceof Error) { console.error('Initialization failed:', error.message) }
else { console.error('Initialization failed:', error) }) so the TypeScript
example is robust under strict settings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0e69d5cb-6e09-4752-b621-63b429c219ba

📥 Commits

Reviewing files that changed from the base of the PR and between b4940c7 and b4e6029.

📒 Files selected for processing (7)
  • e2e/davinci-app/components/fido.ts
  • e2e/device-client-app/src/utils/index.ts
  • e2e/oidc-app/src/utils/oidc-app.ts
  • e2e/protect-app/src/protect-native.ts
  • packages/device-client/README.md
  • packages/journey-client/README.md
  • packages/oidc-client/README.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • e2e/oidc-app/src/utils/oidc-app.ts
  • e2e/device-client-app/src/utils/index.ts
  • e2e/protect-app/src/protect-native.ts
  • packages/device-client/README.md
  • e2e/davinci-app/components/fido.ts

Comment on lines +73 to +77
const authResponse = await oidcClient.authorize.background();

// Get tokens
const tokens = await oidcClient.token.exchange(authResponse.code, authResponse.state);

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard authorize.background() result before using code/state.

This example calls token.exchange() before narrowing out the error branch. If authResponse is an error object, code/state are not guaranteed.

Suggested doc fix
 // Start authorization in the background
 const authResponse = await oidcClient.authorize.background();

-// Get tokens
-const tokens = await oidcClient.token.exchange(authResponse.code, authResponse.state);
+if ('error' in authResponse) {
+  console.error('Authorization failed:', authResponse.error);
+  return;
+}
+
+// Get tokens
+const tokens = await oidcClient.token.exchange(authResponse.code, authResponse.state);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/oidc-client/README.md` around lines 73 - 77, The example uses
authResponse.code and authResponse.state without first checking that
authorize.background() succeeded; update the sample to guard the
authorize.background() result (authResponse) and only call
oidcClient.token.exchange(authResponse.code, authResponse.state) when
authResponse indicates success (not an error), e.g., by branching on the result
type or presence of an error field before passing authResponse.code and
authResponse.state to token.exchange(); reference authorize.background(),
authResponse, and token.exchange() when implementing the guard.

Comment on lines +206 to +213
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const state = urlParams.get('state');

const tokens = await oidcClient.token.exchange(code, state);
if ('error' in tokens) {
console.error('Failed to exchange code for tokens:', tokens.error);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Validate code and state before token exchange.

URLSearchParams.get() can return null, but token.exchange() requires string inputs. The example should guard missing params.

Suggested doc fix
 const urlParams = new URLSearchParams(window.location.search);
 const code = urlParams.get('code');
 const state = urlParams.get('state');

-const tokens = await oidcClient.token.exchange(code, state);
+if (!code || !state) {
+  console.error('Missing authorization code/state in callback URL');
+  return;
+}
+
+const tokens = await oidcClient.token.exchange(code, state);
 if ('error' in tokens) {
   console.error('Failed to exchange code for tokens:', tokens.error);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const state = urlParams.get('state');
const tokens = await oidcClient.token.exchange(code, state);
if ('error' in tokens) {
console.error('Failed to exchange code for tokens:', tokens.error);
}
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get('code');
const state = urlParams.get('state');
if (!code || !state) {
console.error('Missing authorization code/state in callback URL');
return;
}
const tokens = await oidcClient.token.exchange(code, state);
if ('error' in tokens) {
console.error('Failed to exchange code for tokens:', tokens.error);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/oidc-client/README.md` around lines 206 - 213, The example calls
oidcClient.token.exchange(code, state) but URLSearchParams.get may return null;
validate that the retrieved code and state are non-null strings before calling
token.exchange (check urlParams.get('code') and urlParams.get('state') and
handle the missing-case with an error/log or redirect), and only pass the
validated string values to oidcClient.token.exchange to avoid runtime errors in
the token exchange flow.

}); // Returns new tokens or error
const existingTokens = await oidcClient.token.get(); // Returns existing tokens or error
const response = await oidcClient.token.revoke(); // Revokes an access token and returns the response or an error
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:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use hyphenated compound modifier: error-handling pattern.

Minor doc grammar fix for consistency/readability.

🧰 Tools
🪛 LanguageTool

[grammar] ~282-~282: Use a hyphen to join words.
Context: ...ing The library uses a consistent error handling pattern. All methods return eit...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/oidc-client/README.md` at line 282, Change the phrase "error
handling pattern" to the hyphenated compound modifier "error-handling pattern"
in the README sentence that starts "The library uses a consistent error handling
pattern..." so the line reads "The library uses a consistent error-handling
pattern." This is a simple grammar update to the documentation string
referencing the check for an `error` property.

@ancheetah
Copy link
Collaborator Author

Improved OIDC client README again with AI. Please re-review the readme.

@ancheetah ancheetah requested a review from cerebrl March 5, 2026 15:49
@ancheetah ancheetah merged commit d119831 into main Mar 6, 2026
8 checks passed
@ancheetah ancheetah deleted the 2.0-QA-pt2 branch March 6, 2026 16:11
@ryanbas21 ryanbas21 mentioned this pull request Mar 5, 2026
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