@authme/engine 2.3.1-rc.3 → 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.
- package/assets/engine-worker.js +1 -1
- package/assets/ml_engine_web.js +2 -2
- package/assets/ml_engine_web.simd.js +2 -2
- package/assets/ml_engine_web.simd.wasm +0 -0
- package/assets/ml_engine_web.wasm +0 -0
- package/assets/ml_engine_web_version.txt +1 -1
- package/index.cjs +74 -14
- package/index.js +77 -17
- package/package.json +3 -3
- package/src/lib/engine.d.ts +10 -0
- package/src/lib/enum/id-recognition.enum.d.ts +20 -8
- package/src/lib/enum/module.enum.d.ts +3 -2
- package/src/lib/interface/config.interface.d.ts +3 -1
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8.6.0.1
|
package/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
require('core-js/modules/es.array.iterator.js');
|
|
6
6
|
require('core-js/modules/es.object.from-entries.js');
|
|
7
|
+
require('core-js/modules/es.regexp.exec.js');
|
|
7
8
|
require('core-js/modules/es.array-buffer.slice.js');
|
|
8
9
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
|
9
10
|
require('core-js/modules/es.typed-array.fill.js');
|
|
@@ -53,9 +54,10 @@ exports.EngineModule = void 0;
|
|
|
53
54
|
EngineModule["Fas"] = "Fas";
|
|
54
55
|
EngineModule["IdCardAntiFraud"] = "IdCardAntiFraud";
|
|
55
56
|
EngineModule["CardOCR"] = "CardOCR";
|
|
56
|
-
EngineModule["PassportService"] = "PassportService";
|
|
57
57
|
EngineModule["DEBUG"] = "DEBUG";
|
|
58
58
|
EngineModule["Core"] = "Core";
|
|
59
|
+
EngineModule["MRZPassportService"] = "MRZPassportService";
|
|
60
|
+
EngineModule["MRZResidentCardService"] = "MRZResidentCardService";
|
|
59
61
|
})(exports.EngineModule || (exports.EngineModule = {}));
|
|
60
62
|
|
|
61
63
|
exports.EAuthMeEngineReturnCode = void 0;
|
|
@@ -117,21 +119,33 @@ exports.EAuthMeIDCardAntiFraudStatus = void 0;
|
|
|
117
119
|
EAuthMeIDCardAntiFraudStatus["NeedMoreFrame"] = "EAuthMeIDCardAntiFraudStatus_NeedMoreFrame";
|
|
118
120
|
EAuthMeIDCardAntiFraudStatus["Pass"] = "EAuthMeIDCardAntiFraudStatus_Pass";
|
|
119
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";
|
|
120
133
|
})(exports.EAuthMeIDCardAntiFraudStatus || (exports.EAuthMeIDCardAntiFraudStatus = {}));
|
|
121
134
|
exports.EAuthMeMRZRecogStatus = void 0;
|
|
122
135
|
(function (EAuthMeMRZRecogStatus) {
|
|
123
136
|
EAuthMeMRZRecogStatus["Success"] = "EAuthMeMRZRecogStatus_Success";
|
|
124
137
|
EAuthMeMRZRecogStatus["WrongFormat"] = "EAuthMeMRZRecogStatus_WrongFormat";
|
|
125
138
|
})(exports.EAuthMeMRZRecogStatus || (exports.EAuthMeMRZRecogStatus = {}));
|
|
126
|
-
exports.
|
|
127
|
-
(function (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
exports.EAuthMeMRZServiceStatus = void 0;
|
|
140
|
+
(function (EAuthMeMRZServiceStatus) {
|
|
141
|
+
EAuthMeMRZServiceStatus["Success"] = "EAuthMeMRZServiceStatus_Success";
|
|
142
|
+
EAuthMeMRZServiceStatus["NotFound"] = "EAuthMeMRZServiceStatus_NotFound";
|
|
143
|
+
EAuthMeMRZServiceStatus["RecogFailed"] = "EAuthMeMRZServiceStatus_RecogFailed";
|
|
144
|
+
EAuthMeMRZServiceStatus["WrongCardType"] = "EAuthMeMRZServiceStatus_WrongCardType";
|
|
145
|
+
EAuthMeMRZServiceStatus["Error"] = "EAuthMeMRZServiceStatus_Error";
|
|
146
|
+
EAuthMeMRZServiceStatus["NotAligned"] = "EAuthMeMRZServiceStatus_NotAligned";
|
|
147
|
+
EAuthMeMRZServiceStatus["Reflective"] = "EAuthMeMRZServiceStatus_Reflective";
|
|
148
|
+
})(exports.EAuthMeMRZServiceStatus || (exports.EAuthMeMRZServiceStatus = {}));
|
|
135
149
|
exports.EAuthMeIDCardAntiFraudStage = void 0;
|
|
136
150
|
(function (EAuthMeIDCardAntiFraudStage) {
|
|
137
151
|
EAuthMeIDCardAntiFraudStage["Frontal"] = "EAuthMeIDCardAntiFraudStage_Frontal";
|
|
@@ -151,7 +165,7 @@ var idRecognitionEnumModule = /*#__PURE__*/Object.freeze({
|
|
|
151
165
|
get EAuthMeCardOCRStatus () { return exports.EAuthMeCardOCRStatus; },
|
|
152
166
|
get EAuthMeIDCardAntiFraudStatus () { return exports.EAuthMeIDCardAntiFraudStatus; },
|
|
153
167
|
get EAuthMeMRZRecogStatus () { return exports.EAuthMeMRZRecogStatus; },
|
|
154
|
-
get
|
|
168
|
+
get EAuthMeMRZServiceStatus () { return exports.EAuthMeMRZServiceStatus; },
|
|
155
169
|
get EAuthMeIDCardAntiFraudStage () { return exports.EAuthMeIDCardAntiFraudStage; }
|
|
156
170
|
});
|
|
157
171
|
|
|
@@ -223,11 +237,13 @@ const defaultMlEngineConfig = {
|
|
|
223
237
|
token: '',
|
|
224
238
|
scriptPath: '/assets/',
|
|
225
239
|
apiBaseUrl: '/',
|
|
226
|
-
dataTransferMethod: 'binary'
|
|
240
|
+
dataTransferMethod: 'binary',
|
|
241
|
+
enableEventTracking: false,
|
|
242
|
+
eventTrackUrl: '/'
|
|
227
243
|
};
|
|
228
244
|
|
|
229
245
|
var name = "@authme/engine";
|
|
230
|
-
var version$1 = "2.
|
|
246
|
+
var version$1 = "2.4.6";
|
|
231
247
|
var peerDependencies = {
|
|
232
248
|
"core-js": "^3.6.0",
|
|
233
249
|
rxjs: "^7.4.0"
|
|
@@ -259,6 +275,10 @@ const getDownloadOrder = function () {
|
|
|
259
275
|
}();
|
|
260
276
|
function isSimdSupported() {
|
|
261
277
|
try {
|
|
278
|
+
const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
279
|
+
if (isiOS) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
262
282
|
// Test for WebAssembly SIMD capability (for both browsers and Node.js)
|
|
263
283
|
// This typed array is a WebAssembly program containing SIMD instructions.
|
|
264
284
|
return WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]));
|
|
@@ -357,19 +377,23 @@ class MlEngine {
|
|
|
357
377
|
constructor(config) {
|
|
358
378
|
this.workerAndStreamPromise = undefined;
|
|
359
379
|
this.preloadPromise = undefined;
|
|
380
|
+
this.debugTools = util.debugTools();
|
|
360
381
|
this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
|
|
361
382
|
isMobile: util.isMobile()
|
|
362
383
|
});
|
|
363
384
|
}
|
|
364
385
|
_run(worker, workerMessage$, module, command, value = {}) {
|
|
365
386
|
const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
|
|
387
|
+
const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
|
|
366
388
|
worker.postMessage({
|
|
367
389
|
module,
|
|
368
390
|
command,
|
|
369
391
|
id,
|
|
370
392
|
value
|
|
371
393
|
});
|
|
372
|
-
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
|
+
})));
|
|
373
397
|
}
|
|
374
398
|
_makeWorkerAndStreamAsync() {
|
|
375
399
|
var _a;
|
|
@@ -454,7 +478,9 @@ class MlEngine {
|
|
|
454
478
|
const simdSupported = isSimdSupported();
|
|
455
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`;
|
|
456
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');
|
|
457
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();
|
|
458
484
|
return yield this._run(worker, workerMessage$, exports.EngineModule.Core, 'loadEngine', {
|
|
459
485
|
engineJsContent,
|
|
460
486
|
engineWasmContent
|
|
@@ -541,6 +567,9 @@ class AuthmeEngineModuleBase {
|
|
|
541
567
|
getReport() {
|
|
542
568
|
return this._engineRunAsync('getJsonReport');
|
|
543
569
|
}
|
|
570
|
+
setOption(params) {
|
|
571
|
+
return this._engineRunAsync('setOption', params);
|
|
572
|
+
}
|
|
544
573
|
recognition(data) {
|
|
545
574
|
return __awaiter(this, void 0, void 0, function* () {
|
|
546
575
|
// status control
|
|
@@ -611,6 +640,31 @@ class AuthmeEngineModuleBase {
|
|
|
611
640
|
positions
|
|
612
641
|
});
|
|
613
642
|
}
|
|
643
|
+
encryptString(str, key) {
|
|
644
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
645
|
+
return yield this._engineRunAsync('encryptString', {
|
|
646
|
+
string: str,
|
|
647
|
+
key
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
encryptBlob(uint8Array, key) {
|
|
652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
+
return yield this._engineRunAsync('encryptBlob', {
|
|
654
|
+
uint8Array: uint8Array,
|
|
655
|
+
key
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
// 測試圖片上傳加密用,未來實作後請刪除。
|
|
660
|
+
_decryptString(str, key) {
|
|
661
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
662
|
+
return yield this._engineRunAsync('_decryptString', {
|
|
663
|
+
string: str,
|
|
664
|
+
key
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
}
|
|
614
668
|
destroy() {
|
|
615
669
|
return __awaiter(this, void 0, void 0, function* () {
|
|
616
670
|
yield this._engineRunAsync('destroy');
|
|
@@ -619,6 +673,12 @@ class AuthmeEngineModuleBase {
|
|
|
619
673
|
return true;
|
|
620
674
|
});
|
|
621
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
|
+
}
|
|
622
682
|
static reset_MODEL_CACHE() {
|
|
623
683
|
this._MODEL_CACHE = {};
|
|
624
684
|
}
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'core-js/modules/es.array.iterator.js';
|
|
2
2
|
import 'core-js/modules/es.object.from-entries.js';
|
|
3
|
+
import 'core-js/modules/es.regexp.exec.js';
|
|
3
4
|
import 'core-js/modules/es.array-buffer.slice.js';
|
|
4
5
|
import 'core-js/modules/es.typed-array.uint8-array.js';
|
|
5
6
|
import 'core-js/modules/es.typed-array.fill.js';
|
|
@@ -15,8 +16,8 @@ import 'core-js/modules/es.object.assign.js';
|
|
|
15
16
|
import 'core-js/modules/es.regexp.to-string.js';
|
|
16
17
|
import 'core-js/modules/es.array.sort.js';
|
|
17
18
|
import { AuthmeError, ErrorCode, sendRequest } from '@authme/core';
|
|
18
|
-
import { isMobile, Storage } from '@authme/util';
|
|
19
|
-
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';
|
|
20
21
|
import 'core-js/modules/es.symbol.description.js';
|
|
21
22
|
|
|
22
23
|
/******************************************************************************
|
|
@@ -49,9 +50,10 @@ var EngineModule;
|
|
|
49
50
|
EngineModule["Fas"] = "Fas";
|
|
50
51
|
EngineModule["IdCardAntiFraud"] = "IdCardAntiFraud";
|
|
51
52
|
EngineModule["CardOCR"] = "CardOCR";
|
|
52
|
-
EngineModule["PassportService"] = "PassportService";
|
|
53
53
|
EngineModule["DEBUG"] = "DEBUG";
|
|
54
54
|
EngineModule["Core"] = "Core";
|
|
55
|
+
EngineModule["MRZPassportService"] = "MRZPassportService";
|
|
56
|
+
EngineModule["MRZResidentCardService"] = "MRZResidentCardService";
|
|
55
57
|
})(EngineModule || (EngineModule = {}));
|
|
56
58
|
|
|
57
59
|
var EAuthMeEngineReturnCode;
|
|
@@ -113,21 +115,33 @@ var EAuthMeIDCardAntiFraudStatus;
|
|
|
113
115
|
EAuthMeIDCardAntiFraudStatus["NeedMoreFrame"] = "EAuthMeIDCardAntiFraudStatus_NeedMoreFrame";
|
|
114
116
|
EAuthMeIDCardAntiFraudStatus["Pass"] = "EAuthMeIDCardAntiFraudStatus_Pass";
|
|
115
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";
|
|
116
129
|
})(EAuthMeIDCardAntiFraudStatus || (EAuthMeIDCardAntiFraudStatus = {}));
|
|
117
130
|
var EAuthMeMRZRecogStatus;
|
|
118
131
|
(function (EAuthMeMRZRecogStatus) {
|
|
119
132
|
EAuthMeMRZRecogStatus["Success"] = "EAuthMeMRZRecogStatus_Success";
|
|
120
133
|
EAuthMeMRZRecogStatus["WrongFormat"] = "EAuthMeMRZRecogStatus_WrongFormat";
|
|
121
134
|
})(EAuthMeMRZRecogStatus || (EAuthMeMRZRecogStatus = {}));
|
|
122
|
-
var
|
|
123
|
-
(function (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
var EAuthMeMRZServiceStatus;
|
|
136
|
+
(function (EAuthMeMRZServiceStatus) {
|
|
137
|
+
EAuthMeMRZServiceStatus["Success"] = "EAuthMeMRZServiceStatus_Success";
|
|
138
|
+
EAuthMeMRZServiceStatus["NotFound"] = "EAuthMeMRZServiceStatus_NotFound";
|
|
139
|
+
EAuthMeMRZServiceStatus["RecogFailed"] = "EAuthMeMRZServiceStatus_RecogFailed";
|
|
140
|
+
EAuthMeMRZServiceStatus["WrongCardType"] = "EAuthMeMRZServiceStatus_WrongCardType";
|
|
141
|
+
EAuthMeMRZServiceStatus["Error"] = "EAuthMeMRZServiceStatus_Error";
|
|
142
|
+
EAuthMeMRZServiceStatus["NotAligned"] = "EAuthMeMRZServiceStatus_NotAligned";
|
|
143
|
+
EAuthMeMRZServiceStatus["Reflective"] = "EAuthMeMRZServiceStatus_Reflective";
|
|
144
|
+
})(EAuthMeMRZServiceStatus || (EAuthMeMRZServiceStatus = {}));
|
|
131
145
|
var EAuthMeIDCardAntiFraudStage;
|
|
132
146
|
(function (EAuthMeIDCardAntiFraudStage) {
|
|
133
147
|
EAuthMeIDCardAntiFraudStage["Frontal"] = "EAuthMeIDCardAntiFraudStage_Frontal";
|
|
@@ -147,7 +161,7 @@ var idRecognitionEnumModule = /*#__PURE__*/Object.freeze({
|
|
|
147
161
|
get EAuthMeCardOCRStatus () { return EAuthMeCardOCRStatus; },
|
|
148
162
|
get EAuthMeIDCardAntiFraudStatus () { return EAuthMeIDCardAntiFraudStatus; },
|
|
149
163
|
get EAuthMeMRZRecogStatus () { return EAuthMeMRZRecogStatus; },
|
|
150
|
-
get
|
|
164
|
+
get EAuthMeMRZServiceStatus () { return EAuthMeMRZServiceStatus; },
|
|
151
165
|
get EAuthMeIDCardAntiFraudStage () { return EAuthMeIDCardAntiFraudStage; }
|
|
152
166
|
});
|
|
153
167
|
|
|
@@ -219,11 +233,13 @@ const defaultMlEngineConfig = {
|
|
|
219
233
|
token: '',
|
|
220
234
|
scriptPath: '/assets/',
|
|
221
235
|
apiBaseUrl: '/',
|
|
222
|
-
dataTransferMethod: 'binary'
|
|
236
|
+
dataTransferMethod: 'binary',
|
|
237
|
+
enableEventTracking: false,
|
|
238
|
+
eventTrackUrl: '/'
|
|
223
239
|
};
|
|
224
240
|
|
|
225
241
|
var name = "@authme/engine";
|
|
226
|
-
var version$1 = "2.
|
|
242
|
+
var version$1 = "2.4.6";
|
|
227
243
|
var peerDependencies = {
|
|
228
244
|
"core-js": "^3.6.0",
|
|
229
245
|
rxjs: "^7.4.0"
|
|
@@ -255,6 +271,10 @@ const getDownloadOrder = function () {
|
|
|
255
271
|
}();
|
|
256
272
|
function isSimdSupported() {
|
|
257
273
|
try {
|
|
274
|
+
const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
275
|
+
if (isiOS) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
258
278
|
// Test for WebAssembly SIMD capability (for both browsers and Node.js)
|
|
259
279
|
// This typed array is a WebAssembly program containing SIMD instructions.
|
|
260
280
|
return WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]));
|
|
@@ -353,19 +373,23 @@ class MlEngine {
|
|
|
353
373
|
constructor(config) {
|
|
354
374
|
this.workerAndStreamPromise = undefined;
|
|
355
375
|
this.preloadPromise = undefined;
|
|
376
|
+
this.debugTools = debugTools();
|
|
356
377
|
this.config = Object.assign(Object.assign(Object.assign({}, defaultMlEngineConfig), config), {
|
|
357
378
|
isMobile: isMobile()
|
|
358
379
|
});
|
|
359
380
|
}
|
|
360
381
|
_run(worker, workerMessage$, module, command, value = {}) {
|
|
361
382
|
const id = (Math.random() + 1).toString(36).substring(4) + Date.now();
|
|
383
|
+
const durationTimeWorker = this.debugTools.setTimeDuration(`${module}_${command}_${id}`);
|
|
362
384
|
worker.postMessage({
|
|
363
385
|
module,
|
|
364
386
|
command,
|
|
365
387
|
id,
|
|
366
388
|
value
|
|
367
389
|
});
|
|
368
|
-
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
|
+
})));
|
|
369
393
|
}
|
|
370
394
|
_makeWorkerAndStreamAsync() {
|
|
371
395
|
var _a;
|
|
@@ -450,7 +474,9 @@ class MlEngine {
|
|
|
450
474
|
const simdSupported = isSimdSupported();
|
|
451
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`;
|
|
452
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');
|
|
453
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();
|
|
454
480
|
return yield this._run(worker, workerMessage$, EngineModule.Core, 'loadEngine', {
|
|
455
481
|
engineJsContent,
|
|
456
482
|
engineWasmContent
|
|
@@ -537,6 +563,9 @@ class AuthmeEngineModuleBase {
|
|
|
537
563
|
getReport() {
|
|
538
564
|
return this._engineRunAsync('getJsonReport');
|
|
539
565
|
}
|
|
566
|
+
setOption(params) {
|
|
567
|
+
return this._engineRunAsync('setOption', params);
|
|
568
|
+
}
|
|
540
569
|
recognition(data) {
|
|
541
570
|
return __awaiter(this, void 0, void 0, function* () {
|
|
542
571
|
// status control
|
|
@@ -607,6 +636,31 @@ class AuthmeEngineModuleBase {
|
|
|
607
636
|
positions
|
|
608
637
|
});
|
|
609
638
|
}
|
|
639
|
+
encryptString(str, key) {
|
|
640
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
641
|
+
return yield this._engineRunAsync('encryptString', {
|
|
642
|
+
string: str,
|
|
643
|
+
key
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
encryptBlob(uint8Array, key) {
|
|
648
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
649
|
+
return yield this._engineRunAsync('encryptBlob', {
|
|
650
|
+
uint8Array: uint8Array,
|
|
651
|
+
key
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
// 測試圖片上傳加密用,未來實作後請刪除。
|
|
656
|
+
_decryptString(str, key) {
|
|
657
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
+
return yield this._engineRunAsync('_decryptString', {
|
|
659
|
+
string: str,
|
|
660
|
+
key
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
}
|
|
610
664
|
destroy() {
|
|
611
665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
612
666
|
yield this._engineRunAsync('destroy');
|
|
@@ -615,10 +669,16 @@ class AuthmeEngineModuleBase {
|
|
|
615
669
|
return true;
|
|
616
670
|
});
|
|
617
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
|
+
}
|
|
618
678
|
static reset_MODEL_CACHE() {
|
|
619
679
|
this._MODEL_CACHE = {};
|
|
620
680
|
}
|
|
621
681
|
}
|
|
622
682
|
AuthmeEngineModuleBase._MODEL_CACHE = {};
|
|
623
683
|
|
|
624
|
-
export { AuthmeEngineModuleBase, AuthmeFunctionModule, EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeEngineReturnCode, EAuthMeEyeStatus, EAuthMeFASServiceStage, EAuthMeFASServiceStatus, EAuthMeFaceAntiSpoofingStatus, EAuthMeFacePose, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardMetalTagStatus, EAuthMeMRZRecogStatus,
|
|
684
|
+
export { AuthmeEngineModuleBase, AuthmeFunctionModule, EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeEngineReturnCode, EAuthMeEyeStatus, EAuthMeFASServiceStage, EAuthMeFASServiceStatus, EAuthMeFaceAntiSpoofingStatus, EAuthMeFacePose, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeIDCardMetalTagStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus, EAuthMeMouthStatus, EngineModule, MlEngine, defaultMlEngineConfig, version };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authme/engine",
|
|
3
|
-
"version": "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.
|
|
8
|
-
"@authme/util": "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",
|
package/src/lib/engine.d.ts
CHANGED
|
@@ -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,12 +40,21 @@ 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>;
|
|
45
50
|
getParams(): Promise<EngineParams>;
|
|
46
51
|
setParams(params: any): Promise<unknown>;
|
|
47
52
|
setMaskPosition(positions: number[][]): Promise<unknown>;
|
|
53
|
+
encryptString(str: string, key: string): Promise<string>;
|
|
54
|
+
encryptBlob(uint8Array: ArrayBuffer, key: string): Promise<string>;
|
|
55
|
+
_decryptString(str: string, key: string): Promise<string>;
|
|
48
56
|
destroy(): Promise<boolean>;
|
|
57
|
+
getUIParams(): Promise<unknown>;
|
|
58
|
+
setUIParams(params: unknown): Promise<unknown>;
|
|
49
59
|
static reset_MODEL_CACHE(): void;
|
|
50
60
|
}
|
|
@@ -41,19 +41,31 @@ 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",
|
|
48
59
|
WrongFormat = "EAuthMeMRZRecogStatus_WrongFormat"
|
|
49
60
|
}
|
|
50
|
-
export declare enum
|
|
51
|
-
Success = "
|
|
52
|
-
NotFound = "
|
|
53
|
-
RecogFailed = "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
export declare enum EAuthMeMRZServiceStatus {
|
|
62
|
+
Success = "EAuthMeMRZServiceStatus_Success",
|
|
63
|
+
NotFound = "EAuthMeMRZServiceStatus_NotFound",
|
|
64
|
+
RecogFailed = "EAuthMeMRZServiceStatus_RecogFailed",
|
|
65
|
+
WrongCardType = "EAuthMeMRZServiceStatus_WrongCardType",
|
|
66
|
+
Error = "EAuthMeMRZServiceStatus_Error",
|
|
67
|
+
NotAligned = "EAuthMeMRZServiceStatus_NotAligned",
|
|
68
|
+
Reflective = "EAuthMeMRZServiceStatus_Reflective"
|
|
57
69
|
}
|
|
58
70
|
export declare enum EAuthMeIDCardAntiFraudStage {
|
|
59
71
|
Frontal = "EAuthMeIDCardAntiFraudStage_Frontal",
|
|
@@ -2,7 +2,8 @@ export declare enum EngineModule {
|
|
|
2
2
|
Fas = "Fas",
|
|
3
3
|
IdCardAntiFraud = "IdCardAntiFraud",
|
|
4
4
|
CardOCR = "CardOCR",
|
|
5
|
-
PassportService = "PassportService",
|
|
6
5
|
DEBUG = "DEBUG",
|
|
7
|
-
Core = "Core"
|
|
6
|
+
Core = "Core",
|
|
7
|
+
MRZPassportService = "MRZPassportService",
|
|
8
|
+
MRZResidentCardService = "MRZResidentCardService"
|
|
8
9
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface MlEngineConfig {
|
|
2
|
-
token
|
|
2
|
+
token: string;
|
|
3
3
|
scriptPath?: string;
|
|
4
4
|
apiBaseUrl?: string;
|
|
5
5
|
dataTransferMethod?: 'binary' | 'base64';
|
|
6
|
+
enableEventTracking?: boolean;
|
|
7
|
+
eventTrackUrl?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare const defaultMlEngineConfig: MlEngineConfig;
|