@incodetech/core 0.0.0-dev-20260729-9461bce1 → 0.0.0-dev-20260729-e2dda0b0

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 (145) hide show
  1. package/dist/BrowserDiagnosticsCryptoProvider-BZqV7sJR.esm.js +96 -0
  2. package/dist/IBrowserEnvironmentCapability-DEaRRk-R.esm.js +9 -0
  3. package/dist/{WasmUtilProvider-BrWOTaVG.esm.js → WasmUtilProvider-D13sxEmA.esm.js} +2 -406
  4. package/dist/{addressSearch-oyJf4OZO.esm.js → addressSearch-D_0t2Wdn.esm.js} +2 -2
  5. package/dist/ae-signature.esm.js +1 -1
  6. package/dist/antifraud.esm.js +2 -2
  7. package/dist/{antifraudManager-CQ0zC0jZ.esm.js → antifraudManager-COYh4O_y.esm.js} +2 -2
  8. package/dist/{antifraudStateMachine-MfVOsgZf.esm.js → antifraudStateMachine-NuzlVVte.esm.js} +2 -2
  9. package/dist/api-Bx3gKW_y.esm.js +129 -0
  10. package/dist/{apiError-B-PkYxln.esm.js → apiError-GA6MbJpI.esm.js} +12 -1
  11. package/dist/authentication.esm.js +2 -2
  12. package/dist/{authenticationManager-G4OrneRc.esm.js → authenticationManager-B7v0Jy-x.esm.js} +5 -5
  13. package/dist/{authenticationStateMachine-CRaoYKLp.esm.js → authenticationStateMachine-DAh9ziFC.esm.js} +5 -5
  14. package/dist/camera.esm.js +1 -1
  15. package/dist/certificate-issuance.esm.js +2 -2
  16. package/dist/{certificateIssuanceStateMachine-BrbhvQ3k.esm.js → certificateIssuanceStateMachine-N__sTAgu.esm.js} +2 -2
  17. package/dist/consent.d.ts +1 -1
  18. package/dist/consent.esm.js +2 -2
  19. package/dist/{consentManager-DLOyIZzt.d.ts → consentManager-BhYFeKiG.d.ts} +9 -9
  20. package/dist/{consentManager-fOURtjzF.esm.js → consentManager-CWEAhAJ5.esm.js} +2 -2
  21. package/dist/{consentStateMachine-BCVxc6mI.esm.js → consentStateMachine-DWL-X0Jb.esm.js} +2 -2
  22. package/dist/cross-document-data-match.esm.js +1 -1
  23. package/dist/{crossDocumentDataMatchManager-DaJvZ8m1.esm.js → crossDocumentDataMatchManager-Bk4W2TDJ.esm.js} +3 -3
  24. package/dist/curp-validation.esm.js +2 -2
  25. package/dist/{curpValidationManager-CKRo8Mch.esm.js → curpValidationManager-B6gYKygj.esm.js} +2 -2
  26. package/dist/{curpValidationStateMachine-DMdmcv5-.esm.js → curpValidationStateMachine-42RbYcam.esm.js} +2 -2
  27. package/dist/custom-fields.esm.js +3 -3
  28. package/dist/custom-watchlist.esm.js +2 -2
  29. package/dist/{customWatchlistStateMachine-DB2I9_OR.esm.js → customWatchlistStateMachine-BbDtH5kk.esm.js} +2 -2
  30. package/dist/{deepsightLoader-AdX0vjwb.esm.js → deepsightLoader-CHG26pOB.esm.js} +14 -4
  31. package/dist/document-capture.d.ts +1 -1
  32. package/dist/document-capture.esm.js +2 -2
  33. package/dist/document-upload.d.ts +4 -4
  34. package/dist/document-upload.esm.js +3 -3
  35. package/dist/{documentCaptureManager-pEqMY_Oo.d.ts → documentCaptureManager-BK_4RbHt.d.ts} +69 -69
  36. package/dist/{documentCaptureManager-iTx0jqU4.esm.js → documentCaptureManager-FvcNYpkS.esm.js} +2 -2
  37. package/dist/{documentCaptureStateMachine-CrdQsDn2.esm.js → documentCaptureStateMachine-BlzN0-mU.esm.js} +4 -4
  38. package/dist/dynamic-forms.esm.js +2 -2
  39. package/dist/{dynamicFormsManager-BNIbGJmh.esm.js → dynamicFormsManager-CfJixpOW.esm.js} +2 -2
  40. package/dist/{dynamicFormsStateMachine-DKUOlqmi.esm.js → dynamicFormsStateMachine-DrPO1i45.esm.js} +3 -3
  41. package/dist/ekyb.esm.js +3 -3
  42. package/dist/{ekybManager-BUWJUews.esm.js → ekybManager-DVCqaSzz.esm.js} +2 -2
  43. package/dist/{ekybStateMachine-CYLZDKC7.esm.js → ekybStateMachine-C3y-Qx1a.esm.js} +4 -4
  44. package/dist/ekyc.esm.js +2 -2
  45. package/dist/{ekycManager-C6Wc4wRj.esm.js → ekycManager-dimNksoE.esm.js} +2 -2
  46. package/dist/{ekycStateMachine-fHXM6pc0.esm.js → ekycStateMachine-Yl3sQmhm.esm.js} +3 -3
  47. package/dist/electronic-signature.esm.js +1 -1
  48. package/dist/{electronicSignatureManager-hJ9YaAvD.esm.js → electronicSignatureManager-D0X7P-de.esm.js} +4 -4
  49. package/dist/email.esm.js +2 -2
  50. package/dist/{emailManager-B_Q6MfUq.esm.js → emailManager-BqJMritP.esm.js} +2 -2
  51. package/dist/{emailStateMachine-DHfDd8LI.esm.js → emailStateMachine-CLtrh2Ot.esm.js} +2 -2
  52. package/dist/{endpoints-BwKx4Gne.esm.js → endpoints-DOfmJylF.esm.js} +7 -1
  53. package/dist/{events-Dy8PyVO5.esm.js → events-CMFCCu1H.esm.js} +2 -9
  54. package/dist/events.esm.js +1 -1
  55. package/dist/extensibility.d.ts +5 -5
  56. package/dist/extensibility.esm.js +26 -32
  57. package/dist/face-match.esm.js +2 -2
  58. package/dist/{faceCaptureManagerFactory-Bkc1HLRL.esm.js → faceCaptureManagerFactory-D2pR3ZnX.esm.js} +3 -3
  59. package/dist/{faceCaptureSetup-BQEQriDi.esm.js → faceCaptureSetup-DbhDPMjb.esm.js} +5 -5
  60. package/dist/{faceMatchManager-Bh5wFMyh.esm.js → faceMatchManager-XxTEAj9C.esm.js} +2 -2
  61. package/dist/{faceMatchStateMachine-QIf8gak4.esm.js → faceMatchStateMachine-ubds4WlI.esm.js} +2 -2
  62. package/dist/field-comparison.esm.js +1 -1
  63. package/dist/{fieldComparisonManager-B_3cIH9t.esm.js → fieldComparisonManager-BzaX4TvX.esm.js} +3 -3
  64. package/dist/fiscal-qr.esm.js +3 -3
  65. package/dist/flow.esm.js +4 -4
  66. package/dist/{flowCompletionService-6yWz7xwZ.esm.js → flowCompletionService-BdZR6HyE.esm.js} +3 -3
  67. package/dist/{flowServices-Cf63iD-o.esm.js → flowServices-CPti9am-.esm.js} +5 -5
  68. package/dist/geolocation.esm.js +2 -2
  69. package/dist/{geolocationManager-gKopAolS.esm.js → geolocationManager-DW27-LTL.esm.js} +2 -2
  70. package/dist/{geolocationStateMachine-Cac3eKge.esm.js → geolocationStateMachine-Cz3Q6az0.esm.js} +3 -3
  71. package/dist/government-validation.esm.js +2 -2
  72. package/dist/{governmentValidationStateMachine-Be1ruaNj.esm.js → governmentValidationStateMachine-CtG3bIdM.esm.js} +2 -2
  73. package/dist/home.esm.js +1 -1
  74. package/dist/http.esm.js +1 -1
  75. package/dist/id-ocr.d.ts +1 -1
  76. package/dist/id-ocr.esm.js +2 -2
  77. package/dist/id-verification.esm.js +2 -2
  78. package/dist/id.esm.js +5 -5
  79. package/dist/{idCaptureDefaults-DCrjeNl5.esm.js → idCaptureDefaults-BDS43fFL.esm.js} +2 -2
  80. package/dist/{idCaptureManager-Dg8pxseH.esm.js → idCaptureManager-CPzgzVu8.esm.js} +4 -4
  81. package/dist/{idCaptureStateMachine-B2e_wX0x.esm.js → idCaptureStateMachine-CAKztWBq.esm.js} +28 -17
  82. package/dist/{idOcrManager-dLuxey6y.d.ts → idOcrManager-DXc_xRN7.d.ts} +1 -1
  83. package/dist/{idOcrManager-8WPK22Kq.esm.js → idOcrManager-Drs6frVO.esm.js} +2 -2
  84. package/dist/{idOcrStateMachine-Cfq5gJ0f.esm.js → idOcrStateMachine-s08FLvEh.esm.js} +3 -3
  85. package/dist/{idVerificationManager-DBVs8TRS.esm.js → idVerificationManager-Df97Bf0n.esm.js} +2 -2
  86. package/dist/{idVerificationStateMachine-xtTSJDrB.esm.js → idVerificationStateMachine-tAF7pvC8.esm.js} +2 -2
  87. package/dist/identity-reuse.d.ts +1 -1
  88. package/dist/identity-reuse.esm.js +2 -2
  89. package/dist/{identityReuseManager-B8jNZNHu.esm.js → identityReuseManager-0ZHGWr9T.esm.js} +2 -2
  90. package/dist/{identityReuseManager-D6pD4hcZ.d.ts → identityReuseManager-v2TH5g7e.d.ts} +1 -1
  91. package/dist/{identityReuseStateMachine-DdwSrghH.esm.js → identityReuseStateMachine-DG8kbKuy.esm.js} +2 -2
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.esm.js +1 -1
  94. package/dist/{invokeOnCaptureCallback-B-QfsCQY.esm.js → invokeOnCaptureCallback-Cgl54qED.esm.js} +1 -1
  95. package/dist/mandatory-consent.d.ts +1 -1
  96. package/dist/mandatory-consent.esm.js +2 -2
  97. package/dist/{mandatoryConsentManager-Dcgmj1Cd.d.ts → mandatoryConsentManager-CzsVFG33.d.ts} +5 -5
  98. package/dist/{mandatoryConsentManager-BAKnA7U_.esm.js → mandatoryConsentManager-DaKK7S4q.esm.js} +2 -2
  99. package/dist/{mandatoryConsentStateMachine-3a1psaoK.esm.js → mandatoryConsentStateMachine-CjKpOQXU.esm.js} +2 -2
  100. package/dist/{onDeviceFaceResults-DbSP6iTw.esm.js → onDeviceFaceResults-CVhk1BWp.esm.js} +13 -6
  101. package/dist/{permissionGuards-5Cu6a8iN.esm.js → permissionGuards-UMiLlPfq.esm.js} +1 -1
  102. package/dist/{permissionServices-CkHL1BjH.esm.js → permissionServices-C4qKxOl4.esm.js} +1 -1
  103. package/dist/personhood.esm.js +9 -22
  104. package/dist/phone.esm.js +2 -2
  105. package/dist/{phoneManager-dizEvG20.esm.js → phoneManager-WImoAp4i.esm.js} +2 -2
  106. package/dist/{phoneStateMachine-DxmYoLg8.esm.js → phoneStateMachine-FJ-_x1G4.esm.js} +2 -2
  107. package/dist/qe-signature.esm.js +1 -1
  108. package/dist/{recordingService-C8jFtEKZ.esm.js → recordingService-BGPq5vGr.esm.js} +3 -3
  109. package/dist/redirect-to-mobile.esm.js +2 -2
  110. package/dist/{redirectToMobileManager-BCInKNqp.esm.js → redirectToMobileManager-CxEu6KnV.esm.js} +2 -2
  111. package/dist/{redirectToMobileStateMachine-TSHtrr5D.esm.js → redirectToMobileStateMachine-jI5XPtZJ.esm.js} +2 -2
  112. package/dist/{runChildModule-Crz1nHwJ.esm.js → runChildModule-fagPe5Ct.esm.js} +6 -1
  113. package/dist/selfie.esm.js +9 -9
  114. package/dist/{selfieErrorUtils-1aFaxF3Q.esm.js → selfieErrorUtils-DCRRRj38.esm.js} +3 -3
  115. package/dist/{selfieManager-KbDEkivf.esm.js → selfieManager-DTiBsQNn.esm.js} +5 -5
  116. package/dist/{selfieStateMachine-BiuQiED3.esm.js → selfieStateMachine-CxabK5_3.esm.js} +3 -3
  117. package/dist/session-Ccob4IUP.esm.js +161 -0
  118. package/dist/session.d.ts +8 -1
  119. package/dist/session.esm.js +4 -152
  120. package/dist/{sessionInitializer-DyJ4nLFJ.esm.js → sessionInitializer-DEd0CQ74.esm.js} +27 -32
  121. package/dist/{setup-MlGXfrG8.esm.js → setup-BR4G3NHV.esm.js} +78 -11
  122. package/dist/{setup-B1WTXTQV.d.ts → setup-Dj8n_YLP.d.ts} +22 -0
  123. package/dist/signature.esm.js +2 -2
  124. package/dist/{signatureStateMachine-CCcFhvuv.esm.js → signatureStateMachine-Dx92l8pR.esm.js} +2 -2
  125. package/dist/{stats-CKtpeAhi.esm.js → stats-6sK3f5pc.esm.js} +2 -2
  126. package/dist/stats.esm.js +1 -1
  127. package/dist/trueSight-4L5GCqKy.esm.js +1 -0
  128. package/dist/trueSightService-DKC-gmQC.esm.js +1891 -0
  129. package/dist/trust-graph.esm.js +1 -1
  130. package/dist/video-selfie.esm.js +9 -9
  131. package/dist/wasm.d.ts +1 -1
  132. package/dist/wasm.esm.js +3 -3
  133. package/dist/{wasmDefaults-B4DUtYET.esm.js → wasmDefaults-DJiEvV7f.esm.js} +1 -1
  134. package/dist/wasmWebClient-DM8lkb0z.esm.js +407 -0
  135. package/dist/watchlist-for-business.esm.js +2 -2
  136. package/dist/watchlist.esm.js +2 -2
  137. package/dist/{watchlistForBusinessStateMachine-DZZNfYsA.esm.js → watchlistForBusinessStateMachine-Eo-WEYha.esm.js} +2 -2
  138. package/dist/{watchlistManager-CMFZ0aqP.esm.js → watchlistManager-DnVfNc1v.esm.js} +2 -2
  139. package/dist/{watchlistStateMachine-CmhlwIhk.esm.js → watchlistStateMachine-DZSOauwp.esm.js} +2 -2
  140. package/dist/workflow.d.ts +12 -4
  141. package/dist/workflow.esm.js +55 -40
  142. package/package.json +3 -3
  143. package/dist/api-BDTZNnca.esm.js +0 -71
  144. package/dist/clientLifecycle-BX83zwtT.esm.js +0 -528
  145. package/dist/session-CrAUqlgX.esm.js +0 -1
@@ -0,0 +1,96 @@
1
+ //#region ../infra/src/crypto/truesightKey.ts
2
+ /** Interim P1 key id — the BE looks up the AES key by this label. */
3
+ const TRUESIGHT_KID = "truesight-v1";
4
+ const KEY_LENGTH_BYTES = 32;
5
+ /** Recovers the key from its two obfuscated halves. Throws on malformed input. */
6
+ function decodeTruesightKey(s0Base64, s1Base64) {
7
+ const s0 = fromBase64(s0Base64);
8
+ const s1 = fromBase64(s1Base64);
9
+ if (s0.length !== s1.length || s0.length === 0) throw new Error("truesight key halves are malformed");
10
+ const key = new Uint8Array(s0.length);
11
+ for (let i = 0; i < key.length; i += 1) key[i] = s1[(i + 7) % s1.length] ^ s0[i];
12
+ return key;
13
+ }
14
+ /**
15
+ * The bundle's key, decoded lazily — `null` when this build carries no key
16
+ * (defines absent → collect-only mode, uploads disabled). Returns a fresh
17
+ * copy per call so callers may zero their copy after use.
18
+ */
19
+ function getTruesightKey() {
20
+ if (typeof __TRUESIGHT_S0__ === "undefined" || typeof __TRUESIGHT_S1__ === "undefined") return null;
21
+ try {
22
+ const key = decodeTruesightKey(__TRUESIGHT_S0__, __TRUESIGHT_S1__);
23
+ return key.length === KEY_LENGTH_BYTES ? key : null;
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+ function fromBase64(value) {
29
+ return Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
30
+ }
31
+ //#endregion
32
+ //#region ../infra/src/providers/browser/BrowserDiagnosticsCryptoProvider.ts
33
+ /**
34
+ * Browser sealer for TrueSight diagnostics (ENG-48677 plan §1.5): JSON string →
35
+ * gzip via native CompressionStream → AES-256-GCM via WebCrypto → contract
36
+ * envelope. Designed to be loaded as a LAZY chunk — zero bytes on the host
37
+ * page's critical path.
38
+ *
39
+ * The CryptoKey is imported once (non-extractable) and the raw bytes are zeroed
40
+ * immediately after import; `getKeyBytes` must therefore return a fresh copy.
41
+ */
42
+ var BrowserDiagnosticsCryptoProvider = class {
43
+ constructor(getKeyBytes = getTruesightKey, kid = TRUESIGHT_KID) {
44
+ this.getKeyBytes = getKeyBytes;
45
+ this.kid = kid;
46
+ this.keyPromise = null;
47
+ }
48
+ isSupported() {
49
+ return typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined" && typeof crypto.getRandomValues === "function" && typeof CompressionStream !== "undefined";
50
+ }
51
+ async seal(plaintext) {
52
+ const [gz, key] = await Promise.all([gzipUtf8(plaintext), this.importKeyOnce()]);
53
+ const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
54
+ const additionalData = new TextEncoder().encode(`v1|A256GCM|gzip|${this.kid}`);
55
+ const sealed = new Uint8Array(await crypto.subtle.encrypt({
56
+ name: "AES-GCM",
57
+ iv,
58
+ additionalData
59
+ }, key, gz));
60
+ const tagStart = sealed.length - 16;
61
+ return {
62
+ version: 1,
63
+ alg: "A256GCM",
64
+ compression: "gzip",
65
+ kid: this.kid,
66
+ iv: toBase64Url(iv),
67
+ ciphertext: toBase64Url(sealed.subarray(0, tagStart)),
68
+ tag: toBase64Url(sealed.subarray(tagStart))
69
+ };
70
+ }
71
+ importKeyOnce() {
72
+ this.keyPromise ??= (async () => {
73
+ const bytes = this.getKeyBytes();
74
+ if (!bytes || bytes.length !== 32) throw new Error("TrueSight diagnostics key unavailable in this build");
75
+ const copy = new Uint8Array(bytes);
76
+ try {
77
+ return await crypto.subtle.importKey("raw", copy, { name: "AES-GCM" }, false, ["encrypt"]);
78
+ } finally {
79
+ copy.fill(0);
80
+ bytes.fill(0);
81
+ }
82
+ })();
83
+ return this.keyPromise;
84
+ }
85
+ };
86
+ async function gzipUtf8(text) {
87
+ const stream = new Blob([text]).stream().pipeThrough(new CompressionStream("gzip"));
88
+ return new Uint8Array(await new Response(stream).arrayBuffer());
89
+ }
90
+ function toBase64Url(bytes) {
91
+ let binary = "";
92
+ for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
93
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/u, "");
94
+ }
95
+ //#endregion
96
+ export { BrowserDiagnosticsCryptoProvider };
@@ -0,0 +1,9 @@
1
+ //#region ../infra/src/capabilities/IBrowserEnvironmentCapability.ts
2
+ function getTimestamp() {
3
+ return Date.now();
4
+ }
5
+ function revokeObjectURL(url) {
6
+ URL.revokeObjectURL(url);
7
+ }
8
+ //#endregion
9
+ export { revokeObjectURL as n, getTimestamp as t };
@@ -1,408 +1,4 @@
1
- //#region ../infra/src/wasm/wasmPathUtils.ts
2
- function deriveSiblingJsPath(wasmPath) {
3
- const index = wasmPath.lastIndexOf(".wasm");
4
- if (index === -1) return wasmPath;
5
- const rest = wasmPath.slice(index + 5);
6
- if (rest !== "" && !rest.startsWith("?")) return wasmPath;
7
- return `${wasmPath.slice(0, index)}.js${rest}`;
8
- }
9
- //#endregion
10
- //#region ../infra/src/providers/browser/SemaphoreProvider.ts
11
- const DEFAULT_ACQUIRE_TIMEOUT_MS = 3e4;
12
- /**
13
- * Counting-semaphore implementation of {@link IConcurrencyCapability}.
14
- *
15
- * Default `maxConcurrent=1` makes it behave as a mutex; set higher for
16
- * parallel-bounded access. Each acquire returns a numeric `threadId` for
17
- * tracing — the slot index, in `[0, maxConcurrent)` — that must be passed back
18
- * to `release`.
19
- *
20
- * If all slots stay occupied longer than `acquireTimeoutMs` (default 30s), the
21
- * pending wait still resolves when a slot frees, but `console.error` is logged
22
- * as a deadlock-watchdog signal. Misuse — out-of-range or double-released
23
- * `threadId`s — is also logged and treated as a no-op rather than thrown.
24
- */
25
- var SemaphoreProvider = class {
26
- constructor(maxConcurrent = 1, acquireTimeoutMs = DEFAULT_ACQUIRE_TIMEOUT_MS) {
27
- this.pending = [];
28
- this.available = [];
29
- this.processing = /* @__PURE__ */ new Set();
30
- this.maxId = maxConcurrent - 1;
31
- this.acquireTimeoutMs = acquireTimeoutMs;
32
- for (let i = 0; i < maxConcurrent; i++) this.available.push(i);
33
- }
34
- /**
35
- * Acquire a slot. Resolves immediately with the slot's `threadId` if one is
36
- * free, otherwise queues FIFO and resolves when a holder releases.
37
- */
38
- async acquire() {
39
- if (this.available.length > 0) {
40
- const threadId = this.available.shift();
41
- this.processing.add(threadId);
42
- return threadId;
43
- }
44
- return new Promise((resolve, reject) => {
45
- const entry = {
46
- resolve: (threadId) => {
47
- clearTimeout(entry.timer);
48
- this.processing.add(threadId);
49
- resolve(threadId);
50
- },
51
- reject: (error) => {
52
- clearTimeout(entry.timer);
53
- reject(error);
54
- },
55
- timer: setTimeout(() => {
56
- console.error(`SemaphoreProvider: all slots occupied for ${this.acquireTimeoutMs}ms, ${this.pending.length} request(s) waiting`);
57
- }, this.acquireTimeoutMs)
58
- };
59
- this.pending.push(entry);
60
- });
61
- }
62
- /**
63
- * Return a slot to the pool. The next pending waiter (if any) is resolved
64
- * with this `threadId`; otherwise the slot is added back to `available`.
65
- * Releasing an out-of-range or already-released `threadId` logs an error and
66
- * is otherwise a no-op.
67
- */
68
- release(threadId) {
69
- if (threadId < 0 || threadId > this.maxId) {
70
- console.error(`SemaphoreProvider: invalid threadId ${threadId}`);
71
- return;
72
- }
73
- if (!this.processing.has(threadId)) {
74
- console.error(`SemaphoreProvider: double-release of threadId ${threadId}`);
75
- return;
76
- }
77
- this.processing.delete(threadId);
78
- if (this.pending.length > 0) this.pending.shift().resolve(threadId);
79
- else this.available.unshift(threadId);
80
- }
81
- /**
82
- * Cancel all pending acquires with a reset error and replenish all slots.
83
- * Existing holders are not contacted — a `release` after reset will log a
84
- * double-release warning rather than disrupt the new pool.
85
- */
86
- reset() {
87
- const waiters = this.pending;
88
- this.pending = [];
89
- this.available = [];
90
- this.processing = /* @__PURE__ */ new Set();
91
- for (let i = 0; i <= this.maxId; i++) this.available.push(i);
92
- for (const waiter of waiters) waiter.reject(/* @__PURE__ */ new Error("SemaphoreProvider reset: pending acquire cancelled"));
93
- }
94
- /**
95
- * Acquire a slot, invoke `fn(threadId, ...args)`, then release the slot in a
96
- * `finally` block. Errors thrown by `fn` propagate to the caller after the
97
- * slot is released.
98
- */
99
- async withLock(fn, ...args) {
100
- const threadId = await this.acquire();
101
- try {
102
- return await fn(threadId, ...args);
103
- } finally {
104
- this.release(threadId);
105
- }
106
- }
107
- };
108
- //#endregion
109
- //#region ../infra/src/wasm/apiUtilities.ts
110
- /**
111
- * Shared WASM module loader.
112
- *
113
- * The pinned `webLib.wasm` (see `wasmDefaults.ts`) bundles BOTH the ML pipeline
114
- * APIs (used by `mlWasmJSApi.ts`) AND a C++ `WebClient` HTTP client (used by
115
- * `wasmWebClient.ts`). Both consumers must share a single instantiated
116
- * `wasmModule` — calling the glue `Module()` factory twice would re-instantiate
117
- * the WASM heap and produce divergent state.
118
- *
119
- * This module memoizes the load: the first caller (whichever arrives first —
120
- * ML init or HTTP init) triggers the fetch + glue load, and subsequent callers
121
- * await the same promise. Idempotent on success; on failure, the singleton is
122
- * cleared so the next caller retries.
123
- *
124
- * SIMD fallback mirrors the legacy behavior: try the SIMD binary + SIMD glue
125
- * (`webLibSimd.js` + `webLibSimd.wasm`) first, fall back to the non-SIMD pair
126
- * (`webLib.js` + `webLib.wasm`) on instantiation failure. Each binary MUST be
127
- * paired with its matching glue — the CDN ships them as paired artifacts and
128
- * mixing them produces an unusable module.
129
- */
130
- if (typeof window !== "undefined" && window.wasmArrayBuffer === void 0) window.wasmArrayBuffer = null;
131
- let loadPromise = null;
132
- let loadedResult = null;
133
- async function importGlue(glueCodePath) {
134
- const mod = await import(
135
- /* @vite-ignore */
136
- /* webpackIgnore: true */
137
- glueCodePath
138
- );
139
- if (typeof mod.Module !== "function") throw new Error(`WASM glue at ${glueCodePath} did not export a Module factory`);
140
- return mod.Module;
141
- }
142
- async function fetchWasmBinary(libPath) {
143
- const response = await fetch(libPath);
144
- if (!response.ok) throw new Error(`Failed to fetch WASM binary at ${libPath}: ${response.status} ${response.statusText}`);
145
- const buffer = await response.arrayBuffer();
146
- return new Uint8Array(buffer);
147
- }
148
- async function instantiate(factory, libPath) {
149
- window.wasmArrayBuffer = await fetchWasmBinary(libPath);
150
- return await factory();
151
- }
152
- /**
153
- * Load the WASM module, memoized. Subsequent calls return the same instance.
154
- *
155
- * SIMD-first with fallback: if `useSimd !== false` and a `wasmSimdPath` is
156
- * provided, the SIMD binary + SIMD glue are tried first; on instantiation
157
- * failure the non-SIMD binary + non-SIMD glue are used. Each `.wasm` is
158
- * paired with its matching `.js` glue — they cannot be mixed.
159
- */
160
- async function loadWasmModule(config) {
161
- if (loadedResult) return loadedResult;
162
- if (loadPromise) return loadPromise;
163
- loadPromise = (async () => {
164
- try {
165
- const wantSimd = config.useSimd !== false;
166
- const simdBinary = config.wasmSimdPath ?? config.wasmPath;
167
- if (wantSimd && simdBinary !== config.wasmPath) try {
168
- const simdFactory = await importGlue(config.glueCodeSimdPath ?? deriveSiblingJsPath(simdBinary));
169
- window.Module = simdFactory;
170
- const result = {
171
- wasmModule: await instantiate(simdFactory, simdBinary),
172
- simdUsed: true
173
- };
174
- loadedResult = result;
175
- return result;
176
- } catch (simdError) {
177
- console.warn("[Incode SDK] SIMD WASM load failed, falling back to non-SIMD", simdError);
178
- }
179
- const nonSimdFactory = await importGlue(config.glueCodePath);
180
- window.Module = nonSimdFactory;
181
- const result = {
182
- wasmModule: await instantiate(nonSimdFactory, config.wasmPath),
183
- simdUsed: false
184
- };
185
- loadedResult = result;
186
- return result;
187
- } catch (error) {
188
- loadPromise = null;
189
- throw error;
190
- }
191
- })();
192
- return loadPromise;
193
- }
194
- //#endregion
195
- //#region ../infra/src/wasm/wasmCallUtils.ts
196
- async function wasmCallWrapper(concurrency, wasmMethod, useSemaphore = true, ...args) {
197
- const innerCall = async () => {
198
- while (true) {
199
- if (wasmMethod(...args)) return;
200
- await new Promise((resolve) => setTimeout(resolve, 0));
201
- }
202
- };
203
- if (useSemaphore) {
204
- await concurrency.withLock(innerCall);
205
- return;
206
- }
207
- await innerCall();
208
- }
209
- //#endregion
210
- //#region ../infra/src/wasm/wasmWebClient.ts
211
- /**
212
- * JavaScript bridge for the C++ `WebClient` exposed by `webLib.wasm`.
213
- *
214
- * The pinned WASM bundle ships a `WebClient` class alongside the ML pipeline
215
- * APIs. This module instantiates it once (sharing the singleton `wasmModule`
216
- * with `mlWasmJSApi`) and exposes a small TypeScript-friendly surface that
217
- * `createWasmApi` can drive.
218
- *
219
- * Concurrency model mirrors the legacy implementation:
220
- * - 4-slot semaphore keyed by per-request `threadId` so multiple HTTP calls
221
- * can run in parallel without trampling shared C++ state.
222
- * - Each WASM-side method that performs in-binary HTTP (request methods AND
223
- * `createApi`'s in-binary `/e2ee/key` handshake) returns `false` while in
224
- * flight and `true` once the C++ side has finished; the JS bridge awaits
225
- * completion via {@link wasmCallWrapper}.
226
- * - Result extraction (`getRequestResult`) is per-thread for HTTP requests
227
- * and uses `threadId = -1` for the session-level `createApi` handshake.
228
- *
229
- * Encryption support: `setupConnection` accepts an `encryptionEnabled` flag
230
- * that triggers the in-binary RSA/AES handshake. The OAEP MGF1 hash is
231
- * controlled by the `useSha256` flag forwarded to the C++ `createApi`:
232
- * `true` = SHA-256 MGF1, `false` = SHA-1 MGF1 (Java-compat default).
233
- * State lives in the C++ binary and (for SDK config) in
234
- * `@incodetech/core`'s `setup.ts` — this module caches nothing.
235
- */
236
- const HTTP_CONCURRENCY = 4;
237
- /**
238
- * Sentinel `threadId` used by the session-level `createApi` handshake when we
239
- * read its result via `getRequestResult`. Per-request HTTP traffic uses real
240
- * thread ids handed out by the semaphore; the handshake has no slot of its
241
- * own, so the C++ side stores its result under `-1`. Mirrors legacy
242
- * `checkError(threadId = -1)`.
243
- */
244
- const SETUP_THREAD_ID = -1;
245
- var WasmWebClientError = class extends Error {
246
- constructor(message, statusCode, data) {
247
- super(message);
248
- this.name = "WasmWebClientError";
249
- this.status = statusCode;
250
- this.statusCode = statusCode;
251
- if (statusCode > 0 || data !== void 0) this.response = {
252
- status: statusCode,
253
- data
254
- };
255
- }
256
- };
257
- let webClientApi = null;
258
- let initPromise = null;
259
- let semaphore = new SemaphoreProvider(HTTP_CONCURRENCY);
260
- const isWebClientWasm = (mod) => {
261
- return typeof mod.WebClient === "function";
262
- };
263
- const toStringRecord = (obj) => {
264
- if (!obj) return void 0;
265
- const result = {};
266
- for (const key of Object.keys(obj)) {
267
- const value = obj[key];
268
- if (value === void 0 || value === null) continue;
269
- result[key] = String(value);
270
- }
271
- return result;
272
- };
273
- /**
274
- * Loads the shared WASM module (if not already loaded) and instantiates the
275
- * C++ `WebClient`. Idempotent — repeated calls reuse the existing instance.
276
- *
277
- * `glueCodeSimdPath` is paired with `wasmSimdPath` (`webLibSimd.js` for
278
- * `webLibSimd.wasm`). Pass `''` to derive it automatically from
279
- * `wasmSimdPath` by replacing the `.wasm` extension with `.js`.
280
- */
281
- async function initializeWasmWebClient(wasmPath, wasmSimdPath, glueCodePath, glueCodeSimdPath, useSimd) {
282
- if (webClientApi) return;
283
- if (initPromise) return initPromise;
284
- initPromise = (async () => {
285
- try {
286
- const { wasmModule } = await loadWasmModule({
287
- wasmPath,
288
- wasmSimdPath,
289
- glueCodePath,
290
- glueCodeSimdPath: glueCodeSimdPath || void 0,
291
- useSimd
292
- });
293
- if (!isWebClientWasm(wasmModule)) throw new Error("WASM module does not expose a WebClient class. Update webLib.wasm to a build that includes WebClient.");
294
- webClientApi = new wasmModule.WebClient();
295
- } catch (error) {
296
- initPromise = null;
297
- throw error;
298
- }
299
- })();
300
- return initPromise;
301
- }
302
- /**
303
- * Configures the C++ WebClient connection. Safe to call multiple times — each
304
- * call resets the underlying session and re-applies default headers.
305
- *
306
- * `defaultHeaders` are applied **before** `createApi`, so the in-binary RSA
307
- * handshake (`GET /e2ee/key/v2` + `POST /e2ee/key`) sees the same headers as
308
- * data requests. Without this ordering, environments that require auth/version
309
- * headers on the handshake (e.g. `x-api-key`, `api-version`) would 401/4xx
310
- * before any encrypted traffic ever flowed.
311
- *
312
- * The C++ `createApi` returns `false` while the in-binary handshake is still
313
- * in flight and `true` once both the `/e2ee/key/v2` GET and the `/e2ee/key`
314
- * POST have completed (encryption on) or once the WebClient is configured
315
- * (encryption off — same boolean convention, just no network traffic). The
316
- * JS bridge waits on that boolean via {@link wasmCallWrapper}, then surfaces
317
- * any handshake error captured on the session-level (`threadId = -1`)
318
- * request slot. Mirrors legacy
319
- * `ms-incodesmile-web/packages/incode-welcome/src/wasmUtils/webClientApi.ts`
320
- * `setupConnection`.
321
- *
322
- * `useSha256` selects the OAEP MGF1 hash for the in-binary RSA wrap:
323
- * - `true` → MGF1 = SHA-256. Caller is responsible for attaching the
324
- * `X-RSA-Encryption-Scheme: RSA/NONE/OAEPWITHSHA-256ANDMGF1PADDING`
325
- * header on subsequent encrypted requests so the server matches.
326
- * - `false` → MGF1 = SHA-1 (Java-compat default). No scheme header needed;
327
- * the server falls back to the legacy Java default.
328
- */
329
- async function setupWasmConnection(apiURL, token, encryptionEnabled, defaultHeaders, useSha256) {
330
- const api = ensureReady();
331
- api.resetSessionState?.();
332
- api.setDefaultHeaders?.(defaultHeaders);
333
- await wasmCallWrapper(semaphore, () => api.createApi(apiURL, token, useSha256, encryptionEnabled), false);
334
- const result = api.getRequestResult(SETUP_THREAD_ID);
335
- if (result.hasError) throw new WasmWebClientError(result.errorMessage || "WebClient handshake failed", result.statusCode, result.result);
336
- }
337
- /**
338
- * Executes a single HTTP request through the WASM WebClient.
339
- *
340
- * Acquires a semaphore slot for `threadId`, registers progress callbacks, runs
341
- * the request via {@link wasmCallWrapper} (busy-polls until the WASM method
342
- * returns `true`), then extracts the per-thread result. Throws
343
- * {@link WasmWebClientError} on non-2xx or transport errors.
344
- *
345
- * The `ie` (inline-encryption) flag is forwarded to the C++ WebClient for
346
- * mutating methods. Default `false` — the SDK HTTP path leaves payloads
347
- * unencrypted at the WebClient layer. The C++ `WebApi.postFaceResults`
348
- * pre-encrypts its JSON via `SessionEncryptor` and calls back into this
349
- * function with `ie=true`; see {@link createWebApiHostAdapter}.
350
- */
351
- async function executeWasmRequest(method, url, body, headers, params, timeout, onUploadProgress, ie = false) {
352
- const api = ensureReady();
353
- const stringParams = toStringRecord(params);
354
- return semaphore.withLock(async (threadId) => {
355
- if (onUploadProgress && api.setOnUploadProgress) api.setOnUploadProgress((event) => {
356
- try {
357
- onUploadProgress(event);
358
- } catch (error) {
359
- console.error("WasmWebClient: error in onUploadProgress callback", error);
360
- }
361
- });
362
- try {
363
- await wasmCallWrapper(semaphore, () => callWasmMethod(api, method, threadId, url, body, headers, stringParams, timeout, ie), false);
364
- return readResult(api, threadId);
365
- } finally {
366
- api.clearOnUploadProgress?.(threadId);
367
- api.clearOnDownloadProgress?.(threadId);
368
- }
369
- });
370
- }
371
- function callWasmMethod(api, method, threadId, url, body, headers, params, timeout, ie) {
372
- switch (method) {
373
- case "GET": return api.get(threadId, url, params, headers, timeout);
374
- case "POST": return api.post(threadId, url, body ?? {}, headers, params, timeout, ie);
375
- case "PUT": return api.put(threadId, url, body ?? {}, headers, params, timeout, ie);
376
- case "PATCH": return api.patch(threadId, url, body ?? {}, headers, params, timeout, ie);
377
- case "DELETE": return api.del(threadId, url, body ?? {}, headers, params, timeout, ie);
378
- default: throw new Error(`Unsupported WASM HTTP method: ${method}`);
379
- }
380
- }
381
- const DEFAULT_WEBAPI_TIMEOUT_MS = 3e4;
382
- let webApiHttpTransport = null;
383
- function setWebApiHttpTransport(transport) {
384
- webApiHttpTransport = transport;
385
- }
386
- function createWebApiHostAdapter() {
387
- return { post(url, body, config) {
388
- const effectiveConfig = config ?? {};
389
- const transport = webApiHttpTransport;
390
- if (transport) return transport(url, body, effectiveConfig);
391
- return executeWasmRequest("POST", url, body, effectiveConfig.headers ?? {}, effectiveConfig.params, effectiveConfig.timeout ?? DEFAULT_WEBAPI_TIMEOUT_MS, void 0, effectiveConfig.ie === true);
392
- } };
393
- }
394
- function readResult(api, threadId) {
395
- const response = api.getRequestResult(threadId);
396
- if (response.hasError) throw new WasmWebClientError(response.errorMessage || "WasmWebClient request failed", response.statusCode, response.result);
397
- return {
398
- data: response.result,
399
- status: response.statusCode
400
- };
401
- }
402
- function ensureReady() {
403
- if (!webClientApi) throw new Error("WasmWebClient not initialized. Call initializeWasmWebClient() first.");
404
- return webClientApi;
405
- }
1
+ import { c as loadWasmModule, l as SemaphoreProvider, n as createWebApiHostAdapter, s as wasmCallWrapper } from "./wasmWebClient-DM8lkb0z.esm.js";
406
2
  var mlWasmJSApi_default = class MlWasmJSApi {
407
3
  constructor() {
408
4
  this.versionsFile = null;
@@ -1345,4 +941,4 @@ var WasmUtilProvider = class WasmUtilProvider extends BaseWasmProvider {
1345
941
  }
1346
942
  };
1347
943
  //#endregion
1348
- export { warmupWasm as a, executeWasmRequest as c, setupWasmConnection as d, deriveSiblingJsPath as f, setWasmOnDeviceMode as i, initializeWasmWebClient as l, BaseWasmProvider as n, mlWasmJSApi_default as o, getResolvedModelsBasePath as r, WasmWebClientError as s, WasmUtilProvider as t, setWebApiHttpTransport as u };
944
+ export { warmupWasm as a, setWasmOnDeviceMode as i, BaseWasmProvider as n, mlWasmJSApi_default as o, getResolvedModelsBasePath as r, WasmUtilProvider as t };
@@ -1,6 +1,6 @@
1
1
  import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BXhgNxLt.esm.js";
2
- import { t as api } from "./api-BDTZNnca.esm.js";
3
- import { t as endpoints } from "./endpoints-BwKx4Gne.esm.js";
2
+ import { t as api } from "./api-Bx3gKW_y.esm.js";
3
+ import { t as endpoints } from "./endpoints-DOfmJylF.esm.js";
4
4
  import { t as fromCallback } from "./xstate-actors.esm-CtI5S0f4.esm.js";
5
5
  const usStateOptions = Object.values({
6
6
  AL: {
@@ -1,4 +1,4 @@
1
- import { a as areAllConsented, n as electronicSignatureMachine, r as AE_CONSENT_KEYS, s as getDefaultConsentChecks, t as createElectronicSignatureManager } from "./electronicSignatureManager-hJ9YaAvD.esm.js";
1
+ import { a as areAllConsented, n as electronicSignatureMachine, r as AE_CONSENT_KEYS, s as getDefaultConsentChecks, t as createElectronicSignatureManager } from "./electronicSignatureManager-D0X7P-de.esm.js";
2
2
  //#region src/modules/ae-signature/index.ts
3
3
  function createAeSignatureManager(options) {
4
4
  return createElectronicSignatureManager({ config: {
@@ -1,3 +1,3 @@
1
- import { t as antifraudMachine } from "./antifraudStateMachine-MfVOsgZf.esm.js";
2
- import { n as createAntifraudManagerFromActor, t as createAntifraudManager } from "./antifraudManager-CQ0zC0jZ.esm.js";
1
+ import { t as antifraudMachine } from "./antifraudStateMachine-NuzlVVte.esm.js";
2
+ import { n as createAntifraudManagerFromActor, t as createAntifraudManager } from "./antifraudManager-COYh4O_y.esm.js";
3
3
  export { antifraudMachine, createAntifraudManager, createAntifraudManagerFromActor };
@@ -1,7 +1,7 @@
1
- import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-Dy8PyVO5.esm.js";
1
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-CMFCCu1H.esm.js";
2
2
  import { t as topLevelStateName } from "./topLevelStateName-B5i2avbh.esm.js";
3
3
  import { c as createManager, o as createActor } from "./xstate.esm-Cf4e0Cfd.esm.js";
4
- import { t as antifraudMachine } from "./antifraudStateMachine-MfVOsgZf.esm.js";
4
+ import { t as antifraudMachine } from "./antifraudStateMachine-NuzlVVte.esm.js";
5
5
  //#region src/modules/antifraud/antifraudActor.ts
6
6
  function createAntifraudActor() {
7
7
  return createActor(antifraudMachine).start();
@@ -1,5 +1,5 @@
1
- import { t as api } from "./api-BDTZNnca.esm.js";
2
- import { t as endpoints } from "./endpoints-BwKx4Gne.esm.js";
1
+ import { t as api } from "./api-Bx3gKW_y.esm.js";
2
+ import { t as endpoints } from "./endpoints-DOfmJylF.esm.js";
3
3
  import { t as setup } from "./xstate.esm-Cf4e0Cfd.esm.js";
4
4
  import { n as fromPromise } from "./xstate-actors.esm-CtI5S0f4.esm.js";
5
5
  //#region src/modules/antifraud/antifraudServices.ts