@authme/engine 2.4.2 → 2.4.6

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.
Binary file
Binary file
@@ -1 +1 @@
1
- 8.2.0
1
+ 8.6.0.1
package/index.cjs CHANGED
@@ -119,6 +119,17 @@ exports.EAuthMeIDCardAntiFraudStatus = void 0;
119
119
  EAuthMeIDCardAntiFraudStatus["NeedMoreFrame"] = "EAuthMeIDCardAntiFraudStatus_NeedMoreFrame";
120
120
  EAuthMeIDCardAntiFraudStatus["Pass"] = "EAuthMeIDCardAntiFraudStatus_Pass";
121
121
  EAuthMeIDCardAntiFraudStatus["Error"] = "EAuthMeIDCardAntiFraudStatus_Error";
122
+ EAuthMeIDCardAntiFraudStatus["Detect"] = "EAuthMeIDCardAntiFraudStatus_AntiFraudFeatureDetect";
123
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationLeft"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationLeft";
124
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationRight"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationRight";
125
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationUp"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationUp";
126
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationDown"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationDown";
127
+ EAuthMeIDCardAntiFraudStatus["CardCutByCamera"] = "EAuthMeIDCardAntiFraudStatus_CardCutByCamera";
128
+ EAuthMeIDCardAntiFraudStatus["CardNotInROI"] = "EAuthMeIDCardAntiFraudStatus_CardNotInROI";
129
+ EAuthMeIDCardAntiFraudStatus["CardTooSmall"] = "EAuthMeIDCardAntiFraudStatus_CardTooSmall";
130
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationFrontal"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationFrontal";
131
+ EAuthMeIDCardAntiFraudStatus["NeedHoldCard"] = "EAuthMeIDCardAntiFraudStatus_NeedHoldCard";
132
+ EAuthMeIDCardAntiFraudStatus["StagePass"] = "EAuthMeIDCardAntiFraudStatus_StagePass";
122
133
  })(exports.EAuthMeIDCardAntiFraudStatus || (exports.EAuthMeIDCardAntiFraudStatus = {}));
123
134
  exports.EAuthMeMRZRecogStatus = void 0;
124
135
  (function (EAuthMeMRZRecogStatus) {
@@ -232,7 +243,7 @@ const defaultMlEngineConfig = {
232
243
  };
233
244
 
234
245
  var name = "@authme/engine";
235
- var version$1 = "2.4.2";
246
+ var version$1 = "2.4.6";
236
247
  var peerDependencies = {
237
248
  "core-js": "^3.6.0",
238
249
  rxjs: "^7.4.0"
@@ -366,19 +377,23 @@ class MlEngine {
366
377
  constructor(config) {
367
378
  this.workerAndStreamPromise = undefined;
368
379
  this.preloadPromise = undefined;
380
+ this.debugTools = util.debugTools();
369
381
  this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
370
382
  isMobile: util.isMobile()
371
383
  });
372
384
  }
373
385
  _run(worker, workerMessage$, module, command, value = {}) {
374
386
  const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
387
+ const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
375
388
  worker.postMessage({
376
389
  module,
377
390
  command,
378
391
  id,
379
392
  value
380
393
  });
381
- 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
+ })));
382
397
  }
383
398
  _makeWorkerAndStreamAsync() {
384
399
  var _a;
@@ -463,7 +478,9 @@ class MlEngine {
463
478
  const simdSupported = isSimdSupported();
464
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`;
465
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');
466
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();
467
484
  return yield this._run(worker, workerMessage$, exports.EngineModule.Core, 'loadEngine', {
468
485
  engineJsContent,
469
486
  engineWasmContent
@@ -550,6 +567,9 @@ class AuthmeEngineModuleBase {
550
567
  getReport() {
551
568
  return this._engineRunAsync('getJsonReport');
552
569
  }
570
+ setOption(params) {
571
+ return this._engineRunAsync('setOption', params);
572
+ }
553
573
  recognition(data) {
554
574
  return __awaiter(this, void 0, void 0, function* () {
555
575
  // status control
@@ -653,6 +673,12 @@ class AuthmeEngineModuleBase {
653
673
  return true;
654
674
  });
655
675
  }
676
+ getUIParams() {
677
+ return this.engine.run(this.moduleName, 'getUIParams');
678
+ }
679
+ setUIParams(params) {
680
+ return this.engine.run(this.moduleName, 'setUIParams', params);
681
+ }
656
682
  static reset_MODEL_CACHE() {
657
683
  this._MODEL_CACHE = {};
658
684
  }
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
  /******************************************************************************
@@ -115,6 +115,17 @@ var EAuthMeIDCardAntiFraudStatus;
115
115
  EAuthMeIDCardAntiFraudStatus["NeedMoreFrame"] = "EAuthMeIDCardAntiFraudStatus_NeedMoreFrame";
116
116
  EAuthMeIDCardAntiFraudStatus["Pass"] = "EAuthMeIDCardAntiFraudStatus_Pass";
117
117
  EAuthMeIDCardAntiFraudStatus["Error"] = "EAuthMeIDCardAntiFraudStatus_Error";
118
+ EAuthMeIDCardAntiFraudStatus["Detect"] = "EAuthMeIDCardAntiFraudStatus_AntiFraudFeatureDetect";
119
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationLeft"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationLeft";
120
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationRight"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationRight";
121
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationUp"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationUp";
122
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationDown"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationDown";
123
+ EAuthMeIDCardAntiFraudStatus["CardCutByCamera"] = "EAuthMeIDCardAntiFraudStatus_CardCutByCamera";
124
+ EAuthMeIDCardAntiFraudStatus["CardNotInROI"] = "EAuthMeIDCardAntiFraudStatus_CardNotInROI";
125
+ EAuthMeIDCardAntiFraudStatus["CardTooSmall"] = "EAuthMeIDCardAntiFraudStatus_CardTooSmall";
126
+ EAuthMeIDCardAntiFraudStatus["NeedDeformationFrontal"] = "EAuthMeIDCardAntiFraudStatus_NeedDeformationFrontal";
127
+ EAuthMeIDCardAntiFraudStatus["NeedHoldCard"] = "EAuthMeIDCardAntiFraudStatus_NeedHoldCard";
128
+ EAuthMeIDCardAntiFraudStatus["StagePass"] = "EAuthMeIDCardAntiFraudStatus_StagePass";
118
129
  })(EAuthMeIDCardAntiFraudStatus || (EAuthMeIDCardAntiFraudStatus = {}));
119
130
  var EAuthMeMRZRecogStatus;
120
131
  (function (EAuthMeMRZRecogStatus) {
@@ -228,7 +239,7 @@ const defaultMlEngineConfig = {
228
239
  };
229
240
 
230
241
  var name = "@authme/engine";
231
- var version$1 = "2.4.2";
242
+ var version$1 = "2.4.6";
232
243
  var peerDependencies = {
233
244
  "core-js": "^3.6.0",
234
245
  rxjs: "^7.4.0"
@@ -362,19 +373,23 @@ class MlEngine {
362
373
  constructor(config) {
363
374
  this.workerAndStreamPromise = undefined;
364
375
  this.preloadPromise = undefined;
376
+ this.debugTools = debugTools();
365
377
  this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
366
378
  isMobile: isMobile()
367
379
  });
368
380
  }
369
381
  _run(worker, workerMessage$, module, command, value = {}) {
370
382
  const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
383
+ const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
371
384
  worker.postMessage({
372
385
  module,
373
386
  command,
374
387
  id,
375
388
  value
376
389
  });
377
- 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
+ })));
378
393
  }
379
394
  _makeWorkerAndStreamAsync() {
380
395
  var _a;
@@ -459,7 +474,9 @@ class MlEngine {
459
474
  const simdSupported = isSimdSupported();
460
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`;
461
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');
462
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();
463
480
  return yield this._run(worker, workerMessage$, EngineModule.Core, 'loadEngine', {
464
481
  engineJsContent,
465
482
  engineWasmContent
@@ -546,6 +563,9 @@ class AuthmeEngineModuleBase {
546
563
  getReport() {
547
564
  return this._engineRunAsync('getJsonReport');
548
565
  }
566
+ setOption(params) {
567
+ return this._engineRunAsync('setOption', params);
568
+ }
549
569
  recognition(data) {
550
570
  return __awaiter(this, void 0, void 0, function* () {
551
571
  // status control
@@ -649,6 +669,12 @@ class AuthmeEngineModuleBase {
649
669
  return true;
650
670
  });
651
671
  }
672
+ getUIParams() {
673
+ return this.engine.run(this.moduleName, 'getUIParams');
674
+ }
675
+ setUIParams(params) {
676
+ return this.engine.run(this.moduleName, 'setUIParams', params);
677
+ }
652
678
  static reset_MODEL_CACHE() {
653
679
  this._MODEL_CACHE = {};
654
680
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@authme/engine",
3
- "version": "2.4.2",
3
+ "version": "2.4.6",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "rxjs": "^7.4.0",
7
- "@authme/core": "2.4.2",
8
- "@authme/util": "2.4.2"
7
+ "@authme/core": "2.4.6",
8
+ "@authme/util": "2.4.6"
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>;
@@ -49,5 +54,7 @@ export declare abstract class AuthmeEngineModuleBase<T = any> {
49
54
  encryptBlob(uint8Array: ArrayBuffer, key: string): Promise<string>;
50
55
  _decryptString(str: string, key: string): Promise<string>;
51
56
  destroy(): Promise<boolean>;
57
+ getUIParams(): Promise<unknown>;
58
+ setUIParams(params: unknown): Promise<unknown>;
52
59
  static reset_MODEL_CACHE(): void;
53
60
  }
@@ -41,7 +41,18 @@ export declare enum EAuthMeIDCardAntiFraudStatus {
41
41
  PositionNotMatch = "EAuthMeIDCardAntiFraudStatus_PositionNotMatch",
42
42
  NeedMoreFrame = "EAuthMeIDCardAntiFraudStatus_NeedMoreFrame",
43
43
  Pass = "EAuthMeIDCardAntiFraudStatus_Pass",
44
- Error = "EAuthMeIDCardAntiFraudStatus_Error"
44
+ Error = "EAuthMeIDCardAntiFraudStatus_Error",
45
+ Detect = "EAuthMeIDCardAntiFraudStatus_AntiFraudFeatureDetect",
46
+ NeedDeformationLeft = "EAuthMeIDCardAntiFraudStatus_NeedDeformationLeft",
47
+ NeedDeformationRight = "EAuthMeIDCardAntiFraudStatus_NeedDeformationRight",
48
+ NeedDeformationUp = "EAuthMeIDCardAntiFraudStatus_NeedDeformationUp",
49
+ NeedDeformationDown = "EAuthMeIDCardAntiFraudStatus_NeedDeformationDown",
50
+ CardCutByCamera = "EAuthMeIDCardAntiFraudStatus_CardCutByCamera",
51
+ CardNotInROI = "EAuthMeIDCardAntiFraudStatus_CardNotInROI",
52
+ CardTooSmall = "EAuthMeIDCardAntiFraudStatus_CardTooSmall",
53
+ NeedDeformationFrontal = "EAuthMeIDCardAntiFraudStatus_NeedDeformationFrontal",
54
+ NeedHoldCard = "EAuthMeIDCardAntiFraudStatus_NeedHoldCard",
55
+ StagePass = "EAuthMeIDCardAntiFraudStatus_StagePass"
45
56
  }
46
57
  export declare enum EAuthMeMRZRecogStatus {
47
58
  Success = "EAuthMeMRZRecogStatus_Success",
@@ -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';