@incodetech/core 2.3.0-rc.1 → 2.3.0-rc.10

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 (90) hide show
  1. package/dist/{BrowserDiagnosticsCryptoProvider-CU6kBvqv.esm.js → BrowserDiagnosticsCryptoProvider-BuzqvbhN.esm.js} +6 -24
  2. package/dist/{FaceDetectionProvider-BfhWkK90.esm.js → FaceDetectionProvider-BZYHujqz.esm.js} +8 -8
  3. package/dist/{MotionSensorProvider-BgTYwg9L.esm.js → MotionSensorProvider-DyhbM4Si.esm.js} +1 -1
  4. package/dist/ae-signature.esm.js +1 -1
  5. package/dist/{apiError-Budb6m6w.esm.js → apiError-iTFZ5fiI.esm.js} +1 -1
  6. package/dist/authentication.d.ts +2 -2
  7. package/dist/authentication.esm.js +2 -2
  8. package/dist/{authenticationManager-CjXBjC-c.d.ts → authenticationManager-B23V74p7.d.ts} +1 -1
  9. package/dist/{authenticationManager-cMXhG70r.esm.js → authenticationManager-D22ju23T.esm.js} +4 -4
  10. package/dist/{authenticationStateMachine-MOYz4HCf.esm.js → authenticationStateMachine-TyFaCegB.esm.js} +3 -3
  11. package/dist/{backCameraStream-BOtyQowf.esm.js → backCameraStream-B0-YgP_y.esm.js} +1 -0
  12. package/dist/camera.esm.js +1 -1
  13. package/dist/consent.d.ts +1 -1
  14. package/dist/{consentManager-BhYFeKiG.d.ts → consentManager-uhDPdU6i.d.ts} +8 -8
  15. package/dist/{createCameraCycleOwnership-CX3hJGKc.esm.js → createCameraCycleOwnership-DnwTl1ad.esm.js} +6 -1
  16. package/dist/{deepsightLoader-DDv3vhXU.esm.js → deepsightLoader-DamOBrBJ.esm.js} +6 -6
  17. package/dist/document-capture.d.ts +1 -1
  18. package/dist/document-capture.esm.js +2 -2
  19. package/dist/{documentCaptureManager-CwAiM9WY.esm.js → documentCaptureManager-BRPxqYD2.esm.js} +1 -1
  20. package/dist/{documentCaptureManager-DensIj5F.d.ts → documentCaptureManager-lEtCM320.d.ts} +14 -0
  21. package/dist/{documentCaptureStateMachine-DfGOBapD.esm.js → documentCaptureStateMachine-D312sSIu.esm.js} +13 -8
  22. package/dist/dynamic-forms.esm.js +2 -2
  23. package/dist/{dynamicFormsManager-BbS-XMFc.esm.js → dynamicFormsManager-DKgiusbF.esm.js} +1 -1
  24. package/dist/{dynamicFormsStateMachine-D8zHBCh4.esm.js → dynamicFormsStateMachine-BV8yR5iN.esm.js} +1 -1
  25. package/dist/ekyb.esm.js +3 -3
  26. package/dist/{ekybManager-5aiac8wL.esm.js → ekybManager-8VUBu8VW.esm.js} +1 -1
  27. package/dist/{ekybStateMachine-Bn2IE9rx.esm.js → ekybStateMachine-Bnsefu9M.esm.js} +1 -1
  28. package/dist/electronic-signature.esm.js +1 -1
  29. package/dist/{electronicSignatureManager-BJJH0Tvi.esm.js → electronicSignatureManager--YFXVldr.esm.js} +1 -1
  30. package/dist/extensibility.d.ts +7 -7
  31. package/dist/extensibility.esm.js +13 -13
  32. package/dist/{faceCaptureManagerFactory-B7Ms6pSs.esm.js → faceCaptureManagerFactory-Bk6pVs6E.esm.js} +3 -3
  33. package/dist/{faceCaptureManagerFactory-BeUl8fl1.d.ts → faceCaptureManagerFactory-DMLstvui.d.ts} +80 -40
  34. package/dist/{faceCaptureSetup-bkAlr5d8.esm.js → faceCaptureSetup-CGQDK97m.esm.js} +267 -45
  35. package/dist/{feature-management-E0mq0pMs.esm.js → feature-management-C8OAO_CZ.esm.js} +1 -1
  36. package/dist/feature-management.esm.js +1 -1
  37. package/dist/fiscal-qr.esm.js +1 -1
  38. package/dist/{fiscalQrManager-BunLVFbd.esm.js → fiscalQrManager-DbCVMIBx.esm.js} +1 -1
  39. package/dist/flow.esm.js +3 -3
  40. package/dist/{flowCompletionService-DJp1odGN.esm.js → flowCompletionService-C0zcPnqK.esm.js} +1 -1
  41. package/dist/{flowServices-DjPFGs_D.esm.js → flowServices-G1FDrkLd.esm.js} +5 -5
  42. package/dist/geolocation.esm.js +2 -2
  43. package/dist/{geolocationManager-D5906YXx.esm.js → geolocationManager-DNixQOgf.esm.js} +1 -1
  44. package/dist/{geolocationStateMachine-BVOduc3y.esm.js → geolocationStateMachine-D1aZJ6eR.esm.js} +1 -1
  45. package/dist/id-selfie-flow.esm.js +9 -9
  46. package/dist/id.d.ts +2 -2
  47. package/dist/id.esm.js +4 -4
  48. package/dist/idCaptureDefaults-sJahGQgV.esm.js +282 -0
  49. package/dist/{idCaptureManager-rfV9dIXy.esm.js → idCaptureManager-B8lo-ksK.esm.js} +5 -5
  50. package/dist/{idCaptureManager-DKESug0R.d.ts → idCaptureManager-BaHEyQyr.d.ts} +23 -5
  51. package/dist/{idCaptureServices-i1KxugN7.esm.js → idCaptureServices-DLqls7Xv.esm.js} +60 -13
  52. package/dist/{idCaptureStateMachine-Ne_PXth_.esm.js → idCaptureStateMachine-CCPGFPRF.esm.js} +221 -76
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.esm.js +1 -1
  55. package/dist/mandatory-consent.d.ts +1 -1
  56. package/dist/{mandatoryConsentManager-vhv1co_n.d.ts → mandatoryConsentManager-CJSyhTpi.d.ts} +4 -4
  57. package/dist/{multipartRecordingService-OEgIRvqC.esm.js → multipartRecordingService-YKu0Bd7S.esm.js} +490 -8
  58. package/dist/{permissionGuards-uYZYFu4J.esm.js → permissionGuards-D6TfVop2.esm.js} +1 -1
  59. package/dist/{permissionServices-Bj_fyWtv.esm.js → permissionServices-EY3_Vx6c.esm.js} +2 -2
  60. package/dist/qe-signature.esm.js +1 -1
  61. package/dist/{runChildModule-CI1gGWN1.esm.js → runChildModule-B3Z4iJnG.esm.js} +1 -1
  62. package/dist/{safeStorage-B-trhxg6.esm.js → safeStorage-BdU9_m2E.esm.js} +1 -1
  63. package/dist/{sdkVersion-BZh6dj53.esm.js → sdkVersion-CD9fJC2Y.esm.js} +1 -1
  64. package/dist/selfie.d.ts +2 -2
  65. package/dist/selfie.esm.js +7 -7
  66. package/dist/{selfieManager-4RRLi21P.d.ts → selfieManager-CDCTOrcg.d.ts} +1 -1
  67. package/dist/{selfieManager-B-2c1n_x.esm.js → selfieManager-DzOPNipB.esm.js} +4 -4
  68. package/dist/{selfieStateMachine-Bzx41R8d.esm.js → selfieStateMachine-CidiobBW.esm.js} +3 -3
  69. package/dist/{session-3LmvAU4S.esm.js → session-BABCfUhC.esm.js} +3 -3
  70. package/dist/session.esm.js +4 -4
  71. package/dist/{sessionInitializer-BFk33E67.esm.js → sessionInitializer-BK5NjMe0.esm.js} +4 -4
  72. package/dist/{setup-Cv-JM9QC.d.ts → setup-Cyko6cAn.d.ts} +6 -18
  73. package/dist/{setup-BWG-hivt.esm.js → setup-D4YCSH31.esm.js} +12 -200
  74. package/dist/{tri-4RsGrIt6.esm.js → tri-xzRLIIMN.esm.js} +0 -10
  75. package/dist/tri.esm.js +1 -1
  76. package/dist/{trueSightService-BN-Hzw82.esm.js → trueSightService-D8yZwF3G.esm.js} +189 -570
  77. package/dist/video-selfie.esm.js +5 -6
  78. package/dist/{videoSelfieCameraWarmer-B8PcYqmz.esm.js → videoSelfieCameraWarmer-C80ZPDZ8.esm.js} +6 -6
  79. package/dist/{warmup-CUUnwYxe.esm.js → warmup-ChDwHSel.esm.js} +5 -0
  80. package/dist/wasm.d.ts +1 -1
  81. package/dist/wasm.esm.js +3 -2
  82. package/dist/{wasmDsFlagSync-B2e8p268.esm.js → wasmDsFlagSync-DYrLUEII.esm.js} +1 -1
  83. package/dist/workflow.esm.js +15 -15
  84. package/package.json +1 -6
  85. package/dist/FaceDetectionProvider-LdZ47bWy.d.ts +0 -36
  86. package/dist/StreamCanvasProcessingSession-CBnbTnOr.esm.js +0 -42
  87. package/dist/idCaptureDefaults-CbPA-Auz.esm.js +0 -727
  88. package/dist/personhood.d.ts +0 -538
  89. package/dist/personhood.esm.js +0 -1574
  90. package/dist/types-BT_Oalip.d.ts +0 -1
@@ -1,538 +0,0 @@
1
- import { A as StateMachine, i as ActorRefFrom, l as AnyStateMachine } from "./spawn-D9jgw9pW.js";
2
- import "./StateMachine-EDpYWy0i.js";
3
- import { t as Manager } from "./Manager-CQQ99QOI.js";
4
- import "./Actor-iTq7YY48.js";
5
- import { y as IncodeCanvas } from "./createFaceAvatar-BlcTYgJv.js";
6
- import { i as IStorageCapability, t as IWasmUtilCapability } from "./IWasmUtilCapability-CNWRl7jr.js";
7
- import { n as PermissionStatus, t as PermissionResult } from "./types-BEwVKkLJ.js";
8
- import { n as DetectionStatus } from "./types-Bnl58jUQ.js";
9
- import { n as DeepsightService, t as StreamCanvasCapture } from "./StreamCanvasCapture-_8gdW5Lk.js";
10
- import { t as FaceDetectionProvider } from "./FaceDetectionProvider-LdZ47bWy.js";
11
- import { t as CameraStream } from "./camera-9wWD-pwg.js";
12
- //#region src/modules/personhood/types.d.ts
13
- /**
14
- * Head pose (degrees) computed per-frame from the WASM face detector.
15
- * Used internally by the personhood detection actor to accumulate the
16
- * yaw/pitch range that feeds the server-side `headMotion` spoof check.
17
- *
18
- * Re-exported from `@incodetech/core/personhood` as a convenience type
19
- * for integrators running their own face-tracking pipelines (e.g.
20
- * MediaPipe FaceLandmarker) that want to share a pose shape with
21
- * other code that consumes personhood internals — the SDK itself
22
- * does not expose a runtime pose stream.
23
- *
24
- * `faceSizeRatio` is an orientation-invariant 0–1 proxy for how close
25
- * the user is to the camera, computed by the producer as
26
- * `sqrt(face.width * face.height) / min(frame.width, frame.height)`.
27
- * Same value on landscape (laptop) or portrait (phone) cameras since
28
- * the denominator is the frame's *narrower* dimension. Optional —
29
- * absent when the producer doesn't have access to frame size.
30
- */
31
- type HeadPose = {
32
- pitch: number;
33
- yaw: number;
34
- roll: number;
35
- faceSizeRatio?: number;
36
- };
37
- /** Signals we hand back to the integrator alongside the human verdict. */
38
- type DeviceBehavioralSignals = {
39
- /** Visitor fingerprint hash from the Thumbmark provider. */
40
- deviceFingerprint: string;
41
- /** Standard browser / OS info (model, os, browser name + version). */
42
- userAgentClass: string;
43
- /** Matches automation markers (phantom, nightmare, domAutomation, etc.). */
44
- emulator: boolean;
45
- /** `navigator.webdriver` is truthy — chromedriver / geckodriver / playwright. */
46
- webdriver: boolean;
47
- /** Liveness / injection surface reported by local detection. */
48
- headlessHints: readonly string[];
49
- };
50
- /**
51
- * One element of the `spoofCheckResults` array. Carries a single
52
- * anti-spoof / liveness / automation check the on-device pipeline
53
- * ran, with its outcome and (when failed) a short tag explaining
54
- * why. The same shape is sent to `/omni/personhood/verify` and
55
- * exposed on {@link PersonhoodVerdict.spoofCheckResults} so
56
- * integrators and UIs can introspect what passed and what failed
57
- * without parsing the comma-joined `reason` string.
58
- *
59
- * Check ids the SDK currently emits:
60
- * - `physicalAttack` — Deepsight pipeline anti-spoof. Failed
61
- * when `analysisStatus` carries an explicit spoof signal
62
- * (`spoof_suspected`, `injection`, etc.).
63
- * - `virtualCamera` — label-based detection of OBS / ManyCam /
64
- * etc. on the camera track.
65
- * - `motionLiveness` — Deepsight's motion-based liveness check
66
- * (accelerometer + temporal frame analysis).
67
- * - `headMotion` — accumulated yaw + pitch range. Failed
68
- * when below the minimum motion threshold (user held still).
69
- * - `faceDetection` — terminal detection outcome (success vs
70
- * timeout / error).
71
- * - `webdriver` — `navigator.webdriver` is truthy.
72
- * - `emulator` — automation framework markers
73
- * (PhantomJS / Selenium / Nightmare / etc.).
74
- * - `headlessBrowser` — headless-browser fingerprinting hints.
75
- *
76
- * `result: 'unknown'` is reserved for checks that ran but couldn't
77
- * render a definitive verdict (e.g. desktop with no accelerometer
78
- * permission for motion liveness). Absence of evidence is
79
- * intentionally not the same as evidence of a spoof.
80
- *
81
- * `reason` is populated only when `result === 'failed'` and gives
82
- * a short stable tag the integrator's server can pattern-match on:
83
- * the same tags that show up in the verdict's `reason` string
84
- * (`no_motion`, `spoof_suspected`, `virtual_camera`, etc.) plus
85
- * raw underlying values (`analysisStatus` strings, detection
86
- * outcome) where useful.
87
- */
88
- type SpoofCheckResult = {
89
- check: string;
90
- result: 'passed' | 'failed' | 'unknown';
91
- reason?: string;
92
- };
93
- /** On-device liveness outcome — filled in after the detection loop succeeds. */
94
- type LivenessOutcome = {
95
- /** True when the camera stream is a known virtual cam (OBS/ManyCam/etc.). */
96
- virtualCamera: boolean;
97
- /** Opaque Deepsight pipeline check status (string like "PASS"/"FAIL"). */
98
- analysisStatus: string;
99
- /** Deepsight motion status string. */
100
- motionStatus: string;
101
- /** Range of yaw observed during detection (degrees). */
102
- yawRange: number;
103
- /** Range of pitch observed during detection (degrees). */
104
- pitchRange: number;
105
- /**
106
- * Full Deepsight metadata blob from `wasmUtil.getMetadata()`. Opaque
107
- * string (typically a JSON-serialized payload of the pipeline's
108
- * collected signals — frame quality, motion features, environment
109
- * fingerprints, etc.) intended for server-side cross-referencing
110
- * with the evidence record. Empty when the Deepsight pipeline isn't
111
- * available (e.g. WASM init failed).
112
- */
113
- metadata: string;
114
- /**
115
- * Deepsight pipeline state string (e.g. running / completed / error
116
- * substates). Useful for diagnosing why an analysis status came
117
- * back negative — the state often carries the underlying cause that
118
- * `analysisStatus` only summarizes.
119
- */
120
- pipelineState: string;
121
- };
122
- /** Final verdict returned from `/omni/personhood/verify`. */
123
- type PersonhoodVerdict = {
124
- human: boolean;
125
- confidence: number;
126
- evidenceId: string;
127
- /**
128
- * Comma-joined list of failure tags when `human === false`. Same
129
- * tags that appear individually in {@link spoofCheckResults}
130
- * entries' `reason` fields — kept for backward compat and quick
131
- * inspection. Undefined when the verdict is human.
132
- */
133
- reason?: string;
134
- signals: DeviceBehavioralSignals;
135
- /** Present for the on-device path. Absent on server fallback. */
136
- liveness?: LivenessOutcome;
137
- /**
138
- * Per-check breakdown of every anti-spoof / liveness / automation
139
- * gate the on-device pipeline ran. Lets integrators see WHICH
140
- * checks passed or failed instead of having to parse the
141
- * collapsed `reason` string. The same array is the body of the
142
- * `/omni/personhood/verify` POST. Empty on the server-fallback
143
- * path (no on-device pipeline ran).
144
- */
145
- spoofCheckResults: SpoofCheckResult[];
146
- };
147
- type PersonhoodConfig = {
148
- /** Integrator's site key (equivalent to a reCAPTCHA site key). */
149
- siteKey: string;
150
- /**
151
- * OAuth2 client-credentials used to mint the `Authorization: Bearer`
152
- * token for the verify hop (`POST /omni/oauth2/token`,
153
- * `grant_type=client_credentials&scope=openid`). Required for the
154
- * live (non-mock) flow; without them the token fetch fails and the
155
- * flow halts before the camera opens.
156
- *
157
- * ⚠️ These are sent from the browser, so `clientSecret` is exposed to
158
- * anyone who can read the page's source / network traffic. Acceptable
159
- * only where that exposure is tolerable; a server-minted Bearer token
160
- * is the hardened alternative.
161
- */
162
- clientId?: string;
163
- clientSecret?: string;
164
- /**
165
- * Origin of the authorization server that mints the OAuth2 Bearer token
166
- * (e.g. `https://auth.stage.incode.com`). The path is fixed — the token
167
- * is `POST`ed to this origin's own `/oauth2/token`.
168
- *
169
- * When set, the browser calls the auth server DIRECTLY through a
170
- * dedicated HTTP client (topology B): the auth origin is separate from
171
- * the omni `apiURL`, so this is a genuine cross-origin call and the auth
172
- * server must allow the integrator's `Origin` (CORS). The dedicated
173
- * client inherits the omni client's `customHeaders` (notably
174
- * `x-api-key`, which the auth server requires) from the active SDK
175
- * config, so no extra credential plumbing is needed here.
176
- *
177
- * When omitted, the token is minted through the shared omni client at
178
- * `/omni/oauth2/token` — i.e. the omni gateway is expected to front the
179
- * auth server (topology A). Single-origin deployments need not set this.
180
- *
181
- * Only the auth-token hop honors this; the verify hop
182
- * (`/omni/personhood/verify`) always uses the omni `apiURL`.
183
- */
184
- authBaseUrl?: string;
185
- /**
186
- * Minimum confidence required to pass. Default: `0.75`
187
- * (`DEFAULT_PERSONHOOD_THRESHOLD`). Exposed so integrators can tighten or
188
- * loosen gates per use case.
189
- */
190
- threshold?: number;
191
- /**
192
- * When true, `/omni/personhood/verify` is bypassed and a canned verdict
193
- * is returned (the local on-device verdict is used as-is). Defaults to
194
- * `false`. Set to `true` in dev environments where the backend is not
195
- * yet available.
196
- */
197
- mockVerify?: boolean;
198
- /**
199
- * Time-to-live (ms) for cached proofs of the same browser session. Not yet
200
- * enforced at phase 0 (documented for forward-compat).
201
- */
202
- cacheTtlMs?: number;
203
- /** Optional: called every time an interesting signal is observed. */
204
- onSignal?: (event: {
205
- type: 'pose' | 'detection' | 'verdict' | 'error';
206
- payload: unknown;
207
- }) => void;
208
- /** Hides the initial tutorial screen. Default: false. */
209
- showTutorial?: boolean;
210
- /**
211
- * When true, the detection flow auto-completes with whatever frame
212
- * is available after a short hard deadline, regardless of why
213
- * WASM's autocapture criteria didn't fire (user too far, bad
214
- * framing, low light, occlusion, etc). The deadline starts ticking
215
- * the moment the camera produces its first frame — not when
216
- * detection begins — so a slow camera cold-start doesn't eat into
217
- * the user's capture window. Once the deadline lands, the
218
- * provider's best frame (or the most recent processed frame if no
219
- * best-shot was recorded) is pushed through to liveness analysis.
220
- *
221
- * The resulting verdict usually has lower confidence — a non-ideal
222
- * frame gives the detector less signal — but at least produces a
223
- * definitive `human: true | false` outcome instead of leaving the
224
- * modal stuck.
225
- *
226
- * If the camera never produces a frame at all (e.g. the user
227
- * blocked permission mid-flow, browser failed to start the stream)
228
- * this flag does nothing — there's literally no frame to capture
229
- * — and the standard error path applies.
230
- *
231
- * Default: `false`.
232
- */
233
- autoComplete?: boolean;
234
- /**
235
- * Enables Deepsight (injection-attack detection) for the session. The flag is
236
- * handed to the WASM utility API, which latches it on: once any call in the
237
- * session sees `true` the IAD challenges keep running. Leaving it unset (or
238
- * `false`) means the challenges are skipped for the whole session, so never
239
- * hardcode `false` here on a Deepsight-enabled organization.
240
- *
241
- * Default: `false`.
242
- */
243
- ds?: boolean;
244
- };
245
- type PersonhoodDependencies = {
246
- storage: IStorageCapability;
247
- getWasmUtil: () => Promise<IWasmUtilCapability>;
248
- };
249
- declare const PERSONHOOD_ERROR_CODES: {
250
- readonly CAMERA_DENIED: "CAMERA_DENIED";
251
- readonly DETECTION_FAILED: "DETECTION_FAILED";
252
- /**
253
- * The OAuth2 token fetch (`POST /omni/oauth2/token`,
254
- * client-credentials) failed — non-2xx, network error, or no
255
- * `access_token` in the response. The flow halts before the user
256
- * opens the camera so a misconfigured `clientId` / `clientSecret`
257
- * surfaces immediately instead of walking them through a capture we
258
- * can't authenticate the verify hop for.
259
- */
260
- readonly AUTH_TOKEN_FAILED: "AUTH_TOKEN_FAILED";
261
- readonly VERIFY_FAILED: "VERIFY_FAILED";
262
- readonly INJECTION_SUSPECTED: "INJECTION_SUSPECTED";
263
- readonly EMULATOR_DETECTED: "EMULATOR_DETECTED";
264
- readonly TIMEOUT: "TIMEOUT";
265
- readonly UNKNOWN: "UNKNOWN";
266
- };
267
- type PersonhoodErrorCode = (typeof PERSONHOOD_ERROR_CODES)[keyof typeof PERSONHOOD_ERROR_CODES];
268
- //#endregion
269
- //#region src/modules/personhood/personhoodStateMachine.d.ts
270
- type PersonhoodInput = {
271
- config: PersonhoodConfig;
272
- dependencies: PersonhoodDependencies;
273
- };
274
- type PersonhoodMachineContext = {
275
- config: PersonhoodConfig;
276
- dependencies: PersonhoodDependencies;
277
- permissionResult: PermissionResult | 'refresh' | undefined;
278
- /**
279
- * Why the server-fallback path was taken, so `requestServerFallback` reports
280
- * the real cause instead of a hardcoded value. `undefined` means
281
- * `permission_denied` (the original/most common cause).
282
- */
283
- fallbackReason: 'no_camera' | 'permission_denied' | 'unsupported_browser' | undefined;
284
- stream: CameraStream | undefined;
285
- provider: FaceDetectionProvider | undefined;
286
- frameCapturer: StreamCanvasCapture | undefined;
287
- deepsightService: DeepsightService | undefined;
288
- detectionStatus: DetectionStatus;
289
- /**
290
- * Yaw + pitch ranges captured during detection (in degrees). Accumulated
291
- * in the detection actor's closure and committed to context once when
292
- * DETECTION_SUCCESS fires — not per-frame. Pose itself never lives in
293
- * context: per-frame samples are consumed inside the detection actor
294
- * (and discarded) so the manager-subscribed UI tree doesn't churn at
295
- * camera frame rate.
296
- */
297
- yawRange: number;
298
- pitchRange: number;
299
- capturedImage: IncodeCanvas | undefined;
300
- livenessOutcome: LivenessOutcome | undefined;
301
- signals: DeviceBehavioralSignals | undefined;
302
- /**
303
- * Personhood session token from `GET /omni/personhood/token`. Lives
304
- * in actor context (not a module-level slot) so two
305
- * `createPersonhoodManager()` instances active concurrently can't
306
- * trample each other's tokens, and so `actor.stop()` cleans it up
307
- * implicitly. Threaded into the `analyzeLiveness` and
308
- * `verifyOnDevice` actor inputs; those actors attach it as an
309
- * `Authorization: Bearer` header explicitly rather than going
310
- * through the shared `api` wrapper's auto-injection (which only
311
- * carries `currentToken` for the main session). `undefined` until
312
- * the parallel-init phase completes.
313
- */
314
- token: string | undefined;
315
- /**
316
- * Verdict computed locally from device signals + on-device
317
- * liveness analysis. Kept separately from `verdict` (the final,
318
- * server-authoritative one) so the verify-on-server step can use
319
- * it as a fallback when the network call fails. Once verify
320
- * succeeds, `verdict` is the server's response and this stays as
321
- * a debug reference; integrators only see `verdict`.
322
- */
323
- localVerdict: PersonhoodVerdict | undefined;
324
- verdict: PersonhoodVerdict | undefined;
325
- error: {
326
- code: PersonhoodErrorCode;
327
- message?: string;
328
- } | undefined;
329
- resetDetection: (() => void) | undefined;
330
- };
331
- type PersonhoodEvent = {
332
- type: 'LOAD';
333
- } | {
334
- type: 'NEXT_STEP';
335
- } | {
336
- type: 'REQUEST_PERMISSION';
337
- } | {
338
- type: 'GO_TO_LEARN_MORE';
339
- } | {
340
- type: 'BACK';
341
- } | {
342
- type: 'QUIT';
343
- } | {
344
- type: 'RESET';
345
- } |
346
- /**
347
- * Triggered from the UI when the user declines camera access but still
348
- * wants a verdict (server fallback). Also dispatched automatically when
349
- * the device has no camera at all.
350
- */
351
- {
352
- type: 'USE_FALLBACK';
353
- } | {
354
- type: 'DETECTION_UPDATE';
355
- status: DetectionStatus;
356
- } | {
357
- type: 'DETECTION_SUCCESS';
358
- canvas?: IncodeCanvas;
359
- /** Final observed head-pose yaw range (max − min) in degrees. */
360
- yawRange: number;
361
- /** Final observed head-pose pitch range (max − min) in degrees. */
362
- pitchRange: number;
363
- } | {
364
- type: 'DETECTION_RESET_READY';
365
- reset: () => void;
366
- };
367
- declare const _personhoodMachine: AnyStateMachine;
368
- type PersonhoodMachine = typeof _personhoodMachine;
369
- /**
370
- * Public machine value. Typed as `AnyStateMachine` for declaration file
371
- * portability — mirrors the convention used by `selfieMachine` and the
372
- * other Core modules. Type safety is enforced by the `setup()` config
373
- * above, not by the exported binding.
374
- */
375
- declare const personhoodMachine: AnyStateMachine;
376
- /**
377
- * Narrow typed machine used by the Actor helpers. The non-context/event/
378
- * input slots are widened to `any` because XState's full generic surface
379
- * isn't worth threading through every module — we only need the slots
380
- * the actor + manager actually consume. Same pattern as `SelfieMachine`.
381
- */
382
- type PersonhoodTypedMachine = StateMachine<PersonhoodMachineContext, PersonhoodEvent, any, any, any, any, any, any, any, PersonhoodInput, any, any, any, any>;
383
- //#endregion
384
- //#region src/modules/personhood/personhoodActor.d.ts
385
- type CreatePersonhoodActorOptions = {
386
- config: PersonhoodConfig;
387
- dependencies?: PersonhoodDependencies;
388
- };
389
- type PersonhoodActor = ActorRefFrom<PersonhoodTypedMachine>;
390
- /**
391
- * Creates and starts a Personhood XState actor. Defaults to the production
392
- * browser storage + WASM providers; passing `dependencies` lets tests and the
393
- * extensibility layer swap them for fakes.
394
- */
395
- declare function createPersonhoodActor(options: CreatePersonhoodActorOptions): PersonhoodActor;
396
- //#endregion
397
- //#region src/modules/personhood/personhoodManager.d.ts
398
- /** Initial state (before `load()` is invoked). */
399
- type PersonhoodIdleState = {
400
- status: 'idle';
401
- };
402
- /** Collecting local device + behavioural signals before any UI is shown. */
403
- type PersonhoodLoadingState = {
404
- status: 'loading';
405
- phase: 'collectingSignals' | 'checkingPermission';
406
- };
407
- /** Optional opt-in tutorial screen. */
408
- type PersonhoodTutorialState = {
409
- status: 'tutorial';
410
- };
411
- /** Camera permission handshake. */
412
- type PersonhoodPermissionsState = {
413
- status: 'permissions';
414
- permissionStatus: PermissionStatus | 'denied';
415
- };
416
- /**
417
- * Live camera + avatar-driving state.
418
- *
419
- * `stream` is the active camera MediaStream. It is **not** displayed to
420
- * the user by default (the whole UX promise is "stylized avatar, not
421
- * raw camera feed"); it's exposed so integrators can render the avatar
422
- * by piping the stream into their own face-tracking pipeline (e.g.
423
- * MediaPipe FaceLandmarker). Head-pose is intentionally **not** on
424
- * this state type — the SDK extracts pose internally for the
425
- * server-side `headMotion` spoof check, but UI consumers should
426
- * compute their own pose off `stream` rather than subscribing to a
427
- * frame-rate channel here (which would re-render on every frame).
428
- */
429
- type PersonhoodCaptureState = {
430
- status: 'capture';
431
- captureStatus: 'initializing' | 'detecting';
432
- detectionStatus: DetectionStatus;
433
- stream: MediaStream | undefined;
434
- };
435
- /** Synthesizing the local on-device verdict. No network call — the primary path. */
436
- type PersonhoodProcessingState = {
437
- status: 'processing';
438
- /**
439
- * Which stage of the local pipeline we're on:
440
- * - 'analyzing' → Deepsight analysis + pose-motion guard (post-capture)
441
- * - 'local' → synthesizing verdict from the collected signals
442
- * - 'fallback' → server-side liveness fallback (no camera / denied)
443
- */
444
- source: 'analyzing' | 'local' | 'fallback';
445
- };
446
- /** Verdict is in. Integrators read `verdict` to obtain `{ human, confidence, evidenceId, signals }`. */
447
- type PersonhoodFinishedState = {
448
- status: 'finished';
449
- verdict: PersonhoodVerdict;
450
- };
451
- type PersonhoodClosedState = {
452
- status: 'closed';
453
- };
454
- type PersonhoodErrorState = {
455
- status: 'error';
456
- error: {
457
- code: PersonhoodErrorCode;
458
- message?: string;
459
- };
460
- };
461
- type PersonhoodState = PersonhoodIdleState | PersonhoodLoadingState | PersonhoodTutorialState | PersonhoodPermissionsState | PersonhoodCaptureState | PersonhoodProcessingState | PersonhoodFinishedState | PersonhoodClosedState | PersonhoodErrorState;
462
- /**
463
- * Manager built from an externally-owned actor (extensibility path).
464
- */
465
- declare function createPersonhoodManagerFromActor(actor: PersonhoodActor): Manager<PersonhoodState> & {
466
- /** Starts the flow (goes to tutorial or capture depending on config). */
467
- load(): void;
468
- /** Advances from tutorial → capture. */
469
- nextStep(): void;
470
- /** Triggers `getUserMedia` when in `permissions.idle`. */
471
- requestPermission(): void;
472
- /** Shows the permission rationale view. */
473
- goToLearnMore(): void;
474
- /** Returns from learn-more → permission prompt. */
475
- back(): void;
476
- /** Dismisses the widget into the terminal `closed` state. */
477
- close(): void;
478
- /** Resets from the (non-final) `error` state back to `idle`. */
479
- reset(): void;
480
- /**
481
- * Skip the on-device path and hit the server fallback. Wired to the
482
- * "Continue without camera" button on the permission-denied screen; also
483
- * dispatched automatically when the device has no camera at all.
484
- */
485
- useFallback(): void;
486
- };
487
- /**
488
- * Creates a Personhood manager for the drop-in widget.
489
- *
490
- * The manager exposes:
491
- * - `state: PersonhoodState` via `getState()` / `subscribe()`
492
- * - Lifecycle controls: `load`, `nextStep`, `requestPermission`,
493
- * `goToLearnMore`, `back`, `close`, `reset`, `useFallback`, `stop`
494
- *
495
- * Head-pose is intentionally **not** exposed as a stream. The SDK
496
- * extracts pose internally for the server-side `headMotion` spoof
497
- * check; UI consumers that need a frame-rate pose signal (avatar
498
- * mirroring, etc.) should run their own face-tracking pipeline
499
- * (e.g. MediaPipe FaceLandmarker) against `state.stream` instead.
500
- *
501
- * @example
502
- * ```ts
503
- * const manager = createPersonhoodManager({
504
- * config: { siteKey: 'demo', mockVerify: true },
505
- * });
506
- * manager.subscribe((state) => {
507
- * if (state.status === 'finished') {
508
- * console.log('human?', state.verdict.human);
509
- * }
510
- * });
511
- * manager.load();
512
- * ```
513
- */
514
- declare function createPersonhoodManager(options: CreatePersonhoodActorOptions): Manager<PersonhoodState> & {
515
- /** Starts the flow (goes to tutorial or capture depending on config). */
516
- load(): void;
517
- /** Advances from tutorial → capture. */
518
- nextStep(): void;
519
- /** Triggers `getUserMedia` when in `permissions.idle`. */
520
- requestPermission(): void;
521
- /** Shows the permission rationale view. */
522
- goToLearnMore(): void;
523
- /** Returns from learn-more → permission prompt. */
524
- back(): void;
525
- /** Dismisses the widget into the terminal `closed` state. */
526
- close(): void;
527
- /** Resets from the (non-final) `error` state back to `idle`. */
528
- reset(): void;
529
- /**
530
- * Skip the on-device path and hit the server fallback. Wired to the
531
- * "Continue without camera" button on the permission-denied screen; also
532
- * dispatched automatically when the device has no camera at all.
533
- */
534
- useFallback(): void;
535
- };
536
- type PersonhoodManager = ReturnType<typeof createPersonhoodManager>;
537
- //#endregion
538
- export { type CreatePersonhoodActorOptions, type DeviceBehavioralSignals, type HeadPose, type LivenessOutcome, PERSONHOOD_ERROR_CODES, type PersonhoodActor, type PersonhoodCaptureState, type PersonhoodClosedState, type PersonhoodConfig, type PersonhoodDependencies, type PersonhoodErrorCode, type PersonhoodErrorState, type PersonhoodEvent, type PersonhoodFinishedState, type PersonhoodIdleState, type PersonhoodInput, type PersonhoodLoadingState, type PersonhoodMachine, type PersonhoodMachineContext, type PersonhoodManager, type PersonhoodPermissionsState, type PersonhoodProcessingState, type PersonhoodState, type PersonhoodTutorialState, type PersonhoodVerdict, type SpoofCheckResult, createPersonhoodActor, createPersonhoodManager, createPersonhoodManagerFromActor, personhoodMachine };