idmission-web-sdk 0.0.37 → 0.0.38

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
@@ -481,4 +481,4 @@ onBeforeSubmit: (req) => new Promise((resolve) => {
481
481
 
482
482
  Note that you will receive the request as a parameter to `onBeforeSubmit`, and must `resolve` with the altered version in order for your changes to be committed.
483
483
 
484
- If the promise is rejected or an error is thrown, that rejection value or error will be printed to the logs and the request will be sent without any modifications committed.
484
+ If the promise is rejected or an error is thrown, that rejection value or error will be printed to the logs and the request will be not be sent. The `onRequestFailure` hook will be fired with the error that came from your code.
@@ -395,7 +395,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
395
395
  }, []);
396
396
  var submit = React.useCallback(function () {
397
397
  return tslib.__awaiter(void 0, void 0, void 0, function () {
398
- var submissionResponse_1, submissionRequest_1, metadata, platform, onBeforeSubmitResult, e_1, host, endpoint, response, submissionResponse_2, e_2;
398
+ var submissionResponse_1, submissionRequest_1, metadata, platform, onBeforeSubmitResult, host, endpoint, response, submissionResponse_2, e_1;
399
399
  var _a;
400
400
  return tslib.__generator(this, function (_b) {
401
401
  switch (_b.label) {
@@ -414,7 +414,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
414
414
  setSubmissionStatus(SubmissionStatus.SUBMITTING);
415
415
  _b.label = 1;
416
416
  case 1:
417
- _b.trys.push([1, 8,, 9]);
417
+ _b.trys.push([1, 6,, 7]);
418
418
  submissionRequest_1 = {
419
419
  securityData: {
420
420
  userName: '',
@@ -485,7 +485,7 @@ var SubmissionProvider = function SubmissionProvider(_a) {
485
485
  }
486
486
  if (signatureData) {
487
487
  submissionRequest_1.customerData.signatureData = {
488
- signatureImage: signatureData.fileContent
488
+ signatureImage: JSON.stringify(signatureData)
489
489
  };
490
490
  }
491
491
  if (additionalDocuments) {
@@ -515,20 +515,13 @@ var SubmissionProvider = function SubmissionProvider(_a) {
515
515
  metadata.GeoLocation = JSON.stringify(geolocationResult);
516
516
  }
517
517
  submissionRequest_1.additionalData.metadata = JSON.stringify(metadata);
518
- if (!onBeforeSubmit) return [3, 5];
519
- _b.label = 2;
520
- case 2:
521
- _b.trys.push([2, 4,, 5]);
518
+ if (!onBeforeSubmit) return [3, 3];
522
519
  return [4, onBeforeSubmit(submissionRequest_1)];
523
- case 3:
520
+ case 2:
524
521
  onBeforeSubmitResult = _b.sent();
525
522
  if (onBeforeSubmitResult) submissionRequest_1 = onBeforeSubmitResult;
526
- return [3, 5];
527
- case 4:
528
- e_1 = _b.sent();
529
- console.error('onBeforeSubmit was rejected with', e_1);
530
- return [3, 5];
531
- case 5:
523
+ _b.label = 3;
524
+ case 3:
532
525
  host = url || determineSubmissionHost(environment, token);
533
526
  endpoint = determineSubmissionEndpoint(action, !!(idFrontImage || idBackImage || passportImage), !!selfieImage, !!token);
534
527
  return [4, fetch(host + endpoint, {
@@ -536,22 +529,22 @@ var SubmissionProvider = function SubmissionProvider(_a) {
536
529
  headers: apiHeaders(token),
537
530
  body: JSON.stringify(submissionRequest_1)
538
531
  })];
539
- case 6:
532
+ case 4:
540
533
  response = _b.sent();
541
534
  return [4, response.json()];
542
- case 7:
535
+ case 5:
543
536
  submissionResponse_2 = _b.sent();
544
537
  setSubmissionRequest(submissionRequest_1);
545
538
  setSubmissionResponse(submissionResponse_2);
546
539
  setSubmissionStatus(SubmissionStatus.SUBMITTED);
547
540
  onResponseReceived === null || onResponseReceived === void 0 ? void 0 : onResponseReceived(submissionResponse_2);
548
541
  return [2, submissionResponse_2];
549
- case 8:
550
- e_2 = _b.sent();
542
+ case 6:
543
+ e_1 = _b.sent();
551
544
  setSubmissionStatus(SubmissionStatus.FAILED);
552
- onRequestFailure === null || onRequestFailure === void 0 ? void 0 : onRequestFailure(e_2);
545
+ onRequestFailure === null || onRequestFailure === void 0 ? void 0 : onRequestFailure(e_1);
553
546
  return [2, null];
554
- case 9:
547
+ case 7:
555
548
  return [2];
556
549
  }
557
550
  });