@velion-la/onboarding-sdk-web 1.2.0-beta.1 → 1.2.0-beta.11
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.
- package/README.md +3 -0
- package/dist/index.d.ts +195 -11
- package/dist/velion-sdk.es.js +1 -1
- package/dist/velion-sdk.es.js.map +1 -1
- package/dist/velion-sdk.umd.js +1 -1
- package/dist/velion-sdk.umd.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -103,6 +103,9 @@ More detail: [web/README.md](../web/README.md) (integration notes for the hosted
|
|
|
103
103
|
| `onStepComplete` | `(step: OnboardingStep) => void` | | — | Called after each step succeeds. |
|
|
104
104
|
| `onExit` | `(exit: OnboardingExit) => void` | | — | Called when the user leaves without a verdict (`reason: 'BACK_EXIT' \| 'RETRY_CANCELLED'`). Neither `onSuccess` nor `onError` fires; dismiss the SDK surface. |
|
|
105
105
|
| `onLivenessVideoUploaded` | `(ref: LivenessVideoRef) => void` | | — | Called once the `LIVENESS_MATCH` step stored its session video (GCS PUT returned 200). `ref` is `{ upload_url, content_type, duration_ms, size_bytes }`. Best-effort: not called when recording was disabled or the upload failed. |
|
|
106
|
+
| `presentation` | `'standalone' \| 'embedded'` | | `'standalone'` | `'embedded'`: no background, card shadow, side padding or progress bar, and the iframe height follows its content (`VELION_RESIZE`), so the host page scrolls instead of the iframe. |
|
|
107
|
+
| `onProgress` | `(progress: VelionProgress) => void` | | — | Visited steps (`{ code, stepKey, name?, status }`) on every step change and status update (`VELION_PROGRESS`). No personal data. |
|
|
108
|
+
| `onSessionEvent` | `(event: OnboardingSessionEvent) => void` | | — | Each SSE event (`VELION_SESSION_EVENT`), without `step_config` and `step_result`. |
|
|
106
109
|
| `retryStepTexts` | `VelionRetryStepTexts` | | — | Per-step copy override for the retry dialog shown on a backend `RETRY_STEP`. Keyed by step code. |
|
|
107
110
|
| `onTokenExpired` | `() => Promise<{ sessionToken: string; expiresAt?: string }>` | | — | Optional. When the iframe reports token expiry, return a new token so the flow can continue. |
|
|
108
111
|
| `runtimeReadyTimeoutMs` | `number` | | `30000` | How long to wait, after the iframe document loaded, for the runtime to report ready. Past it `onError` fires with `RUNTIME_LOAD_FAILED` instead of leaving a blank iframe (e.g. a CDN whose `index.html` points at missing assets). |
|
package/dist/index.d.ts
CHANGED
|
@@ -336,6 +336,10 @@ export declare interface OnboardingDtoResponse {
|
|
|
336
336
|
status?: string;
|
|
337
337
|
current_step?: {
|
|
338
338
|
code?: string;
|
|
339
|
+
/** Key of the step inside the workflow; falls back to `code` when absent. */
|
|
340
|
+
step_key?: string;
|
|
341
|
+
name?: string;
|
|
342
|
+
description?: string;
|
|
339
343
|
status?: string;
|
|
340
344
|
config?: Record<string, unknown>;
|
|
341
345
|
/**
|
|
@@ -430,17 +434,28 @@ export declare interface OnboardingResult {
|
|
|
430
434
|
* - SESSION_APPROVED — all checks passed; session_status = APPROVED
|
|
431
435
|
* - SESSION_MANUAL_REVIEW — manual review required; session_status = MANUAL_REVIEW
|
|
432
436
|
* - SESSION_DECLINED — session ended with decline (step_code, session_status DECLINED, reason)
|
|
437
|
+
* - SESSION_CANCELLED — session cancelled by the backend, not a verdict (session_status CANCELLED,
|
|
438
|
+
* reason e.g. WORKFLOW_VERSION_RETIRED). The stream closes and the session token is revoked.
|
|
433
439
|
*/
|
|
434
440
|
export declare interface OnboardingSessionEvent {
|
|
435
441
|
/** Onboarding session identifier (Long in backend). */
|
|
436
442
|
session_id?: number;
|
|
437
|
-
/** Discriminator: STEP_UPDATED | ROUTING_COMMAND | SESSION_APPROVED | SESSION_MANUAL_REVIEW | SESSION_DECLINED */
|
|
443
|
+
/** Discriminator: STEP_UPDATED | ROUTING_COMMAND | SESSION_APPROVED | SESSION_MANUAL_REVIEW | SESSION_DECLINED | SESSION_CANCELLED */
|
|
438
444
|
event_type?: string;
|
|
439
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* Present for STEP_UPDATED or ROUTING_COMMAND (next step code). Always the
|
|
447
|
+
* step type: it chooses the screen.
|
|
448
|
+
*/
|
|
440
449
|
step_code?: string;
|
|
450
|
+
/**
|
|
451
|
+
* Key of the step inside the workflow, next to `step_code`. Identifies the
|
|
452
|
+
* instance (several `CUSTOM_FORM` can coexist). Absent on older backends:
|
|
453
|
+
* the SDK then uses `step_code`.
|
|
454
|
+
*/
|
|
455
|
+
step_key?: string;
|
|
441
456
|
/** Present for STEP_UPDATED; e.g. COMPLETED. */
|
|
442
457
|
step_status?: string;
|
|
443
|
-
/** Present for terminal events; e.g. APPROVED | MANUAL_REVIEW |
|
|
458
|
+
/** Present for terminal events; e.g. APPROVED | MANUAL_REVIEW | DECLINED | CANCELLED. */
|
|
444
459
|
session_status?: string;
|
|
445
460
|
/**
|
|
446
461
|
* For ROUTING_COMMAND: NEXT_STEP | RETRY_STEP (render step_code), TERMINATE
|
|
@@ -449,7 +464,7 @@ export declare interface OnboardingSessionEvent {
|
|
|
449
464
|
* reversible step — leave the flow and notify the host via `onExit`).
|
|
450
465
|
*/
|
|
451
466
|
action?: string;
|
|
452
|
-
/** For SESSION_DECLINED / SESSION_MANUAL_REVIEW or ROUTING_COMMAND TERMINATE; e.g. UNREADABLE_DOCUMENT. */
|
|
467
|
+
/** For SESSION_DECLINED / SESSION_MANUAL_REVIEW / SESSION_CANCELLED or ROUTING_COMMAND TERMINATE; e.g. UNREADABLE_DOCUMENT. */
|
|
453
468
|
reason?: string;
|
|
454
469
|
/** Step-specific config sent with ROUTING_COMMAND NEXT_STEP / PREVIOUS_STEP. */
|
|
455
470
|
step_config?: Record<string, unknown>;
|
|
@@ -489,17 +504,27 @@ export declare interface OnboardingSessionEvent {
|
|
|
489
504
|
* - `TAX_INFO`, `HUMAN_EXTENDED_INFO`, `LEGAL_EXTENDED_INFO`, `ADDRESS_INFO`, `SWORN_DECLARATION`: form steps.
|
|
490
505
|
* - `ECONOMIC_ACTIVITY_DECLARATION`: pick exactly one economic activity from a searchable list.
|
|
491
506
|
* - `TERMS_AND_CONDITIONS`: accept configured T&C items.
|
|
507
|
+
* - `CUSTOM_FORM`: a form the workflow defines field by field (`form_fields`). A
|
|
508
|
+
* workflow may hold several; each instance is told apart by its `step_key`.
|
|
509
|
+
* - `ENTITY_TYPE_SELECTION`: the person picks natural person (`HUMAN`) or legal
|
|
510
|
+
* entity (`LEGAL`); the backend routes to the matching branch.
|
|
492
511
|
* - `FACE_MATCH`: server-side face comparison after liveness (no user input; SDK waits).
|
|
493
512
|
* - `AML_SCREENING`: server-side PEP / sanctions screening (no user input; never routed to
|
|
494
513
|
* the SDK as `NEXT_STEP`, only visible in `steps[]` and `STEP_UPDATED`).
|
|
495
514
|
*/
|
|
496
|
-
export declare type OnboardingStep = 'DEVICE_FINGERPRINT' | 'HUMAN_BASIC_INFO' | 'LEGAL_BASIC_INFO' | 'EMAIL_OTP' | 'EMAIL_CONTACT' | 'PHONE_OTP' | 'PHONE_CONTACT' | 'TAX_INFO' | 'HUMAN_EXTENDED_INFO' | 'LEGAL_EXTENDED_INFO' | 'ADDRESS_INFO' | 'SWORN_DECLARATION' | 'ECONOMIC_ACTIVITY_DECLARATION' | 'DOCUMENTS_OCR' | 'LIVENESS_MATCH' | 'FACE_MATCH' | 'AML_SCREENING' | 'TERMS_AND_CONDITIONS';
|
|
515
|
+
export declare type OnboardingStep = 'DEVICE_FINGERPRINT' | 'HUMAN_BASIC_INFO' | 'LEGAL_BASIC_INFO' | 'EMAIL_OTP' | 'EMAIL_CONTACT' | 'PHONE_OTP' | 'PHONE_CONTACT' | 'TAX_INFO' | 'HUMAN_EXTENDED_INFO' | 'LEGAL_EXTENDED_INFO' | 'ADDRESS_INFO' | 'SWORN_DECLARATION' | 'ECONOMIC_ACTIVITY_DECLARATION' | 'DOCUMENTS_OCR' | 'LIVENESS_MATCH' | 'FACE_MATCH' | 'AML_SCREENING' | 'TERMS_AND_CONDITIONS' | 'CUSTOM_FORM' | 'ENTITY_TYPE_SELECTION';
|
|
497
516
|
|
|
498
517
|
/**
|
|
499
518
|
* Backend step DTO (OnboardingStepDto). GET session returns an array of these.
|
|
500
519
|
*/
|
|
501
520
|
export declare interface OnboardingStepDto {
|
|
502
521
|
code: string;
|
|
522
|
+
/**
|
|
523
|
+
* Key of the step inside the workflow. Equals `code` for standard steps; a
|
|
524
|
+
* `CUSTOM_FORM` carries its form slug, so several instances can coexist.
|
|
525
|
+
* Optional while the backend rolls it out: the SDK falls back to `code`.
|
|
526
|
+
*/
|
|
527
|
+
step_key?: string;
|
|
503
528
|
name?: string;
|
|
504
529
|
description?: string;
|
|
505
530
|
order?: number;
|
|
@@ -574,6 +599,11 @@ export declare interface SdkError {
|
|
|
574
599
|
* for `ROUTING_TIMEOUT` it is the step that was completed and never routed.
|
|
575
600
|
*/
|
|
576
601
|
readonly stepCode?: string;
|
|
602
|
+
/**
|
|
603
|
+
* Key of the step inside the workflow, for `UNSUPPORTED_STEP`. Equals
|
|
604
|
+
* `stepCode` except for steps with several instances (`CUSTOM_FORM`).
|
|
605
|
+
*/
|
|
606
|
+
readonly stepKey?: string;
|
|
577
607
|
/**
|
|
578
608
|
* Localized headline resolved by the SDK for SESSION_DECLINED.
|
|
579
609
|
* Useful when hosts hide the built-in final result screen but still want
|
|
@@ -585,6 +615,8 @@ export declare interface SdkError {
|
|
|
585
615
|
* Mirrors the text shown in the built-in final result screen.
|
|
586
616
|
*/
|
|
587
617
|
readonly declineMessage?: string;
|
|
618
|
+
/** Present when `code === SdkErrorCode.SESSION_CANCELLED` (backend `reason`, e.g. `WORKFLOW_VERSION_RETIRED`). */
|
|
619
|
+
readonly cancelReason?: string;
|
|
588
620
|
/** Present when `code === SdkErrorCode.CAMERA_ERROR`. Provides camera-specific detail. */
|
|
589
621
|
readonly cameraCode?: CameraErrorCode;
|
|
590
622
|
/** HTTP status code when the error originated from an API call. */
|
|
@@ -608,6 +640,16 @@ export declare enum SdkErrorCode {
|
|
|
608
640
|
SESSION_FETCH_FAILED = "SESSION_FETCH_FAILED",
|
|
609
641
|
/** Backend sent SESSION_DECLINED over SSE; session ended before completion. */
|
|
610
642
|
SESSION_DECLINED = "SESSION_DECLINED",
|
|
643
|
+
/**
|
|
644
|
+
* The backend cancelled the session (`SESSION_CANCELLED` over SSE,
|
|
645
|
+
* `status: CANCELLED` on `GET /sessions/:id`, or a `401` with
|
|
646
|
+
* `code: VOB-40103` on any request). Not a verdict on the person:
|
|
647
|
+
* the session was closed on Velion's side (e.g. `WORKFLOW_VERSION_RETIRED`
|
|
648
|
+
* when a new workflow version is published forcing it). The session token
|
|
649
|
+
* is revoked and the SDK sends no further requests; create a new session
|
|
650
|
+
* to let the person start again. `cancelReason` carries the backend reason.
|
|
651
|
+
*/
|
|
652
|
+
SESSION_CANCELLED = "SESSION_CANCELLED",
|
|
611
653
|
/**
|
|
612
654
|
* A step was completed but the backend did not route the session to the
|
|
613
655
|
* next one within `routingTimeoutMs` (default 120 s): no `ROUTING_COMMAND`
|
|
@@ -651,6 +693,14 @@ export declare enum SdkErrorCode {
|
|
|
651
693
|
* page that hosts the SDK, or set allowEmbedded: true if embedding is intentional.
|
|
652
694
|
*/
|
|
653
695
|
INSECURE_EMBED = "INSECURE_EMBED",
|
|
696
|
+
/**
|
|
697
|
+
* The session reached a step this SDK version cannot render: a step code it
|
|
698
|
+
* does not know, or a `CUSTOM_FORM` with a required field of a type it does
|
|
699
|
+
* not know. `stepCode` and `stepKey` name the step. The flow stops with a
|
|
700
|
+
* "this version does not support the step" screen; the step is never
|
|
701
|
+
* skipped, since the backend would then decline the session. Update the SDK.
|
|
702
|
+
*/
|
|
703
|
+
UNSUPPORTED_STEP = "UNSUPPORTED_STEP",
|
|
654
704
|
/**
|
|
655
705
|
* The CDN-served runtime failed verification: the manifest could not be
|
|
656
706
|
* downloaded or its Ed25519 signature did not verify against the loader's
|
|
@@ -714,6 +764,12 @@ export declare interface SessionCreationResponse {
|
|
|
714
764
|
export declare interface SessionState {
|
|
715
765
|
/** Current runnable step reported by backend session state. */
|
|
716
766
|
currentStep?: OnboardingStep;
|
|
767
|
+
/**
|
|
768
|
+
* Key of `currentStep` inside the workflow (`current_step.step_key`, or the
|
|
769
|
+
* code when the backend does not send it). Identifies the instance the SDK
|
|
770
|
+
* answers to; the code only chooses the screen.
|
|
771
|
+
*/
|
|
772
|
+
currentStepKey?: string;
|
|
717
773
|
/** Step-specific config for `currentStep` from GET /sessions/:id `current_step.config`. */
|
|
718
774
|
currentStepConfig?: Record<string, unknown>;
|
|
719
775
|
/** Cached configs discovered from GET session and SSE `step_config`. */
|
|
@@ -735,6 +791,7 @@ export declare interface SessionState {
|
|
|
735
791
|
*/
|
|
736
792
|
stepReversibility?: Array<{
|
|
737
793
|
code: OnboardingStep;
|
|
794
|
+
stepKey: string;
|
|
738
795
|
reversible: boolean;
|
|
739
796
|
}>;
|
|
740
797
|
/**
|
|
@@ -758,8 +815,12 @@ export declare interface SessionState {
|
|
|
758
815
|
*/
|
|
759
816
|
export declare function setOpenCVBaseUrl(_url: string): void;
|
|
760
817
|
|
|
761
|
-
/**
|
|
762
|
-
|
|
818
|
+
/**
|
|
819
|
+
* Generic per-step runtime config map carried by session state and SSE, keyed
|
|
820
|
+
* by step key (equal to the step code except for `CUSTOM_FORM`, whose instances
|
|
821
|
+
* each have their own key).
|
|
822
|
+
*/
|
|
823
|
+
export declare type StepConfigMap = Partial<Record<string, Record<string, unknown>>>;
|
|
763
824
|
|
|
764
825
|
/** Select option used by configurable step fields (e.g. HUMAN_EXTENDED_INFO gender/civil_status). */
|
|
765
826
|
declare interface StepFieldOption {
|
|
@@ -884,6 +945,14 @@ export declare interface TermsAndConditionsSubmitPayload {
|
|
|
884
945
|
acceptances: TermsAndConditionsAcceptancePayload[];
|
|
885
946
|
}
|
|
886
947
|
|
|
948
|
+
/**
|
|
949
|
+
* Closed catalog of fonts the SDK can load (`VelionTheme.fontId`). Each id maps,
|
|
950
|
+
* inside the runtime, to a Google Fonts stylesheet (weights 400, 500, 600, 700);
|
|
951
|
+
* `system` (the default) loads nothing and uses the platform font stack.
|
|
952
|
+
* The same list is shared with the React Native SDK (OSDKR-45).
|
|
953
|
+
*/
|
|
954
|
+
export declare const VELION_FONT_IDS: readonly ["system", "inter", "roboto", "open-sans", "montserrat", "poppins", "nunito", "source-sans-3", "work-sans", "ibm-plex-sans", "dm-sans"];
|
|
955
|
+
|
|
887
956
|
export declare const VELION_MSG_ERROR: "VELION_ERROR";
|
|
888
957
|
|
|
889
958
|
/**
|
|
@@ -904,9 +973,25 @@ export declare const VELION_MSG_INIT: "VELION_INIT";
|
|
|
904
973
|
*/
|
|
905
974
|
export declare const VELION_MSG_LIVENESS_VIDEO_UPLOADED: "VELION_LIVENESS_VIDEO_UPLOADED";
|
|
906
975
|
|
|
976
|
+
/** Iframe → parent: the visited steps changed ({@link VelionProgress}). Forwarded to `onProgress`. */
|
|
977
|
+
export declare const VELION_MSG_PROGRESS: "VELION_PROGRESS";
|
|
978
|
+
|
|
907
979
|
/** Message types: iframe (CDN app) sends to parent (loader). */
|
|
908
980
|
export declare const VELION_MSG_READY: "VELION_READY";
|
|
909
981
|
|
|
982
|
+
/**
|
|
983
|
+
* Iframe → parent, only with `presentation: 'embedded'`: the height in CSS
|
|
984
|
+
* pixels the runtime content needs. The loader sets it on the iframe so the host
|
|
985
|
+
* page scrolls instead of the iframe.
|
|
986
|
+
*/
|
|
987
|
+
export declare const VELION_MSG_RESIZE: "VELION_RESIZE";
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Iframe → parent: one SSE session event, without the step config and the
|
|
991
|
+
* user's data ({@link VelionSessionEventPayload}). Forwarded to `onSessionEvent`.
|
|
992
|
+
*/
|
|
993
|
+
export declare const VELION_MSG_SESSION_EVENT: "VELION_SESSION_EVENT";
|
|
994
|
+
|
|
910
995
|
export declare const VELION_MSG_STEP_CHANGE: "VELION_STEP_CHANGE";
|
|
911
996
|
|
|
912
997
|
export declare const VELION_MSG_STEP_COMPLETE: "VELION_STEP_COMPLETE";
|
|
@@ -964,8 +1049,20 @@ export declare interface VelionCallbacks {
|
|
|
964
1049
|
/**
|
|
965
1050
|
* Fires for each SSE event from GET /sessions/:sessionId/events
|
|
966
1051
|
* (e.g. STEP_UPDATED, SESSION_APPROVED).
|
|
1052
|
+
*
|
|
1053
|
+
* Through the loader the event crosses the iframe as `VELION_SESSION_EVENT`
|
|
1054
|
+
* without `step_config` and `step_result` (the step's configuration and the
|
|
1055
|
+
* user's own data); see {@link VelionSessionEventPayload}.
|
|
967
1056
|
*/
|
|
968
1057
|
onSessionEvent?: (event: OnboardingSessionEvent) => void;
|
|
1058
|
+
/**
|
|
1059
|
+
* Fires whenever the list of steps the user went through changes: on every
|
|
1060
|
+
* step change and on every step status update. Lists only the steps already
|
|
1061
|
+
* visited plus the current one, in workflow order, following the branch the
|
|
1062
|
+
* session took; steps the user never sees (fingerprint, face match, AML) are
|
|
1063
|
+
* left out. Carries no personal data: see {@link VelionProgress}.
|
|
1064
|
+
*/
|
|
1065
|
+
onProgress?: (progress: VelionProgress) => void;
|
|
969
1066
|
/**
|
|
970
1067
|
* Called when the user taps the dismiss control on the final result screen
|
|
971
1068
|
* (only when the final result screen is shown). `onSuccess` has already run.
|
|
@@ -1040,7 +1137,8 @@ export declare interface VelionConfig extends VelionCallbacks {
|
|
|
1040
1137
|
/**
|
|
1041
1138
|
* ISO-8601 expiry timestamp of the sessionToken. If provided, the SDK may
|
|
1042
1139
|
* check expiration before requests and emit SESSION_EXPIRED without a round-trip.
|
|
1043
|
-
* When the backend returns 401/403, the SDK emits SESSION_EXPIRED anyway
|
|
1140
|
+
* When the backend returns 401/403, the SDK emits SESSION_EXPIRED anyway,
|
|
1141
|
+
* except for the cancelled-session 401 (`VOB-40103`), which is SESSION_CANCELLED.
|
|
1044
1142
|
*/
|
|
1045
1143
|
expiresAt?: string;
|
|
1046
1144
|
/**
|
|
@@ -1085,6 +1183,19 @@ export declare interface VelionConfig extends VelionCallbacks {
|
|
|
1085
1183
|
* @default true
|
|
1086
1184
|
*/
|
|
1087
1185
|
showProgressBar?: boolean;
|
|
1186
|
+
/**
|
|
1187
|
+
* How the SDK sits in the page.
|
|
1188
|
+
* - `'standalone'` (default): the SDK paints its own surface — background,
|
|
1189
|
+
* card shadows, side padding and progress bar — and fills its container.
|
|
1190
|
+
* - `'embedded'`: the SDK blends into the host page. No background (the host
|
|
1191
|
+
* page shows through), no card shadow, no side padding, no progress bar and
|
|
1192
|
+
* no viewport-tall minimum height. Through the loader, the iframe follows the
|
|
1193
|
+
* height of its content (`VELION_RESIZE`), so the page scrolls instead of the
|
|
1194
|
+
* iframe; the container needs no height of its own.
|
|
1195
|
+
*
|
|
1196
|
+
* @default 'standalone'
|
|
1197
|
+
*/
|
|
1198
|
+
presentation?: VelionPresentation;
|
|
1088
1199
|
/**
|
|
1089
1200
|
* Overrides for default titles, messages, and dismiss button on the final result screen.
|
|
1090
1201
|
* Only used when the final result screen is shown (`showFinalResultScreen` is not `false`).
|
|
@@ -1221,6 +1332,8 @@ export declare interface VelionFinalResultScreenTexts {
|
|
|
1221
1332
|
rejected?: VelionFinalResultStatusCopy;
|
|
1222
1333
|
/** Copy when {@link OnboardingResult.status} is `DECLINED`. */
|
|
1223
1334
|
declined?: VelionFinalResultStatusCopy;
|
|
1335
|
+
/** Copy for the screen shown when the backend cancels the session (`SESSION_CANCELLED`). */
|
|
1336
|
+
cancelled?: VelionFinalResultStatusCopy;
|
|
1224
1337
|
/** Primary button label (e.g. "Entendido" / "Got it"). */
|
|
1225
1338
|
dismissLabel?: string;
|
|
1226
1339
|
}
|
|
@@ -1233,6 +1346,9 @@ export declare interface VelionFinalResultStatusCopy {
|
|
|
1233
1346
|
message?: string;
|
|
1234
1347
|
}
|
|
1235
1348
|
|
|
1349
|
+
/** One id of {@link VELION_FONT_IDS}. */
|
|
1350
|
+
export declare type VelionFontId = (typeof VELION_FONT_IDS)[number];
|
|
1351
|
+
|
|
1236
1352
|
/** Payload for VELION_INIT: full config (iframe runs with containerId overwritten to root id). */
|
|
1237
1353
|
export declare type VelionInitPayload = VelionConfig;
|
|
1238
1354
|
|
|
@@ -1286,7 +1402,7 @@ export declare interface VelionMessage<T = unknown> {
|
|
|
1286
1402
|
payload: T;
|
|
1287
1403
|
}
|
|
1288
1404
|
|
|
1289
|
-
export declare type VelionMessageType = typeof VELION_MSG_INIT | typeof VELION_MSG_READY | typeof VELION_MSG_SUCCESS | typeof VELION_MSG_ERROR | typeof VELION_MSG_STEP_CHANGE | typeof VELION_MSG_STEP_COMPLETE | typeof VELION_MSG_TOKEN_EXPIRED | typeof VELION_MSG_EXIT | typeof VELION_MSG_LIVENESS_VIDEO_UPLOADED | typeof VELION_MSG_TOKEN;
|
|
1405
|
+
export declare type VelionMessageType = typeof VELION_MSG_INIT | typeof VELION_MSG_READY | typeof VELION_MSG_SUCCESS | typeof VELION_MSG_ERROR | typeof VELION_MSG_STEP_CHANGE | typeof VELION_MSG_STEP_COMPLETE | typeof VELION_MSG_TOKEN_EXPIRED | typeof VELION_MSG_EXIT | typeof VELION_MSG_LIVENESS_VIDEO_UPLOADED | typeof VELION_MSG_TOKEN | typeof VELION_MSG_RESIZE | typeof VELION_MSG_PROGRESS | typeof VELION_MSG_SESSION_EVENT;
|
|
1290
1406
|
|
|
1291
1407
|
export declare class VelionOnboarding {
|
|
1292
1408
|
private readonly config;
|
|
@@ -1348,6 +1464,43 @@ export declare class VelionOnboarding {
|
|
|
1348
1464
|
destroy(): void;
|
|
1349
1465
|
}
|
|
1350
1466
|
|
|
1467
|
+
/** Values of {@link VelionConfig.presentation}. */
|
|
1468
|
+
export declare type VelionPresentation = 'standalone' | 'embedded';
|
|
1469
|
+
|
|
1470
|
+
/** Steps the user went through, delivered to `onProgress` and as `VELION_PROGRESS`. */
|
|
1471
|
+
export declare interface VelionProgress {
|
|
1472
|
+
/** Visited steps plus the current one, in workflow order. */
|
|
1473
|
+
steps: VelionProgressStep[];
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/** Payload for VELION_PROGRESS. */
|
|
1477
|
+
export declare type VelionProgressPayload = VelionProgress;
|
|
1478
|
+
|
|
1479
|
+
/** One visited step in {@link VelionProgress}. Never carries what the user entered. */
|
|
1480
|
+
export declare interface VelionProgressStep {
|
|
1481
|
+
/** Step type (e.g. `HUMAN_BASIC_INFO`). */
|
|
1482
|
+
code: string;
|
|
1483
|
+
/** Key of the step inside the workflow; equals `code` unless the backend sends `step_key`. */
|
|
1484
|
+
stepKey: string;
|
|
1485
|
+
/** Display name the backend gives the step, when it sends one. */
|
|
1486
|
+
name?: string;
|
|
1487
|
+
/** Step status; see {@link VelionProgressStepStatus}. */
|
|
1488
|
+
status: VelionProgressStepStatus;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/**
|
|
1492
|
+
* Status of a step in {@link VelionProgress}. Matches the backend
|
|
1493
|
+
* `OnboardingStepStatus`; at most one step is `IN_PROGRESS`: the one the user
|
|
1494
|
+
* is on.
|
|
1495
|
+
*/
|
|
1496
|
+
export declare type VelionProgressStepStatus = 'PENDING' | 'IN_PROGRESS' | 'PROCESSING' | 'COMPLETED' | 'SKIPPED' | 'FAILED' | 'MANUAL_REVIEW';
|
|
1497
|
+
|
|
1498
|
+
/** Payload for VELION_RESIZE. */
|
|
1499
|
+
export declare interface VelionResizePayload {
|
|
1500
|
+
/** Height of the runtime content in CSS pixels (a positive integer). */
|
|
1501
|
+
height: number;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1351
1504
|
/**
|
|
1352
1505
|
* Per-step overrides for the retry dialog shown when the backend emits a
|
|
1353
1506
|
* `ROUTING_COMMAND / RETRY_STEP` (the step failed but the retry quota is not
|
|
@@ -1375,6 +1528,12 @@ export declare interface VelionSessionDeclinedReasonMessages {
|
|
|
1375
1528
|
*/
|
|
1376
1529
|
export declare type VelionSessionDeclinedReasonTexts = Record<string, VelionSessionDeclinedReasonMessages>;
|
|
1377
1530
|
|
|
1531
|
+
/**
|
|
1532
|
+
* Payload for VELION_SESSION_EVENT: the SSE event without `step_config` (the
|
|
1533
|
+
* step's workflow configuration) and `step_result` (data the user entered).
|
|
1534
|
+
*/
|
|
1535
|
+
export declare type VelionSessionEventPayload = Omit<OnboardingSessionEvent, 'step_config' | 'step_result'>;
|
|
1536
|
+
|
|
1378
1537
|
/** Payload for VELION_STEP_CHANGE. */
|
|
1379
1538
|
export declare interface VelionStepChangePayload {
|
|
1380
1539
|
step: OnboardingStep;
|
|
@@ -1413,8 +1572,22 @@ export declare interface VelionTheme {
|
|
|
1413
1572
|
textSecondaryColor?: string;
|
|
1414
1573
|
/** Border radius for cards, buttons, and inputs. */
|
|
1415
1574
|
borderRadius?: string;
|
|
1416
|
-
/**
|
|
1575
|
+
/**
|
|
1576
|
+
* Free CSS `font-family` value. The SDK does not load it: it renders only when
|
|
1577
|
+
* the font is already available where the SDK runs. With the loader the SDK
|
|
1578
|
+
* runs in an iframe that does not see the host page's fonts, so only system
|
|
1579
|
+
* fonts work there; use {@link fontId} to have the SDK load a font.
|
|
1580
|
+
* Ignored when a valid `fontId` is set.
|
|
1581
|
+
*/
|
|
1417
1582
|
fontFamily?: string;
|
|
1583
|
+
/**
|
|
1584
|
+
* Font the SDK loads by itself, chosen from the closed catalog
|
|
1585
|
+
* {@link VELION_FONT_IDS}. The id is mapped to a stylesheet URL inside the
|
|
1586
|
+
* runtime; a URL never comes from the configuration. Any other value renders
|
|
1587
|
+
* the system font stack (and `fontFamily` is ignored) and logs a warning.
|
|
1588
|
+
* Without `fontId`, `fontFamily` applies as before.
|
|
1589
|
+
*/
|
|
1590
|
+
fontId?: VelionFontId;
|
|
1418
1591
|
/** Color used for error states and destructive actions. */
|
|
1419
1592
|
errorColor?: string;
|
|
1420
1593
|
/** Color used for success confirmations. */
|
|
@@ -1423,8 +1596,19 @@ export declare interface VelionTheme {
|
|
|
1423
1596
|
warningColor?: string;
|
|
1424
1597
|
/** Border color for input fields and separators. */
|
|
1425
1598
|
borderColor?: string;
|
|
1426
|
-
/** Box shadow definition for elevated elements (cards, modals). */
|
|
1599
|
+
/** Box shadow definition for elevated elements (cards, modals). Not applied with `presentation: 'embedded'`. */
|
|
1427
1600
|
cardShadow?: string;
|
|
1601
|
+
/**
|
|
1602
|
+
* Minimum height of text inputs and selects, in pixels: `'48px'`, or a number
|
|
1603
|
+
* without unit (`48` or `'48'`). Any other unit or value keeps the default,
|
|
1604
|
+
* `'44px'`. Backend configuration name: `input_height`.
|
|
1605
|
+
*/
|
|
1606
|
+
inputHeight?: number | string;
|
|
1607
|
+
/**
|
|
1608
|
+
* Minimum height of the action buttons, with the same format and default as
|
|
1609
|
+
* {@link inputHeight}. Backend configuration name: `button_height`.
|
|
1610
|
+
*/
|
|
1611
|
+
buttonHeight?: number | string;
|
|
1428
1612
|
/**
|
|
1429
1613
|
* When `true`, the round icon that sits above each step's title is hidden.
|
|
1430
1614
|
* Only the title and subtitle are rendered. Useful when the host UI already
|
package/dist/velion-sdk.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,r,n)=>((t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n)(t,"symbol"!=typeof r?r+"":r,n),r=/* @__PURE__ */(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(r||{}),n=/* @__PURE__ */(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(n||{});const i="VELION_INIT",s="VELION_READY",o="VELION_SUCCESS",a="VELION_ERROR",c="VELION_STEP_CHANGE",l="VELION_STEP_COMPLETE",f="VELION_TOKEN_EXPIRED",d="VELION_EXIT",u="VELION_LIVENESS_VIDEO_UPLOADED",h="VELION_TOKEN",E=Object.freeze,g=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,y=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,m=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,R=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,p=0x6666666666666666666666666666666666666666666666666666666666666658n,I=g-1n,N=E({p:g,n:y,h:8n,a:I,d:m,Gx:R,Gy:p}),w=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,O=(e,t,r="")=>{if(w(e)&&(void 0===t||e.length===t))return e;const n=w(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},T=(e,t)=>e.toString(16).padStart(t,"0"),b=e=>{let t="";for(const r of O(e))t+=T(r,2);return t},A=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},_=(...e)=>{let t=0;for(const i of e)t+=O(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},S=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},D=(e,t=g)=>(e%=t)>=0n?e:t+e,v=(1n<<255n)-1n,L=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&v);return t=19n*(t>>255n)+(t&v),t%g},U=async(e,...t)=>O(await(e=>{const t=K[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(_(...t)),64,"digest"),C=e=>{if(e instanceof x)return e;throw new TypeError("Point expected")},k=2n**256n,$=class e{constructor(e,r,n,i){t(this,"X"),t(this,"Y"),t(this,"Z"),t(this,"T");const s=k;this.X=S(e,0n,s),this.Y=S(r,0n,s),this.Z=S(n,1n,s),this.T=S(i,0n,s),E(this)}static CURVE(){return N}static fromAffine(t){return new e(t.x,t.y,1n,L(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(O(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=F(n);r||S(s,0n,g);const o=L(s*s),a=D(o-1n),c=L(m*o+1n);let{isValid:l,value:f}=H(a,c);if(!l)throw new Error("bad point: y not sqrt");const d=!!(128&i);if(!r&&0n===f&&d)throw new Error("bad point: x==0, isLastByteOdd");return d!==!!(1n&f)&&(f=D(-f)),new e(f,s,1n,L(f*s))}static fromHex(t,r){return e.fromBytes(A(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=I,t=m;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=L(r*r),a=L(n*n),c=L(i*i),l=L(c*c),f=L(o*e);if(L(c*(f+a))!==D(l+L(t*L(o*a))))throw new Error("bad point: equation left != right (1)");if(L(r*n)!==L(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=C(e);return L(t*o)===L(i*n)&&L(r*o)===L(s*n)}is0(){return this.equals(P)}negate(){return new e(D(-this.X),this.Y,this.Z,D(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=I,s=L(t*t),o=L(r*r),a=L(2n*n*n),c=L(i*s),l=D(t+r),f=D(L(l*l)-s-o),d=D(c+o),u=D(d-a),h=D(c-o),E=L(f*u),g=L(d*h),y=L(f*h),m=L(u*d);return new e(E,g,m,y)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=C(t),f=I,d=m,u=L(r*o),h=L(n*a),E=L(L(s*d)*l),g=L(i*c),y=D(L(D(r+n)*D(o+a))-u-h),R=D(g-E),p=D(g+E),N=D(h-L(f*u)),w=L(y*R),O=L(p*N),T=L(y*N),b=L(R*p);return new e(w,O,b,T)}subtract(e){return this.add(C(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return P;if(S(e,1n,y),!t&&this.is0())return P;if(1n===e)return this;if(this.equals(M))return q(e).p;let r=P,n=M,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(P))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=D(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return D(i,t)})(r,g);if(1n!==L(r*n))throw new Error("invalid inverse");return{x:L(e*n),y:L(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=V(t);return r[31]|=1n&e?128:0,r}toHex(){return b(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(y/2n,!1).double().add(this).is0()}};t($,"BASE"),t($,"ZERO");let x=$;const M=new x(R,p,1n,D(R*p)),P=new x(0n,1n,1n,0n);x.BASE=M,x.ZERO=P;const V=e=>A(T(S(e,0n,k),64)).reverse(),F=e=>BigInt("0x"+b(Uint8Array.from(O(e)).reverse())),B=(e,t)=>{let r=e;for(;t-- >0;)r=L(r*r);return r},W=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,H=(e,t)=>{const r=L(t*L(t*t)),n=L(L(r*r)*t),i=(e=>{const t=L(e*e),r=L(t*e),n=L(B(r,2)*r),i=L(B(n,1)*e),s=L(B(i,5)*i),o=L(B(s,10)*s),a=L(B(o,20)*o),c=L(B(a,40)*a),l=L(B(c,80)*c),f=L(B(l,80)*c),d=L(B(f,10)*s);return L(B(d,2)*e)})(L(e*n));let s=L(e*L(r*i));const o=L(t*L(s*s)),a=s,c=L(s*W),l=o===e,f=o===D(-e),d=o===D(-e*W);return l&&(s=a),(f||d)&&(s=c),1n==(1n&D(s))&&(s=D(-s)),{isValid:l||f,value:s}},Y=e=>{return t=F(e),D(t,y);var t},z=(e,t,r,n)=>{e=O(e,64,"signature"),t=O(t,void 0,"message"),r=O(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=F(e.subarray(32,64));let a,c,l,f=Uint8Array.of(),d=!1;try{a=x.fromBytes(r,i),c=x.fromBytes(s,i),l=M.multiply(o,!1),f=_(s,r,t),d=!0}catch(u){}return[f,e=>{if(!d)return!1;if(!i&&a.isSmallOrder())return!1;const t=Y(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},G=async(e,t,r,n={})=>(async e=>e[1](await U("sha512Async",e[0])))(z(e,t,r,n)),K={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",_(e)))},sha512:void 0};let X;const Z=(e,t)=>{const r=t.negate();return e?r:t},q=e=>{const t=X||(X=(()=>{const e=[];let t,r=M;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=P,n=M;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(Z(c,t[o])):r=r.add(Z(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},j="oX1GwUEjM7Zj9ShtUekgNRXuAUhwgQP5Gf5yYn/xpx4=";function J(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function Q(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function ee(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=J(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return Q(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return G(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}function te(e,t,r="1.1.0-beta.7"){if(e.version!==t)return{ok:!1,reason:"policy",detail:`manifest is for loader major "${e.version}", this loader is "${t}"`};if("string"!=typeof e.appVersion)return{ok:!1,reason:"policy",detail:"manifest has no appVersion"};const n=function(e,t){const r=e=>{const t=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(e.trim());return t?{core:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null},n=r(e),i=r(t);if(!n||!i)return Number.NaN;for(let s=0;s<3;s++){const e=(n.core[s]??0)-(i.core[s]??0);if(0!==e)return Math.sign(e)}if(0===n.pre.length||0===i.pre.length)return Math.sign(i.pre.length-n.pre.length);for(let s=0;s<Math.max(n.pre.length,i.pre.length);s++){const e=n.pre[s],t=i.pre[s];if(void 0===e)return-1;if(void 0===t)return 1;const r=/^\d+$/.test(e),o=/^\d+$/.test(t);if(r&&o){const r=Number(e)-Number(t);if(0!==r)return Math.sign(r)}else{if(r!==o)return r?-1:1;if(e!==t)return e<t?-1:1}}return 0}(e.appVersion,r);return Number.isNaN(n)?{ok:!1,reason:"policy",detail:`unparseable appVersion "${e.appVersion}"`}:n<0?{ok:!1,reason:"policy",detail:`runtime ${e.appVersion} is older than the minimum ${r} (rollback refused)`}:"string"==typeof e.entryIntegrity&&e.entryIntegrity.startsWith("sha384-")?null:{ok:!1,reason:"policy",detail:"manifest does not name the entry digest (entryIntegrity)"}}async function re(e){const t=new Uint8Array(await crypto.subtle.digest("SHA-384",e));let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]??0);return`sha384-${btoa(r)}`}function ne(e,t){return e.trim().split(/\s+/).some(e=>e.split("?")[0]===t)}async function ie(e,t){try{const r=await fetch(e,{credentials:"omit",redirect:"error",...t&&{cache:"no-cache"}});return r.ok?await r.arrayBuffer():{ok:!1,reason:"unavailable",detail:`HTTP ${r.status} for ${e}`}}catch(r){return{ok:!1,reason:"unavailable",detail:`${e}: ${r.message}`}}}const se="https://static.velion.la/sdk/onboarding/v1";function oe(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ae=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","finalResultScreenTexts","routingTimeoutMs"];class ce{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.initSent=!1,this.iframeReloaded=!1,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:n.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:n.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:n.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??se).replace(/\/$/,"");if(!oe(t))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!oe(this.config.apiUrl))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:n.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const E=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;if(this.iframeReloaded)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case s:this.status="RUNNING";break;case o:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case a:this.status="ERROR",this.config.onError?.(t.payload);break;case c:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case l:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case d:this.status="EXITED",this.config.onExit?.(t.payload);break;case u:this.config.onLivenessVideoUploaded?.(t.payload);break;case f:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:h,payload:e}),()=>{this.config.onError?.({code:n.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:n.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",E),this.messageHandler=E,this.iframe=r,e.replaceChildren(r),this.attachIframeHeightSync(e,r);const g=await this.resolveManifest(t);if(!g)return;const{manifest:y}=g;if(!(await this.verifyRuntime(t,g)))return;if("INITIALIZING"!==this.status)return;const m=y.entry.startsWith("/")?y.entry:`/${y.entry}`;return new Promise(e=>{r.onload=()=>{if(function(e){try{return"about:blank"===e.contentWindow?.location.href}catch{return!1}}(r))return;if(this.initSent)return void this.handleIframeReload();if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:"Iframe failed to load."}),void e();const s=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ae){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let o;try{o=JSON.parse(JSON.stringify(s))}catch{o=s}this.sendToIframe({type:i,payload:o}),this.initSent=!0,this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${m}`})}handleIframeReload(){this.iframeReloaded=!0,this.clearReadyTimer(),"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:"The onboarding iframe reloaded after the session started. The loader does not resend the session token to a document it did not verify; call destroy() and start a new instance to resume from the current step."}))}async verifyRuntime(e,t){const{manifest:r,signed:i,synthesized:s}=t;if(s)return!0;if(i){const t=te(r,"v1");if(t)return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" is signed but not acceptable: ${t.detail}. Refusing to load the iframe.`}),!1}else if("string"!=typeof r.entryIntegrity)return!0;let o;try{o=await async function(e,t){if("string"!=typeof t.entryIntegrity)return{ok:!1,reason:"integrity",detail:"manifest does not name the entry digest"};if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unavailable",detail:"crypto.subtle is unavailable"};const r=t.entry.startsWith("/")?t.entry:`/${t.entry}`,n=`${e}${r}`,i=new URL(e).origin,s=await ie(n,!0);if(!(s instanceof ArrayBuffer))return s;const o=await re(s);if(!ne(t.entryIntegrity,o))return{ok:!1,reason:"integrity",detail:`${r} does not match the signed manifest (got ${o})`};const a=(new DOMParser).parseFromString((new TextDecoder).decode(s),"text/html"),c=[];a.querySelectorAll("script[src]").forEach(e=>{c.push({url:e.getAttribute("src")??"",integrity:e.getAttribute("integrity")})}),a.querySelectorAll("link[href]").forEach(e=>{const t=(e.getAttribute("rel")??"").toLowerCase().split(/\s+/);(t.includes("modulepreload")||t.includes("stylesheet")||t.includes("preload"))&&c.push({url:e.getAttribute("href")??"",integrity:e.getAttribute("integrity")})});for(const l of c){let e;try{e=new URL(l.url,n)}catch{return{ok:!1,reason:"integrity",detail:`invalid resource URL "${l.url}" in the entry`}}if(e.origin!==i)return{ok:!1,reason:"integrity",detail:`entry loads ${e.href} from another origin`};if(!l.integrity)return{ok:!1,reason:"integrity",detail:`entry loads ${e.pathname} without SRI`};const t=await ie(e.href,!1);if(!(t instanceof ArrayBuffer))return t;const r=await re(t);if(!ne(l.integrity,r))return{ok:!1,reason:"integrity",detail:`${e.pathname} does not match its SRI digest (got ${r})`}}return null}(e,r)}catch(a){o={ok:!1,reason:"integrity",detail:a.message}}return!o||(this.status="ERROR","unavailable"===o.reason?this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`Could not download the onboarding runtime from ${e} to verify it (${o.detail}). Check the CDN deploy and the network.`}):this.config.onError?.({code:n.INTEGRITY_FAILED,message:`The onboarding runtime at ${e} failed its integrity check: ${o.detail}. Refusing to load the iframe to protect the user.`}),!1)}async resolveManifest(e){let t;try{t=await async function(e,t=j){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=J((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await ee(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&j?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):{manifest:t.manifest,signed:t.signed,synthesized:!1};if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{manifest:{version:"legacy",buildTime:/* @__PURE__ */(new Date).toISOString(),entry:"/index.html"},signed:!1,synthesized:!0}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:n.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.2.0-beta.1"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}}function le(e){}export{r as CameraErrorCode,se as DEFAULT_CDN_URL,n as SdkErrorCode,a as VELION_MSG_ERROR,d as VELION_MSG_EXIT,i as VELION_MSG_INIT,u as VELION_MSG_LIVENESS_VIDEO_UPLOADED,s as VELION_MSG_READY,c as VELION_MSG_STEP_CHANGE,l as VELION_MSG_STEP_COMPLETE,o as VELION_MSG_SUCCESS,h as VELION_MSG_TOKEN,f as VELION_MSG_TOKEN_EXPIRED,ce as VelionOnboarding,le as setOpenCVBaseUrl};
|
|
1
|
+
var e=Object.defineProperty,t=(t,r,n)=>((t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n)(t,"symbol"!=typeof r?r+"":r,n),r=/* @__PURE__ */(e=>(e.PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.DEVICE_NOT_FOUND="CAMERA_DEVICE_NOT_FOUND",e.DEVICE_NOT_READABLE="CAMERA_DEVICE_NOT_READABLE",e.INSECURE_CONTEXT="CAMERA_INSECURE_CONTEXT",e.POLICY_BLOCKED="CAMERA_POLICY_BLOCKED",e.NOT_SUPPORTED="CAMERA_NOT_SUPPORTED",e.WEBVIEW_BLOCKED="CAMERA_WEBVIEW_BLOCKED",e.CONSTRAINT_ERROR="CAMERA_CONSTRAINT_ERROR",e.UNKNOWN="CAMERA_UNKNOWN_ERROR",e))(r||{}),n=/* @__PURE__ */(e=>(e.SESSION_INVALID="SESSION_INVALID",e.SESSION_EXPIRED="SESSION_EXPIRED",e.SESSION_FETCH_FAILED="SESSION_FETCH_FAILED",e.SESSION_DECLINED="SESSION_DECLINED",e.SESSION_CANCELLED="SESSION_CANCELLED",e.ROUTING_TIMEOUT="ROUTING_TIMEOUT",e.FINGERPRINT_FAILED="FINGERPRINT_FAILED",e.DOCUMENT_UPLOAD_FAILED="DOCUMENT_UPLOAD_FAILED",e.LIVENESS_FAILED="LIVENESS_FAILED",e.LIVENESS_INIT_FAILED="LIVENESS_INIT_FAILED",e.LIVENESS_VIDEO_UPLOAD_FAILED="LIVENESS_VIDEO_UPLOAD_FAILED",e.CAMERA_ERROR="CAMERA_ERROR",e.NETWORK_ERROR="NETWORK_ERROR",e.API_ERROR="API_ERROR",e.CONTAINER_NOT_FOUND="CONTAINER_NOT_FOUND",e.ALREADY_STARTED="ALREADY_STARTED",e.INSTANCE_DESTROYED="INSTANCE_DESTROYED",e.INSECURE_EMBED="INSECURE_EMBED",e.UNSUPPORTED_STEP="UNSUPPORTED_STEP",e.INTEGRITY_FAILED="INTEGRITY_FAILED",e.UNSUPPORTED_BROWSER="UNSUPPORTED_BROWSER",e.RUNTIME_LOAD_FAILED="RUNTIME_LOAD_FAILED",e.UNKNOWN="UNKNOWN",e))(n||{});const i=["system","inter","roboto","open-sans","montserrat","poppins","nunito","source-sans-3","work-sans","ibm-plex-sans","dm-sans"],s="VELION_INIT",o="VELION_READY",a="VELION_SUCCESS",c="VELION_ERROR",l="VELION_STEP_CHANGE",f="VELION_STEP_COMPLETE",d="VELION_TOKEN_EXPIRED",u="VELION_EXIT",h="VELION_LIVENESS_VIDEO_UPLOADED",E="VELION_TOKEN",g="VELION_RESIZE",y="VELION_PROGRESS",m="VELION_SESSION_EVENT",p=Object.freeze,R=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,I=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,N=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,O=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,b=0x6666666666666666666666666666666666666666666666666666666666666658n,T=R-1n,w=p({p:R,n:I,h:8n,a:T,d:N,Gx:O,Gy:b}),S=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&1===e.BYTES_PER_ELEMENT,A=(e,t,r="")=>{if(S(e)&&(void 0===t||e.length===t))return e;const n=S(e),i=(r?`"${r}" `:"")+"expected Uint8Array"+(void 0!==t?` of length ${t}`:"")+", got "+(n?`length=${e.length}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)},_=(e,t)=>e.toString(16).padStart(t,"0"),D=e=>{let t="";for(const r of A(e))t+=_(r,2);return t},v=e=>{const t="hex invalid";if("string"!=typeof e)throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);const r=new Uint8Array(e.length/2);for(let n=0,i=0;n<r.length;n++,i+=2){const t=e.charCodeAt(i),s=e.charCodeAt(i+1);r[n]=16*((15&t)+9*(t>>6))+(15&s)+9*(s>>6)}return r},L=(...e)=>{let t=0;for(const i of e)t+=A(i).length;const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r},U=(e,t,r,n="bad number: out of range")=>{if("bigint"!=typeof e)throw new TypeError(n);if(t<=e&&e<r)return e;throw new RangeError(n)},C=(e,t=R)=>(e%=t)>=0n?e:t+e,k=(1n<<255n)-1n,P=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=19n*(e>>255n)+(e&k);return t=19n*(t>>255n)+(t&k),t%R},$=async(e,...t)=>A(await(e=>{const t=q[e];if("function"!=typeof t)throw new Error("hashes."+e+" not set");return t})(e)(L(...t)),64,"digest"),x=e=>{if(e instanceof F)return e;throw new TypeError("Point expected")},M=2n**256n,V=class e{constructor(e,r,n,i){t(this,"X"),t(this,"Y"),t(this,"Z"),t(this,"T");const s=M;this.X=U(e,0n,s),this.Y=U(r,0n,s),this.Z=U(n,1n,s),this.T=U(i,0n,s),p(this)}static CURVE(){return w}static fromAffine(t){return new e(t.x,t.y,1n,P(t.x*t.y))}static fromBytes(t,r=!1){const n=((e,t="",r)=>Uint8Array.from(A(e,r,t)))(t,"point",32),i=n[31];n[31]=-129&i;const s=Y(n);r||U(s,0n,R);const o=P(s*s),a=C(o-1n),c=P(N*o+1n);let{isValid:l,value:f}=K(a,c);if(!l)throw new Error("bad point: y not sqrt");const d=!!(128&i);if(!r&&0n===f&&d)throw new Error("bad point: x==0, isLastByteOdd");return d!==!!(1n&f)&&(f=C(-f)),new e(f,s,1n,P(f*s))}static fromHex(t,r){return e.fromBytes(v(t),r)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const e=T,t=N;if(this.is0())throw new Error("bad point: ZERO");const{X:r,Y:n,Z:i,T:s}=this,o=P(r*r),a=P(n*n),c=P(i*i),l=P(c*c),f=P(o*e);if(P(c*(f+a))!==C(l+P(t*P(o*a))))throw new Error("bad point: equation left != right (1)");if(P(r*n)!==P(i*s))throw new Error("bad point: equation left != right (2)");return this}equals(e){const{X:t,Y:r,Z:n}=this,{X:i,Y:s,Z:o}=x(e);return P(t*o)===P(i*n)&&P(r*o)===P(s*n)}is0(){return this.equals(W)}negate(){return new e(C(-this.X),this.Y,this.Z,C(-this.T))}double(){const{X:t,Y:r,Z:n}=this,i=T,s=P(t*t),o=P(r*r),a=P(2n*n*n),c=P(i*s),l=C(t+r),f=C(P(l*l)-s-o),d=C(c+o),u=C(d-a),h=C(c-o),E=P(f*u),g=P(d*h),y=P(f*h),m=P(u*d);return new e(E,g,m,y)}add(t){const{X:r,Y:n,Z:i,T:s}=this,{X:o,Y:a,Z:c,T:l}=x(t),f=T,d=N,u=P(r*o),h=P(n*a),E=P(P(s*d)*l),g=P(i*c),y=C(P(C(r+n)*C(o+a))-u-h),m=C(g-E),p=C(g+E),R=C(h-P(f*u)),I=P(y*m),O=P(p*R),b=P(y*R),w=P(m*p);return new e(I,O,w,b)}subtract(e){return this.add(x(e).negate())}multiply(e,t=!0){if(!t&&0n===e)return W;if(U(e,1n,I),!t&&this.is0())return W;if(1n===e)return this;if(this.equals(B))return ee(e).p;let r=W,n=B,i=this;for(let s=0;t?s<256:e>0n;s++)1n&e?r=r.add(i):t&&(n=n.add(i)),i=i.double(),e>>=1n;return r}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){const{X:e,Y:t,Z:r}=this;if(this.equals(W))return{x:0n,y:1n};const n=((e,t)=>{if(0n===e)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let r=C(e,t),n=t,i=0n,s=1n;for(;0n!==r;){const e=n/r,t=n-r*e,o=i-s*e;n=r,r=t,i=s,s=o}if(1n!==n)throw new Error("invert: does not exist");return C(i,t)})(r,R);if(1n!==P(r*n))throw new Error("invalid inverse");return{x:P(e*n),y:P(t*n)}}toBytes(){const{x:e,y:t}=this.toAffine(),r=H(t);return r[31]|=1n&e?128:0,r}toHex(){return D(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(I/2n,!1).double().add(this).is0()}};t(V,"BASE"),t(V,"ZERO");let F=V;const B=new F(O,b,1n,C(O*b)),W=new F(0n,1n,1n,0n);F.BASE=B,F.ZERO=W;const H=e=>v(_(U(e,0n,M),64)).reverse(),Y=e=>BigInt("0x"+D(Uint8Array.from(A(e)).reverse())),G=(e,t)=>{let r=e;for(;t-- >0;)r=P(r*r);return r},z=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,K=(e,t)=>{const r=P(t*P(t*t)),n=P(P(r*r)*t),i=(e=>{const t=P(e*e),r=P(t*e),n=P(G(r,2)*r),i=P(G(n,1)*e),s=P(G(i,5)*i),o=P(G(s,10)*s),a=P(G(o,20)*o),c=P(G(a,40)*a),l=P(G(c,80)*c),f=P(G(l,80)*c),d=P(G(f,10)*s);return P(G(d,2)*e)})(P(e*n));let s=P(e*P(r*i));const o=P(t*P(s*s)),a=s,c=P(s*z),l=o===e,f=o===C(-e),d=o===C(-e*z);return l&&(s=a),(f||d)&&(s=c),1n==(1n&C(s))&&(s=C(-s)),{isValid:l||f,value:s}},X=e=>{return t=Y(e),C(t,I);var t},Z=(e,t,r,n)=>{e=A(e,64,"signature"),t=A(t,void 0,"message"),r=A(r,32,"publicKey");const i=(e=>{if(null===e||"object"!=typeof e)throw new TypeError("expected valid options object");return e.zip215??!0})(n),s=e.subarray(0,32),o=Y(e.subarray(32,64));let a,c,l,f=Uint8Array.of(),d=!1;try{a=F.fromBytes(r,i),c=F.fromBytes(s,i),l=B.multiply(o,!1),f=L(s,r,t),d=!0}catch(u){}return[f,e=>{if(!d)return!1;if(!i&&a.isSmallOrder())return!1;const t=X(e);return c.add(a.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},j=async(e,t,r,n={})=>(async e=>e[1](await $("sha512Async",e[0])))(Z(e,t,r,n)),q={sha512Async:async e=>{const t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",L(e)))},sha512:void 0};let J;const Q=(e,t)=>{const r=t.negate();return e?r:t},ee=e=>{const t=J||(J=(()=>{const e=[];let t,r=B;for(let n=0;n<33;n++){t=r,e.push(t);for(let n=1;n<128;n++)t=t.add(r),e.push(t);r=t.double()}return e})());let r=W,n=B;for(let i=0;i<33;i++){let s=Number(255n&e);e>>=8n,s>128&&(s-=256,e+=1n);const o=128*i,a=o+Math.abs(s)-1,c=i%2!=0,l=s<0;0===s?n=n.add(Q(c,t[o])):r=r.add(Q(l,t[a]))}if(0n!==e)throw new Error("invalid wnaf");return{p:r,f:n}},te="oX1GwUEjM7Zj9ShtUekgNRXuAUhwgQP5Gf5yYn/xpx4=";function re(e){const t=atob(e),r=new ArrayBuffer(t.length),n=new Uint8Array(r);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return r}function ne(e){if(e instanceof Error&&"NotSupportedError"===e.name)return!0;const t=e instanceof Error?e.message:String(e);return/unrecognized|not supported|unsupported/i.test(t)}async function ie(e,t,r){if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unsupported_browser",detail:"crypto.subtle is unavailable (insecure context or very old browser); the manifest signature cannot be verified."};const n=re(e),i=await async function(e,t,r){let n;try{n=await crypto.subtle.importKey("raw",e,{name:"Ed25519"},!1,["verify"])}catch(i){return ne(i)?{kind:"unsupported"}:{kind:"error",detail:`pubkey import failed: ${i.message}`}}try{return{kind:"verdict",valid:await crypto.subtle.verify({name:"Ed25519"},n,t,r)}}catch(i){return ne(i)?{kind:"unsupported"}:{kind:"error",detail:i.message}}}(n,t,r);if("error"===i.kind)return{ok:!1,reason:"invalid_signature",detail:i.detail};let s;if("verdict"===i.kind)s=i.valid;else try{s=await async function(e,t,r){return j(new Uint8Array(t),new Uint8Array(r),new Uint8Array(e),{zip215:!1})}(n,t,r)}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return s?null:{ok:!1,reason:"invalid_signature"}}function se(e,t,r="1.1.0-beta.7"){if(e.version!==t)return{ok:!1,reason:"policy",detail:`manifest is for loader major "${e.version}", this loader is "${t}"`};if("string"!=typeof e.appVersion)return{ok:!1,reason:"policy",detail:"manifest has no appVersion"};const n=function(e,t){const r=e=>{const t=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(e.trim());return t?{core:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]?t[4].split("."):[]}:null},n=r(e),i=r(t);if(!n||!i)return Number.NaN;for(let s=0;s<3;s++){const e=(n.core[s]??0)-(i.core[s]??0);if(0!==e)return Math.sign(e)}if(0===n.pre.length||0===i.pre.length)return Math.sign(i.pre.length-n.pre.length);for(let s=0;s<Math.max(n.pre.length,i.pre.length);s++){const e=n.pre[s],t=i.pre[s];if(void 0===e)return-1;if(void 0===t)return 1;const r=/^\d+$/.test(e),o=/^\d+$/.test(t);if(r&&o){const r=Number(e)-Number(t);if(0!==r)return Math.sign(r)}else{if(r!==o)return r?-1:1;if(e!==t)return e<t?-1:1}}return 0}(e.appVersion,r);return Number.isNaN(n)?{ok:!1,reason:"policy",detail:`unparseable appVersion "${e.appVersion}"`}:n<0?{ok:!1,reason:"policy",detail:`runtime ${e.appVersion} is older than the minimum ${r} (rollback refused)`}:"string"==typeof e.entryIntegrity&&e.entryIntegrity.startsWith("sha384-")?null:{ok:!1,reason:"policy",detail:"manifest does not name the entry digest (entryIntegrity)"}}async function oe(e){const t=new Uint8Array(await crypto.subtle.digest("SHA-384",e));let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]??0);return`sha384-${btoa(r)}`}function ae(e,t){return e.trim().split(/\s+/).some(e=>e.split("?")[0]===t)}async function ce(e,t){try{const r=await fetch(e,{credentials:"omit",redirect:"error",...t&&{cache:"no-cache"}});return r.ok?await r.arrayBuffer():{ok:!1,reason:"unavailable",detail:`HTTP ${r.status} for ${e}`}}catch(r){return{ok:!1,reason:"unavailable",detail:`${e}: ${r.message}`}}}const le="https://static.velion.la/sdk/onboarding/v1",fe=/* @__PURE__ */new Set(["PENDING","IN_PROGRESS","PROCESSING","COMPLETED","SKIPPED","FAILED","MANUAL_REVIEW"]);function de(e){try{const r=new URL(e);return"https:"===r.protocol||"http:"===r.protocol&&("localhost"===(t=r.hostname)||"127.0.0.1"===t||"::1"===t||t.endsWith(".local"))}catch{return!1}var t}const ue=["containerId","sessionId","sessionToken","apiUrl","expiresAt","theme","colorMode","locale","allowEmbedded","livenessShowIntro","livenessShowBackButton","fingerprintEndpoint","debug","googleMapsApiKey","showFinalResultScreen","showProgressBar","presentation","finalResultScreenTexts","routingTimeoutMs"];class he{constructor(e){this.status="IDLE",this.iframe=null,this.container=null,this.messageHandler=null,this.containerResizeObserver=null,this.iframeHeightWindowResizeHandler=null,this.cdnOrigin="",this.readyTimer=null,this.initSent=!1,this.iframeReloaded=!1,this.config=Object.freeze({...e})}clearReadyTimer(){null!==this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null)}armReadyTimer(e){this.clearReadyTimer();const t=this.config.runtimeReadyTimeoutMs??3e4;t>0&&(this.readyTimer=setTimeout(()=>{this.readyTimer=null,"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`The onboarding runtime at ${e} did not become ready within ${t} ms. Check that the CDN serves the assets referenced by its index.html and that the host page's Content-Security-Policy allows the runtime scripts.`}))},t))}async start(){if("DESTROYED"===this.status)return void this.config.onError?.({code:n.INSTANCE_DESTROYED,message:"This VelionOnboarding instance has been destroyed. Create a new instance to retry."});if("IDLE"!==this.status)return void this.config.onError?.({code:n.ALREADY_STARTED,message:"start() was called on an already-running SDK instance. Call destroy() before re-starting."});const e=document.getElementById(this.config.containerId);if(!e)return void this.config.onError?.({code:n.CONTAINER_NOT_FOUND,message:`No DOM element found with id="${this.config.containerId}". Ensure the element exists before calling start().`});const t=(this.config.cdnUrl??le).replace(/\/$/,"");if(!de(t))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure cdnUrl: "${t}". Must be https:// (http:// is allowed only for localhost).`});if(this.config.apiUrl&&!de(this.config.apiUrl))return void this.config.onError?.({code:n.UNKNOWN,message:`Insecure apiUrl: "${this.config.apiUrl}". Must be https:// (http:// is allowed only for localhost).`});if(this.cdnOrigin=function(e){try{return new URL(e).origin}catch{return""}}(t),!this.cdnOrigin)return void this.config.onError?.({code:n.UNKNOWN,message:`Invalid cdnUrl: ${t}. Must be a valid absolute URL.`});this.container=e,this.status="INITIALIZING";const r=document.createElement("iframe");r.setAttribute("title","Velion Onboarding"),r.setAttribute("allow","camera"),r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-modals"),r.setAttribute("referrerpolicy","no-referrer"),r.style.width="100%",r.style.border="none",r.style.display="block";const i="embedded"===this.config.presentation;i&&(r.style.colorScheme="normal",r.style.background="transparent");const p=e=>{if(e.origin!==this.cdnOrigin)return;if(e.source!==this.iframe?.contentWindow)return;if(this.iframeReloaded)return;const t=e.data;if(t&&"string"==typeof t.type)switch(this.clearReadyTimer(),t.type){case o:this.status="RUNNING";break;case a:this.status="COMPLETED",this.config.onSuccess?.(t.payload);break;case c:this.status="ERROR",this.config.onError?.(t.payload);break;case l:{const e=t.payload;this.config.onStepChange?.(e.step,e.stepIndex);break}case f:{const e=t.payload;this.config.onStepComplete?.(e.step);break}case u:this.status="EXITED",this.config.onExit?.(t.payload);break;case g:{if(!i)break;const e=function(e){const t=e?.height;return"number"==typeof t&&Number.isFinite(t)?t<=0||t>1e5?null:Math.ceil(t):null}(t.payload);null!==e&&this.iframe&&(this.iframe.style.height=`${e}px`);break}case y:{const e=function(e){const t=e?.steps;if(!Array.isArray(t))return null;const r=[];for(const n of t){if(null===n||"object"!=typeof n)continue;const{code:e,stepKey:t,name:i,status:s}=n;"string"==typeof e&&"string"==typeof t&&"string"==typeof s&&fe.has(s)&&r.push({code:e,stepKey:t,..."string"==typeof i&&{name:i},status:s})}return{steps:r}}(t.payload);e&&this.config.onProgress?.(e);break}case m:{const e=t.payload;if(null===e||"object"!=typeof e)break;const{step_config:r,step_result:n,...i}=e;this.config.onSessionEvent?.(i);break}case h:this.config.onLivenessVideoUploaded?.(t.payload);break;case d:{const e=this.config.onTokenExpired;e?e().then(e=>this.sendToIframe({type:E,payload:e}),()=>{this.config.onError?.({code:n.SESSION_EXPIRED,message:"Token refresh failed."})}):this.config.onError?.({code:n.SESSION_EXPIRED,message:"Session token expired. Provide onTokenExpired in config to refresh."});break}}};window.addEventListener("message",p),this.messageHandler=p,this.iframe=r,e.replaceChildren(r),i?r.style.height="240px":this.attachIframeHeightSync(e,r);const R=await this.resolveManifest(t);if(!R)return;const{manifest:I}=R;if(!(await this.verifyRuntime(t,R)))return;if("INITIALIZING"!==this.status)return;const N=I.entry.startsWith("/")?I.entry:`/${I.entry}`;return new Promise(e=>{r.onload=()=>{if(function(e){try{return"about:blank"===e.contentWindow?.location.href}catch{return!1}}(r))return;if(this.initSent)return void this.handleIframeReload();if(!this.iframe?.contentWindow)return this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:"Iframe failed to load."}),void e();const i=function(e){const t={containerId:"velion-sdk-root",allowEmbedded:!0};for(const r of ue){if("containerId"===r||"allowEmbedded"===r)continue;const n=e[r];void 0!==n&&"function"!=typeof n&&(t[r]=n)}return t}(this.config);let o;try{o=JSON.parse(JSON.stringify(i))}catch{o=i}this.sendToIframe({type:s,payload:o}),this.initSent=!0,this.status="RUNNING",this.armReadyTimer(t),e()},r.onerror=()=>{this.status="ERROR",this.config.onError?.({code:n.UNKNOWN,message:`Failed to load onboarding app from ${t}. Check cdnUrl and network.`}),e()},r.src=`${t}${N}`})}handleIframeReload(){this.iframeReloaded=!0,this.clearReadyTimer(),"RUNNING"===this.status&&(this.status="ERROR",this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:"The onboarding iframe reloaded after the session started. The loader does not resend the session token to a document it did not verify; call destroy() and start a new instance to resume from the current step."}))}async verifyRuntime(e,t){const{manifest:r,signed:i,synthesized:s}=t;if(s)return!0;if(i){const t=se(r,"v1");if(t)return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" is signed but not acceptable: ${t.detail}. Refusing to load the iframe.`}),!1}else if("string"!=typeof r.entryIntegrity)return!0;let o;try{o=await async function(e,t){if("string"!=typeof t.entryIntegrity)return{ok:!1,reason:"integrity",detail:"manifest does not name the entry digest"};if("function"!=typeof globalThis.crypto?.subtle?.digest)return{ok:!1,reason:"unavailable",detail:"crypto.subtle is unavailable"};const r=t.entry.startsWith("/")?t.entry:`/${t.entry}`,n=`${e}${r}`,i=new URL(e).origin,s=await ce(n,!0);if(!(s instanceof ArrayBuffer))return s;const o=await oe(s);if(!ae(t.entryIntegrity,o))return{ok:!1,reason:"integrity",detail:`${r} does not match the signed manifest (got ${o})`};const a=(new DOMParser).parseFromString((new TextDecoder).decode(s),"text/html"),c=[];a.querySelectorAll("script[src]").forEach(e=>{c.push({url:e.getAttribute("src")??"",integrity:e.getAttribute("integrity")})}),a.querySelectorAll("link[href]").forEach(e=>{const t=(e.getAttribute("rel")??"").toLowerCase().split(/\s+/);(t.includes("modulepreload")||t.includes("stylesheet")||t.includes("preload"))&&c.push({url:e.getAttribute("href")??"",integrity:e.getAttribute("integrity")})});for(const l of c){let e;try{e=new URL(l.url,n)}catch{return{ok:!1,reason:"integrity",detail:`invalid resource URL "${l.url}" in the entry`}}if(e.origin!==i)return{ok:!1,reason:"integrity",detail:`entry loads ${e.href} from another origin`};if(!l.integrity)return{ok:!1,reason:"integrity",detail:`entry loads ${e.pathname} without SRI`};const t=await ce(e.href,!1);if(!(t instanceof ArrayBuffer))return t;const r=await oe(t);if(!ae(l.integrity,r))return{ok:!1,reason:"integrity",detail:`${e.pathname} does not match its SRI digest (got ${r})`}}return null}(e,r)}catch(a){o={ok:!1,reason:"integrity",detail:a.message}}return!o||(this.status="ERROR","unavailable"===o.reason?this.config.onError?.({code:n.RUNTIME_LOAD_FAILED,message:`Could not download the onboarding runtime from ${e} to verify it (${o.detail}). Check the CDN deploy and the network.`}):this.config.onError?.({code:n.INTEGRITY_FAILED,message:`The onboarding runtime at ${e} failed its integrity check: ${o.detail}. Refusing to load the iframe to protect the user.`}),!1)}async resolveManifest(e){let t;try{t=await async function(e,t=te){let r,n,i,s;try{const t=await fetch(`${e}/manifest.json`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(404===t.status)return{ok:!1,reason:"unavailable"};if(!t.ok)return{ok:!1,reason:"unavailable",detail:`HTTP ${t.status}`};r=await t.arrayBuffer(),n=(new TextDecoder).decode(r)}catch(o){return{ok:!1,reason:"unavailable",detail:o.message}}try{if(i=JSON.parse(n),"string"!=typeof i.version||"string"!=typeof i.entry||"string"!=typeof i.buildTime)return{ok:!1,reason:"malformed"}}catch(o){return{ok:!1,reason:"malformed",detail:o.message}}if(!t)return{ok:!0,manifest:i,signed:!1};try{const t=await fetch(`${e}/manifest.sig`,{credentials:"omit",cache:"no-cache",redirect:"error"});if(!t.ok)return{ok:!1,reason:"invalid_signature",detail:`sig HTTP ${t.status}`};s=re((await t.text()).trim())}catch(o){return{ok:!1,reason:"invalid_signature",detail:o.message}}return await ie(t,s,r)||{ok:!0,manifest:i,signed:!0}}(e)}catch(r){return this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`Manifest verification crashed unexpectedly: ${r.message}`}),null}if(t.ok)return!t.signed&&te?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:"Internal: manifest reported as unsigned despite pubkey being set."}),null):{manifest:t.manifest,signed:t.signed,synthesized:!1};if("unavailable"===t.reason){return!0!==this.config.allowUnverifiedCdn?(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN at "${e}" did not expose /manifest.json. The loader is configured to require a signed manifest. If the CDN is migrating, set \`allowUnverifiedCdn: true\` on the loader config — but only as a temporary measure.`}),null):{manifest:{version:"legacy",buildTime:/* @__PURE__ */(new Date).toISOString(),entry:"/index.html"},signed:!1,synthesized:!0}}return"unsupported_browser"===t.reason?(this.status="ERROR",this.config.onError?.({code:n.UNSUPPORTED_BROWSER,message:"This browser cannot verify the signature of the Velion CDN manifest, so the onboarding cannot start. It needs a secure context (https) and WebCrypto (Chrome/Edge 67+, Firefox 68+, Safari 14+). "+(t.detail?`Detail: ${t.detail}`:"")}),null):(this.status="ERROR",this.config.onError?.({code:n.INTEGRITY_FAILED,message:`CDN manifest at "${e}/manifest.json" failed integrity check (${t.reason}). Refusing to load the iframe to protect the user. `+("detail"in t&&t.detail?`Detail: ${t.detail}`:"")}),null)}attachIframeHeightSync(e,t){const r=()=>{if(this.iframe!==t||this.container!==e)return;const r=e.clientHeight;r>0?(t.style.height=`${r}px`,t.style.minHeight=""):(t.style.height="min(85vh, 880px)",t.style.minHeight="")};r(),requestAnimationFrame(r),requestAnimationFrame(()=>{requestAnimationFrame(r)}),"undefined"!=typeof ResizeObserver?(this.containerResizeObserver=new ResizeObserver(r),this.containerResizeObserver.observe(e)):(this.iframeHeightWindowResizeHandler=r,window.addEventListener("resize",r))}detachIframeHeightSync(){this.containerResizeObserver&&(this.containerResizeObserver.disconnect(),this.containerResizeObserver=null),this.iframeHeightWindowResizeHandler&&(window.removeEventListener("resize",this.iframeHeightWindowResizeHandler),this.iframeHeightWindowResizeHandler=null)}sendToIframe(e){this.iframe?.contentWindow&&this.iframe.contentWindow.postMessage(e,this.cdnOrigin)}getStatus(){return this.status}static getVersion(){return"1.2.0-beta.11"}destroy(){"DESTROYED"!==this.status&&(this.clearReadyTimer(),this.detachIframeHeightSync(),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.container&&(this.iframe.remove(),this.container.replaceChildren()),this.iframe=null,this.container=null,this.status="DESTROYED")}}function Ee(e){}export{r as CameraErrorCode,le as DEFAULT_CDN_URL,n as SdkErrorCode,i as VELION_FONT_IDS,c as VELION_MSG_ERROR,u as VELION_MSG_EXIT,s as VELION_MSG_INIT,h as VELION_MSG_LIVENESS_VIDEO_UPLOADED,y as VELION_MSG_PROGRESS,o as VELION_MSG_READY,g as VELION_MSG_RESIZE,m as VELION_MSG_SESSION_EVENT,l as VELION_MSG_STEP_CHANGE,f as VELION_MSG_STEP_COMPLETE,a as VELION_MSG_SUCCESS,E as VELION_MSG_TOKEN,d as VELION_MSG_TOKEN_EXPIRED,he as VelionOnboarding,Ee as setOpenCVBaseUrl};
|
|
2
2
|
//# sourceMappingURL=velion-sdk.es.js.map
|