@tsocial/tvweb-sdk 5.35.1 → 5.36.0
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-0811f0b9.js +10 -0
- package/build/esm/chunk-3475f25e.js +3 -0
- package/build/esm/chunk-44cbd562.js +428 -0
- package/build/esm/chunk-571e89c0.js +1 -0
- package/build/esm/chunk-641f0a71.js +1 -0
- package/build/esm/chunk-6b0b5adc.js +3 -0
- package/build/esm/chunk-6e830372.js +1 -0
- package/build/esm/chunk-7f5333af.js +256 -0
- package/build/esm/chunk-81ce3c83.js +1 -0
- package/build/esm/chunk-abf5e014.js +1 -0
- package/build/esm/chunk-b87b1853.js +1 -0
- package/build/esm/chunk-dc7a2229.js +1 -0
- package/build/esm/chunk-de5b2d76.js +1 -0
- package/build/esm/chunk-e0f43811.js +85 -0
- package/build/esm/chunk-e289e491.js +1 -0
- package/build/esm/chunk-e31767ae.js +45 -0
- package/build/esm/chunk-e3a48659.js +1 -0
- package/build/esm/chunk-e77bab5e.js +1 -0
- package/build/esm/chunk-ed832fec.js +1121 -0
- package/build/esm/chunk-ee9ed408.js +1 -0
- package/build/esm/chunk-fa450310.js +1 -0
- package/build/esm/chunk-ff693e7b.js +1 -0
- package/build/esm/tvweb-sdk.esm.min.js +1 -0
- package/build/tvweb-sdk.cjs.min.js +986 -1131
- package/build/tvweb-sdk.standalone.js +61390 -65022
- package/build/tvweb-sdk.standalone.min.js +986 -1131
- package/build/types/index.d.ts +22 -11
- package/package.json +7 -7
- package/build/tvweb-sdk.esm.min.js +0 -2089
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,C as r,T as s,r as n,m as a,c as t,s as o,j as i,a4 as c,b as l,P as u,k as p}from"./chunk-ed832fec.js";import{p as m,g as d,S as f,a as h,O as g,C as C,E as j,b as y,B as D,c as F,L as S}from"./chunk-7f5333af.js";import{u as x,C as b}from"./chunk-fa450310.js";import{M as T,O as k,W as I,C as E}from"./chunk-e0f43811.js";import{D as R}from"./chunk-3475f25e.js";import{u as L}from"./chunk-de5b2d76.js";import"./chunk-e77bab5e.js";import"./chunk-81ce3c83.js";import"./chunk-b87b1853.js";let v=p.isMobile?{width:{ideal:640}}:null;function P(u){let{apiCheck:p,onLivenessDetectionDone:R,captureFrameSettings:P,onFramesCaptured:A,frontCamera:M,flipVideoHorizontal:O,customDirectionIcon:H,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:$,outputEncryptionSettings:_,cameraScale:B,defaultCameraId:K,passiveModeAuto:N,offsetFaceY:z,styledComponent:G,serviceSettings:Y,onReset:W,isLoading:q}=u,J=e(),{onErrorCallback:Q,onCloseCallback:X}=L(),Z=r.useAsset("bg_camera_mask.png"),ee=r.useAsset("bg_camera_mask_red.png"),er=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[es,en]=n.useState({}),{yFaceDetectionError:ea,yFaceVerificationStepsWrapper:et}=es,[eo,ei]=n.useState(""),[ec,el]=n.useState(),eu=n.useMemo(()=>({backgroundColor:a("Selfie.backgroundColor")({theme:J})}),[J]),ep=n.useCallback(({lostY:e,height:r,clientHeight:s})=>{let n=e+25,a=n+30;en({yFaceDetectionError:n,yFaceVerificationStepsWrapper:a+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(a);return 0!==z&&(i+z<t||i+z+r>o)?Q({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=z,{y:i}},[z,Q]),{shouldResetFlowOnOrientationChange:em,countdownToTakePicture:ed,cropArea:ef,curStepIndex:eh,faceDetectionError:eg,resetFlow:eC,handleTriggerPassiveMode:ej,handleVideoPlayed:ey,refVideo:eD,showCountdown:eF,steps:eS,refIsReseting:ex,videoPlayed:eb,warmupDone:eT,showCaptureButton:ek,shouldShowCountdown:eI,showLoading:eE}=x({currentOrientation:ec,apiCheck:p,bgCameraMask:Z,bgCameraMaskRed:ee,surroundStyle:eu,onLivenessDetectionDone:R,onError:Q,cropAreaDimension:ep,customDirectionIcon:H,captureFrameSettings:P,onFramesCaptured:A,setRemainingTime:ei,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:$,outputEncryptionSettings:_,cameraScale:B,passiveModeAuto:N,serviceSettings:Y,onReset:W});n.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eR}=G,eL=d(u,J),ev=ex.current?0:eh/eS.length*100,{lang:eP}=t.useSDKSettings(),eA=n.useRef(0),eM=n.useRef({}),eO=n.useRef(o.ErrorDuration.SHORT),eH=n.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eg||{},s=e?.[eP];return Date.now()-eA.current>=eO.current&&(eA.current=Date.now(),eO.current=r,eM.current=s),eM.current},[eg,eh]),eV=n.useCallback(e=>{el(e),em?eC():e===T.LANDSCAPE?eD.current?.pause():eD.current?.play()},[eD,eC,em]);return i.jsx(k,{onOrientationChange:eV,children:i.jsxs(c,{frontCamera:M,onVideoPlayed:ey,onClose:X,flipHorizontal:O??M,ref:eD,videoSettings:v,onError:Q,scale:B,defaultCameraId:K,closeButton:eR||null,children:[!eT&&i.jsx(I,{}),eb?i.jsxs(i.Fragment,{children:["string"==typeof eH?i.jsx(f,{top:ea-15,className:"face-detection-error",children:eH}):null,ef.current?i.jsxs(E,{x:`${ef.current.x}px`,y:`${ef.current.y}px`,width:`${ef.current.width}px`,height:`${ef.current.height}px`,surroundStyle:ef.current.surroundStyle,children:[i.jsx(h,{}),i.jsx(g,{...eL,progress:ev,showErrorRing:!!eg&&a("Selfie.progressCircle.showErrorRing")({theme:J})}),eI?i.jsx(C,{children:ed}):null,eg&&i.jsx(j,{})]}):null,eo&&i.jsx(y,{top:et-30,children:eo}),ek?i.jsx(D,{children:i.jsx(F,{onClick:ej,disabled:eF,children:l(J,"Selfie.captureIcon.src")?i.jsx("img",{src:l(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(b,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eE||q)&&i.jsx(S,{children:i.jsx("img",{src:er,alt:""})})]})})}P.propTypes={apiCheck:u.bool,mode:u.string,onLivenessDetectionDone:u.func,onClose:u.func,onError:u.func,onReset:u.func,captureFrameSettings:u.shape({}),onFramesCaptured:u.func,frontCamera:u.bool,isLoading:u.bool,flipVideoHorizontal:u.bool,customDirectionIcon:u.shape({}),customStepTimeConstraints:u.shape({}),onProcessing:u.func,customErrors:u.shape({}),apiCredentials:u.shape({accessKey:u.string,secretKey:u.string,apiUrl:u.string}),outputEncryptionSettings:u.shape({}),cameraScale:u.number,defaultCameraId:u.string,passiveModeAuto:u.bool,offsetFaceY:u.number,styledComponent:u.shape({CloseCameraButton:u.node}),serviceSettings:u.shape({})},P.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(R,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(R,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(R,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(R,{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{P as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,b as t,u as s,aH as a,s as n,c as i,ab as r,d as l,e as c,f as o,k as u,aK as _,aL as m,J as g,O as d,Y as f,Q as h,F as b,av as v,t as p,aB as w,j as k}from"./chunk-ed832fec.js";import{t as y}from"./chunk-e77bab5e.js";import{t as F}from"./chunk-81ce3c83.js";import{n as T,u as L,o as R,q as B,r as C,v as S,s as x,x as I}from"./chunk-7f5333af.js";import{m as M}from"./chunk-de5b2d76.js";import{u as D}from"./chunk-b87b1853.js";let E=a.faceTracker(),j=new _,{FaceDirection:P,Errors:A,Messages:V,TrackLivenessEvents:W}=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:Z,surroundStyle:G,cropAreaDimension:H,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:es=500,captureFrameSettings:ea=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:eB,assetRoot:eC,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),[ej,eP]=e.useState(!1),eA=e.useRef({}),{sendEvent:eV}=c.useSDKTracking(),[eW,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),eZ=e.useRef([]),eG=e.useRef(null),eH=e.useRef(),eJ=e.useRef(null);null===eJ.current&&(eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y,Locale:eI,lang:eB}));let[eQ,eX]=e.useState(),eY=e.useCallback(e=>{eX(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:ts,waitBeforeStartFlowMs:ta,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:a,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},T,a),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"),_=s.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:!s.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(a,"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}},[a,n])}({clientSettings:e4,captureFrameSettingsProp:ea}),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===W?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eV(e),ed&&ed(e)}},[ed,eV]),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:W?.start_camera,log:{}})},[tu]),e.useEffect(()=>(j.start(),()=>{j.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eP(!0),tu({tag:"selfie",event:W?.show_warmup,log:{}}),tu({tag:"selfie",event:W?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[ej,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eJ.current.curStepIndex=eJ.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eq.current)},[]),tb=e.useCallback(()=>{eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,Locale:eI,lang:eB}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eX(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eG.current=null,eZ.current=[],eH.current=null,"function"==typeof eb&&eb(),eD()},[eI,eC,X,Q,J,eK,eB,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...V,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let s=F(tp.liveness_terminated_time_out?.msg[t]);e[t]=s({x:e3.limitTimeSecond})}),eX({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),j.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=F(tw.REMAIN_TIME[eB]),s=e;switch(e3.format){case"mm:ss":s=e.toString().padStart(5,"00:00");break;case"ss":s=e.toString().padStart(2,"0")}en(t({x:s}))}},[eB,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(),j.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&&ej,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=s:r=l=a-200;let c=Math.floor((s-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:G},"object"==typeof H?eE.current={...eE.current,...H}:"function"==typeof H&&(eE.current={...eE.current,...H({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,G,H]),tR=e.useCallback(()=>{eN(3),clearInterval(eq.current),eK(!0);let e=async e=>{if(e-1==0){let e;j.stop(),tT(),clearInterval(eq.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*j.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eG.current]:eZ.current).map(e=>f.resizeBlobImg(e.blob,400,400)),s=(await Promise.all(t)).map((t,s)=>{let a=d.parseLivenessImg({...e[s],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:a})}),a=await Promise.all(s),n={};if(e_&&e_.key){let{key:e}=e_,t=a.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,s)=>({...t,base64:e[s]})),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:s})=>({base64:e,label:t,index:s}))),_&&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:P.FRONTAL})}),s=e.map((e,s)=>eM.uploadImage({file:a[s],...t(e.leftRightScore)}));e_&&e_.key&&(s=e.map((e,s)=>{let a=new Blob([n.frontalFacesEncrypted[s].hex]);return eM.uploadImage({file:a,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(s),a=null;tc.enableVerifyFaceLiveness&&(a=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([a,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,s)=>({id:t?.data?.image_id,blob:e?.[s]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:a,...n,capturedFrames:i,video:B()}),C()}};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]),tB=e.useRef({});e.useEffect(()=>{tB.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function s({faceDirection:e,canvas:t,leftRightScore:s,blurScore:a,isEyeClosed:n}){if(!0===ez.current&&(ts&&e===P.FRONTAL||!ts)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eH.current<e9?.waitForBestImageTimeMsWeb?(eG.current||(eG.current={blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eG.current=I({incomingFrame:{blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eG.current}))):eZ.current.length<1&&eZ.current.push({blob:e,leftRightScore:s,captureTime:Date.now(),blurScore:a})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tB.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:B,faceNotFrontalMinThreshold:C}=await a.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}=eJ.current;if(L){I=L.landmarks;let e=await a.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===j.duration("limit_close_eye")||j.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==j.duration("limit_close_eye")||j.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let V=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:s}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:a}=tg.current;e&&Date.now()-a>=s&&(eX({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:V&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:W?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==P.FRONTAL&&B>=C){if(!function(e,t,s,a){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:a,bottomRight:n}=e,i=[...a,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:s,original_landmarks:s,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:s},a)=>({base64:t[a],label:e,index:s}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:s},a)=>({base64:t[a],label:e,index:s})),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:s})=>({base64:e,label:t,index:s}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==P.FRONTAL&&ts)o=tp.not_frontal_face,eE.current.image=Z;else if(!c){u||(eL(!0),j.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eZ.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eH.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eH.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await s({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=Z);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),s=document.createElement("canvas");s.width=400,s.height=400;let a=s.getContext("2d");a.translate(400,0),a.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,s)}return ew&&ej&&setTimeout(()=>{r()},ta??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ta,ts,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eB,eM,_,k,Z,$,ee,et,es,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,ej,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(()=>{eQ&&(eQ?.code!==tp?.liveness_terminated_time_out&&eQ?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eq.current),eK(!1),eG.current=null,eZ.current=[],eH.current=null))},[e9?.enable,eQ,eK,tp]);let{curStepIndex:tC,steps:tS}=eJ.current,tx=eT&&!eQ&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eW,cropArea:eE,curStepIndex:tC,faceDetectionError:eQ,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:ej,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function Z({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{Z as C,q as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as r}from"./chunk-ed832fec.js";import{r as o}from"./chunk-e77bab5e.js";var s=r(o());export{s as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{s as Constants,a_ as SDK,h as SDKAdapter,aX as ScannerType,aZ as defaultClientSettings,aY as defaultReadIDCardSteps,aW as getSDKVersion}from"./chunk-ed832fec.js";
|