local-id-scan-journey
Version:
A React component for GBG ID verification and document scanning with bundled SDK
3 lines • 3.87 kB
JavaScript
/*! For license information please see ides-micro.c7f56e19625c4d2863a9.js.LICENSE.txt */
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.GBG=r():(e.GBG=e.GBG||{},e.GBG.Idscan=r())}(this,(()=>(()=>{"use strict";var e={7461:(e,r)=>{var s;Object.defineProperty(r,"__esModule",{value:!0}),r.IdesMicroWorkerMessages=void 0,function(e){e.CheckComplete="CheckComplete",e.CheckFailed="CheckFailed",e.Initialise="Initialise",e.Terminate="Terminate",e.LoadingResources="LoadingResources",e.PerformQualityCheck="PerformQualityCheck",e.ReadyToProcess="ReadyToProcess",e.Error="Error"}(s||(r.IdesMicroWorkerMessages=s={}))}},r={};function s(o){var t=r[o];if(void 0!==t)return t.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,s),i.exports}var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.IdesMicroWorker=void 0;const r=s(7461);class t{constructor(e){this.postMessage=(e,r,s)=>new Promise((o=>o(this.workerGlobalContext.postMessage({id:e,message:r,data:s})))),this.onError=e=>this.postMessage("",r.IdesMicroWorkerMessages.Error,Object.assign({},e)),this.onMessage=({data:e})=>{switch(e.message){case r.IdesMicroWorkerMessages.PerformQualityCheck:return this.onPerformQualityCheck(e.id,e.data);case r.IdesMicroWorkerMessages.Terminate:return this.postMessage(e.id,r.IdesMicroWorkerMessages.Terminate).then((()=>this.workerGlobalContext.close()));case r.IdesMicroWorkerMessages.Initialise:return this.onInitialise(e.data.asmScriptUrl,e.data.timeout,e.data.timeLogsEnabled).then((()=>this.postMessage(e.id,r.IdesMicroWorkerMessages.ReadyToProcess))).catch((()=>this.postMessage(e.id,r.IdesMicroWorkerMessages.Error)))}},this.onInitialise=(e="./idesmicro_asm.js",r=6e4,s=!1)=>new Promise(((o,t)=>{performance.now();if(this.timeLogsEnabled=s,this.timeLogsEnabled,this.idesMicro){performance.now();return o()}{this.workerGlobalContext.importScripts(e);const s=setTimeout((()=>t()),r);return this.workerGlobalContext.Initidesmicro().then((e=>{clearTimeout(s),this.idesMicro=e,this.frameSelection=new this.idesMicro.frame_selection;performance.now();o()}))}})),this.onPerformQualityCheck=(e,{image:s})=>{performance.now();return this.checkQuality(s).then((s=>this.postMessage(e,r.IdesMicroWorkerMessages.CheckComplete,s))).then((()=>{performance.now();this.timeLogsEnabled})).catch((s=>this.postMessage(e,r.IdesMicroWorkerMessages.CheckFailed,s.message)))},this.checkQuality=e=>this.checkImageQuality(e).then((({glare:e,blur:r,low_res:s,out_of_frame:o,document:t,done:i})=>{performance.now();if(i){const e=this.frameSelection.get_best_frame(),r=new Uint8Array(this.idesMicro.HEAPU8.buffer,e.bufferPointerAddress,e.size),s=new Uint8Array(r);this.frameSelection.clear();var a=Promise.resolve({quality:{blurCheck:!0,glareCheck:!0,resolutionCheck:!0,coordinateCheck:!0},coords:[],image:s});performance.now();return this.timeLogsEnabled,a}var n=Promise.resolve({quality:{blurCheck:!r,glareCheck:!e,resolutionCheck:!s,coordinateCheck:!o&&t},coords:[]});performance.now();return this.timeLogsEnabled,n})),this.checkImageQuality=e=>new Promise((r=>{performance.now();const s=e.length|e.BYTES_PER_ELEMENT,o=this.idesMicro._malloc(s),t=new Uint8Array(this.idesMicro.HEAPU8.buffer,o,s);t.set(e);performance.now();const i=this.frameSelection.add_frame(t.byteOffset,e.length);performance.now();return this.timeLogsEnabled,this.idesMicro._free(o),void 0===i?r({glare:!1,blur:!1,low_res:!1,out_of_frame:!1,document:!1,done:!1}):(performance.now(),this.timeLogsEnabled,r(i))})),this.workerGlobalContext=e,this.workerGlobalContext.addEventListener("message",this.onMessage),this.workerGlobalContext.addEventListener("error",this.onError)}}e.IdesMicroWorker=t,e.default=new t(self)})(),o})()));
//# sourceMappingURL=ides-micro.c7f56e19625c4d2863a9.js.map