Recognize callback - #745
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ors for initialization and element validation
…rove type definitions
…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.
…on-cancelable events from Keyless SDK v3
…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>
…ode enum to plain objects
… recognize errors and exported types
… @aracna/core types
🦋 Changeset detectedLatest commit: 7ff6a89 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
| new KeylessRecoverableErrorEvent({ | ||
| error: new Error('SERVER_RECOGNITION_FAILED', { cause: event.detail }), | ||
| }), |
| aborter = new AbortController(); | ||
|
|
||
| const onError = (event: ErrorEvent): void => { | ||
| if (event instanceof KeylessRecoverableErrorEvent) { |
cerebrl
left a comment
There was a problem hiding this comment.
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?
No description provided.