@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,4 @@
1
+ import "./Manager-C8PrhBOx.js";
2
+ import "./Actor-CI32dTbG.js";
3
+ import { a as AE_CONSENT_KEYS, c as ConsentKey, d as ElectronicSignatureVariant, f as QE_CONSENT_KEYS, g as getDefaultConsentChecks, h as getConsentKeys, i as electronicSignatureMachine, l as ElectronicSignatureConfig, m as areAllConsented, n as ElectronicSignatureState, o as AeConsentKey, p as QeConsentKey, r as createElectronicSignatureManager, s as ConsentChecks, t as ElectronicSignatureManager, u as ElectronicSignatureDocument } from "./index-BLKtMA0g.js";
4
+ export { AE_CONSENT_KEYS, AeConsentKey, ConsentChecks, ConsentKey, ElectronicSignatureConfig, ElectronicSignatureDocument, ElectronicSignatureManager, ElectronicSignatureState, ElectronicSignatureVariant, QE_CONSENT_KEYS, QeConsentKey, areAllConsented, createElectronicSignatureManager, electronicSignatureMachine, getConsentKeys, getDefaultConsentChecks };
@@ -0,0 +1,7 @@
1
+ import "./api-CESGtpbH.esm.js";
2
+ import "./events-D6-e4vok.esm.js";
3
+ import "./endpoints-CnN3SyDa.esm.js";
4
+ import "./xstate.esm-B70JrNqo.esm.js";
5
+ import { a as areAllConsented, i as QE_CONSENT_KEYS, n as electronicSignatureMachine, o as getConsentKeys, r as AE_CONSENT_KEYS, s as getDefaultConsentChecks, t as createElectronicSignatureManager } from "./electronicSignatureManager-D9OHzTpG.esm.js";
6
+
7
+ export { AE_CONSENT_KEYS, QE_CONSENT_KEYS, areAllConsented, createElectronicSignatureManager, electronicSignatureMachine, getConsentKeys, getDefaultConsentChecks };
@@ -0,0 +1,428 @@
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
+
6
+ //#region ../infra/src/http/externalFetch.ts
7
+ async function externalFetch(config) {
8
+ const res = await fetch(config.url, {
9
+ method: config.method,
10
+ headers: config.headers,
11
+ body: config.body,
12
+ signal: config.signal
13
+ });
14
+ if (!res.ok) throw new Error(`${config.method} ${config.url} failed: ${res.status} ${res.statusText}`);
15
+ return res;
16
+ }
17
+
18
+ //#endregion
19
+ //#region src/modules/electronic-signature/electronicSignatureServices.ts
20
+ async function fetchUnsignedDocuments(signal) {
21
+ const res = await api.get(endpoints.aesUnsignedDocuments, { signal });
22
+ if (!res.ok) throw new Error(`GET ${endpoints.aesUnsignedDocuments} failed: ${res.status} ${res.statusText}`);
23
+ return res.data;
24
+ }
25
+ function getSignEndpoint(variant) {
26
+ return variant === "qe" ? endpoints.qesSignDocument : endpoints.aesSignDocument;
27
+ }
28
+ async function signDocument(documentRef, variant, signal) {
29
+ const endpoint = getSignEndpoint(variant);
30
+ const res = await api.post(endpoint, {
31
+ documentRef,
32
+ userConsented: true
33
+ }, { signal });
34
+ if (!res.ok) throw new Error(`POST ${endpoint} failed: ${res.status} ${res.statusText}`);
35
+ return res.data;
36
+ }
37
+ async function generateUploadUrl(signal) {
38
+ const res = await api.post(endpoints.aesGenerateUploadUrl, {}, { signal });
39
+ if (!res.ok) throw new Error(`POST ${endpoints.aesGenerateUploadUrl} failed: ${res.status} ${res.statusText}`);
40
+ return res.data;
41
+ }
42
+ async function uploadDocumentFile(presignedUrl, data, signal) {
43
+ await externalFetch({
44
+ method: "PUT",
45
+ url: presignedUrl,
46
+ headers: { "Content-Type": "application/pdf" },
47
+ body: data,
48
+ signal
49
+ });
50
+ }
51
+
52
+ //#endregion
53
+ //#region src/modules/electronic-signature/electronicSignatureActors.ts
54
+ const fetchUnsignedDocsActor = fromPromise(async ({ signal }) => fetchUnsignedDocuments(signal));
55
+ const signDocumentsActor = fromPromise(async ({ input, signal }) => {
56
+ return (await Promise.all(input.documents.map((doc) => signDocument(doc.documentRef, input.variant, signal)))).map((r) => ({ signedDocumentUrl: r.signedDocumentUrl }));
57
+ });
58
+ const uploadDocumentActor = fromPromise(async ({ input, signal }) => {
59
+ const fileData = input.getFileData();
60
+ if (!fileData) throw new Error("No file data available for upload");
61
+ const { preSignedUrl } = await generateUploadUrl(signal);
62
+ await uploadDocumentFile(preSignedUrl, fileData, signal);
63
+ });
64
+
65
+ //#endregion
66
+ //#region src/modules/electronic-signature/types.ts
67
+ const AE_CONSENT_KEYS = [
68
+ "terms",
69
+ "signElectronically",
70
+ "signDisplayed"
71
+ ];
72
+ const QE_CONSENT_KEYS = [
73
+ "issuance",
74
+ "qesAcknowledgement",
75
+ "qscdConfirmation",
76
+ "termsAgreement",
77
+ "documentsReviewed"
78
+ ];
79
+ function getConsentKeys(variant) {
80
+ return variant === "qe" ? QE_CONSENT_KEYS : AE_CONSENT_KEYS;
81
+ }
82
+ function getDefaultConsentChecks(variant) {
83
+ const keys = getConsentKeys(variant);
84
+ return Object.fromEntries(keys.map((k) => [k, false]));
85
+ }
86
+ function areAllConsented(checks) {
87
+ return Object.values(checks).every(Boolean);
88
+ }
89
+
90
+ //#endregion
91
+ //#region src/modules/electronic-signature/electronicSignatureStateMachine.ts
92
+ const electronicSignatureMachine = setup({
93
+ types: {
94
+ context: {},
95
+ events: {},
96
+ input: {}
97
+ },
98
+ actors: {
99
+ fetchUnsignedDocs: fetchUnsignedDocsActor,
100
+ signDocuments: signDocumentsActor,
101
+ uploadDocument: uploadDocumentActor
102
+ },
103
+ actions: {
104
+ setDocuments: assign(({ event }) => {
105
+ const { output } = event;
106
+ return { documents: output.documents ?? [] };
107
+ }),
108
+ setSignedDocuments: assign(({ event }) => {
109
+ const { output } = event;
110
+ return { signedDocuments: output };
111
+ }),
112
+ setFile: assign(({ event }) => {
113
+ const { fileName, fileSize, fileUrl } = event;
114
+ return {
115
+ fileName,
116
+ fileSize,
117
+ fileUrl
118
+ };
119
+ }),
120
+ updateConsent: assign(({ context, event }) => {
121
+ const { name, checked } = event;
122
+ return { consentChecks: {
123
+ ...context.consentChecks,
124
+ [name]: checked
125
+ } };
126
+ }),
127
+ setViewingDocument: assign(({ event }) => ({ viewingDocumentUrl: event.url })),
128
+ clearViewingDocument: assign({ viewingDocumentUrl: () => null })
129
+ },
130
+ guards: {
131
+ errorFromUpload: ({ context }) => context.errorSource === "upload",
132
+ errorFromSigning: ({ context }) => context.errorSource === "signing",
133
+ shouldUpload: ({ context }) => context.config.uploadDocument === true,
134
+ shouldDownload: ({ context }) => context.config.downloadDocument === true,
135
+ allConsented: ({ context }) => areAllConsented(context.consentChecks),
136
+ hasDocuments: ({ event }) => {
137
+ const { output } = event;
138
+ return (output.documents?.length ?? 0) > 0;
139
+ },
140
+ allSigned: ({ event }) => {
141
+ const { output } = event;
142
+ return output.every((d) => !!d.signedDocumentUrl);
143
+ },
144
+ allSignedAndDownload: ({ context, event }) => {
145
+ const { output } = event;
146
+ return output.every((d) => !!d.signedDocumentUrl) && context.config.downloadDocument === true;
147
+ }
148
+ }
149
+ }).createMachine({
150
+ id: "electronicSignature",
151
+ initial: "idle",
152
+ context: ({ input }) => ({
153
+ config: input.config,
154
+ getFileData: input.getFileData,
155
+ documents: [],
156
+ signedDocuments: [],
157
+ fileName: null,
158
+ fileSize: null,
159
+ fileUrl: null,
160
+ consentChecks: getDefaultConsentChecks(input.config.variant ?? "ae"),
161
+ viewingDocumentUrl: null,
162
+ errorMessage: "",
163
+ errorSource: null
164
+ }),
165
+ states: {
166
+ idle: { on: { LOAD: [{
167
+ target: "uploading",
168
+ guard: "shouldUpload"
169
+ }, { target: "fetchingDocs" }] } },
170
+ uploading: { on: {
171
+ SELECT_FILE: {
172
+ target: "reviewing",
173
+ actions: "setFile"
174
+ },
175
+ CLOSE: { target: "closed" }
176
+ } },
177
+ reviewing: { on: {
178
+ REPLACE_FILE: {
179
+ target: "uploading",
180
+ actions: assign({
181
+ fileName: () => null,
182
+ fileSize: () => null,
183
+ fileUrl: () => null
184
+ })
185
+ },
186
+ CONFIRM_FILE: { target: "uploadingFile" },
187
+ CLOSE: { target: "closed" }
188
+ } },
189
+ uploadingFile: { invoke: {
190
+ id: "uploadDocument",
191
+ src: "uploadDocument",
192
+ input: ({ context }) => ({ getFileData: context.getFileData }),
193
+ onDone: { target: "fetchingDocs" },
194
+ onError: {
195
+ target: "error",
196
+ actions: assign(({ event }) => ({
197
+ errorMessage: String(event.error ?? "aes.error"),
198
+ errorSource: "upload"
199
+ }))
200
+ }
201
+ } },
202
+ fetchingDocs: { invoke: {
203
+ id: "fetchUnsignedDocs",
204
+ src: "fetchUnsignedDocs",
205
+ onDone: [{
206
+ target: "signing",
207
+ guard: "hasDocuments",
208
+ actions: "setDocuments"
209
+ }, {
210
+ target: "error",
211
+ actions: assign({
212
+ errorMessage: () => "aes.noDocuments",
213
+ errorSource: () => "fetchDocs"
214
+ })
215
+ }],
216
+ onError: {
217
+ target: "error",
218
+ actions: assign(({ event }) => ({
219
+ errorMessage: String(event.error ?? "aes.error"),
220
+ errorSource: "fetchDocs"
221
+ }))
222
+ }
223
+ } },
224
+ signing: { on: {
225
+ SET_CONSENT: { actions: "updateConsent" },
226
+ VIEW_DOCUMENT: { actions: "setViewingDocument" },
227
+ CLOSE_DOCUMENT_VIEW: { actions: "clearViewingDocument" },
228
+ SIGN: {
229
+ target: "processing",
230
+ guard: "allConsented"
231
+ },
232
+ CLOSE: { target: "closed" }
233
+ } },
234
+ processing: { invoke: {
235
+ id: "signDocuments",
236
+ src: "signDocuments",
237
+ input: ({ context }) => ({
238
+ documents: context.documents,
239
+ variant: context.config.variant ?? "ae"
240
+ }),
241
+ onDone: [
242
+ {
243
+ target: "successDownload",
244
+ guard: "allSignedAndDownload",
245
+ actions: "setSignedDocuments"
246
+ },
247
+ {
248
+ target: "success",
249
+ guard: "allSigned",
250
+ actions: "setSignedDocuments"
251
+ },
252
+ {
253
+ target: "error",
254
+ actions: assign({
255
+ errorMessage: () => "aes.signingFailed",
256
+ errorSource: () => "signing"
257
+ })
258
+ }
259
+ ],
260
+ onError: {
261
+ target: "error",
262
+ actions: assign(({ event }) => ({
263
+ errorMessage: String(event.error ?? "aes.error"),
264
+ errorSource: "signing"
265
+ }))
266
+ }
267
+ } },
268
+ success: { after: { 3e3: "finished" } },
269
+ successDownload: { on: {
270
+ FINISH: { target: "finished" },
271
+ CLOSE: { target: "closed" }
272
+ } },
273
+ error: { on: {
274
+ RETRY: [
275
+ {
276
+ target: "uploading",
277
+ guard: "errorFromUpload",
278
+ actions: assign({
279
+ errorMessage: () => "",
280
+ errorSource: () => null,
281
+ fileName: () => null,
282
+ fileSize: () => null,
283
+ fileUrl: () => null
284
+ })
285
+ },
286
+ {
287
+ target: "signing",
288
+ guard: "errorFromSigning",
289
+ actions: assign({
290
+ errorMessage: () => "",
291
+ errorSource: () => null
292
+ })
293
+ },
294
+ {
295
+ target: "fetchingDocs",
296
+ actions: assign({
297
+ errorMessage: () => "",
298
+ errorSource: () => null
299
+ })
300
+ }
301
+ ],
302
+ CLOSE: { target: "closed" }
303
+ } },
304
+ finished: { type: "final" },
305
+ closed: { type: "final" }
306
+ }
307
+ });
308
+
309
+ //#endregion
310
+ //#region src/modules/electronic-signature/electronicSignatureActor.ts
311
+ function createElectronicSignatureActor(options) {
312
+ return createActor(electronicSignatureMachine, { input: {
313
+ config: options.config,
314
+ getFileData: options.getFileData
315
+ } }).start();
316
+ }
317
+
318
+ //#endregion
319
+ //#region src/modules/electronic-signature/electronicSignatureManager.ts
320
+ function mapState(snapshot) {
321
+ const { context } = snapshot;
322
+ if (snapshot.matches("idle") || snapshot.matches("fetchingDocs") || snapshot.matches("uploadingFile")) return { status: "loading" };
323
+ if (snapshot.matches("uploading")) return {
324
+ status: "uploading",
325
+ fileName: context.fileName
326
+ };
327
+ if (snapshot.matches("reviewing")) return {
328
+ status: "reviewing",
329
+ fileName: context.fileName,
330
+ fileUrl: context.fileUrl
331
+ };
332
+ if (snapshot.matches("signing")) return {
333
+ status: "signing",
334
+ variant: context.config.variant ?? "ae",
335
+ documents: context.documents,
336
+ consentChecks: context.consentChecks,
337
+ allConsented: areAllConsented(context.consentChecks),
338
+ viewingDocumentUrl: context.viewingDocumentUrl
339
+ };
340
+ if (snapshot.matches("processing")) return { status: "processing" };
341
+ if (snapshot.matches("success") || snapshot.matches("successDownload")) return {
342
+ status: "success",
343
+ signedDocuments: context.signedDocuments,
344
+ downloadDocument: context.config.downloadDocument === true
345
+ };
346
+ if (snapshot.matches("error")) return {
347
+ status: "error",
348
+ errorMessage: context.errorMessage
349
+ };
350
+ if (snapshot.matches("finished")) return { status: "finished" };
351
+ if (snapshot.matches("closed")) return { status: "closed" };
352
+ throw new Error(`Unhandled electronic-signature state: ${JSON.stringify(snapshot.value)}`);
353
+ }
354
+ function createApi({ actor, trackElementClicked, fileDataRef }) {
355
+ return {
356
+ load() {
357
+ actor.send({ type: "LOAD" });
358
+ },
359
+ setConsent(name, checked) {
360
+ actor.send({
361
+ type: "SET_CONSENT",
362
+ name,
363
+ checked
364
+ });
365
+ },
366
+ selectFile(fileName, fileData, fileUrl) {
367
+ fileDataRef.current = fileData;
368
+ actor.send({
369
+ type: "SELECT_FILE",
370
+ fileName,
371
+ fileSize: fileData.byteLength,
372
+ fileUrl
373
+ });
374
+ },
375
+ replaceFile() {
376
+ fileDataRef.current = null;
377
+ actor.send({ type: "REPLACE_FILE" });
378
+ },
379
+ confirmFile() {
380
+ trackElementClicked?.("confirmFile");
381
+ actor.send({ type: "CONFIRM_FILE" });
382
+ },
383
+ viewDocument(url) {
384
+ actor.send({
385
+ type: "VIEW_DOCUMENT",
386
+ url
387
+ });
388
+ },
389
+ closeDocumentView() {
390
+ actor.send({ type: "CLOSE_DOCUMENT_VIEW" });
391
+ },
392
+ sign() {
393
+ trackElementClicked?.("sign");
394
+ actor.send({ type: "SIGN" });
395
+ },
396
+ finish() {
397
+ trackElementClicked?.("finish");
398
+ actor.send({ type: "FINISH" });
399
+ },
400
+ retry() {
401
+ trackElementClicked?.("retry");
402
+ fileDataRef.current = null;
403
+ actor.send({ type: "RETRY" });
404
+ },
405
+ close() {
406
+ trackElementClicked?.("close");
407
+ actor.send({ type: "CLOSE" });
408
+ }
409
+ };
410
+ }
411
+ function createElectronicSignatureManager(options) {
412
+ const fileDataRef = { current: null };
413
+ return createManager({
414
+ actor: createElectronicSignatureActor({
415
+ config: options.config,
416
+ getFileData: () => fileDataRef.current
417
+ }),
418
+ mapState,
419
+ createApi: (apiOptions) => createApi({
420
+ ...apiOptions,
421
+ fileDataRef
422
+ }),
423
+ instrumentation: createManagerInstrumentation(options.config.variant === "qe" ? eventModuleNames.qeSignature : eventModuleNames.aeSignature)
424
+ });
425
+ }
426
+
427
+ //#endregion
428
+ export { areAllConsented as a, QE_CONSENT_KEYS as i, electronicSignatureMachine as n, getConsentKeys as o, AE_CONSENT_KEYS as r, getDefaultConsentChecks as s, createElectronicSignatureManager as t };
package/dist/email.d.ts CHANGED
@@ -1,264 +1,4 @@
1
- import { t as Manager } from "./Manager-BGfxEmyv.js";
2
-
3
- //#region src/modules/email/types.d.ts
4
-
5
- /**
6
- * Configuration options for email verification.
7
- *
8
- * @example Standard OTP verification
9
- * ```typescript
10
- * const config: EmailConfig = {
11
- * otpVerification: true,
12
- * otpExpirationInMinutes: 5,
13
- * prefill: false,
14
- * };
15
- * ```
16
- *
17
- * @example With all options
18
- * ```typescript
19
- * const config: EmailConfig = {
20
- * otpVerification: true,
21
- * otpExpirationInMinutes: 10,
22
- * prefill: true,
23
- * maxOtpAttempts: 3,
24
- * };
25
- * ```
26
- */
27
- type EmailConfig = {
28
- /**
29
- * Whether to require OTP (email code) verification.
30
- * If false, email is verified immediately after submission.
31
- */
32
- otpVerification: boolean;
33
- /**
34
- * How long the OTP code remains valid, in minutes.
35
- * After expiration, user must request a new code.
36
- */
37
- otpExpirationInMinutes: number;
38
- /**
39
- * Whether to pre-populate with user's previously stored email address.
40
- * Useful for returning users.
41
- */
42
- prefill: boolean;
43
- /**
44
- * Maximum number of OTP verification attempts before lockout.
45
- * After exhausting attempts, user sees an error state.
46
- * @default 3
47
- */
48
- maxOtpAttempts?: number;
49
- };
50
- //#endregion
51
- //#region src/modules/email/emailStateMachine.d.ts
52
-
53
- declare const emailMachine: any;
54
- //#endregion
55
- //#region src/modules/email/emailActor.d.ts
56
- type CreateEmailActorOptions = {
57
- config: EmailConfig;
58
- };
59
- //#endregion
60
- //#region src/modules/email/emailManager.d.ts
61
- /** Email manager is in initial state, waiting for `load()` to be called */
62
- type EmailIdleState = {
63
- status: 'idle';
64
- };
65
- /** Loading prefilled email address from backend (if prefill is enabled) */
66
- type EmailLoadingPrefillState = {
67
- status: 'loadingPrefill';
68
- };
69
- /**
70
- * Ready for email input - use `setEmail()` and `submit()`
71
- * @property prefilledEmail - Pre-populated email address (if prefill enabled)
72
- * @property emailError - Validation error message if email was rejected
73
- */
74
- type EmailInputtingState = {
75
- status: 'inputting';
76
- prefilledEmail?: string;
77
- emailError?: string;
78
- };
79
- /** Email address is being submitted to the backend */
80
- type EmailSubmittingState = {
81
- status: 'submitting';
82
- };
83
- /** OTP is being sent to the email address */
84
- type EmailSendingOtpState = {
85
- status: 'sendingOtp';
86
- };
87
- /**
88
- * Waiting for OTP code - use `submitOtp()`, `resendOtp()`, or `back()`
89
- * @property resendTimer - Seconds remaining before resend is allowed
90
- * @property canResend - Whether the resend button should be enabled
91
- * @property attemptsRemaining - Number of OTP verification attempts left
92
- */
93
- type EmailAwaitingOtpState = {
94
- status: 'awaitingOtp';
95
- resendTimer: number;
96
- canResend: boolean;
97
- attemptsRemaining: number;
98
- };
99
- /** OTP code is being verified against the backend */
100
- type EmailVerifyingOtpState = {
101
- status: 'verifyingOtp';
102
- };
103
- /**
104
- * OTP verification failed - user can retry with `submitOtp()`
105
- * @property error - Error message describing why verification failed
106
- * @property attemptsRemaining - Number of remaining attempts before lockout
107
- */
108
- type EmailOtpErrorState = {
109
- status: 'otpError';
110
- error: string;
111
- attemptsRemaining: number;
112
- };
113
- /** Email verification completed successfully - call `reset()` to start over */
114
- type EmailSuccessState = {
115
- status: 'success';
116
- };
117
- /**
118
- * Fatal error occurred - call `reset()` to start over
119
- * @property error - Error message describing what went wrong
120
- */
121
- type EmailErrorState = {
122
- status: 'error';
123
- error: string;
124
- };
125
- /**
126
- * Union of all possible email manager states.
127
- * Use discriminated union pattern to narrow the type:
128
- *
129
- * @example
130
- * ```typescript
131
- * const state = emailManager.getState();
132
- * if (state.status === 'inputting') {
133
- * // TypeScript knows state has prefilledEmail, emailError, etc.
134
- * console.log(state.prefilledEmail);
135
- * }
136
- * ```
137
- */
138
- type EmailState = EmailIdleState | EmailLoadingPrefillState | EmailInputtingState | EmailSubmittingState | EmailSendingOtpState | EmailAwaitingOtpState | EmailVerifyingOtpState | EmailOtpErrorState | EmailSuccessState | EmailErrorState;
139
- /**
140
- * Creates an email verification manager for headless or UI-driven usage.
141
- *
142
- * The manager provides a state machine-based API for email address verification
143
- * with optional OTP (one-time password) verification.
144
- *
145
- * @param options - Configuration options
146
- * @param options.config - Email verification configuration
147
- * @param options.config.otpVerification - Whether to require OTP verification
148
- * @param options.config.otpExpirationInMinutes - How long the OTP is valid
149
- * @param options.config.prefill - Whether to fetch a pre-filled email address
150
- * @param options.config.maxOtpAttempts - Maximum OTP verification attempts (default: 3)
151
- *
152
- * @returns Email manager with state, API methods, and subscription
153
- *
154
- * @example Headless usage
155
- * ```typescript
156
- * const manager = createEmailManager({
157
- * config: { otpVerification: true, otpExpirationInMinutes: 5, prefill: false },
158
- * });
159
- *
160
- * manager.subscribe((state) => console.log(state.status));
161
- * manager.load();
162
- * manager.setEmail('user@example.com', true);
163
- * manager.submit();
164
- * // ... wait for 'awaitingOtp' state ...
165
- * manager.submitOtp('ABC123');
166
- * manager.stop();
167
- * ```
168
- *
169
- * @example With React/Preact UI hook
170
- * ```tsx
171
- * const [state, manager] = useManager(() => createEmailManager({ config }));
172
- *
173
- * if (state.status === 'inputting') {
174
- * return <input onChange={(e) => manager.setEmail(e.target.value, true)} />;
175
- * }
176
- * ```
177
- */
178
- declare function createEmailManager(options: CreateEmailActorOptions): Manager<EmailState> & {
179
- /**
180
- * Initializes the email verification flow.
181
- * Transitions from 'idle' to 'loadingPrefill' or 'inputting'.
182
- * Must be called before any other method.
183
- */
184
- load(): void;
185
- /**
186
- * Sets the email address for verification.
187
- * Should be called when state is 'inputting'.
188
- *
189
- * @param email - Email address (e.g., 'user@example.com')
190
- * @param isValid - Whether the email address passes validation
191
- *
192
- * @example
193
- * ```typescript
194
- * // Using regex for validation
195
- * const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
196
- * const email = 'user@example.com';
197
- * emailManager.setEmail(email, emailRegex.test(email));
198
- * ```
199
- */
200
- setEmail(email: string, isValid: boolean): void;
201
- /**
202
- * Submits the email address for verification.
203
- * Requires a valid email address to be set via `setEmail()`.
204
- * Transitions to 'submitting', then to 'sendingOtp' or 'success' (if no OTP).
205
- */
206
- submit(): void;
207
- /**
208
- * Sets the OTP code without submitting.
209
- * Use this for controlled input components.
210
- *
211
- * @param code - The OTP code entered by the user
212
- */
213
- setOtpCode(code: string): void;
214
- /**
215
- * Sets and submits the OTP code in one call.
216
- * Should be called when state is 'awaitingOtp' or 'otpError'.
217
- *
218
- * @param code - The complete OTP code (typically 6 alphanumeric characters)
219
- *
220
- * @example
221
- * ```typescript
222
- * // Submit OTP when user completes entry
223
- * emailManager.submitOtp('HH36LP');
224
- * ```
225
- */
226
- submitOtp(code: string): void;
227
- /**
228
- * Requests a new OTP code to be sent.
229
- * Only works when state is 'awaitingOtp' and `canResend` is true.
230
- * Resets the resend timer.
231
- */
232
- resendOtp(): void;
233
- /**
234
- * Returns to the email input screen from OTP entry.
235
- * Allows the user to change their email address.
236
- * Transitions from 'awaitingOtp' or 'otpError' back to 'inputting'.
237
- */
238
- back(): void;
239
- /**
240
- * Resets the manager to initial state.
241
- * Can be called from 'success' or 'error' states to start over.
242
- * Clears all stored data including email address and OTP.
243
- */
244
- reset(): void;
245
- };
246
- /**
247
- * Type representing an email manager instance.
248
- * Includes state access, API methods, and lifecycle management.
249
- *
250
- * @property getState - Returns the current EmailState
251
- * @property subscribe - Subscribes to state changes, returns unsubscribe function
252
- * @property stop - Stops the manager and cleans up resources
253
- * @property load - Initializes the verification flow
254
- * @property setEmail - Sets the email address
255
- * @property submit - Submits the email address
256
- * @property setOtpCode - Sets OTP code without submitting
257
- * @property submitOtp - Sets and submits OTP code
258
- * @property resendOtp - Requests new OTP code
259
- * @property back - Returns to email input from OTP screen
260
- * @property reset - Resets to initial state
261
- */
262
- type EmailManager = ReturnType<typeof createEmailManager>;
263
- //#endregion
1
+ import "./Manager-C8PrhBOx.js";
2
+ import "./Actor-CI32dTbG.js";
3
+ import { a as emailMachine, n as EmailState, o as EmailConfig, r as createEmailManager, t as EmailManager } from "./emailManager-DIfnS5g1.js";
264
4
  export { type EmailConfig, type EmailManager, type EmailState, createEmailManager, emailMachine };