@idmission/websdk-ui 0.2.0 → 0.6.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 (200) hide show
  1. package/README.md +75 -4
  2. package/dist/DocumentCaptureView.d.ts +7 -5
  3. package/dist/DocumentCaptureView.d.ts.map +1 -1
  4. package/dist/DocumentCaptureView.js +30 -26
  5. package/dist/FaceLivenessView.d.ts +2 -2
  6. package/dist/FaceLivenessView.d.ts.map +1 -1
  7. package/dist/FaceLivenessView.js +47 -13
  8. package/dist/IdCaptureView.d.ts +27 -15
  9. package/dist/IdCaptureView.d.ts.map +1 -1
  10. package/dist/IdCaptureView.js +149 -26
  11. package/dist/SelfieCaptureView.d.ts +18 -1
  12. package/dist/SelfieCaptureView.d.ts.map +1 -1
  13. package/dist/SelfieCaptureView.js +13 -4
  14. package/dist/SignatureCaptureView.d.ts +18 -5
  15. package/dist/SignatureCaptureView.d.ts.map +1 -1
  16. package/dist/SignatureCaptureView.js +90 -15
  17. package/dist/VideoIdCaptureView.d.ts +14 -2
  18. package/dist/VideoIdCaptureView.d.ts.map +1 -1
  19. package/dist/VideoIdCaptureView.js +13 -6
  20. package/dist/bindings/useDocumentCapture.d.ts.map +1 -1
  21. package/dist/bindings/useDocumentCapture.js +2 -1
  22. package/dist/bindings/useIdCapture.d.ts.map +1 -1
  23. package/dist/bindings/useIdCapture.js +2 -1
  24. package/dist/bindings/useSelfieCapture.d.ts.map +1 -1
  25. package/dist/bindings/useSelfieCapture.js +2 -1
  26. package/dist/bindings/useSignatureCapture.d.ts.map +1 -1
  27. package/dist/bindings/useSignatureCapture.js +2 -1
  28. package/dist/bindings/useVideoIdCapture.d.ts.map +1 -1
  29. package/dist/bindings/useVideoIdCapture.js +2 -1
  30. package/dist/components/common/BrowserEdgeTint.d.ts +63 -0
  31. package/dist/components/common/BrowserEdgeTint.d.ts.map +1 -0
  32. package/dist/components/common/BrowserEdgeTint.js +111 -0
  33. package/dist/components/common/LoaderButton.d.ts +9 -0
  34. package/dist/components/common/LoaderButton.d.ts.map +1 -1
  35. package/dist/components/common/LoaderButton.js +44 -321
  36. package/dist/components/common/ScreenReaderStatus.d.ts +8 -0
  37. package/dist/components/common/ScreenReaderStatus.d.ts.map +1 -0
  38. package/dist/components/common/ScreenReaderStatus.js +18 -0
  39. package/dist/components/common/overlay.d.ts +6 -0
  40. package/dist/components/common/overlay.d.ts.map +1 -1
  41. package/dist/components/common/overlay.js +7 -1
  42. package/dist/components/debug/debug.d.ts +6 -0
  43. package/dist/components/debug/debug.d.ts.map +1 -1
  44. package/dist/components/debug/debug.js +5 -1
  45. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.d.ts.map +1 -1
  46. package/dist/components/document/DocumentCaptureAutoCaptureDebugLayer.js +4 -5
  47. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.d.ts.map +1 -1
  48. package/dist/components/document/DocumentCaptureAutoCaptureGuidance.js +40 -13
  49. package/dist/components/error/CameraAccessDeniedOverlay.d.ts +8 -1
  50. package/dist/components/error/CameraAccessDeniedOverlay.d.ts.map +1 -1
  51. package/dist/components/error/useCameraAccessDeniedReport.d.ts +12 -0
  52. package/dist/components/error/useCameraAccessDeniedReport.d.ts.map +1 -0
  53. package/dist/components/error/useCameraAccessDeniedReport.js +31 -0
  54. package/dist/components/face_liveness/FaceLivenessFailure.d.ts +4 -1
  55. package/dist/components/face_liveness/FaceLivenessFailure.d.ts.map +1 -1
  56. package/dist/components/face_liveness/FaceLivenessFailure.js +4 -2
  57. package/dist/components/face_liveness/FaceLivenessSuccess.d.ts +4 -1
  58. package/dist/components/face_liveness/FaceLivenessSuccess.d.ts.map +1 -1
  59. package/dist/components/face_liveness/FaceLivenessSuccess.js +6 -2
  60. package/dist/components/guides/IdCaptureFitGuide.d.ts +2 -0
  61. package/dist/components/guides/IdCaptureFitGuide.d.ts.map +1 -1
  62. package/dist/components/guides/IdCaptureFitGuide.js +4 -1
  63. package/dist/components/guides/IdCaptureGuideOverlay.d.ts +2 -0
  64. package/dist/components/guides/IdCaptureGuideOverlay.d.ts.map +1 -1
  65. package/dist/components/guides/IdCaptureGuideOverlay.js +3 -1
  66. package/dist/components/guides/IdCaptureGuides.d.ts +14 -0
  67. package/dist/components/guides/IdCaptureGuides.d.ts.map +1 -1
  68. package/dist/components/guides/IdCaptureGuides.js +22 -7
  69. package/dist/components/guides/IdCaptureGuidesCommon.d.ts.map +1 -1
  70. package/dist/components/guides/IdCaptureGuidesCommon.js +12 -7
  71. package/dist/components/loading/IdCaptureLoadingOverlayDefault.d.ts +9 -0
  72. package/dist/components/loading/IdCaptureLoadingOverlayDefault.d.ts.map +1 -1
  73. package/dist/components/loading/IdCaptureLoadingOverlayDefault.js +26 -4
  74. package/dist/components/loading/RingIntroScreen.d.ts.map +1 -1
  75. package/dist/components/loading/RingIntroScreen.js +4 -34
  76. package/dist/components/review/ReviewScreen.d.ts +10 -1
  77. package/dist/components/review/ReviewScreen.d.ts.map +1 -1
  78. package/dist/components/review/ReviewScreen.js +8 -8
  79. package/dist/components/review/SignatureCaptureDiagnostics.d.ts +5 -1
  80. package/dist/components/review/SignatureCaptureDiagnostics.d.ts.map +1 -1
  81. package/dist/components/review/SignatureCaptureDiagnostics.js +4 -2
  82. package/dist/components/selfie/FaceCaptureGuideOverlay.d.ts +9 -2
  83. package/dist/components/selfie/FaceCaptureGuideOverlay.d.ts.map +1 -1
  84. package/dist/components/selfie/FaceCaptureGuideOverlay.js +10 -4
  85. package/dist/components/selfie/SelfieCaptureAnimatedMask.d.ts +8 -1
  86. package/dist/components/selfie/SelfieCaptureAnimatedMask.d.ts.map +1 -1
  87. package/dist/components/selfie/SelfieCaptureAnimatedMask.js +55 -21
  88. package/dist/components/selfie/SelfieCaptureSurface.d.ts +9 -2
  89. package/dist/components/selfie/SelfieCaptureSurface.d.ts.map +1 -1
  90. package/dist/components/selfie/SelfieCaptureSurface.js +77 -16
  91. package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.d.ts +9 -0
  92. package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.d.ts.map +1 -1
  93. package/dist/components/selfie_loading/SelfieCaptureLoadingOverlayDefault.js +26 -4
  94. package/dist/flows/AuthStateContext.d.ts.map +1 -1
  95. package/dist/flows/AuthStateContext.js +2 -1
  96. package/dist/flows/CaptureProgress.d.ts +14 -0
  97. package/dist/flows/CaptureProgress.d.ts.map +1 -0
  98. package/dist/flows/CaptureProgress.js +51 -0
  99. package/dist/flows/CompositeWizard.d.ts +7 -1
  100. package/dist/flows/CompositeWizard.d.ts.map +1 -1
  101. package/dist/flows/CompositeWizard.js +6 -2
  102. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts +3 -3
  103. package/dist/flows/CustomerBiometricsEnrollmentFlow.d.ts.map +1 -1
  104. package/dist/flows/CustomerBiometricsEnrollmentFlow.js +26 -4
  105. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts +3 -3
  106. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.d.ts.map +1 -1
  107. package/dist/flows/CustomerIdAndBiometricsEnrollmentFlow.js +45 -9
  108. package/dist/flows/DocumentCaptureFlow.d.ts +4 -3
  109. package/dist/flows/DocumentCaptureFlow.d.ts.map +1 -1
  110. package/dist/flows/DocumentCaptureFlow.js +14 -8
  111. package/dist/flows/FaceValidationFlow.d.ts +2 -2
  112. package/dist/flows/FaceValidationFlow.d.ts.map +1 -1
  113. package/dist/flows/FaceValidationFlow.js +7 -2
  114. package/dist/flows/FlowChassis.d.ts +19 -1
  115. package/dist/flows/FlowChassis.d.ts.map +1 -1
  116. package/dist/flows/FlowChassis.js +40 -4
  117. package/dist/flows/IdAndFaceValidationFlow.d.ts +3 -3
  118. package/dist/flows/IdAndFaceValidationFlow.d.ts.map +1 -1
  119. package/dist/flows/IdAndFaceValidationFlow.js +33 -3
  120. package/dist/flows/IdValidationFlow.d.ts +10 -5
  121. package/dist/flows/IdValidationFlow.d.ts.map +1 -1
  122. package/dist/flows/IdValidationFlow.js +32 -5
  123. package/dist/flows/SignatureKYCFlow.d.ts +43 -7
  124. package/dist/flows/SignatureKYCFlow.d.ts.map +1 -1
  125. package/dist/flows/SignatureKYCFlow.js +154 -16
  126. package/dist/flows/SubmissionProvider.d.ts +12 -3
  127. package/dist/flows/SubmissionProvider.d.ts.map +1 -1
  128. package/dist/flows/SubmissionProvider.js +142 -16
  129. package/dist/flows/VideoIdValidationFlow.d.ts +3 -5
  130. package/dist/flows/VideoIdValidationFlow.d.ts.map +1 -1
  131. package/dist/flows/VideoIdValidationFlow.js +38 -4
  132. package/dist/flows/additionalDocuments.d.ts.map +1 -1
  133. package/dist/flows/additionalDocuments.js +3 -6
  134. package/dist/flows/approval.d.ts +1 -14
  135. package/dist/flows/approval.d.ts.map +1 -1
  136. package/dist/flows/approval.js +1 -19
  137. package/dist/flows/artifacts.d.ts +1 -1
  138. package/dist/flows/artifacts.d.ts.map +1 -1
  139. package/dist/flows/artifacts.js +29 -9
  140. package/dist/flows/customerMatch/CustomerMatchCapture.d.ts +3 -2
  141. package/dist/flows/customerMatch/CustomerMatchCapture.d.ts.map +1 -1
  142. package/dist/flows/customerMatch/CustomerMatchCapture.js +3 -2
  143. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts +13 -4
  144. package/dist/flows/customerMatch/CustomerMatchFlow.d.ts.map +1 -1
  145. package/dist/flows/customerMatch/CustomerMatchFlow.js +17 -12
  146. package/dist/flows/flowSettings.d.ts +11 -0
  147. package/dist/flows/flowSettings.d.ts.map +1 -0
  148. package/dist/flows/flowSettings.js +20 -0
  149. package/dist/flows/ringScreens.d.ts +1 -0
  150. package/dist/flows/ringScreens.d.ts.map +1 -1
  151. package/dist/flows/ringScreens.js +17 -2
  152. package/dist/flows/signatureStep.d.ts +6 -1
  153. package/dist/flows/signatureStep.d.ts.map +1 -1
  154. package/dist/flows/types.d.ts +120 -10
  155. package/dist/flows/types.d.ts.map +1 -1
  156. package/dist/flows/videoIdSteps.d.ts +2 -2
  157. package/dist/flows/videoIdSteps.d.ts.map +1 -1
  158. package/dist/guidance/selfieStrings.d.ts.map +1 -1
  159. package/dist/guidance/selfieStrings.js +8 -4
  160. package/dist/guidance/strings.d.ts +34 -1
  161. package/dist/guidance/strings.d.ts.map +1 -1
  162. package/dist/guidance/strings.js +39 -0
  163. package/dist/i18n/index.d.ts +5 -1
  164. package/dist/i18n/index.d.ts.map +1 -1
  165. package/dist/i18n/index.js +13 -2
  166. package/dist/i18n/locales/threeOh.d.ts.map +1 -1
  167. package/dist/i18n/locales/threeOh.js +56 -2
  168. package/dist/index.d.ts +9 -6
  169. package/dist/index.d.ts.map +1 -1
  170. package/dist/index.js +3 -0
  171. package/dist/testing/autoCaptureFrames.d.ts.map +1 -1
  172. package/dist/testing/autoCaptureFrames.js +10 -4
  173. package/dist/testing/buildSelfieState.d.ts.map +1 -1
  174. package/dist/testing/buildSelfieState.js +5 -0
  175. package/dist/testing/classNamesLeaves.js +1 -1
  176. package/dist/testing/fakeClient.d.ts +41 -2
  177. package/dist/testing/fakeClient.d.ts.map +1 -1
  178. package/dist/testing/fakeClient.js +71 -16
  179. package/dist/testing/fakeSelfieController.d.ts.map +1 -1
  180. package/dist/testing/fakeSelfieController.js +7 -0
  181. package/dist/testing/index.d.ts +1 -1
  182. package/dist/testing/index.d.ts.map +1 -1
  183. package/dist/testing/index.js +1 -1
  184. package/dist/theme/index.d.ts +10 -0
  185. package/dist/theme/index.d.ts.map +1 -1
  186. package/dist/useDocumentUpload.d.ts +63 -0
  187. package/dist/useDocumentUpload.d.ts.map +1 -0
  188. package/dist/useDocumentUpload.js +45 -0
  189. package/dist/useIdmissionClient.d.ts +24 -3
  190. package/dist/useIdmissionClient.d.ts.map +1 -1
  191. package/dist/useIdmissionClient.js +46 -0
  192. package/dist/utils/mountOnly.d.ts +25 -0
  193. package/dist/utils/mountOnly.d.ts.map +1 -0
  194. package/dist/utils/mountOnly.js +111 -0
  195. package/dist/version.d.ts +1 -1
  196. package/dist/version.js +1 -1
  197. package/package.json +10 -9
  198. package/dist/flows/autoCaptureMountGuard.d.ts +0 -22
  199. package/dist/flows/autoCaptureMountGuard.d.ts.map +0 -1
  200. package/dist/flows/autoCaptureMountGuard.js +0 -61
@@ -1,13 +1,59 @@
1
1
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
2
  import { createIdmissionClient, } from '@idmission/websdk-core/client';
3
3
  import { withLatestCallbacks } from './flows/latestCallbacks';
4
+ import { useMountOnlyWarnings } from './utils/mountOnly';
4
5
  const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
6
+ // Typed as a record so adding a callback to `ClientCallbackOptions` without
7
+ // listing it here fails to compile.
8
+ const CALLBACK_NAMES = Object.keys({
9
+ onBeforeSubmit: true,
10
+ onSubmit: true,
11
+ onBeforeLivenessCheck: true,
12
+ onResponseReceived: true,
13
+ onRequestFailure: true,
14
+ onBeforeDocumentUpload: true,
15
+ onDocumentUploadProgress: true,
16
+ onDocumentUploaded: true,
17
+ onDocumentUploadFailed: true,
18
+ onAuthError: true,
19
+ });
5
20
  /**
6
21
  * Owns one stateful IDmission client for the lifetime of this React mount.
7
22
  * Inline options are safe; consumers do not need `useMemo`, `useCallback`, or
8
23
  * callback refs to preserve the client or keep its live values current.
24
+ *
25
+ * In development builds, changing a mount-only option after mount logs a
26
+ * `console.warn` naming the option, because the change is otherwise ignored
27
+ * silently.
28
+ *
29
+ * The client also owns `submissionStatus`, and flows render from it. A retry
30
+ * that remounts the flow but keeps the same client starts from the previous
31
+ * attempt's status, so use one client per attempt: call this hook in a
32
+ * component that renders the flow, and key that component by attempt.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * function IdValidationAttempt({ sessionId }: { sessionId: string }) {
37
+ * const client = useIdmissionClient({ sessionId })
38
+ * return <IdValidationFlow client={client} />
39
+ * }
40
+ *
41
+ * // Bumping `attempt` gives the retry a fresh client and a fresh flow.
42
+ * <IdValidationAttempt key={attempt} sessionId={sessionId} />
43
+ * ```
9
44
  */
10
45
  export function useIdmissionClient(options) {
46
+ useMountOnlyWarnings('useIdmissionClient', 'remount the component that calls useIdmissionClient with a React `key`, ' +
47
+ 'or create your own client with `createIdmissionClient`', {
48
+ authUrl: options.authUrl,
49
+ submissionUrl: options.submissionUrl,
50
+ documentServiceUrl: options.documentServiceUrl,
51
+ timeoutMs: options.timeoutMs,
52
+ // Presence, not implementation: implementations are live, but whether
53
+ // each callback exists is fixed at mount (`onSubmit`'s presence selects
54
+ // customer handoff versus SDK posting).
55
+ ...Object.fromEntries(CALLBACK_NAMES.map((name) => [name, options[name] ? 'passed' : 'omitted'])),
56
+ });
11
57
  const committedSession = useRef(options.sessionId);
12
58
  const committedCallbacks = useRef(options);
13
59
  useIsomorphicLayoutEffect(() => {
@@ -0,0 +1,25 @@
1
+ export type MountOnlyChange = {
2
+ path: string;
3
+ before: unknown;
4
+ after: unknown;
5
+ };
6
+ /**
7
+ * Every leaf whose value differs between `before` and `after`.
8
+ *
9
+ * A live callback's new implementation, or its removal, is not reported. A
10
+ * callback ADDED after mount is, because only callbacks present at mount are
11
+ * wrapped. An absent field and an explicit `undefined` are the same value.
12
+ */
13
+ export declare function mountOnlyChanges(before: unknown, after: unknown, path: string): MountOnlyChange[];
14
+ /**
15
+ * In development builds, warns once per input path when a value in `inputs`
16
+ * differs from its value at mount. Does nothing in production.
17
+ *
18
+ * `owner` names the component or hook in the message, and `remedy` finishes
19
+ * the sentence "To change it, …". Pass only inputs that really are mount-only:
20
+ * a live input passed here would warn about a change that did take effect.
21
+ */
22
+ export declare function useMountOnlyWarnings(owner: string, remedy: string, inputs: Readonly<Record<string, unknown>>): void;
23
+ /** The `remedy` every flow gives for a changed capture-bag field. */
24
+ export declare const FLOW_MOUNT_ONLY_REMEDY = "remount the flow with a React `key`, or pass your own controller";
25
+ //# sourceMappingURL=mountOnly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mountOnly.d.ts","sourceRoot":"","sources":["../../src/utils/mountOnly.ts"],"names":[],"mappings":"AAyCA,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAU/E;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CAwBnB;AAiBD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,IAAI,CAyBN;AAED,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,qEACiC,CAAA"}
@@ -0,0 +1,111 @@
1
+ // Makes mount-only inputs fail loudly in development.
2
+ //
3
+ // The client and every flow controller are built once, in a lazy `useState`,
4
+ // from the values present at mount, and have no reconfigure path. A later
5
+ // change to one of those values is ignored without an error or a log. That is
6
+ // how a capture screen that mounts before its feature flags land ends up with
7
+ // auto-capture off for the applicant's whole session (#351). These warnings
8
+ // name the ignored input so the race shows up while the integration is being
9
+ // written, not in the field.
10
+ import { useEffect, useRef } from 'react';
11
+ import { warn } from './logger';
12
+ /**
13
+ * True unless the host bundle was built for production.
14
+ *
15
+ * Follows the `process.env.NODE_ENV` convention that React and mainstream
16
+ * bundlers use, and that `websdk-compat`'s rollup build defines. Read inside a
17
+ * `try` because unbundled ESM has no `process`; that case counts as
18
+ * production, so a missing define never adds console output.
19
+ */
20
+ function isDevelopment() {
21
+ try {
22
+ return process.env.NODE_ENV !== 'production';
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * Plain objects and arrays are compared field by field, so an inline literal
30
+ * rebuilt every render with the same values is not a change. Anything else
31
+ * (class instances, DOM nodes, blobs) is compared by identity.
32
+ */
33
+ function isPlainContainer(value) {
34
+ if (Array.isArray(value))
35
+ return true;
36
+ if (typeof value !== 'object' || value === null)
37
+ return false;
38
+ const prototype = Object.getPrototypeOf(value);
39
+ return prototype === Object.prototype || prototype === null;
40
+ }
41
+ /**
42
+ * Callbacks the flows wrap with `useLatestCallbacks`: a bag's own top-level
43
+ * functions and those of its `liveness` sub-bag. Replacing or removing one of
44
+ * these is live. Any other function (such as `io.acquireCamera`) is a
45
+ * controller dependency fixed at mount, so it compares by identity.
46
+ */
47
+ const LIVE_CALLBACK_PATH = /^[^.[\]]+(\.liveness)?\.[^.[\]]+$/;
48
+ /**
49
+ * Every leaf whose value differs between `before` and `after`.
50
+ *
51
+ * A live callback's new implementation, or its removal, is not reported. A
52
+ * callback ADDED after mount is, because only callbacks present at mount are
53
+ * wrapped. An absent field and an explicit `undefined` are the same value.
54
+ */
55
+ export function mountOnlyChanges(before, after, path) {
56
+ if (Object.is(before, after))
57
+ return [];
58
+ if (typeof before === 'function' &&
59
+ (typeof after === 'function' || after === undefined) &&
60
+ LIVE_CALLBACK_PATH.test(path)) {
61
+ return [];
62
+ }
63
+ if (!isPlainContainer(before) ||
64
+ !isPlainContainer(after) ||
65
+ Array.isArray(before) !== Array.isArray(after)) {
66
+ return [{ path, before, after }];
67
+ }
68
+ const keys = new Set([...Object.keys(before), ...Object.keys(after)]);
69
+ return [...keys].flatMap((key) => mountOnlyChanges(before[key], after[key], Array.isArray(before) ? `${path}[${key}]` : `${path}.${key}`));
70
+ }
71
+ /**
72
+ * Whether a value is small and safe enough to print. Long strings are left
73
+ * out: capture bags can carry image data (`precapturedDocuments`), which is
74
+ * both personal data and too large to be useful in a warning.
75
+ */
76
+ const isPrintable = (value) => value === null ||
77
+ value === undefined ||
78
+ typeof value === 'boolean' ||
79
+ typeof value === 'number' ||
80
+ (typeof value === 'string' && value.length <= 64);
81
+ const describe = (value) => typeof value === 'string' ? JSON.stringify(value) : String(value);
82
+ /**
83
+ * In development builds, warns once per input path when a value in `inputs`
84
+ * differs from its value at mount. Does nothing in production.
85
+ *
86
+ * `owner` names the component or hook in the message, and `remedy` finishes
87
+ * the sentence "To change it, …". Pass only inputs that really are mount-only:
88
+ * a live input passed here would warn about a change that did take effect.
89
+ */
90
+ export function useMountOnlyWarnings(owner, remedy, inputs) {
91
+ const mounted = useRef(inputs);
92
+ const warned = useRef(new Set());
93
+ useEffect(() => {
94
+ if (!isDevelopment())
95
+ return;
96
+ for (const [name, value] of Object.entries(inputs)) {
97
+ for (const { path, before, after } of mountOnlyChanges(mounted.current[name], value, name)) {
98
+ if (warned.current.has(path))
99
+ continue;
100
+ warned.current.add(path);
101
+ const values = isPrintable(before) && isPrintable(after)
102
+ ? ` (${describe(before)} → ${describe(after)})`
103
+ : '';
104
+ warn(`[${owner}] \`${path}\` changed after mount${values} and was ignored: ` +
105
+ `${owner} reads it once, at mount. To change it, ${remedy}.`);
106
+ }
107
+ }
108
+ });
109
+ }
110
+ /** The `remedy` every flow gives for a changed capture-bag field. */
111
+ export const FLOW_MOUNT_ONLY_REMEDY = 'remount the flow with a React `key`, or pass your own controller';
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const webSdkUiVersion = "0.2.0";
1
+ export declare const webSdkUiVersion = "0.6.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Extracted from the barrel so modules inside this package can read the
2
2
  // version without importing index.ts (which would be circular).
3
- export const webSdkUiVersion = '0.2.0';
3
+ export const webSdkUiVersion = '0.6.0';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@idmission/websdk-ui",
3
- "version": "0.2.0",
3
+ "version": "0.6.0",
4
4
  "description": "React presentation layer for the IDmission Web SDK",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/Idmission-LLC/idmission-web-sdk-2.0.git",
8
+ "url": "https://github.com/idmission/websdk.git",
9
9
  "directory": "packages/websdk-ui"
10
10
  },
11
11
  "publishConfig": {
@@ -34,19 +34,20 @@
34
34
  "styled-components": "^6"
35
35
  },
36
36
  "dependencies": {
37
- "i18next": "^23.16.8",
38
- "i18next-browser-languagedetector": "^7.2.2",
39
- "ladda": "^2.0.3",
40
- "react-i18next": "^13.5.0",
37
+ "i18next": "^26.7.1",
38
+ "i18next-browser-languagedetector": "^8.3.0",
39
+ "react-i18next": "^17.1.11",
41
40
  "signature_pad": "^5.1.4",
42
41
  "thinking-orbs": "0.1.1",
43
- "@idmission/websdk-core": "0.2.0"
42
+ "use-sync-external-store": "^1.6.0",
43
+ "@idmission/websdk-core": "0.6.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@testing-library/react": "^16.3.0",
47
47
  "@types/node": "^20.19.39",
48
48
  "@types/react": "^19.2.14",
49
49
  "@types/react-dom": "^18.3.1",
50
+ "@types/use-sync-external-store": "^1.7.0",
50
51
  "global-jsdom": "^26.0.0",
51
52
  "jsdom": "^26.1.0",
52
53
  "react": "18.3.1",
@@ -54,8 +55,8 @@
54
55
  "styled-components": "^6.4.1",
55
56
  "tsx": "^4.20.0",
56
57
  "typescript": "^5.9.3",
57
- "@idmission/eslint-config": "1.0.0",
58
- "@idmission/typescript-config": "1.0.0"
58
+ "@idmission/typescript-config": "1.0.0",
59
+ "@idmission/eslint-config": "1.0.0"
59
60
  },
60
61
  "scripts": {
61
62
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
@@ -1,22 +0,0 @@
1
- import type { DocumentCapturePrompt } from '../components/document/types';
2
- /**
3
- * A comparable summary of what auto-capture each document asked for.
4
- *
5
- * Resolved rather than compared raw, so a caller who re-spreads an equivalent
6
- * bag every render (`autoCapture: {}`, or `{ minScore: undefined }`) does not
7
- * trip the warning — only a change that would actually have configured the
8
- * engine differently does.
9
- *
10
- * PRESENCE is preserved as `null` rather than folded into the resolved
11
- * defaults, because `undefined` -> `{}` is precisely the late-flag race this
12
- * exists to catch, and resolving both would make them identical.
13
- */
14
- export declare function autoCaptureSignature(documents: readonly DocumentCapturePrompt[]): string;
15
- /**
16
- * Warn once if `documents`' auto-capture configuration changes after mount.
17
- *
18
- * Warns rather than reconfigures: the change genuinely has no effect, and a
19
- * caller who cannot see that is the failure mode.
20
- */
21
- export declare function useAutoCaptureMountGuard(documents: readonly DocumentCapturePrompt[]): void;
22
- //# sourceMappingURL=autoCaptureMountGuard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autoCaptureMountGuard.d.ts","sourceRoot":"","sources":["../../src/flows/autoCaptureMountGuard.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,qBAAqB,EAAE,GAC1C,MAAM,CAQR;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,qBAAqB,EAAE,GAC1C,IAAI,CAoBN"}
@@ -1,61 +0,0 @@
1
- // Makes the mount-time-only `autoCapture` contract audible (#351).
2
- //
3
- // `DocumentCaptureFlow` builds its controller inside `useState(() => …)` from
4
- // `documentsRef.current`, and `documentCapture/controller.ts` has no
5
- // reconfigure path — so `autoCapture` is read once, at mount, and every later
6
- // change is ignored. A reconfigure path was ruled against: it is real surface
7
- // on a controller that has none today, bought to serve a race the consumer can
8
- // simply not have (AMEX's `DocumentCaptureScreen` should gate on `flagsLoaded`,
9
- // not just `sessionLoaded`).
10
- //
11
- // The SILENCE is the expensive half. All four of this repo's cascade-default
12
- // incidents were "the value was quietly wrong and nothing said so", and this
13
- // one has the same shape: a capture screen that mounts before the flags land
14
- // has auto-capture off for that applicant's whole session, with no error and
15
- // no log. The field-visible half of the same ruling is
16
- // `autoCaptureStatus: 'disabled:lateFlag'` on the capture metadata.
17
- import { useEffect, useRef } from 'react';
18
- import { resolveAutoCapture } from '@idmission/websdk-core/documentCapture';
19
- import { warn } from '../utils/logger';
20
- /**
21
- * A comparable summary of what auto-capture each document asked for.
22
- *
23
- * Resolved rather than compared raw, so a caller who re-spreads an equivalent
24
- * bag every render (`autoCapture: {}`, or `{ minScore: undefined }`) does not
25
- * trip the warning — only a change that would actually have configured the
26
- * engine differently does.
27
- *
28
- * PRESENCE is preserved as `null` rather than folded into the resolved
29
- * defaults, because `undefined` -> `{}` is precisely the late-flag race this
30
- * exists to catch, and resolving both would make them identical.
31
- */
32
- export function autoCaptureSignature(documents) {
33
- return JSON.stringify(documents.map((document) => document.autoCapture
34
- ? resolveAutoCapture(document.autoCapture, undefined)
35
- : null));
36
- }
37
- /**
38
- * Warn once if `documents`' auto-capture configuration changes after mount.
39
- *
40
- * Warns rather than reconfigures: the change genuinely has no effect, and a
41
- * caller who cannot see that is the failure mode.
42
- */
43
- export function useAutoCaptureMountGuard(documents) {
44
- const mounted = useRef(null);
45
- const warned = useRef(false);
46
- const signature = autoCaptureSignature(documents);
47
- useEffect(() => {
48
- if (mounted.current === null) {
49
- mounted.current = signature;
50
- return;
51
- }
52
- if (warned.current || signature === mounted.current)
53
- return;
54
- warned.current = true;
55
- warn('[DocumentCaptureFlow] `autoCapture` changed after mount and has been ' +
56
- 'ignored: the controller is built once and has no reconfigure path. ' +
57
- 'Mount this flow only once the value is known — if it comes from a ' +
58
- 'feature flag, gate the screen on the flags having loaded, not just ' +
59
- 'the session.');
60
- }, [signature]);
61
- }