@ekyc_qoobiss/qbs-ect-cmp 3.3.1 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cjs/agreement-check_18.cjs.entry.js +99 -31
  2. package/dist/collection/components/common/camera-error/camera-error.js +3 -1
  3. package/dist/collection/components/common/id-back-capture/id-back-capture.js +17 -4
  4. package/dist/collection/components/common/id-capture/id-capture.js +17 -4
  5. package/dist/collection/components/common/selfie-capture/selfie-capture.js +17 -4
  6. package/dist/collection/components/flow/agreement-info/agreement-info.js +3 -1
  7. package/dist/collection/components/flow/error-end/error-end.js +1 -5
  8. package/dist/collection/components/flow/id-double-side/id-double-side.js +3 -1
  9. package/dist/collection/components/flow/id-single-side/id-single-side.js +3 -1
  10. package/dist/collection/components/flow/landing-validation/landing-validation.js +3 -2
  11. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.js +3 -1
  12. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.js +3 -1
  13. package/dist/collection/components/flow/user-liveness/user-liveness.js +3 -1
  14. package/dist/collection/components/identification-component/identification-component.js +1 -1
  15. package/dist/collection/helpers/ApiCall.js +63 -7
  16. package/dist/esm/agreement-check_18.entry.js +99 -31
  17. package/dist/qbs-ect-cmp/{p-419e65b4.entry.js → p-21b40971.entry.js} +2 -2
  18. package/dist/qbs-ect-cmp/qbs-ect-cmp.esm.js +1 -1
  19. package/dist/types/components/common/camera-error/camera-error.d.ts +1 -0
  20. package/dist/types/components/common/id-back-capture/id-back-capture.d.ts +1 -0
  21. package/dist/types/components/common/id-capture/id-capture.d.ts +1 -0
  22. package/dist/types/components/common/selfie-capture/selfie-capture.d.ts +1 -0
  23. package/dist/types/components/flow/agreement-info/agreement-info.d.ts +1 -0
  24. package/dist/types/components/flow/id-double-side/id-double-side.d.ts +1 -0
  25. package/dist/types/components/flow/id-single-side/id-single-side.d.ts +1 -0
  26. package/dist/types/components/flow/landing-validation/landing-validation.d.ts +1 -0
  27. package/dist/types/components/flow/mobile-redirect/mobile-redirect.d.ts +1 -0
  28. package/dist/types/components/flow/sms-code-validation/sms-code-validation.d.ts +1 -0
  29. package/dist/types/components/flow/user-liveness/user-liveness.d.ts +1 -0
  30. package/dist/types/components.d.ts +3 -0
  31. package/dist/types/helpers/ApiCall.d.ts +1 -0
  32. package/package.json +1 -1
@@ -13,6 +13,30 @@ export class ApiCall {
13
13
  });
14
14
  this.urls = new ApiUrls();
15
15
  }
16
+ async http2(method, url, data) {
17
+ return new Promise((resolve, reject) => {
18
+ var xhr = new XMLHttpRequest();
19
+ xhr.open(method, url);
20
+ xhr.onload = function () {
21
+ if (xhr.status >= 200 && xhr.status < 300) {
22
+ resolve(xhr.response);
23
+ }
24
+ else {
25
+ reject({
26
+ status: xhr.status,
27
+ statusText: xhr.statusText,
28
+ });
29
+ }
30
+ };
31
+ xhr.onerror = function () {
32
+ reject({
33
+ status: xhr.status,
34
+ statusText: xhr.statusText,
35
+ });
36
+ };
37
+ xhr.send(data);
38
+ });
39
+ }
16
40
  async http(request) {
17
41
  const response = await fetch(request);
18
42
  if (!response.ok) {
@@ -26,24 +50,56 @@ export class ApiCall {
26
50
  throw new Error('No json found in response ' + ex);
27
51
  }
28
52
  }
29
- async post(url, data) {
30
- return await this.http(new Request(store.apiBaseUrl + url, {
53
+ async post(url, data, withRetry = true) {
54
+ var request = new Request(store.apiBaseUrl + url, {
31
55
  method: 'POST',
32
56
  body: data,
33
57
  headers: {
34
58
  'Content-Type': 'application/json',
35
59
  'Authorization': 'IDKYC-TOKEN ' + store.token,
36
60
  },
37
- }));
61
+ });
62
+ try {
63
+ return await this.http(request);
64
+ }
65
+ catch (ex) {
66
+ this.AddLog('Error in post ', ex);
67
+ if (!withRetry) {
68
+ throw ex;
69
+ }
70
+ try {
71
+ return await this.http(request);
72
+ }
73
+ catch (ex2) {
74
+ this.AddLog('Error in post ', ex2);
75
+ return await this.http2('POST', store.apiBaseUrl + url, data);
76
+ }
77
+ }
38
78
  }
39
- async get(url) {
40
- return await this.http(new Request(store.apiBaseUrl + url, {
79
+ async get(url, withRetry = true) {
80
+ var request = new Request(store.apiBaseUrl + url, {
41
81
  method: 'GET',
42
82
  headers: {
43
83
  'Content-Type': 'application/json',
44
84
  'Authorization': 'IDKYC-TOKEN ' + store.token,
45
85
  },
46
- }));
86
+ });
87
+ try {
88
+ return await this.http(request);
89
+ }
90
+ catch (ex) {
91
+ this.AddLog('Error in get ', ex);
92
+ if (!withRetry) {
93
+ throw ex;
94
+ }
95
+ try {
96
+ return await this.http(request);
97
+ }
98
+ catch (ex2) {
99
+ this.AddLog('Error in get ', ex2);
100
+ return await this.http2('GET', store.apiBaseUrl + url, '');
101
+ }
102
+ }
47
103
  }
48
104
  async SendOTPCode(requestId, phoneNumber) {
49
105
  let data = { requestId: requestId, phone: phoneNumber };
@@ -118,7 +174,7 @@ export class ApiCall {
118
174
  action: FlowStatus[store.flowStatus],
119
175
  message: JSON.stringify({ error, context }),
120
176
  };
121
- let result = await this.post(this.urls.AddLog, JSON.stringify(data));
177
+ let result = await this.post(this.urls.AddLog, JSON.stringify(data), false);
122
178
  return result.saved;
123
179
  }
124
180
  catch (_a) { }
@@ -435,6 +435,30 @@ class ApiCall {
435
435
  });
436
436
  this.urls = new ApiUrls();
437
437
  }
438
+ async http2(method, url, data) {
439
+ return new Promise((resolve, reject) => {
440
+ var xhr = new XMLHttpRequest();
441
+ xhr.open(method, url);
442
+ xhr.onload = function () {
443
+ if (xhr.status >= 200 && xhr.status < 300) {
444
+ resolve(xhr.response);
445
+ }
446
+ else {
447
+ reject({
448
+ status: xhr.status,
449
+ statusText: xhr.statusText,
450
+ });
451
+ }
452
+ };
453
+ xhr.onerror = function () {
454
+ reject({
455
+ status: xhr.status,
456
+ statusText: xhr.statusText,
457
+ });
458
+ };
459
+ xhr.send(data);
460
+ });
461
+ }
438
462
  async http(request) {
439
463
  const response = await fetch(request);
440
464
  if (!response.ok) {
@@ -448,24 +472,56 @@ class ApiCall {
448
472
  throw new Error('No json found in response ' + ex);
449
473
  }
450
474
  }
451
- async post(url, data) {
452
- return await this.http(new Request(state.apiBaseUrl + url, {
475
+ async post(url, data, withRetry = true) {
476
+ var request = new Request(state.apiBaseUrl + url, {
453
477
  method: 'POST',
454
478
  body: data,
455
479
  headers: {
456
480
  'Content-Type': 'application/json',
457
481
  'Authorization': 'IDKYC-TOKEN ' + state.token,
458
482
  },
459
- }));
483
+ });
484
+ try {
485
+ return await this.http(request);
486
+ }
487
+ catch (ex) {
488
+ this.AddLog('Error in post ', ex);
489
+ if (!withRetry) {
490
+ throw ex;
491
+ }
492
+ try {
493
+ return await this.http(request);
494
+ }
495
+ catch (ex2) {
496
+ this.AddLog('Error in post ', ex2);
497
+ return await this.http2('POST', state.apiBaseUrl + url, data);
498
+ }
499
+ }
460
500
  }
461
- async get(url) {
462
- return await this.http(new Request(state.apiBaseUrl + url, {
501
+ async get(url, withRetry = true) {
502
+ var request = new Request(state.apiBaseUrl + url, {
463
503
  method: 'GET',
464
504
  headers: {
465
505
  'Content-Type': 'application/json',
466
506
  'Authorization': 'IDKYC-TOKEN ' + state.token,
467
507
  },
468
- }));
508
+ });
509
+ try {
510
+ return await this.http(request);
511
+ }
512
+ catch (ex) {
513
+ this.AddLog('Error in get ', ex);
514
+ if (!withRetry) {
515
+ throw ex;
516
+ }
517
+ try {
518
+ return await this.http(request);
519
+ }
520
+ catch (ex2) {
521
+ this.AddLog('Error in get ', ex2);
522
+ return await this.http2('GET', state.apiBaseUrl + url, '');
523
+ }
524
+ }
469
525
  }
470
526
  async SendOTPCode(requestId, phoneNumber) {
471
527
  let data = { requestId: requestId, phone: phoneNumber };
@@ -540,7 +596,7 @@ class ApiCall {
540
596
  action: FlowStatus[state.flowStatus],
541
597
  message: JSON.stringify({ error, context }),
542
598
  };
543
- let result = await this.post(this.urls.AddLog, JSON.stringify(data));
599
+ let result = await this.post(this.urls.AddLog, JSON.stringify(data), false);
544
600
  return result.saved;
545
601
  }
546
602
  catch (_a) { }
@@ -822,9 +878,11 @@ const AgreementInfo = class {
822
878
  this.openAgreements = false;
823
879
  this.openTerms = false;
824
880
  }
881
+ disconnectedCallback() {
882
+ this.baseComponent.finalize();
883
+ }
825
884
  async buttonClick() {
826
885
  if (this.agreementsChecked && this.termsChecked) {
827
- await this.baseComponent.finalize();
828
886
  state.flowStatus = FlowStatus.PHONE;
829
887
  }
830
888
  }
@@ -5428,9 +5486,11 @@ const CameraError = class {
5428
5486
  }
5429
5487
  }
5430
5488
  }
5489
+ disconnectedCallback() {
5490
+ this.baseComponent.finalize();
5491
+ }
5431
5492
  async buttonClick() {
5432
5493
  this.buttonDisabled = true;
5433
- await this.baseComponent.finalize();
5434
5494
  if (state.device.mobileOS == MobileOS.iOS) {
5435
5495
  sessionStorage.setItem(SessionKeys.RefreshDoneKey, 'true');
5436
5496
  window.location.reload();
@@ -5519,10 +5579,7 @@ const ErrorEnd = class {
5519
5579
  this.message = undefined;
5520
5580
  this.errorTitle = undefined;
5521
5581
  }
5522
- componentDidLoad() {
5523
- Events.init(window);
5524
- Events.flowError(this.errorTitle + ' ' + this.message);
5525
- }
5582
+ componentDidLoad() { }
5526
5583
  render() {
5527
5584
  return (h("div", { class: "container" }, h("div", { class: "row" }, h("div", { class: "text-center" }, h("h1", null, this.errorTitle)), h("div", { class: "text-center" }, h("p", null, state.requestId)), h("div", null, h("p", { class: "color-red font-weight-bold font-size-2 text-center mt-10" }, this.message)))));
5528
5585
  }
@@ -5702,6 +5759,7 @@ const IdBackCapture = class {
5702
5759
  constructor(hostRef) {
5703
5760
  registerInstance(this, hostRef);
5704
5761
  this.eventPhotoCapture = createEvent(this, "photoIdBackCapture", 7);
5762
+ this.apiErrorEvent = createEvent(this, "apiError", 7);
5705
5763
  this.photoIsReady = photos => {
5706
5764
  //this.closeCamera();
5707
5765
  this.eventPhotoCapture.emit(photos);
@@ -5731,10 +5789,9 @@ const IdBackCapture = class {
5731
5789
  this.cameraSize = event.detail;
5732
5790
  }
5733
5791
  async componentWillLoad() {
5734
- Events.init(this.component);
5735
5792
  //this.videoDemoStyle = this.device.isMobile ? { width: window.screen.width + 'px', height: window.screen.height + 'px', 'object-fit': 'fill' } : {};
5736
5793
  if (!navigator.mediaDevices) {
5737
- Events.flowError('This browser does not support webRTC');
5794
+ this.apiErrorEvent.emit({ message: 'This browser does not support webRTC' });
5738
5795
  }
5739
5796
  }
5740
5797
  async componentDidLoad() {
@@ -5760,7 +5817,7 @@ const IdBackCapture = class {
5760
5817
  })
5761
5818
  .catch(e => {
5762
5819
  this.closeCamera();
5763
- Events.flowError(e);
5820
+ this.apiErrorEvent.emit(e);
5764
5821
  });
5765
5822
  }, 100);
5766
5823
  }
@@ -5816,6 +5873,7 @@ const IdCapture = class {
5816
5873
  constructor(hostRef) {
5817
5874
  registerInstance(this, hostRef);
5818
5875
  this.eventPhotoCapture = createEvent(this, "photoIdCapture", 7);
5876
+ this.apiErrorEvent = createEvent(this, "apiError", 7);
5819
5877
  this.photoIsReady = photos => {
5820
5878
  //this.closeCamera();
5821
5879
  this.eventPhotoCapture.emit(photos);
@@ -5845,11 +5903,10 @@ const IdCapture = class {
5845
5903
  this.cameraSize = event.detail;
5846
5904
  }
5847
5905
  async componentWillLoad() {
5848
- Events.init(this.component);
5849
5906
  this.titleMesage = IdCaptureValues.Title;
5850
5907
  //this.videoDemoStyle = this.device.isMobile ? { 'width': window.screen.width + 'px', 'height': window.screen.height + 'px', 'object-fit': 'fill' } : {};
5851
5908
  if (!navigator.mediaDevices) {
5852
- Events.flowError('This browser does not support webRTC');
5909
+ this.apiErrorEvent.emit({ message: 'This browser does not support webRTC' });
5853
5910
  }
5854
5911
  }
5855
5912
  async componentDidLoad() {
@@ -5870,7 +5927,7 @@ const IdCapture = class {
5870
5927
  })
5871
5928
  .catch(e => {
5872
5929
  this.closeCamera();
5873
- Events.flowError(e);
5930
+ this.apiErrorEvent.emit(e);
5874
5931
  });
5875
5932
  }, 100);
5876
5933
  }
@@ -6090,9 +6147,11 @@ const IdDoubleSide = class {
6090
6147
  return;
6091
6148
  }
6092
6149
  state.recordingRetryCount = 0;
6093
- await this.baseComponent.finalize();
6094
6150
  state.flowStatus = FlowStatus.LIVENESS;
6095
6151
  }
6152
+ disconnectedCallback() {
6153
+ this.baseComponent.finalize();
6154
+ }
6096
6155
  switchCamera() {
6097
6156
  if (this.captureRetryCount == 1) {
6098
6157
  let camIndex = state.cameraIds.indexOf(state.cameraId);
@@ -6221,9 +6280,11 @@ const IdSingleSide = class {
6221
6280
  if (!this.idFlow.verificationFinished) {
6222
6281
  return;
6223
6282
  }
6224
- await this.baseComponent.finalize();
6225
6283
  state.flowStatus = FlowStatus.LIVENESS;
6226
6284
  }
6285
+ disconnectedCallback() {
6286
+ this.baseComponent.finalize();
6287
+ }
6227
6288
  switchCamera() {
6228
6289
  if (this.captureRetryCount == 1) {
6229
6290
  let camIndex = state.cameraIds.indexOf(state.cameraId);
@@ -6309,7 +6370,7 @@ function v4(options, buf, offset) {
6309
6370
  }
6310
6371
 
6311
6372
  const name = "@ekyc_qoobiss/qbs-ect-cmp";
6312
- const version$1 = "3.3.1";
6373
+ const version$1 = "3.3.3";
6313
6374
  const description = "Person Identification Component";
6314
6375
  const main = "./dist/index.cjs.js";
6315
6376
  const module = "./dist/index.js";
@@ -6471,7 +6532,7 @@ const IdentificationComponent = class {
6471
6532
  await this.baseComponent.apiCall.AddLog(apiLogData, getLogMessage(this.order_id, this.redirect_id, this.token));
6472
6533
  }
6473
6534
  catch (_c) { }
6474
- Events.flowError(data);
6535
+ Events.flowError(this.errorTitle);
6475
6536
  state.flowStatus = FlowStatus.ERROREND;
6476
6537
  }
6477
6538
  constructor(hostRef) {
@@ -6699,7 +6760,6 @@ const LandingValidation = class {
6699
6760
  state.flowStatus = FlowStatus.COMPLETE;
6700
6761
  return;
6701
6762
  }
6702
- await this.baseComponent.finalize();
6703
6763
  if (!(await Cameras.InitCameras(state.device))) {
6704
6764
  if (state.device.mobileOS == MobileOS.iOS)
6705
6765
  sessionStorage.setItem(SessionKeys.RefreshDoneKey, 'false');
@@ -6716,13 +6776,15 @@ const LandingValidation = class {
6716
6776
  }
6717
6777
  }
6718
6778
  }
6779
+ disconnectedCallback() {
6780
+ this.baseComponent.finalize();
6781
+ }
6719
6782
  async leaveFlow() {
6720
6783
  if (this.buttonDisabled)
6721
6784
  return;
6722
6785
  state.initialised = false;
6723
6786
  try {
6724
6787
  await this.baseComponent.apiCall.AbortRequest();
6725
- await this.baseComponent.finalize();
6726
6788
  Events.flowAborted();
6727
6789
  }
6728
6790
  catch (e) {
@@ -9661,7 +9723,6 @@ const MobileRedirect = class {
9661
9723
  this.orderStatus = await this.baseComponent.apiCall.GetStatus(state.requestId);
9662
9724
  if (this.orderStatus == OrderStatuses.FinishedCapturing) {
9663
9725
  this.waitingMobile = false;
9664
- await this.baseComponent.finalize();
9665
9726
  state.flowStatus = FlowStatus.COMPLETE;
9666
9727
  }
9667
9728
  if (this.orderStatus == OrderStatuses.NotFound) {
@@ -9677,6 +9738,9 @@ const MobileRedirect = class {
9677
9738
  Events.flowAborted();
9678
9739
  }
9679
9740
  }
9741
+ disconnectedCallback() {
9742
+ this.baseComponent.finalize();
9743
+ }
9680
9744
  async buttonClick() {
9681
9745
  if (this.contact == '' || this.contact.length != 10) {
9682
9746
  return;
@@ -9712,6 +9776,7 @@ const SelfieCapture = class {
9712
9776
  constructor(hostRef) {
9713
9777
  registerInstance(this, hostRef);
9714
9778
  this.eventPhotoCapture = createEvent(this, "photoSelfieCapture", 7);
9779
+ this.apiErrorEvent = createEvent(this, "apiError", 7);
9715
9780
  this.photoIsReady = photos => {
9716
9781
  //this.closeCamera();
9717
9782
  this.eventPhotoCapture.emit(photos);
@@ -9753,11 +9818,10 @@ const SelfieCapture = class {
9753
9818
  this.captureWidth = Math.round((this.captureHeight * 9) / 16);
9754
9819
  }
9755
9820
  componentWillLoad() {
9756
- Events.init(this.component);
9757
9821
  this.titleMesage = SelfieCaptureValues.Title;
9758
9822
  //this.videoDemoStyle = this.device.isMobile ? { 'width': window.screen.width + 'px', 'height': window.screen.height + 'px', 'object-fit': 'fill' } : {};
9759
9823
  if (!navigator.mediaDevices) {
9760
- Events.flowError('This browser does not support webRTC');
9824
+ this.apiErrorEvent.emit({ message: 'This browser does not support webRTC' });
9761
9825
  }
9762
9826
  }
9763
9827
  async componentDidLoad() {
@@ -9778,7 +9842,7 @@ const SelfieCapture = class {
9778
9842
  })
9779
9843
  .catch(e => {
9780
9844
  this.closeCamera();
9781
- Events.flowError(e);
9845
+ this.apiErrorEvent.emit(e);
9782
9846
  });
9783
9847
  }, 100);
9784
9848
  }
@@ -9855,7 +9919,6 @@ const SmsCodeValidation = class {
9855
9919
  async doAction() {
9856
9920
  try {
9857
9921
  this.canSend = false;
9858
- await this.baseComponent.finalize();
9859
9922
  if (state.flowStatus == FlowStatus.CODE || state.flowStatus == FlowStatus.CODEERROR) {
9860
9923
  var codeChecked = await this.baseComponent.apiCall.CheckOTPCode(state.requestId, this.code);
9861
9924
  if (codeChecked === true) {
@@ -9876,6 +9939,9 @@ const SmsCodeValidation = class {
9876
9939
  this.apiErrorEvent.emit(e);
9877
9940
  }
9878
9941
  }
9942
+ disconnectedCallback() {
9943
+ this.baseComponent.finalize();
9944
+ }
9879
9945
  componentWillRender() {
9880
9946
  if (state.flowStatus == FlowStatus.PHONE) {
9881
9947
  this.title = PhoneValidationValues.Title;
@@ -10005,6 +10071,9 @@ const UserLiveness = class {
10005
10071
  this.selfieFlow.verificationFinished = true;
10006
10072
  await this.endFlow();
10007
10073
  }
10074
+ disconnectedCallback() {
10075
+ this.baseComponent.finalize();
10076
+ }
10008
10077
  async uploadPhoto() {
10009
10078
  if (this.selfieFlow.photoFile == null || this.selfieFlow.photoDone) {
10010
10079
  return;
@@ -10045,7 +10114,6 @@ const UserLiveness = class {
10045
10114
  return;
10046
10115
  }
10047
10116
  state.recordingRetryCount = 0;
10048
- await this.baseComponent.finalize();
10049
10117
  state.flowStatus = FlowStatus.COMPLETE;
10050
10118
  }
10051
10119
  render() {