@incodetech/core 2.0.0-alpha.8 → 2.0.0-rc.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 (184) hide show
  1. package/dist/Actor-CI32dTbG.d.ts +2 -0
  2. package/dist/BaseWasmProvider-C_DLEI40.esm.js +1118 -0
  3. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +55 -0
  4. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +22 -0
  5. package/dist/ITimerCapability-C67ZRskg.esm.js +7 -0
  6. package/dist/IpifyProvider-D7jx52AL.esm.js +139 -0
  7. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +254 -0
  8. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +87 -0
  9. package/dist/StateMachine-BCQrZJhf.d.ts +2 -0
  10. package/dist/WasmUtilProvider-j98OJf-S.esm.js +114 -0
  11. package/dist/addressSearch-BpTbTWCa.esm.js +430 -0
  12. package/dist/ae-signature-DDDZmWXj.esm.js +12 -0
  13. package/dist/ae-signature.d.ts +25 -0
  14. package/dist/ae-signature.esm.js +8 -0
  15. package/dist/antifraud.d.ts +57 -0
  16. package/dist/antifraud.esm.js +45 -0
  17. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +39 -0
  18. package/dist/api-CESGtpbH.esm.js +53 -0
  19. package/dist/authentication.d.ts +12 -0
  20. package/dist/authentication.esm.js +25 -0
  21. package/dist/authenticationManager-5M-fKzXx.esm.js +67 -0
  22. package/dist/authenticationManager-C83GNIhl.d.ts +66 -0
  23. package/dist/authenticationStateMachine-BMZqatiF.esm.js +139 -0
  24. package/dist/backCameraStream-DMdMeGk2.esm.js +346 -0
  25. package/dist/browserSimulation-gxD8cSpM.esm.js +20 -0
  26. package/dist/camera-DBSxa6ML.d.ts +4 -0
  27. package/dist/camera-PA2Ljri3.esm.js +22 -0
  28. package/dist/camera.d.ts +15 -0
  29. package/dist/camera.esm.js +5 -0
  30. package/dist/consent.d.ts +398 -0
  31. package/dist/consent.esm.js +79 -0
  32. package/dist/consentStateMachine-CCT-B60O.esm.js +151 -0
  33. package/dist/cpf-PPz2Njto.esm.js +38 -0
  34. package/dist/cpf-ocr.d.ts +204 -0
  35. package/dist/cpf-ocr.esm.js +177 -0
  36. package/dist/cross-document-data-match.d.ts +34 -0
  37. package/dist/cross-document-data-match.esm.js +71 -0
  38. package/dist/curp-validation.d.ts +188 -0
  39. package/dist/curp-validation.esm.js +110 -0
  40. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +595 -0
  41. package/dist/custom-fields.d.ts +115 -0
  42. package/dist/custom-fields.esm.js +177 -0
  43. package/dist/custom-watchlist.d.ts +66 -0
  44. package/dist/custom-watchlist.esm.js +86 -0
  45. package/dist/dateUtils-UoN5xswP.esm.js +23 -0
  46. package/dist/deepsightLoader-Cm4JIT_z.esm.js +52 -0
  47. package/dist/deepsightService-CEVxzehb.d.ts +412 -0
  48. package/dist/deepsightService-O74l4Y__.esm.js +489 -0
  49. package/dist/device.d.ts +46 -0
  50. package/dist/device.esm.js +106 -0
  51. package/dist/displayErrors-DqJ_IbsG.d.ts +39 -0
  52. package/dist/document-capture.d.ts +906 -0
  53. package/dist/document-capture.esm.js +156 -0
  54. package/dist/document-upload.d.ts +331 -0
  55. package/dist/document-upload.esm.js +203 -0
  56. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +394 -0
  57. package/dist/dynamic-forms.d.ts +178 -0
  58. package/dist/dynamic-forms.esm.js +323 -0
  59. package/dist/ekyb.d.ts +148 -0
  60. package/dist/ekyb.esm.js +127 -0
  61. package/dist/ekybStateMachine-B59rQjgj.esm.js +674 -0
  62. package/dist/ekyc.d.ts +164 -0
  63. package/dist/ekyc.esm.js +104 -0
  64. package/dist/ekycStateMachine-oeO0Iekd.esm.js +10626 -0
  65. package/dist/electronic-signature.d.ts +4 -0
  66. package/dist/electronic-signature.esm.js +7 -0
  67. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +428 -0
  68. package/dist/email.d.ts +3 -263
  69. package/dist/email.esm.js +7 -477
  70. package/dist/emailManager-DIfnS5g1.d.ts +352 -0
  71. package/dist/emailManager-wAV0LE-H.esm.js +238 -0
  72. package/dist/emailStateMachine-DOf4j58N.esm.js +292 -0
  73. package/dist/endpoints-CnN3SyDa.esm.js +87 -0
  74. package/dist/events-D6-e4vok.esm.js +596 -0
  75. package/dist/events.d.ts +265 -0
  76. package/dist/events.esm.js +4 -0
  77. package/dist/extensibility.d.ts +122 -0
  78. package/dist/extensibility.esm.js +43 -0
  79. package/dist/face-match.d.ts +228 -0
  80. package/dist/face-match.esm.js +173 -0
  81. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +290 -0
  82. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +690 -0
  83. package/dist/faceCaptureSetup-B3faSpYA.esm.js +873 -0
  84. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +127 -0
  85. package/dist/flow-events.d.ts +6 -0
  86. package/dist/flow-events.esm.js +0 -0
  87. package/dist/flow.d.ts +101 -321
  88. package/dist/flow.esm.js +370 -173
  89. package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
  90. package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
  91. package/dist/flowServices-DTsm-Vf1.esm.js +188 -0
  92. package/dist/geolocation.d.ts +127 -0
  93. package/dist/geolocation.esm.js +89 -0
  94. package/dist/geolocationStateMachine-asasuHY2.esm.js +105 -0
  95. package/dist/getBrowser-BSXUTWXw.esm.js +41 -0
  96. package/dist/getDeviceClass-BSntT9_j.esm.js +14 -0
  97. package/dist/government-validation.d.ts +67 -0
  98. package/dist/government-validation.esm.js +81 -0
  99. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +271 -0
  100. package/dist/home.d.ts +99 -0
  101. package/dist/home.esm.js +61 -0
  102. package/dist/http.d.ts +68 -0
  103. package/dist/http.esm.js +3 -0
  104. package/dist/id-ocr.d.ts +635 -0
  105. package/dist/id-ocr.esm.js +86 -0
  106. package/dist/id-verification.d.ts +190 -0
  107. package/dist/id-verification.esm.js +43 -0
  108. package/dist/id.d.ts +24 -0
  109. package/dist/id.esm.js +164 -0
  110. package/dist/idCaptureManager-B9TGA5dq.d.ts +956 -0
  111. package/dist/idCaptureManager-DMK0GIt3.esm.js +581 -0
  112. package/dist/idCaptureStateMachine-Bq0fVZXl.esm.js +2954 -0
  113. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +388 -0
  114. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +71 -0
  115. package/dist/identity-reuse.d.ts +530 -0
  116. package/dist/identity-reuse.esm.js +274 -0
  117. package/dist/index-BLKtMA0g.d.ts +1177 -0
  118. package/dist/index-BcRG8rtJ.d.ts +97 -0
  119. package/dist/index.d.ts +3 -226
  120. package/dist/index.esm.js +11 -154
  121. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
  122. package/dist/{lib-Bu9XGMBW.esm.js → lib-BB0B_qQX.esm.js} +801 -2
  123. package/dist/mandatory-consent.d.ts +412 -0
  124. package/dist/mandatory-consent.esm.js +78 -0
  125. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +126 -0
  126. package/dist/openviduLazy-Cm0XFh_v.esm.js +3 -0
  127. package/dist/openviduLazy-Cok70ZSg.esm.js +12 -0
  128. package/dist/permissionServices-D_i6nzEw.esm.js +50 -0
  129. package/dist/phone.d.ts +3 -291
  130. package/dist/phone.esm.js +7 -548
  131. package/dist/phoneManager-B6M30hKE.d.ts +397 -0
  132. package/dist/phoneManager-DAJbGhlY.esm.js +256 -0
  133. package/dist/phoneStateMachine-CuPARRaT.esm.js +351 -0
  134. package/dist/platform-CfrjKhmi.esm.js +83 -0
  135. package/dist/qe-signature-DFo_Cc-I.esm.js +12 -0
  136. package/dist/qe-signature.d.ts +25 -0
  137. package/dist/qe-signature.esm.js +8 -0
  138. package/dist/recordingService-Ig2UgbLv.esm.js +1003 -0
  139. package/dist/redirect-to-mobile.d.ts +107 -0
  140. package/dist/redirect-to-mobile.esm.js +102 -0
  141. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +249 -0
  142. package/dist/runChildModule-CqqwqAkW.esm.js +219 -0
  143. package/dist/selfie.d.ts +21 -754
  144. package/dist/selfie.esm.js +113 -962
  145. package/dist/selfieManager-D0lSgd-J.d.ts +68 -0
  146. package/dist/selfieManager-Duisl7qN.esm.js +60 -0
  147. package/dist/selfieStateMachine-D76whWEf.esm.js +68 -0
  148. package/dist/session-BS-d_vuE.esm.js +3206 -0
  149. package/dist/session.d.ts +217 -0
  150. package/dist/session.esm.js +9 -0
  151. package/dist/setup-Buy-hyj4.esm.js +887 -0
  152. package/dist/setup-C5AITV8m.d.ts +254 -0
  153. package/dist/signature.d.ts +94 -0
  154. package/dist/signature.esm.js +66 -0
  155. package/dist/signatureStateMachine-B5-QVUve.esm.js +132 -0
  156. package/dist/stats-CIfiPzb1.esm.js +16 -0
  157. package/dist/stats.d.ts +16 -0
  158. package/dist/stats.esm.js +4 -0
  159. package/dist/trust-graph.d.ts +54 -0
  160. package/dist/trust-graph.esm.js +56 -0
  161. package/dist/types-B06Ypu2F.d.ts +49 -0
  162. package/dist/types-BP1m8VRw.d.ts +340 -0
  163. package/dist/types-CFV9G_7j.d.ts +24 -0
  164. package/dist/{warmup-CEJTfxQr.d.ts → warmup-CEcppFiS.d.ts} +11 -3
  165. package/dist/wasm.d.ts +15 -0
  166. package/dist/wasm.esm.js +12 -0
  167. package/dist/watchlist-for-business.d.ts +79 -0
  168. package/dist/watchlist-for-business.esm.js +148 -0
  169. package/dist/watchlist.d.ts +62 -0
  170. package/dist/watchlist.esm.js +86 -0
  171. package/dist/watchlistServices-DMbUhkBX.esm.js +12 -0
  172. package/dist/workflow.d.ts +907 -0
  173. package/dist/workflow.esm.js +702 -0
  174. package/dist/{xstate.esm-B_rda9yU.esm.js → xstate.esm-B70JrNqo.esm.js} +144 -1
  175. package/package.json +203 -6
  176. package/dist/OpenViduLogger-BdPfiZO6.esm.js +0 -3
  177. package/dist/OpenViduLogger-CQyDxBvM.esm.js +0 -803
  178. package/dist/StateMachine-DRE1oH2B.d.ts +0 -2
  179. package/dist/addEvent-W0ORK0jT.esm.js +0 -16
  180. package/dist/endpoints-BSTFaHYo.esm.js +0 -1706
  181. package/dist/permissionServices-I6vX6DBy.esm.js +0 -72
  182. /package/dist/{Manager-BGfxEmyv.d.ts → Manager-C8PrhBOx.d.ts} +0 -0
  183. /package/dist/{chunk-C_Yo44FK.esm.js → chunk-CRF6K_H_.esm.js} +0 -0
  184. /package/dist/{types-iZi2rawo.d.ts → types-CAD4va6a.d.ts} +0 -0
@@ -0,0 +1,156 @@
1
+ import "./api-CESGtpbH.esm.js";
2
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
3
+ import "./endpoints-CnN3SyDa.esm.js";
4
+ import { c as createManager, s as createActor } from "./xstate.esm-B70JrNqo.esm.js";
5
+ import "./ITimerCapability-C67ZRskg.esm.js";
6
+ import "./camera-PA2Ljri3.esm.js";
7
+ import "./platform-CfrjKhmi.esm.js";
8
+ import "./backCameraStream-DMdMeGk2.esm.js";
9
+ import { n as DOCUMENT_CAPTURE_ERROR_CODES, t as documentCaptureMachine } from "./documentCaptureStateMachine-BqzTDy9k.esm.js";
10
+
11
+ //#region src/modules/document-capture/documentCaptureActor.ts
12
+ function createDocumentCaptureActor(options) {
13
+ return createActor(documentCaptureMachine, { input: { config: options.config } }).start();
14
+ }
15
+
16
+ //#endregion
17
+ //#region src/modules/document-capture/documentCaptureManager.ts
18
+ function mapState(snapshot) {
19
+ const typedSnapshot = snapshot;
20
+ const { context } = typedSnapshot;
21
+ if (typedSnapshot.matches("tutorial")) {
22
+ const isSecondPage = context.pageNumber > 1;
23
+ return {
24
+ status: "tutorial",
25
+ title: isSecondPage ? context.config.step2Title ?? context.config.title : context.config.title,
26
+ text: isSecondPage ? context.config.step2Text ?? context.config.text : context.config.text,
27
+ allowSkipDocumentCapture: context.config.allowSkipDocumentCapture && context.pageNumber === 1,
28
+ captureMode: context.config.captureMode,
29
+ error: context.error,
30
+ pageNumber: context.pageNumber
31
+ };
32
+ }
33
+ if (typedSnapshot.matches("initCamera")) return { status: "initializingCamera" };
34
+ if (typedSnapshot.matches("capturing")) return {
35
+ status: "capturing",
36
+ stream: context.stream,
37
+ captureMode: context.config.captureMode,
38
+ captureMethod: context.captureMethod,
39
+ error: context.error,
40
+ pageNumber: context.pageNumber
41
+ };
42
+ if (typedSnapshot.matches("preview")) return {
43
+ status: "preview",
44
+ imageBase64: context.capturedDocument?.imageBase64 ?? "",
45
+ fileType: context.capturedDocument?.fileType ?? "",
46
+ fileName: context.capturedDocument?.file.name ?? ""
47
+ };
48
+ if (typedSnapshot.matches("uploading")) return {
49
+ status: "uploading",
50
+ progress: context.progress,
51
+ imageBase64: context.capturedDocument?.imageBase64 ?? "",
52
+ fileType: context.capturedDocument?.fileType ?? "",
53
+ fileName: context.capturedDocument?.file.name ?? ""
54
+ };
55
+ if (typedSnapshot.matches("success")) return {
56
+ status: "success",
57
+ imageBase64: context.capturedDocument?.imageBase64 ?? "",
58
+ fileType: context.capturedDocument?.fileType ?? "",
59
+ fileName: context.capturedDocument?.file.name ?? "",
60
+ nextPageType: context.nextPageType
61
+ };
62
+ if (typedSnapshot.matches("failure")) return {
63
+ status: "failure",
64
+ error: context.error ?? DOCUMENT_CAPTURE_ERROR_CODES.UPLOAD_FAILED,
65
+ attemptsRemaining: context.attemptsRemaining
66
+ };
67
+ if (typedSnapshot.matches("finished")) return { status: "finished" };
68
+ if (typedSnapshot.matches("closed")) return { status: "closed" };
69
+ if (typedSnapshot.matches("nextPage")) return {
70
+ status: "nextPage",
71
+ imageBase64: context.capturedDocument?.imageBase64 ?? "",
72
+ fileType: context.capturedDocument?.fileType ?? "",
73
+ fileName: context.capturedDocument?.file.name ?? "",
74
+ pageNumber: context.pageNumber,
75
+ nextPageType: context.nextPageType,
76
+ captureMode: context.config.captureMode
77
+ };
78
+ if (typedSnapshot.matches("finalizing")) return { status: "finalizing" };
79
+ return {
80
+ status: "tutorial",
81
+ title: void 0,
82
+ text: void 0,
83
+ allowSkipDocumentCapture: false,
84
+ captureMode: "file",
85
+ error: void 0,
86
+ pageNumber: 1
87
+ };
88
+ }
89
+ function createApi({ actor, trackElementClicked }) {
90
+ return {
91
+ capture() {
92
+ trackElementClicked?.("capture");
93
+ actor.send({ type: "CAPTURE" });
94
+ },
95
+ setFile(file, imageBase64) {
96
+ actor.send({
97
+ type: "FILE_SELECTED",
98
+ file,
99
+ imageBase64,
100
+ fileType: file.type
101
+ });
102
+ },
103
+ accept() {
104
+ trackElementClicked?.("accept");
105
+ actor.send({ type: "ACCEPT" });
106
+ },
107
+ retake() {
108
+ trackElementClicked?.("retake");
109
+ actor.send({ type: "RETAKE" });
110
+ },
111
+ retry() {
112
+ trackElementClicked?.("retry");
113
+ actor.send({ type: "RETRY" });
114
+ },
115
+ continue() {
116
+ trackElementClicked?.("continue");
117
+ actor.send({ type: "CONTINUE" });
118
+ },
119
+ skip() {
120
+ trackElementClicked?.("skip");
121
+ actor.send({ type: "SKIP" });
122
+ },
123
+ close() {
124
+ trackElementClicked?.("close");
125
+ actor.send({ type: "CLOSE" });
126
+ },
127
+ captureNextPageFromCamera() {
128
+ trackElementClicked?.("captureNextPageFromCamera");
129
+ actor.send({ type: "NEXT_PAGE_CAMERA" });
130
+ },
131
+ captureNextPageFromFile() {
132
+ trackElementClicked?.("captureNextPageFromFile");
133
+ actor.send({ type: "NEXT_PAGE_PHOTO_LIBRARY" });
134
+ },
135
+ finishPageCapture() {
136
+ trackElementClicked?.("finishPageCapture");
137
+ actor.send({ type: "ALL_PAGES_CAPTURED" });
138
+ }
139
+ };
140
+ }
141
+ function getDocumentCaptureErrorPayload(snapshot) {
142
+ const errorCode = snapshot.context.error;
143
+ if (errorCode === void 0) return;
144
+ return { errorCode };
145
+ }
146
+ function createDocumentCaptureManager(options) {
147
+ return createManager({
148
+ actor: createDocumentCaptureActor(options),
149
+ mapState,
150
+ createApi,
151
+ instrumentation: createManagerInstrumentation(eventModuleNames.document, { getErrorPayload: getDocumentCaptureErrorPayload })
152
+ });
153
+ }
154
+
155
+ //#endregion
156
+ export { DOCUMENT_CAPTURE_ERROR_CODES, createDocumentCaptureManager, documentCaptureMachine };
@@ -0,0 +1,331 @@
1
+ import { t as Manager } from "./Manager-C8PrhBOx.js";
2
+ import "./Actor-CI32dTbG.js";
3
+ import "./camera-DBSxa6ML.js";
4
+ import { n as DocumentUploadContext, r as DocumentUploadInput, t as DocumentUploadConfig } from "./types-CFV9G_7j.js";
5
+ import * as xstate938 from "xstate";
6
+
7
+ //#region src/modules/document-upload/documentUploadStateMachine.d.ts
8
+ declare const documentUploadMachine: xstate938.StateMachine<DocumentUploadContext, {
9
+ type: "START";
10
+ } | {
11
+ type: "CAPTURE";
12
+ imageBase64: string;
13
+ } | {
14
+ type: "UPLOAD_PROGRESS";
15
+ progress: number;
16
+ } | {
17
+ type: "RETRY";
18
+ } | {
19
+ type: "CLOSE";
20
+ }, {
21
+ [x: string]: xstate938.ActorRefFromLogic<xstate938.PromiseActorLogic<MediaStream, void, xstate938.EventObject>> | xstate938.ActorRefFromLogic<xstate938.PromiseActorLogic<void, {
22
+ imageBase64: string;
23
+ documentType: string;
24
+ onProgress: (progress: number) => void;
25
+ }, xstate938.EventObject>> | undefined;
26
+ }, xstate938.Values<{
27
+ uploadDocument: {
28
+ src: "uploadDocument";
29
+ logic: xstate938.PromiseActorLogic<void, {
30
+ imageBase64: string;
31
+ documentType: string;
32
+ onProgress: (progress: number) => void;
33
+ }, xstate938.EventObject>;
34
+ id: string | undefined;
35
+ };
36
+ initCamera: {
37
+ src: "initCamera";
38
+ logic: xstate938.PromiseActorLogic<MediaStream, void, xstate938.EventObject>;
39
+ id: string | undefined;
40
+ };
41
+ }>, xstate938.Values<{
42
+ setError: {
43
+ type: "setError";
44
+ params: xstate938.NonReducibleUnknown;
45
+ };
46
+ clearError: {
47
+ type: "clearError";
48
+ params: xstate938.NonReducibleUnknown;
49
+ };
50
+ setStream: {
51
+ type: "setStream";
52
+ params: xstate938.NonReducibleUnknown;
53
+ };
54
+ setProgress: {
55
+ type: "setProgress";
56
+ params: xstate938.NonReducibleUnknown;
57
+ };
58
+ stopStream: {
59
+ type: "stopStream";
60
+ params: xstate938.NonReducibleUnknown;
61
+ };
62
+ setImageAndClearError: {
63
+ type: "setImageAndClearError";
64
+ params: xstate938.NonReducibleUnknown;
65
+ };
66
+ }>, never, never, "error" | "idle" | "uploading" | "closed" | "finished" | "initCamera" | "capturing", string, DocumentUploadInput, xstate938.NonReducibleUnknown, xstate938.EventObject, xstate938.MetaObject, {
67
+ readonly id: "documentUpload";
68
+ readonly initial: "idle";
69
+ readonly context: ({
70
+ input
71
+ }: {
72
+ spawn: {
73
+ <TSrc extends "uploadDocument" | "initCamera">(logic: TSrc, ...[options]: ({
74
+ src: "uploadDocument";
75
+ logic: xstate938.PromiseActorLogic<void, {
76
+ imageBase64: string;
77
+ documentType: string;
78
+ onProgress: (progress: number) => void;
79
+ }, xstate938.EventObject>;
80
+ id: string | undefined;
81
+ } extends infer T ? T extends {
82
+ src: "uploadDocument";
83
+ logic: xstate938.PromiseActorLogic<void, {
84
+ imageBase64: string;
85
+ documentType: string;
86
+ onProgress: (progress: number) => void;
87
+ }, xstate938.EventObject>;
88
+ id: string | undefined;
89
+ } ? T extends {
90
+ src: TSrc;
91
+ } ? xstate938.ConditionalRequired<[options?: ({
92
+ id?: T["id"] | undefined;
93
+ systemId?: string;
94
+ input?: xstate938.InputFrom<T["logic"]> | undefined;
95
+ syncSnapshot?: boolean;
96
+ } & { [K in xstate938.RequiredActorOptions<T>]: unknown }) | undefined], xstate938.IsNotNever<xstate938.RequiredActorOptions<T>>> : never : never : never) | ({
97
+ src: "initCamera";
98
+ logic: xstate938.PromiseActorLogic<MediaStream, void, xstate938.EventObject>;
99
+ id: string | undefined;
100
+ } extends infer T_1 ? T_1 extends {
101
+ src: "initCamera";
102
+ logic: xstate938.PromiseActorLogic<MediaStream, void, xstate938.EventObject>;
103
+ id: string | undefined;
104
+ } ? T_1 extends {
105
+ src: TSrc;
106
+ } ? xstate938.ConditionalRequired<[options?: ({
107
+ id?: T_1["id"] | undefined;
108
+ systemId?: string;
109
+ input?: xstate938.InputFrom<T_1["logic"]> | undefined;
110
+ syncSnapshot?: boolean;
111
+ } & { [K_1 in xstate938.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate938.IsNotNever<xstate938.RequiredActorOptions<T_1>>> : never : never : never)): xstate938.ActorRefFromLogic<xstate938.GetConcreteByKey<xstate938.Values<{
112
+ uploadDocument: {
113
+ src: "uploadDocument";
114
+ logic: xstate938.PromiseActorLogic<void, {
115
+ imageBase64: string;
116
+ documentType: string;
117
+ onProgress: (progress: number) => void;
118
+ }, xstate938.EventObject>;
119
+ id: string | undefined;
120
+ };
121
+ initCamera: {
122
+ src: "initCamera";
123
+ logic: xstate938.PromiseActorLogic<MediaStream, void, xstate938.EventObject>;
124
+ id: string | undefined;
125
+ };
126
+ }>, "src", TSrc>["logic"]>;
127
+ <TLogic extends xstate938.AnyActorLogic>(src: TLogic, ...[options]: xstate938.ConditionalRequired<[options?: ({
128
+ id?: never;
129
+ systemId?: string;
130
+ input?: xstate938.InputFrom<TLogic> | undefined;
131
+ syncSnapshot?: boolean;
132
+ } & { [K in xstate938.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate938.IsNotNever<xstate938.RequiredLogicInput<TLogic>>>): xstate938.ActorRefFromLogic<TLogic>;
133
+ };
134
+ input: DocumentUploadInput;
135
+ self: xstate938.ActorRef<xstate938.MachineSnapshot<DocumentUploadContext, {
136
+ type: "START";
137
+ } | {
138
+ type: "CAPTURE";
139
+ imageBase64: string;
140
+ } | {
141
+ type: "UPLOAD_PROGRESS";
142
+ progress: number;
143
+ } | {
144
+ type: "RETRY";
145
+ } | {
146
+ type: "CLOSE";
147
+ }, Record<string, xstate938.AnyActorRef | undefined>, xstate938.StateValue, string, unknown, any, any>, {
148
+ type: "START";
149
+ } | {
150
+ type: "CAPTURE";
151
+ imageBase64: string;
152
+ } | {
153
+ type: "UPLOAD_PROGRESS";
154
+ progress: number;
155
+ } | {
156
+ type: "RETRY";
157
+ } | {
158
+ type: "CLOSE";
159
+ }, xstate938.AnyEventObject>;
160
+ }) => {
161
+ config: DocumentUploadConfig;
162
+ stream: undefined;
163
+ imageBase64: undefined;
164
+ progress: number;
165
+ error: undefined;
166
+ };
167
+ readonly states: {
168
+ readonly idle: {
169
+ readonly on: {
170
+ readonly START: {
171
+ readonly target: "initCamera";
172
+ };
173
+ };
174
+ };
175
+ readonly initCamera: {
176
+ readonly invoke: {
177
+ readonly id: "initCamera";
178
+ readonly src: "initCamera";
179
+ readonly input: undefined;
180
+ readonly onDone: {
181
+ readonly target: "capturing";
182
+ readonly actions: "setStream";
183
+ };
184
+ readonly onError: {
185
+ readonly target: "error";
186
+ readonly actions: "setError";
187
+ };
188
+ };
189
+ readonly on: {
190
+ readonly CLOSE: {
191
+ readonly target: "closed";
192
+ };
193
+ };
194
+ };
195
+ readonly capturing: {
196
+ readonly on: {
197
+ readonly CAPTURE: {
198
+ readonly target: "uploading";
199
+ readonly actions: "setImageAndClearError";
200
+ };
201
+ readonly CLOSE: {
202
+ readonly target: "closed";
203
+ readonly actions: "stopStream";
204
+ };
205
+ };
206
+ };
207
+ readonly uploading: {
208
+ readonly invoke: {
209
+ readonly id: "uploadDocument";
210
+ readonly src: "uploadDocument";
211
+ readonly input: ({
212
+ context,
213
+ self
214
+ }: {
215
+ context: DocumentUploadContext;
216
+ event: {
217
+ type: "START";
218
+ } | {
219
+ type: "CAPTURE";
220
+ imageBase64: string;
221
+ } | {
222
+ type: "UPLOAD_PROGRESS";
223
+ progress: number;
224
+ } | {
225
+ type: "RETRY";
226
+ } | {
227
+ type: "CLOSE";
228
+ };
229
+ self: xstate938.ActorRef<xstate938.MachineSnapshot<DocumentUploadContext, {
230
+ type: "START";
231
+ } | {
232
+ type: "CAPTURE";
233
+ imageBase64: string;
234
+ } | {
235
+ type: "UPLOAD_PROGRESS";
236
+ progress: number;
237
+ } | {
238
+ type: "RETRY";
239
+ } | {
240
+ type: "CLOSE";
241
+ }, Record<string, xstate938.AnyActorRef>, xstate938.StateValue, string, unknown, any, any>, {
242
+ type: "START";
243
+ } | {
244
+ type: "CAPTURE";
245
+ imageBase64: string;
246
+ } | {
247
+ type: "UPLOAD_PROGRESS";
248
+ progress: number;
249
+ } | {
250
+ type: "RETRY";
251
+ } | {
252
+ type: "CLOSE";
253
+ }, xstate938.AnyEventObject>;
254
+ }) => {
255
+ imageBase64: string;
256
+ documentType: string;
257
+ onProgress: (progress: number) => void;
258
+ };
259
+ readonly onDone: {
260
+ readonly target: "finished";
261
+ readonly actions: "stopStream";
262
+ };
263
+ readonly onError: {
264
+ readonly target: "error";
265
+ readonly actions: readonly ["setError", "stopStream"];
266
+ };
267
+ };
268
+ readonly on: {
269
+ readonly UPLOAD_PROGRESS: {
270
+ readonly actions: "setProgress";
271
+ };
272
+ };
273
+ };
274
+ readonly error: {
275
+ readonly on: {
276
+ readonly RETRY: {
277
+ readonly target: "initCamera";
278
+ readonly actions: "clearError";
279
+ };
280
+ readonly CLOSE: {
281
+ readonly target: "closed";
282
+ readonly actions: "stopStream";
283
+ };
284
+ };
285
+ };
286
+ readonly finished: {
287
+ readonly type: "final";
288
+ };
289
+ readonly closed: {
290
+ readonly type: "final";
291
+ };
292
+ };
293
+ }>;
294
+ //#endregion
295
+ //#region src/modules/document-upload/documentUploadActor.d.ts
296
+ type CreateDocumentUploadActorOptions = {
297
+ config: DocumentUploadConfig;
298
+ };
299
+ //#endregion
300
+ //#region src/modules/document-upload/documentUploadManager.d.ts
301
+ type DocumentUploadInitializingState = {
302
+ status: 'initializing';
303
+ };
304
+ type DocumentUploadCapturingState = {
305
+ status: 'capturing';
306
+ stream: MediaStream;
307
+ };
308
+ type DocumentUploadUploadingState = {
309
+ status: 'uploading';
310
+ progress: number;
311
+ };
312
+ type DocumentUploadErrorState = {
313
+ status: 'error';
314
+ error: string;
315
+ };
316
+ type DocumentUploadFinishedState = {
317
+ status: 'finished';
318
+ };
319
+ type DocumentUploadClosedState = {
320
+ status: 'closed';
321
+ };
322
+ type DocumentUploadState = DocumentUploadInitializingState | DocumentUploadCapturingState | DocumentUploadUploadingState | DocumentUploadErrorState | DocumentUploadFinishedState | DocumentUploadClosedState;
323
+ declare function createDocumentUploadManager(options: CreateDocumentUploadActorOptions): Manager<DocumentUploadState> & {
324
+ load(): void;
325
+ capture(imageBase64: string): void;
326
+ retry(): void;
327
+ close(): void;
328
+ };
329
+ type DocumentUploadManager = ReturnType<typeof createDocumentUploadManager>;
330
+ //#endregion
331
+ export { type DocumentUploadConfig, type DocumentUploadManager, type DocumentUploadState, createDocumentUploadManager, documentUploadMachine };
@@ -0,0 +1,203 @@
1
+ import { t as api } from "./api-CESGtpbH.esm.js";
2
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
3
+ import { t as endpoints } from "./endpoints-CnN3SyDa.esm.js";
4
+ import { a as fromPromise, c as createManager, r as assign, s as createActor, t as setup } from "./xstate.esm-B70JrNqo.esm.js";
5
+ import "./ITimerCapability-C67ZRskg.esm.js";
6
+ import { i as stopCameraStream } from "./camera-PA2Ljri3.esm.js";
7
+ import "./platform-CfrjKhmi.esm.js";
8
+ import { t as getBackCameraStream } from "./backCameraStream-DMdMeGk2.esm.js";
9
+
10
+ //#region src/modules/document-upload/documentUploadServices.ts
11
+ async function uploadDocument({ imageBase64, documentType, onProgress, signal }) {
12
+ const url = `${endpoints.addDocument}?type=${encodeURIComponent(documentType)}`;
13
+ const response = await api.post(url, { base64Image: imageBase64 }, {
14
+ signal,
15
+ onUploadProgress: onProgress
16
+ });
17
+ if (!response.ok) throw new Error(`Document upload failed: ${response.status} ${response.statusText}`);
18
+ }
19
+
20
+ //#endregion
21
+ //#region src/modules/document-upload/documentUploadStateMachine.ts
22
+ const documentUploadMachine = setup({
23
+ types: {
24
+ context: {},
25
+ events: {},
26
+ input: {}
27
+ },
28
+ actors: {
29
+ initCamera: fromPromise(async () => {
30
+ const { stream } = await getBackCameraStream(void 0);
31
+ return stream;
32
+ }),
33
+ uploadDocument: fromPromise(async ({ input, signal }) => {
34
+ return uploadDocument({
35
+ imageBase64: input.imageBase64,
36
+ documentType: input.documentType,
37
+ onProgress: input.onProgress,
38
+ signal
39
+ });
40
+ })
41
+ },
42
+ actions: {
43
+ setStream: assign(({ event }) => ({ stream: event.output })),
44
+ setImageAndClearError: assign(({ event }) => {
45
+ return {
46
+ imageBase64: event.imageBase64,
47
+ error: void 0
48
+ };
49
+ }),
50
+ setProgress: assign(({ event }) => ({ progress: event.progress })),
51
+ setError: assign(({ event }) => ({ error: String(event.error) })),
52
+ clearError: assign({ error: () => void 0 }),
53
+ stopStream: assign(({ context }) => {
54
+ if (context.stream) stopCameraStream(context.stream);
55
+ return { stream: void 0 };
56
+ })
57
+ }
58
+ }).createMachine({
59
+ id: "documentUpload",
60
+ initial: "idle",
61
+ context: ({ input }) => ({
62
+ config: input.config,
63
+ stream: void 0,
64
+ imageBase64: void 0,
65
+ progress: 0,
66
+ error: void 0
67
+ }),
68
+ states: {
69
+ idle: { on: { START: { target: "initCamera" } } },
70
+ initCamera: {
71
+ invoke: {
72
+ id: "initCamera",
73
+ src: "initCamera",
74
+ input: void 0,
75
+ onDone: {
76
+ target: "capturing",
77
+ actions: "setStream"
78
+ },
79
+ onError: {
80
+ target: "error",
81
+ actions: "setError"
82
+ }
83
+ },
84
+ on: { CLOSE: { target: "closed" } }
85
+ },
86
+ capturing: { on: {
87
+ CAPTURE: {
88
+ target: "uploading",
89
+ actions: "setImageAndClearError"
90
+ },
91
+ CLOSE: {
92
+ target: "closed",
93
+ actions: "stopStream"
94
+ }
95
+ } },
96
+ uploading: {
97
+ invoke: {
98
+ id: "uploadDocument",
99
+ src: "uploadDocument",
100
+ input: ({ context, self }) => {
101
+ const imageBase64 = context.imageBase64;
102
+ if (!imageBase64) throw new Error("No image to upload");
103
+ return {
104
+ imageBase64,
105
+ documentType: context.config.documentType,
106
+ onProgress: (progress) => {
107
+ self.send({
108
+ type: "UPLOAD_PROGRESS",
109
+ progress
110
+ });
111
+ }
112
+ };
113
+ },
114
+ onDone: {
115
+ target: "finished",
116
+ actions: "stopStream"
117
+ },
118
+ onError: {
119
+ target: "error",
120
+ actions: ["setError", "stopStream"]
121
+ }
122
+ },
123
+ on: { UPLOAD_PROGRESS: { actions: "setProgress" } }
124
+ },
125
+ error: { on: {
126
+ RETRY: {
127
+ target: "initCamera",
128
+ actions: "clearError"
129
+ },
130
+ CLOSE: {
131
+ target: "closed",
132
+ actions: "stopStream"
133
+ }
134
+ } },
135
+ finished: { type: "final" },
136
+ closed: { type: "final" }
137
+ }
138
+ });
139
+
140
+ //#endregion
141
+ //#region src/modules/document-upload/documentUploadActor.ts
142
+ function createDocumentUploadActor(options) {
143
+ return createActor(documentUploadMachine, { input: { config: options.config } }).start();
144
+ }
145
+
146
+ //#endregion
147
+ //#region src/modules/document-upload/documentUploadManager.ts
148
+ function mapState(snapshot) {
149
+ const typedSnapshot = snapshot;
150
+ const { context } = typedSnapshot;
151
+ if (typedSnapshot.matches("idle") || typedSnapshot.matches("initCamera")) return { status: "initializing" };
152
+ if (typedSnapshot.matches("capturing")) {
153
+ if (!context.stream) return { status: "initializing" };
154
+ return {
155
+ status: "capturing",
156
+ stream: context.stream
157
+ };
158
+ }
159
+ if (typedSnapshot.matches("uploading")) return {
160
+ status: "uploading",
161
+ progress: context.progress
162
+ };
163
+ if (typedSnapshot.matches("error")) return {
164
+ status: "error",
165
+ error: context.error ?? "Upload failed"
166
+ };
167
+ if (typedSnapshot.matches("finished")) return { status: "finished" };
168
+ if (typedSnapshot.matches("closed")) return { status: "closed" };
169
+ return { status: "initializing" };
170
+ }
171
+ function createApi({ actor, trackElementClicked }) {
172
+ return {
173
+ load() {
174
+ actor.send({ type: "START" });
175
+ },
176
+ capture(imageBase64) {
177
+ trackElementClicked?.("capture");
178
+ actor.send({
179
+ type: "CAPTURE",
180
+ imageBase64
181
+ });
182
+ },
183
+ retry() {
184
+ trackElementClicked?.("retry");
185
+ actor.send({ type: "RETRY" });
186
+ },
187
+ close() {
188
+ trackElementClicked?.("close");
189
+ actor.send({ type: "CLOSE" });
190
+ }
191
+ };
192
+ }
193
+ function createDocumentUploadManager(options) {
194
+ return createManager({
195
+ actor: createDocumentUploadActor(options),
196
+ mapState,
197
+ createApi,
198
+ instrumentation: createManagerInstrumentation(eventModuleNames.document)
199
+ });
200
+ }
201
+
202
+ //#endregion
203
+ export { createDocumentUploadManager, documentUploadMachine };