gbc-kyc-kit 2.0.1 → 2.0.2

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.
@@ -40928,7 +40928,6 @@ BlackList.propTypes = {
40928
40928
  validateVpn: propTypes.exports.PropTypes.bool
40929
40929
  };
40930
40930
  const DocumentReaderController = (dataDocument, clientId, authorize, eventId, source2, inProduction, countryCodeAllowed, validateVpn, successMessage, dualModeRequired) => {
40931
- const [docImage, setDocImage] = useState({});
40932
40931
  const [base64, setBase64] = useState({});
40933
40932
  const [message, setMessage] = useState("");
40934
40933
  const [isLoading, setIsLoading] = useState(false);
@@ -40936,7 +40935,6 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
40936
40935
  const [countryCode, setCountryCode] = useState(null);
40937
40936
  const geolocation = useGeolocation(inProduction);
40938
40937
  const [dualMode, setDualMode] = useState(dualModeRequired);
40939
- const [thumbnails, setThumbnails] = useState([]);
40940
40938
  const webcamRef = useRef(null);
40941
40939
  const [activateCamera, setActivateCamera] = useState(false);
40942
40940
  const [videoDimensions, setVideoDimensions] = useState({
@@ -40973,7 +40971,6 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
40973
40971
  countryCodeAllowed && geolocation && setCountryCode(geolocation == null ? void 0 : geolocation.data_connection.isocode);
40974
40972
  }, [geolocation, countryCodeAllowed]);
40975
40973
  const clearState = () => {
40976
- setDocImage({});
40977
40974
  setDualMode(dualModeRequired);
40978
40975
  setBase64({});
40979
40976
  setStatus("");
@@ -40983,136 +40980,7 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
40983
40980
  const {
40984
40981
  handleSubmit: simpleHandleSubmit
40985
40982
  } = useForm();
40986
- const handleChangeDocument = (e2, side) => {
40987
- const file = e2.target.files[0];
40988
- const {
40989
- id
40990
- } = e2.target;
40991
- const reader = new FileReader();
40992
- const allowedTypeFile = ["image/jpg", "image/png", "image/jpeg"];
40993
- if (allowedTypeFile.includes(file.type)) {
40994
- reader.addEventListener("load", async () => {
40995
- const {
40996
- result
40997
- } = reader;
40998
- if (result != null) {
40999
- const img = new Image();
41000
- img.src = result;
41001
- img.onload = async () => {
41002
- let newWidth = img.width;
41003
- let newHeight = img.height;
41004
- if (newWidth > 1e3) {
41005
- newWidth = 1e3;
41006
- newHeight = img.height * 1e3 / img.width;
41007
- }
41008
- if (newHeight > 1e3) {
41009
- newHeight = 1e3;
41010
- newWidth = img.width * 1e3 / img.height;
41011
- }
41012
- const canvas = document.createElement("canvas");
41013
- canvas.width = newWidth;
41014
- canvas.height = newHeight;
41015
- const ctx = canvas.getContext("2d");
41016
- ctx.drawImage(img, 0, 0, newWidth, newHeight);
41017
- const resizedBase64 = canvas.toDataURL(file.type);
41018
- setBase64({
41019
- ...base64,
41020
- [id]: resizedBase64
41021
- });
41022
- setDocImage({
41023
- ...docImage,
41024
- [id]: file.name
41025
- });
41026
- };
41027
- }
41028
- });
41029
- reader.readAsDataURL(file);
41030
- } else {
41031
- setMessage("Tipo de documento no v\xE1lido");
41032
- setStatus(400);
41033
- }
41034
- };
41035
40983
  const onSendSubmitDocument = async () => {
41036
- var _a;
41037
- setIsLoading(true);
41038
- try {
41039
- const res2 = await authorize();
41040
- const customHeaders = {
41041
- client_id: clientId,
41042
- access_token: res2
41043
- };
41044
- const parseReq2 = {
41045
- method: "POST",
41046
- path: "api/v1/kyc-kit/document/recognition",
41047
- inProduction,
41048
- customHeaders,
41049
- bodyParams: base64
41050
- };
41051
- try {
41052
- const res22 = await request2(parseReq2);
41053
- const fullData = res22.data.data;
41054
- const dataOcrSaved = await saveDataToDB({
41055
- data: {
41056
- ...fullData,
41057
- status_code: 200
41058
- },
41059
- component: "ocr",
41060
- eventId,
41061
- source: source2,
41062
- inProduction,
41063
- clientId,
41064
- geolocation
41065
- });
41066
- dataOcrSaved && Object.assign(fullData, {
41067
- checkIp: dataOcrSaved.check_ip
41068
- });
41069
- fullData && await dataDocument(fullData);
41070
- const {
41071
- message: message2
41072
- } = res22.data;
41073
- message2 && setStatus(message2);
41074
- setMessage(successMessage ? successMessage : "Documento verificado con \xE9xito");
41075
- } catch (error) {
41076
- let message2 = "";
41077
- const {
41078
- status: status2
41079
- } = error.response;
41080
- const data2 = await saveDataToDB({
41081
- data: {
41082
- first_image: base64.firstImage,
41083
- second_image: base64.secondImage,
41084
- status_code: status2
41085
- },
41086
- component: "ocr",
41087
- eventId,
41088
- source: source2,
41089
- inProduction,
41090
- clientId,
41091
- geolocation
41092
- });
41093
- await dataDocument({
41094
- ...error,
41095
- countAttempts: data2.count_try
41096
- });
41097
- if ((_a = error.response.data) == null ? void 0 : _a.message) {
41098
- message2 = error.response.data.message;
41099
- } else if (status2 === 500) {
41100
- message2 = {
41101
- limit_of_request
41102
- };
41103
- }
41104
- setIsLoading(null);
41105
- setMessage(message2);
41106
- setStatus(status2);
41107
- ErrorHandler(error);
41108
- }
41109
- } catch (error) {
41110
- Q.error("Error - Verificar host con el proveedor");
41111
- } finally {
41112
- setIsLoading(false);
41113
- }
41114
- };
41115
- const onSendSubmitDocument2 = async () => {
41116
40984
  var _a;
41117
40985
  setIsLoading(true);
41118
40986
  try {
@@ -41194,7 +41062,6 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
41194
41062
  }
41195
41063
  };
41196
41064
  const onUploadImage = async () => {
41197
- videoDimensions.width / videoDimensions.height;
41198
41065
  const getImage = webcamRef.current.getScreenshot();
41199
41066
  setBase64(base64.firstImage ? {
41200
41067
  ...base64,
@@ -41210,11 +41077,9 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
41210
41077
  facingMode: "environment"
41211
41078
  };
41212
41079
  return {
41213
- handleChangeDocument,
41214
41080
  onSendSubmitDocument,
41215
41081
  simpleHandleSubmit,
41216
41082
  isLoading,
41217
- docImage,
41218
41083
  status,
41219
41084
  message,
41220
41085
  base64,
@@ -41225,9 +41090,6 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
41225
41090
  setDualMode,
41226
41091
  dualModeRequired,
41227
41092
  onUploadImage,
41228
- thumbnails,
41229
- setThumbnails,
41230
- onSendSubmitDocument2,
41231
41093
  webcamRef,
41232
41094
  activateCamera,
41233
41095
  setActivateCamera,
@@ -41265,172 +41127,9 @@ function UploadDocument({
41265
41127
  })
41266
41128
  }, id);
41267
41129
  }
41268
- function CustomCheckbox({
41269
- isActive,
41270
- label,
41271
- onChange
41272
- }) {
41273
- return /* @__PURE__ */ jsxs("label", {
41274
- className: "custom-checkbox",
41275
- children: [/* @__PURE__ */ jsx("input", {
41276
- type: "checkbox",
41277
- checked: isActive,
41278
- onChange
41279
- }), /* @__PURE__ */ jsx("span", {
41280
- className: "checkmark"
41281
- }), label]
41282
- });
41283
- }
41284
41130
  const validateErrorMessageOCR = (message) => {
41285
41131
  return message === "Tipo de documento no v\xE1lido" || message === "Datos de la imagen no reconocidas" || message === "Dato no reconocido(Primer Nombre)" || message == "Dato no reconocido(Primer Apellido)" || message == "";
41286
41132
  };
41287
- function DocumentReader({
41288
- mode = "light",
41289
- dataDocument,
41290
- clientId,
41291
- authorize,
41292
- eventId = null,
41293
- source: source2 = "component",
41294
- inProduction = "prd",
41295
- countryCodeAllowed = null,
41296
- validateVpn = false,
41297
- successMessage,
41298
- dualModeRequired = false
41299
- }) {
41300
- const {
41301
- onSendSubmitDocument,
41302
- handleChangeDocument,
41303
- simpleHandleSubmit,
41304
- isLoading,
41305
- docImage,
41306
- status,
41307
- message,
41308
- clearState,
41309
- base64,
41310
- countryCode,
41311
- setDualMode,
41312
- dualMode
41313
- } = DocumentReaderController(dataDocument, clientId, authorize, eventId, source2, inProduction, countryCodeAllowed, validateVpn, successMessage, dualModeRequired);
41314
- return /* @__PURE__ */ jsxs("div", {
41315
- className: `kit-gbc ${mode}`,
41316
- children: [/* @__PURE__ */ jsx(k$3, {
41317
- position: "top-center",
41318
- autoClose: 5e3,
41319
- hideProgressBar: false,
41320
- newestOnTop: false,
41321
- closeOnClick: true,
41322
- rtl: false,
41323
- pauseOnFocusLoss: true,
41324
- draggable: true,
41325
- pauseOnHover: true
41326
- }), isLoading || countryCodeAllowed !== null && !countryCode ? /* @__PURE__ */ jsx(BackDropLoader, {}) : null, /* @__PURE__ */ jsx("form", {
41327
- onSubmit: simpleHandleSubmit(onSendSubmitDocument),
41328
- id: "document-reader",
41329
- children: /* @__PURE__ */ jsxs("div", {
41330
- className: "sub",
41331
- children: [(source2 !== "secure_link" || validateErrorMessageOCR(message)) && showBackButton(status) && /* @__PURE__ */ jsx(BackButton, {
41332
- action: clearState
41333
- }), /* @__PURE__ */ jsxs("div", {
41334
- className: "header-component",
41335
- children: [/* @__PURE__ */ jsx("h4", {
41336
- children: "Lectura del documento"
41337
- }), !lib$1(status) ? /* @__PURE__ */ jsx(StatusComponent, {
41338
- status,
41339
- message
41340
- }) : /* @__PURE__ */ jsx("p", {
41341
- children: "Utilice la c\xE1mara de su dispositivo para capturar una foto de su documento de identidad."
41342
- })]
41343
- }), lib$1(status) && /* @__PURE__ */ jsxs("div", {
41344
- className: `body-id-doc ${dualMode && docImage.firstImage ? "ready" : ""}`,
41345
- children: [/* @__PURE__ */ jsxs("label", {
41346
- className: "upload-document front",
41347
- style: {
41348
- display: "flex"
41349
- },
41350
- children: [docImage.firstImage ? /* @__PURE__ */ jsx("img", {
41351
- src: base64.firstImage,
41352
- alt: "front-document"
41353
- }) : /* @__PURE__ */ jsx(UploadDocument, {
41354
- id: "front",
41355
- message: "Carga frontal"
41356
- }), /* @__PURE__ */ jsx("input", {
41357
- type: "file",
41358
- hidden: true,
41359
- capture: "camera",
41360
- id: "firstImage",
41361
- onChange: (e2) => {
41362
- handleChangeDocument(e2);
41363
- }
41364
- })]
41365
- }, "front-doc"), /* @__PURE__ */ jsxs("label", {
41366
- className: "upload-document back",
41367
- style: {
41368
- display: "flex"
41369
- },
41370
- children: [docImage.secondImage ? /* @__PURE__ */ jsx("img", {
41371
- src: base64.secondImage,
41372
- alt: "rear-document"
41373
- }) : /* @__PURE__ */ jsx(UploadDocument, {
41374
- id: "rear",
41375
- message: "Carga del Reverso"
41376
- }), /* @__PURE__ */ jsx("input", {
41377
- type: "file",
41378
- hidden: true,
41379
- capture: "camera",
41380
- id: "secondImage",
41381
- onChange: (e2) => {
41382
- handleChangeDocument(e2);
41383
- }
41384
- })]
41385
- }, "back-doc")]
41386
- }), /* @__PURE__ */ jsxs(Box$1, {
41387
- width: "100%",
41388
- children: [!status && /* @__PURE__ */ jsxs(Box$1, {
41389
- children: [!dualModeRequired && /* @__PURE__ */ jsx(Box$1, {
41390
- display: "flex",
41391
- children: /* @__PURE__ */ jsx(CustomCheckbox, {
41392
- id: "reverse-document",
41393
- label: "Cargar reverso del documento",
41394
- onChange: () => setDualMode(!dualMode)
41395
- })
41396
- }), !dualMode && !base64.secondImage && base64.firstImage && lib$1(status) && /* @__PURE__ */ jsx(CustomButton, {
41397
- type: "submit",
41398
- children: "Procesar"
41399
- })]
41400
- }), docImage.firstImage && dualMode && docImage.secondImage || !dualMode && docImage.secondImage || status && status != {
41401
- status_country_not_allowed
41402
- } && status != {
41403
- status_token: status_token$1
41404
- } && status != {
41405
- status_client_id: status_client_id$1
41406
- } && status != {
41407
- status_vpn
41408
- } ? /* @__PURE__ */ jsx(Box$1, {
41409
- children: /* @__PURE__ */ jsx("div", {
41410
- className: `${!status && "both-button"}`,
41411
- children: !status && /* @__PURE__ */ jsx(CustomButton, {
41412
- type: "submit",
41413
- children: "Procesar"
41414
- })
41415
- })
41416
- }) : null]
41417
- })]
41418
- })
41419
- })]
41420
- });
41421
- }
41422
- DocumentReader.propTypes = {
41423
- mode: propTypes.exports.PropTypes.string,
41424
- clientId: propTypes.exports.PropTypes.string.isRequired,
41425
- authorize: propTypes.exports.PropTypes.func.isRequired,
41426
- dataDocument: propTypes.exports.PropTypes.func.isRequired,
41427
- inProduction: propTypes.exports.PropTypes.string,
41428
- countryCodeAllowed: propTypes.exports.PropTypes.array,
41429
- source: propTypes.exports.PropTypes.string,
41430
- eventId: propTypes.exports.PropTypes.string,
41431
- validateVpn: propTypes.exports.PropTypes.bool,
41432
- dualModeRequired: propTypes.exports.PropTypes.bool
41433
- };
41434
41133
  var reactWebcam = { exports: {} };
41435
41134
  (function(module, exports) {
41436
41135
  (function webpackUniversalModuleDefinition(root2, factory) {
@@ -41826,7 +41525,7 @@ var reactWebcam = { exports: {} };
41826
41525
  });
41827
41526
  })(reactWebcam);
41828
41527
  var Webcam = /* @__PURE__ */ getDefaultExportFromCjs(reactWebcam.exports);
41829
- function DocumentReader2({
41528
+ function DocumentReader({
41830
41529
  mode = "light",
41831
41530
  dataDocument,
41832
41531
  clientId,
@@ -41840,18 +41539,15 @@ function DocumentReader2({
41840
41539
  dualModeRequired = false
41841
41540
  }) {
41842
41541
  const {
41843
- onSendSubmitDocument2,
41542
+ onSendSubmitDocument,
41844
41543
  simpleHandleSubmit,
41845
41544
  isLoading,
41846
- docImage,
41847
41545
  status,
41848
41546
  message,
41849
41547
  clearState,
41850
41548
  base64,
41851
41549
  setBase64,
41852
41550
  countryCode,
41853
- thumbnails,
41854
- setThumbnails,
41855
41551
  onUploadImage,
41856
41552
  webcamRef,
41857
41553
  activateCamera,
@@ -41871,7 +41567,7 @@ function DocumentReader2({
41871
41567
  draggable: true,
41872
41568
  pauseOnHover: true
41873
41569
  }), isLoading || countryCodeAllowed !== null && !countryCode ? /* @__PURE__ */ jsx(BackDropLoader, {}) : null, /* @__PURE__ */ jsx("form", {
41874
- onSubmit: simpleHandleSubmit(onSendSubmitDocument2),
41570
+ onSubmit: simpleHandleSubmit(onSendSubmitDocument),
41875
41571
  id: "document-reader",
41876
41572
  children: /* @__PURE__ */ jsxs("div", {
41877
41573
  className: "sub",
@@ -41925,9 +41621,6 @@ function DocumentReader2({
41925
41621
  }), /* @__PURE__ */ jsx(Typography$1, {
41926
41622
  variant: "body2",
41927
41623
  children: " Subir frontal y reverso"
41928
- }), /* @__PURE__ */ jsx(Typography$1, {
41929
- variant: "body2",
41930
- children: " Tama\xF1o m\xE1ximo permitido 3Mb"
41931
41624
  })]
41932
41625
  })]
41933
41626
  }), Object.keys(base64).length > 0 && /* @__PURE__ */ jsx(Box$1, {
@@ -41989,7 +41682,7 @@ function DocumentReader2({
41989
41682
  })]
41990
41683
  });
41991
41684
  }
41992
- DocumentReader2.propTypes = {
41685
+ DocumentReader.propTypes = {
41993
41686
  mode: propTypes.exports.PropTypes.string,
41994
41687
  clientId: propTypes.exports.PropTypes.string.isRequired,
41995
41688
  authorize: propTypes.exports.PropTypes.func.isRequired,
@@ -62221,4 +61914,4 @@ var bootstrap_bundle_min = { exports: {} };
62221
61914
  return R2(In), g2(In), { Alert: q2, Button: K, Carousel: at, Collapse: pt, Dropdown: li, Modal: Si, Offcanvas: Bi, Popover: hn, ScrollSpy: mn, Tab: On, Toast: In, Tooltip: an };
62222
61915
  });
62223
61916
  })(bootstrap_bundle_min);
62224
- export { BlackList, BulkVerification, DocumentReader, DocumentReader2, FaceMatch, LivenessCheck };
61917
+ export { BlackList, BulkVerification, DocumentReader, FaceMatch, LivenessCheck };