@regulaforensics/idv-capture-web 3.1.239 → 3.2.1-nightly

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 CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  The available component is `<idv-flow>`.
19
19
 
20
- The component is based on WebAssembly (compiled from our core C++ code and wrapped with JavaScript). The same code is used across all SDK packages, ensuring consistency between platforms.
20
+ The component designed to play the idv workflow of the platform , collect data from users , and send data to the platform .
21
21
 
22
22
  ## Before You Start
23
23
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,20 @@
1
+ import { CSSResult } from 'lit';
2
+ import { LitElement } from 'lit';
3
+ import { nothing } from 'lit';
4
+ import { TemplateResult } from 'lit-html';
5
+
1
6
  export declare type ApiKeyConnectionConfig = {
2
7
  baseUrl: string;
3
8
  apiKey: string;
4
9
  ttl?: number;
5
10
  };
6
11
 
12
+ declare type AuthTokenStoreData = {
13
+ apiKey: string;
14
+ authToken: string;
15
+ tokenExpiresAt: number;
16
+ };
17
+
7
18
  declare class BaseConfigureError extends BaseError {
8
19
  private static readonly MODULE;
9
20
  private static readonly ERROR_ENUM_NAME;
@@ -16,6 +27,18 @@ declare class BaseConfigureError extends BaseError {
16
27
  });
17
28
  }
18
29
 
30
+ declare class BaseConnectionError extends BaseError {
31
+ private static readonly MODULE;
32
+ private static readonly ERROR_ENUM_NAME;
33
+ private static readonly SHORT_CODE;
34
+ constructor({ errorCode, message, underlyingError, underlyingBaseError, }: {
35
+ errorCode: ConnectionError;
36
+ message?: string;
37
+ underlyingError?: string;
38
+ underlyingBaseError?: BaseError;
39
+ });
40
+ }
41
+
19
42
  declare class BaseDeinitializationError extends BaseError {
20
43
  private static readonly MODULE;
21
44
  private static readonly ERROR_ENUM_NAME;
@@ -28,7 +51,7 @@ declare class BaseDeinitializationError extends BaseError {
28
51
  });
29
52
  }
30
53
 
31
- declare class BaseError {
54
+ export declare class BaseError {
32
55
  errorCode: number | string;
33
56
  errorCodeKey: string;
34
57
  message?: string;
@@ -68,6 +91,11 @@ declare class BaseInitializationError extends BaseError {
68
91
  });
69
92
  }
70
93
 
94
+ export declare abstract class BaseModule<TModuleProps = unknown, TModulesConfig = unknown> extends HTMLElement {
95
+ abstract props: IdvModuleProps<TModuleProps, TModulesConfig> | null;
96
+ abstract setProps(config: IdvModuleProps<TModuleProps, TModulesConfig>): void;
97
+ }
98
+
71
99
  declare class BasePrepareWorkflowError extends BaseError {
72
100
  private static readonly MODULE;
73
101
  private static readonly ERROR_ENUM_NAME;
@@ -115,17 +143,51 @@ declare enum ConfigureError {
115
143
  SCENARIO_IN_PROGRESS = 3
116
144
  }
117
145
 
146
+ declare type ConnectionByApiKeyConfigCore = {
147
+ host: string;
148
+ isSecure?: boolean;
149
+ port?: number;
150
+ apiKey: string;
151
+ authToken?: string;
152
+ tokenExpiresAt?: number;
153
+ deviceDescriptor: {
154
+ ttl: number;
155
+ };
156
+ };
157
+
158
+ declare type ConnectionConfigCore = {
159
+ host: string;
160
+ isSecure?: boolean;
161
+ password: string;
162
+ port?: number;
163
+ userName: string;
164
+ };
165
+
118
166
  export declare enum ConnectionError {
119
167
  HTTP_ISSUE = 0,
120
168
  PROVIDER_ERROR = 1
121
169
  }
122
170
 
171
+ declare type ContinueSessionResults = SessionData | WorkflowResult | {
172
+ error?: BaseWorkflowError;
173
+ };
174
+
123
175
  export declare type CredentialConnectionConfig = {
124
176
  baseUrl: string;
125
177
  password: string;
126
178
  userName: string;
127
179
  };
128
180
 
181
+ declare type CurrentScreenConfig = {
182
+ templateId: string;
183
+ templateLayout?: Record<string, unknown>;
184
+ dataSource: Record<string, unknown> | null;
185
+ properties?: SessionPropertiesItem[];
186
+ sessionId?: string;
187
+ serviceToken?: string;
188
+ locale?: string;
189
+ } & Record<string, any>;
190
+
129
191
  export declare enum DeinitializationError {
130
192
  INITIALIZATION_REQUIRED = 0,
131
193
  SCENARIO_IN_PROGRESS = 3
@@ -135,6 +197,90 @@ export declare type DeinitializeCompletion = {
135
197
  error?: BaseDeinitializationError;
136
198
  };
137
199
 
200
+ declare type FetchErrorResult = {
201
+ code: FetchResultCode.HTTP_ISSUE | FetchResultCode.PROVIDER_ERROR | FetchResultCode.DECODING_FAILED;
202
+ data: FetchState;
203
+ };
204
+
205
+ declare enum FetchResultCode {
206
+ SUCCESS = 0,
207
+ HTTP_ISSUE = 4,
208
+ PROVIDER_ERROR = 5,
209
+ DECODING_FAILED = 6
210
+ }
211
+
212
+ declare type FetchState = {
213
+ httpCode: number;
214
+ method: string;
215
+ url: string;
216
+ what?: string;
217
+ };
218
+
219
+ declare type GeoCoords = {
220
+ lat: number;
221
+ lon: number;
222
+ };
223
+
224
+ declare type GetSessionStateNextStepConditionResult = {
225
+ data?: SessionData;
226
+ error?: BaseWorkflowError;
227
+ shouldRetry?: boolean;
228
+ };
229
+
230
+ declare type IdvBusinessLogicControllerProps = {
231
+ connectByUserPass: (config: ConnectionConfigCore) => Promise<{
232
+ error?: BaseConnectionError;
233
+ }>;
234
+ connectByApiKey: (config: ConnectionByApiKeyConfigCore) => Promise<{
235
+ error?: BaseTokenInitializationError;
236
+ workflows?: string[];
237
+ authToken?: string;
238
+ }>;
239
+ connectByUrl: (urlWithToken: string) => Promise<{
240
+ error?: BaseTokenInitializationError;
241
+ workflows: string[];
242
+ }>;
243
+ workflowSessionCompletion: (data: WorkflowCompletion) => void;
244
+ setWorkflowSessionCompletion: (fn: (data: WorkflowCompletion) => void) => void;
245
+ loadModules: (modulesFromProps: any[]) => Promise<{
246
+ error?: BaseInitializationError;
247
+ }>;
248
+ setProcessingTemplate: (workflowSteps: any[]) => void;
249
+ isProcessing: boolean;
250
+ setIsProcessing: (isProcessing: boolean) => void;
251
+ _pushStep: (stepId: string, data: Record<string, any>, type?: PerformType) => Promise<{
252
+ error?: BaseWorkflowError;
253
+ }>;
254
+ _waitingForNextStep: () => Promise<{
255
+ sessionData: SessionData;
256
+ error?: undefined;
257
+ } | {
258
+ error: BaseWorkflowError;
259
+ sessionData?: undefined;
260
+ }>;
261
+ _stepSocketListenerWhenStepIsRunning: (isStepRunning: boolean) => void;
262
+ _getSessionStateNextStepConditionResult: () => Promise<GetSessionStateNextStepConditionResult>;
263
+ _findStepById: (stepId: string) => WorkflowStep | null;
264
+ pushStepWaitNextStepAndSet: (data: Record<string, any>, type?: PerformType) => void;
265
+ setNextStep: (props: {
266
+ workflow: Workflow;
267
+ properties: SessionPropertiesItem[];
268
+ nextStepId: string;
269
+ locale: string;
270
+ }) => void;
271
+ onChangeScreen: (stepId: string | null) => void;
272
+ deinitializationIdv: () => Promise<{
273
+ error?: any;
274
+ }>;
275
+ fetchService: IdvFetchService | null;
276
+ setAndInitFetchService: () => Promise<void>;
277
+ isFinalWaitingUi: boolean;
278
+ setFinalWaitingUi: (isWaitingUi: boolean) => void;
279
+ setFinalStepAndStopProcess: (stepId?: string) => void;
280
+ resetSession: () => void;
281
+ resetFetchService: () => void;
282
+ };
283
+
138
284
  export declare type IdvEventTypes = (typeof IdvEventTypesEnum)[keyof typeof IdvEventTypesEnum];
139
285
 
140
286
  export declare const IdvEventTypesEnum: {
@@ -142,6 +288,151 @@ export declare const IdvEventTypesEnum: {
142
288
  readonly ERROR: "ERROR";
143
289
  };
144
290
 
291
+ declare class IdvFetchService {
292
+ private _connectionTokenExpirationBufferMs;
293
+ private _origin;
294
+ private _locale;
295
+ private _workflowId;
296
+ private _session;
297
+ private _apiKeyAuthToken;
298
+ private _connectionToken;
299
+ private _connect;
300
+ private _getErrorTextFromError;
301
+ private _setApiKeyAuthToken;
302
+ private _setConnectionToken;
303
+ private _getOriginFromConfig;
304
+ private _getOriginFromUrl;
305
+ private _getExpiresAtFromTtl;
306
+ private _getAuthorizationHeaderFromConnectionToken;
307
+ private _getAuthorizationHeaderFromBasicToken;
308
+ private _getAuthorizationHeaderFromAuthToken;
309
+ private _getApiKeyAuthTokenFromLs;
310
+ private _getApiKeyAuthTokenFromHeader;
311
+ _getValidApiKeyAuthToken(config: {
312
+ apiKey: string;
313
+ deviceDescriptor: {
314
+ ttl: number;
315
+ };
316
+ }, isFromSession: boolean): Promise<{
317
+ code: FetchResultCode.SUCCESS;
318
+ data: {
319
+ token: string;
320
+ expiresAt: number;
321
+ };
322
+ } | FetchErrorResult>;
323
+ private _getAuthorizationSearchParam;
324
+ private _getResponseTextFromBadResponse;
325
+ private _fetchPing;
326
+ private _fetchMe;
327
+ private _fetchConnection;
328
+ private _fetchEphemeral;
329
+ private _fetchSessionByWorkflowId;
330
+ private _fetchSessionState;
331
+ private _fetchWorkflows;
332
+ private _fetchWorkflow;
333
+ private _fetchStep;
334
+ private _fetchSessionLogs;
335
+ connectByUserPass(config: ConnectionConfigCore): Promise<{
336
+ code: FetchResultCode.SUCCESS;
337
+ data: {
338
+ workflows: string[];
339
+ };
340
+ } | FetchErrorResult>;
341
+ connectByApiKey(config: ConnectionByApiKeyConfigCore, isFromSession: boolean): Promise<{
342
+ code: FetchResultCode.SUCCESS;
343
+ data: {
344
+ authToken: string;
345
+ workflows: string[];
346
+ };
347
+ } | FetchErrorResult>;
348
+ connectByUrl(urlWithToken: string): Promise<{
349
+ code: FetchResultCode.SUCCESS;
350
+ data: {
351
+ workflows: string[];
352
+ };
353
+ } | FetchErrorResult>;
354
+ getConnectionToken(isFromSession: boolean): Promise<string>;
355
+ startSession({ workflowId, locale, metadata, location, }: {
356
+ workflowId: string;
357
+ locale: string;
358
+ metadata?: Record<string, unknown>;
359
+ location?: GeoCoords | null;
360
+ }): Promise<{
361
+ code: FetchResultCode.SUCCESS;
362
+ data: SessionData;
363
+ } | FetchErrorResult>;
364
+ continueSession(sessionId: string, locale: string): Promise<{
365
+ code: FetchResultCode.SUCCESS;
366
+ data: SessionData;
367
+ } | FetchErrorResult>;
368
+ listWorkflows(params?: {
369
+ limit: number;
370
+ skip: number;
371
+ }): Promise<{
372
+ code: FetchResultCode.SUCCESS;
373
+ data: {
374
+ count: number;
375
+ items: Workflow[];
376
+ };
377
+ } | FetchErrorResult>;
378
+ getWorkflow(workflowId: string): Promise<{
379
+ code: FetchResultCode.SUCCESS;
380
+ data: Workflow;
381
+ } | FetchErrorResult>;
382
+ pushData(stepId: string, data: any, type?: PerformType): Promise<{
383
+ code: FetchResultCode.SUCCESS;
384
+ data: Record<string, unknown>;
385
+ } | FetchErrorResult>;
386
+ getSessionState(): Promise<{
387
+ code: FetchResultCode.SUCCESS;
388
+ data: SessionData;
389
+ } | FetchErrorResult>;
390
+ pushSessionLogs(pushSessionLogsParams: PushSessionLogsParams): Promise<Record<string, unknown>>;
391
+ }
392
+
393
+ declare type IdvIntegrationControllerProps = {
394
+ _isInitialized: boolean;
395
+ _isConnectedToPlatform: boolean;
396
+ _initializationInProgress: boolean;
397
+ _sessionIdFromUrl: null | string;
398
+ _ttl: number;
399
+ _continueSession: (locale: string, forceSessionId: string | null) => Promise<ContinueSessionResults>;
400
+ _checkIsSessionDataValid: (sessionData: SessionData | {
401
+ httpCode: number;
402
+ method: string;
403
+ url: string;
404
+ what?: string;
405
+ }) => SessionData | {
406
+ error?: BaseWorkflowError;
407
+ };
408
+ _checkAndSetApiTokenToLs: (sessionId: string) => void;
409
+ _runSocketConnection: (token: string) => Promise<{
410
+ error?: BaseWorkflowError;
411
+ }>;
412
+ initialize: (config: InitConfig) => Promise<{
413
+ error?: BaseInitializationError;
414
+ }>;
415
+ configureByUserPass: (config: CredentialConnectionConfig) => Promise<object | {
416
+ error?: BaseConfigureError;
417
+ }>;
418
+ configureWithUrl: (urlWithToken: string) => Promise<object | {
419
+ error?: BaseConfigureError;
420
+ }>;
421
+ configureByApiKey: (config: ApiKeyConnectionConfig) => Promise<object | {
422
+ error?: BaseConfigureError;
423
+ }>;
424
+ getWorkflows: (params?: WorkflowListRequest) => Promise<WorkflowListCompletion>;
425
+ prepareWorkflowAndPrepareUi: (workflowId: string) => Promise<PrepareWorkflowCompletion>;
426
+ startNewSession: (params: {
427
+ completion: (data: WorkflowCompletion) => void;
428
+ locale: string;
429
+ metadata?: Record<string, unknown>;
430
+ location?: GeoCoords | null;
431
+ }) => Promise<WorkflowCompletion>;
432
+ playWorkflow: () => void;
433
+ deinitialize: () => Promise<DeinitializeCompletion>;
434
+ };
435
+
145
436
  export declare class IdvIntegrationService {
146
437
  /** main commands */
147
438
  initialize(config: InitConfig): Promise<{
@@ -167,6 +458,23 @@ export declare type IdvMessageEvent = {
167
458
  message?: IdvServiceMessages;
168
459
  };
169
460
 
461
+ export declare type IdvModuleProps<TModuleProps, TModulesConfig> = {
462
+ isProcessing?: (isProcessing: boolean) => void;
463
+ moduleProps: TModuleProps;
464
+ modulesConfig?: TModulesConfig;
465
+ perform: (data: any, type?: PerformType) => void;
466
+ idvEventListener: (module: string, data: any) => void;
467
+ };
468
+
469
+ export declare interface IdvModuleStaticMethods {
470
+ displayName: string;
471
+ isReady(): boolean;
472
+ getSupportedTemplates(): string[];
473
+ initialize(modulesConfig: Record<string, unknown>): void;
474
+ deinitialize(): void;
475
+ getIdentifier(): string;
476
+ }
477
+
170
478
  export declare enum IdvServiceMessages {
171
479
  DID_START_SESSION = "DID_START_SESSION",
172
480
  DID_END_SESSION = "DID_END_SESSION",
@@ -174,15 +482,80 @@ export declare enum IdvServiceMessages {
174
482
  DID_CONTINUE_REMOTE_SESSION = "DID_CONTINUE_REMOTE_SESSION"
175
483
  }
176
484
 
177
- export declare class IdvWebComponent extends HTMLElement {
178
- private _root;
179
- private _mounted;
180
- constructor();
181
- static get observedAttributes(): Array<string>;
485
+ declare type IdvStoreProps = {
486
+ sessionRestoreMode: boolean;
487
+ setSessionRestoreMode: (isEnabled: boolean) => void;
488
+ currentSessionData: {
489
+ sessionId: string;
490
+ workflowId: string;
491
+ } | null;
492
+ setCurrentSessionDataLsAndStore: (data: {
493
+ sessionId: string;
494
+ workflowId: string;
495
+ }) => void;
496
+ removeCurrentSessionDataLsAndStore: () => void;
497
+ getCurrentSessionDataLs: () => {
498
+ sessionId: string;
499
+ workflowId: string;
500
+ apiKey?: string;
501
+ } | null;
502
+ getCurrentSessionId: () => string | null;
503
+ modulesConfig: Record<string, any>;
504
+ layout: Record<string, any> | null;
505
+ sessionProperties: SessionPropertiesItem[];
506
+ setSessionProperties: (properties: SessionPropertiesItem[]) => void;
507
+ setLayout: (layout: Record<string, any>) => void;
508
+ workflow: Workflow | null;
509
+ setWorkflow: (workflow: Workflow) => void;
510
+ currentStepId: string | null;
511
+ setCurrentStepId: (stepId: string) => void;
512
+ listener: (message: IdvMessageEvent) => void | null;
513
+ setListener: (callback: (message: IdvMessageEvent) => void) => void;
514
+ workflowId: string | null;
515
+ setWorkflowId: (id: string) => void;
516
+ nonce?: string;
517
+ setNonce: (id: string) => void;
518
+ getNonce: () => string | undefined;
519
+ currentScreenConfig: CurrentScreenConfig | null;
520
+ externalModules: LoadedModule[] | [];
521
+ processingTransformedTemplate: WorkflowStepClientGui | null;
522
+ serviceToken?: string;
523
+ apiKeyAuthTokenCollection: AuthTokenStoreData | Record<string, unknown>;
524
+ setApiKeyAuthTokenCollection: (apiKey: string, authToken: string, tokenExpiresAt: number) => void;
525
+ setServiceSessionToken: (token: string) => void;
526
+ resetProps: () => void;
527
+ startConfig: StartConfig;
528
+ setStartConfig: (startConfig: StartConfig) => void;
529
+ locale: string;
530
+ setLocale: (locale: string) => void;
531
+ trackLocation: boolean;
532
+ setTrackLocation: (trackLocation: boolean) => void;
533
+ };
534
+
535
+ export declare class IdvWebComponent extends LitElement {
536
+ private _currentProgressElement;
537
+ private _currentScreenElement;
538
+ private _currentScreenModuleId;
539
+ private _currentScreenConfig;
540
+ private orientation;
541
+ private unsubscribeFromStore?;
542
+ static styles: CSSResult[];
543
+ store: IdvStoreProps & IdvIntegrationControllerProps & IdvBusinessLogicControllerProps;
544
+ currentScreenConfig: CurrentScreenConfig | null;
545
+ processingScreenFromWorkflow: WorkflowStepClientGui | null;
546
+ isProcessing: boolean;
547
+ loadedModules: [] | LoadedModule[];
548
+ modulesConfig: Record<string, any>;
182
549
  connectedCallback(): void;
550
+ _listenerFromModule: (module: string, data: any) => void;
551
+ _isProcessingCallback: (isProcessing: boolean) => void;
552
+ _performFromModule: (data: any, type?: PerformType) => void;
553
+ _processingScreen(): HTMLElement | TemplateResult<1>;
554
+ private _isTheSameModuleAndScreen;
555
+ _currentScreen(): HTMLElement | typeof nothing;
183
556
  get version(): string;
184
- private render;
185
557
  disconnectedCallback(): void;
558
+ render(): TemplateResult<1> | null;
186
559
  }
187
560
 
188
561
  export declare type InitConfig = {
@@ -205,6 +578,21 @@ export declare enum InitializeError {
205
578
  INITIALIZATION_IN_PROGRESS = 2
206
579
  }
207
580
 
581
+ declare type LoadedModule = {
582
+ id: string;
583
+ supportedTemplates: string[];
584
+ component: any;
585
+ };
586
+
587
+ export declare type ModuleClass<TModuleProps = unknown, TModulesConfig = unknown> = IdvModuleStaticMethods & (new (...args: any[]) => BaseModule<TModuleProps, TModulesConfig>);
588
+
589
+ declare type PerformType = (typeof performType)[keyof typeof performType] | undefined;
590
+
591
+ declare const performType: {
592
+ readonly FORM: "form";
593
+ readonly DATA: "data";
594
+ };
595
+
208
596
  export declare type PrepareWorkflowCompletion = {
209
597
  workflow?: Workflow;
210
598
  error?: BasePrepareWorkflowError;
@@ -218,6 +606,25 @@ export declare enum PrepareWorkflowError {
218
606
  SCENARIO_IN_PROGRESS = 4
219
607
  }
220
608
 
609
+ declare type PushSessionLogsParams = {
610
+ body: {
611
+ log: string;
612
+ errorCode?: string;
613
+ deviceInfo?: Record<string, string>;
614
+ };
615
+ };
616
+
617
+ export declare function registerModule<TModuleProps = unknown, TModulesConfig = unknown>(name: string, ModuleClass: ModuleClass<TModuleProps, TModulesConfig>): void;
618
+
619
+ declare type SessionData = {
620
+ id: string;
621
+ currentStep: string;
622
+ workflow: Workflow;
623
+ properties: SessionPropertiesItem[];
624
+ isProcessingFiles: boolean;
625
+ locale: string;
626
+ };
627
+
221
628
  export declare enum SessionError {
222
629
  HTTP_ISSUE = 0,
223
630
  PROVIDER_ERROR = 1,
@@ -227,6 +634,31 @@ export declare enum SessionError {
227
634
  NOT_DATA_TYPE = 5
228
635
  }
229
636
 
637
+ /** sync with gui module */
638
+ declare type SessionPropertiesItem = {
639
+ id: string;
640
+ createdAt: string;
641
+ updatedAt: string;
642
+ createdBy: unknown;
643
+ updatedBy: unknown;
644
+ action: unknown;
645
+ step: string;
646
+ name: string;
647
+ path: unknown;
648
+ string: string;
649
+ array?: string[];
650
+ integer: unknown;
651
+ decimal: unknown;
652
+ object: unknown;
653
+ };
654
+
655
+ declare type StartConfig = {
656
+ host?: string;
657
+ isSecure?: boolean;
658
+ apiKey?: string;
659
+ port?: number;
660
+ };
661
+
230
662
  export declare enum StartSessionError {
231
663
  HTTP_ISSUE = 0,
232
664
  PROVIDER_ERROR = 1,
@@ -304,9 +736,11 @@ declare type WorkflowResult = {
304
736
  } & Record<string, any>;
305
737
 
306
738
  declare type WorkflowStep = {
739
+ type: string;
307
740
  id: string;
308
741
  name: string;
309
742
  final: boolean;
743
+ releaseClientApp: boolean;
310
744
  client?: Record<string, unknown> | WorkflowStepClientGui;
311
745
  dataSource: Record<string, unknown> | null;
312
746
  } & Record<string, any>;