@tsocial/tvweb-sdk.platform 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-1bd57581.js +3 -0
- package/build/esm/chunk-390ea2aa.js +1 -0
- package/build/esm/chunk-3fc64163.js +1 -0
- package/build/esm/chunk-41c1d4f2.js +1 -0
- package/build/esm/chunk-44240957.js +1 -0
- package/build/esm/chunk-4da2a90d.js +1 -0
- package/build/esm/chunk-5544ce07.js +1 -0
- package/build/esm/chunk-58f60271.js +10 -0
- package/build/esm/chunk-7c980e08.js +1 -0
- package/build/esm/chunk-9390d088.js +1121 -0
- package/build/esm/chunk-989d36e3.js +3 -0
- package/build/esm/chunk-a37a1269.js +256 -0
- package/build/esm/chunk-afb105f2.js +428 -0
- package/build/esm/chunk-b39a7ba9.js +1 -0
- package/build/esm/chunk-c136757f.js +1 -0
- package/build/esm/chunk-c298ad04.js +1 -0
- package/build/esm/chunk-ce4fbdae.js +1 -0
- package/build/esm/chunk-dad8ede3.js +1 -0
- package/build/esm/chunk-e1ce62d6.js +45 -0
- package/build/esm/chunk-e468b8ce.js +85 -0
- package/build/esm/chunk-eea8c6e6.js +1 -0
- package/build/esm/chunk-fdbce3d2.js +1 -0
- package/build/esm/tvweb-sdk.platform.esm.min.js +1 -0
- package/build/tvweb-sdk.platform.cjs.min.js +986 -1131
- package/build/tvweb-sdk.platform.standalone.js +61402 -65034
- package/build/tvweb-sdk.platform.standalone.min.js +986 -1131
- package/build/types/index.d.ts +22 -11
- package/package.json +7 -7
- package/build/tvweb-sdk.platform.esm.min.js +0 -2089
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{i as e,P as r,s as t,A as n,T as s,m as i,b as a,j as o,C as c,r as l,aI as u,c as m,a4 as p,k as d,aJ as f}from"./chunk-9390d088.js";import{M as g,O as h,W as j,C as x}from"./chunk-e468b8ce.js";import{u as F}from"./chunk-41c1d4f2.js";import{p as y,g as C,a as D,O as S,I as b,h as T,F as I,i as v,j as E,L as k,b as L,S as R}from"./chunk-a37a1269.js";import{u as V}from"./chunk-4da2a90d.js";import"./chunk-c136757f.js";import"./chunk-c298ad04.js";import"./chunk-fdbce3d2.js";import"./chunk-dad8ede3.js";let _=e.img`
|
|
2
|
+
width: ${({width:e})=>e};
|
|
3
|
+
`;function w({type:e}){let r=n(),t=s(`Selfie.Active.directionIcon.${e}`,`${e}_arrow.gif`),c=i(`Selfie.Active.directionIcon.${e}Width`)({theme:r}),l=a(r,`Selfie.Active.directionIcon.${e}`);return null===l?o.jsx(o.Fragment,{}):l&&null!==l?o.jsx(_,{src:a(r,`Selfie.Active.directionIcon.${e}`),width:c,alt:""}):o.jsx(_,{src:t,alt:"",width:c})}w.propTypes={type:r.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},w.defaultProps={type:t.FaceDirection.LEFT};let A=d.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:t})=>{let n=f(`instruction_${r}.svg`),s=a(t,`Selfie.Active.imageHolder.${r}`);return null===s?o.jsx(o.Fragment,{}):"string"==typeof s&&""!==s?o.jsx("img",{src:s,alt:""}):"v1"===a(t,"themeVersion")?o.jsx("span",{children:e}):o.jsx("img",{src:n,alt:""})};function P(e){var r,f;let{apiCheck:_,onLivenessDetectionDone:w,captureFrameSettings:P,onFramesCaptured:N,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:M,customStepTimeConstraints:U,onProcessing:B,customErrors:K,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,defaultCameraId:Y,offsetFaceY:J,styledComponent:q,isLoading:Q,serviceSettings:X,onReset:Z}=e,ee=n(),{onErrorCallback:er,onCloseCallback:et}=V(),en=c.useAsset("bg_camera_mask.png"),es=c.useAsset("bg_camera_mask_red.png"),ei=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,eo]=l.useState({}),{yFaceVerificationStepsWrapper:ec,yFaceDetectionError:el}=ea,[eu,em]=l.useState(""),[ep,ed]=l.useState(),ef=l.useMemo(()=>({backgroundColor:i("Selfie.backgroundColor")({theme:ee})}),[ee]);u(a(ee,"themeVersion"),"up_arrow.gif"),u(a(ee,"themeVersion"),"left_arrow.gif"),u(a(ee,"themeVersion"),"right_arrow.gif"),u(a(ee,"themeVersion"),"frontal_arrow.gif"),u(a(ee,"themeVersion"),"instruction_up.svg"),u(a(ee,"themeVersion"),"instruction_left.svg"),u(a(ee,"themeVersion"),"instruction_right.svg"),u(a(ee,"themeVersion"),"instruction_frontal.svg");let eg=l.useCallback(({clientHeight:e,videoAreaWidth:r,videoAreaHeight:t,lostX:n,lostY:s})=>{let i,a;d.isMobile?a=i=r:i=a=t-200;let o=Math.floor((r-i)/2)+n,c=5+s,l=s+25,u=l+30;eo({yFaceDetectionError:l,yFaceVerificationStepsWrapper:u+a+20});let m=Math.floor(s),p=Math.floor(e-s);return c=Math.floor(u),0!==J&&(c+J<m||c+J+a>p)?er({code:`offsetFaceY must be in [-${c-m}, ${p-a-c}]`}):c+=J,{x:o,y:c,width:i,height:a}},[J,er]),{shouldResetFlowOnOrientationChange:eh,cropArea:ej,curStepIndex:ex,directionIcon:eF,directionIconAnimation:ey,faceDetectionError:eC,resetFlow:eD,handleVideoPlayed:eS,instructions:eb,refVideo:eT,refIsReseting:eI,steps:ev,videoPlayed:eE,activeCapturing:ek,warmupDone:eL,showLoading:eR}=F({currentOrientation:ep,apiCheck:_,bgCameraMask:en,bgCameraMaskRed:es,surroundStyle:ef,onLivenessDetectionDone:w,onError:er,cropAreaDimension:eg,customDirectionIcon:M,captureFrameSettings:P,onFramesCaptured:N,setRemainingTime:em,customStepTimeConstraints:U,onProcessing:B,customErrors:K,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,serviceSettings:X,onReset:Z});l.useEffect(()=>{"string"==typeof ev[0]?.directionIcon&&Promise.all(ev.map(e=>y(e.directionIcon)))},[ev]);let{CloseCameraButton:eV}=q,e_=C(e,ee),ew=eI.current?0:ex/ev.length*100,{lang:eA}=m.useSDKSettings(),e$=l.useRef(0),eP=l.useRef({}),eN=l.useRef(t.ErrorDuration.SHORT),eH=l.useMemo(()=>{let{msg:e,duration:r=t.ErrorDuration.SHORT}=eC||{},n=e?.[eA];return Date.now()-e$.current>=eN.current&&(e$.current=Date.now(),eN.current=r,eP.current=n),eP.current},[eC,ex]),eO=l.useCallback(e=>{ed(e),eh?eD():e===g.LANDSCAPE?eT.current?.pause():eT.current?.play()},[eT,eD,eh]);return o.jsx(h,{onOrientationChange:eO,children:o.jsxs(p,{frontCamera:H,onVideoPlayed:eS,onClose:et,flipHorizontal:O??H,ref:eT,videoSettings:A,onError:er,scale:z,defaultCameraId:Y,closeButton:eV||null,children:[!eL&&o.jsx(j,{}),eE?o.jsxs(o.Fragment,{children:[ej.current?o.jsxs(x,{x:`${ej.current.x}px`,y:`${ej.current.y}px`,width:`${ej.current.width}px`,height:`${ej.current.height}px`,surroundStyle:ej.current.surroundStyle,children:[o.jsx(D,{}),o.jsx(S,{...e_,progress:ew,showErrorRing:!!eC&&i("Selfie.progressCircle.showErrorRing")({theme:ee})}),o.jsx(b,{children:(r=eF,f=ey,r?"string"==typeof r?o.jsx("img",{className:f,src:r,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):r:null)}),ek&&o.jsx(T,{})]}):null,eb?o.jsxs(o.Fragment,{children:[o.jsx(I,{top:ec+5,className:"instructions",children:eb}),o.jsx(v,{top:ec+35,children:ev.map((e,r)=>{let{name:t,image:{objUrl:n}}=e;return o.jsx(E,{active:ex>=r,className:"step-item",children:n?o.jsx("img",{className:"image_preview",src:n,alt:""}):o.jsx($,{stepNumber:r+1,type:t,theme:ee})},t)})})]}):null]}):null,(eR||Q)&&o.jsx(k,{children:o.jsx("img",{src:ei,alt:"",className:"spin"})}),eu&&o.jsx(L,{top:ec-30,children:eu}),"string"==typeof eH?o.jsx(R,{top:el-15,className:"face-detection-error",children:eH}):null]})})}P.propTypes={apiCheck:r.bool,onLivenessDetectionDone:r.func,onClose:r.func,onError:r.func,onReset:r.func,captureFrameSettings:r.shape({}),onFramesCaptured:r.func,flipVideoHorizontal:r.bool,frontCamera:r.bool,isLoading:r.bool,customDirectionIcon:r.shape({}),customStepTimeConstraints:r.shape({}),onProcessing:r.func,customErrors:r.shape({}),apiCredentials:r.shape({accessKey:r.string,secretKey:r.string,apiUrl:r.string}),outputEncryptionSettings:r.shape({}),cameraScale:r.number,defaultCameraId:r.string,offsetFaceY:r.number,styledComponent:r.shape({CloseCameraButton:r.node}),serviceSettings:r.shape({})},P.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[t.FaceDirection.LEFT]:o.jsx(w,{type:t.FaceDirection.LEFT}),[t.FaceDirection.RIGHT]:o.jsx(w,{type:t.FaceDirection.RIGHT}),[t.FaceDirection.UP]:o.jsx(w,{type:t.FaceDirection.UP}),[t.FaceDirection.FRONTAL]:o.jsx(w,{type:t.FaceDirection.FRONTAL})},customStepTimeConstraints:{[t.FaceDirection.UP]:{delayTime:0},[t.FaceDirection.LEFT]:{delayTime:0},[t.FaceDirection.RIGHT]:{delayTime:0},[t.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,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{A as e,C as r,T as s,r as t,m as n,aI as a,b as o,c as i,s as c,j as l,a4 as u,az as m,a7 as p,W as d,P as h,k as g,aJ as f}from"./chunk-9390d088.js";import{M as j,O as x,W as y,C as C}from"./chunk-e468b8ce.js";import{u as F}from"./chunk-41c1d4f2.js";import{D as D}from"./chunk-989d36e3.js";import{p as S,d as b,e as v,A as T,f as k,I as I,h as E,F as _,i as V,j as L,T as R,L as w,k as A,l as P,S as H}from"./chunk-a37a1269.js";import{u as N}from"./chunk-4da2a90d.js";import"./chunk-c136757f.js";import"./chunk-c298ad04.js";import"./chunk-fdbce3d2.js";import"./chunk-dad8ede3.js";let M=g.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:s})=>{let t=f(`instruction_${r}.svg`),n=o(s,`Selfie.Active.imageHolder.${r}`);return null===n?l.jsx(l.Fragment,{}):"string"==typeof n&&""!==n?l.jsx("img",{src:n,alt:""}):"v1"===o(s,"themeVersion")?l.jsx("span",{children:e}):l.jsx("img",{src:t,alt:""})};function O(h){var f,D;let{apiCheck:O,onLivenessDetectionDone:U,captureFrameSettings:B,onFramesCaptured:K,frontCamera:z,flipVideoHorizontal:W,customDirectionIcon:G,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,defaultCameraId:ee,offsetFaceY:er,isLoading:es,serviceSettings:et,onReset:en}=h,ea=e(),{onErrorCallback:eo,onCloseCallback:ei}=N(),ec=r.useAsset("bg_camera_mask.png"),el=r.useAsset("bg_camera_mask_red.png"),eu=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[em,ep]=t.useState({}),{yFaceVerificationStepsWrapper:ed,yFaceDetectionError:eh,yCountdown:eg}=em,[ef,ej]=t.useState(""),[ex,ey]=t.useState(),eC=t.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:ea})}),[ea]);a(o(ea,"themeVersion"),"up_arrow.gif"),a(o(ea,"themeVersion"),"left_arrow.gif"),a(o(ea,"themeVersion"),"right_arrow.gif"),a(o(ea,"themeVersion"),"frontal_arrow.svg"),a(o(ea,"themeVersion"),"instruction_up.svg"),a(o(ea,"themeVersion"),"instruction_left.svg"),a(o(ea,"themeVersion"),"instruction_right.svg"),a(o(ea,"themeVersion"),"instruction_frontal.svg");let eF=t.useCallback(({lostY:e,height:r,clientHeight:s})=>{let t=g.isMobile?e:e+80,n=t+r+20,a=n+110;ep({yFaceDetectionError:a+30,yCountdown:a,yFaceVerificationStepsWrapper:n});let o=Math.floor(e),i=Math.floor(s-e),c=Math.floor(t);return 0!==er&&(c+er<o||c+er+r>i)?eo({code:`offsetFaceY must be in [-${c-o}, ${i-r-c}]`}):c+=er,{y:c}},[er,eo]),{shouldResetFlowOnOrientationChange:eD,cropArea:eS,curStepIndex:eb,directionIcon:ev,directionIconAnimation:eT,faceDetectionError:ek,resetFlow:eI,handleVideoPlayed:eE,instructions:e_,refVideo:eV,refIsReseting:eL,steps:eR,videoPlayed:ew,activeCapturing:eA,warmupDone:eP,showLoading:eH}=F({currentOrientation:ex,apiCheck:O,bgCameraMask:ec,bgCameraMaskRed:el,surroundStyle:eC,onLivenessDetectionDone:U,onError:eo,cropAreaDimension:eF,customDirectionIcon:G,captureFrameSettings:B,onFramesCaptured:K,setRemainingTime:ej,customStepTimeConstraints:Y,onProcessing:J,customErrors:q,apiCredentials:Q,outputEncryptionSettings:X,cameraScale:Z,serviceSettings:et,onReset:en});t.useEffect(()=>{"string"==typeof eR[0]?.directionIcon&&Promise.all(eR.map(e=>S(e.directionIcon)))},[eR]);let eN=b(h,ea),eM=eL.current?0:eb/eR.length*100,{lang:e$}=i.useSDKSettings(),eO=t.useRef(0),eU=t.useRef({}),eB=t.useRef(c.ErrorDuration.SHORT),eK=t.useMemo(()=>{let{msg:e,duration:r=c.ErrorDuration.SHORT}=ek||{},s=e?.[e$];return Date.now()-eO.current>=eB.current&&(eO.current=Date.now(),eB.current=r,eU.current=s),eU.current},[ek,eb]),ez=t.useCallback(e=>{ey(e),eD?eI():e===j.LANDSCAPE?eV.current?.pause():eV.current?.play()},[eV,eI,eD]);return l.jsx(x,{onOrientationChange:ez,children:l.jsxs(u,{frontCamera:z,onVideoPlayed:eE,onClose:ei,flipHorizontal:W??z,ref:eV,videoSettings:M,onError:eo,scale:Z,defaultCameraId:ee,closeButton:l.jsx(m,{}),children:[!eP&&l.jsx(y,{}),ew?l.jsxs(l.Fragment,{children:[eS.current?l.jsxs(C,{x:`${eS.current.x}px`,y:`${eS.current.y}px`,width:`${eS.current.width}px`,height:`${eS.current.height}px`,surroundStyle:eS.current.surroundStyle,children:[l.jsx(v,{padding:T}),l.jsx(k,{...eN,progress:eM,showErrorRing:!!ek}),l.jsx(I,{children:(f=ev,D=eT,f?"string"==typeof f?l.jsx("img",{className:D,src:f,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):f:null)}),eA&&l.jsx(E,{})]}):null,e_?l.jsxs(l.Fragment,{children:[l.jsx(_,{top:ed+5,className:"instructions",children:e_}),l.jsx(V,{top:ed+40,children:eR.map((e,r)=>{let{name:s,image:{objUrl:t}}=e;return l.jsx(L,{active:eb>=r,className:"step-item",children:t?l.jsx("img",{className:"image_preview",src:t,alt:""}):l.jsx($,{stepNumber:r+1,type:s,theme:ea})},s)})})]}):null]}):null,l.jsx(R,{y:"20px",children:l.jsx(p,{id:"flash_liveness.title"})}),(eH||es)&&l.jsx(w,{children:l.jsx("img",{src:eu,alt:""})}),ef&&l.jsxs(A,{top:eg,children:[l.jsx(d,{color:n("Selfie.countdown.color")({theme:ea})}),l.jsx(P,{children:ef})]}),"string"==typeof eK?l.jsx(H,{top:eh,className:"face-detection-error",children:eK}):null]})})}O.propTypes={apiCheck:h.bool,onLivenessDetectionDone:h.func,onClose:h.func,onError:h.func,onReset:h.func,captureFrameSettings:h.shape({}),onFramesCaptured:h.func,flipVideoHorizontal:h.bool,frontCamera:h.bool,isLoading:h.bool,customDirectionIcon:h.shape({}),customStepTimeConstraints:h.shape({}),onProcessing:h.func,customErrors:h.shape({}),apiCredentials:h.shape({accessKey:h.string,secretKey:h.string,apiUrl:h.string}),outputEncryptionSettings:h.shape({}),cameraScale:h.number,defaultCameraId:h.string,offsetFaceY:h.number,styledComponent:h.shape({CloseCameraButton:h.node}),serviceSettings:h.shape({})},O.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[c.FaceDirection.LEFT]:l.jsx(D,{type:c.FaceDirection.LEFT}),[c.FaceDirection.RIGHT]:l.jsx(D,{type:c.FaceDirection.RIGHT}),[c.FaceDirection.UP]:l.jsx(D,{type:c.FaceDirection.UP}),[c.FaceDirection.FRONTAL]:l.jsx(D,{type:c.FaceDirection.FRONTAL})},customStepTimeConstraints:{[c.FaceDirection.UP]:{delayTime:0},[c.FaceDirection.LEFT]:{delayTime:0},[c.FaceDirection.RIGHT]:{delayTime:0},[c.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,C as r,T as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-9390d088.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-a37a1269.js";import{u as b,C as T}from"./chunk-44240957.js";import{M as k,O as I,W as E,C as R}from"./chunk-e468b8ce.js";import{D as L}from"./chunk-989d36e3.js";import{u as v}from"./chunk-4da2a90d.js";import"./chunk-c298ad04.js";import"./chunk-fdbce3d2.js";import"./chunk-dad8ede3.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,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:J}=p,Q=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:Q})}),[Q]),em=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:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:eT,warmupDone:ek,showCaptureButton:eI,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,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=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/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,eg]),eU=a.useCallback(e=>{eu(e),ed?ej():e===k.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(I,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!ek&&i.jsx(E,{}),eT?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(h,{top:et-15,className:"face-detection-error",children:ew}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eI?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(T,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,b as t,u as a,aH as n,s as s,c as i,ab as r,d as l,e as c,aq as o,ap as m,f as g,O as u,k as _,aK as f,aL as d,J as b,Y as h,F as p,Q as v,av as k,t as F,aB as w}from"./chunk-9390d088.js";import{d as y}from"./chunk-c136757f.js";import{t as T}from"./chunk-c298ad04.js";import{t as I}from"./chunk-fdbce3d2.js";import{w as R,m as S,n as L,u as x,o as B,q as D,r as E,v as A,s as M,t as O}from"./chunk-a37a1269.js";import{m as N}from"./chunk-4da2a90d.js";import{u as P}from"./chunk-dad8ede3.js";let C=async({steps:e,apiClient:t,FaceDirection:a,outputEncryptionSettings:n,video:s})=>{let i=[];e.forEach(e=>{let{name:s,image:r,frontalFaceImage:l}=e;if(s!==a.FRONTAL){let e={label:"portrait",metadata:JSON.stringify({gesture_score:r.leftRightScore,gesture:s})};if(n&&n.key){let a=new Blob([r.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:r.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}));if(l.blob){let e={label:"portrait",metadata:JSON.stringify({gesture_score:l.leftRightScore,gesture:a.FRONTAL})};if(n&&n.key){let a=new Blob([l.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:l.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}))});let r=s?t.uploadFile({file:s,label:"video"}):Promise.resolve({data:{file_id:null}}),[l,...c]=await Promise.all([r,...i]);return e.forEach((e,t)=>{e.image.imageId=c[2*t].data.image_id,e.frontalFaceImage.imageId=c[2*t+1].data.image_id}),l},j=async({apiClient:e,faceVerificationFlowData:t,onLivenessDetectionDone:a,captureFrameSettings:n,FaceDirection:s,onError:i,outputEncryptionSettings:r,video:l,enabledServices:c,capturedFrames:o})=>{try{let i=t.current.steps;await C({steps:i,apiClient:e,FaceDirection:s,outputEncryptionSettings:r,video:l});let m=i.filter(e=>e.frontalFaceImage.imageId);if(0===m.length)a({error:"wrong_face_movement"});else{await R();let t=S(n);if(t){let n=null;c.enableVerifyFaceLiveness&&(n=e.verifyFaceLiveness({images:m.map(e=>({id:e.frontalFaceImage.imageId})),gesture_images:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:{imageId:t}})=>({gesture:e,images:[{id:t}]})),videos:t}));let r=null;c.enableVerifySanityPortrait&&(r=e.requestVerifyPortrait({image:{id:m[m.length-1].frontalFaceImage.imageId}}));let[l,g]=await Promise.all([n,r]),u=l?.data.is_live===!0;a({apiCheckPassed:u,verifyFaceLivenessResult:l?.data??null,verifyFacePortraitResult:g?.data??null,frontalFaces:m.map(e=>({id:e.frontalFaceImage.imageId,blob:e.frontalFaceImage.blob})),steps:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:t})=>({name:e,blob:t.blob,id:t.imageId})),uploadFramesResult:t,capturedFrames:o})}else a({error:"network_error"})}}catch(e){i({error:e})}},U=n.faceTracker(),V=new f,{FaceDirection:W,Errors:J,Messages:K,TrackLivenessEvents:$}=s,z={enable:!1,framesIntervalTime:180,framesBatchLength:0},q={[s.FaceDirection.UP]:{delayTime:0},[s.FaceDirection.LEFT]:{delayTime:0},[s.FaceDirection.RIGHT]:{delayTime:0},[s.FaceDirection.FRONTAL]:{delayTime:2e3}},H=()=>{},G=()=>{},X=()=>{};function Z({apiCheck:f,bgCameraMask:R,bgCameraMaskRed:S,surroundStyle:C,cropAreaDimension:Q,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea=q,onLivenessDetectionDone:en,onError:es,frontalMinSize:ei,waitingTimeToGetBetterFrames:er=500,captureFrameSettings:el=z,setRemainingTime:ec=H,onProcessing:eo=X,customErrors:em,customMessages:eg,apiCredentials:eu={},onFramesCaptured:e_=G,initFirstGestureTimeout:ef=2e3,outputEncryptionSettings:ed,cameraScale:eb=1,sendCustomEvent:eh,serviceSettings:ep,currentOrientation:ev,onReset:ek}={}){let[eF,ew]=e.useState(!1),[ey,eT]=e.useState(!1),[eI,eR]=e.useState(!1),[eS,eL]=e.useState(!1),ex=e.useRef(null),{lang:eB,assetRoot:eD,customUrls:eE,exifKey:eA}=i.useSDKSettings(),eM=r.useSDKLocale(),{apiClient:eO}=l.useApiClient({apiCredentials:eu}),[,eN]=e.useReducer(e=>e+1,0),eP=e.useRef(null),eC=e.useRef(!1),[ej,eU]=e.useState(!1),eV=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),eJ=e.useRef(null);null===eJ.current&&(eJ.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea,Locale:eM,lang:eB}));let[eK,e$]=e.useState(),ez=e.useCallback(e=>{e$(e)},[]),eq=e.useMemo(()=>T(ez,500),[ez]),eH=e.useRef([]),eG=e.useRef(),eX=P(),{faceTrackingSetting:eZ,flowIntervalTimeMs:eQ,limitTimeLivenessCheck:eY,terminateIfNoFace:e0,closeEyeSettings:e1,captureFrameSettings:e4,exifDataSettings:e6,recordVideo:e2,waitBeforeStartFlowMs:e3,resetFlowOnOrientationChange:e5,autoGenFrameIds:e8}=function({captureFrameSettingsProp:n,clientSettings:s}){return e.useMemo(()=>{let e,i=N({},L,s),r={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.enable"),webTerminateThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_terminate_threshold"),webWarningThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_warning_threshold"),limitFor:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.limit_for"),maxWarningTime:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.max_warning_time")},l=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),c=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),o=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),m=t(i,"data.settings.sdk_settings.active_liveness_settings.take_one_picture_time_ms"),g=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),u={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:g>0,totalMaxRetries:g,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},_={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")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.force_check")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},b={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");e=h?{enable:h.enable,enableLogging:h.enable_logging,framesBatchLength:h.frames_batch_len,framesIntervalTime:h.frames_interval_ms}:n;let p={enable:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.enable")&&u.enable,maxItems:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.max_items")};return{faceTrackingSetting:r,resetFlowOnOrientationChange:l,waitBeforeStartFlowMs:c,flowIntervalTimeMs:o,takeOnePictureTimeMs:m,limitTimeLivenessCheck:u,terminateIfNoFace:_,closeEyeSettings:f,exifDataSettings:d,recordVideo:b,captureFrameSettings:e,autoGenFrameIds:p}},[n,s])}({captureFrameSettingsProp:el,clientSettings:eX}),e9=1e3*eY.limitTimeSecond/e4.framesIntervalTime,{uuids:e7,getNextUUID:te,reset:tt}=o({total:Math.min(e8.maxItems,Math.ceil(e9/e4.framesBatchLength*1.2))}),ta=e.useRef(m.createSingleUUID()),tn=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);e8.enable&&(e.global_batch_id=te()),e.global_session_id=ta.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[e8.enable,te]),ts=e2?.enable,ti=e.useMemo(()=>g.getEnabledServices(ep,eX),[eX,ep]),tr=e.useRef(""),tl=e.useCallback(e=>{if(e?.event){if(e.event===$?.show_alert){let t=e.log?.alert;if(t===tr.current)return;tr.current=t}eW(e),eh&&eh(e)}},[eh,eW]),tc=e.useMemo(()=>T(e=>{tl(e)},2e3),[tl]),to=e.useRef(0),tm=e.useRef(),tg=e.useRef();e.useEffect(()=>{tl({tag:"selfie",event:$?.start_camera,log:{}})},[tl]),e.useEffect(()=>(V.start(),()=>{V.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(eG.current=performance.now(),eV.current=await d(eE),await b.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eU(!0),tl({tag:"selfie",event:$?.show_warmup,log:{}}),tl({tag:"selfie",event:$?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-eG.current}}),eG.current=null))}(),()=>{e=!0}},[ej,eE,tl]);let tu=e.useRef(!1),t_=e.useCallback(()=>{eJ.current.curStepIndex=eJ.current.steps.length,tu.current=!0,eR(!1),tg.current?.discardRecording()},[]),tf=e.useCallback(()=>{if(eJ.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,Locale:eM,lang:eB}),to.current=0,tm.current=null,eH.current=[],eL(!1),e$(null),M(),tg.current?.start(),tu.current=!1,e8.enable){let e=tt();u.addExifData("frame_batch_ids",e)}"function"==typeof ek&&ek(),eN()},[eM,eD,e8.enable,et,ee,Y,eB,ek,tt]),td=e.useCallback(()=>{t_(),setTimeout(()=>{tf()},eQ)},[t_,eQ,tf]),tb=e.useMemo(()=>({...J,...em}),[em]),th=e.useMemo(()=>({...K,...eg}),[eg]),tp=e.useCallback(({remainTime:e})=>{if(e>0&&e<=eY.remainTimeShow){let t=I(th.REMAIN_TIME[eB]),a=e;switch(eY.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}ec(t({x:a}))}},[eB,eY.format,eY.remainTimeShow,th.REMAIN_TIME,ec]),tv=e.useCallback(()=>{let e={};Object.keys(tb.liveness_terminated_time_out?.msg).forEach(t=>{let a=I(tb.liveness_terminated_time_out?.msg[t]);e[t]=a({x:eY.limitTimeSecond})}),e$({...tb.liveness_terminated_time_out,msg:e,duration:.95*eQ}),tl({tag:"selfie",event:$?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),V.stop(),ec(""),t_()},[tb.liveness_terminated_time_out,eQ,eY.limitTimeSecond,t_,tl,ec]),tk=e.useCallback(({attemptCount:e,fromBackground:t})=>{eY.enableMaxRetries&&e>=eY.totalMaxRetries&&es(s.Errors.max_retry_reached),t&&t_(),V.start(),tf()},[eY.enableMaxRetries,eY.totalMaxRetries,es,tf,t_]),{stopTimer:tF}=x({totalTime:eY.limitTimeSecond,totalDelayBetweenReset:eQ/1e3,interruptible:eY.interruptible,shouldStart:ey&&eY.enable&&ej,onTimesUp:tv,onTick:tp,onReset:tk}),tw=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i})=>{let r,l;_.isMobile?l=r=a-40:(l=450,r=450);let c=Math.floor((a-r)/2)+s;eP.current={x:c,y:5+i,width:r,height:l,image:R,surroundStyle:C},"object"==typeof Q?eP.current={...eP.current,...Q}:"function"==typeof Q&&(eP.current={...eP.current,...Q({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i,isMobile:_.isMobile,width:r,height:l})}),eN(),eT(!0)},[R,C,Q]),ty=e.useRef({});e.useEffect(()=>{ty.current.isFirstValidFrameFoundRef=eS},[eS]),e.useEffect(()=>{let e,t=ex.current,a=async()=>{let{steps:e}=eJ.current,t=[];e.map(e=>(t.push({name:e.name,blob:e.image.blob,captureTime:e.image.captureTime,gesture:e.name}),e.frontalFaceImage.blob&&t.push({name:e.name,blob:e.frontalFaceImage.blob,captureTime:e.frontalFaceImage.captureTime,gesture:W.FRONTAL}),0));let a=t.map(e=>h.resizeBlobImg(e.blob,400,400)),n=await Promise.all(a),s="0";if(e4.framesBatchLength>0){let e=`${Math.floor(eH.current.length/e4.framesBatchLength)}x${e4.framesBatchLength}`,t=eH.current.length%e4.framesBatchLength>0?`+${eH.current.length%e4.framesBatchLength}`:"";s=`${eH.current.length}:${e}${t}`}let i=n.map((e,a)=>{let n=u.parseLivenessImg({...t[a],frames:s});return u.writeCurrentExif({imageData:{blob:e},enableExifData:e6.enable,additionalData:n})}),r=await Promise.all(i),l=t.map((e,t)=>({name:e.name,blob:r[t]}));await Promise.all(e.map(async(t,a)=>{let n=l.filter(e=>e.name===t.name);if(e[a].image.blob=n[0].blob,t.frontalFaceImage.blob&&(e[a].frontalFaceImage.blob=n[1].blob),ed&&ed.key){let{key:s}=ed;e[a].image.encrypted=await v.encrypt({blob:n[0].blob,key:s}),t.frontalFaceImage.blob&&(e[a].frontalFaceImage.encrypted=await v.encrypt({blob:n[1].blob,key:s}))}return 0}))},i=async()=>{let{steps:e}=eJ.current,t=e[eJ.current.curStepIndex];if((t&&tl({tag:"selfie",event:{[s.FaceDirection.UP]:$?.capture_up_face,[s.FaceDirection.LEFT]:$?.capture_left_face,[s.FaceDirection.RIGHT]:$?.capture_right_face,[s.FaceDirection.FRONTAL]:$?.capture_frontal_face}[t.name],log:{time_capture_in_seconds:((performance.now()-eG.current)/1e3).toFixed(1)}}),eJ.current.curStepIndex++,eG.current=performance.now(),eZ.enable&&"each_gesture"===eZ.limitFor&&(to.current=0),eJ.current.curStepIndex===e.length)&&(eY.enable&&(V.stop(),tF(),ec("")),en)){let t=eH.current;if(ed&&ed.key){let e=await Promise.all(t.map(e=>e?.base64));if(t=t.map((t,a)=>({...t,base64:e[a]})),e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));e_(e),f&&B(ed,e,eO,t.length===e4.framesBatchLength)}}else if(e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO)}tl({tag:"selfie",event:$?.finish_capture,log:{time_capture_in_seconds:V.duration("from_1st_frame")}}),eo(),await tg.current?.stopVideoRecording(),ew(!0),u.addExifData("user_action",{start_selfie:Date.now()-1e3*V.duration("from_1st_frame"),end_selfie:Date.now()}),u.addExifData("global_session_id",ta.current),e8.enable&&u.addExifData("frame_batch_ids",e7),await a();let n=eH.current;if(ed&&ed.key){let e=await Promise.all(n.map(e=>e?.base64));n=n.map((t,a)=>({...t,base64:e[a]}))}if(f&&ti.enableUploadImages)await j({apiClient:eO,faceVerificationFlowData:eJ,onLivenessDetectionDone:en,captureFrameSettings:e4,FaceDirection:W,onError:es,outputEncryptionSettings:ed,video:D().length?D()[0]:null,enabledServices:ti,capturedFrames:n});else{let t=e.filter(e=>e.name!==W.FRONTAL).map(e=>({name:e.name,image:{blob:e.image.blob,encrypted:e.image.encrypted}})),a=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.blob).filter(e=>null!==e),s=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.encrypted).filter(e=>e&&e.hex),i=e.find(e=>e.name===W.FRONTAL)?.image?.blob,r=e.find(e=>e.name===W.FRONTAL)?.image?.encrypted,l=i&&ei?await h.scaleImage(i,{minSize:ei}):null;i&&a.push(i),r&&s.push(r),tl({tag:"result",event:$?.liveness_detection_done,log:{result_object:{steps:t,frontalFaces:a,frontalScaledImage:l}}}),en({steps:t,frontalFaces:a,frontalFacesEncrypted:s,frontalScaledImage:l,capturedFrames:n,video:D().length?D()[0]:null}),E()}ew(!1)}eN()},r=y(()=>{let{curStepIndex:e,steps:t}=eJ.current,a=t[e],n=a?.image.blob!==null,s=a?.frontalFaceImage.blob!==null,r=t.filter(e=>e.frontalFaceImage.blob).length,l=!1;return n&&(s||![1].includes(e)||r>=1)?(eC.current=!1,i(),l=!0):n&&!s?eC.current=!0:eC.current=!1,eR(!1),l},er);async function l({faceDirection:e,canvas:t,blurScore:a,leftRightScore:n,isEyeClose:s}){let{curStepIndex:l,steps:c}=eJ.current;if(l<c.length){let o=c[l];if(O({faceDirection:e,curStep:o})||s)return;if(e===W.FRONTAL&&(null===o.frontalFaceImage.blurScore||k.hasBetterBlurScore(a,o.frontalFaceImage.blurScore))){o.frontalFaceImage.blurScore=a;let e=await p.takePicture({canvas:t});o.frontalFaceImage.blob=e,o.frontalFaceImage.leftRightScore=n,o.frontalFaceImage.captureTime=Date.now(),eC.current&&(eC.current=!1,i())}if(o.name===e&&(null===o.image.blurScore||k.hasBetterBlurScore(a,o.image.blurScore))){eR(!0),o.image.blurScore=a;let e=await p.takePicture({canvas:t});o.image.blob=e,o.image.leftRightScore=n,o.image.captureTime=Date.now(),o.image.objUrl&&URL.revokeObjectURL(o.image.objUrl),o.image.objUrl=URL.createObjectURL(e),r()}}}async function c(a,i){let r,o;if(i?.width===0||i?.height===0)return;let{isFirstValidFrameFoundRef:m}=ty.current,{cropX:g,cropY:u,cropWidth:_,cropHeight:d}=a;i.getContext("2d").drawImage(t,g,u,_,d,-((400*eb-400)/2)/eb,-((400*eb-400)/2)/eb,400,400);let{blazefaceModel:b,closeEyesModel:h}=eV.current,[p,v]=await Promise.all([k.calculateBlurScore(i),F.getModelPredictions({model:b,sCanvas:i})]),{error:y,fullFace:T,faceRatio:I,faceNotFrontalMinThreshold:L}=await n.validatePredictions({predictions:v,width:F.SIZE,height:F.SIZE});r=y,eP.current.image=R;let x=null,D=null,E=null,A=null,{curStepIndex:M,steps:O}=eJ.current;if(T){let e=O[M],t=e&&e.name===W.FRONTAL;E=T.landmarks;let a=await n.calculateFaceDirection({landmarks:E,getPerfectFrontal:t});a&&(x=a.gesture,D=a.leftRightScore);let l=e1?.webTimeout+ea[s.FaceDirection.FRONTAL].delayTime/1e3;if(t&&e1?.enable&&(-1===V.duration("limit_close_eye")||V.duration("limit_close_eye")<l)){e1?.forceCheck||-1!==V.duration("limit_close_eye")||V.start("limit_close_eye");let{isEyeClose:e}=await h.predict(i,E,e1?.webThreshold);(A=e)&&!r&&(r=J.close_eye)}}let N=r?.code==="no_face"||r?.code==="partial_face",P=M<O.length;!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e0.enable||!t)return;let{maxTimeMs:a}=e0;tm.current&&e||(tm.current={time:Date.now(),frame:0}),e&&tm.current.frame++;let{time:n}=tm.current;e&&Date.now()-n>=a&&(e$({...tb.liveness_terminated_no_face,duration:eQ}),tl({tag:"selfie",event:$?.show_alert,log:{alert:"liveness_terminated_no_face"}}),td())}({noFace:N&&P,isFirstValidFrameFoundRef:m}),r?.code&&tc({tag:"selfie",event:$?.show_alert,log:{alert:r.code}}),!r||"face_too_small"===r.code&&x!==W.FRONTAL&&I>=L?(m||(eL(!0),eG.current=performance.now(),V.start("from_1st_frame")),function({trackingScore:e,isFirstValidFrameFoundRef:t}){if(!eZ.enable||null===e||!t)return!0;let{webWarningThreshold:a,webTerminateThreshold:n,maxWarningTime:s}=eZ;return!!(e<a)||(e<n&&to.current<s?(to.current++,to.current===s?(e$({...tb.liveness_terminated_face_tracking,duration:eQ}),tl({tag:"selfie",event:$?.show_alert,log:{alert:"liveness_terminated_face_tracking"}})):e$({...tb.liveness_too_fast,duration:1500}),!0):(e$({...tb.liveness_terminated,duration:eQ}),tl({tag:"selfie",event:$?.show_alert,log:{alert:"liveness_terminated"}}),td(),!1))}({trackingScore:function(e,t,a,n){if(eH.current.length&&Date.now()-eH.current[eH.current.length-1].time<e4.framesIntervalTime)return null;if(e4.enable&&!n){let{topLeft:n,bottomRight:s}=e,i=[...n,...s],{score:r,time:l}=U(e,0===eH.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:eH.current.length,bbox:i,original_bbox:i,metadata:JSON.stringify({})};if(ed&&ed.key){if(c.base64=w.encryptFrameBase64(c.base64,ed.key),eH.current.push(c),e4.framesBatchLength>0&&eH.current.length%e4.framesBatchLength==0&&e_){let e=eH.current.slice(-e4.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{e_(e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a}))),f&&ti.enableUploadFrames&&B(ed,e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a})),eO,eH.current.length===e4.framesBatchLength)})}}else if(eH.current.push(c),e4.framesBatchLength>0&&eH.current.length%e4.framesBatchLength==0&&e_){let e=eH.current.slice(-e4.framesBatchLength);tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO,eH.current.length===e4.framesBatchLength)}return r}return null}(v[0],i,E,M>=O.length),isFirstValidFrameFoundRef:m})&&await l({faceDirection:x,canvas:i,blurScore:p,leftRightScore:D,isEyeClose:A})):M<O.length&&(o=tb[r.code],eP.current.image=S),eq(o),-1!==e&&(e=requestAnimationFrame(()=>c(a,i)))}async function o(){let e=p.analyzeVideoAndWindowSizes(t,eP.current),a=document.createElement("canvas");a.width=400,a.height=400;let n=a.getContext("2d");n.translate(400,0),n.scale(-1*eb,+eb);let{mediaRecorder:s}=ts&&t?await A({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};tg.current=s,tg.current&&tg.current.start(),c(e,a)}return ey&&ej&&setTimeout(()=>{o()},e3??ef),()=>{cancelAnimationFrame(e),e=-1}},[ev,e3,ef,ey,eB,eO,f,R,S,en,es,ei,er,e4,eo,eZ,eY.enable,ec,eq,ea,eQ,td,e0,tb,ej,tl,e_,ed,eb,e1?.enable,e1?.webThreshold,e1?.webTimeout,e1?.forceCheck,e6.enable,eA,tc,ts,ti,tF,e7,tn,e8.enable]);let{curStepIndex:tT,steps:tI}=eJ.current,tR=e.useMemo(()=>tI.find(e=>e.name===s.FaceDirection.FRONTAL),[tI]),tS=eC.current?tR:tI[tT],tL=tS&&eS?tS.instructions[eB]:null,tx=tS&&eS?tS.directionIcon:"";return{resetFlowOnOrientationChange:e5,cropArea:eP,curStepIndex:tT,directionIcon:tx,directionIconAnimation:tS?tS.directionIconAnimation:"",faceDetectionError:eK,resetFlow:td,handleVideoPlayed:tw,instructions:tL,refVideo:ex,refIsReseting:tu,steps:tI,videoPlayed:ey,activeCapturing:eI,isFirstValidFrameFound:eS,warmupDone:ej,showLoading:eF}}export{Z as u};
|
|
@@ -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-9390d088.js";import{t as y}from"./chunk-c298ad04.js";import{t as F}from"./chunk-fdbce3d2.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-a37a1269.js";import{m as M}from"./chunk-4da2a90d.js";import{u as D}from"./chunk-dad8ede3.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{j as r,r as e,s as o,a2 as n,ac as t,ad as i,ae as a,af as u,ag as s,ah as d,ai as c,aj as l,ak as g,al as f,am as p,an as h,$ as b,u as y,ao as x}from"./chunk-9390d088.js";let k=e.createContext(!1),C=({children:e,debug:o=!1})=>r.jsx(k.Provider,{value:o,children:e}),T=()=>e.useContext(k),v={tsBlue:"#0276f1",tsSecondary:"rgba(0, 47, 117, 0.6)"},m={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},titleBack:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},instruction:{padding:"unset",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"},captured:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"}},error:{padding:"5px 10px",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},toggle:{color:"#d1d1d1",fontSize:"16px",fontWeight:"500",gap:"16px",backgroundColor:"#fff",active:{backgroundColor:"#2196f3"},inactive:{backgroundColor:"#ccc"}},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:"60px",height:"60px",disabled:{src:""}},loadingIcon:{src:"",width:"100px",height:"100px"},rectangleMask:{width:600,height:400,strokeWidth:2,strokeStyles:{},radius:10,paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"7, 4",opacity:.6},error:{fill:"rgba(234,50,35, 0.1)",strokeWidth:2,stroke:"#ea3223"}}},IDConfirmPopup:{image:{borderRadius:"5px"}},QRStep:{title:{color:"#fff",fontSize:"20px",fontWeight:"700",backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:"5px",backgroundColor:"#e7e6e6"},guideText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"},countdownText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"}},scanTooltip:{backgroundColor:"#00ce78",borderRadius:"8px",color:"#fff",padding:"10px",textAlign:"center"},scanCountdown:{textAlign:"center",color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"none",borderRadius:"3px",padding:"5px 10px"},invalidPopup:{padding:"10px",title:{display:"block",color:v.tsSecondary,fontSize:"16px",fontWeight:"bold",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{color:"#fff",fontSize:"1rem",fontWeight:"normal",backgroundColor:v.tsBlue,border:"none",borderRadius:"3px",outline:"none",height:"66px",margin:"30px 0 0 0"},skipButton:{color:v.tsBlue,fontSize:"1rem",fontWeight:"normal",backgroundColor:"unset",border:"none",borderRadius:"unset",outline:"none",height:"unset",margin:"20px 0"}},resultText:{success:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#34ce60"},error:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#ff9532"}}}},D={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{...o.DesignToken.Typography.h4,color:o.DesignToken.Color.base.white,backgroundColor:"unset"},titleBack:{...o.DesignToken.Typography.h4,color:o.DesignToken.Color.base.white,backgroundColor:"unset"},instruction:{...o.DesignToken.Typography.body,padding:"5px 10px",color:"rgba(255, 255, 255, 0.8)",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{...o.DesignToken.Typography.label,color:o.DesignToken.Color.base.white,padding:`6px ${o.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},captured:{...o.DesignToken.Typography.label,color:o.DesignToken.Color.base.white,padding:`6px ${o.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"}},error:{...o.DesignToken.Typography.body,padding:"5px 10px",color:o.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:o.DesignToken.CornerRadius["2xs"]},toggle:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.base.white,gap:o.DesignToken.Spacing.base,backgroundColor:o.DesignToken.Color.base.white,active:{backgroundColor:o.DesignToken.Color.base.blue},inactive:{backgroundColor:o.DesignToken.Color.neutral[300]}},countdown:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:o.DesignToken.CornerRadius["2xs"]},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:o.DesignToken.Height["7xl"],height:o.DesignToken.Height["7xl"],disabled:{src:""}},loadingIcon:{src:"",width:"47px",height:"47px"},rectangleMask:{width:600,height:400,strokeWidth:n.getCSSNumericValue(o.DesignToken.BorderWidth["3xl"]),strokeStyles:{},radius:n.getCSSNumericValue(o.DesignToken.CornerRadius.base),paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:o.DesignToken.Color.neutral[400],strokeWidth:n.getCSSNumericValue(o.DesignToken.BorderWidth["3xl"])},error:{fill:"none",strokeWidth:n.getCSSNumericValue(o.DesignToken.BorderWidth["3xl"]),stroke:o.DesignToken.Color.semantic.error[400]}}},IDConfirmPopup:{image:{borderRadius:o.DesignToken.CornerRadius["2xs"]}},QRStep:{title:{...o.DesignToken.Typography.h4,backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:o.DesignToken.CornerRadius["2xs"],backgroundColor:"transparent"},guideText:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.neutral[600],textAlign:"center"},countdownText:{...o.DesignToken.UIText.medium,color:o.DesignToken.Color.neutral[500],textAlign:"center"}},scanTooltip:{backgroundColor:"transparent",borderRadius:o.DesignToken.CornerRadius.xs,color:o.DesignToken.Color.base.white,padding:"10px",textAlign:"center"},scanCountdown:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.semantic.error[400],textAlign:"center",backgroundColor:"transparent",border:"none",borderRadius:o.DesignToken.CornerRadius["2xs"],padding:"0px"},invalidPopup:{padding:"10px",title:{...o.DesignToken.Typography.h6,color:o.DesignToken.Color.content.primary,display:"none",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.content.secondary,textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.base.white,backgroundColor:o.DesignToken.Color.base.blue,borderRadius:o.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:o.DesignToken.Height["3xl"],margin:"24px 0 0 0"},skipButton:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.content.primary,backgroundColor:o.DesignToken.Color.background.tertiary,borderRadius:o.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:o.DesignToken.Height["3xl"],margin:"12px 0"}},resultText:{success:{...o.DesignToken.Typography.body,textColor:o.DesignToken.Color.content.primary,mainColor:o.DesignToken.Color.semantic.success[400]},error:{...o.DesignToken.Typography.body,textColor:o.DesignToken.Color.content.primary,mainColor:o.DesignToken.Color.semantic.warning[500]}}}},R=m,S=D,{DesignToken:W}=o,w={FlashLiveness:{maskFill:"#fff",mask:{strokeColor:W.Color.separators.secondary,strokeColorError:W.Color.semantic.error[400],strokeWidth:4,path:"M118.5 2.5C54.2233 2.5 2.5 59.5579 2.5 129.447C2.5 146.072 3.68394 172.618 8.16415 200.483C12.6369 228.301 20.4309 257.673 33.7816 279.787C46.9667 301.626 59.6817 317.047 73.3658 327.003C87.1207 337.011 101.735 341.41 118.5 341.41C135.265 341.41 149.879 337.011 163.634 327.003C177.318 317.047 190.033 301.626 203.218 279.787C216.569 257.673 224.363 228.301 228.836 200.483C233.316 172.618 234.5 146.072 234.5 129.447C234.5 59.5579 182.777 2.5 118.5 2.5Z",width:237,height:344},title:{hidden:!1,height:"auto",color:W.Color.content.primary,fontSize:W.Typography.h5.fontSize,fontWeight:W.Typography.h5.fontWeight,lineHeight:W.Typography.h5.lineHeight},guideline:{text:{close:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},far:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},flashing:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",padding:"12px 16px"}},icon:{color:W.Color.blue[900],src:""}},instruction:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},timeoutText:{color:W.Color.semantic.error[400],fontSize:W.Typography.body.fontSize,fontWeight:W.Typography.body.fontWeight,padding:"0"},errorOverlay:{backgroundColor:"transparent",opacity:0},progressBar:{mainColor:W.Color.blue[900],secondaryColor:W.Color.blue[100],textColor:W.Color.blue[900],fontSize:W.Typography.body.fontSize,fontWeight:W.FontWeight["semi-bold"]},flashing:{logo:{src:"",width:"140px",height:"auto"},backgroundPattern:{srcMobile:"",srcDesktop:"",width:"100%",height:"auto"}}}},z=w,j=w,{DesignToken:_}=o,A={Selfie:{backgroundColor:"#FFF",title:{...o.DesignToken.Typography.h5,color:o.DesignToken.Color.content.primary},countdown:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"0px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{activeColor:"rgba(52, 152, 211, 1)",innerPadding:3,showDashedRing:!0,showOutsideRing:!1,dashedRingLineThick:"2",dashedRingLineSpacing:"3.5",dashedRingColor:"rgba(193, 197, 204, 1)",dashedRingOpacity:1,insideRingColor:"#fff",insideRingWidth:10,insideRingStrokeDash:"0",outsideRingOpacity:1,outsideRingColor:"#fff",errorRingWidth:0,radius:160,strokeWidth:3,progress:0,showErrorRing:!1,errorRingColor:"#df0000",dashedRingWidth:10,dashedInsideRingColor:"#fff",dashedInsideRingWidth:3,showInsideRing:!0},progressCircleV2:{activeColor:_.Color.blue[900],neutralColor:_.Color.neutral[300],errorColor:_.Color.semantic.error[400],radius:160,strokeWidth:2,progress:0,tickWidth:15,numberOfTicks:200},Active:{instruction:{color:_.Color.content.primary,fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,textShadow:"none",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"168px",left:"",leftWidth:"150px",right:"",rightWidth:"150px",up:"",upWidth:"150px"},imageHolder:{width:"72px",height:"72px",borderRadius:"50%",border:`3px solid ${_.Color.blue[900]}`,fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:"",activeStepBorder:`1px solid ${_.Color.separators.tertiary}`,activeStepBorderRadius:"50%"}}}},I={Selfie:{backgroundColor:"rgba(0, 0, 0, 0.6)",captureIcon:{src:"",width:"50px"},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{radius:160,strokeWidth:3,progress:0,showErrorRing:!0,activeColor:"#0092ff",innerPadding:5,outsideRingColor:"#f2f6f9",outsideRingOpacity:.1,insideRingColor:"#f2f6f9",insideRingWidth:1,insideRingStrokeDash:"2",errorRingColor:"#df0000",errorRingWidth:1,dashedRingColor:"#ffffff",dashedRingOpacity:.3,dashedRingWidth:10,dashedRingLineThick:1,dashedRingLineSpacing:6,dashedInsideRingColor:"#ffffff",dashedInsideRingWidth:0,showOutsideRing:!1,showDashedRing:!1,showInsideRing:!0},Active:{instruction:{color:"#fff",fontSize:"20px",fontWeight:"normal",textShadow:"2px 2px 4px #000000",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"140px",left:"",leftWidth:"80px",right:"",rightWidth:"80px",up:"",upWidth:"80px"},imageHolder:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid #fff",fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:""}}}},O=A,{DesignToken:P}=o,B={PassiveLiveness:{instruction:{color:P.Color.content["on-bg-color"],fontSize:P.Typography.label.fontSize,fontWeight:P.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",backdropFilter:"blur(28px)",padding:"12px 12px"}}},F=B,q=B,H={closeButton:{top:o.DesignToken.Spacing.base,right:o.DesignToken.Spacing.base,left:"auto",bottom:"auto",display:"block",src:"",width:"24px",height:"auto"},popup:{backgroundColor:o.DesignToken.Color.base.white,padding:"10px",border:"none",borderRadius:o.DesignToken.CornerRadius.sm,overlay:{backgroundColor:o.DesignToken.Color.mask[70]},title:{...o.DesignToken.Typography.h6,fontWeight:o.DesignToken.FontWeight["semi-bold"],color:o.DesignToken.Color.content.primary,textAlign:"center",display:"initial",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.content.secondary,textAlign:"center",border:"unset",borderRadius:"unset",margin:"30px 0 0 0",padding:"0 0 0 0"},primaryButton:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.base.white,backgroundColor:o.DesignToken.Color.base.blue,borderRadius:o.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:o.DesignToken.Height["3xl"],maxWidth:"unset"},secondaryButton:{...o.DesignToken.Typography.body,color:o.DesignToken.Color.content.primary,backgroundColor:o.DesignToken.Color.background.tertiary,borderRadius:o.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:o.DesignToken.Height["3xl"],maxWidth:"unset"}}},$={v1:{...R,...z,...I,...F,...H},v2:{...S,...j,...O,...q,...H}};function L(){if(rn)return ro;rn=1;var r=u();return ro=function(){try{var e=r(Object,"defineProperty");return e({},"",{}),e}catch(r){}}()}function M(){if(ri)return rt;ri=1;var r=L();return rt=function(e,o,n){"__proto__"==o&&r?r(e,o,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[o]=n}}function U(){if(ru)return ra;ru=1;var r=M(),e=s();return ra=function(o,n,t){(void 0===t||e(o[n],t))&&(void 0!==t||n in o)||r(o,n,t)}}var E,V,K,N,Q,Z,G,J,X,Y,rr,re,ro,rn,rt,ri,ra,ru,rs,rd,rc,rl,rg,rf,rp,rh,rb,ry,rx,rk,rC,rT,rv,rm,rD,rR,rS,rW,rw,rz,rj,r_,rA,rI,rO,rP,rB,rF,rq,rH,r$,rL,rM,rU,rE,rV,rK,rN,rQ,rZ,rG,rJ,rX,rY,r0,r1,r2,r3,r5,r6,r4,r7,r8,r9,er,ee,eo,en,et,ei,ea,eu,es,ed,ec,el,eg,ef,ep,eh,eb,ey,ex,ek,eC,eT,ev,em,eD,eR,eS,eW,ew,ez,ej,e_,eA,eI,eO,eP={exports:{}};eP.exports;function eB(){return rD?rm:(rD=1,rm=function(r,e){return function(o){return r(e(o))}})}function eF(){return rS?rR:(rS=1,rR=eB()(Object.getPrototypeOf,Object))}function eq(){if(rw)return rW;rw=1;var r=Object.prototype;return rW=function(e){var o=e&&e.constructor;return e===("function"==typeof o&&o.prototype||r)}}function eH(){if(rO)return rI;rO=1;var r=function(){if(rA)return r_;rA=1;var r=l(),e=g();return r_=function(o){return e(o)&&"[object Arguments]"==r(o)}}(),e=g(),o=Object.prototype,n=o.hasOwnProperty,t=o.propertyIsEnumerable;return rI=r(function(){return arguments}())?r:function(r){return e(r)&&n.call(r,"callee")&&!t.call(r,"callee")}}function e$(){return rB?rP:(rB=1,rP=function(r){return"number"==typeof r&&r>-1&&r%1==0&&r<=0x1fffffffffffff})}function eL(){if(rq)return rF;rq=1;var r=f(),e=e$();return rF=function(o){return null!=o&&e(o.length)&&!r(o)}}var eM={exports:{}};function eU(){var r,e,o,n,t,i,a,u;if(rU)return eM.exports;return rU=1,r=eM,e=eM.exports,o=d(),n=rM?rL:(rM=1,rL=function(){return!1}),u=(a=(i=(t=e&&!e.nodeType&&e)&&r&&!r.nodeType&&r)&&i.exports===t?o.Buffer:void 0)?a.isBuffer:void 0,r.exports=u||n,eM.exports}function eE(){if(rV)return rE;rV=1;var r=l(),e=eF(),o=g(),n=Object.prototype,t=Function.prototype.toString,i=n.hasOwnProperty,a=t.call(Object);return rE=function(n){if(!o(n)||"[object Object]"!=r(n))return!1;var u=e(n);if(null===u)return!0;var s=i.call(u,"constructor")&&u.constructor;return"function"==typeof s&&s instanceof s&&t.call(s)==a}}eM.exports;var eV={exports:{}};eV.exports;function eK(){if(rX)return rJ;rX=1;var r=function(){if(rN)return rK;rN=1;var r=l(),e=e$(),o=g(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,rK=function(t){return o(t)&&e(t.length)&&!!n[r(t)]}}(),e=rZ?rQ:(rZ=1,rQ=function(r){return function(e){return r(e)}}),o=function(){var r,e,o,n,t,i;if(rG)return eV.exports;return rG=1,r=eV,e=eV.exports,o=p(),i=(t=(n=e&&!e.nodeType&&e)&&r&&!r.nodeType&&r)&&t.exports===n&&o.process,r.exports=function(){try{var r=t&&t.require&&t.require("util").types;if(r)return r;return i&&i.binding&&i.binding("util")}catch(r){}}(),eV.exports}(),n=o&&o.isTypedArray;return rJ=n?e(n):r}function eN(){return r0?rY:(r0=1,rY=function(r,e){if("constructor"!==e||"function"!=typeof r[e]){if("__proto__"!=e)return r[e]}})}function eQ(){if(r5)return r3;r5=1;var r=function(){if(r2)return r1;r2=1;var r=M(),e=s(),o=Object.prototype.hasOwnProperty;return r1=function(n,t,i){var a=n[t];o.call(n,t)&&e(a,i)&&(void 0!==i||t in n)||r(n,t,i)}}(),e=M();return r3=function(o,n,t,i){var a=!t;t||(t={});for(var u=-1,s=n.length;++u<s;){var d=n[u],c=i?i(t[d],o[d],d,t,o):void 0;void 0===c&&(c=o[d]),a?e(t,d,c):r(t,d,c)}return t}}function eZ(){if(r8)return r7;r8=1;var r=/^(?:0|[1-9]\d*)$/;return r7=function(e,o){var n=typeof e;return!!(o=null==o?0x1fffffffffffff:o)&&("number"==n||"symbol"!=n&&r.test(e))&&e>-1&&e%1==0&&e<o}}function eG(){if(er)return r9;er=1;var r=r4?r6:(r4=1,r6=function(r,e){for(var o=-1,n=Array(r);++o<r;)n[o]=e(o);return n}),e=eH(),o=h(),n=eU(),t=eZ(),i=eK(),a=Object.prototype.hasOwnProperty;return r9=function(u,s){var d=o(u),c=!d&&e(u),l=!d&&!c&&n(u),g=!d&&!c&&!l&&i(u),f=d||c||l||g,p=f?r(u.length,String):[],h=p.length;for(var b in u)(s||a.call(u,b))&&!(f&&("length"==b||l&&("offset"==b||"parent"==b)||g&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||t(b,h)))&&p.push(b);return p}}function eJ(){if(ea)return ei;ea=1;var r=eG(),e=function(){if(et)return en;et=1;var r=c(),e=eq(),o=eo?ee:(eo=1,ee=function(r){var e=[];if(null!=r)for(var o in Object(r))e.push(o);return e}),n=Object.prototype.hasOwnProperty;return en=function(t){if(!r(t))return o(t);var i=e(t),a=[];for(var u in t)"constructor"==u&&(i||!n.call(t,u))||a.push(u);return a}}(),o=eL();return ei=function(n){return o(n)?r(n,!0):e(n)}}function eX(){return ep?ef:(ep=1,ef=function(r){return r})}function eY(){return eb?eh:(eb=1,eh=function(r,e,o){switch(o.length){case 0:return r.call(e);case 1:return r.call(e,o[0]);case 2:return r.call(e,o[0],o[1]);case 3:return r.call(e,o[0],o[1],o[2])}return r.apply(e,o)})}function e0(){if(ew)return eW;ew=1;var r=eX(),e=function(){if(ex)return ey;ex=1;var r=eY(),e=Math.max;return ey=function(o,n,t){return n=e(void 0===n?o.length-1:n,0),function(){for(var i=arguments,a=-1,u=e(i.length-n,0),s=Array(u);++a<u;)s[a]=i[n+a];a=-1;for(var d=Array(n+1);++a<n;)d[a]=i[a];return d[n]=t(s),r(o,this,d)}}}(),o=function(){if(eS)return eR;eS=1;var r=function(){if(ev)return eT;ev=1;var r=eC?ek:(eC=1,ek=function(r){return function(){return r}}),e=L(),o=eX();return eT=e?function(o,n){return e(o,"toString",{configurable:!0,enumerable:!1,value:r(n),writable:!0})}:o}();return eR=(function(){if(eD)return em;eD=1;var r=Date.now;return em=function(e){var o=0,n=0;return function(){var t=r(),i=16-(t-n);if(n=t,i>0){if(++o>=800)return arguments[0]}else o=0;return e.apply(void 0,arguments)}}})()(r)}();return eW=function(n,t){return o(e(n,t,r),n+"")}}function e1(){if(ej)return ez;ej=1;var r=s(),e=eL(),o=eZ(),n=c();return ez=function(t,i,a){if(!n(a))return!1;var u=typeof i;return("number"==u?!!(e(a)&&o(i,a.length)):"string"==u&&i in a)&&r(a[i],t)}}function e2(){if(eA)return e_;eA=1;var r=e0(),e=e1();return e_=function(o){return r(function(r,n){var t=-1,i=n.length,a=i>1?n[i-1]:void 0,u=i>2?n[2]:void 0;for(a=o.length>3&&"function"==typeof a?(i--,a):void 0,u&&e(n[0],n[1],u)&&(a=i<3?void 0:a,i=1),r=Object(r);++t<i;){var s=n[t];s&&o(r,s,t,a)}return r})}}var e3=b(function(){if(eO)return eI;eO=1;var r=function(){if(eg)return el;eg=1;var r=function(){if(re)return rr;re=1;var r=t(),e=function(){if(V)return E;V=1;var r=t();return E=function(){this.__data__=new r,this.size=0}}(),o=N?K:(N=1,K=function(r){var e=this.__data__,o=e.delete(r);return this.size=e.size,o}),n=Z?Q:(Z=1,Q=function(r){return this.__data__.get(r)}),u=J?G:(J=1,G=function(r){return this.__data__.has(r)}),s=function(){if(Y)return X;Y=1;var r=t(),e=i(),o=a();return X=function(n,t){var i=this.__data__;if(i instanceof r){var a=i.__data__;if(!e||a.length<199)return a.push([n,t]),this.size=++i.size,this;i=this.__data__=new o(a)}return i.set(n,t),this.size=i.size,this}}();function d(e){var o=this.__data__=new r(e);this.size=o.size}return d.prototype.clear=e,d.prototype.delete=o,d.prototype.get=n,d.prototype.has=u,d.prototype.set=s,rr=d}(),e=U(),o=rl?rc:(rl=1,rc=(rd?rs:(rd=1,rs=function(r){return function(e,o,n){for(var t=-1,i=Object(e),a=n(e),u=a.length;u--;){var s=a[r?u:++t];if(!1===o(i[s],s,i))break}return e}}))()),n=function(){if(ec)return ed;ec=1;var r=U(),e=function(){var r,e,o,n,t,i,a;if(rg)return eP.exports;return rg=1,r=eP,e=eP.exports,o=d(),a=(i=(t=(n=e&&!e.nodeType&&e)&&r&&!r.nodeType&&r)&&t.exports===n?o.Buffer:void 0)?i.allocUnsafe:void 0,r.exports=function(r,e){if(e)return r.slice();var o=r.length,n=a?a(o):new r.constructor(o);return r.copy(n),n},eP.exports}(),o=function(){if(rx)return ry;rx=1;var r=function(){if(rb)return rh;rb=1;var r=rp?rf:(rp=1,rf=d().Uint8Array);return rh=function(e){var o=new e.constructor(e.byteLength);return new r(o).set(new r(e)),o}}();return ry=function(e,o){var n=o?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}(),n=rC?rk:(rC=1,rk=function(r,e){var o=-1,n=r.length;for(e||(e=Array(n));++o<n;)e[o]=r[o];return e}),t=function(){if(rj)return rz;rj=1;var r=function(){if(rv)return rT;rv=1;var r=c(),e=Object.create;return rT=function(){function o(){}return function(n){if(!r(n))return{};if(e)return e(n);o.prototype=n;var t=new o;return o.prototype=void 0,t}}()}(),e=eF(),o=eq();return rz=function(n){return"function"!=typeof n.constructor||o(n)?{}:r(e(n))}}(),i=eH(),a=h(),u=function(){if(r$)return rH;r$=1;var r=eL(),e=g();return rH=function(o){return e(o)&&r(o)}}(),s=eU(),l=f(),p=c(),b=eE(),y=eK(),x=eN(),k=function(){if(es)return eu;es=1;var r=eQ(),e=eJ();return eu=function(o){return r(o,e(o))}}();return ed=function(d,c,g,f,h,C,T){var v=x(d,g),m=x(c,g),D=T.get(m);if(D)return void r(d,g,D);var R=C?C(v,m,g+"",d,c,T):void 0,S=void 0===R;if(S){var W=a(m),w=!W&&s(m),z=!W&&!w&&y(m);R=m,W||w||z?a(v)?R=v:u(v)?R=n(v):w?(S=!1,R=e(m,!0)):z?(S=!1,R=o(m,!0)):R=[]:b(m)||i(m)?(R=v,i(v)?R=k(v):(!p(v)||l(v))&&(R=t(m))):S=!1}S&&(T.set(m,R),h(R,m,f,C,T),T.delete(m)),r(d,g,R)}}(),u=c(),s=eJ(),l=eN();return el=function t(i,a,d,c,g){i!==a&&o(a,function(o,s){if(g||(g=new r),u(o))n(i,a,s,d,t,c,g);else{var f=c?c(l(i,s),o,s+"",i,a,g):void 0;void 0===f&&(f=o),e(i,s,f)}},s)}}();return eI=e2()(function(e,o,n){r(e,o,n)})}());let e5=r=>{let{customTheme:o,clientSettings:n,themeVersion:t,uiSettings:i,defaultThemes:a=$}=r,u=y.getWebSetting(n,"data.settings.sdk_settings.ui_custom_settings");return e.useMemo(()=>{let r=x.selectUiSettings(i,u);return{...e3({},x.mapUISettingsToCustomTheme(r),o),themeVersion:t,defaultThemes:a}},[o,a,t,i,u])},e6=()=>{},e4=e.createContext({onDoneCallback:e6,onErrorCallback:e6,onCloseCallback:e6}),e7=({children:o,onDone:n=e6,onError:t=e6,onClose:i=e6})=>{let a=e.useCallback(r=>{n&&n(r)},[n]),u=e.useCallback(r=>{t&&t(r)},[t]),s=e.useCallback(()=>{i&&i()},[i]),d=e.useMemo(()=>({onDoneCallback:a,onErrorCallback:u,onCloseCallback:s}),[a,u,s]);return r.jsx(e4.Provider,{value:d,children:o})},e8=()=>{let r=e.useContext(e4);if(void 0===r)throw Error("useSDKCallback must be used within a SDKCallbackProvider");return r},e9=e.createContext(""),or=({children:e,isWrappedBy:o=""})=>r.jsx(e9.Provider,{value:o,children:e}),oe=()=>e.useContext(e9);export{C as D,e7 as S,or as W,D as a,T as b,oe as c,$ as d,e5 as e,e2 as f,eJ as g,eE as h,e0 as i,eY as j,eB as k,eq as l,e3 as m,eG as n,eL as o,e1 as p,eQ as r,v as t,e8 as u};
|
|
@@ -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-9390d088.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-a37a1269.js";import{u as x,C as b}from"./chunk-44240957.js";import{M as T,O as k,W as I,C as E}from"./chunk-e468b8ce.js";import{D as R}from"./chunk-989d36e3.js";import{u as L}from"./chunk-4da2a90d.js";import"./chunk-c298ad04.js";import"./chunk-fdbce3d2.js";import"./chunk-dad8ede3.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,10 @@
|
|
|
1
|
+
let e,t;import{r as r,i as a,j as o,e as i,F as n,aE as l,J as s,au as c,aF as u,aG as h,s as d,c as f,G as m,t as g,aH as _,v as p,av as b,k as y,K as w,P as E,d as C}from"./chunk-9390d088.js";import{W as v}from"./chunk-e468b8ce.js";let A=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
z-index: 1001;
|
|
8
|
+
|
|
9
|
+
background-color: ${e=>e.$overlay?"white":"transparent"};
|
|
10
|
+
`,T=({children:e=null,overlay:t=!1,loadingComponent:r=o.jsx(v,{})})=>o.jsxs(k,{$overlay:t,children:[t&&r,o.jsx("div",{style:{visibility:t?"hidden":"visible"},children:e})]}),L=(e,t,r)=>{let{smallScale:a,largeScale:o,ovalPadding:i}=e,n=t.width/t.height,l=a*r.height,s=o*r.height,c=i.top+i.bottom,u=i.left+i.right,h=s-c;if(parseFloat((h*n).toFixed(2))+u>r.width){let e=Number(((r.width-u)/t.width).toFixed(2));return{smallScale:Number((a/o*e).toFixed(2)),largeScale:e}}let d=Number(((l-c)/t.height).toFixed(2));return{smallScale:d,largeScale:Number((h/t.height).toFixed(2))}},M=({offset:e,ovalPadding:t,largeScale:r,ovalHeight:a,maskHeight:o})=>{let i=a/2+t.bottom;return(i+e)*r>o/2?o/2/r-i:e},P=e=>{r.useEffect(()=>()=>{e&&e.srcObject?.getTracks().forEach(e=>{e.stop()})},[e])},O=()=>{let[e,t]=r.useState(null),[a,o]=r.useState(!1),i=r.useRef(null);return r.useEffect(()=>{if(!i.current)return()=>{};let e=i.current,r=()=>{t(e.getBoundingClientRect()),o(!1)},a=()=>{o(!0)};return e.addEventListener("transitionstart",a),e.addEventListener("transitionend",r),()=>{e.removeEventListener("transitionstart",a),e.removeEventListener("transitionend",r)}},[]),[i,e??i.current?.getBoundingClientRect(),a,o]},B=()=>{let e=r.useRef(),{sendEvent:t}=i.useSDKTracking();return r.useCallback((r,a,o={})=>{let i=performance.now(),n={};"object"==typeof o&&(n={...o},e.current&&(n.interval_vs_previous_in_ms=Math.round(i-e.current))),"function"==typeof o&&(n=o({lastTimeLog:e.current})),e.current=i,t({tag:r,event:a,log:n})},[t])},D=(e,t)=>{let a=r.useRef(e);r.useEffect(()=>{a.current=e},[e]),r.useEffect(()=>{t&&"function"==typeof a.current&&a.current()},[t])},N=({compareFn:e,duration:t,minFrames:a=null})=>{let o=r.useRef(null),i=r.useRef(!1),n=r.useRef(0),l=r.useRef(()=>{}),{compareAndStoreResult:s,getBestResult:c,reset:u}=r.useMemo(()=>{var r,a;let o,i,n;return r=e,a=t,o=null,i=null,n=()=>null!==i&&performance.now()-i>a,{checkIsTimeUp:n,compareAndStoreResult:e=>{null===o&&(o=e,i=performance.now()),n()||r(o,e)&&(o=e)},getBestResult:()=>o,reset:()=>{o=null,i=null}}},[e,t]),h=r.useCallback(()=>{u(),n.current=0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)},[u]),d=r.useCallback(()=>null!==o.current,[]),f=r.useCallback(e=>{if(s(e),n.current+=1,!i.current||"number"!=typeof a||n.current<a)return;let t=c();l.current(t),h()},[s,c,a,h]),m=r.useCallback(({initialFrame:e,onDone:r})=>{l.current=r,f(e),o.current=setTimeout(()=>{if(i.current=!0,"number"==typeof a&&n.current<a)return;let e=c();l.current(e),h()},t)},[f,t,c,a,h]);return r.useEffect(()=>()=>{clearTimeout(o.current)},[]),r.useMemo(()=>({captureFrame:f,getBestResult:c,isAutoCapturing:d,startCapturing:m,stopCapturing:h}),[f,c,d,m,h])},I=e=>{let t=document.createElement("canvas");return t.setAttribute("width",e.videoWidth.toString()),t.setAttribute("height",e.videoHeight.toString()),t.getContext("2d").drawImage(e,0,0,e.videoWidth,e.videoHeight),t},j=()=>{let[e,t]=r.useState(Date.now());return{sessionId:e,updateSessionId:r.useCallback(()=>{t(Date.now())},[])}},z=(e,t)=>{if(0===Object.keys(e).length)return{topLeft:[0,0],bottomRight:[0,0],probability:0,landmarks:[]};let r=e.topLeft??[0,0],a=e.bottomRight??[0,0],o=e.probability??0,i=e.landmarks??[];return{topLeft:[r[0]*t,r[1]*t],bottomRight:[a[0]*t,a[1]*t],probability:o,landmarks:i.map(e=>[e[0]*t,e[1]*t])}},W=200,q=({size:e,scale:t=1,video:r,baseSize:a=W})=>{let{width:o,height:i}=e,{videoWidth:n=Number.MAX_SAFE_INTEGER,videoHeight:l=Number.MAX_SAFE_INTEGER}=r??{},s=Math.min(o,i)/a,c=Math.round(o/s*t),u=Math.round(i/s*t);return c>n||u>l?{width:o,height:i}:{width:c,height:u}},G=({width:e,height:t,cameraScale:r})=>{let a=document.createElement("canvas");a.width=e,a.height=t;let o=a.getContext("2d");return o?(o.translate(e,0),o.scale(-1*r,+r)):console.error("Failed to get 2D context from canvas in createLivenessCanvas"),a},H=({maskBoundingBox:e,faceRatio:t,validFaceRatio:r,video:a,shouldCropCenterSquare:o=!0,cropArea:i,frame:l,facePrediction:s,detectionToWholeFaceRatio:c=.8})=>{let u=e.width*t/r,h=u/e.width,d=e.height*h,f={x:e.x-(u-e.width)/2,y:e.y-(d-e.height)/2,width:u,height:d};f.x+f.width>i.x+i.width&&(f.width=i.width,f.x=i.x),f.y+f.height>i.y+i.height&&(f.height=i.height,f.y=i.y);let m=null;if(o){let e=Math.min(f.width,f.height),t=(s.bottomRight[1]-s.topLeft[1])/c,r=s.bottomRight[1]-t+(t-e)/2+i.y;r+e>f.y+f.height&&(r=f.y+f.height-e);let o={x:f.x+f.width/2-e/2,y:r,width:e,height:e};m=n.analyzeVideoAndWindowSizes(a,o)}else m=n.analyzeVideoAndWindowSizes(a,f);let g=q({size:{width:m.cropWidth,height:m.cropHeight},baseSize:400,video:a}),_=G({width:g.width,height:g.height,cameraScale:1}),p=_.width,b=_.height;return _.getContext("2d").drawImage(l,m.cropX,m.cropY,m.cropWidth,m.cropHeight,0,0,p,b),_},V=l(async function e({tfScriptUrls:t,closeEyesModelUrl:r,blazefaceModelUrl:a,qualifyModelUrl:o,opencvUrl:i}={}){let n=new u(r),l=new h(o),d=new c;await s.loadTensorFlow(t),await s.initTensorFlow({preferredBackends:["wasm","cpu"]});let f=[s.loadBlazefaceModel({modelUrl:a}),n.load(),l.init({opencvUrl:i}),c.init({opencvUrl:i})],[{blazefaceModel:m}]=await Promise.all(f);return{closeEyesModel:n,blazefaceModel:m,notQualifiedModel:l,brightnessDetector:d}}),U=({width:e,height:t,cameraScale:a=1,debug:o=!1})=>{let[i,n]=r.useState(null);return r.useEffect(()=>{let r=G({width:e,height:t,cameraScale:a});return o&&(document.body.appendChild(r),r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),n(r),()=>{o&&document.body.removeChild(r)}},[a,o,t,e]),i},K=y.isMobile?200:400;function J({cameraScale:e=1,isVideoPlaying:t,step:a,cropArea:o,videoRef:i,onFarFaceDetected:l,onFarFullFaceDetected:s,onCloseFaceDetected:c,onCloseFullFaceDetected:u,onFlashingFramesCaptured:h,frameInterval:y=0,useFaceDetectorWhenFlashing:w,onFaceError:E,onError:C,maskBoundingRect:v,shouldPauseFaceDetection:A,shouldContinueOnError:R,debug:S=!1,faceDetectionSettings:x}){let{faceSettings:k,maskSettings:T,closeEyesSettings:L,captureFrameSettings:M,blurCheckFarSettings:P,blurCheckCloseSettings:O,brightnessDetectionFarSettings:B,brightnessDetectionCloseSettings:D,notQualifiedFarSettings:N,notQualifiedCloseSettings:I,frontalFaceCheckSettings:j}=x,{chinToMaskBottomPadding:W}=T,{frameScale:G}=M,{enable:H,timeout:J,forceCheck:X}=L,{enable:$,upDownBoundMin:Y,upDownBoundMax:Q}=j,{minFarFaceRatio:Z,maxFarFaceRatio:ee,closeFaceRatio:et}=k,er=(e=>{let[t,a]=r.useState(e);return r.useEffect(()=>{(async()=>{try{let t=Math.max(16.666666666666668,33.333333333333336,e);a(t)}catch(e){console.error(e),a(20)}})()},[e]),t})(y),ea=(({videoRef:e,cropArea:t})=>r.useMemo(()=>e.current&&0!==Object.keys(t).length?n.analyzeVideoAndWindowSizes(e.current,t):{},[e,t]))({videoRef:i,cropArea:o}),eo=q({size:{width:ea.cropWidth,height:ea.cropHeight},scale:G,video:i.current}),ei=(({cropArea:e,maskBoundingRect:t,baseSize:r})=>{let{width:a,height:o,x:i,y:n}=e,l=Math.min(a,o)/r,s=t?.left??0,c=t?.top??0,u=t?.right??a;return{left:Math.max((s-i)/l,0),right:Math.min((u-i)/l,a/l),top:Math.max((c-n)/l,0),bottom:Math.min(((t?.bottom??o)-n)/l,o/l)}})({cropArea:o,maskBoundingRect:v,baseSize:Math.min(eo.width,eo.height)}),en=U({width:eo.width,height:eo.height,cameraScale:e}),el=Math.min(o.width,o.height)/Math.min(eo.width,eo.height),es=U({width:K,height:K*(eo.height/eo.width),cameraScale:e,debug:S}),ec=(({width:e,height:t,debug:a})=>{let o=r.useRef(null),i=r.useMemo(()=>{let r=document.createElement("canvas");return r.width=e,r.height=t,r.style.position="fixed",r.style.bottom="0",r.style.left="0",r.style.zIndex="99999",o.current=r,a&&document.body.appendChild(r),r},[t,e,a]);return r.useEffect(()=>()=>{a&&document.body.removeChild(o.current)},[a]),i})({width:160,height:150,debug:S}),{customUrls:eu}=f.useSDKSettings(),[eh,ed]=((e,t)=>{let[a,o]=r.useState({}),i=Object.keys(a).length>0;return r.useEffect(()=>{let r=!1;return(async()=>{try{let t=await V(e);if(r)return;o(t)}catch(e){t({...d.Errors.unable_to_load_model,details:e}),console.error(e)}})(),()=>{r=!0}},[i,e,t]),[a,i]})(eu,C),ef=r.useRef(null),{markTime:em,checkIfEllapsed:eg}=(({timeout:e})=>{let t=r.useRef(null),a=r.useCallback(()=>{t.current=performance.now()},[]),o=r.useCallback(()=>null===t.current?(a(),!1):performance.now()-t.current>e,[a,e]);return{markTime:a,checkIfEllapsed:o}})({timeout:1e3*J}),e_=ed&&t,{closeEyesModel:ep,blazefaceModel:eb,notQualifiedModel:ey,brightnessDetector:ew}=eh,eE=r.useCallback(async(e,t)=>{try{if(t?.width===0||t?.height===0||null===i.current||A||a===F.STOP_DECTECTING)return;let{cropX:n,cropY:f,cropWidth:y,cropHeight:C}=e,v=t.width,x=t.height;t.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v,x);let k=m.drawToSquareCanvas(t),T=K/v;if(S&&es.getContext("2d").drawImage(i.current,n,f,y,C,0,0,v*T,x*T),!w&&a===F.START_FLASHING){"function"==typeof h&&await h({prediction:null,originalRatio:el,canvas:t});return}let L=await g.getModelPredictions({model:eb,sCanvas:k}),M=[[ei.left,ei.top],[ei.right,ei.bottom]],{error:j,fullFace:q,faceRatio:G}=await _.validatePredictions({predictions:L,cropAreaCoordinates:M});if(S){var r,o;let e,t={left:ei.left*T,top:ei.top*T,right:ei.right*T,bottom:ei.bottom*T};r=es,o={x:t.left,y:t.top,width:t.right-t.left,height:t.bottom-t.top},e=r.getContext("2d"),e?(e.strokeStyle="red",e.lineWidth=1,e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.stroke(),e.closePath()):console.warn("drawBoundingBox: 2D context is not available.");let a=L.map(e=>z(e,T));((e,t,r=!1)=>{let a=e.getContext("2d");if(!a)return;let o=e.width;a.strokeStyle="blue",a.fillStyle="blue",a.lineWidth=1,t.forEach(e=>{e.landmarks.forEach(e=>{a.beginPath(),a.arc(r?o-e[0]:e[0],e[1],2,0,2*Math.PI),a.fill(),a.closePath()}),a.beginPath();let t={x:r?o-e.bottomRight[0]:e.bottomRight[0],y:e.topLeft[1],width:e.bottomRight[0]-e.topLeft[0],height:e.bottomRight[1]-e.topLeft[1]};a.rect(t.x,t.y,t.width,t.height),a.stroke(),a.closePath()})})(es,a,!0)}let V=d.FaceDirection.FRONTAL;if(q&&$){let e=await _.calculateFaceDirection({landmarks:q.landmarks,upDownBound:{lower:Y,upper:Q}});V=e?.gesture??""}(q||j?.code===d.Errors.partial_face.code)&&a===F.FAR_FACE&&"function"==typeof l&&await l({prediction:L[0],originalRatio:el,canvas:t}),(q||j?.code===d.Errors.partial_face.code)&&a===F.CLOSE_FACE&&"function"==typeof c&&await c({prediction:L[0],originalRatio:el,canvas:t});let U=j?.code;try{if(U===d.Errors.no_face.code)throw Error("no_face");if(U===d.Errors.multiple_faces.code){let e=_.calculateFaceArea(L[0]),t=_.calculateFaceArea(L[1]);if(e<=2*t)throw Error("multiple_faces")}if(V!==d.FaceDirection.FRONTAL)throw Error("face_not_frontal");if(U===d.Errors.partial_face.code){let e=_.cropFaceInsideBox([L[0].topLeft,L[0].bottomRight],M);if(p.rectEdgeRatio(e,M)>.95)throw Error("face_too_large")}if(a===F.FAR_FACE){if(G>ee)throw Error("face_too_large");if(G<Z)throw Error("face_too_small")}if(a===F.CLOSE_FACE&&G<et)throw Error("face_too_small");if(Array.isArray(L)&&L.length>0&&ei.bottom-L[0].bottomRight[1]>W)throw Error("face_too_high");if(U===d.Errors.face_out_of_box.code&&(a===F.FAR_FACE&&G>=Z&&G<=ee||a===F.CLOSE_FACE&&G>=et))throw Error("")}catch(e){U=e.message}let J=null;if(H)if(U)em();else{let e=await ep.predict(t,q.landmarks),r=!X&&eg();J=e.isEyeClose,e.isEyeClose&&!r&&(U="eye_close")}let er=null,ea=a===F.FAR_FACE?B:D;if((ea.enableTooBrightCheck||ea.enableTooDarkCheck)&&Array.isArray(L)&&L.length>0){let e=[[Math.max(L[0].topLeft[1],0),Math.min(L[0].bottomRight[0],t.width),Math.min(L[0].bottomRight[1],t.height),Math.max(L[0].topLeft[0],0)]],{score:r,message:a}=ew.score(t,e,ea.tooDarkThreshold,ea.tooBrightThreshold);er=r,""===U&&ea.enableTooBrightCheck&&"face_too_bright"===a&&(U="face_too_bright"),""===U&&ea.enableTooDarkCheck&&"face_too_dark"===a&&(U="face_too_dark")}let eo=0,en={enable:a===F.FAR_FACE?P.enable:O.enable,threshold:a===F.FAR_FACE?P.threshold:O.threshold};en.enable&&(eo=await b.calculateBlurScore(t),""!==U||b.hasBetterBlurScore(eo,en.threshold)||(U="blurry_face"));let eu=0,eh=0,ed="model_not_run",ef={enable:a===F.FAR_FACE?N.enable:I.enable,threshold:a===F.FAR_FACE?N.threshold:I.threshold};if(ef.enable&&q&&q.landmarks){let[e,r,a,o]=await ey.predict(t,q.landmarks,ef.threshold);eu=r,eh=o,ed=a,""!==U||e||(U="face_not_qualified")}if((S&&m.drawDebugCanvas(ec,{error:U,ovalFaceRatio:G?.toFixed(3)??"null",ovalError:j?.code??"null",step:a===F.FAR_FACE?"far":"close",blurScore:eo.toFixed(3),qualifyScore:eu.toFixed(3),brightnessScore:er?.toFixed(3)??"null"}),U)&&("function"==typeof E&&await E({error:U,currentStep:a}),!R))return;let e_=q,eE=G;if(!e_&&R&&(e_=Array.isArray(L)&&L.length>0?L[0]:{},eE=a===F.FAR_FACE?ee:et),a===F.FAR_FACE&&e_&&Z<=eE&&eE<=ee&&"function"==typeof s)return void await s({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});if(e_&&a===F.CLOSE_FACE&&eE>=et&&"function"==typeof u)return void await u({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:J,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});w&&e_&&a===F.START_FLASHING&&eE>=et&&"function"==typeof h&&await h({prediction:e_,originalRatio:el,canvas:t,faceError:U})}catch(e){console.error(e),C({error:e})}},[i,A,a,S,w,eb,ei.left,ei.top,ei.right,ei.bottom,$,H,B,D,P.enable,P.threshold,O.enable,O.threshold,N.enable,N.threshold,I.enable,I.threshold,R,Z,ee,et,es,h,el,Y,Q,l,c,W,ep,X,eg,em,ew,ey,ec,E,s,u,C]);return r.useEffect(()=>{let e=null,t=!1;return e_&&function r(){e=requestAnimationFrame(async e=>{t||null===i.current||((null===ef.current&&(ef.current=e),e-ef.current<er)?r():(ef.current=e,await eE(ea,en),r()))})}(),()=>{t=!0,cancelAnimationFrame(e)}},[en,ea,eE,e_,i,er]),{warmupDone:ed}}let X=e=>{let{shouldStart:t,totalTime:a,totalDelay:o,onError:i,onTimeout:n,onDelayEnd:l,maxRetriesSettings:s,interruptible:c=!0}=e,u=r.useRef(new w({totalTime:a,interruptible:c,totalDelayBetweenReset:o})),[h,f]=r.useState(a);return r.useEffect(()=>u.current.on("tick",({remainTime:e})=>{f(e)}),[n]),r.useEffect(()=>u.current.on("delaystart",({attemptCount:e})=>{s.enable&&e>=s.total?i(d.Errors.max_retry_reached):n()}),[s.enable,s.total,i,n]),r.useEffect(()=>u.current.on("delayend",()=>{l()}),[l]),r.useEffect(()=>u.current.on("reset",({attemptCount:e,fromBackground:t})=>{s.enable&&e>=s.total&&i(d.Errors.max_retry_reached),t&&(n(),l())}),[n,l,s.enable,s.total,i]),r.useEffect(()=>t?u.current.start():()=>{},[t]),{remaining:h}},$=e=>{switch(e){case"partial_face":return"flash_liveness.error.partial_face";case"no_face":case"face_out_of_box":return"flash_liveness.error.no_face";case"face_too_small":return"flash_liveness.error.face_too_small";case"face_too_large":return"flash_liveness.error.face_too_large";case"eye_close":return"flash_liveness.error.close_eye";case"face_not_frontal":return"flash_liveness.error.face_not_frontal";case"multiple_faces":return"flash_liveness.error.multiple_faces";case"face_too_high":return"flash_liveness.error.face_too_high";case"blurry_face":return"flash_liveness.error.face_too_blurry";case"face_not_qualified":return"flash_liveness.error.face_not_qualified";case"face_too_bright":return"flash_liveness.error.face_too_bright";case"face_too_dark":return"flash_liveness.error.face_too_dark";default:return""}},Y=e=>Array.isArray(e)?e.map(({base64:e,label:t,index:r,metadata:a})=>({base64:e,label:t,index:r,metadata:a})):e,Q=r.createContext({enable:!1,key:""}),Z=({children:e,settings:t})=>{let a=r.useMemo(()=>{let e=t?.key??"";return{enable:!!e,key:e}},[t?.key]);return o.jsx(Q.Provider,{value:a,children:e})};Z.propTypes={children:E.node.isRequired,settings:E.shape({key:E.string})},Z.defaultProps={settings:{key:""}};let ee=()=>r.useContext(Q),et=r.createContext({}),er=({apiCredentials:e,children:t})=>{let{apiClient:r}=C.useApiClient({apiCredentials:e});return o.jsx(et.Provider,{value:r,children:t})};er.propTypes={apiCredentials:E.shape({accessKey:E.string.isRequired,secretKey:E.string.isRequired,apiUrl:E.string.isRequired}),children:E.node.isRequired},er.defaultProps={apiCredentials:{}};let ea=()=>r.useContext(et);let eo=(e=[],t=async()=>(await Promise.all(e)).map(e=>({id:e?.data?.file_id??-1})),{uploadFrameBatch:(t,r,a)=>{let o=new Blob([JSON.stringify(t)]);e.push(r.uploadFile({file:o,metadata:JSON.stringify({type:"selfie"}),label:"video"},a))},getAllUploadedBatches:t,resetUploadBatches:()=>{e.length=0}});export{er as A,R as F,Z as O,S as R,F as S,T as W,O as a,N as b,j as c,A as d,I as e,x as f,J as g,P as h,D as i,X as j,H as k,M as l,$ as m,L as n,ee as o,ea as p,eo as q,Y as r,z as s,B as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,r as t,d as r,f as a,c as i,p as n,u as l,g as s,l as d,j as o,a as u,P as c}from"./chunk-9390d088.js";import{g as p,S as g,R as f}from"./chunk-afb105f2.js";import{W as m}from"./chunk-4da2a90d.js";import"./chunk-e468b8ce.js";let{IDCardSide:y,Errors:I}=e;async function b({image:e,cardType:t,cardSide:r,apiClient:a,outputEncryptionSettings:i}){let n={label:`id_card.${t}.${r}`};if(i&&i.key){let t=new File([e.encrypted.hex],`${Date.now()}.jpg`,{type:"image/jpeg"});return a.uploadImage({file:t,...n},{"X-TV-Key":i.key})}let l=new File([e.blob],`${Date.now()}.jpg`,{type:"image/jpeg"});return a.uploadImage({file:l,...n})}let S={data:{image_id:null}};async function _({image:e,apiClient:t,rawString:r,results:a,outputEncryptionSettings:i}){if(!e||!e.blob||!r)return Promise.resolve(S);let n={raw:r};a&&a.length>1&&(n=a.reduce((e,t,r)=>(e[0===r?"raw":`raw${r+1}`]=t,e),{}));let l={label:"qr_code",metadata:JSON.stringify(n)};if(i&&i.key){let r=new Blob([e.encrypted.hex]);return t.uploadImage({file:r,...l},{"X-TV-Key":i.key})}return t.uploadImage({file:e.blob,...l})}let C={data:{file_id:null}};async function h({video:e,apiClient:t,outputEncryptionSettings:r}){if(!e||!e.blob)return Promise.resolve(C);let a={label:"video"};if(r&&r.key){let i=new Blob([e.encrypted.hex]);return t.uploadFile({file:i,...a},{"X-TV-Key":r.key})}return t.uploadFile({file:e.blob,...a})}async function v({imageId:e,cardType:t,apiClient:r}){return r.requestVerifyIDCard({card_type:t,image1:{id:e}})}async function D({apiClient:e,cardType:t,frontCardId:r,isCapturingFrontSide:a,backCardId:i,recordedVideos:n=[],qrImageId:l,previousCapturingVideoId:s,previousFullVideoId:d,latestCapturingVideoId:o,latestFullVideoId:u}){let c=n.filter(e=>null!==e.id),p=n.filter(e=>null===e.id&&e.frames.length>0),g=await Promise.all(p.map(t=>e.fileService.request({frames:t.frames}))),f={card_type:t,image:{id:r},image2:a?void 0:{id:i},videos:[...[s,d,o,u].filter(e=>null!=e).map(e=>({id:e})),...c.map(e=>({id:e.id})),...g.map(e=>({id:e.data.file_id}))]};return l&&(f.qr1_images=[{id:l}]),e.detectIDTampering(f)}async function w({cardType:e,apiClient:t,cardImageId:r,qrImageId:a}){let i={card_type:e,image1:{id:r}};return a&&(i.qr1_images=[{id:a}]),t.readIDCard(i)}async function k({image:e,frontCardId:t,qrImageId:r,onError:a,recordedVideos:i,apiClient:n,cardType:l,cardSide:s,qrScannedResult:d,outputEncryptionSettings:o,enabledServices:u,fullVideo:c,capturingVideo:p,previousCapturingVideoId:g,previousFullVideoId:f}){let m=[b({image:e,cardType:l,cardSide:s,apiClient:n,outputEncryptionSettings:o})];m.push(_({image:d?.image,apiClient:n,rawString:d?.result,results:d?.results,outputEncryptionSettings:o})),m.push(h({video:c,apiClient:n,outputEncryptionSettings:o}),h({video:p,apiClient:n,outputEncryptionSettings:o}));let[S,C,k,E]=await Promise.all(m);if(S.errors)return void a({...I.upload_error,details:S.errors});let V=S.data.image_id,j=C?.data?.image_id||r,R={data:null};if(u?.enableVerifySanityIDCard){let e=await v({imageId:V,cardType:l,apiClient:n});if(e.errors)return void a({...I.sanity_check_error,details:e.errors});R.data=e.data}let B={data:null};if(u?.enableReadIDCardInfo){let e=await w({cardType:l,apiClient:n,cardImageId:V,qrImageId:j});if(e.errors)return void a({...I.read_id_card_error,details:e.errors});B.data=e.data}let F=k?.data?.file_id||null,T=E?.data?.file_id||null,K={data:null};if(u?.enableDetectIDCardTampering){let e,r;if(s===y.BACK&&!t)return void a(I.missing_front_id_card);let d=s===y.FRONT;d?e=V:(e=t,r=V);let o=await D({apiClient:n,cardType:l,frontCardId:e,isCapturingFrontSide:d,backCardId:r,recordedVideos:i,qrImageId:j,previousCapturingVideoId:g,previousFullVideoId:f,latestCapturingVideoId:T,latestFullVideoId:F});if(o.errors)return void a({...I.detect_id_tampering_error,details:o.errors});K.data=o.data}return{sanityResult:R.data,tamperingInfo:K.data,cardInfo:B.data,cardImageId:V,qrImageId:j,mp4VideoIds:{full:F,capturing:T}}}let{Errors:E}=e,V=({readIDCardUIOnlyComponent:c,...f})=>{let{onError:y,onStepDone:I,apiCredentials:b,logCredentials:S,outputEncryptionSettings:_,serviceSettings:C,flowId:h,clientSettings:v,...D}=f,[w,V]=t.useState(v),[j,R]=t.useState(!1),{apiClient:B}=r.useApiClient({apiCredentials:b,logCredentials:S}),F=t.useRef(""),T=t.useRef(""),K=t.useRef(null),U=t.useRef(null),q=a.getEnabledServices(C,w),{billingSettings:O,enableBilling:P}=i.useSDKSettings(),x=n.buildBillingInput(f),A=l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:W}=s({enable:P,onError:y,billingSettings:O??{json:A??{}},billingUrl:l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.url")}),$=t.useCallback(t=>{if(e.ErrorsWithoutBilling.includes(t.code))return void y(t);let r={error:t,sdkStatus:e.BillingStatus.fail};W({service:p(D.steps),input:x,output:r}),y&&y(t)},[W,D.steps,x,y]),G=t.useCallback((t,r)=>{if(r){let r={sdkStatus:e.BillingStatus.success,result:n.buildBillingOutput(t)},a={service:p(D.steps),input:x,output:r};if(Array.isArray(D.steps)&&1===D.steps.length&&D.steps[0].scannerType===g.QR_CODE){let{qrScannedResult:r={}}=t,i=r.result;if(i){let e=i.split("|")[0];a.id_num=d.SHA256(e),a.full_hash=d.SHA256(i)}else a.output={...a.output,sdkStatus:e.BillingStatus.cancel}}W(a)}I&&I(t)},[I,D.steps,x,W]);t.useEffect(()=>{async function e(){try{let e=await B.clientSettings({flow_id:h});V(e)}catch(e){console.error("Error fetching client settings:",e)}finally{R(!0)}}q.enableGetClientSettings&&e()},[B,q.enableGetClientSettings,h]);let N=t.useCallback(async(t,{shouldBilling:r})=>{let{cardType:a,cardSide:i,recordedVideos:n,qrScannedResult:l,image:s,fullVideo:d,capturingVideo:o}=t;try{if(!q.enableUploadImages||!s.blob)return void G(t,r);let u=null;(u=await k({image:s,cardSide:i,frontCardId:F.current,qrImageId:T.current,onError:$,apiClient:B,cardType:a,recordedVideos:n,qrScannedResult:l,outputEncryptionSettings:_,enabledServices:q,fullVideo:d,capturingVideo:o,previousCapturingVideoId:U.current,previousFullVideoId:K.current}))&&(i===e.IDCardSide.FRONT&&(F.current=u.cardImageId),U.current=u?.mp4VideoIds?.capturing,K.current=u?.mp4VideoIds?.full,T.current=u.qrImageId,G({...t,apiResult:u},r))}catch(e){$({...E.api_call_error,details:e})}},[B,q,$,G,_]);return q.enableGetClientSettings&&!j?null:o.jsx(u.LicenseProvider,{clientSettings:w,onError:y,children:o.jsx(m,{isWrappedBy:"id_with_api_call",children:o.jsx(c,{logCredentials:S,onError:y,onStepDone:N,outputEncryptionSettings:_,...D,clientSettings:w})})})};V.propTypes={onError:c.func,onStepDone:c.func,apiCredentials:c.shape({accessKey:c.string,secretKey:c.string,apiUrl:c.string}),logCredentials:c.shape({}),outputEncryptionSettings:c.shape({}),readIDCardUIOnlyComponent:c.func,serviceSettings:c.shape({}),flowId:c.string,clientSettings:c.shape({})},V.defaultProps={onError:()=>{},onStepDone:()=>{},apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},logCredentials:{enable:!1},outputEncryptionSettings:{key:""},readIDCardUIOnlyComponent:f,serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0},flowId:"",clientSettings:null};export{V as default};
|