@tsocial/tvweb-sdk.platform 5.38.3 → 5.38.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/build/esm/{chunk-ec455fe3.js → chunk-001d91a5.js} +1 -1
- package/build/esm/{chunk-7fd5f30f.js → chunk-07fa1ee8.js} +1 -1
- package/build/esm/{chunk-83b4e661.js → chunk-158293f4.js} +1 -1
- package/build/esm/{chunk-85c7fccc.js → chunk-3d38e367.js} +1 -1
- package/build/esm/{chunk-ea488e70.js → chunk-457fe1f2.js} +1 -1
- package/build/esm/chunk-480f7783.js +1 -0
- package/build/esm/{chunk-df1a18df.js → chunk-52bf7aa2.js} +1 -1
- package/build/esm/{chunk-9a57dffd.js → chunk-5f4b20dc.js} +1 -1
- package/build/esm/{chunk-cb78319b.js → chunk-665f0d35.js} +1 -1
- package/build/esm/{chunk-6c419352.js → chunk-66ec7159.js} +1 -1
- package/build/esm/{chunk-fc1ca1ea.js → chunk-84cee1c5.js} +1 -1
- package/build/esm/{chunk-e6f33641.js → chunk-92b01004.js} +1 -1
- package/build/esm/{chunk-62203103.js → chunk-96c04d90.js} +1 -1
- package/build/esm/{chunk-3a5e2fb7.js → chunk-9d07c97a.js} +1 -1
- package/build/esm/{chunk-4c589d01.js → chunk-c4b227ab.js} +1 -1
- package/build/esm/{chunk-2da8af58.js → chunk-d93d576d.js} +1 -1
- package/build/esm/{chunk-973e0c2c.js → chunk-ed3848f7.js} +12 -2
- package/build/esm/{chunk-7b148a15.js → chunk-f403b8bc.js} +1 -1
- package/build/esm/{chunk-6000df97.js → chunk-f4844e7f.js} +1 -1
- package/build/esm/{chunk-01c3fea1.js → chunk-fd4c4194.js} +1 -1
- package/build/esm/tvweb-sdk.platform.esm.min.js +1 -1
- package/build/tvweb-sdk.platform.cjs.min.js +12 -2
- package/build/tvweb-sdk.platform.standalone.js +50 -37
- package/build/tvweb-sdk.platform.standalone.min.js +12 -2
- package/package.json +5 -5
- package/build/esm/chunk-443bbdef.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{P as e,r as t,j as r,b as o,e as n,l as a,h as i,i as s,k as l,m as c,n as d,s as u,o as g,q as p,t as m,B as f,v as k,w as h,S as b,x as _,y as C,z as B,A as w,c as y,C as v,D as x,E as P,F as S,G as I,H as R,I as $,J as D,K as M,L as E,M as T,N as j,O as A,Q as L,R as F,T as z,U as O,V as W,W as V,X as N,Y as Q,Z as q,_ as U,$ as X,a0 as H,a1 as K,a2 as Z,a3 as G,a4 as J,a5 as Y,g as ee,p as et,a6 as er,u as eo,a7 as en,a8 as ea,a9 as ei}from"./chunk-
|
|
1
|
+
import{P as e,r as t,j as r,b as o,e as n,l as a,h as i,i as s,k as l,m as c,n as d,s as u,o as g,q as p,t as m,B as f,v as k,w as h,S as b,x as _,y as C,z as B,A as w,c as y,C as v,D as x,E as P,F as S,G as I,H as R,I as $,J as D,K as M,L as E,M as T,N as j,O as A,Q as L,R as F,T as z,U as O,V as W,W as V,X as N,Y as Q,Z as q,_ as U,$ as X,a0 as H,a1 as K,a2 as Z,a3 as G,a4 as J,a5 as Y,g as ee,p as et,a6 as er,u as eo,a7 as en,a8 as ea,a9 as ei}from"./chunk-ed3848f7.js";import{W as es,C as el,P as ec,O as ed}from"./chunk-f403b8bc.js";import{d as eu,u as eg,a as ep,t as em,b as ef,m as ek,c as eh,D as eb,S as e_}from"./chunk-96c04d90.js";let eC="default",eB="error";function ew({className:e,width:o,height:n,type:a,strokeStyles:i,strokeWidth:s,radius:l,paddingStyle:c,defaultRectStyles:d,errorRectStyles:u,paddingCornerMultiplier:g=1.5}){let p=t.useMemo(()=>({[eC]:d,[eB]:u,...i}),[d,u,i]),m=l+s*g,f=p[a];return r.jsxs("svg",{width:o,height:n,className:e,children:[r.jsx("rect",{x:s/2,y:s/2,rx:l,ry:l,width:o-s,height:n-s,style:f}),r.jsx("path",{d:`M0,${m} Q0,0 ${m},0 L0,0 Z`,style:c}),r.jsx("path",{d:`M0,${n-m} Q0,${n} ${m},${n} L0,${n} Z`,style:c}),r.jsx("path",{d:`M${o-m},${n} Q${o},${n} ${o},${n-m} L${o},${n} Z`,style:c}),r.jsx("path",{d:`M${o-m},0 Q${o},0 ${o},${m} L${o},0 Z`,style:c})]})}ew.propTypes={className:e.string,width:e.number,height:e.number,strokeWidth:e.number,strokeStyles:e.shape({}),type:e.oneOf([eC,eB]),radius:e.number,paddingStyle:e.shape({}),defaultRectStyles:e.shape({}),errorRectStyles:e.shape({}),paddingCornerMultiplier:e.number},ew.defaultProps={className:"",width:eu.IDCapturing.rectangleMask.width,height:eu.IDCapturing.rectangleMask.height,strokeWidth:eu.IDCapturing.rectangleMask.strokeWidth,strokeStyles:eu.IDCapturing.rectangleMask.strokeStyles,type:eC,radius:eu.IDCapturing.rectangleMask.radius,paddingStyle:eu.IDCapturing.rectangleMask.paddingStyle,defaultRectStyles:eu.IDCapturing.rectangleMask.default,errorRectStyles:eu.IDCapturing.rectangleMask.error,paddingCornerMultiplier:1.5};let ey=o.isMobile?200:400,ev=o.isMobile?150:300,ex={ID_CARD:"id_card",QR_CODE:"qr_code"},eP=[{x:.02,y:.03,w:.46,h:.87},{x:.3,y:.03,w:.47,h:.87}],eS="raw",{Errors:eI}=u;async function eR(e,t){let r=i.getOpenCV(),o=e.getContext("2d").getImageData(0,0,e.width,e.height);return await r.fourPointTransform(o,t)}async function e$({canvas:e,paddingPercent:t=.04,glareThreshold:r}={}){let o=e.width,n=e.height,a=Math.floor(o*t),i=Math.floor(n*t),l=o-2*a,c=n-2*i,d=document.createElement("canvas"),u=d.getContext("2d");return d.width=l,d.height=c,u.drawImage(e,a,i,l,c,0,0,l,c),s.isCardGlare(d,r)}async function eD({blazefaceModel:e,predictedIdCardCanvas:t,frontSide:r}){let o=t.width,n=t.height,a=Math.floor(o/3),i=Math.floor(4*n/5),s=document.createElement("canvas"),d=s.getContext("2d");s.width=a,s.height=i,d.drawImage(t,0,Math.floor(n/5),a,i,0,0,a,i);let u=await l.getModelPredictions({model:e,sCanvas:s}),g=e=>e&&"function"==typeof e.arraySync?e.arraySync():e,p=e=>{e&&"function"==typeof e.dispose&&e.dispose()},m=u.map(e=>{let t={topLeft:g(e.topLeft),bottomRight:g(e.bottomRight),probability:g(e.probability),landmarks:g(e.landmarks)};return p(e.topLeft),p(e.bottomRight),p(e.probability),p(e.landmarks),t}).filter(({topLeft:e,bottomRight:t,probability:[r],landmarks:o})=>!(r<.9||o.length<4||.025>c.rectAreaRatio({small:{coords:[e,t]},big:{coords:[[0,0],[l.SIZE,l.SIZE]]}}))&&!0).length;if(r){if(0===m)return eI.id_detector_error_front_side_no_faces;if(m>1)return eI.id_detector_error_front_side_multiple_faces}else if(m>0)return eI.id_detector_error_back_side_has_faces;return null}async function eM({blazefaceModel:e,predictedIdCardCanvas:t,frontSide:r,hasFrontFace:o,hasBackFace:n,genericEnableCheckFrontFace:a,genericEnableCheckBackFace:i}){if(r&&!a||!r&&!i)return null;let{width:s,height:c}=t,d=document.createElement("canvas"),u=document.createElement("canvas");d.width=s/2,u.width=s/2,d.height=c,u.height=c;let g=d.getContext("2d"),p=u.getContext("2d");g.drawImage(t,0,0,s/2,c,0,0,s/2,c),p.drawImage(t,s/2,0,s/2,c,0,0,s/2,c);let m=e=>e&&"function"==typeof e.arraySync?e.arraySync():e,f=e=>{e&&"function"==typeof e.dispose&&e.dispose()},k=e=>{let t={probability:m(e.probability),landmarks:m(e.landmarks)};return f(e.topLeft),f(e.bottomRight),f(e.probability),f(e.landmarks),t},[h,b]=await Promise.all([l.getModelPredictions({model:e,sCanvas:d}),l.getModelPredictions({model:e,sCanvas:u})]),_=h.map(k),C=b.map(k),B=({probability:[e],landmarks:t})=>e>=.9&&t.length>=4,w=_.filter(B),y=C.filter(B),v=w.length>0||y.length>0;if(r){if(!v&&o||v&&!o)return eI.id_detector_error_front_side_no_faces}else if(!v&&n||v&&!n)return eI.id_detector_error_back_side_has_faces;return null}let eE=({canvas:e,cardPosition:t,quality:r=1})=>{if(!t||!t.corners||!Array.isArray(t.corners))return null;let[o,n,i]=t.corners,s=n?.location?.x-o?.location?.x-100,l=i?.location?.y-n?.location?.y-100,c=document.createElement("canvas");c.width=s,c.height=l,c.getContext("2d").drawImage(e,o?.location?.x+50,o?.location?.y+50,s,l,0,0,s,l);let d=c.toDataURL("image/jpeg",r);return a.base64ToMD5({base64:d}).toString()},eT=async({canvas:e,cardPosition:t,quality:r,count:o=3})=>{if(!t||!t.corners||!Array.isArray(t.corners))return[];let n=[];for(;n.length<o;){let a=performance.now(),i=eE({canvas:e,cardPosition:t,quality:r});if(n.push(i),n.length<o){let e=180-(a=Math.floor(performance.now()-a))>0?180-a:0;await new Promise(t=>setTimeout(t,e))}}return n},ej=(e,t)=>{if(null!=e)return parseFloat(e.toFixed(t))},eA=({currentFrameBlurScore:e,incomingFrameBlurScore:t,currentFrameGlareScore:r,incomingFrameGlareScore:o,settings:n,blurLargeThreshold:a,blurSmallThreshold:i})=>{if(null===e)return!0;let{enableBlurCheck:s,enableGlareCheck:l}=n,c=e?.small,d=e?.large,u=t?.small,g=t?.large;return(!s||!(u<i)&&!(g<a))&&(Math.abs(u-c)>Number.EPSILON?u>c:Math.abs(g-d)>Number.EPSILON?g>d:!!(l&&Math.abs(o-r)>Number.EPSILON)&&o>r)};function eL(e,t,r,o,n){r&&(r.strokeStyle=t,r.lineWidth=2,e.forEach(e=>{let[t,a,i,s]=e,l=(t+n.x)*o,c=(a+n.y)*o,d=(i+n.x)*o,u=(s+n.y)*o;r.strokeRect(l,c,d-l,u-c)}))}function eF(e){let t=e.find(e=>"top-left"===e.label).location,r=e.find(e=>"top-right"===e.label).location,o=e.find(e=>"bottom-right"===e.label).location,n=e.find(e=>"bottom-left"===e.label).location,a=Math.sqrt((o.x-n.x)**2+(o.y-n.y)**2),i=Math.sqrt((r.x-t.x)**2+(r.y-t.y)**2),s=Math.max(parseInt(a,10),parseInt(i,10)),l=Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2),c=Math.sqrt((r.x-o.x)**2+(r.y-o.y)**2);return{topLeft:t,topRight:r,bottomRight:o,bottomLeft:n,maxWidth:s,maxHeight:Math.max(parseInt(l,10),parseInt(c,10))}}let ez=g(ew)``,eO=g.img`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as e,y as r,Q as s,r as a,e as n,c as t,s as o,j as i,a2 as c,ay as l,n as u,P as p,b as d}from"./chunk-
|
|
1
|
+
import{x as e,y as r,Q as s,r as a,e as n,c as t,s as o,j as i,a2 as c,ay as l,n as u,P as p,b as d}from"./chunk-ed3848f7.js";import{p as m,g as f,S as g,a as h,O as C,C as y,E as j,b as D,B as x,c as F,L as S}from"./chunk-158293f4.js";import{u as b,C as I}from"./chunk-d93d576d.js";import{M as T,O as E,W as k,C as R}from"./chunk-f403b8bc.js";import{D as L}from"./chunk-001d91a5.js";import{u as v}from"./chunk-96c04d90.js";import"./chunk-5f4b20dc.js";import"./chunk-84cee1c5.js";let P=d.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:d,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:w,customStepTimeConstraints:U,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:Q,isLoading:q}=p,J=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:J})}),[J]),ed=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:em,countdownToTakePicture:ef,cropArea:eg,curStepIndex:eh,faceDetectionError:eC,resetFlow:ey,handleTriggerPassiveMode:ej,handleVideoPlayed:eD,refVideo:ex,showCountdown:eF,steps:eS,refIsReseting:eb,videoPlayed:eI,warmupDone:eT,showCaptureButton:eE,shouldShowCountdown:ek,showLoading:eR}=b({currentOrientation:el,apiCheck:d,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:ed,customDirectionIcon:w,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:U,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:Q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,J),eP=eb.current?0:eh/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),ew=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eh]),eU=a.useCallback(e=>{eu(e),em?ey():e===T.LANDSCAPE?ex.current?.pause():ex.current?.play()},[ex,ey,em]);return i.jsx(E,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:ex,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eT&&i.jsx(k,{}),eI?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(g,{top:et-15,className:"face-detection-error",children:ew}):null,eg.current?i.jsxs(R,{x:`${eg.current.x}px`,y:`${eg.current.y}px`,width:`${eg.current.width}px`,height:`${eg.current.height}px`,surroundStyle:eg.current.surroundStyle,children:[i.jsx(h,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:J})}),ek?i.jsx(y,{children:ef}):null,eC&&i.jsx(j,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eE?i.jsx(x,{children:i.jsx(F,{onClick:ej,disabled:eF,children:u(J,"Selfie.captureIcon.src")?i.jsx("img",{src:u(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(I,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||q)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,n as t,u as a,aG as s,s as n,c as i,a9 as r,d as l,I as c,f as o,b as u,aJ as _,aK as m,F as g,L as d,W as f,M as h,D as b,au as v,k as p,aA as w,j as k}from"./chunk-973e0c2c.js";import{t as y}from"./chunk-9a57dffd.js";import{n as F,t as T,u as L,o as R,q as C,r as B,v as S,s as x,y as I}from"./chunk-83b4e661.js";import{m as M}from"./chunk-62203103.js";import{u as D}from"./chunk-fc1ca1ea.js";let E=s.faceTracker(),P=new _,{FaceDirection:j,Errors:A,Messages:W,TrackLivenessEvents:V}=n,N={enable:!1,framesIntervalTime:180,framesBatchLength:0},U={[n.FaceDirection.UP]:{delayTime:0},[n.FaceDirection.LEFT]:{delayTime:0},[n.FaceDirection.RIGHT]:{delayTime:0},[n.FaceDirection.FRONTAL]:{delayTime:2e3}},O=()=>{},z=()=>{},K=()=>{};function q({apiCheck:_,bgCameraMask:k,bgCameraMaskRed:G,surroundStyle:Z,cropAreaDimension:J,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:ea=500,captureFrameSettings:es=N,setRemainingTime:en=O,onProcessing:ei=K,customErrors:er,customMessages:el,apiCredentials:ec={},onFramesCaptured:eo=z,initFirstGestureTimeout:eu=2e3,outputEncryptionSettings:e_,cameraScale:em=1,passiveModeAuto:eg=!1,sendCustomEvent:ed,serviceSettings:ef,currentOrientation:eh,onReset:eb}={}){let[ev,ep]=e.useState(!1),[ew,ek]=e.useState(!1),[ey,eF]=e.useState(!1),[eT,eL]=e.useState(!1),eR=e.useRef(null),{lang:eC,assetRoot:eB,customUrls:eS,exifKey:ex}=i.useSDKSettings(),eI=r.useSDKLocale(),{apiClient:eM}=l.useApiClient({apiCredentials:ec}),[,eD]=e.useReducer(e=>e+1,0),eE=e.useRef(null),[eP,ej]=e.useState(!1),eA=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),[eV,eN]=e.useState(3),[eU,eO]=e.useState(!1),ez=e.useRef(!1),eK=e.useCallback(e=>{eO(e),ez.current=e},[]),eq=e.useRef(null),eG=e.useRef([]),eZ=e.useRef(null),eJ=e.useRef(),eH=e.useRef(null);null===eH.current&&(eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y,Locale:eI,lang:eC}));let[eX,eQ]=e.useState(),eY=e.useCallback(e=>{eQ(e)},[]),e$=e.useMemo(()=>y(eY,500),[eY]),e0=e.useRef([]),e1=e.useRef(),e4=D(),{flowIntervalTimeMs:e2,limitTimeLivenessCheck:e3,terminateIfNoFace:e5,closeEyeDetectorSettings:e7,exifDataSettings:e6,recordVideo:e8,autoCaptureSettings:e9,manualCaptureSettings:te,blurCheckSettings:tt,webIsRequiredFrontalFace:ta,waitBeforeStartFlowMs:ts,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:s,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},F,s),r={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.enable"),showCaptureButton:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_capture_button"),showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.wait_for_best_image_time_ms_web")},l={showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.wait_for_best_image_time_ms_web")},c={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.enable"),webBlurryThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.web_blurry_threshold")},o={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.force_check")},u=t(i,"data.settings.sdk_settings.passive_liveness_settings.web_is_required_frontal_face"),_=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),m={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:_>0,totalMaxRetries:_,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},g={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),b=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),v=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),p=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");return{autoCaptureSettings:r,manualCaptureSettings:l,blurCheckSettings:c,closeEyeDetectorSettings:o,webIsRequiredFrontalFace:u,limitTimeLivenessCheck:m,terminateIfNoFace:g,exifDataSettings:d,recordVideo:f,waitBeforeStartFlowMs:h,resetFlowOnOrientationChange:b,flowIntervalTimeMs:v,captureFrameSettings:e=p?{enable:p.enable,enableLogging:p.enable_logging,framesBatchLength:p.frames_batch_len,framesIntervalTime:p.frames_interval_ms}:n}},[s,n])}({clientSettings:e4,captureFrameSettingsProp:es}),tr=e9?.enable?e9?.waitForBestImageTimeMsWeb:te?.waitForBestImageTimeMsWeb,tl=e8?.enable,tc=e.useMemo(()=>o.getEnabledServices(ef,e4),[e4,ef]),to=e.useRef(""),tu=e.useCallback(e=>{if(e?.event){if(e.event===V?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eW(e),ed&&ed(e)}},[ed,eW]),t_=e.useMemo(()=>y(e=>{tu(e)},2e3),[tu]),tm=e.useRef(0),tg=e.useRef(),td=e.useRef();e.useEffect(()=>{tu({tag:"selfie",event:V?.start_camera,log:{}})},[tu]),e.useEffect(()=>(P.start(),()=>{P.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!eP&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(ej(!0),tu({tag:"selfie",event:V?.show_warmup,log:{}}),tu({tag:"selfie",event:V?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[eP,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eH.current.curStepIndex=eH.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,Locale:eI,lang:eC}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eQ(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eZ.current=null,eG.current=[],eJ.current=null,"function"==typeof eb&&eb(),eD()},[eI,eB,Q,X,H,eK,eC,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...W,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tp.liveness_terminated_time_out?.msg[t]);e[t]=a({x:e3.limitTimeSecond})}),eQ({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),P.stop(),en(""),th()},[tp.liveness_terminated_time_out,e2,e3.limitTimeSecond,th,tu,en]),ty=e.useCallback(({remainTime:e})=>{if(e>0&&e<=e3.remainTimeShow){let t=T(tw.REMAIN_TIME[eC]),a=e;switch(e3.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}en(t({x:a}))}},[eC,e3.format,e3.remainTimeShow,tw.REMAIN_TIME,en]),tF=e.useCallback(({attemptCount:e,fromBackground:t})=>{e3.enableMaxRetries&&e>=e3.totalMaxRetries&&ee(n.Errors.max_retry_reached),t&&th(),P.start(),tb()},[e3.enableMaxRetries,e3.totalMaxRetries,ee,tb,th]),{stopTimer:tT}=L({totalTime:e3.limitTimeSecond,totalDelayBetweenReset:e2/1e3,interruptible:e3.interruptible,shouldStart:ew&&e3.enable&&eP,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=a:r=l=s-200;let c=Math.floor((a-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:Z},"object"==typeof J?eE.current={...eE.current,...J}:"function"==typeof J&&(eE.current={...eE.current,...J({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,Z,J]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;P.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*P.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eZ.current]:eG.current).map(e=>f.resizeBlobImg(e.blob,400,400)),a=(await Promise.all(t)).map((t,a)=>{let s=d.parseLivenessImg({...e[a],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:s})}),s=await Promise.all(a),n={};if(e_&&e_.key){let{key:e}=e_,t=s.map(t=>h.encrypt({blob:t,key:e}));n={frontalFacesEncrypted:await Promise.all(t)}}let i=[...e0.current];if(e_&&e_.key){let e=await Promise.all(i.map(e=>e?.base64));if(i=i.map((t,a)=>({...t,base64:e[a]})),ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0){let e=i.slice(-1*(i.length%ti.framesBatchLength));eo(e),_&&tc.enableUploadFrames&&R(e_,e,eM,i.length===ti.framesBatchLength)}}else ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0&&(eo(i.slice(-1*(i.length%ti.framesBatchLength)).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,i.slice(-1*(i.length%ti.framesBatchLength)),eM));if(_&&tc.enableUploadImages){let t=e=>({label:"portrait",metadata:JSON.stringify({gesture_score:e,gesture:j.FRONTAL})}),a=e.map((e,a)=>eM.uploadImage({file:s[a],...t(e.leftRightScore)}));e_&&e_.key&&(a=e.map((e,a)=>{let s=new Blob([n.frontalFacesEncrypted[a].hex]);return eM.uploadImage({file:s,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(a),s=null;tc.enableVerifyFaceLiveness&&(s=eM.verifyFaceLiveness({images:t.map(e=>({id:e.data.image_id})),videos:[{frames:i}]}));let n=null;tc.enableVerifySanityPortrait&&(n=eM.requestVerifyPortrait({image:{id:t?.[t.length-1]?.data?.image_id}}));let[r,l]=await Promise.all([s,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,a)=>({id:t?.data?.image_id,blob:e?.[a]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:s,...n,capturedFrames:i,video:C()}),B()}};eq.current=setInterval(()=>{eN(t=>(e(t),t-1))},tr/3)},[eK,tr,tT,ei,e9.enable,e_,ti.enable,ti.framesBatchLength,_,tc.enableUploadImages,tc.enableUploadFrames,tc.enableVerifyFaceLiveness,tc.enableVerifySanityPortrait,e6.enable,eo,eM,$,ee]),tC=e.useRef({});e.useEffect(()=>{tC.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function a({faceDirection:e,canvas:t,leftRightScore:a,blurScore:s,isEyeClosed:n}){if(!0===ez.current&&(ta&&e===j.FRONTAL||!ta)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eJ.current<e9?.waitForBestImageTimeMsWeb?(eZ.current||(eZ.current={blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eZ.current=I({incomingFrame:{blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eZ.current}))):eG.current.length<1&&eG.current.push({blob:e,leftRightScore:a,captureTime:Date.now(),blurScore:s})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tC.current,{cropX:m,cropY:g,cropWidth:d,cropHeight:f}=r;l.getContext("2d").drawImage(t,m,g,d,f,-((400*em-400)/2)/em,-((400*em-400)/2)/em,400,400);let{blazefaceModel:h,closeEyesModel:b}=eA.current,[y,F]=await Promise.all([v.calculateBlurScore(l),p.getModelPredictions({model:h,sCanvas:l})]),{error:T,fullFace:L,faceRatio:C,faceNotFrontalMinThreshold:B}=await s.validatePredictions({predictions:F,width:p.SIZE,height:p.SIZE});c=T,eE.current.image=k;let S=null,x=null,I=null,{curStepIndex:M,steps:D}=eH.current;if(L){I=L.landmarks;let e=await s.calculateFaceDirection({landmarks:I,getPerfectFrontal:!0});e&&(S=e.gesture,x=e.leftRightScore);let t=e7?.webTimeout+Y[n.FaceDirection.FRONTAL].delayTime/1e3;if(e7?.enable&&(-1===P.duration("limit_close_eye")||P.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==P.duration("limit_close_eye")||P.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let W=c?.code==="no_face"||c?.code==="partial_face",N=M<D.length;if(!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e5.enable||!t)return;let{max_time_ms:a}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:s}=tg.current;e&&Date.now()-s>=a&&(eQ({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:W&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:V?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==j.FRONTAL&&C>=B){if(!function(e,t,a,s){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:s,bottomRight:n}=e,i=[...s,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:e0.current.length,bbox:i,original_bbox:i};if(e_&&e_.key){if(c.base64=w.encryptFrameBase64(c.base64,e_.key),e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo){let e=e0.current.slice(-ti.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{eo(e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a})),eM,e0.current.length===ti.framesBatchLength)})}}else e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo&&(eo(e0.current.slice(-ti.framesBatchLength).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==j.FRONTAL&&ta)o=tp.not_frontal_face,eE.current.image=G;else if(!c){u||(eL(!0),P.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eG.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eJ.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eJ.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await a({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=G);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),a=document.createElement("canvas");a.width=400,a.height=400;let s=a.getContext("2d");s.translate(400,0),s.scale(-1*em,+em);let{mediaRecorder:n}=tl&&t?await S({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};td.current=n,td.current&&td.current.start(),i(e,a)}return ew&&eP&&setTimeout(()=>{r()},ts??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ts,ta,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eC,eM,_,k,G,$,ee,et,ea,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,eP,tu,eo,e_,em,tR,eg,e7?.enable,e7?.webThreshold,e7?.webTimeout,e7?.forceCheck,e6.enable,ex,t_,ti.framesBatchLength,tl,tc.enableUploadFrames]),e.useEffect(()=>{eX&&(eX?.code!==tp?.liveness_terminated_time_out&&eX?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eZ.current=null,eG.current=[],eJ.current=null))},[e9?.enable,eX,eK,tp]);let{curStepIndex:tB,steps:tS}=eH.current,tx=eT&&!eX&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eV,cropArea:eE,curStepIndex:tB,faceDetectionError:eX,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:eP,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function G({className:e="",fillColor:t=null}){return k.jsxs("svg",{className:e,width:"38px",height:"32px",viewBox:"0 0 24 21","data-testid":"camera-icon",children:[k.jsx("title",{children:"FA45C15C-1E21-4D7B-9585-07FB9F999CB8"}),k.jsx("desc",{children:"Created with sketchtool."}),k.jsx("g",{id:"Web-demo",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:k.jsx("g",{id:"step1",transform:"translate(-950.000000, -380.000000)",fill:t??"currentColor",fillRule:"nonzero",children:k.jsx("g",{id:"Group",transform:"translate(950.000000, 380.000000)",children:k.jsx("g",{id:"Group-2",children:k.jsx("g",{id:"camera",children:k.jsx("path",{d:"M21,3 L17,3 L15,0 L9,0 L7,3 L3,3 C1.34314575,3 0,4.34314575 0,6 L0,18 C0,19.6568542 1.34314575,21 3,21 L21,21 C22.6568542,21 24,19.6568542 24,18 L24,6 C24,4.34314575 22.6568542,3 21,3 Z M12,17 C9.23857625,17 7,14.7614237 7,12 C7,9.23857625 9.23857625,7 12,7 C14.7614237,7 17,9.23857625 17,12 C17,14.7614237 14.7614237,17 12,17 L12,17 Z",id:"Shape"})})})})})})]})}export{G as C,q as u};
|
|
1
|
+
import{r as e,n as t,u as a,aG as s,s as n,c as i,a9 as r,d as l,I as c,f as o,b as u,aJ as _,aK as m,F as g,L as d,W as f,M as h,D as b,au as v,k as p,aA as w,j as k}from"./chunk-ed3848f7.js";import{t as y}from"./chunk-5f4b20dc.js";import{n as F,t as T,u as L,o as R,q as C,r as B,v as S,s as x,y as I}from"./chunk-158293f4.js";import{m as M}from"./chunk-96c04d90.js";import{u as D}from"./chunk-84cee1c5.js";let E=s.faceTracker(),P=new _,{FaceDirection:j,Errors:A,Messages:W,TrackLivenessEvents:V}=n,N={enable:!1,framesIntervalTime:180,framesBatchLength:0},U={[n.FaceDirection.UP]:{delayTime:0},[n.FaceDirection.LEFT]:{delayTime:0},[n.FaceDirection.RIGHT]:{delayTime:0},[n.FaceDirection.FRONTAL]:{delayTime:2e3}},O=()=>{},z=()=>{},K=()=>{};function q({apiCheck:_,bgCameraMask:k,bgCameraMaskRed:G,surroundStyle:Z,cropAreaDimension:J,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:ea=500,captureFrameSettings:es=N,setRemainingTime:en=O,onProcessing:ei=K,customErrors:er,customMessages:el,apiCredentials:ec={},onFramesCaptured:eo=z,initFirstGestureTimeout:eu=2e3,outputEncryptionSettings:e_,cameraScale:em=1,passiveModeAuto:eg=!1,sendCustomEvent:ed,serviceSettings:ef,currentOrientation:eh,onReset:eb}={}){let[ev,ep]=e.useState(!1),[ew,ek]=e.useState(!1),[ey,eF]=e.useState(!1),[eT,eL]=e.useState(!1),eR=e.useRef(null),{lang:eC,assetRoot:eB,customUrls:eS,exifKey:ex}=i.useSDKSettings(),eI=r.useSDKLocale(),{apiClient:eM}=l.useApiClient({apiCredentials:ec}),[,eD]=e.useReducer(e=>e+1,0),eE=e.useRef(null),[eP,ej]=e.useState(!1),eA=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),[eV,eN]=e.useState(3),[eU,eO]=e.useState(!1),ez=e.useRef(!1),eK=e.useCallback(e=>{eO(e),ez.current=e},[]),eq=e.useRef(null),eG=e.useRef([]),eZ=e.useRef(null),eJ=e.useRef(),eH=e.useRef(null);null===eH.current&&(eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,customStepTimeConstraints:Y,Locale:eI,lang:eC}));let[eX,eQ]=e.useState(),eY=e.useCallback(e=>{eQ(e)},[]),e$=e.useMemo(()=>y(eY,500),[eY]),e0=e.useRef([]),e1=e.useRef(),e4=D(),{flowIntervalTimeMs:e2,limitTimeLivenessCheck:e3,terminateIfNoFace:e5,closeEyeDetectorSettings:e7,exifDataSettings:e6,recordVideo:e8,autoCaptureSettings:e9,manualCaptureSettings:te,blurCheckSettings:tt,webIsRequiredFrontalFace:ta,waitBeforeStartFlowMs:ts,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:s,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},F,s),r={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.enable"),showCaptureButton:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_capture_button"),showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.wait_for_best_image_time_ms_web")},l={showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.wait_for_best_image_time_ms_web")},c={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.enable"),webBlurryThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.web_blurry_threshold")},o={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.force_check")},u=t(i,"data.settings.sdk_settings.passive_liveness_settings.web_is_required_frontal_face"),_=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),m={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:_>0,totalMaxRetries:_,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},g={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),b=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),v=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),p=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");return{autoCaptureSettings:r,manualCaptureSettings:l,blurCheckSettings:c,closeEyeDetectorSettings:o,webIsRequiredFrontalFace:u,limitTimeLivenessCheck:m,terminateIfNoFace:g,exifDataSettings:d,recordVideo:f,waitBeforeStartFlowMs:h,resetFlowOnOrientationChange:b,flowIntervalTimeMs:v,captureFrameSettings:e=p?{enable:p.enable,enableLogging:p.enable_logging,framesBatchLength:p.frames_batch_len,framesIntervalTime:p.frames_interval_ms}:n}},[s,n])}({clientSettings:e4,captureFrameSettingsProp:es}),tr=e9?.enable?e9?.waitForBestImageTimeMsWeb:te?.waitForBestImageTimeMsWeb,tl=e8?.enable,tc=e.useMemo(()=>o.getEnabledServices(ef,e4),[e4,ef]),to=e.useRef(""),tu=e.useCallback(e=>{if(e?.event){if(e.event===V?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eW(e),ed&&ed(e)}},[ed,eW]),t_=e.useMemo(()=>y(e=>{tu(e)},2e3),[tu]),tm=e.useRef(0),tg=e.useRef(),td=e.useRef();e.useEffect(()=>{tu({tag:"selfie",event:V?.start_camera,log:{}})},[tu]),e.useEffect(()=>(P.start(),()=>{P.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!eP&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(ej(!0),tu({tag:"selfie",event:V?.show_warmup,log:{}}),tu({tag:"selfie",event:V?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[eP,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eH.current.curStepIndex=eH.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eH.current=s.initFaceVerificationData({assetRoot:eB,customInstructions:H,customIcon:X,customDirectionIcon:Q,Locale:eI,lang:eC}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eQ(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eZ.current=null,eG.current=[],eJ.current=null,"function"==typeof eb&&eb(),eD()},[eI,eB,Q,X,H,eK,eC,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...W,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tp.liveness_terminated_time_out?.msg[t]);e[t]=a({x:e3.limitTimeSecond})}),eQ({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),P.stop(),en(""),th()},[tp.liveness_terminated_time_out,e2,e3.limitTimeSecond,th,tu,en]),ty=e.useCallback(({remainTime:e})=>{if(e>0&&e<=e3.remainTimeShow){let t=T(tw.REMAIN_TIME[eC]),a=e;switch(e3.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}en(t({x:a}))}},[eC,e3.format,e3.remainTimeShow,tw.REMAIN_TIME,en]),tF=e.useCallback(({attemptCount:e,fromBackground:t})=>{e3.enableMaxRetries&&e>=e3.totalMaxRetries&&ee(n.Errors.max_retry_reached),t&&th(),P.start(),tb()},[e3.enableMaxRetries,e3.totalMaxRetries,ee,tb,th]),{stopTimer:tT}=L({totalTime:e3.limitTimeSecond,totalDelayBetweenReset:e2/1e3,interruptible:e3.interruptible,shouldStart:ew&&e3.enable&&eP,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=a:r=l=s-200;let c=Math.floor((a-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:Z},"object"==typeof J?eE.current={...eE.current,...J}:"function"==typeof J&&(eE.current={...eE.current,...J({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:s,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,Z,J]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;P.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*P.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eZ.current]:eG.current).map(e=>f.resizeBlobImg(e.blob,400,400)),a=(await Promise.all(t)).map((t,a)=>{let s=d.parseLivenessImg({...e[a],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:s})}),s=await Promise.all(a),n={};if(e_&&e_.key){let{key:e}=e_,t=s.map(t=>h.encrypt({blob:t,key:e}));n={frontalFacesEncrypted:await Promise.all(t)}}let i=[...e0.current];if(e_&&e_.key){let e=await Promise.all(i.map(e=>e?.base64));if(i=i.map((t,a)=>({...t,base64:e[a]})),ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0){let e=i.slice(-1*(i.length%ti.framesBatchLength));eo(e),_&&tc.enableUploadFrames&&R(e_,e,eM,i.length===ti.framesBatchLength)}}else ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0&&(eo(i.slice(-1*(i.length%ti.framesBatchLength)).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,i.slice(-1*(i.length%ti.framesBatchLength)),eM));if(_&&tc.enableUploadImages){let t=e=>({label:"portrait",metadata:JSON.stringify({gesture_score:e,gesture:j.FRONTAL})}),a=e.map((e,a)=>eM.uploadImage({file:s[a],...t(e.leftRightScore)}));e_&&e_.key&&(a=e.map((e,a)=>{let s=new Blob([n.frontalFacesEncrypted[a].hex]);return eM.uploadImage({file:s,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(a),s=null;tc.enableVerifyFaceLiveness&&(s=eM.verifyFaceLiveness({images:t.map(e=>({id:e.data.image_id})),videos:[{frames:i}]}));let n=null;tc.enableVerifySanityPortrait&&(n=eM.requestVerifyPortrait({image:{id:t?.[t.length-1]?.data?.image_id}}));let[r,l]=await Promise.all([s,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,a)=>({id:t?.data?.image_id,blob:e?.[a]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:s,...n,capturedFrames:i,video:C()}),B()}};eq.current=setInterval(()=>{eN(t=>(e(t),t-1))},tr/3)},[eK,tr,tT,ei,e9.enable,e_,ti.enable,ti.framesBatchLength,_,tc.enableUploadImages,tc.enableUploadFrames,tc.enableVerifyFaceLiveness,tc.enableVerifySanityPortrait,e6.enable,eo,eM,$,ee]),tC=e.useRef({});e.useEffect(()=>{tC.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function a({faceDirection:e,canvas:t,leftRightScore:a,blurScore:s,isEyeClosed:n}){if(!0===ez.current&&(ta&&e===j.FRONTAL||!ta)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eJ.current<e9?.waitForBestImageTimeMsWeb?(eZ.current||(eZ.current={blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eZ.current=I({incomingFrame:{blob:e,blurScore:s,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eZ.current}))):eG.current.length<1&&eG.current.push({blob:e,leftRightScore:a,captureTime:Date.now(),blurScore:s})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tC.current,{cropX:m,cropY:g,cropWidth:d,cropHeight:f}=r;l.getContext("2d").drawImage(t,m,g,d,f,-((400*em-400)/2)/em,-((400*em-400)/2)/em,400,400);let{blazefaceModel:h,closeEyesModel:b}=eA.current,[y,F]=await Promise.all([v.calculateBlurScore(l),p.getModelPredictions({model:h,sCanvas:l})]),{error:T,fullFace:L,faceRatio:C,faceNotFrontalMinThreshold:B}=await s.validatePredictions({predictions:F,width:p.SIZE,height:p.SIZE});c=T,eE.current.image=k;let S=null,x=null,I=null,{curStepIndex:M,steps:D}=eH.current;if(L){I=L.landmarks;let e=await s.calculateFaceDirection({landmarks:I,getPerfectFrontal:!0});e&&(S=e.gesture,x=e.leftRightScore);let t=e7?.webTimeout+Y[n.FaceDirection.FRONTAL].delayTime/1e3;if(e7?.enable&&(-1===P.duration("limit_close_eye")||P.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==P.duration("limit_close_eye")||P.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let W=c?.code==="no_face"||c?.code==="partial_face",N=M<D.length;if(!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e5.enable||!t)return;let{max_time_ms:a}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:s}=tg.current;e&&Date.now()-s>=a&&(eQ({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:V?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:W&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:V?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==j.FRONTAL&&C>=B){if(!function(e,t,a,s){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:s,bottomRight:n}=e,i=[...s,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:e0.current.length,bbox:i,original_bbox:i};if(e_&&e_.key){if(c.base64=w.encryptFrameBase64(c.base64,e_.key),e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo){let e=e0.current.slice(-ti.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{eo(e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:a},s)=>({base64:t[s],label:e,index:a})),eM,e0.current.length===ti.framesBatchLength)})}}else e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo&&(eo(e0.current.slice(-ti.framesBatchLength).map(({base64:e,label:t,index:a})=>({base64:e,label:t,index:a}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==j.FRONTAL&&ta)o=tp.not_frontal_face,eE.current.image=G;else if(!c){u||(eL(!0),P.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eG.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eJ.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eJ.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await a({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=G);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),a=document.createElement("canvas");a.width=400,a.height=400;let s=a.getContext("2d");s.translate(400,0),s.scale(-1*em,+em);let{mediaRecorder:n}=tl&&t?await S({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};td.current=n,td.current&&td.current.start(),i(e,a)}return ew&&eP&&setTimeout(()=>{r()},ts??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ts,ta,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eC,eM,_,k,G,$,ee,et,ea,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,eP,tu,eo,e_,em,tR,eg,e7?.enable,e7?.webThreshold,e7?.webTimeout,e7?.forceCheck,e6.enable,ex,t_,ti.framesBatchLength,tl,tc.enableUploadFrames]),e.useEffect(()=>{eX&&(eX?.code!==tp?.liveness_terminated_time_out&&eX?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eZ.current=null,eG.current=[],eJ.current=null))},[e9?.enable,eX,eK,tp]);let{curStepIndex:tB,steps:tS}=eH.current,tx=eT&&!eX&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eV,cropArea:eE,curStepIndex:tB,faceDetectionError:eX,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:eP,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function G({className:e="",fillColor:t=null}){return k.jsxs("svg",{className:e,width:"38px",height:"32px",viewBox:"0 0 24 21","data-testid":"camera-icon",children:[k.jsx("title",{children:"FA45C15C-1E21-4D7B-9585-07FB9F999CB8"}),k.jsx("desc",{children:"Created with sketchtool."}),k.jsx("g",{id:"Web-demo",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:k.jsx("g",{id:"step1",transform:"translate(-950.000000, -380.000000)",fill:t??"currentColor",fillRule:"nonzero",children:k.jsx("g",{id:"Group",transform:"translate(950.000000, 380.000000)",children:k.jsx("g",{id:"Group-2",children:k.jsx("g",{id:"camera",children:k.jsx("path",{d:"M21,3 L17,3 L15,0 L9,0 L7,3 L3,3 C1.34314575,3 0,4.34314575 0,6 L0,18 C0,19.6568542 1.34314575,21 3,21 L21,21 C22.6568542,21 24,19.6568542 24,18 L24,6 C24,4.34314575 22.6568542,3 21,3 Z M12,17 C9.23857625,17 7,14.7614237 7,12 C7,9.23857625 9.23857625,7 12,7 C14.7614237,7 17,9.23857625 17,12 C17,14.7614237 14.7614237,17 12,17 L12,17 Z",id:"Shape"})})})})})})]})}export{G as C,q as u};
|