Skip to content

Recognize callback - #745

Draft
eugeniobet-ping wants to merge 38 commits into
mainfrom
recognize-callback-3
Draft

Recognize callback#745
eugeniobet-ping wants to merge 38 commits into
mainfrom
recognize-callback-3

Conversation

@eugeniobet-ping

Copy link
Copy Markdown
Collaborator

No description provided.

ryanbas21 and others added 30 commits May 19, 2026 15:12
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ors for initialization and element validation
…d SDK

Renames the public web-component type surface from `RecognizeWc*` to
`RecognizeWebComponent*` (e.g. `RecognizeWcConfig` →
`RecognizeWebComponentConfiguration`, `RecognizeWcClient` →
`RecognizeWebComponentClient`, `RecognizeWcCompleteDetail` →
`RecognizeWebComponentCompleteData`) for clarity at the package boundary,
and re-exports `RecognizeError` from the package entry point.

Reworks `RecognizeError` and the error-code taxonomy:

- `RecognizeErrorCode` switches from string values to numeric values
  grouped by domain (SDK 1xxx, CAMERA 2xxx, CORE 3xxx, BIOM 4xxx,
  SERVER 5xxx, SECURITY 6xxx). Several codes are renamed to match the
  upstream SDK vocabulary (`CAMERA_MISSING` → `CAMERA_NOT_FOUND`,
  `SDK_CONFIGURATION_FAILED` → `SDK_INVALID_CONFIGURATION`,
  `SDK_STORAGE_ERROR` → `SDK_STORAGE_FAILED`,
  `SDK_DYNAMIC_LINKING_MALFORMED_PAYLOAD` →
  `SDK_DYNAMIC_LINKING_PAYLOAD_MALFORMED`), and new codes are added
  (`SDK_OUTDATED_APP`, `SDK_INVALID_CUSTOMER_PROPERTIES`,
  `SDK_INVALID_CLIENT_STATE`, `BIOM_GENUINE_PRESENCE_NOT_ESTABLISHED`).
- `RecognizeError`'s constructor now accepts a standard `ErrorOptions`
  bag (`new RecognizeError(code, { cause })`) and forwards it to the
  base `Error` constructor, so `error.message` is the enum name and
  `error.cause` follows the platform contract instead of being assigned
  manually.
- The `createRecognizeError` factory is removed; `recognize.ts` now
  constructs `RecognizeError` directly. The SDK→proxy error map is
  frozen with `Object.freeze` to prevent accidental mutation at runtime.

Updates `recognize()` accordingly:

- Init failures now throw `RecognizeError` (with `SDK_ERROR` /
  `SDK_WEB_ASSEMBLY_IMPORT_FAILED` and a descriptive `cause`) instead of
  returning the error or throwing a plain `Error`.
- Subscribes to two new web-component events, `begin-stream` and
  `stop-stream`, and forwards them through the observer pipeline.
- Internal renames for readability (`effectiveConfig` → `config`,
  `abortController` → `aborter`, `attachListeners` →
  `addEventListeners`, `applyConfig` → `setAttributes`) and a global
  `HTMLElementTagNameMap` augmentation for `kl-auth` / `kl-enroll`.

Refreshes the bundled keyless SDK (`recognize-sdk/index.{js,d.ts}`,
`wasm.{js,wasm}`, `pthreads/wasm.{js,wasm}`) to a new upstream build.
The package's ESLint config now ignores `src/lib/recognize-sdk/**/*`
for dependency-checks since the bundled artifact pulls in transitive
imports that don't belong in the package manifest.

Updates the e2e example and unit tests to match: the example config
includes `authorizationToken`, and the spec asserts the new
`{ message, cause }` shape on thrown `RecognizeError`s.
…eb component options

Update bundled Keyless SDK (index.js, .d.ts, wasm binaries, LICENSE) and wire up the
new surface: recognition-start event, aspectRatio/cameraAspectRatio/cameraInstructions
and enableDatadogPII configuration, CORE_NOT_ENOUGH_CIRCUITS (3005) and
SERVER_AUTHORIZATION_FAILED (5003) error codes, and mappings for SERVER_FORBIDDEN,
SERVER_INVALID_STATE, and SERVER_NO_ATTEMPTS_LEFT. Refactor recognize.ts event
listener wiring to route recognition-failure through the shared onError path and
drop leftover debug logging. Also add pnpm onlyBuiltDependencies allowlist and
remove the empty dependencies block from the root package.json.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…vent in mock

Aliasing the mock class directly to ErrorEvent made every dispatched ErrorEvent
pass the instanceof check in onError and try to call element.dispose(), which
does not exist on the underlying custom element. Use a distinct subclass so
plain error events skip the recoverable path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ff6a89

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

This PR includes changesets to release 13 packages
Name Type
@forgerock/recognize Minor
@forgerock/davinci-client Minor
@forgerock/device-client Minor
@forgerock/journey-client Minor
@forgerock/oidc-client Minor
@forgerock/protect Minor
@forgerock/sdk-types Minor
@forgerock/sdk-utilities Minor
@forgerock/iframe-manager Minor
@forgerock/sdk-logger Minor
@forgerock/sdk-oidc Minor
@forgerock/sdk-request-middleware Minor
@forgerock/storage 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

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21bcf752-3f8d-4548-9b08-6b4af6fda231

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

Comment on lines +80 to +82
new KeylessRecoverableErrorEvent({
error: new Error('SERVER_RECOGNITION_FAILED', { cause: event.detail }),
}),
aborter = new AbortController();

const onError = (event: ErrorEvent): void => {
if (event instanceof KeylessRecoverableErrorEvent) {

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

This is looking good. We just need some unit tests for the callback, and I'd like to see at least some e2e tests that test at least some portion of this feature. I know we can't fully automate the flow, but, like some of our other tests, can we at least test that the parts that can be automated?

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.

4 participants