@idmission/websdk-core 0.2.0-rc.2 → 0.5.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 (209) hide show
  1. package/README.md +27 -1
  2. package/dist/attestation/clientAttestation.d.ts +5 -0
  3. package/dist/attestation/clientAttestation.d.ts.map +1 -1
  4. package/dist/attestation/clientAttestation.js +4 -4
  5. package/dist/attestation/collectClientAttestation.d.ts +3 -1
  6. package/dist/attestation/collectClientAttestation.d.ts.map +1 -1
  7. package/dist/attestation/collectClientAttestation.js +4 -3
  8. package/dist/camera/acquireCamera.d.ts +5 -0
  9. package/dist/camera/acquireCamera.d.ts.map +1 -1
  10. package/dist/camera/acquireCamera.js +25 -5
  11. package/dist/captureProgress/actor.d.ts +30 -0
  12. package/dist/captureProgress/actor.d.ts.map +1 -0
  13. package/dist/captureProgress/actor.js +754 -0
  14. package/dist/captureProgress/encoder.d.ts +7 -0
  15. package/dist/captureProgress/encoder.d.ts.map +1 -0
  16. package/dist/captureProgress/encoder.js +195 -0
  17. package/dist/captureProgress/index.d.ts +4 -0
  18. package/dist/captureProgress/index.d.ts.map +1 -0
  19. package/dist/captureProgress/index.js +45 -0
  20. package/dist/captureProgress/internal.d.ts +3 -0
  21. package/dist/captureProgress/internal.d.ts.map +1 -0
  22. package/dist/captureProgress/internal.js +1 -0
  23. package/dist/captureProgress/protocol.d.ts +224 -0
  24. package/dist/captureProgress/protocol.d.ts.map +1 -0
  25. package/dist/captureProgress/protocol.js +106 -0
  26. package/dist/captureProgress/recorder.d.ts +32 -0
  27. package/dist/captureProgress/recorder.d.ts.map +1 -0
  28. package/dist/captureProgress/recorder.js +554 -0
  29. package/dist/captureProgress/transport.d.ts +33 -0
  30. package/dist/captureProgress/transport.d.ts.map +1 -0
  31. package/dist/captureProgress/transport.js +109 -0
  32. package/dist/captureProgress/types.d.ts +35 -0
  33. package/dist/captureProgress/types.d.ts.map +1 -0
  34. package/dist/captureProgress/types.js +27 -0
  35. package/dist/client/IdmissionClient.d.ts +8 -1
  36. package/dist/client/IdmissionClient.d.ts.map +1 -1
  37. package/dist/client/IdmissionClient.js +96 -27
  38. package/dist/client/approval.d.ts +15 -0
  39. package/dist/client/approval.d.ts.map +1 -0
  40. package/dist/client/approval.js +19 -0
  41. package/dist/client/artifacts.d.ts +2 -0
  42. package/dist/client/artifacts.d.ts.map +1 -1
  43. package/dist/client/documentFileMetadata.d.ts +13 -0
  44. package/dist/client/documentFileMetadata.d.ts.map +1 -0
  45. package/dist/client/documentFileMetadata.js +51 -0
  46. package/dist/client/index.d.ts +3 -0
  47. package/dist/client/index.d.ts.map +1 -1
  48. package/dist/client/index.js +2 -0
  49. package/dist/client/payload.d.ts +3 -0
  50. package/dist/client/payload.d.ts.map +1 -1
  51. package/dist/client/payload.js +3 -1
  52. package/dist/client/submissionMetadata.d.ts +4 -1
  53. package/dist/client/submissionMetadata.d.ts.map +1 -1
  54. package/dist/client/submissionMetadata.js +13 -8
  55. package/dist/client/types.d.ts +8 -0
  56. package/dist/client/types.d.ts.map +1 -1
  57. package/dist/client/validateSession.d.ts +2 -0
  58. package/dist/client/validateSession.d.ts.map +1 -1
  59. package/dist/client/validateSession.js +53 -24
  60. package/dist/documentCapture/autoCaptureEngine.d.ts +106 -0
  61. package/dist/documentCapture/autoCaptureEngine.d.ts.map +1 -0
  62. package/dist/documentCapture/autoCaptureEngine.js +475 -0
  63. package/dist/documentCapture/autoCaptureGeometry.d.ts +514 -0
  64. package/dist/documentCapture/autoCaptureGeometry.d.ts.map +1 -0
  65. package/dist/documentCapture/autoCaptureGeometry.js +475 -0
  66. package/dist/documentCapture/autoCaptureGuidance.d.ts +61 -0
  67. package/dist/documentCapture/autoCaptureGuidance.d.ts.map +1 -0
  68. package/dist/documentCapture/autoCaptureGuidance.js +73 -0
  69. package/dist/documentCapture/autoCaptureMetadata.d.ts +193 -0
  70. package/dist/documentCapture/autoCaptureMetadata.d.ts.map +1 -0
  71. package/dist/documentCapture/autoCaptureMetadata.js +200 -0
  72. package/dist/documentCapture/autoCaptureOptions.d.ts +211 -0
  73. package/dist/documentCapture/autoCaptureOptions.d.ts.map +1 -0
  74. package/dist/documentCapture/autoCaptureOptions.js +177 -0
  75. package/dist/documentCapture/autoCaptureShutter.d.ts +162 -0
  76. package/dist/documentCapture/autoCaptureShutter.d.ts.map +1 -0
  77. package/dist/documentCapture/autoCaptureShutter.js +183 -0
  78. package/dist/documentCapture/controller.d.ts +38 -1
  79. package/dist/documentCapture/controller.d.ts.map +1 -1
  80. package/dist/documentCapture/controller.js +620 -40
  81. package/dist/documentCapture/index.d.ts +8 -2
  82. package/dist/documentCapture/index.d.ts.map +1 -1
  83. package/dist/documentCapture/index.js +6 -0
  84. package/dist/documentCapture/reducer.d.ts +26 -1
  85. package/dist/documentCapture/reducer.d.ts.map +1 -1
  86. package/dist/documentCapture/reducer.js +43 -0
  87. package/dist/documentCapture/state.d.ts +118 -0
  88. package/dist/documentCapture/state.d.ts.map +1 -1
  89. package/dist/documentCapture/state.js +24 -0
  90. package/dist/idCapture/controller.d.ts +24 -1
  91. package/dist/idCapture/controller.d.ts.map +1 -1
  92. package/dist/idCapture/controller.js +111 -13
  93. package/dist/idCapture/index.d.ts +1 -1
  94. package/dist/idCapture/index.d.ts.map +1 -1
  95. package/dist/idCapture/index.js +12 -1
  96. package/dist/idCapture/pipeline.d.ts +30 -0
  97. package/dist/idCapture/pipeline.d.ts.map +1 -1
  98. package/dist/idCapture/pipeline.js +33 -10
  99. package/dist/idCapture/state.d.ts +1 -3
  100. package/dist/idCapture/state.d.ts.map +1 -1
  101. package/dist/idCapture/submit.d.ts.map +1 -1
  102. package/dist/idCapture/submit.js +35 -1
  103. package/dist/idCapture/types.d.ts +2 -0
  104. package/dist/idCapture/types.d.ts.map +1 -1
  105. package/dist/index.d.ts +2 -0
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +1 -0
  108. package/dist/liveness/challengeGeometry.d.ts +48 -17
  109. package/dist/liveness/challengeGeometry.d.ts.map +1 -1
  110. package/dist/liveness/challengeGeometry.js +101 -54
  111. package/dist/models/DocumentDetection.d.ts +29 -1
  112. package/dist/models/DocumentDetection.d.ts.map +1 -1
  113. package/dist/models/DocumentDetection.js +75 -7
  114. package/dist/models/defaults/DocumentDetectorLiteRT.d.ts +2 -2
  115. package/dist/models/defaults/DocumentDetectorLiteRT.d.ts.map +1 -1
  116. package/dist/models/defaults/DocumentDetectorLiteRT.js +27 -2
  117. package/dist/models/defaults/HandLandmarkLiteRT.d.ts +3 -0
  118. package/dist/models/defaults/HandLandmarkLiteRT.d.ts.map +1 -0
  119. package/dist/models/defaults/HandLandmarkLiteRT.js +5 -0
  120. package/dist/models/defaults/IrisLandmarkLiteRT.d.ts +3 -0
  121. package/dist/models/defaults/IrisLandmarkLiteRT.d.ts.map +1 -0
  122. package/dist/models/defaults/IrisLandmarkLiteRT.js +5 -0
  123. package/dist/models/defaults/PalmDetectionLiteRT.d.ts +3 -0
  124. package/dist/models/defaults/PalmDetectionLiteRT.d.ts.map +1 -0
  125. package/dist/models/defaults/PalmDetectionLiteRT.js +5 -0
  126. package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts +3 -0
  127. package/dist/models/defaults/PoaDocumentDetectorLiteRT.d.ts.map +1 -0
  128. package/dist/models/defaults/PoaDocumentDetectorLiteRT.js +19 -0
  129. package/dist/models/defaults/index.d.ts +13 -1
  130. package/dist/models/defaults/index.d.ts.map +1 -1
  131. package/dist/models/defaults/index.js +16 -0
  132. package/dist/models/preloadModels.d.ts +24 -16
  133. package/dist/models/preloadModels.d.ts.map +1 -1
  134. package/dist/models/preloadModels.js +33 -3
  135. package/dist/models/providers/litert/FaceLandmarker.d.ts +8 -1
  136. package/dist/models/providers/litert/FaceLandmarker.d.ts.map +1 -1
  137. package/dist/models/providers/litert/FaceLandmarker.js +95 -3
  138. package/dist/models/providers/litert/HandOverFaceDetector.d.ts +27 -0
  139. package/dist/models/providers/litert/HandOverFaceDetector.d.ts.map +1 -0
  140. package/dist/models/providers/litert/HandOverFaceDetector.js +162 -0
  141. package/dist/models/providers/litert/blazeFacePrePost.js +4 -2
  142. package/dist/models/providers/litert/docDetectPrePost.d.ts.map +1 -1
  143. package/dist/models/providers/litert/docDetectPrePost.js +20 -3
  144. package/dist/models/providers/litert/handLandmarkPrePost.d.ts +20 -0
  145. package/dist/models/providers/litert/handLandmarkPrePost.d.ts.map +1 -0
  146. package/dist/models/providers/litert/handLandmarkPrePost.js +72 -0
  147. package/dist/models/providers/litert/handOverFace.d.ts +44 -0
  148. package/dist/models/providers/litert/handOverFace.d.ts.map +1 -0
  149. package/dist/models/providers/litert/handOverFace.js +139 -0
  150. package/dist/models/providers/litert/irisPrePost.d.ts +38 -0
  151. package/dist/models/providers/litert/irisPrePost.d.ts.map +1 -0
  152. package/dist/models/providers/litert/irisPrePost.js +101 -0
  153. package/dist/models/providers/litert/palmPrePost.d.ts +55 -0
  154. package/dist/models/providers/litert/palmPrePost.d.ts.map +1 -0
  155. package/dist/models/providers/litert/palmPrePost.js +151 -0
  156. package/dist/sdkVersions.d.ts +18 -0
  157. package/dist/sdkVersions.d.ts.map +1 -0
  158. package/dist/sdkVersions.js +8 -0
  159. package/dist/selfieCapture/captureQuality.d.ts +43 -0
  160. package/dist/selfieCapture/captureQuality.d.ts.map +1 -0
  161. package/dist/selfieCapture/captureQuality.js +87 -0
  162. package/dist/selfieCapture/challengeRunner.d.ts +9 -2
  163. package/dist/selfieCapture/challengeRunner.d.ts.map +1 -1
  164. package/dist/selfieCapture/challengeRunner.js +2 -5
  165. package/dist/selfieCapture/controller.d.ts +62 -1
  166. package/dist/selfieCapture/controller.d.ts.map +1 -1
  167. package/dist/selfieCapture/controller.js +470 -105
  168. package/dist/selfieCapture/faceTracking.d.ts +69 -1
  169. package/dist/selfieCapture/faceTracking.d.ts.map +1 -1
  170. package/dist/selfieCapture/faceTracking.js +134 -6
  171. package/dist/selfieCapture/guidance.d.ts +64 -0
  172. package/dist/selfieCapture/guidance.d.ts.map +1 -1
  173. package/dist/selfieCapture/guidance.js +74 -0
  174. package/dist/selfieCapture/index.d.ts +4 -3
  175. package/dist/selfieCapture/index.d.ts.map +1 -1
  176. package/dist/selfieCapture/index.js +2 -2
  177. package/dist/selfieCapture/livenessMachine.d.ts +2 -0
  178. package/dist/selfieCapture/livenessMachine.d.ts.map +1 -1
  179. package/dist/selfieCapture/livenessMachine.js +8 -0
  180. package/dist/selfieCapture/pipeline.d.ts +8 -0
  181. package/dist/selfieCapture/pipeline.d.ts.map +1 -1
  182. package/dist/selfieCapture/pipeline.js +2 -2
  183. package/dist/selfieCapture/reducer.d.ts +7 -0
  184. package/dist/selfieCapture/reducer.d.ts.map +1 -1
  185. package/dist/selfieCapture/reducer.js +45 -4
  186. package/dist/selfieCapture/state.d.ts +6 -0
  187. package/dist/selfieCapture/state.d.ts.map +1 -1
  188. package/dist/selfieCapture/state.js +1 -0
  189. package/dist/signature/frameDecode.d.ts.map +1 -1
  190. package/dist/signature/frameDecode.js +29 -0
  191. package/dist/signature/metadata.d.ts +10 -1
  192. package/dist/signature/metadata.d.ts.map +1 -1
  193. package/dist/signature/quality.d.ts +14 -6
  194. package/dist/signature/quality.d.ts.map +1 -1
  195. package/dist/signature/quality.js +13 -4
  196. package/dist/signatureCapture/controller.d.ts +2 -1
  197. package/dist/signatureCapture/controller.d.ts.map +1 -1
  198. package/dist/signatureCapture/controller.js +118 -23
  199. package/dist/signatureCapture/pipeline.d.ts +14 -2
  200. package/dist/signatureCapture/pipeline.d.ts.map +1 -1
  201. package/dist/signatureCapture/pipeline.js +36 -8
  202. package/dist/signatureCapture/state.d.ts +15 -0
  203. package/dist/signatureCapture/state.d.ts.map +1 -1
  204. package/dist/version.d.ts +1 -1
  205. package/dist/version.d.ts.map +1 -1
  206. package/dist/version.js +1 -1
  207. package/dist/videoIdCapture/controller.d.ts.map +1 -1
  208. package/dist/videoIdCapture/controller.js +64 -3
  209. package/package.json +10 -2
@@ -0,0 +1,7 @@
1
+ import { type SnapshotV1, type ProgressBatchV1, type FrozenBatch } from "./protocol";
2
+ export declare function validateSnapshot(report: SnapshotV1): void;
3
+ export declare function encodeProgressBatch(batch: ProgressBatchV1): {
4
+ batch: FrozenBatch | null;
5
+ dropped: readonly SnapshotV1[];
6
+ };
7
+ //# sourceMappingURL=encoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/captureProgress/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAcL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAIjB,MAAM,YAAY,CAAC;AAyDpB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CA2KzD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG;IAC3D,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CAChC,CAkCA"}
@@ -0,0 +1,195 @@
1
+ import { sdkPhases, sdkMilestones, failureCodes, reportReasons, attemptStatuses, workflowFailureCodes, visibilities, exposureKinds, transitionKinds, idGuidanceCodes, selfieGuidanceCodes, faceMessageCodes, signatureGuidanceCodes, } from "./protocol";
2
+ import { workflowPhases, workflowMilestones } from "./types";
3
+ const maximumBytes = 32 * 1024;
4
+ const maximumTime = 86_400_000;
5
+ const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6
+ const integer = (n, maximum = maximumTime) => Number.isSafeInteger(n) && n >= 0 && n <= maximum;
7
+ const member = (values, value) => values.includes(value);
8
+ const requireValid = (condition) => {
9
+ if (!condition)
10
+ throw new Error("Invalid capture progress facts");
11
+ };
12
+ const utf8 = (value) => new TextEncoder().encode(JSON.stringify(value));
13
+ function durationValid(duration) {
14
+ requireValid(integer(duration.wallMs) &&
15
+ integer(duration.visibleMs) &&
16
+ duration.visibleMs <= duration.wallMs &&
17
+ integer(duration.entries, 1_000_000));
18
+ }
19
+ function guidanceValid(phase, guidance, displayed) {
20
+ const vocabularies = {
21
+ id: idGuidanceCodes,
22
+ selfie: selfieGuidanceCodes,
23
+ face: faceMessageCodes,
24
+ signature: signatureGuidanceCodes,
25
+ };
26
+ const phases = {
27
+ id: ["id-front", "id-back", "passport"],
28
+ selfie: ["selfie"],
29
+ face: ["selfie"],
30
+ signature: ["signature", "review"],
31
+ };
32
+ requireValid(member(vocabularies[guidance.family], guidance.code) &&
33
+ phases[guidance.family].includes(phase) &&
34
+ (!displayed || guidance.code !== "NONE"));
35
+ }
36
+ function exposureValid(phase, exposure) {
37
+ requireValid(member(exposureKinds, exposure.kind));
38
+ if (exposure.kind === "displayed")
39
+ guidanceValid(phase, exposure.message, true);
40
+ }
41
+ function unique(keys) {
42
+ requireValid(new Set(keys).size === keys.length);
43
+ }
44
+ export function validateSnapshot(report) {
45
+ requireValid(report.context.length > 0 &&
46
+ new TextEncoder().encode(report.context).length <= 2048);
47
+ requireValid(uuidPattern.test(report.streamId) && uuidPattern.test(report.attemptId));
48
+ requireValid(integer(report.sequence, Number.MAX_SAFE_INTEGER) &&
49
+ report.sequence > 0 &&
50
+ integer(report.attemptOrdinal, 1_000_000) &&
51
+ report.attemptOrdinal > 0);
52
+ requireValid(member(reportReasons, report.reason) &&
53
+ member(attemptStatuses, report.attemptStatus));
54
+ requireValid(integer(report.attemptStartedAtUnixMs, Number.MAX_SAFE_INTEGER));
55
+ requireValid(integer(report.elapsedMs) &&
56
+ integer(report.visibleMs) &&
57
+ report.visibleMs <= report.elapsedMs);
58
+ requireValid(report.lastObservationAgeMs === null ||
59
+ integer(report.lastObservationAgeMs));
60
+ requireValid(member(visibilities, report.visibility));
61
+ for (const [key, value] of Object.entries(report.counters.failures))
62
+ requireValid(member(report.lane === "sdk" ? failureCodes : workflowFailureCodes, key) && integer(value, 1_000_000));
63
+ for (const value of [
64
+ report.counters.retries,
65
+ report.counters.transitionsDropped,
66
+ report.counters.reportsDropped,
67
+ ])
68
+ requireValid(integer(value, 1_000_000));
69
+ const phases = report.lane === "sdk" ? sdkPhases : workflowPhases;
70
+ let wall = 0;
71
+ unique(report.phaseTotals.map((total) => total.phase));
72
+ for (const total of report.phaseTotals) {
73
+ requireValid(member(phases, total.phase) &&
74
+ integer(total.completions, 1_000_000) &&
75
+ total.completions <= total.duration.entries);
76
+ durationValid(total.duration);
77
+ wall += total.duration.wallMs;
78
+ }
79
+ requireValid(wall <= report.elapsedMs);
80
+ if (report.current) {
81
+ const current = report.current;
82
+ const total = report.phaseTotals.find((total) => total.phase === current.phase);
83
+ requireValid(Boolean(total) &&
84
+ member(phases, current.phase) &&
85
+ integer(current.phaseEntryOrdinal, 1_000_000) &&
86
+ current.phaseEntryOrdinal > 0);
87
+ requireValid(integer(current.phaseEnteredAtMs) &&
88
+ current.phaseEnteredAtMs <= report.elapsedMs);
89
+ requireValid(integer(current.phaseRunWallMs) &&
90
+ integer(current.phaseRunVisibleMs) &&
91
+ current.phaseRunVisibleMs <= current.phaseRunWallMs);
92
+ requireValid(current.phaseRunWallMs <= (total?.duration.wallMs ?? -1) &&
93
+ current.phaseRunVisibleMs <= (total?.duration.visibleMs ?? -1));
94
+ requireValid(current.ended ===
95
+ (report.attemptStatus === "active" ? null : report.attemptStatus));
96
+ }
97
+ requireValid(report.recentTransitions.length <= 32);
98
+ let index = 0;
99
+ let atMs = 0;
100
+ for (const transition of report.recentTransitions) {
101
+ requireValid(member(transitionKinds, transition.kind));
102
+ requireValid(integer(transition.index, 1_000_000) &&
103
+ transition.index > index &&
104
+ integer(transition.atMs) &&
105
+ transition.atMs >= atMs &&
106
+ transition.atMs <= report.elapsedMs);
107
+ index = transition.index;
108
+ atMs = transition.atMs;
109
+ if (transition.kind === "phase")
110
+ requireValid(member(phases, transition.phase));
111
+ if (transition.kind === "visibility")
112
+ requireValid(transition.visibility === "visible" ||
113
+ transition.visibility === "hidden");
114
+ if (transition.kind === "guidance")
115
+ requireValid(report.lane === "sdk");
116
+ }
117
+ const milestones = report.lane === "sdk"
118
+ ? sdkMilestones
119
+ : [...workflowMilestones, "task-completed"];
120
+ for (const [key, value] of Object.entries(report.milestones))
121
+ requireValid(member(milestones, key) && integer(value, 1_000_000));
122
+ if (report.lane === "sdk") {
123
+ unique(report.guidanceTotals.map((total) => JSON.stringify([total.phase, total.exposure])));
124
+ unique(report.controllerGuidanceTotals.map((total) => JSON.stringify([total.phase, total.guidance])));
125
+ for (const total of report.guidanceTotals) {
126
+ durationValid(total.duration);
127
+ exposureValid(total.phase, total.exposure);
128
+ }
129
+ for (const total of report.controllerGuidanceTotals) {
130
+ durationValid(total.duration);
131
+ guidanceValid(total.phase, total.guidance, false);
132
+ }
133
+ if (report.current) {
134
+ exposureValid(report.current.phase, report.current.exposure);
135
+ const total = report.guidanceTotals.find((total) => total.phase === report.current?.phase &&
136
+ JSON.stringify(total.exposure) ===
137
+ JSON.stringify(report.current.exposure));
138
+ requireValid(integer(report.current.guidanceRunWallMs) &&
139
+ integer(report.current.guidanceRunVisibleMs) &&
140
+ report.current.guidanceRunVisibleMs <=
141
+ report.current.guidanceRunWallMs &&
142
+ report.current.guidanceRunWallMs <= (total?.duration.wallMs ?? -1) &&
143
+ report.current.guidanceRunVisibleMs <=
144
+ (total?.duration.visibleMs ?? -1));
145
+ }
146
+ requireValid(report.lastSDKObservationAgeMs === null ||
147
+ integer(report.lastSDKObservationAgeMs));
148
+ if (report.signature) {
149
+ const s = report.signature;
150
+ for (const value of [
151
+ s.maxPointsSeen,
152
+ s.inkInteractionCount,
153
+ s.interruptions,
154
+ s.interruptionsWithInk,
155
+ ])
156
+ requireValid(integer(value, 1_000_000));
157
+ requireValid(s.interruptionsWithInk <= s.interruptions);
158
+ requireValid(s.drawingStarted === (s.drawingStartedAtMs !== null));
159
+ for (const value of [s.drawingStartedAtMs, s.lastInteractionAtMs])
160
+ requireValid(value === null || (integer(value) && value <= report.elapsedMs));
161
+ }
162
+ }
163
+ }
164
+ export function encodeProgressBatch(batch) {
165
+ requireValid(batch.schemaVersion === 1 &&
166
+ batch.sdkVersion.length > 0 &&
167
+ batch.sdkVersion.length <= 32 &&
168
+ batch.sessionId.length > 0 &&
169
+ uuidPattern.test(batch.producerId) &&
170
+ integer(batch.sentAtUnixMs, Number.MAX_SAFE_INTEGER));
171
+ const reports = [];
172
+ const dropped = [];
173
+ for (const report of batch.reports) {
174
+ try {
175
+ validateSnapshot(report);
176
+ if (utf8({ ...batch, reports: [report] }).length > maximumBytes) {
177
+ dropped.push(report);
178
+ continue;
179
+ }
180
+ if (reports.length >= 4 ||
181
+ utf8({ ...batch, reports: [...reports, report] }).length > maximumBytes)
182
+ break;
183
+ reports.push(report);
184
+ }
185
+ catch {
186
+ dropped.push(report);
187
+ }
188
+ }
189
+ return {
190
+ batch: reports.length
191
+ ? { bytes: utf8({ ...batch, reports }), reports }
192
+ : null,
193
+ dropped,
194
+ };
195
+ }
@@ -0,0 +1,4 @@
1
+ import type { CaptureProgressOptions, CaptureProgressSession } from "./types";
2
+ export type { CaptureProgressOptions, CaptureProgressSession, CaptureProgressTask, WorkflowObservation, WorkflowPhase, } from "./types";
3
+ export declare function createCaptureProgress(options: CaptureProgressOptions): CaptureProgressSession;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/captureProgress/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC9E,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,sBAAsB,CA8CxB"}
@@ -0,0 +1,45 @@
1
+ import { createSessionActor, inertSession } from "./actor";
2
+ import { createTransport } from "./transport";
3
+ export function createCaptureProgress(options) {
4
+ try {
5
+ if (!options.sessionId ||
6
+ typeof document === "undefined" ||
7
+ typeof window === "undefined" ||
8
+ typeof performance?.now !== "function" ||
9
+ typeof crypto?.randomUUID !== "function" ||
10
+ typeof fetch !== "function" ||
11
+ typeof AbortController !== "function" ||
12
+ typeof TextEncoder !== "function")
13
+ return inertSession;
14
+ const url = new URL(options.authUrl);
15
+ if (!["http:", "https:"].includes(url.protocol))
16
+ return inertSession;
17
+ return createSessionActor(options, {
18
+ now: () => performance.now(),
19
+ unixMs: () => Date.now(),
20
+ uuid: () => crypto.randomUUID(),
21
+ random: Math.random,
22
+ visibility: () => document.visibilityState === "hidden" ? "hidden" : "visible",
23
+ subscribe(listener) {
24
+ const visibility = () => listener(document.visibilityState === "hidden" ? "hidden" : "visible");
25
+ const hide = () => listener("hidden");
26
+ document.addEventListener("visibilitychange", visibility);
27
+ window.addEventListener("pagehide", hide);
28
+ window.addEventListener("pageshow", visibility);
29
+ return () => {
30
+ document.removeEventListener("visibilitychange", visibility);
31
+ window.removeEventListener("pagehide", hide);
32
+ window.removeEventListener("pageshow", visibility);
33
+ };
34
+ },
35
+ timer(callback, delay) {
36
+ const timer = setTimeout(callback, delay);
37
+ return () => clearTimeout(timer);
38
+ },
39
+ transport: createTransport(options.sessionId, options.authUrl),
40
+ });
41
+ }
42
+ catch {
43
+ return inertSession;
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ export { openCaptureAttempt, inertObserver, bindCaptureController, bindSubmissionObserver, } from "./actor";
2
+ export type { CaptureObserver, GuidanceExposure } from "./protocol";
3
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/captureProgress/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { openCaptureAttempt, inertObserver, bindCaptureController, bindSubmissionObserver, } from "./actor";
@@ -0,0 +1,224 @@
1
+ import { workflowMilestones, type WorkflowPhase } from "./types";
2
+ export declare const visibilities: readonly ["visible", "hidden"];
3
+ export declare const exposureKinds: readonly ["displayed", "no-prompt", "unobserved"];
4
+ export declare const transitionKinds: readonly ["phase", "visibility", "guidance"];
5
+ export type Visibility = (typeof visibilities)[number];
6
+ export type AttemptEnd = "completed" | "failed" | "superseded" | "disposed";
7
+ export declare const sdkPhases: readonly ["initializing", "instructions", "id-front", "id-back", "passport", "selfie", "signature", "review", "upload", "validation"];
8
+ export type SDKPhase = (typeof sdkPhases)[number];
9
+ export declare const idGuidanceCodes: ("NONE" | "HOLD_STILL" | "NO_DOCUMENT" | "BACK_DETECTED_FLIP" | "FRONT_DETECTED_FLIP" | "ID_CARD_NOT_ALLOWED" | "PASSPORT_NOT_ALLOWED" | "BOOKLET_CORNERS_CUT_OFF" | "BOOKLET_TOO_FAR" | "NOT_CENTERED" | "TOO_CLOSE" | "FINGER_OCCLUSION" | "GLARE" | "HOLOGRAM_REFLECTION" | "NOT_STABLE" | "OUT_OF_FOCUS" | "BARCODE_MOVE_CLOSER" | "BARCODE_HOLD_STILL")[];
10
+ export declare const selfieGuidanceCodes: ("NONE" | "HOLD_STILL" | "NOT_STABLE" | "HAND_OVER_FACE" | "VISIBILITY_TOO_LOW" | "NO_FACE_DETECTED" | "MOVE_TO_CENTER" | "LOOK_STRAIGHT" | "EYES_CLOSED" | "MOVE_BACK" | "MOVE_FORWARD")[];
11
+ export declare const faceMessageCodes: ("TURN_LEFT" | "TURN_RIGHT" | "RETURN_TO_CENTER" | "BLINK" | "BLINK_TWICE" | "REMOVE_EYE_COVERINGS" | "REMOVE_HEAD_COVERINGS" | "REMOVE_MASK" | "CHALLENGE_TIMED_OUT" | "LIVENESS_CHECK_FAILED" | "LIVENESS_CHECK_ERROR" | "VALIDATING" | "MANUAL_CAPTURE")[];
12
+ export declare const signatureGuidanceCodes: ("NONE" | "SIGN_HERE" | "KEEP_SIGNING" | "READY_TO_ACCEPT" | "PROCESSING")[];
13
+ export type HeldGuidance = Readonly<{
14
+ family: "id";
15
+ code: (typeof idGuidanceCodes)[number];
16
+ }> | Readonly<{
17
+ family: "selfie";
18
+ code: (typeof selfieGuidanceCodes)[number];
19
+ }> | Readonly<{
20
+ family: "face";
21
+ code: (typeof faceMessageCodes)[number];
22
+ }> | Readonly<{
23
+ family: "signature";
24
+ code: (typeof signatureGuidanceCodes)[number];
25
+ }>;
26
+ export type DisplayedGuidance = Readonly<{
27
+ family: "id";
28
+ code: Exclude<(typeof idGuidanceCodes)[number], "NONE">;
29
+ }> | Readonly<{
30
+ family: "selfie";
31
+ code: Exclude<(typeof selfieGuidanceCodes)[number], "NONE">;
32
+ }> | Readonly<{
33
+ family: "face";
34
+ code: (typeof faceMessageCodes)[number];
35
+ }> | Readonly<{
36
+ family: "signature";
37
+ code: Exclude<(typeof signatureGuidanceCodes)[number], "NONE">;
38
+ }>;
39
+ export type GuidanceExposure = Readonly<{
40
+ kind: "displayed";
41
+ message: DisplayedGuidance;
42
+ }> | Readonly<{
43
+ kind: "no-prompt";
44
+ }> | Readonly<{
45
+ kind: "unobserved";
46
+ }>;
47
+ export declare const sdkMilestones: readonly ["operation-entered", "camera-ready", "models-ready", "instructions-dismissed", "document-detected", "document-captured", "selfie-captured", "challenge-completed", "recording-started", "first-recording-chunk", "drawing-started", "recording-interrupted", "capture-completed", "capture-skipped", "upload-started", "upload-completed", "validation-started", "validation-completed", "validation-rejected"];
48
+ export type SDKMilestone = (typeof sdkMilestones)[number];
49
+ export type FailureCode = "camera-denied" | "microphone-denied" | "model-load" | "capture-error" | "recording-interrupted" | "upload-error" | "validation-error";
50
+ export type SDKObservation = Readonly<{
51
+ kind: "phase";
52
+ phase: SDKPhase;
53
+ mode: "automatic" | "manual" | "precaptured";
54
+ }> | Readonly<{
55
+ kind: "held-guidance";
56
+ guidance: HeldGuidance;
57
+ }> | Readonly<{
58
+ kind: "displayed-guidance";
59
+ exposure: GuidanceExposure;
60
+ }> | Readonly<{
61
+ kind: "milestone";
62
+ code: SDKMilestone;
63
+ }> | Readonly<{
64
+ kind: "signature-interaction";
65
+ pointCount: number;
66
+ inkInteraction: boolean;
67
+ }> | Readonly<{
68
+ kind: "recording-interruption";
69
+ hadInk: boolean;
70
+ capReached: boolean;
71
+ }> | Readonly<{
72
+ kind: "failure";
73
+ code: FailureCode;
74
+ terminal: boolean;
75
+ }> | Readonly<{
76
+ kind: "phase-completed";
77
+ }> | Readonly<{
78
+ kind: "flow-completed";
79
+ }>;
80
+ export interface CaptureObserver {
81
+ observe(observation: SDKObservation): void;
82
+ retry(reason: "user-requested" | "capture-error" | "recording-interrupted"): void;
83
+ dispose(): void;
84
+ }
85
+ export type Duration = Readonly<{
86
+ wallMs: number;
87
+ visibleMs: number;
88
+ entries: number;
89
+ }>;
90
+ export type PhaseTotal<P extends string> = Readonly<{
91
+ phase: P;
92
+ duration: Duration;
93
+ completions: number;
94
+ }>;
95
+ export type GuidanceTotal = Readonly<{
96
+ phase: SDKPhase;
97
+ exposure: GuidanceExposure;
98
+ duration: Duration;
99
+ }>;
100
+ export type ControllerGuidanceTotal = Readonly<{
101
+ phase: SDKPhase;
102
+ guidance: HeldGuidance;
103
+ duration: Duration;
104
+ }>;
105
+ export type Transition<P extends string> = Readonly<{
106
+ index: number;
107
+ atMs: number;
108
+ kind: "phase";
109
+ phase: P;
110
+ }> | Readonly<{
111
+ index: number;
112
+ atMs: number;
113
+ kind: "visibility";
114
+ visibility: Visibility;
115
+ }> | Readonly<{
116
+ index: number;
117
+ atMs: number;
118
+ kind: "guidance";
119
+ exposure: GuidanceExposure;
120
+ }>;
121
+ export type CurrentState<P extends string> = Readonly<{
122
+ phase: P;
123
+ phaseEntryOrdinal: number;
124
+ phaseEnteredAtMs: number;
125
+ phaseRunWallMs: number;
126
+ phaseRunVisibleMs: number;
127
+ ended: AttemptEnd | null;
128
+ }>;
129
+ export type CurrentSDKState = CurrentState<SDKPhase> & Readonly<{
130
+ exposure: GuidanceExposure;
131
+ guidanceRunWallMs: number;
132
+ guidanceRunVisibleMs: number;
133
+ }>;
134
+ export type SignatureSignals = Readonly<{
135
+ drawingStarted: boolean;
136
+ drawingStartedAtMs: number | null;
137
+ lastInteractionAtMs: number | null;
138
+ maxPointsSeen: number;
139
+ inkInteractionCount: number;
140
+ interruptions: number;
141
+ interruptionsWithInk: number;
142
+ interruptionCapReached: boolean;
143
+ }>;
144
+ export type ObservationCounters = Readonly<{
145
+ retries: number;
146
+ failures: Partial<Record<FailureCode, number>>;
147
+ transitionsDropped: number;
148
+ reportsDropped: number;
149
+ }>;
150
+ export type ReportReason = "entry" | "phase-change" | "checkpoint" | "milestone" | "valuable-state" | "hidden" | "resume" | "completion" | "failure" | "dispose";
151
+ export type SnapshotIdentity = Readonly<{
152
+ context: string;
153
+ streamId: string;
154
+ attemptId: string;
155
+ attemptOrdinal: number;
156
+ attemptStatus: "active" | AttemptEnd;
157
+ sequence: number;
158
+ reason: ReportReason;
159
+ attemptStartedAtUnixMs: number;
160
+ elapsedMs: number;
161
+ visibility: Visibility;
162
+ visibleMs: number;
163
+ lastObservationAgeMs: number | null;
164
+ counters: ObservationCounters;
165
+ }>;
166
+ export type SDKSnapshotV1 = SnapshotIdentity & Readonly<{
167
+ lane: "sdk";
168
+ current: CurrentSDKState | null;
169
+ phaseTotals: readonly PhaseTotal<SDKPhase>[];
170
+ guidanceTotals: readonly GuidanceTotal[];
171
+ controllerGuidanceTotals: readonly ControllerGuidanceTotal[];
172
+ recentTransitions: readonly Transition<SDKPhase>[];
173
+ milestones: Partial<Record<SDKMilestone, number>>;
174
+ lastSDKObservationAgeMs: number | null;
175
+ signature: SignatureSignals | null;
176
+ }>;
177
+ export type WorkflowSnapshotV1 = SnapshotIdentity & Readonly<{
178
+ lane: "workflow";
179
+ current: CurrentState<WorkflowPhase> | null;
180
+ phaseTotals: readonly PhaseTotal<WorkflowPhase>[];
181
+ recentTransitions: readonly Exclude<Transition<WorkflowPhase>, {
182
+ kind: "guidance";
183
+ }>[];
184
+ milestones: Partial<Record<(typeof workflowMilestones)[number] | "task-completed", number>>;
185
+ }>;
186
+ export type SnapshotV1 = SDKSnapshotV1 | WorkflowSnapshotV1;
187
+ export type ProgressBatchV1 = Readonly<{
188
+ schemaVersion: 1;
189
+ sdkVersion: string;
190
+ sessionId: string;
191
+ producerId: string;
192
+ sentAtUnixMs: number;
193
+ reports: readonly SnapshotV1[];
194
+ }>;
195
+ export declare const failureCodes: readonly ["camera-denied", "microphone-denied", "model-load", "capture-error", "recording-interrupted", "upload-error", "validation-error"];
196
+ export declare const workflowFailureCodes: readonly ["upload-error", "validation-error"];
197
+ export declare const retryReasons: readonly ["user-requested", "capture-error", "recording-interrupted"];
198
+ export declare const workflowRetryReasons: readonly ["id-validation", "signature-quality", "signature-complexity", "user-requested"];
199
+ export declare const reportReasons: readonly ["entry", "phase-change", "checkpoint", "milestone", "valuable-state", "hidden", "resume", "completion", "failure", "dispose"];
200
+ export declare const attemptStatuses: readonly ["active", "completed", "failed", "superseded", "disposed"];
201
+ export declare const vocabulary: {
202
+ sdkPhases: readonly ["initializing", "instructions", "id-front", "id-back", "passport", "selfie", "signature", "review", "upload", "validation"];
203
+ workflowPhases: readonly ["task-initializing", "document-selection", "instructions", "manual-id-front", "manual-id-back", "manual-passport", "terms-review", "contract-review", "signature-review", "upload", "validation"];
204
+ idGuidanceCodes: ("NONE" | "HOLD_STILL" | "NO_DOCUMENT" | "BACK_DETECTED_FLIP" | "FRONT_DETECTED_FLIP" | "ID_CARD_NOT_ALLOWED" | "PASSPORT_NOT_ALLOWED" | "BOOKLET_CORNERS_CUT_OFF" | "BOOKLET_TOO_FAR" | "NOT_CENTERED" | "TOO_CLOSE" | "FINGER_OCCLUSION" | "GLARE" | "HOLOGRAM_REFLECTION" | "NOT_STABLE" | "OUT_OF_FOCUS" | "BARCODE_MOVE_CLOSER" | "BARCODE_HOLD_STILL")[];
205
+ selfieGuidanceCodes: ("NONE" | "HOLD_STILL" | "NOT_STABLE" | "HAND_OVER_FACE" | "VISIBILITY_TOO_LOW" | "NO_FACE_DETECTED" | "MOVE_TO_CENTER" | "LOOK_STRAIGHT" | "EYES_CLOSED" | "MOVE_BACK" | "MOVE_FORWARD")[];
206
+ faceMessageCodes: ("TURN_LEFT" | "TURN_RIGHT" | "RETURN_TO_CENTER" | "BLINK" | "BLINK_TWICE" | "REMOVE_EYE_COVERINGS" | "REMOVE_HEAD_COVERINGS" | "REMOVE_MASK" | "CHALLENGE_TIMED_OUT" | "LIVENESS_CHECK_FAILED" | "LIVENESS_CHECK_ERROR" | "VALIDATING" | "MANUAL_CAPTURE")[];
207
+ signatureGuidanceCodes: ("NONE" | "SIGN_HERE" | "KEEP_SIGNING" | "READY_TO_ACCEPT" | "PROCESSING")[];
208
+ sdkMilestones: readonly ["operation-entered", "camera-ready", "models-ready", "instructions-dismissed", "document-detected", "document-captured", "selfie-captured", "challenge-completed", "recording-started", "first-recording-chunk", "drawing-started", "recording-interrupted", "capture-completed", "capture-skipped", "upload-started", "upload-completed", "validation-started", "validation-completed", "validation-rejected"];
209
+ workflowMilestones: string[];
210
+ failureCodes: readonly ["camera-denied", "microphone-denied", "model-load", "capture-error", "recording-interrupted", "upload-error", "validation-error"];
211
+ workflowFailureCodes: readonly ["upload-error", "validation-error"];
212
+ retryReasons: readonly ["user-requested", "capture-error", "recording-interrupted"];
213
+ workflowRetryReasons: readonly ["id-validation", "signature-quality", "signature-complexity", "user-requested"];
214
+ reportReasons: readonly ["entry", "phase-change", "checkpoint", "milestone", "valuable-state", "hidden", "resume", "completion", "failure", "dispose"];
215
+ attemptStatuses: readonly ["active", "completed", "failed", "superseded", "disposed"];
216
+ visibilities: readonly ["visible", "hidden"];
217
+ exposureKinds: readonly ["displayed", "no-prompt", "unobserved"];
218
+ transitionKinds: readonly ["phase", "visibility", "guidance"];
219
+ };
220
+ export type FrozenBatch = Readonly<{
221
+ bytes: Uint8Array;
222
+ reports: readonly SnapshotV1[];
223
+ }>;
224
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/captureProgress/protocol.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAElB,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,YAAY,gCAAiC,CAAC;AAC3D,eAAO,MAAM,aAAa,mDAAoD,CAAC;AAC/E,eAAO,MAAM,eAAe,8CAA+C,CAAC;AAC5E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5E,eAAO,MAAM,SAAS,uIAWZ,CAAC;AACX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,eAAO,MAAM,eAAe,gWAA8B,CAAC;AAC3D,eAAO,MAAM,mBAAmB,6LAAoC,CAAC;AACrE,eAAO,MAAM,gBAAgB,+PAAiC,CAAC;AAC/D,eAAO,MAAM,sBAAsB,8EAElC,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,QAAQ,CAAC;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAClE,QAAQ,CAAC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAC1E,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,M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C;IACJ,UAAU,EAAE,OAAO,CACjB,MAAM,CAAC,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,gBAAgB,EAAE,MAAM,CAAC,CACvE,CAAC;CACH,CAAC,CAAC;AAEL,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,aAAa,EAAE,CAAC,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CAChC,CAAC,CAAC;AAEH,eAAO,MAAM,YAAY,6IAQf,CAAC;AACX,eAAO,MAAM,oBAAoB,+CAGvB,CAAC;AACX,eAAO,MAAM,YAAY,uEAIf,CAAC;AACX,eAAO,MAAM,oBAAoB,2FAKvB,CAAC;AACX,eAAO,MAAM,aAAa,yIAWhB,CAAC;AACX,eAAO,MAAM,eAAe,sEAMlB,CAAC;AACX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;CAkBtB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CAChC,CAAC,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { GuidanceCode } from "../idCapture/guidance";
2
+ import { SelfieGuidanceCode, FaceMessageCode } from "../selfieCapture/guidance";
3
+ import { SignatureCaptureGuidanceCode } from "../signatureCapture/guidance";
4
+ import { workflowMilestones, workflowPhases, } from "./types";
5
+ export const visibilities = ["visible", "hidden"];
6
+ export const exposureKinds = ["displayed", "no-prompt", "unobserved"];
7
+ export const transitionKinds = ["phase", "visibility", "guidance"];
8
+ export const sdkPhases = [
9
+ "initializing",
10
+ "instructions",
11
+ "id-front",
12
+ "id-back",
13
+ "passport",
14
+ "selfie",
15
+ "signature",
16
+ "review",
17
+ "upload",
18
+ "validation",
19
+ ];
20
+ export const idGuidanceCodes = Object.values(GuidanceCode);
21
+ export const selfieGuidanceCodes = Object.values(SelfieGuidanceCode);
22
+ export const faceMessageCodes = Object.values(FaceMessageCode);
23
+ export const signatureGuidanceCodes = Object.values(SignatureCaptureGuidanceCode);
24
+ export const sdkMilestones = [
25
+ "operation-entered",
26
+ "camera-ready",
27
+ "models-ready",
28
+ "instructions-dismissed",
29
+ "document-detected",
30
+ "document-captured",
31
+ "selfie-captured",
32
+ "challenge-completed",
33
+ "recording-started",
34
+ "first-recording-chunk",
35
+ "drawing-started",
36
+ "recording-interrupted",
37
+ "capture-completed",
38
+ "capture-skipped",
39
+ "upload-started",
40
+ "upload-completed",
41
+ "validation-started",
42
+ "validation-completed",
43
+ "validation-rejected",
44
+ ];
45
+ export const failureCodes = [
46
+ "camera-denied",
47
+ "microphone-denied",
48
+ "model-load",
49
+ "capture-error",
50
+ "recording-interrupted",
51
+ "upload-error",
52
+ "validation-error",
53
+ ];
54
+ export const workflowFailureCodes = [
55
+ "upload-error",
56
+ "validation-error",
57
+ ];
58
+ export const retryReasons = [
59
+ "user-requested",
60
+ "capture-error",
61
+ "recording-interrupted",
62
+ ];
63
+ export const workflowRetryReasons = [
64
+ "id-validation",
65
+ "signature-quality",
66
+ "signature-complexity",
67
+ "user-requested",
68
+ ];
69
+ export const reportReasons = [
70
+ "entry",
71
+ "phase-change",
72
+ "checkpoint",
73
+ "milestone",
74
+ "valuable-state",
75
+ "hidden",
76
+ "resume",
77
+ "completion",
78
+ "failure",
79
+ "dispose",
80
+ ];
81
+ export const attemptStatuses = [
82
+ "active",
83
+ "completed",
84
+ "failed",
85
+ "superseded",
86
+ "disposed",
87
+ ];
88
+ export const vocabulary = {
89
+ sdkPhases,
90
+ workflowPhases,
91
+ idGuidanceCodes,
92
+ selfieGuidanceCodes,
93
+ faceMessageCodes,
94
+ signatureGuidanceCodes,
95
+ sdkMilestones,
96
+ workflowMilestones: [...workflowMilestones, "task-completed"],
97
+ failureCodes,
98
+ workflowFailureCodes,
99
+ retryReasons,
100
+ workflowRetryReasons,
101
+ reportReasons,
102
+ attemptStatuses,
103
+ visibilities,
104
+ exposureKinds,
105
+ transitionKinds,
106
+ };
@@ -0,0 +1,32 @@
1
+ import type { WorkflowObservation } from "./types";
2
+ import type { SnapshotV1, SDKSnapshotV1, SDKObservation, Visibility, HeldGuidance, ReportReason, AttemptEnd } from "./protocol";
3
+ export declare const count: (value: number) => number;
4
+ export type RecorderState = Readonly<{
5
+ openedAt: number;
6
+ lastObservationAt: number | null;
7
+ lastSDKObservationAt: number | null;
8
+ held: HeldGuidance | null;
9
+ transitionIndex: number;
10
+ phaseIndex: number;
11
+ guidanceChanges: readonly number[];
12
+ report: SnapshotV1;
13
+ }>;
14
+ export declare function createRecorder(input: {
15
+ lane: "sdk" | "workflow";
16
+ context: string;
17
+ streamId: string;
18
+ attemptId: string;
19
+ attemptOrdinal: number;
20
+ now: number;
21
+ unixMs: number;
22
+ visibility: Visibility;
23
+ }): RecorderState;
24
+ export declare function reduceObservation(state: RecorderState, observation: SDKObservation | WorkflowObservation | {
25
+ kind: "visibility";
26
+ visibility: Visibility;
27
+ }, now: number): RecorderState;
28
+ export declare function endAttempt(state: RecorderState, status: AttemptEnd, now: number): RecorderState;
29
+ export declare function snapshotAt(state: RecorderState, now: number, sequence: number, reason: ReportReason): SnapshotV1;
30
+ export declare function nextCheckpointAfter(visibleMs: number): number;
31
+ export declare function valuableStateDue(snapshot: SDKSnapshotV1, previousVisibleMs: number, guidanceChanges?: readonly number[]): boolean;
32
+ //# sourceMappingURL=recorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../../src/captureProgress/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EACV,UAA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