@authme/engine 2.4.4-rc.7 → 2.4.5

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.
@@ -1 +1 @@
1
- !function(){let r=!1,a=!1;const t={get TD1(){return self.EngineLib.EAuthMeMRZType.TD1},get TD3(){return self.EngineLib.EAuthMeMRZType.TD3}};function i(e){return{MRZService:"MRZService",MRZResidentCardService:"MRZService",MRZPassportService:"MRZService"}[e]||e}async function n({engineJsContent:n,engineWasmContent:i}){return new Promise(function(s,e){var t;r||a?s(!0):(a=!0,self.Module={},self.Module={locateFile:(e,t)=>t+"/"+e,print:e=>{postMessage({module:"DEBUG",command:"DEBUG",id:null,value:e})}},t=URL.createObjectURL(new Blob([n],{type:"text/javascript"})),importScripts(t),URL.revokeObjectURL(t),async function t(){try{const e=await AuthmeMLEngineLib({wasmBinary:i,print:e=>{console.log(e),postMessage({module:"DEBUG",command:"DEBUG",id:null,value:e})}});(self.EngineLib=e).FS.mkdir("/model"),r=!0,a=!1,s(!0)}catch(e){console.warn("init Authme EngineLib error:",e," Try after 3 second."),n=3e3,await new Promise(e=>{setTimeout(()=>{e(!0)},n)}),await t()}var n}())})}const o={MRZService:e=>self.EngineLib.MRZService.getModelVersion(t.TD3),MRZResidentCardService:e=>self.EngineLib.MRZService.getModelVersion(t.TD1),MRZPassportService:e=>self.EngineLib.MRZService.getModelVersion(t.TD3),default:e=>self.EngineLib[i(e)].getModelVersion()},e={_getLoadedModelKey({modelVersion:{name:e,version:t}}){return e+"#"+t},_getModelVersions(e){const t=o[e]||o.default,n=t(e),s=[];for(let r=0;r<n.size();r++){var i=n.get(r);s.push({name:""+i.szName,version:""+i.szVersion})}return s},_getNoLoadedModelVersions(e){const t=this._getModelVersions(e);return t.filter(e=>!this._loadedSessions[this._getLoadedModelKey({modelVersion:e})])},loadSession({modelVersion:{name:e,version:t},modelArrayBuffer:n}){let s=!1;try{const r=self.EngineLib.FS;r.mkdir(`/${e}-${t}/`),r.mount(r.filesystems.WORKERFS,{blobs:[{name:e+"-"+t,data:new Blob([n],{type:"application/octet-stream"})}]},`/${e}-${t}/`),s=!0}catch(e){if(20!==e?.errno)throw e;s=!0}if(s){var i=this._getLoadedModelKey({modelVersion:{name:e,version:t}});if(this._loadedSessions[i])throw new Error("should be undefined here.");this._loadedSessions[i]=self.EngineLib.createInferenceSession(e,`/${e}-${t}/${e}-`+t)}},async _init(e){{const t=new self.EngineLib[i(e)];if("EAuthMeEngineReturnCode_eAuthMe_Engine_Failed"==(await t.initial(...this._getModelVersions(e).map(e=>this._loadedSessions[this._getLoadedModelKey({modelVersion:e})]))).constructor.name)return console.error("model loading error,please ask server to check the model"),!1;const n=t,s=n.getUIParams();return s.previewPosition.fLeft=0,s.previewPosition.fTop=0,s.previewPosition.fRight=1,s.previewPosition.fBottom=1,n.setUIParams(s),this.instance=t,!0}},start(){return this.instance?.start()},stop(){return this.instance?.stop()},setPublicKeyForJson(e){return self.EngineLib.setPublicKeyForJson(e)},_setFrameSize(e){if(c.frame.width=Math.floor(e.width),c.frame.height=Math.floor(e.height),this.instance){const t=this.instance,n=t.getUIParams();return n.analyzeSize.iHeight=c.frame.height,n.analyzeSize.iWidth=c.frame.width,t.setUIParams(n),!0}},setFrameSize(e){return this._setFrameSize(e)},_recognition(e){const t=this.instance;if(t)try{var n=l(e.data),s=t.run(n.byteOffset,n.length,c.frame.width,c.frame.height);return self.EngineLib._free(n.dataPtr),s}catch(e){return null}console.warn("engine not initialized")},recognition(e){return this._recognition(e)},getParams(){return this.instance.getParams()},getUIParams(){return this.instance.getUIParams()},setParams(e){return this.instance.setParams(e.params)},setUIParams(e){return this.instance.setUIParams(e)},getDebugImage(e){var t=l(e.data);let n;var s=this.instance.getDebugImage(t.byteOffset,t.length,c.frame.width,c.frame.height);return self.EngineLib._free(t.dataPtr),s&&(n=self.EngineLib.HEAPU8.slice(s,s+c.frame.width*c.frame.height*4),self.EngineLib._free(s)),n},destroy(){this.instance&&(this.instance.delete(),this.instance=null);for(const e of Object.values(this._loadedSessions))self.EngineLib.deleteSession(e);this._loadedSessions={}},getJsonReport(){return this.instance?.getJsonReport()},encryptString({string:e,key:t}){return self.EngineLib.encryptString(e,t)},encryptBlob({uint8Array:e,key:t}){const n=new self.EngineLib.VectorUChar;for(let s=0;s<e.length;s++)n.push_back(e[s]);return self.EngineLib.encryptBlob(n,t)},_decryptString({string:e,key:t}){return self.EngineLib.decryptString(e,t)}};function s(n){return{instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions(n)},init(){return this._init(n)},toJson(e){return Object.getPrototypeOf(this.instance).constructor.toJson(e)},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.tField=JSON.parse(self[n].toJson(t.tField)),0<t.pointer&&(t.imageData=self.EngineLib.HEAPU8.slice(t.pointer,t.pointer+t.iHeight*t.iWidth*4),self.EngineLib._free(t.pointer))),t},setMaskPosition(e){var t=e.positions;return self[n].instance?.setMatchROI(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])},getFinalResult(){return this.instance.getFinalResult()}}}self.MRZPassportService=s("MRZPassportService"),self.MRZResidentCardService=s("MRZResidentCardService"),self.CardOCR={instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("CardOCR")},init(){return this._init("CardOCR")},recognition(e){const t=this._recognition(e);return t&&(0<t.pointer&&(t.imageData=self.EngineLib.HEAPU8.slice(t.pointer,t.pointer+t.iHeight*t.iWidth*4),self.EngineLib._free(t.pointer)),t.eStatus=t.eStatus.constructor.name,t.info.cardClass.eClass=t.info.cardClass.eClass.constructor.name),t},setType({type:e,options:t}){const n=this.instance;var s=t||{};if(n){const i=n.getParams();return i.eTargetCardType=self.EngineLib.EAuthMeCardClass[e.replace(/^EAuthMeCardClass_/,"")],i.fImageBlurTh=750,n.setParams({...i,...s}),!0}return!1},setMaskPosition(e){var t=e.positions;return this.instance?.setCardMatchROI(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])}},self.IdCardAntiFraud={instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("IdCardAntiFraudService")},async init(){if(await this._init("IdCardAntiFraudService"),this.instance){const e=this.instance,t=e.getParams();return t.timeoutSec=52,e.setParams(t),!0}},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.eStage=t.eStage.constructor.name,t.info.eCardMatchStatus=t.info.eCardMatchStatus.constructor.name,t.info.cardClass.eClass=t.info.cardClass.eClass.constructor.name,t.info.metalTag.aeStatus=t.info.metalTag.aeStatus.map(e=>e.constructor.name)),t},setMaskPosition(e){var t=e.positions;return this.instance?.setFrontalCardVertices(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])},setStage(e){if(this.instance){const t=new self.EngineLib.FraudStageList;for(const n of e)t.push_back(self.EngineLib.EAuthMeIDCardAntiFraudStage[n]);this.instance.setStage(t)}},getCardMatchROI(){if(!this.instance)throw new Error("instance not initialized");const e=[],t=this.instance.getCardMatchROI();for(let s=0;s<t.size();s++){var n=t.get(s);e.push(n)}return e}},self.Fas={instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("CFASService")},init(){return this._init("CFASService")},setFrameSize(e){if(this._setFrameSize(e),1<=c.frame.width/c.frame.height){const e=this.instance.getParams();e.fFaceRoiPreviewRatioW=.3,this.instance.setParams(e)}},setStage(e){if(this.instance){const t=new self.EngineLib.FASStageList;for(const n of e.stageList)t.push_back(self.EngineLib.EAuthMeFASServiceStage[n]);this.instance.setStage(t)}},getStageParams({stageIndex:e}){return this.instance.getStageParams(e)},setStageParams({stageIndex:e,value:t}){this.instance.setStageParams(t,e)},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.eStage=t.eStage.constructor.name,t.info.eye.eStatus=t.info.eye.eStatus.constructor.name,t.info.fas.eStatus=t.info.fas.eStatus.constructor.name,t.info.mouth.eStatus=t.info.mouth.eStatus.constructor.name,t.info.pose.ePose=t.info.pose.ePose.constructor.name,t.info.miniFAS=t.info.miniFAS.constructor.name),t},async getNormalizedFaceROI(){var e=await this.instance.getNormalizedFaceROI();return{height:e.height,width:e.width,x:e.x,y:e.y}}},self.Core={async setConfig(e){return self.config={...self.config,...e},!0},async loadEngine({engineJsContent:e,engineWasmContent:t}){return n({engineJsContent:e,engineWasmContent:t})},async verify(e){for(let t=0;t<20;t++)if(self.EngineLib)return self.EngineLib.verifySDK(e.cert,e.authToken).constructor.name;return!1},checkEnumConsistency(e){const t=[];for(var[n,s]of Object.entries(e)){var i,r,a=self.EngineLib[n]?.values??{},o=Object.fromEntries(Object.values(a).map(e=>[e.constructor.name,e.value]));for([i,r]of Object.entries(s))void 0===o[r]&&t.push({enumName:n,key:i,engineKey:r,actualEnumMap:o})}return t}},addEventListener("message",(async function({data:t}){try{var e,{module:n,command:s,id:i,value:r}=t;const a=self[n][s];a&&(e=await a.call(self[n],r),postMessage({module:n,command:s,id:i,value:e}))}catch(e){var{module:r,command:n,id:s}=t;throw postMessage({module:r,command:n,id:s,value:{error:!0,cause:JSON.parse(JSON.stringify(e))}}),e}}).bind(self));let c={scriptPath:"assets",apiBaseUrl:"/",frame:{width:0,height:0}};function l(e){const t=self.EngineLib;var n=new Uint8Array(e),s=n.length*n.BYTES_PER_ELEMENT,i=t._malloc(s);const r=new Uint8Array(t.HEAPU8.buffer,i,s);return r.set(n),{byteOffset:r.byteOffset,length:n.length,dataPtr:i,dataOnHeap:r,Module:t}}}();
1
+ !function(){let r=!1,a=!1;const t={get TD1(){return self.EngineLib.EAuthMeMRZType.TD1},get TD3(){return self.EngineLib.EAuthMeMRZType.TD3}};function i(e){return{MRZService:"MRZService",MRZResidentCardService:"MRZService",MRZPassportService:"MRZService"}[e]||e}async function n({engineJsContent:n,engineWasmContent:i}){return new Promise(function(s,e){var t;r||a?s(!0):(a=!0,self.Module={},self.Module={locateFile:(e,t)=>t+"/"+e,print:e=>{postMessage({module:"DEBUG",command:"DEBUG",id:null,value:e})}},t=URL.createObjectURL(new Blob([n],{type:"text/javascript"})),importScripts(t),URL.revokeObjectURL(t),async function t(){try{const e=await AuthmeMLEngineLib({wasmBinary:i,print:e=>{console.log(e),postMessage({module:"DEBUG",command:"DEBUG",id:null,value:e})}});(self.EngineLib=e).FS.mkdir("/model"),r=!0,a=!1,s(!0)}catch(e){console.warn("init Authme EngineLib error:",e," Try after 3 second."),n=3e3,await new Promise(e=>{setTimeout(()=>{e(!0)},n)}),await t()}var n}())})}const o={MRZService:e=>self.EngineLib.MRZService.getModelVersion(t.TD3),MRZResidentCardService:e=>self.EngineLib.MRZService.getModelVersion(t.TD1),MRZPassportService:e=>self.EngineLib.MRZService.getModelVersion(t.TD3),default:e=>self.EngineLib[i(e)].getModelVersion()},e={async setOption({key:e,value:t}){return this.instance?.setOption(e,t)},_getLoadedModelKey({modelVersion:{name:e,version:t}}){return e+"#"+t},_getModelVersions(e){const t=o[e]||o.default,n=t(e),s=[];for(let r=0;r<n.size();r++){var i=n.get(r);s.push({name:""+i.szName,version:""+i.szVersion})}return s},_getNoLoadedModelVersions(e){const t=this._getModelVersions(e);return t.filter(e=>!this._loadedSessions[this._getLoadedModelKey({modelVersion:e})])},loadSession({modelVersion:{name:e,version:t},modelArrayBuffer:n}){let s=!1;try{const r=self.EngineLib.FS;r.mkdir(`/${e}-${t}/`),r.mount(r.filesystems.WORKERFS,{blobs:[{name:e+"-"+t,data:new Blob([n],{type:"application/octet-stream"})}]},`/${e}-${t}/`),s=!0}catch(e){if(20!==e?.errno)throw e;s=!0}if(s){var i=this._getLoadedModelKey({modelVersion:{name:e,version:t}});if(this._loadedSessions[i])throw new Error("should be undefined here.");this._loadedSessions[i]=self.EngineLib.createInferenceSession(e,`/${e}-${t}/${e}-`+t)}},async _init(e){{const t=new self.EngineLib[i(e)];if("EAuthMeEngineReturnCode_eAuthMe_Engine_Failed"==(await t.initial(...this._getModelVersions(e).map(e=>this._loadedSessions[this._getLoadedModelKey({modelVersion:e})]))).constructor.name)return console.error("model loading error,please ask server to check the model"),!1;const n=t,s=n.getUIParams();return s.previewPosition.fLeft=0,s.previewPosition.fTop=0,s.previewPosition.fRight=1,s.previewPosition.fBottom=1,n.setUIParams(s),this.instance=t,!0}},start(){return this.instance?.start()},stop(){return this.instance?.stop()},setPublicKeyForJson(e){return self.EngineLib.setPublicKeyForJson(e)},_setFrameSize(e){if(c.frame.width=Math.floor(e.width),c.frame.height=Math.floor(e.height),this.instance){const t=this.instance,n=t.getUIParams();return n.analyzeSize.iHeight=c.frame.height,n.analyzeSize.iWidth=c.frame.width,t.setUIParams(n),!0}},setFrameSize(e){return this._setFrameSize(e)},_recognition(e){const t=this.instance;if(t)try{var n=l(e.data),s=t.run(n.byteOffset,n.length,c.frame.width,c.frame.height);return self.EngineLib._free(n.dataPtr),s}catch(e){return null}console.warn("engine not initialized")},recognition(e){return this._recognition(e)},getParams(){return this.instance.getParams()},getUIParams(){return this.instance.getUIParams()},setParams(e){return this.instance.setParams(e.params)},setUIParams(e){return this.instance.setUIParams(e)},getDebugImage(e){var t=l(e.data);let n;var s=this.instance.getDebugImage(t.byteOffset,t.length,c.frame.width,c.frame.height);return self.EngineLib._free(t.dataPtr),s&&(n=self.EngineLib.HEAPU8.slice(s,s+c.frame.width*c.frame.height*4),self.EngineLib._free(s)),n},destroy(){this.instance&&(this.instance.delete(),this.instance=null);for(const e of Object.values(this._loadedSessions))self.EngineLib.deleteSession(e);this._loadedSessions={}},getJsonReport(){return this.instance?.getJsonReport()},encryptString({string:e,key:t}){return self.EngineLib.encryptString(e,t)},encryptBlob({uint8Array:e,key:t}){const n=new self.EngineLib.VectorUChar;for(let s=0;s<e.length;s++)n.push_back(e[s]);return self.EngineLib.encryptBlob(n,t)},_decryptString({string:e,key:t}){return self.EngineLib.decryptString(e,t)}};function s(n){return{instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions(n)},init(){return this._init(n)},toJson(e){return Object.getPrototypeOf(this.instance).constructor.toJson(e)},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.tField=JSON.parse(self[n].toJson(t.tField)),0<t.pointer&&(t.imageData=self.EngineLib.HEAPU8.slice(t.pointer,t.pointer+t.iHeight*t.iWidth*4),self.EngineLib._free(t.pointer))),t},setMaskPosition(e){var t=e.positions;return self[n].instance?.setMatchROI(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])},getFinalResult(){return this.instance.getFinalResult()}}}self.MRZPassportService=s("MRZPassportService"),self.MRZResidentCardService=s("MRZResidentCardService"),self.CardOCR={instance:null,_loadedSessions:{},...e,setParams(e){return this.instance.setParams({...e,eTargetCardType:self.EngineLib.EAuthMeCardClass[e.type.replace(/^EAuthMeCardClass_/,"")]})},getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("CardOCR")},init(){return this._init("CardOCR")},recognition(e){const t=this._recognition(e);return t&&(0<t.pointer&&(t.imageData=self.EngineLib.HEAPU8.slice(t.pointer,t.pointer+t.iHeight*t.iWidth*4),self.EngineLib._free(t.pointer)),t.eStatus=t.eStatus.constructor.name,t.info.cardClass.eClass=t.info.cardClass.eClass.constructor.name),t},setType({type:t}){const n=this.instance;if(n){let e=n.getParams();return e.eTargetCardType=self.EngineLib.EAuthMeCardClass[t.replace(/^EAuthMeCardClass_/,"")],n.setParams({...e}),!0}return!1},setMaskPosition(e){var t=e.positions;return this.instance?.setCardMatchROI(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])}},self.IdCardAntiFraud={instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("IdCardAntiFraudService")},async init(){if(await this._init("IdCardAntiFraudService"),this.instance){const e=this.instance,t=e.getParams();return t.timeoutSec=52,e.setParams(t),!0}},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.eStage=t.eStage.constructor.name,t.info.eCardMatchStatus=t.info.eCardMatchStatus.constructor.name,t.info.cardClass.eClass=t.info.cardClass.eClass.constructor.name,t.info.metalTag.aeStatus=t.info.metalTag.aeStatus.map(e=>e.constructor.name)),t},setMaskPosition(e){var t=e.positions;return this.instance?.setFrontalCardVertices(t[0][0],t[0][1],t[1][0],t[1][1],t[2][0],t[2][1],t[3][0],t[3][1])},setStage(e){if(this.instance){const t=new self.EngineLib.FraudStageList;for(const n of e)t.push_back(self.EngineLib.EAuthMeIDCardAntiFraudStage[n]);this.instance.setStage(t)}},getCardMatchROI(){if(!this.instance)throw new Error("instance not initialized");const e=[],t=this.instance.getCardMatchROI();for(let s=0;s<t.size();s++){var n=t.get(s);e.push(n)}return e}},self.Fas={instance:null,_loadedSessions:{},...e,getNoLoadedModelVersions(){return this._getNoLoadedModelVersions("CFASService")},init(){return this._init("CFASService")},setFrameSize(e){if(this._setFrameSize(e),1<=c.frame.width/c.frame.height){const e=this.instance.getParams();e.fFaceRoiPreviewRatioW=.3,this.instance.setParams(e)}},setStage(e){if(this.instance){const t=new self.EngineLib.FASStageList;for(const n of e.stageList)t.push_back(self.EngineLib.EAuthMeFASServiceStage[n]);this.instance.setStage(t)}},getStageParams({stageIndex:e}){return this.instance.getStageParams(e)},setStageParams({stageIndex:e,value:t}){this.instance.setStageParams(t,e)},recognition(e){const t=this._recognition(e);return t&&(t.eStatus=t.eStatus.constructor.name,t.eStage=t.eStage.constructor.name,t.info.eye.eStatus=t.info.eye.eStatus.constructor.name,t.info.fas.eStatus=t.info.fas.eStatus.constructor.name,t.info.mouth.eStatus=t.info.mouth.eStatus.constructor.name,t.info.pose.ePose=t.info.pose.ePose.constructor.name,t.info.miniFAS=t.info.miniFAS.constructor.name),t},async getNormalizedFaceROI(){var e=await this.instance.getNormalizedFaceROI();return{height:e.height,width:e.width,x:e.x,y:e.y}}},self.Core={async setConfig(e){return self.config={...self.config,...e},!0},async loadEngine({engineJsContent:e,engineWasmContent:t}){return n({engineJsContent:e,engineWasmContent:t})},async verify(e){for(let t=0;t<20;t++)if(self.EngineLib)return self.EngineLib.verifySDK(e.cert,e.authToken).constructor.name;return!1},checkEnumConsistency(e){const t=[];for(var[n,s]of Object.entries(e)){var i,r,a=self.EngineLib[n]?.values??{},o=Object.fromEntries(Object.values(a).map(e=>[e.constructor.name,e.value]));for([i,r]of Object.entries(s))void 0===o[r]&&t.push({enumName:n,key:i,engineKey:r,actualEnumMap:o})}return t}},addEventListener("message",(async function({data:t}){try{var e,{module:n,command:s,id:i,value:r}=t;const a=self[n][s];a&&(e=await a.call(self[n],r),postMessage({module:n,command:s,id:i,value:e}))}catch(e){var{module:r,command:n,id:s}=t;throw postMessage({module:r,command:n,id:s,value:{error:!0,cause:JSON.parse(JSON.stringify(e))}}),e}}).bind(self));let c={scriptPath:"assets",apiBaseUrl:"/",frame:{width:0,height:0}};function l(e){const t=self.EngineLib;var n=new Uint8Array(e),s=n.length*n.BYTES_PER_ELEMENT,i=t._malloc(s);const r=new Uint8Array(t.HEAPU8.buffer,i,s);return r.set(n),{byteOffset:r.byteOffset,length:n.length,dataPtr:i,dataOnHeap:r,Module:t}}}();
Binary file
Binary file
@@ -1 +1 @@
1
- 8.6.0
1
+ 8.6.0.1
package/index.cjs CHANGED
@@ -243,7 +243,7 @@ const defaultMlEngineConfig = {
243
243
  };
244
244
 
245
245
  var name = "@authme/engine";
246
- var version$1 = "2.4.4-rc.7";
246
+ var version$1 = "2.4.5";
247
247
  var peerDependencies = {
248
248
  "core-js": "^3.6.0",
249
249
  rxjs: "^7.4.0"
@@ -377,19 +377,23 @@ class MlEngine {
377
377
  constructor(config) {
378
378
  this.workerAndStreamPromise = undefined;
379
379
  this.preloadPromise = undefined;
380
+ this.debugTools = util.debugTools();
380
381
  this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
381
382
  isMobile: util.isMobile()
382
383
  });
383
384
  }
384
385
  _run(worker, workerMessage$, module, command, value = {}) {
385
386
  const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
387
+ const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
386
388
  worker.postMessage({
387
389
  module,
388
390
  command,
389
391
  id,
390
392
  value
391
393
  });
392
- return rxjs.firstValueFrom(workerMessage$.pipe(rxjs.filter(x => x.id === id), rxjs.map(x => x.value)));
394
+ return rxjs.firstValueFrom(workerMessage$.pipe(rxjs.filter(x => x.id === id), rxjs.map(x => x.value), rxjs.tap(() => {
395
+ durationTimeWorker.end();
396
+ })));
393
397
  }
394
398
  _makeWorkerAndStreamAsync() {
395
399
  var _a;
@@ -474,7 +478,9 @@ class MlEngine {
474
478
  const simdSupported = isSimdSupported();
475
479
  const jsUrl = simdSupported ? `${(_a = this.config.scriptPath) !== null && _a !== void 0 ? _a : ''}ml_engine_web.simd.js` : `${(_b = this.config.scriptPath) !== null && _b !== void 0 ? _b : ''}ml_engine_web.js`;
476
480
  const wasmUrl = simdSupported ? `${(_c = this.config.scriptPath) !== null && _c !== void 0 ? _c : ''}ml_engine_web.simd.wasm` : `${(_d = this.config.scriptPath) !== null && _d !== void 0 ? _d : ''}ml_engine_web.wasm`;
481
+ const durationTimeNetworkEngine = this.debugTools.setTimeDuration('loadEngine_network');
477
482
  const [engineJsContent, engineWasmContent] = yield (_e = MlEngine._ENGINE_CACHE) !== null && _e !== void 0 ? _e : MlEngine._ENGINE_CACHE = Promise.all([getJsContentAsync(`${jsUrl}?t=${Date.now()}`), getWasmContentAsync(`${wasmUrl}?t=${Date.now()}`)]);
483
+ durationTimeNetworkEngine.end();
478
484
  return yield this._run(worker, workerMessage$, exports.EngineModule.Core, 'loadEngine', {
479
485
  engineJsContent,
480
486
  engineWasmContent
@@ -561,6 +567,9 @@ class AuthmeEngineModuleBase {
561
567
  getReport() {
562
568
  return this._engineRunAsync('getJsonReport');
563
569
  }
570
+ setOption(params) {
571
+ return this._engineRunAsync('setOption', params);
572
+ }
564
573
  recognition(data) {
565
574
  return __awaiter(this, void 0, void 0, function* () {
566
575
  // status control
package/index.js CHANGED
@@ -16,8 +16,8 @@ import 'core-js/modules/es.object.assign.js';
16
16
  import 'core-js/modules/es.regexp.to-string.js';
17
17
  import 'core-js/modules/es.array.sort.js';
18
18
  import { AuthmeError, ErrorCode, sendRequest } from '@authme/core';
19
- import { isMobile, Storage } from '@authme/util';
20
- import { firstValueFrom, filter, map, fromEvent, shareReplay, from, mergeAll, concatMap, of, reduce, defer, concatAll, mergeMap } from 'rxjs';
19
+ import { debugTools, isMobile, Storage } from '@authme/util';
20
+ import { firstValueFrom, filter, map, tap, fromEvent, shareReplay, from, mergeAll, concatMap, of, reduce, defer, concatAll, mergeMap } from 'rxjs';
21
21
  import 'core-js/modules/es.symbol.description.js';
22
22
 
23
23
  /******************************************************************************
@@ -239,7 +239,7 @@ const defaultMlEngineConfig = {
239
239
  };
240
240
 
241
241
  var name = "@authme/engine";
242
- var version$1 = "2.4.4-rc.7";
242
+ var version$1 = "2.4.5";
243
243
  var peerDependencies = {
244
244
  "core-js": "^3.6.0",
245
245
  rxjs: "^7.4.0"
@@ -373,19 +373,23 @@ class MlEngine {
373
373
  constructor(config) {
374
374
  this.workerAndStreamPromise = undefined;
375
375
  this.preloadPromise = undefined;
376
+ this.debugTools = debugTools();
376
377
  this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
377
378
  isMobile: isMobile()
378
379
  });
379
380
  }
380
381
  _run(worker, workerMessage$, module, command, value = {}) {
381
382
  const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
383
+ const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
382
384
  worker.postMessage({
383
385
  module,
384
386
  command,
385
387
  id,
386
388
  value
387
389
  });
388
- return firstValueFrom(workerMessage$.pipe(filter(x => x.id === id), map(x => x.value)));
390
+ return firstValueFrom(workerMessage$.pipe(filter(x => x.id === id), map(x => x.value), tap(() => {
391
+ durationTimeWorker.end();
392
+ })));
389
393
  }
390
394
  _makeWorkerAndStreamAsync() {
391
395
  var _a;
@@ -470,7 +474,9 @@ class MlEngine {
470
474
  const simdSupported = isSimdSupported();
471
475
  const jsUrl = simdSupported ? `${(_a = this.config.scriptPath) !== null && _a !== void 0 ? _a : ''}ml_engine_web.simd.js` : `${(_b = this.config.scriptPath) !== null && _b !== void 0 ? _b : ''}ml_engine_web.js`;
472
476
  const wasmUrl = simdSupported ? `${(_c = this.config.scriptPath) !== null && _c !== void 0 ? _c : ''}ml_engine_web.simd.wasm` : `${(_d = this.config.scriptPath) !== null && _d !== void 0 ? _d : ''}ml_engine_web.wasm`;
477
+ const durationTimeNetworkEngine = this.debugTools.setTimeDuration('loadEngine_network');
473
478
  const [engineJsContent, engineWasmContent] = yield (_e = MlEngine._ENGINE_CACHE) !== null && _e !== void 0 ? _e : MlEngine._ENGINE_CACHE = Promise.all([getJsContentAsync(`${jsUrl}?t=${Date.now()}`), getWasmContentAsync(`${wasmUrl}?t=${Date.now()}`)]);
479
+ durationTimeNetworkEngine.end();
474
480
  return yield this._run(worker, workerMessage$, EngineModule.Core, 'loadEngine', {
475
481
  engineJsContent,
476
482
  engineWasmContent
@@ -557,6 +563,9 @@ class AuthmeEngineModuleBase {
557
563
  getReport() {
558
564
  return this._engineRunAsync('getJsonReport');
559
565
  }
566
+ setOption(params) {
567
+ return this._engineRunAsync('setOption', params);
568
+ }
560
569
  recognition(data) {
561
570
  return __awaiter(this, void 0, void 0, function* () {
562
571
  // status control
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@authme/engine",
3
- "version": "2.4.4-rc.7",
3
+ "version": "2.4.5",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "rxjs": "^7.4.0",
7
- "@authme/core": "2.4.4-rc.7",
8
- "@authme/util": "2.4.4-rc.7"
7
+ "@authme/core": "2.4.5",
8
+ "@authme/util": "2.4.5"
9
9
  },
10
10
  "module": "./index.js",
11
11
  "main": "./index.cjs",
@@ -10,6 +10,7 @@ export declare class MlEngine {
10
10
  private workerAndStreamPromise;
11
11
  private preloadPromise;
12
12
  constructor(config: MlEngineConfig);
13
+ private debugTools;
13
14
  private _run;
14
15
  private _makeWorkerAndStreamAsync;
15
16
  private _backgroundPreloadAsync;
@@ -39,6 +40,10 @@ export declare abstract class AuthmeEngineModuleBase<T = any> {
39
40
  startSession(): Promise<void>;
40
41
  stop(): Promise<void>;
41
42
  getReport(): Promise<string>;
43
+ setOption(params: {
44
+ key: string;
45
+ value: string;
46
+ }): Promise<void>;
42
47
  recognition(data: Uint8Array | Uint8ClampedArray): Promise<T & EngineDebugInfo>;
43
48
  getDebugImageData(data: Uint8Array | Uint8ClampedArray): Promise<Uint8Array>;
44
49
  setFrameSize(width: number, height: number): Promise<boolean>;
@@ -1,5 +1,5 @@
1
1
  export interface MlEngineConfig {
2
- token?: string;
2
+ token: string;
3
3
  scriptPath?: string;
4
4
  apiBaseUrl?: string;
5
5
  dataTransferMethod?: 'binary' | 'base64';