idmission-web-sdk 1.0.101 → 1.0.103

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.
@@ -0,0 +1,34 @@
1
+ import { FC, PropsWithChildren, ReactNode } from 'react';
2
+ import { ThemeInput } from '../../themes';
3
+ import { LangOption } from '../../lib/locales';
4
+ import { SubmissionRequest, SubmissionResponse } from '../../contexts/SubmissionContext';
5
+ import { DocumentCaptureWizardClassNames } from '../document_capture/DocumentCaptureWizard';
6
+ export type DocumentCaptureClassNames = DocumentCaptureWizardClassNames;
7
+ export interface DocumentCaptureProps extends PropsWithChildren {
8
+ /** Language code to use. Supported values: 'auto' (detect based on user's OS), 'en' (English), 'es' (Spanish). Defaults to auto. */
9
+ lang?: LangOption;
10
+ /** A token generated with your IDmission credentials. */
11
+ submissionToken: string;
12
+ /** URL to hit with all API requests. Defaults to the value specified in your decoded `submissionToken`. */
13
+ submissionUrl?: string;
14
+ /** Callback function that fires immediately prior to submission, giving the client application an opportunity to specify custom asynchronous logic that mutates the request before it executes. The submission request is passed in as a parameter and a promise resolving to the updated request should be returned. */
15
+ onBeforeSubmit?: (req: SubmissionRequest) => Promise<SubmissionRequest>;
16
+ /** Callback function that fires when the user has completed the flow instead of making a call to IDmission's servers, allowing customers to specify their own submission logic. Arguments: the request payload that would have been dispatched to IDmission's API, which contains the images/documents/video submitted by the user. Note that when this parameter is supplied, `onComplete` will never fire, and the customer will need to implement their own error handling/retry logic. Use at your own risk! */
17
+ onSubmit?: (req: SubmissionRequest) => void;
18
+ /** Callback function that fires when the user completes the DocumentCapture flow. Arguments: the SubmissionResponse from IDmission's API is passed as an argument to the customer's application for further handling, which indicates whether the user passed the validation check, and the request payload dispatched to IDmission's API, which contains the images submitted by the user. */
19
+ onComplete?: (resp: SubmissionResponse, req: SubmissionRequest) => void;
20
+ /** Callback function that fires when the user clicks the exit button during ID or selfie capture. */
21
+ onExitCapture?: () => void;
22
+ /** Callback function that fires when the user clicks the exit button from the loading overlay, declining to engage with IDmission. Binding this callback results in the cancel button being rendered on the loading overlay. */
23
+ onUserCancel?: () => void;
24
+ aspectRatio?: number;
25
+ instructions?: ReactNode;
26
+ /** Name of an included theme or object containing theme properties. **/
27
+ theme?: ThemeInput;
28
+ /** Object containing any classNames for inner components. **/
29
+ classNames?: DocumentCaptureClassNames;
30
+ }
31
+ /**
32
+ * Render a fullscreen capture component that instructs the user to photograph their document.
33
+ */
34
+ export declare const DocumentCapture: FC<DocumentCaptureProps>;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export type DocumentCaptureGuideOverlayClassNames = {
3
+ container?: string;
4
+ };
5
+ export type DocumentCaptureGuideOverlayProps = {
6
+ aspectRatio?: number;
7
+ borderRadius?: number;
8
+ borderColor?: string;
9
+ borderWidth?: number;
10
+ maskColor?: string;
11
+ padding?: number;
12
+ classNames?: DocumentCaptureGuideOverlayClassNames;
13
+ };
14
+ export declare const DocumentCaptureGuideOverlay: ({ aspectRatio, borderRadius, borderColor, borderWidth, maskColor, padding, classNames, }: DocumentCaptureGuideOverlayProps) => React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React, { ReactNode } from 'react';
2
+ export type DocumentCaptureWizardClassNames = {
3
+ container?: string;
4
+ cameraFeed?: string;
5
+ };
6
+ export type DocumentCaptureWizardProps = {
7
+ onSuccess?: () => void;
8
+ onExitCapture?: () => void;
9
+ onUserCancel?: () => void;
10
+ aspectRatio?: number;
11
+ instructions?: ReactNode;
12
+ classNames?: DocumentCaptureWizardClassNames;
13
+ };
14
+ export declare const DocumentCaptureWizard: ({ aspectRatio, instructions, classNames, }: DocumentCaptureWizardProps) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DocumentCaptureGuideOverlayClassNames } from './DocumentCaptureGuideOverlay';
2
+ import { IdCaptureGuideOverlayClassNames } from './IdCaptureGuideOverlay';
3
3
  import { PDF417DetectionResult } from '../../lib/barcode/Native';
4
4
  import { CaptureAttemptMetadata } from '../../contexts/SubmissionContext';
5
5
  import { IdCapturePrediction } from './IdCaptureModelsProvider';
@@ -12,7 +12,7 @@ export type IdCaptureAssets = {
12
12
  };
13
13
  export type IdCaptureClassNames = {
14
14
  container?: string;
15
- guides?: DocumentCaptureGuideOverlayClassNames;
15
+ guides?: IdCaptureGuideOverlayClassNames;
16
16
  guidanceMessageContainer?: string;
17
17
  guidanceMessage?: string;
18
18
  imagePreview?: IdCaptureImagePreviewClassNames;
@@ -831,7 +831,7 @@ export declare const GuideImage: import("styled-components").IStyledComponent<"w
831
831
  $height?: number | undefined;
832
832
  $padding: number;
833
833
  }>>;
834
- export type DocumentCaptureGuideOverlayClassNames = {
834
+ export type IdCaptureGuideOverlayClassNames = {
835
835
  container?: string;
836
836
  inner?: string;
837
837
  dimmingRegion?: string;
@@ -845,8 +845,8 @@ export type DocumentCaptureGuideOverlayClassNames = {
845
845
  image?: string;
846
846
  guideText?: string;
847
847
  };
848
- export type DocumentCaptureGuideOverlayProps = {
849
- classNames?: DocumentCaptureGuideOverlayClassNames;
848
+ export type IdCaptureGuideOverlayProps = {
849
+ classNames?: IdCaptureGuideOverlayClassNames;
850
850
  width?: number;
851
851
  height?: number;
852
852
  padding?: number;
@@ -859,4 +859,4 @@ export type DocumentCaptureGuideOverlayProps = {
859
859
  landscapeGuidesImageUrl?: string;
860
860
  onClick?: () => void;
861
861
  };
862
- export declare const DocumentCaptureGuideOverlay: ({ classNames, width, height, padding: userSuppliedPadding, imagePadding: userSuppliedImagePadding, borderWidth, borderColor, isMirrored, instruction, portraitGuidesImageUrl, landscapeGuidesImageUrl, onClick, }: DocumentCaptureGuideOverlayProps) => ReactElement;
862
+ export declare const IdCaptureGuideOverlay: ({ classNames, width, height, padding: userSuppliedPadding, imagePadding: userSuppliedImagePadding, borderWidth, borderColor, isMirrored, instruction, portraitGuidesImageUrl, landscapeGuidesImageUrl, onClick, }: IdCaptureGuideOverlayProps) => ReactElement;
@@ -46,7 +46,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
46
46
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
47
47
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
48
48
 
49
- var webSdkVersion = '1.0.101';
49
+ var webSdkVersion = '1.0.103';
50
50
 
51
51
  function getPlatform() {
52
52
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1394,9 +1394,10 @@ function isBrowser() {
1394
1394
  (typeof WorkerGlobalScope !== 'undefined');
1395
1395
  }
1396
1396
 
1397
- var GuidesContainer = styled__default['default'].div(templateObject_1$t || (templateObject_1$t = tslib.__makeTemplateObject(["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"], ["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"])));
1398
- var GuideCenterRow = styled__default['default'].div(templateObject_2$h || (templateObject_2$h = tslib.__makeTemplateObject(["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"], ["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"])));
1399
- var GuideRegion = styled__default['default'].div(templateObject_3$c || (templateObject_3$c = tslib.__makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"], ["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"])), function (props) {
1397
+ var StyledPageContainer = styled__default['default'](PageContainer)(templateObject_1$t || (templateObject_1$t = tslib.__makeTemplateObject(["\n z-index: 1000;\n"], ["\n z-index: 1000;\n"])));
1398
+ var GuidesContainer = styled__default['default'].div(templateObject_2$h || (templateObject_2$h = tslib.__makeTemplateObject(["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"], ["\n display: flex;\n flex-flow: column nowrap;\n width: 100%;\n height: 100%;\n"])));
1399
+ var GuideCenterRow = styled__default['default'].div(templateObject_3$c || (templateObject_3$c = tslib.__makeTemplateObject(["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"], ["\n position: relative;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-items: center;\n box-sizing: border-box;\n max-width: 100%;\n max-height: 100%;\n"])));
1400
+ var GuideRegion = styled__default['default'].div(templateObject_4$8 || (templateObject_4$8 = tslib.__makeTemplateObject(["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"], ["\n display: flex;\n flex-direction: column;\n justify-content: end;\n width: 100%;\n height: 100%;\n flex-grow: 1;\n background: ", ";\n color: ", ";\n text-align: center;\n ", "\n ", "\n"])), function (props) {
1400
1401
  var _a, _b, _c, _d;
1401
1402
  return (_d = (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.guideOverlay) === null || _c === void 0 ? void 0 : _c.backgroundColor) !== null && _d !== void 0 ? _d : 'rgba(0, 0, 0, 0.5)';
1402
1403
  }, function (props) {
@@ -1407,22 +1408,22 @@ var GuideRegion = styled__default['default'].div(templateObject_3$c || (template
1407
1408
  }, function (props) {
1408
1409
  return props.$minHeight ? "min-width: ".concat(props.$minHeight, "px;") : "";
1409
1410
  });
1410
- var GuideCenterRegion = styled__default['default'].div(templateObject_4$8 || (templateObject_4$8 = tslib.__makeTemplateObject(["\n ", "\n box-sizing: border-box;\n"], ["\n ", "\n box-sizing: border-box;\n"])), function (props) {
1411
+ var GuideCenterRegion = styled__default['default'].div(templateObject_5$3 || (templateObject_5$3 = tslib.__makeTemplateObject(["\n ", "\n box-sizing: border-box;\n"], ["\n ", "\n box-sizing: border-box;\n"])), function (props) {
1411
1412
  return props.$isMirrored ? 'transform: scaleX(-1);' : '';
1412
1413
  });
1413
- var GuideCenterBorder = styled__default['default'].div(templateObject_5$3 || (templateObject_5$3 = tslib.__makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"], ["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"])), function (props) {
1414
+ var GuideCenterBorder = styled__default['default'].div(templateObject_6$2 || (templateObject_6$2 = tslib.__makeTemplateObject(["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"], ["\n box-sizing: border-box;\n position: relative;\n border: ", ";\n"])), function (props) {
1414
1415
  var _a, _b;
1415
1416
  return "".concat((_a = props.$borderWidth) !== null && _a !== void 0 ? _a : 4, "px solid ").concat((_b = props.$borderColor) !== null && _b !== void 0 ? _b : 'white');
1416
1417
  });
1417
- var GuideText = styled__default['default'].span(templateObject_6$2 || (templateObject_6$2 = tslib.__makeTemplateObject(["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"], ["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"])));
1418
- var GuideImage = styled__default['default'].img(templateObject_7 || (templateObject_7 = tslib.__makeTemplateObject(["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"], ["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"])), function (props) {
1418
+ var GuideText = styled__default['default'].span(templateObject_7 || (templateObject_7 = tslib.__makeTemplateObject(["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"], ["\n align-content: center;\n margin-top: 12px;\n margin-bottom: 12px;\n"])));
1419
+ var GuideImage = styled__default['default'].img(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"], ["\n display: block;\n padding: ", "px;\n box-sizing: border-box;\n ", "\n ", "\n"])), function (props) {
1419
1420
  return props.$padding;
1420
1421
  }, function (props) {
1421
1422
  return props.$width ? "width: ".concat(props.$width, "px;\n max-width: ").concat(props.$width, "px;") : "max-width: none;";
1422
1423
  }, function (props) {
1423
1424
  return props.$height ? "height: ".concat(props.$height, "px;\n max-height: ").concat(props.$height, "px;") : "max-height: none;";
1424
1425
  });
1425
- var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
1426
+ var IdCaptureGuideOverlay = function IdCaptureGuideOverlay(_a) {
1426
1427
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1427
1428
  var _p = _a.classNames,
1428
1429
  classNames = _p === void 0 ? {} : _p,
@@ -1514,7 +1515,6 @@ var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
1514
1515
  }
1515
1516
  }, instruction)))));
1516
1517
  };
1517
- var StyledPageContainer = styled__default['default'](PageContainer)(templateObject_8 || (templateObject_8 = tslib.__makeTemplateObject(["\n z-index: 1000;\n"], ["\n z-index: 1000;\n"])));
1518
1518
  var regionClsx$1 = function regionClsx(classNames, which) {
1519
1519
  return [classNames.dimmingRegion, classNames["dimmingRegion".concat(which)]].filter(function (v) {
1520
1520
  return v;
@@ -2127,13 +2127,13 @@ function loadFocusModel(url) {
2127
2127
  case 2:
2128
2128
  _e.sent();
2129
2129
  zeroes = tf__namespace.zeros([448, 448, 3]);
2130
- tfInt32 = tf__namespace.cast(zeroes, 'int32');
2130
+ tfInt32 = tf__namespace.cast(zeroes, 'float32');
2131
2131
  _b = (_a = tf__namespace).tensor4d;
2132
2132
  _d = (_c = Array).from;
2133
2133
  return [4 /*yield*/, tfInt32.data()];
2134
2134
  case 3:
2135
2135
  tf4d_ = _b.apply(_a, [_d.apply(_c, [_e.sent()]), [1, 448, 448, 3]]);
2136
- tf4d = tf__namespace.cast(tf4d_, 'int32');
2136
+ tf4d = tf__namespace.cast(tf4d_, 'float32');
2137
2137
  return [4 /*yield*/, focusModel.predict(tf4d)];
2138
2138
  case 4:
2139
2139
  warmupResult = _e.sent();
@@ -9166,9 +9166,9 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
9166
9166
  } else {
9167
9167
  tfImg = tf__namespace.browser.fromPixels(imageData);
9168
9168
  }
9169
- tfResize = tf__namespace.image.resizeBilinear(tfImg, [448, 448]);
9169
+ tfResize = tf__namespace.image.resizeBilinear(tfImg, [448, 448]).div(tf__namespace.scalar(127.5)).sub(tf__namespace.scalar(1));
9170
9170
  tfImg.dispose();
9171
- tfInt32 = tf__namespace.cast(tfResize, 'int32');
9171
+ tfInt32 = tf__namespace.cast(tfResize, 'float32');
9172
9172
  tfResize.dispose();
9173
9173
  _b = (_a = tf__namespace).tensor4d;
9174
9174
  _d = (_c = Array).from;
@@ -9176,7 +9176,7 @@ function makeFocusPrediction(imageData, bbox, logPredictions) {
9176
9176
  case 2:
9177
9177
  tf4d_ = _b.apply(_a, [_d.apply(_c, [_e.sent()]), [1, 448, 448, 3]]);
9178
9178
  tfInt32.dispose();
9179
- tf4d = tf__namespace.cast(tf4d_, 'int32');
9179
+ tf4d = tf__namespace.cast(tf4d_, 'float32');
9180
9180
  tf4d_.dispose();
9181
9181
  if (logPredictions) console.time('focus prediction');
9182
9182
  return [4 /*yield*/, focusModel.predict(tf4d)];
@@ -10128,7 +10128,7 @@ var IdCapture = function IdCapture(_a) {
10128
10128
  return /*#__PURE__*/React__default['default'].createElement(PageContainer, {
10129
10129
  ref: ref,
10130
10130
  className: "flex ".concat((_l = classNames.container) !== null && _l !== void 0 ? _l : '')
10131
- }, /*#__PURE__*/React__default['default'].createElement(DocumentCaptureGuideOverlay, {
10131
+ }, /*#__PURE__*/React__default['default'].createElement(IdCaptureGuideOverlay, {
10132
10132
  classNames: classNames.guides,
10133
10133
  width: width,
10134
10134
  height: height,