@idmission/websdk-ui 0.2.0-rc.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +147 -56
  2. package/dist/DocumentCaptureView.d.ts +37 -0
  3. package/dist/DocumentCaptureView.d.ts.map +1 -1
  4. package/dist/DocumentCaptureView.js +489 -6
  5. package/dist/FaceLivenessView.d.ts +1 -1
  6. package/dist/FaceLivenessView.d.ts.map +1 -1
  7. package/dist/FaceLivenessView.js +37 -29
  8. package/dist/IdCaptureView.d.ts +6 -5
  9. package/dist/IdCaptureView.d.ts.map +1 -1
  10. package/dist/IdCaptureView.js +52 -12
  11. package/dist/SelfieCaptureView.d.ts +1 -1
  12. package/dist/SelfieCaptureView.d.ts.map +1 -1
  13. package/dist/SelfieCaptureView.js +6 -3
  14. package/dist/SignatureCaptureView.d.ts +9 -1
  15. package/dist/SignatureCaptureView.d.ts.map +1 -1
  16. package/dist/SignatureCaptureView.js +51 -10
  17. package/dist/VideoIdCaptureView.d.ts +1 -1
  18. package/dist/VideoIdCaptureView.d.ts.map +1 -1
  19. package/dist/VideoIdCaptureView.js +24 -4
  20. package/dist/components/CameraFeed.d.ts +11 -3
  21. package/dist/components/CameraFeed.d.ts.map +1 -1
  22. package/dist/components/CameraFeed.js +24 -4
  23. package/dist/components/barcode/BarcodeGuideOverlay.d.ts +7 -1
  24. package/dist/components/barcode/BarcodeGuideOverlay.d.ts.map +1 -1
  25. package/dist/components/barcode/BarcodeGuideOverlay.js +2 -2
  26. package/dist/components/debug/debug.d.ts +4 -4
  27. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts +29 -0
  28. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts.map +1 -0
  29. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.js +274 -0
  30. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts +56 -0
  31. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts.map +1 -0
  32. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.js +101 -0
  33. package/dist/components/document/DocumentCaptureGuideOverlay.d.ts +31 -1
  34. package/dist/components/document/DocumentCaptureGuideOverlay.d.ts.map +1 -1
  35. package/dist/components/document/DocumentCaptureGuideOverlay.js +121 -2
  36. package/dist/components/document/DocumentCaptureReviewScreen.d.ts +44 -0
  37. package/dist/components/document/DocumentCaptureReviewScreen.d.ts.map +1 -0
  38. package/dist/components/document/DocumentCaptureReviewScreen.js +40 -0
  39. package/dist/components/document/types.d.ts +25 -0
  40. package/dist/components/document/types.d.ts.map +1 -1
  41. package/dist/components/document/types.js +18 -1
  42. package/dist/components/guides/IdCaptureGuides.d.ts.map +1 -1
  43. package/dist/components/guides/IdCaptureGuides.js +3 -4
  44. package/dist/components/review/ReviewScreen.d.ts.map +1 -1
  45. package/dist/components/review/ReviewScreen.js +1 -1
  46. package/dist/components/review/SignatureCaptureDiagnostics.d.ts +50 -0
  47. package/dist/components/review/SignatureCaptureDiagnostics.d.ts.map +1 -0
  48. package/dist/components/review/SignatureCaptureDiagnostics.js +142 -0
  49. package/dist/components/selfie/SelfieCaptureSurface.d.ts +11 -2
  50. package/dist/components/selfie/SelfieCaptureSurface.d.ts.map +1 -1
  51. package/dist/components/selfie/SelfieCaptureSurface.js +5 -2
  52. package/dist/components/videoId/VideoIdCaptureGuides.d.ts +4 -1
  53. package/dist/components/videoId/VideoIdCaptureGuides.d.ts.map +1 -1
  54. package/dist/components/videoId/VideoIdCaptureGuides.js +2 -2
  55. package/dist/flows/CompositeWizard.d.ts +5 -0
  56. package/dist/flows/CompositeWizard.d.ts.map +1 -1
  57. package/dist/flows/CompositeWizard.js +2 -1
  58. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts +13 -0
  59. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts.map +1 -1
  60. package/dist/flows/CustomerBiometricsEnrollmentFlow.js +8 -3
  61. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts +25 -0
  62. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts.map +1 -1
  63. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.js +12 -5
  64. package/dist/flows/DocumentCaptureFlow.d.ts +7 -1
  65. package/dist/flows/DocumentCaptureFlow.d.ts.map +1 -1
  66. package/dist/flows/DocumentCaptureFlow.js +10 -7
  67. package/dist/flows/FaceValidationFlow.d.ts +7 -0
  68. package/dist/flows/FaceValidationFlow.d.ts.map +1 -1
  69. package/dist/flows/FaceValidationFlow.js +6 -2
  70. package/dist/flows/IdAndFaceValidationFlow.d.ts +19 -0
  71. package/dist/flows/IdAndFaceValidationFlow.d.ts.map +1 -1
  72. package/dist/flows/IdAndFaceValidationFlow.js +10 -4
  73. package/dist/flows/IdValidationFlow.d.ts +12 -0
  74. package/dist/flows/IdValidationFlow.d.ts.map +1 -1
  75. package/dist/flows/IdValidationFlow.js +6 -2
  76. package/dist/flows/SignatureKYCFlow.d.ts +13 -0
  77. package/dist/flows/SignatureKYCFlow.d.ts.map +1 -1
  78. package/dist/flows/SignatureKYCFlow.js +8 -3
  79. package/dist/flows/SubmissionProvider.d.ts.map +1 -1
  80. package/dist/flows/SubmissionProvider.js +2 -4
  81. package/dist/flows/VideoIdValidationFlow.d.ts +25 -1
  82. package/dist/flows/VideoIdValidationFlow.d.ts.map +1 -1
  83. package/dist/flows/VideoIdValidationFlow.js +12 -5
  84. package/dist/flows/approval.d.ts +15 -0
  85. package/dist/flows/approval.d.ts.map +1 -0
  86. package/dist/flows/approval.js +19 -0
  87. package/dist/flows/autoCaptureMountGuard.d.ts +22 -0
  88. package/dist/flows/autoCaptureMountGuard.d.ts.map +1 -0
  89. package/dist/flows/autoCaptureMountGuard.js +61 -0
  90. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts +7 -0
  91. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts.map +1 -1
  92. package/dist/flows/customerMatch/CustomerMatchFlow.js +4 -1
  93. package/dist/flows/latestCallbacks.d.ts +31 -0
  94. package/dist/flows/latestCallbacks.d.ts.map +1 -0
  95. package/dist/flows/latestCallbacks.js +56 -0
  96. package/dist/flows/ringScreens.d.ts +0 -3
  97. package/dist/flows/ringScreens.d.ts.map +1 -1
  98. package/dist/flows/ringScreens.js +2 -3
  99. package/dist/guidance/selfieStrings.d.ts +9 -1
  100. package/dist/guidance/selfieStrings.d.ts.map +1 -1
  101. package/dist/guidance/selfieStrings.js +59 -20
  102. package/dist/i18n/index.d.ts +28 -1177
  103. package/dist/i18n/index.d.ts.map +1 -1
  104. package/dist/i18n/index.js +58 -22
  105. package/dist/i18n/locales/threeOh.d.ts +4 -0
  106. package/dist/i18n/locales/threeOh.d.ts.map +1 -0
  107. package/dist/i18n/locales/threeOh.js +105 -0
  108. package/dist/index.d.ts +3 -0
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +1 -0
  111. package/dist/testing/autoCaptureFrames.d.ts +23 -0
  112. package/dist/testing/autoCaptureFrames.d.ts.map +1 -0
  113. package/dist/testing/autoCaptureFrames.js +187 -0
  114. package/dist/testing/fakeDocumentController.d.ts +7 -1
  115. package/dist/testing/fakeDocumentController.d.ts.map +1 -1
  116. package/dist/testing/fakeDocumentController.js +10 -2
  117. package/dist/testing/index.d.ts +1 -0
  118. package/dist/testing/index.d.ts.map +1 -1
  119. package/dist/testing/index.js +1 -0
  120. package/dist/useIdmissionClient.d.ts +29 -0
  121. package/dist/useIdmissionClient.d.ts.map +1 -0
  122. package/dist/useIdmissionClient.js +44 -0
  123. package/dist/utils/canvas.d.ts.map +1 -1
  124. package/dist/utils/canvas.js +41 -0
  125. package/dist/version.d.ts +1 -1
  126. package/dist/version.d.ts.map +1 -1
  127. package/dist/version.js +1 -1
  128. package/package.json +3 -2
@@ -19,6 +19,7 @@ import { RingFailureScreen, } from '../../components/ring/RingFailureScreen';
19
19
  import { RingSuccessScreen, } from '../../components/ring/RingSuccessScreen';
20
20
  import { readFlowElapsedMs, resetFlowClock, markFlowStart } from '../../utils/flowClock';
21
21
  import { FlowChassis } from '../FlowChassis';
22
+ import { useLatestCallbacks } from '../latestCallbacks';
22
23
  import { impliedAutoContinueAfterLoading, isRingIntroActive, } from '../ringIntroImplications';
23
24
  import { SubmissionErrorOverlay } from '../overlays';
24
25
  import { useShowSuccessScreen } from '../useShowSuccessScreen';
@@ -72,13 +73,15 @@ const EMPTY_SUBMISSION = {};
72
73
  const EMPTY_ARTIFACTS = {};
73
74
  export function CustomerMatchFlow({ action, adapter, variant, client, submission = EMPTY_SUBMISSION, initialArtifacts = EMPTY_ARTIFACTS, controller, capture = EMPTY_CAPTURE, view = EMPTY_VIEW, theme, className, geolocationEnabled, geolocationRequired, remoteDiagnostics, loadingSpinner, useFrontendLivenessToken = false, timeoutDurationMs = DEFAULT_CAPTURE_GUIDANCE_TIMEOUT_MS, skipSuccessScreen = false, assets = {}, classNames = {}, colors = {}, verbiage = {}, onComplete, onCustomerMatched, onCustomerNotMatched, onRequestFailure, onCaptureGuidanceTimeout, onExitCapture, onExitAfterFailure, }) {
74
75
  const { checkLivenessOptions, ...controllerCapture } = capture;
76
+ // Config callbacks follow the latest render; see useLatestCallbacks.
77
+ const latestCapture = useLatestCallbacks(controllerCapture);
75
78
  // These flows drive the live-check themselves, per capture, and read its
76
79
  // verdict — so the controller is created WITHOUT a `liveness` config. That is
77
80
  // what keeps them on plain selfie capture instead of the challenge-response
78
81
  // liveness machine FaceLivenessView uses.
79
82
  const [resolvedController] = useState(() => controller ??
80
83
  createSelfieCaptureController({
81
- ...controllerCapture,
84
+ ...latestCapture,
82
85
  // Same wiring every other flow does. `view.showIntroScreen` is
83
86
  // meaningless without it: attach() would acquire the camera eagerly
84
87
  // and latch `camera.accessRequested` before the intro could render,
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Builds a copy of `config` whose function-valued fields call the LATEST
3
+ * config `read()` returns, instead of the function present when the copy was
4
+ * made. Non-function fields are copied once.
5
+ *
6
+ * Pure core of `useLatestCallbacks`, exported for tests and for callers that
7
+ * hold the config in something other than a React ref.
8
+ */
9
+ export declare function withLatestCallbacks<T extends object | undefined>(config: T, read: () => T): T;
10
+ /**
11
+ * Makes the callbacks inside a controller config follow the caller's latest
12
+ * render.
13
+ *
14
+ * Every flow builds its core controller once, in a lazy `useState`, from the
15
+ * config bag it was mounted with. The callbacks in that bag
16
+ * (`onDocumentDetected`, `onSignatureValidityConcern`, the selfie `liveness`
17
+ * notifications, …) would otherwise be frozen at their mount-time closure: an
18
+ * inline arrow that reads component state would keep being called with the
19
+ * state from the first render, and nothing at compile time or runtime would
20
+ * say so. Flow-level callback props already escape this with refs; this
21
+ * applies the same rule to callbacks nested in config, so an integrator can
22
+ * write the config inline without `useMemo`/`useCallback`.
23
+ *
24
+ * The returned object is created once and is referentially stable. Its
25
+ * non-function fields are the mount-time values — they are mount-only
26
+ * configuration by design (see each flow's `capture` prop). A callback must
27
+ * be present at mount to be followed; one added on a later render is not
28
+ * observed.
29
+ */
30
+ export declare function useLatestCallbacks<T extends object | undefined>(config: T): T;
31
+ //# sourceMappingURL=latestCallbacks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latestCallbacks.d.ts","sourceRoot":"","sources":["../../src/flows/latestCallbacks.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,EAC9D,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,MAAM,CAAC,GACZ,CAAC,CAWH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAQ7E"}
@@ -0,0 +1,56 @@
1
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+ // Layout effect in the browser so the ref is updated before any post-commit
3
+ // work can call a callback; plain effect on the server, where React 18 warns
4
+ // about useLayoutEffect.
5
+ const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
6
+ /**
7
+ * Builds a copy of `config` whose function-valued fields call the LATEST
8
+ * config `read()` returns, instead of the function present when the copy was
9
+ * made. Non-function fields are copied once.
10
+ *
11
+ * Pure core of `useLatestCallbacks`, exported for tests and for callers that
12
+ * hold the config in something other than a React ref.
13
+ */
14
+ export function withLatestCallbacks(config, read) {
15
+ if (!config)
16
+ return config;
17
+ const result = { ...config };
18
+ for (const key of Object.keys(result)) {
19
+ if (typeof result[key] !== 'function')
20
+ continue;
21
+ result[key] = (...args) => {
22
+ const latest = read()?.[key];
23
+ return typeof latest === 'function' ? latest(...args) : undefined;
24
+ };
25
+ }
26
+ return result;
27
+ }
28
+ /**
29
+ * Makes the callbacks inside a controller config follow the caller's latest
30
+ * render.
31
+ *
32
+ * Every flow builds its core controller once, in a lazy `useState`, from the
33
+ * config bag it was mounted with. The callbacks in that bag
34
+ * (`onDocumentDetected`, `onSignatureValidityConcern`, the selfie `liveness`
35
+ * notifications, …) would otherwise be frozen at their mount-time closure: an
36
+ * inline arrow that reads component state would keep being called with the
37
+ * state from the first render, and nothing at compile time or runtime would
38
+ * say so. Flow-level callback props already escape this with refs; this
39
+ * applies the same rule to callbacks nested in config, so an integrator can
40
+ * write the config inline without `useMemo`/`useCallback`.
41
+ *
42
+ * The returned object is created once and is referentially stable. Its
43
+ * non-function fields are the mount-time values — they are mount-only
44
+ * configuration by design (see each flow's `capture` prop). A callback must
45
+ * be present at mount to be followed; one added on a later render is not
46
+ * observed.
47
+ */
48
+ export function useLatestCallbacks(config) {
49
+ const ref = useRef(config);
50
+ // Assigned after commit, not during render: a concurrent render React
51
+ // discards must not leave its closures behind for core to call.
52
+ useIsomorphicLayoutEffect(() => {
53
+ ref.current = config;
54
+ });
55
+ return useState(() => withLatestCallbacks(config, () => ref.current))[0];
56
+ }
@@ -1,9 +1,6 @@
1
- import type { SubmissionResponse } from '@idmission/websdk-core/client';
2
1
  import type { CompositeWizardFinishingScreenProps, CompositeWizardSuccessScreenProps } from './CompositeWizard';
3
2
  import type { RingFinishingScreenClassNames, RingFinishingScreenVerbiage } from '../components/ring/RingFinishingScreen';
4
3
  import type { RingSuccessScreenClassNames, RingSuccessScreenVerbiage } from '../components/ring/RingSuccessScreen';
5
- /** sdk2's `isApprovedResponse` (IdValidation.tsx:89-90), shared by every flow. */
6
- export declare const isApprovedResponse: (response: SubmissionResponse) => boolean;
7
4
  export type RingScreenOptions = {
8
5
  /** Usually `view.loadingOverlayMode === 'ring'` for the flow's FIRST stage. */
9
6
  ringMode: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ringScreens.d.ts","sourceRoot":"","sources":["../../src/flows/ringScreens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EACV,mCAAmC,EACnC,iCAAiC,EAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,sCAAsC,CAAA;AAE7C,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,GAAI,UAAU,kBAAkB,KAAG,OACR,CAAA;AAE1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAA;IACjB,iBAAiB,CAAC,EAAE,2BAA2B,CAAA;IAC/C,eAAe,CAAC,EAAE,yBAAyB,CAAA;IAC3C,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;IAChD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,6BAA6B,CAAA;IACnD,iBAAiB,CAAC,EAAE,2BAA2B,CAAA;CAChD,CAAA;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,GAAG;IACrB,eAAe,EAAE,mCAAmC,CAAA;IACpD,aAAa,EAAE,iCAAiC,CAAA;CACjD,CAeA"}
1
+ {"version":3,"file":"ringScreens.d.ts","sourceRoot":"","sources":["../../src/flows/ringScreens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,mCAAmC,EACnC,iCAAiC,EAClC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,sCAAsC,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAA;IACjB,iBAAiB,CAAC,EAAE,2BAA2B,CAAA;IAC/C,eAAe,CAAC,EAAE,yBAAyB,CAAA;IAC3C,kBAAkB,CAAC,EAAE,2BAA2B,CAAA;IAChD,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,6BAA6B,CAAA;IACnD,iBAAiB,CAAC,EAAE,2BAA2B,CAAA;CAChD,CAAA;AAED,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,GAClB,EAAE,iBAAiB,GAAG;IACrB,eAAe,EAAE,mCAAmC,CAAA;IACpD,aAAa,EAAE,iCAAiC,CAAA;CACjD,CAgBA"}
@@ -1,5 +1,3 @@
1
- /** sdk2's `isApprovedResponse` (IdValidation.tsx:89-90), shared by every flow. */
2
- export const isApprovedResponse = (response) => response.resultData['verificationResult'] === 'Approved';
3
1
  export function buildRingScreenProps({ ringMode, finishingVerbiage, successVerbiage, finishingOverrides, successOverrides, finishingClassNames, successClassNames, }) {
4
2
  const mode = ringMode ? 'ring' : 'default';
5
3
  return {
@@ -8,9 +6,10 @@ export function buildRingScreenProps({ ringMode, finishingVerbiage, successVerbi
8
6
  verbiage: { ...finishingVerbiage, ...finishingOverrides },
9
7
  classNames: finishingClassNames,
10
8
  },
9
+ // No `isApproved`: CompositeWizard classifies from the submission action
10
+ // (approval.ts), so enrollment's 'Customer Onboarded' counts as success.
11
11
  successScreen: {
12
12
  mode,
13
- isApproved: isApprovedResponse,
14
13
  verbiage: { ...successVerbiage, ...successOverrides },
15
14
  classNames: successClassNames,
16
15
  },
@@ -1,6 +1,7 @@
1
- import { SelfieGuidanceCode } from '@idmission/websdk-core/selfieCapture';
1
+ import { FaceMessageCode, SelfieGuidanceCode } from '@idmission/websdk-core/selfieCapture';
2
2
  import type { ChallengeRunnerSnapshot, LivenessMachineState } from '@idmission/websdk-core/selfieCapture';
3
3
  export declare function selfieGuidanceMessageKey(code: SelfieGuidanceCode): string;
4
+ export declare function faceMessageKey(code: FaceMessageCode): string;
4
5
  /**
5
6
  * sdk2's guidance-pill variant selection: `negative` (FAILED/ERROR/covering
6
7
  * states, supplied by the liveness view) always wins; otherwise `satisfied`
@@ -10,9 +11,16 @@ export declare function selfieGuidanceVariant({ satisfied, negative, }: {
10
11
  satisfied: boolean;
11
12
  negative: boolean;
12
13
  }): 'default' | 'positive' | 'negative';
14
+ export declare function challengePromptCode(snapshot: ChallengeRunnerSnapshot): {
15
+ code: FaceMessageCode;
16
+ blinkCount?: number;
17
+ } | null;
18
+ /** `challengePromptCode` resolved to its translation key. */
13
19
  export declare function challengePromptKey(snapshot: ChallengeRunnerSnapshot): {
14
20
  key: string;
15
21
  blinkCount?: number;
16
22
  } | null;
23
+ export declare function livenessStatusCode(state: LivenessMachineState): FaceMessageCode | null;
24
+ /** `livenessStatusCode` resolved to its translation key. */
17
25
  export declare function livenessStatusKey(state: LivenessMachineState): string | null;
18
26
  //# sourceMappingURL=selfieStrings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"selfieStrings.d.ts","sourceRoot":"","sources":["../../src/guidance/selfieStrings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,sCAAsC,CAAA;AAqB7C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAGzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAItC;AAkBD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,uBAAuB,GAChC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAc7C;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAoB5E"}
1
+ {"version":3,"file":"selfieStrings.d.ts","sourceRoot":"","sources":["../../src/guidance/selfieStrings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EACnB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,sCAAsC,CAAA;AAqB7C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAGzE;AA6BD,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAItC;AAkBD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,uBAAuB,GAChC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAevD;AAED,6DAA6D;AAC7D,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,uBAAuB,GAChC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAM7C;AAWD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,oBAAoB,GAC1B,eAAe,GAAG,IAAI,CAgBxB;AAED,4DAA4D;AAC5D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAG5E"}
@@ -1,4 +1,4 @@
1
- import { SelfieGuidanceCode } from '@idmission/websdk-core/selfieCapture';
1
+ import { FaceMessageCode, SelfieGuidanceCode, } from '@idmission/websdk-core/selfieCapture';
2
2
  // Byte-identical to sdk2's verbiage defaults
3
3
  // (SelfieCapture.tsx:273-284, FaceLivenessCapture.tsx:845-912). These
4
4
  // strings are i18n translation keys — any drift silently un-translates 8
@@ -19,6 +19,33 @@ export function selfieGuidanceMessageKey(code) {
19
19
  return '';
20
20
  return selfieGuidanceKeys[code];
21
21
  }
22
+ // The other half of the face pill's vocabulary: challenge prompts, the
23
+ // liveness status ladder, and the manual-capture prompt. Byte-identical to
24
+ // sdk2's verbiage defaults (FaceLivenessCapture.tsx:845-912), and — like every
25
+ // string in this file — these ARE the i18n translation keys, so any drift here
26
+ // silently un-translates 8 locales.
27
+ //
28
+ // Exhaustive by type: adding a `FaceMessageCode` without a string here is a
29
+ // compile error, which is the point. Strings may change freely; the codes they
30
+ // hang off may not (see FaceMessageCode's append-only note).
31
+ const faceMessageKeys = {
32
+ TURN_LEFT: 'Turn your head left',
33
+ TURN_RIGHT: 'Turn your head right',
34
+ RETURN_TO_CENTER: 'Return to center',
35
+ BLINK: 'Blink',
36
+ BLINK_TWICE: 'Blink twice',
37
+ REMOVE_EYE_COVERINGS: 'Please remove your eye coverings (sunglasses, eye patch, etc.)...',
38
+ REMOVE_HEAD_COVERINGS: 'Please remove your head coverings (hat, scarf, etc.)...',
39
+ REMOVE_MASK: 'Please remove your mask...',
40
+ CHALLENGE_TIMED_OUT: "Let's try that again — please follow the prompts.",
41
+ LIVENESS_CHECK_FAILED: 'Could not verify your face.',
42
+ LIVENESS_CHECK_ERROR: 'An error occurred while verifying your face.',
43
+ VALIDATING: 'Photo captured, verifying...',
44
+ MANUAL_CAPTURE: 'Position your face in the circle and click to capture.',
45
+ };
46
+ export function faceMessageKey(code) {
47
+ return faceMessageKeys[code];
48
+ }
22
49
  /**
23
50
  * sdk2's guidance-pill variant selection: `negative` (FAILED/ERROR/covering
24
51
  * states, supplied by the liveness view) always wins; otherwise `satisfied`
@@ -46,24 +73,33 @@ export function selfieGuidanceVariant({ satisfied, negative, }) {
46
73
  // The view is expected to render `` `${t(key)} ${blinkCount} times` `` to
47
74
  // match that exactly — sdk2 parity, not an oversight.
48
75
  const TURN_KINDS = new Set(['turn-left', 'turn-right']);
49
- export function challengePromptKey(snapshot) {
76
+ export function challengePromptCode(snapshot) {
50
77
  const { promptKind, promptCount, awaitingReturn } = snapshot;
51
78
  if (promptKind !== null && TURN_KINDS.has(promptKind) && awaitingReturn) {
52
- return { key: 'Return to center' };
79
+ return { code: FaceMessageCode.RETURN_TO_CENTER };
53
80
  }
54
81
  if (promptKind === 'turn-left')
55
- return { key: 'Turn your head left' };
82
+ return { code: FaceMessageCode.TURN_LEFT };
56
83
  if (promptKind === 'turn-right')
57
- return { key: 'Turn your head right' };
84
+ return { code: FaceMessageCode.TURN_RIGHT };
58
85
  if (promptKind === 'blink') {
59
86
  if (promptCount === 2)
60
- return { key: 'Blink twice' };
87
+ return { code: FaceMessageCode.BLINK_TWICE };
61
88
  if (promptCount > 2)
62
- return { key: 'Blink', blinkCount: promptCount };
63
- return { key: 'Blink' };
89
+ return { code: FaceMessageCode.BLINK, blinkCount: promptCount };
90
+ return { code: FaceMessageCode.BLINK };
64
91
  }
65
92
  return null;
66
93
  }
94
+ /** `challengePromptCode` resolved to its translation key. */
95
+ export function challengePromptKey(snapshot) {
96
+ const prompt = challengePromptCode(snapshot);
97
+ if (!prompt)
98
+ return null;
99
+ return prompt.blinkCount === undefined
100
+ ? { key: faceMessageKey(prompt.code) }
101
+ : { key: faceMessageKey(prompt.code), blinkCount: prompt.blinkCount };
102
+ }
67
103
  // Liveness-status ladder (FaceLivenessCapture.tsx:896-912's `guidanceMessage`
68
104
  // derivation, minus its leading `challengeMessage ? ... :` branch).
69
105
  // LivenessMachineState carries no promptKind/challenge fields — that's
@@ -73,25 +109,28 @@ export function challengePromptKey(snapshot) {
73
109
  // eye covering > head covering > mask > FAILED (challengeTimedOut ? "let's
74
110
  // try again" : "could not verify") > ERROR > CAPTURED|IN_PROGRESS
75
111
  // ("verifying...") > null (nothing to show).
76
- export function livenessStatusKey(state) {
77
- if (state.eyeCoveringDetected) {
78
- return 'Please remove your eye coverings (sunglasses, eye patch, etc.)...';
79
- }
80
- if (state.headCoveringDetected) {
81
- return 'Please remove your head coverings (hat, scarf, etc.)...';
82
- }
112
+ export function livenessStatusCode(state) {
113
+ if (state.eyeCoveringDetected)
114
+ return FaceMessageCode.REMOVE_EYE_COVERINGS;
115
+ if (state.headCoveringDetected)
116
+ return FaceMessageCode.REMOVE_HEAD_COVERINGS;
83
117
  if (state.maskDetected)
84
- return 'Please remove your mask...';
118
+ return FaceMessageCode.REMOVE_MASK;
85
119
  if (state.requestState === 'FAILED') {
86
120
  return state.challengeTimedOut
87
- ? "Let's try that again — please follow the prompts."
88
- : 'Could not verify your face.';
121
+ ? FaceMessageCode.CHALLENGE_TIMED_OUT
122
+ : FaceMessageCode.LIVENESS_CHECK_FAILED;
89
123
  }
90
124
  if (state.requestState === 'ERROR') {
91
- return 'An error occurred while verifying your face.';
125
+ return FaceMessageCode.LIVENESS_CHECK_ERROR;
92
126
  }
93
127
  if (state.requestState === 'CAPTURED' || state.requestState === 'IN_PROGRESS') {
94
- return 'Photo captured, verifying...';
128
+ return FaceMessageCode.VALIDATING;
95
129
  }
96
130
  return null;
97
131
  }
132
+ /** `livenessStatusCode` resolved to its translation key. */
133
+ export function livenessStatusKey(state) {
134
+ const code = livenessStatusCode(state);
135
+ return code === null ? null : faceMessageKey(code);
136
+ }