gbc-kyc-kit 2.2.2 → 2.2.4
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/dist/gbc-kyc-kit.es.js +130 -30
- package/dist/gbc-kyc-kit.umd.js +66 -66
- package/package.json +1 -1
package/dist/gbc-kyc-kit.es.js
CHANGED
|
@@ -18487,7 +18487,7 @@ function CustomButton({
|
|
|
18487
18487
|
href
|
|
18488
18488
|
}) {
|
|
18489
18489
|
return /* @__PURE__ */ jsx$1("div", {
|
|
18490
|
-
className: `button-container m-0 mt-2`,
|
|
18490
|
+
className: `button-container m-0 mt-2 testing`,
|
|
18491
18491
|
children: /* @__PURE__ */ jsx$1("button", {
|
|
18492
18492
|
type,
|
|
18493
18493
|
name,
|
|
@@ -39051,6 +39051,14 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
|
|
|
39051
39051
|
setBase64(newImage);
|
|
39052
39052
|
setActivateCamera(false);
|
|
39053
39053
|
};
|
|
39054
|
+
const onUploadImage2 = async (side, image) => {
|
|
39055
|
+
const newImage = Object.assign(base64, {
|
|
39056
|
+
[side]: image
|
|
39057
|
+
});
|
|
39058
|
+
console.log(newImage);
|
|
39059
|
+
setBase64(newImage);
|
|
39060
|
+
setActivateCamera(false);
|
|
39061
|
+
};
|
|
39054
39062
|
const usePortrait = () => {
|
|
39055
39063
|
const [isPortrait2, setIsPortrait] = useState(window.innerHeight > window.innerWidth);
|
|
39056
39064
|
useEffect(() => {
|
|
@@ -39103,26 +39111,53 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
|
|
|
39103
39111
|
webcamRef,
|
|
39104
39112
|
activateCamera,
|
|
39105
39113
|
setActivateCamera,
|
|
39106
|
-
videoConstraints
|
|
39114
|
+
videoConstraints,
|
|
39115
|
+
onUploadImage2
|
|
39107
39116
|
};
|
|
39108
39117
|
};
|
|
39109
39118
|
const validateErrorMessageOCR = (message) => {
|
|
39110
39119
|
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 == "";
|
|
39111
39120
|
};
|
|
39112
|
-
function
|
|
39121
|
+
function UploadDocument2({
|
|
39113
39122
|
setActivateCamera,
|
|
39114
39123
|
activateCamera,
|
|
39115
|
-
webcamRef,
|
|
39116
|
-
Webcam: Webcam2,
|
|
39117
39124
|
videoConstraints,
|
|
39118
39125
|
base64,
|
|
39119
|
-
detail
|
|
39126
|
+
detail,
|
|
39127
|
+
videoRef,
|
|
39128
|
+
streamRef,
|
|
39129
|
+
onTapToFocus
|
|
39120
39130
|
}) {
|
|
39131
|
+
console.log(videoConstraints);
|
|
39132
|
+
useEffect(() => {
|
|
39133
|
+
if (activateCamera && videoRef.current) {
|
|
39134
|
+
navigator.mediaDevices.getUserMedia({
|
|
39135
|
+
video: videoConstraints || {
|
|
39136
|
+
facingMode: "environment"
|
|
39137
|
+
},
|
|
39138
|
+
audio: false
|
|
39139
|
+
}).then((stream) => {
|
|
39140
|
+
if (videoRef.current) {
|
|
39141
|
+
videoRef.current.srcObject = stream;
|
|
39142
|
+
videoRef.current.play();
|
|
39143
|
+
streamRef.current = stream;
|
|
39144
|
+
}
|
|
39145
|
+
}).catch((err) => {
|
|
39146
|
+
console.error("Error al acceder a la c\xE1mara:", err);
|
|
39147
|
+
});
|
|
39148
|
+
}
|
|
39149
|
+
return () => {
|
|
39150
|
+
if (streamRef.current) {
|
|
39151
|
+
streamRef.current.getTracks().forEach((track) => track.stop());
|
|
39152
|
+
streamRef.current = null;
|
|
39153
|
+
}
|
|
39154
|
+
};
|
|
39155
|
+
}, [activateCamera, videoConstraints]);
|
|
39121
39156
|
return /* @__PURE__ */ jsx$1("div", {
|
|
39122
39157
|
className: "drag-zone",
|
|
39123
39158
|
children: /* @__PURE__ */ jsx$1(Box$1, {
|
|
39124
39159
|
className: "drag-and-drop-container",
|
|
39125
|
-
children: /* @__PURE__ */
|
|
39160
|
+
children: /* @__PURE__ */ jsx$1(Box$1, {
|
|
39126
39161
|
onClick: () => setActivateCamera(true),
|
|
39127
39162
|
position: "relative",
|
|
39128
39163
|
zIndex: 1,
|
|
@@ -39132,12 +39167,8 @@ function UploadDocument({
|
|
|
39132
39167
|
display: "flex",
|
|
39133
39168
|
justifyContent: "center",
|
|
39134
39169
|
alignItems: "center",
|
|
39135
|
-
children:
|
|
39136
|
-
ref:
|
|
39137
|
-
videoConstraints,
|
|
39138
|
-
screenshotFormat: "image/jpeg",
|
|
39139
|
-
forceScreenshotSourceSize: true,
|
|
39140
|
-
audio: false,
|
|
39170
|
+
children: activateCamera ? /* @__PURE__ */ jsx$1("video", {
|
|
39171
|
+
ref: videoRef,
|
|
39141
39172
|
style: {
|
|
39142
39173
|
width: "100%",
|
|
39143
39174
|
height: "100%",
|
|
@@ -39147,8 +39178,12 @@ function UploadDocument({
|
|
|
39147
39178
|
left: "50%",
|
|
39148
39179
|
transform: "translate(-50%, -50%)",
|
|
39149
39180
|
borderRadius: "5px"
|
|
39150
|
-
}
|
|
39151
|
-
|
|
39181
|
+
},
|
|
39182
|
+
onClick: onTapToFocus,
|
|
39183
|
+
playsInline: true,
|
|
39184
|
+
muted: true,
|
|
39185
|
+
autoPlay: true
|
|
39186
|
+
}) : /* @__PURE__ */ jsxs(Box$1, {
|
|
39152
39187
|
children: [/* @__PURE__ */ jsx$1(CloudUploadIcon, {}), /* @__PURE__ */ jsx$1(Typography$1, {
|
|
39153
39188
|
variant: "h6",
|
|
39154
39189
|
className: "title",
|
|
@@ -39158,7 +39193,7 @@ function UploadDocument({
|
|
|
39158
39193
|
variant: "body2",
|
|
39159
39194
|
children: detail
|
|
39160
39195
|
})]
|
|
39161
|
-
})
|
|
39196
|
+
})
|
|
39162
39197
|
})
|
|
39163
39198
|
})
|
|
39164
39199
|
});
|
|
@@ -39179,6 +39214,7 @@ function CustomTabPanel(props) {
|
|
|
39179
39214
|
onUploadImage,
|
|
39180
39215
|
dualModeRequired,
|
|
39181
39216
|
status,
|
|
39217
|
+
onUploadImage2,
|
|
39182
39218
|
...other
|
|
39183
39219
|
} = props;
|
|
39184
39220
|
return /* @__PURE__ */ jsx$1("div", {
|
|
@@ -39213,7 +39249,8 @@ function SideDocsSelector({
|
|
|
39213
39249
|
videoConstraints,
|
|
39214
39250
|
onUploadImage,
|
|
39215
39251
|
dualModeRequired,
|
|
39216
|
-
status
|
|
39252
|
+
status,
|
|
39253
|
+
onUploadImage2
|
|
39217
39254
|
}) {
|
|
39218
39255
|
const [value, setValue] = React$2.useState(0);
|
|
39219
39256
|
const [showZoom, setShowZoom] = React$2.useState(false);
|
|
@@ -39230,6 +39267,63 @@ function SideDocsSelector({
|
|
|
39230
39267
|
const toggleZoom = () => {
|
|
39231
39268
|
setShowZoom(!showZoom);
|
|
39232
39269
|
};
|
|
39270
|
+
const videoRef = useRef(null);
|
|
39271
|
+
const streamRef = useRef(null);
|
|
39272
|
+
const takeScreenshot = (side) => {
|
|
39273
|
+
const video = videoRef.current;
|
|
39274
|
+
if (!video)
|
|
39275
|
+
return;
|
|
39276
|
+
const canvas = document.createElement("canvas");
|
|
39277
|
+
canvas.width = video.videoWidth;
|
|
39278
|
+
canvas.height = video.videoHeight;
|
|
39279
|
+
const ctx = canvas.getContext("2d");
|
|
39280
|
+
ctx && ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
39281
|
+
const imageData = canvas.toDataURL("image/jpeg");
|
|
39282
|
+
onUploadImage2(side, imageData);
|
|
39283
|
+
};
|
|
39284
|
+
const handleTapToFocus = async () => {
|
|
39285
|
+
var _a, _b;
|
|
39286
|
+
if (!streamRef.current)
|
|
39287
|
+
return;
|
|
39288
|
+
const [track] = streamRef.current.getVideoTracks();
|
|
39289
|
+
const capabilities = (_a = track.getCapabilities) == null ? void 0 : _a.call(track);
|
|
39290
|
+
const settings = (_b = track.getSettings) == null ? void 0 : _b.call(track);
|
|
39291
|
+
console.log("focus capabilities:", capabilities);
|
|
39292
|
+
console.log("focus settings:", settings);
|
|
39293
|
+
if (!capabilities || !capabilities.focusMode) {
|
|
39294
|
+
console.warn("No se puede acceder a las capacidades de enfoque");
|
|
39295
|
+
return;
|
|
39296
|
+
}
|
|
39297
|
+
try {
|
|
39298
|
+
if (capabilities.focusMode.includes("continuous")) {
|
|
39299
|
+
await track.applyConstraints({
|
|
39300
|
+
advanced: [{
|
|
39301
|
+
focusMode: "continuous"
|
|
39302
|
+
}]
|
|
39303
|
+
});
|
|
39304
|
+
console.log("Reiniciado enfoque autom\xE1tico (continuous)");
|
|
39305
|
+
} else if (capabilities.focusMode.includes("single-shot")) {
|
|
39306
|
+
await track.applyConstraints({
|
|
39307
|
+
advanced: [{
|
|
39308
|
+
focusMode: "single-shot"
|
|
39309
|
+
}]
|
|
39310
|
+
});
|
|
39311
|
+
console.log("Aplicado enfoque tipo single-shot");
|
|
39312
|
+
} else if (capabilities.focusMode.includes("manual") && capabilities.focusDistance) {
|
|
39313
|
+
await track.applyConstraints({
|
|
39314
|
+
advanced: [{
|
|
39315
|
+
focusMode: "manual",
|
|
39316
|
+
focusDistance: capabilities.focusDistance.min
|
|
39317
|
+
}]
|
|
39318
|
+
});
|
|
39319
|
+
console.log("Aplicado enfoque manual al m\xEDnimo");
|
|
39320
|
+
} else {
|
|
39321
|
+
console.warn("No hay modo de enfoque compatible");
|
|
39322
|
+
}
|
|
39323
|
+
} catch (err) {
|
|
39324
|
+
console.error("Error al aplicar constraints de enfoque:", err);
|
|
39325
|
+
}
|
|
39326
|
+
};
|
|
39233
39327
|
return /* @__PURE__ */ jsxs(Box$1, {
|
|
39234
39328
|
sx: {
|
|
39235
39329
|
width: "100%"
|
|
@@ -39278,7 +39372,8 @@ function SideDocsSelector({
|
|
|
39278
39372
|
alt: "thumbnail",
|
|
39279
39373
|
style: {
|
|
39280
39374
|
width: "100%",
|
|
39281
|
-
height: "100%"
|
|
39375
|
+
height: "100%",
|
|
39376
|
+
objectFit: "cover"
|
|
39282
39377
|
}
|
|
39283
39378
|
}), /* @__PURE__ */ jsxs(Box$1, {
|
|
39284
39379
|
style: {
|
|
@@ -39334,19 +39429,20 @@ function SideDocsSelector({
|
|
|
39334
39429
|
})
|
|
39335
39430
|
})]
|
|
39336
39431
|
})]
|
|
39337
|
-
}) : /* @__PURE__ */ jsx$1(
|
|
39432
|
+
}) : /* @__PURE__ */ jsx$1(UploadDocument2, {
|
|
39433
|
+
videoRef,
|
|
39434
|
+
streamRef,
|
|
39338
39435
|
setActivateCamera,
|
|
39339
39436
|
activateCamera,
|
|
39340
|
-
webcamRef,
|
|
39341
|
-
Webcam: Webcam2,
|
|
39342
39437
|
videoConstraints,
|
|
39343
39438
|
base64,
|
|
39344
|
-
detail: "Subir frontal del documento"
|
|
39439
|
+
detail: "Subir frontal del documento",
|
|
39440
|
+
onTapToFocus: handleTapToFocus
|
|
39345
39441
|
}), /* @__PURE__ */ jsxs(Box$1, {
|
|
39346
39442
|
width: "100%",
|
|
39347
39443
|
children: [activateCamera && /* @__PURE__ */ jsx$1(CustomButton, {
|
|
39348
39444
|
type: "button",
|
|
39349
|
-
onClick: () =>
|
|
39445
|
+
onClick: () => takeScreenshot("firstImage"),
|
|
39350
39446
|
children: "Capturar"
|
|
39351
39447
|
}), !status && Object.keys(base64).length > 0 && !activateCamera && lib$1(status) && (!dualModeRequired && base64.firstImage || dualModeRequired && base64.firstImage && base64.secondImage) && /* @__PURE__ */ jsx$1(CustomButton, {
|
|
39352
39448
|
type: "submit",
|
|
@@ -39383,7 +39479,8 @@ function SideDocsSelector({
|
|
|
39383
39479
|
alt: "thumbnail",
|
|
39384
39480
|
style: {
|
|
39385
39481
|
width: "100%",
|
|
39386
|
-
height: "100%"
|
|
39482
|
+
height: "100%",
|
|
39483
|
+
objectFit: "cover"
|
|
39387
39484
|
}
|
|
39388
39485
|
}), /* @__PURE__ */ jsxs(Box$1, {
|
|
39389
39486
|
style: {
|
|
@@ -39439,19 +39536,20 @@ function SideDocsSelector({
|
|
|
39439
39536
|
})
|
|
39440
39537
|
})]
|
|
39441
39538
|
})]
|
|
39442
|
-
}) : /* @__PURE__ */ jsx$1(
|
|
39539
|
+
}) : /* @__PURE__ */ jsx$1(UploadDocument2, {
|
|
39540
|
+
videoRef,
|
|
39541
|
+
streamRef,
|
|
39443
39542
|
setActivateCamera,
|
|
39444
39543
|
activateCamera,
|
|
39445
|
-
webcamRef,
|
|
39446
|
-
Webcam: Webcam2,
|
|
39447
39544
|
videoConstraints,
|
|
39448
39545
|
base64,
|
|
39449
|
-
detail: "Subir reverso del documento"
|
|
39546
|
+
detail: "Subir reverso del documento",
|
|
39547
|
+
onTapToFocus: handleTapToFocus
|
|
39450
39548
|
}), /* @__PURE__ */ jsxs(Box$1, {
|
|
39451
39549
|
width: "100%",
|
|
39452
39550
|
children: [activateCamera && /* @__PURE__ */ jsx$1(CustomButton, {
|
|
39453
39551
|
type: "button",
|
|
39454
|
-
onClick: () =>
|
|
39552
|
+
onClick: () => takeScreenshot("secondImage"),
|
|
39455
39553
|
children: "Capturar"
|
|
39456
39554
|
}), !status && Object.keys(base64).length > 0 && !activateCamera && lib$1(status) && (!dualModeRequired && base64.secondImage && base64.firstImage || dualModeRequired && base64.firstImage && base64.secondImage) && /* @__PURE__ */ jsx$1(CustomButton, {
|
|
39457
39555
|
type: "submit",
|
|
@@ -39914,6 +40012,7 @@ function DocumentReader({
|
|
|
39914
40012
|
base64,
|
|
39915
40013
|
countryCode,
|
|
39916
40014
|
onUploadImage,
|
|
40015
|
+
onUploadImage2,
|
|
39917
40016
|
activateCamera,
|
|
39918
40017
|
setActivateCamera,
|
|
39919
40018
|
webcamRef,
|
|
@@ -39959,7 +40058,8 @@ function DocumentReader({
|
|
|
39959
40058
|
videoConstraints,
|
|
39960
40059
|
onUploadImage,
|
|
39961
40060
|
dualModeRequired,
|
|
39962
|
-
status
|
|
40061
|
+
status,
|
|
40062
|
+
onUploadImage2
|
|
39963
40063
|
})]
|
|
39964
40064
|
})
|
|
39965
40065
|
})]
|