Skip to content

feat(davinci-client): mfa otp field support#262

Merged
cerebrl merged 1 commit into
mainfrom
feat_mfa-otp
Apr 28, 2025
Merged

feat(davinci-client): mfa otp field support#262
cerebrl merged 1 commit into
mainfrom
feat_mfa-otp

Conversation

@cerebrl

@cerebrl cerebrl commented Apr 24, 2025

Copy link
Copy Markdown
Collaborator

JIRA Ticket

SDKS-3901

Description

Adds MFA OTP (email, sms, voice) to field support.

Changeset: Yes!

@changeset-bot

changeset-bot Bot commented Apr 24, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e38b49e

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

This PR includes changesets to release 6 packages
Name Type
@forgerock/davinci-client Minor
@forgerock/sdk-types Minor
@forgerock/sdk-utilities Minor
@forgerock/sdk-logger Minor
@forgerock/sdk-oidc 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 Apr 24, 2025

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit e38b49e.

Command Status Duration Result
nx affected -t build typecheck lint test e2e-ci ✅ Succeeded 1m 34s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-28 19:51:24 UTC

@github-actions

github-actions Bot commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

Deployed b3df0d6 to https://ForgeRock.github.io/ping-javascript-sdk/pr-262/b3df0d65173ef64ec5af80c74931ac2d991fe858 branch gh-pages in ForgeRock/ping-javascript-sdk

@codecov-commenter

codecov-commenter commented Apr 24, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 83.18584% with 19 lines in your changes missing coverage. Please review.

Project coverage is 55.50%. Comparing base (6cdc7b8) to head (e38b49e).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/davinci-client/src/lib/node.reducer.ts 75.00% 8 Missing ⚠️
packages/davinci-client/src/lib/collector.utils.ts 92.10% 6 Missing ⚠️
packages/davinci-client/src/lib/client.store.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #262      +/-   ##
==========================================
+ Coverage   47.35%   55.50%   +8.15%     
==========================================
  Files          29       20       -9     
  Lines        1472     1380      -92     
  Branches      148      163      +15     
==========================================
+ Hits          697      766      +69     
+ Misses        775      614     -161     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/collector.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/davinci.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/node.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/client.store.ts 0.44% <0.00%> (-0.01%) ⬇️
packages/davinci-client/src/lib/collector.utils.ts 85.10% <92.10%> (+1.09%) ⬆️
packages/davinci-client/src/lib/node.reducer.ts 75.59% <75.00%> (-0.20%) ⬇️

... and 9 files with indirect coverage changes

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

@ryanbas21

Copy link
Copy Markdown
Collaborator

@cerebrl changeset bot is having an issue detecting your changeset, could you manually remove it, then push it back up as its own commit so that maybe the force push doesn't mess up its commit tracking?


if (collector.type === 'DeviceRegistrationCollector') {
if (typeof action.payload.id !== 'string') {
throw new Error('Index argument must be a string');

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.

Are we wanting to throw errors? if so - should this throw a TypeError?

* @param {ObjectValueCollectorTypes} [collectorType] - Optional type of the ObjectCollector.
* @returns {ObjectCollector} The constructed ObjectCollector object.
*/
export function returnObjectCollector<

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.

Not blocking by any means, but in the spirit of our discussion of a pipeable api,

we could probably refactor this and similar functions like returnActionCollector and returnSingleValueCollector to be this type of api, and reduce duplication in checking the errors.

I think we can abstract the error checking as their own functions and we can then have a "switch" type function for the device return

pipe(
  field,
  checkForKeyInField,
  checkForLabelInField,
  checkForTypeInField,
  mapTypeToDevice
 )

How we want to handle the "error" channel here is up to us, but I think if we wanted an api in this manner, these style internal functions have very similar structures that can be re-used in a pipeline roughly like this

Just leaving as food for thought, not required for this PR.

Comment thread packages/davinci-client/src/lib/collector.types.ts
Comment thread packages/davinci-client/src/lib/collector.types.ts
required: boolean;
};

export type DaVinciField =

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.

As this "type" grows, I wonder if we should consider breaking this into some groups of subtypes.

Not blocking for this PR, and I do think this organization has pro's but also negatives as we have to think about where things go and this is exposed to the consumer, so we'd want to document this well so a consumer knows what these fields are when dealing with more "primitive" types to the group.

i.e. DeviceFields | InputFields | ValidationFields | RedirectFields (naming subject to change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree with this. I'll do it now.


if (collector.type === 'DeviceAuthenticationCollector') {
if (typeof action.payload.id !== 'string') {
throw new Error('Index argument must be a string');

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.

TypeError? What is the thought process in returning a error here versus our current idea of not returning errors?

Since we aren't catching this we are returning this to the user here, is this a new pattern?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As mentioned on the call, this is not a new pattern, and the thrown error doesn't actually make it to the user. The original caller catches it, but I agree with your overall sentiment. We should revisit this and see if there's a better pattern.

export function returnObjectCollector<
Field extends DeviceAuthenticationFieldValue | DeviceRegistrationFieldValue,
CollectorType extends ObjectValueCollectorTypes = 'ObjectValueCollector',
>(field: Field, idx: number, collectorType: CollectorType) {

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 wondering if we should restructure how across the board we are doing function arguments to be composable.

I just think how can we use these functions within a pipe and it's pretty difficult.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree. As to not make this into a large refactor, let's save these changes until the implementation of our new "pipe" solution.

@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.

LGTM

@cerebrl cerebrl merged commit d428a76 into main Apr 28, 2025
3 checks passed
@ryanbas21 ryanbas21 mentioned this pull request Apr 28, 2025
@SteinGabriel SteinGabriel deleted the feat_mfa-otp branch April 17, 2026 15:50
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