@authme/engine 2.8.41 → 2.8.44
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 +7464 -14
- package/assets/ml_engine_web.simd.js +7464 -14
- 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.d.ts +1 -0
- package/{index.cjs → index.cjs.js} +300 -332
- package/index.esm.d.ts +1 -0
- package/{index.js → index.esm.js} +301 -331
- package/package.json +6 -10
- package/src/index.d.ts +4 -4
- package/src/lib/api.d.ts +1 -1
- package/src/lib/engine.d.ts +60 -60
- package/src/lib/enum/auth.enum.d.ts +3 -3
- package/src/lib/enum/fas-recognition.enum.d.ts +49 -49
- package/src/lib/enum/id-recognition.enum.d.ts +85 -81
- package/src/lib/enum/index.d.ts +4 -4
- package/src/lib/enum/module.enum.d.ts +9 -9
- package/src/lib/interface/basic-type.interface.d.ts +22 -22
- package/src/lib/interface/config.interface.d.ts +9 -9
- package/src/lib/interface/index.d.ts +3 -3
- package/src/lib/interface/worker-command.interface.d.ts +7 -7
- package/src/lib/version.d.ts +1 -1
|
@@ -1,58 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
require('core-js/modules/es.array.iterator.js');
|
|
4
|
+
require('core-js/modules/es.array.push.js');
|
|
5
|
+
require('core-js/modules/es.array.sort.js');
|
|
6
|
+
require('core-js/modules/es.array-buffer.constructor.js');
|
|
7
|
+
require('core-js/modules/es.array-buffer.slice.js');
|
|
8
|
+
require('core-js/modules/es.array-buffer.detached.js');
|
|
9
|
+
require('core-js/modules/es.array-buffer.transfer.js');
|
|
10
|
+
require('core-js/modules/es.array-buffer.transfer-to-fixed-length.js');
|
|
11
|
+
require('core-js/modules/es.json.stringify.js');
|
|
12
|
+
require('core-js/modules/es.object.assign.js');
|
|
6
13
|
require('core-js/modules/es.object.from-entries.js');
|
|
14
|
+
require('core-js/modules/es.parse-int.js');
|
|
15
|
+
require('core-js/modules/es.promise.js');
|
|
7
16
|
require('core-js/modules/es.regexp.exec.js');
|
|
8
|
-
require('core-js/modules/es.
|
|
17
|
+
require('core-js/modules/es.regexp.test.js');
|
|
18
|
+
require('core-js/modules/es.regexp.to-string.js');
|
|
9
19
|
require('core-js/modules/es.typed-array.uint8-array.js');
|
|
20
|
+
require('core-js/modules/es.typed-array.at.js');
|
|
10
21
|
require('core-js/modules/es.typed-array.fill.js');
|
|
22
|
+
require('core-js/modules/es.typed-array.find-last.js');
|
|
23
|
+
require('core-js/modules/es.typed-array.find-last-index.js');
|
|
11
24
|
require('core-js/modules/es.typed-array.set.js');
|
|
12
25
|
require('core-js/modules/es.typed-array.sort.js');
|
|
13
26
|
require('core-js/modules/es.typed-array.to-locale-string.js');
|
|
27
|
+
require('core-js/modules/es.typed-array.to-reversed.js');
|
|
28
|
+
require('core-js/modules/es.typed-array.to-sorted.js');
|
|
29
|
+
require('core-js/modules/es.typed-array.with.js');
|
|
30
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
31
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
32
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
33
|
+
require('core-js/modules/esnext.uint8-array.to-base64.js');
|
|
34
|
+
require('core-js/modules/esnext.uint8-array.to-hex.js');
|
|
14
35
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
15
36
|
require('core-js/modules/web.url.js');
|
|
37
|
+
require('core-js/modules/web.url.to-json.js');
|
|
16
38
|
require('core-js/modules/web.url-search-params.js');
|
|
17
|
-
require('core-js/modules/
|
|
18
|
-
require('core-js/modules/
|
|
19
|
-
require('core-js/modules/
|
|
20
|
-
require('core-js/modules/es.regexp.to-string.js');
|
|
21
|
-
require('core-js/modules/es.array.sort.js');
|
|
39
|
+
require('core-js/modules/web.url-search-params.delete.js');
|
|
40
|
+
require('core-js/modules/web.url-search-params.has.js');
|
|
41
|
+
require('core-js/modules/web.url-search-params.size.js');
|
|
22
42
|
var core = require('@authme/core');
|
|
23
43
|
var util = require('@authme/util');
|
|
24
44
|
var rxjs = require('rxjs');
|
|
25
|
-
require('core-js/modules/es.symbol.description.js');
|
|
26
|
-
|
|
27
|
-
/******************************************************************************
|
|
28
|
-
Copyright (c) Microsoft Corporation.
|
|
29
|
-
|
|
30
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
-
purpose with or without fee is hereby granted.
|
|
32
|
-
|
|
33
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
-
***************************************************************************** */
|
|
41
|
-
|
|
42
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
44
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
45
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
46
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
47
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
48
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
53
|
-
var e = new Error(message);
|
|
54
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
55
|
-
};
|
|
56
45
|
|
|
57
46
|
exports.EngineModule = void 0;
|
|
58
47
|
(function (EngineModule) {
|
|
@@ -71,8 +60,8 @@ exports.EAuthMeEngineReturnCode = void 0;
|
|
|
71
60
|
})(exports.EAuthMeEngineReturnCode || (exports.EAuthMeEngineReturnCode = {}));
|
|
72
61
|
|
|
73
62
|
var authEnumModule = /*#__PURE__*/Object.freeze({
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
__proto__: null,
|
|
64
|
+
get EAuthMeEngineReturnCode () { return exports.EAuthMeEngineReturnCode; }
|
|
76
65
|
});
|
|
77
66
|
|
|
78
67
|
exports.EAuthMeCardClass = void 0;
|
|
@@ -80,7 +69,7 @@ exports.EAuthMeCardClass = void 0;
|
|
|
80
69
|
EAuthMeCardClass["Invalid"] = "EAuthMeCardClass_Invalid";
|
|
81
70
|
EAuthMeCardClass["Unknown"] = "EAuthMeCardClass_UnknownCard";
|
|
82
71
|
EAuthMeCardClass["Passport"] = "EAuthMeCardClass_Passport";
|
|
83
|
-
EAuthMeCardClass["ALL_PASSPORT_CONTENT"] = "
|
|
72
|
+
EAuthMeCardClass["ALL_PASSPORT_CONTENT"] = "EAuthMeCardClass_ALL_PASSPORT_CONTENT";
|
|
84
73
|
EAuthMeCardClass["TWN_IDCard_Front"] = "EAuthMeCardClass_TWN_IDCard_Front";
|
|
85
74
|
EAuthMeCardClass["TWN_IDCard_Back"] = "EAuthMeCardClass_TWN_IDCard_Back";
|
|
86
75
|
EAuthMeCardClass["TWN_DriverLicense_Front"] = "EAuthMeCardClass_TWN_DriverLicense_Front";
|
|
@@ -109,10 +98,11 @@ exports.EAuthMeCardOCRStatus = void 0;
|
|
|
109
98
|
EAuthMeCardOCRStatus["WrongCardType"] = "EAuthMeCardOCRStatus_WrongCardType";
|
|
110
99
|
EAuthMeCardOCRStatus["PositionNotMatch"] = "EAuthMeCardOCRStatus_PositionNotMatch";
|
|
111
100
|
EAuthMeCardOCRStatus["Reflective"] = "EAuthMeCardOCRStatus_Reflective";
|
|
101
|
+
EAuthMeCardOCRStatus["Gray"] = "EAuthMeCardOCRStatus_Gray";
|
|
112
102
|
EAuthMeCardOCRStatus["Blur"] = "EAuthMeCardOCRStatus_Blur";
|
|
113
|
-
EAuthMeCardOCRStatus["Motion"] = "EAuthMeCardOCRStatus_Motion";
|
|
114
103
|
EAuthMeCardOCRStatus["Pass"] = "EAuthMeCardOCRStatus_Pass";
|
|
115
104
|
EAuthMeCardOCRStatus["Error"] = "EAuthMeCardOCRStatus_Error";
|
|
105
|
+
EAuthMeCardOCRStatus["Motion"] = "EAuthMeCardOCRStatus_Motion";
|
|
116
106
|
})(exports.EAuthMeCardOCRStatus || (exports.EAuthMeCardOCRStatus = {}));
|
|
117
107
|
exports.EAuthMeIDCardAntiFraudStatus = void 0;
|
|
118
108
|
(function (EAuthMeIDCardAntiFraudStatus) {
|
|
@@ -138,6 +128,7 @@ exports.EAuthMeIDCardAntiFraudStatus = void 0;
|
|
|
138
128
|
EAuthMeIDCardAntiFraudStatus["NeedHoldCard"] = "EAuthMeIDCardAntiFraudStatus_NeedHoldCard";
|
|
139
129
|
EAuthMeIDCardAntiFraudStatus["StagePass"] = "EAuthMeIDCardAntiFraudStatus_StagePass";
|
|
140
130
|
EAuthMeIDCardAntiFraudStatus["CardThicknessFailed"] = "EAuthMeIDCardAntiFraudStatus_CardThicknessFailed";
|
|
131
|
+
EAuthMeIDCardAntiFraudStatus["Undefined"] = "EAuthMeIDCardAntiFraudStatus_Undefined";
|
|
141
132
|
})(exports.EAuthMeIDCardAntiFraudStatus || (exports.EAuthMeIDCardAntiFraudStatus = {}));
|
|
142
133
|
exports.EAuthMeMRZRecogStatus = void 0;
|
|
143
134
|
(function (EAuthMeMRZRecogStatus) {
|
|
@@ -146,13 +137,15 @@ exports.EAuthMeMRZRecogStatus = void 0;
|
|
|
146
137
|
})(exports.EAuthMeMRZRecogStatus || (exports.EAuthMeMRZRecogStatus = {}));
|
|
147
138
|
exports.EAuthMeMRZServiceStatus = void 0;
|
|
148
139
|
(function (EAuthMeMRZServiceStatus) {
|
|
149
|
-
EAuthMeMRZServiceStatus["Success"] = "EAuthMeMRZServiceStatus_Success";
|
|
150
140
|
EAuthMeMRZServiceStatus["NotFound"] = "EAuthMeMRZServiceStatus_NotFound";
|
|
151
|
-
EAuthMeMRZServiceStatus["RecogFailed"] = "EAuthMeMRZServiceStatus_RecogFailed";
|
|
152
|
-
EAuthMeMRZServiceStatus["WrongCardType"] = "EAuthMeMRZServiceStatus_WrongCardType";
|
|
153
|
-
EAuthMeMRZServiceStatus["Error"] = "EAuthMeMRZServiceStatus_Error";
|
|
154
141
|
EAuthMeMRZServiceStatus["NotAligned"] = "EAuthMeMRZServiceStatus_NotAligned";
|
|
155
142
|
EAuthMeMRZServiceStatus["Reflective"] = "EAuthMeMRZServiceStatus_Reflective";
|
|
143
|
+
EAuthMeMRZServiceStatus["Blur"] = "EAuthMeMRZServiceStatus_Blur";
|
|
144
|
+
EAuthMeMRZServiceStatus["WrongCardType"] = "EAuthMeMRZServiceStatus_WrongCardType";
|
|
145
|
+
EAuthMeMRZServiceStatus["MRZNotFound"] = "EAuthMeMRZServiceStatus_MRZNotFound";
|
|
146
|
+
EAuthMeMRZServiceStatus["RecogFailed"] = "EAuthMeMRZServiceStatus_RecogFailed";
|
|
147
|
+
EAuthMeMRZServiceStatus["Success"] = "EAuthMeMRZServiceStatus_Success";
|
|
148
|
+
EAuthMeMRZServiceStatus["Error"] = "EAuthMeMRZServiceStatus_Error";
|
|
156
149
|
})(exports.EAuthMeMRZServiceStatus || (exports.EAuthMeMRZServiceStatus = {}));
|
|
157
150
|
exports.EAuthMeIDCardAntiFraudStage = void 0;
|
|
158
151
|
(function (EAuthMeIDCardAntiFraudStage) {
|
|
@@ -166,15 +159,15 @@ exports.EAuthMeIDCardAntiFraudStage = void 0;
|
|
|
166
159
|
})(exports.EAuthMeIDCardAntiFraudStage || (exports.EAuthMeIDCardAntiFraudStage = {}));
|
|
167
160
|
|
|
168
161
|
var idRecognitionEnumModule = /*#__PURE__*/Object.freeze({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
162
|
+
__proto__: null,
|
|
163
|
+
get EAuthMeCardClass () { return exports.EAuthMeCardClass; },
|
|
164
|
+
get EAuthMeCardMatchStatus () { return exports.EAuthMeCardMatchStatus; },
|
|
165
|
+
get EAuthMeCardOCRStatus () { return exports.EAuthMeCardOCRStatus; },
|
|
166
|
+
get EAuthMeIDCardAntiFraudStage () { return exports.EAuthMeIDCardAntiFraudStage; },
|
|
167
|
+
get EAuthMeIDCardAntiFraudStatus () { return exports.EAuthMeIDCardAntiFraudStatus; },
|
|
168
|
+
get EAuthMeIDCardMetalTagStatus () { return exports.EAuthMeIDCardMetalTagStatus; },
|
|
169
|
+
get EAuthMeMRZRecogStatus () { return exports.EAuthMeMRZRecogStatus; },
|
|
170
|
+
get EAuthMeMRZServiceStatus () { return exports.EAuthMeMRZServiceStatus; }
|
|
178
171
|
});
|
|
179
172
|
|
|
180
173
|
exports.EAuthMeFASServiceStatus = void 0;
|
|
@@ -234,13 +227,13 @@ exports.EAuthMeFaceAntiSpoofingStatus = void 0;
|
|
|
234
227
|
})(exports.EAuthMeFaceAntiSpoofingStatus || (exports.EAuthMeFaceAntiSpoofingStatus = {}));
|
|
235
228
|
|
|
236
229
|
var fasRecognitionEnumModule = /*#__PURE__*/Object.freeze({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
230
|
+
__proto__: null,
|
|
231
|
+
get EAuthMeEyeStatus () { return exports.EAuthMeEyeStatus; },
|
|
232
|
+
get EAuthMeFASServiceStage () { return exports.EAuthMeFASServiceStage; },
|
|
233
|
+
get EAuthMeFASServiceStatus () { return exports.EAuthMeFASServiceStatus; },
|
|
234
|
+
get EAuthMeFaceAntiSpoofingStatus () { return exports.EAuthMeFaceAntiSpoofingStatus; },
|
|
235
|
+
get EAuthMeFacePose () { return exports.EAuthMeFacePose; },
|
|
236
|
+
get EAuthMeMouthStatus () { return exports.EAuthMeMouthStatus; }
|
|
244
237
|
});
|
|
245
238
|
|
|
246
239
|
const defaultMlEngineConfig = {
|
|
@@ -253,18 +246,14 @@ const defaultMlEngineConfig = {
|
|
|
253
246
|
};
|
|
254
247
|
|
|
255
248
|
var name = "authme/sdk";
|
|
256
|
-
var version$1 = "2.8.
|
|
257
|
-
var date = "2026-01-30T10:27:23+0000";
|
|
249
|
+
var version$1 = "2.8.44";
|
|
258
250
|
var sdkInfo = {
|
|
259
251
|
name: name,
|
|
260
|
-
version: version$1
|
|
261
|
-
date: date
|
|
262
|
-
};
|
|
252
|
+
version: version$1};
|
|
263
253
|
|
|
264
|
-
var
|
|
265
|
-
var _b, _c;
|
|
254
|
+
var _window, _Symbol$for, _window$_Symbol$for;
|
|
266
255
|
const version = sdkInfo.version;
|
|
267
|
-
(
|
|
256
|
+
(_window$_Symbol$for = (_window = window)[_Symbol$for = Symbol.for('authme-sdk')]) != null ? _window$_Symbol$for : _window[_Symbol$for] = {};
|
|
268
257
|
window[Symbol.for('authme-sdk')][sdkInfo.name] = version;
|
|
269
258
|
|
|
270
259
|
function logCollect(message, stackTrace) {
|
|
@@ -281,17 +270,36 @@ function logCollect(message, stackTrace) {
|
|
|
281
270
|
});
|
|
282
271
|
}
|
|
283
272
|
|
|
273
|
+
var _MlEngine, _AuthmeEngineModuleBase;
|
|
284
274
|
const getDownloadOrder = function () {
|
|
285
275
|
// model 越大,在後續 worker service 載入與解密的時間越長,
|
|
286
276
|
// 所以盡可能讓越大的檔案排在越前面下載,以便讓耗費時間長的任務先排在背景執行。
|
|
287
277
|
//
|
|
288
278
|
// 但由於 api server 目前沒有提供檔案大小的相關資訊,
|
|
289
279
|
// 所以將順序相關的資訊寫死在 sdk 裡。
|
|
290
|
-
const DOWNLOAD_ORDER = Object.fromEntries(['FACE_03',
|
|
280
|
+
const DOWNLOAD_ORDER = Object.fromEntries(['FACE_03',
|
|
281
|
+
// 3.7m
|
|
282
|
+
'FACE_00',
|
|
283
|
+
// 1.6m
|
|
284
|
+
'IDCardAntiFraud_00',
|
|
285
|
+
//1.5m
|
|
286
|
+
'FACE_01',
|
|
287
|
+
// 1.4m
|
|
288
|
+
'OCR_00',
|
|
289
|
+
// 1.4m
|
|
290
|
+
'FACE_02',
|
|
291
|
+
// 1.3m
|
|
292
|
+
'OCR_02',
|
|
293
|
+
// 548k
|
|
294
|
+
'MRZ_00',
|
|
295
|
+
// 548k
|
|
296
|
+
'OCR_01',
|
|
297
|
+
// 375k
|
|
298
|
+
'MRZ_01' // 375k
|
|
291
299
|
].map((key, index) => [key, index]));
|
|
292
300
|
return function getDownloadOrder(key) {
|
|
293
|
-
var
|
|
294
|
-
return (
|
|
301
|
+
var _DOWNLOAD_ORDER$key;
|
|
302
|
+
return (_DOWNLOAD_ORDER$key = DOWNLOAD_ORDER[key]) != null ? _DOWNLOAD_ORDER$key : Number.MAX_VALUE;
|
|
295
303
|
};
|
|
296
304
|
}();
|
|
297
305
|
function isSimdSupported() {
|
|
@@ -323,54 +331,46 @@ function getJsContentAsync(url) {
|
|
|
323
331
|
sdkInfo: null
|
|
324
332
|
});
|
|
325
333
|
}
|
|
326
|
-
function createWorkerWithObjectUrlAsync(url) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return worker;
|
|
335
|
-
});
|
|
334
|
+
async function createWorkerWithObjectUrlAsync(url) {
|
|
335
|
+
const scriptContent = await getJsContentAsync(url);
|
|
336
|
+
const objectUrl = URL.createObjectURL(new Blob([scriptContent], {
|
|
337
|
+
type: 'text/javascript'
|
|
338
|
+
}));
|
|
339
|
+
const worker = new Worker(objectUrl);
|
|
340
|
+
URL.revokeObjectURL(objectUrl);
|
|
341
|
+
return worker;
|
|
336
342
|
}
|
|
337
343
|
function convertToModelQueryString(modelVersion) {
|
|
338
344
|
return `models=${modelVersion.name}[${modelVersion.version}]`;
|
|
339
345
|
}
|
|
340
|
-
function fetchModelCodesAsync(modelVersions) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return response.models;
|
|
345
|
-
});
|
|
346
|
+
async function fetchModelCodesAsync(modelVersions) {
|
|
347
|
+
const queryString = modelVersions.map(convertToModelQueryString).join('&');
|
|
348
|
+
const response = await core.sendRequest('/api/model-management/v1/model?' + queryString);
|
|
349
|
+
return response.models;
|
|
346
350
|
}
|
|
347
351
|
function base64ToBufferAsync(base64) {
|
|
348
352
|
const dataUrl = 'data:application/octet-binary;base64,' + base64;
|
|
349
353
|
return fetch(dataUrl).then(res => res.arrayBuffer());
|
|
350
354
|
}
|
|
351
|
-
function fetchModelContentAsync(code, dataTransferMethod) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
});
|
|
355
|
+
async function fetchModelContentAsync(code, dataTransferMethod) {
|
|
356
|
+
const payload = await core.sendRequest(`/api/model-management/v1/model/${code}${dataTransferMethod === 'binary' ? '/file' : ''}`);
|
|
357
|
+
if (dataTransferMethod === 'binary') {
|
|
358
|
+
return payload;
|
|
359
|
+
} else {
|
|
360
|
+
return await base64ToBufferAsync(payload.data);
|
|
361
|
+
}
|
|
360
362
|
}
|
|
361
363
|
function fetchModelContents(modelVersions, dataTransferMethod) {
|
|
362
364
|
return rxjs.of(modelVersions).pipe(rxjs.concatMap(modelVersions => rxjs.defer(() => fetchModelCodesAsync(modelVersions))), rxjs.concatAll(), rxjs.mergeMap(({
|
|
363
365
|
name,
|
|
364
366
|
version,
|
|
365
367
|
code
|
|
366
|
-
}) => rxjs.defer(() =>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
modelArrayBuffer: yield fetchModelContentAsync(code, dataTransferMethod)
|
|
373
|
-
};
|
|
368
|
+
}) => rxjs.defer(async () => ({
|
|
369
|
+
modelVersion: {
|
|
370
|
+
name,
|
|
371
|
+
version: `${parseInt(version)}`
|
|
372
|
+
},
|
|
373
|
+
modelArrayBuffer: await fetchModelContentAsync(code, dataTransferMethod)
|
|
374
374
|
})), 1
|
|
375
375
|
// 下載 model 過程會分為 wait time & download time,
|
|
376
376
|
// concurrent 設定越高,只能起到降低 wait time 的作用,但會拉長單一檔案完成下載的時間,
|
|
@@ -379,16 +379,13 @@ function fetchModelContents(modelVersions, dataTransferMethod) {
|
|
|
379
379
|
// 所以 concurrent 建議設定為 1 或 2,盡量讓已下載好的 model 儘早進行載入與解密。
|
|
380
380
|
));
|
|
381
381
|
}
|
|
382
|
-
|
|
383
382
|
class AuthmeFunctionModule {
|
|
384
|
-
init(config) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
util.Storage.setItem(key, config[key]);
|
|
389
|
-
}
|
|
383
|
+
async init(config) {
|
|
384
|
+
for (const key in config) {
|
|
385
|
+
if (Object.prototype.hasOwnProperty.call(config, key)) {
|
|
386
|
+
util.Storage.setItem(key, config[key]);
|
|
390
387
|
}
|
|
391
|
-
}
|
|
388
|
+
}
|
|
392
389
|
}
|
|
393
390
|
static getVersion() {
|
|
394
391
|
return version;
|
|
@@ -399,7 +396,7 @@ class MlEngine {
|
|
|
399
396
|
this.workerAndStreamPromise = undefined;
|
|
400
397
|
this.preloadPromise = undefined;
|
|
401
398
|
this.debugTools = util.debugTools();
|
|
402
|
-
this.config = Object.assign(
|
|
399
|
+
this.config = Object.assign({}, defaultMlEngineConfig, config, {
|
|
403
400
|
isMobile: util.isMobile()
|
|
404
401
|
});
|
|
405
402
|
}
|
|
@@ -416,102 +413,88 @@ class MlEngine {
|
|
|
416
413
|
durationTimeWorker.end();
|
|
417
414
|
})));
|
|
418
415
|
}
|
|
419
|
-
_makeWorkerAndStreamAsync() {
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
return x.data;
|
|
434
|
-
}), rxjs.shareReplay(1));
|
|
435
|
-
yield this._run(worker, workerMessage$, exports.EngineModule.Core, 'setConfig', this.config);
|
|
436
|
-
return [worker, workerMessage$];
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
_backgroundPreloadAsync() {
|
|
440
|
-
var _a;
|
|
441
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
442
|
-
const [worker, workerMessage$] = yield (_a = this.workerAndStreamPromise) !== null && _a !== void 0 ? _a : this.workerAndStreamPromise = this._makeWorkerAndStreamAsync();
|
|
443
|
-
yield this._loadEngineAsync(worker, workerMessage$);
|
|
444
|
-
yield this._checkEnumConsistencyAsync(worker, workerMessage$);
|
|
445
|
-
return [worker, workerMessage$];
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
terminateWorkerAsync() {
|
|
449
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
-
if (this.workerAndStreamPromise || this.preloadPromise) {
|
|
451
|
-
const [worker, _] = yield this._backgroundPreloadAsync();
|
|
452
|
-
this.workerAndStreamPromise = undefined;
|
|
453
|
-
this.preloadPromise = undefined;
|
|
454
|
-
worker.terminate();
|
|
416
|
+
async _makeWorkerAndStreamAsync() {
|
|
417
|
+
var _this$config$scriptPa;
|
|
418
|
+
// use blobUrl to fix cross-domain problem on worker creating.
|
|
419
|
+
// ref:
|
|
420
|
+
// * https://stackoverflow.com/questions/25458104/can-should-html5-web-workers-use-cors-for-cross-origin
|
|
421
|
+
// * https://web.dev/workers-basics/
|
|
422
|
+
const worker = await createWorkerWithObjectUrlAsync(`${(_this$config$scriptPa = this.config.scriptPath) != null ? _this$config$scriptPa : ''}engine-worker.js?t=${Date.now()}`);
|
|
423
|
+
const workerMessage$ = rxjs.fromEvent(worker, 'message').pipe(rxjs.map(x => {
|
|
424
|
+
var _x$data;
|
|
425
|
+
if ((_x$data = x.data) != null && (_x$data = _x$data.value) != null && _x$data.error) {
|
|
426
|
+
var _x$data2;
|
|
427
|
+
logCollect('workerMessage error', JSON.stringify((_x$data2 = x.data) == null || (_x$data2 = _x$data2.value) == null ? void 0 : _x$data2.error));
|
|
428
|
+
throw new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, 'unexpected worker error');
|
|
455
429
|
}
|
|
456
|
-
|
|
430
|
+
return x.data;
|
|
431
|
+
}), rxjs.shareReplay(1));
|
|
432
|
+
await this._run(worker, workerMessage$, exports.EngineModule.Core, 'setConfig', this.config);
|
|
433
|
+
return [worker, workerMessage$];
|
|
434
|
+
}
|
|
435
|
+
async _backgroundPreloadAsync() {
|
|
436
|
+
var _this$workerAndStream;
|
|
437
|
+
const [worker, workerMessage$] = await ((_this$workerAndStream = this.workerAndStreamPromise) != null ? _this$workerAndStream : this.workerAndStreamPromise = this._makeWorkerAndStreamAsync());
|
|
438
|
+
await this._loadEngineAsync(worker, workerMessage$);
|
|
439
|
+
await this._checkEnumConsistencyAsync(worker, workerMessage$);
|
|
440
|
+
return [worker, workerMessage$];
|
|
441
|
+
}
|
|
442
|
+
async terminateWorkerAsync() {
|
|
443
|
+
if (this.workerAndStreamPromise || this.preloadPromise) {
|
|
444
|
+
const [worker, _] = await this._backgroundPreloadAsync();
|
|
445
|
+
this.workerAndStreamPromise = undefined;
|
|
446
|
+
this.preloadPromise = undefined;
|
|
447
|
+
worker.terminate();
|
|
448
|
+
}
|
|
457
449
|
}
|
|
458
450
|
_preloadAndWaitReadyAsync() {
|
|
459
|
-
var
|
|
460
|
-
return (
|
|
461
|
-
}
|
|
462
|
-
_checkEnumConsistencyAsync(worker, workerMessage$) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
});
|
|
451
|
+
var _this$preloadPromise;
|
|
452
|
+
return (_this$preloadPromise = this.preloadPromise) != null ? _this$preloadPromise : this.preloadPromise = this._backgroundPreloadAsync();
|
|
453
|
+
}
|
|
454
|
+
async _checkEnumConsistencyAsync(worker, workerMessage$) {
|
|
455
|
+
const problem = await this._run(worker, workerMessage$, 'Core', 'checkEnumConsistency', Object.assign({}, authEnumModule, idRecognitionEnumModule, fasRecognitionEnumModule));
|
|
456
|
+
if (problem.length > 0) {
|
|
457
|
+
logCollect('enum consistency problem', JSON.stringify(problem));
|
|
458
|
+
throw new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, {
|
|
459
|
+
problem
|
|
460
|
+
});
|
|
461
|
+
}
|
|
472
462
|
}
|
|
473
|
-
run(module, command, value = {}) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return yield this._run(worker, workerMessage$, module, command, value);
|
|
477
|
-
});
|
|
463
|
+
async run(module, command, value = {}) {
|
|
464
|
+
const [worker, workerMessage$] = await this._preloadAndWaitReadyAsync();
|
|
465
|
+
return await this._run(worker, workerMessage$, module, command, value);
|
|
478
466
|
}
|
|
479
467
|
getConfig() {
|
|
480
468
|
return this.config;
|
|
481
469
|
}
|
|
482
|
-
setConfig(config) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
setPublicKeyForJson(pubKey) {
|
|
492
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
493
|
-
const [worker, workerMessage$] = yield this._preloadAndWaitReadyAsync();
|
|
494
|
-
yield this._run(worker, workerMessage$, exports.EngineModule.Fas, 'setPublicKeyForJson', pubKey);
|
|
495
|
-
});
|
|
470
|
+
async setConfig(config) {
|
|
471
|
+
this.config = Object.assign({}, this.config, config);
|
|
472
|
+
if (this.workerAndStreamPromise) {
|
|
473
|
+
const [worker, workerMessage$] = await this._preloadAndWaitReadyAsync();
|
|
474
|
+
await this._run(worker, workerMessage$, exports.EngineModule.Core, 'setConfig', this.config);
|
|
475
|
+
}
|
|
496
476
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
477
|
+
async setPublicKeyForJson(pubKey) {
|
|
478
|
+
const [worker, workerMessage$] = await this._preloadAndWaitReadyAsync();
|
|
479
|
+
await this._run(worker, workerMessage$, exports.EngineModule.Fas, 'setPublicKeyForJson', pubKey);
|
|
480
|
+
}
|
|
481
|
+
async _loadEngineAsync(worker, workerMessage$) {
|
|
482
|
+
var _this$config$scriptPa2, _this$config$scriptPa3, _this$config$scriptPa4, _this$config$scriptPa5, _MlEngine$_ENGINE_CAC;
|
|
483
|
+
// load js/wasm outside the worker.
|
|
484
|
+
const simdSupported = isSimdSupported();
|
|
485
|
+
const jsUrl = simdSupported ? `${(_this$config$scriptPa2 = this.config.scriptPath) != null ? _this$config$scriptPa2 : ''}ml_engine_web.simd.js` : `${(_this$config$scriptPa3 = this.config.scriptPath) != null ? _this$config$scriptPa3 : ''}ml_engine_web.js`;
|
|
486
|
+
const wasmUrl = simdSupported ? `${(_this$config$scriptPa4 = this.config.scriptPath) != null ? _this$config$scriptPa4 : ''}ml_engine_web.simd.wasm` : `${(_this$config$scriptPa5 = this.config.scriptPath) != null ? _this$config$scriptPa5 : ''}ml_engine_web.wasm`;
|
|
487
|
+
const durationTimeNetworkEngine = this.debugTools.setTimeDuration('loadEngine_network');
|
|
488
|
+
const [engineJsContent, engineWasmContent] = await ((_MlEngine$_ENGINE_CAC = MlEngine._ENGINE_CACHE) != null ? _MlEngine$_ENGINE_CAC : MlEngine._ENGINE_CACHE = Promise.all([getJsContentAsync(`${jsUrl}?t=${Date.now()}`), getWasmContentAsync(`${wasmUrl}?t=${Date.now()}`)]));
|
|
489
|
+
durationTimeNetworkEngine.end();
|
|
490
|
+
return await this._run(worker, workerMessage$, exports.EngineModule.Core, 'loadEngine', {
|
|
491
|
+
engineJsContent,
|
|
492
|
+
engineWasmContent
|
|
511
493
|
});
|
|
512
494
|
}
|
|
513
495
|
}
|
|
514
|
-
|
|
496
|
+
_MlEngine = MlEngine;
|
|
497
|
+
_MlEngine._ENGINE_CACHE = undefined;
|
|
515
498
|
class AuthmeEngineModuleBase {
|
|
516
499
|
constructor(engine) {
|
|
517
500
|
this._initPromise = undefined;
|
|
@@ -524,59 +507,57 @@ class AuthmeEngineModuleBase {
|
|
|
524
507
|
_engineRunAsync(command, value) {
|
|
525
508
|
return this.engine.run(this.moduleName, command, value);
|
|
526
509
|
}
|
|
527
|
-
_init() {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}) => modelVersion.name === name && modelVersion.version === version));
|
|
551
|
-
}
|
|
552
|
-
const loadSessions$ = rxjs.from(noLoadedModelVersions).pipe(rxjs.map(({
|
|
553
|
-
name,
|
|
554
|
-
version
|
|
555
|
-
}) => AuthmeEngineModuleBase._MODEL_CACHE[`${name}-${version}`]), rxjs.mergeAll(), rxjs.concatMap(({
|
|
556
|
-
modelVersion,
|
|
557
|
-
modelArrayBuffer
|
|
558
|
-
}) => rxjs.of(this._engineRunAsync('loadSession', {
|
|
559
|
-
modelVersion,
|
|
560
|
-
modelArrayBuffer
|
|
561
|
-
}))), rxjs.reduce((promises, item) => {
|
|
562
|
-
promises.push(item);
|
|
563
|
-
return promises;
|
|
564
|
-
}, []), rxjs.concatMap(promises => rxjs.defer(() => Promise.all(promises))));
|
|
565
|
-
yield rxjs.firstValueFrom(loadSessions$);
|
|
566
|
-
const result = yield this._engineRunAsync('init');
|
|
567
|
-
this.initialized = true;
|
|
568
|
-
return result;
|
|
569
|
-
} catch (error) {
|
|
570
|
-
logCollect('engine init error', JSON.stringify(error));
|
|
571
|
-
throw new core.AuthmeError(core.ErrorCode.ENGINE_MODULE_INIT_ERROR, error);
|
|
572
|
-
} finally {
|
|
573
|
-
this.initializing = false;
|
|
510
|
+
async _init() {
|
|
511
|
+
if (this.initialized) {
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
if (this.initializing) {
|
|
515
|
+
throw new core.AuthmeError(core.ErrorCode.ENGINE_MODULE_IS_INITIALIZING);
|
|
516
|
+
}
|
|
517
|
+
this.initializing = true;
|
|
518
|
+
try {
|
|
519
|
+
var _this$engine$getConfi;
|
|
520
|
+
const noLoadedModelVersions = await this._engineRunAsync('getNoLoadedModelVersions');
|
|
521
|
+
const noCachedModelVersions = noLoadedModelVersions.filter(({
|
|
522
|
+
name,
|
|
523
|
+
version
|
|
524
|
+
}) => !AuthmeEngineModuleBase._MODEL_CACHE[`${name}-${version}`]);
|
|
525
|
+
const newCachedValues = fetchModelContents(noCachedModelVersions.sort((a, b) => getDownloadOrder(a.name) - getDownloadOrder(b.name)), (_this$engine$getConfi = this.engine.getConfig().dataTransferMethod) != null ? _this$engine$getConfi : 'binary').pipe(rxjs.shareReplay());
|
|
526
|
+
for (const {
|
|
527
|
+
name,
|
|
528
|
+
version
|
|
529
|
+
} of noCachedModelVersions) {
|
|
530
|
+
AuthmeEngineModuleBase._MODEL_CACHE[`${name}-${version}`] = newCachedValues.pipe(rxjs.filter(({
|
|
531
|
+
modelVersion
|
|
532
|
+
}) => modelVersion.name === name && modelVersion.version === version));
|
|
574
533
|
}
|
|
575
|
-
|
|
534
|
+
const loadSessions$ = rxjs.from(noLoadedModelVersions).pipe(rxjs.map(({
|
|
535
|
+
name,
|
|
536
|
+
version
|
|
537
|
+
}) => AuthmeEngineModuleBase._MODEL_CACHE[`${name}-${version}`]), rxjs.mergeAll(), rxjs.concatMap(({
|
|
538
|
+
modelVersion,
|
|
539
|
+
modelArrayBuffer
|
|
540
|
+
}) => rxjs.of(this._engineRunAsync('loadSession', {
|
|
541
|
+
modelVersion,
|
|
542
|
+
modelArrayBuffer
|
|
543
|
+
}))), rxjs.reduce((promises, item) => {
|
|
544
|
+
promises.push(item);
|
|
545
|
+
return promises;
|
|
546
|
+
}, []), rxjs.concatMap(promises => rxjs.defer(() => Promise.all(promises))));
|
|
547
|
+
await rxjs.firstValueFrom(loadSessions$);
|
|
548
|
+
const result = await this._engineRunAsync('init');
|
|
549
|
+
this.initialized = true;
|
|
550
|
+
return result;
|
|
551
|
+
} catch (error) {
|
|
552
|
+
logCollect('engine init error', JSON.stringify(error));
|
|
553
|
+
throw new core.AuthmeError(core.ErrorCode.ENGINE_MODULE_INIT_ERROR, error);
|
|
554
|
+
} finally {
|
|
555
|
+
this.initializing = false;
|
|
556
|
+
}
|
|
576
557
|
}
|
|
577
558
|
init() {
|
|
578
|
-
var
|
|
579
|
-
return (
|
|
559
|
+
var _this$_initPromise;
|
|
560
|
+
return (_this$_initPromise = this._initPromise) != null ? _this$_initPromise : this._initPromise = this._init();
|
|
580
561
|
}
|
|
581
562
|
preloadAsync() {
|
|
582
563
|
return this.init();
|
|
@@ -594,66 +575,60 @@ class AuthmeEngineModuleBase {
|
|
|
594
575
|
setOption(params) {
|
|
595
576
|
return this._engineRunAsync('setOption', params);
|
|
596
577
|
}
|
|
597
|
-
recognition(data) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
debugInfo: {
|
|
613
|
-
inferenceTime: performance.now() - start
|
|
614
|
-
}
|
|
615
|
-
});
|
|
616
|
-
} catch (error) {
|
|
617
|
-
this.received = true;
|
|
618
|
-
logCollect('recognition error', JSON.stringify(error));
|
|
619
|
-
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_ERROR, error);
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
getDebugImageData(data) {
|
|
624
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
625
|
-
// status control
|
|
626
|
-
if (!this.received || !this.initialized || !this.setSized) {
|
|
627
|
-
logCollect('getDebugImageData recognition not available', JSON.stringify(core.ErrorCode.RECOGNITION_NOT_AVAILABLE));
|
|
628
|
-
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_NOT_AVAILABLE);
|
|
629
|
-
}
|
|
630
|
-
try {
|
|
631
|
-
this.received = false;
|
|
632
|
-
const start = performance.now();
|
|
633
|
-
const return$ = yield this._engineRunAsync('getDebugImage', {
|
|
634
|
-
data
|
|
635
|
-
});
|
|
636
|
-
this.received = true;
|
|
637
|
-
return$.debugInfo = {
|
|
578
|
+
async recognition(data) {
|
|
579
|
+
// status control
|
|
580
|
+
if (!this.received || !this.initialized || !this.setSized) {
|
|
581
|
+
logCollect('recognition not available', JSON.stringify(core.ErrorCode.RECOGNITION_NOT_AVAILABLE));
|
|
582
|
+
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_NOT_AVAILABLE);
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
this.received = false;
|
|
586
|
+
const start = performance.now();
|
|
587
|
+
const return$ = await this._engineRunAsync('recognition', {
|
|
588
|
+
data
|
|
589
|
+
});
|
|
590
|
+
this.received = true;
|
|
591
|
+
return Object.assign({}, return$, {
|
|
592
|
+
debugInfo: {
|
|
638
593
|
inferenceTime: performance.now() - start
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
});
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
} catch (error) {
|
|
597
|
+
this.received = true;
|
|
598
|
+
logCollect('recognition error', JSON.stringify(error));
|
|
599
|
+
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_ERROR, error);
|
|
600
|
+
}
|
|
647
601
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
602
|
+
async getDebugImageData(data) {
|
|
603
|
+
// status control
|
|
604
|
+
if (!this.received || !this.initialized || !this.setSized) {
|
|
605
|
+
logCollect('getDebugImageData recognition not available', JSON.stringify(core.ErrorCode.RECOGNITION_NOT_AVAILABLE));
|
|
606
|
+
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_NOT_AVAILABLE);
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
this.received = false;
|
|
610
|
+
const start = performance.now();
|
|
611
|
+
const return$ = await this._engineRunAsync('getDebugImage', {
|
|
612
|
+
data
|
|
653
613
|
});
|
|
654
|
-
this.
|
|
655
|
-
return
|
|
614
|
+
this.received = true;
|
|
615
|
+
return$.debugInfo = {
|
|
616
|
+
inferenceTime: performance.now() - start
|
|
617
|
+
};
|
|
618
|
+
return return$;
|
|
619
|
+
} catch (error) {
|
|
620
|
+
this.received = true;
|
|
621
|
+
logCollect('getDebugImageData recognition error', JSON.stringify(error));
|
|
622
|
+
throw new core.AuthmeError(core.ErrorCode.RECOGNITION_ERROR, error);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
async setFrameSize(width, height) {
|
|
626
|
+
const result = await this._engineRunAsync('setFrameSize', {
|
|
627
|
+
width,
|
|
628
|
+
height
|
|
656
629
|
});
|
|
630
|
+
this.setSized = true;
|
|
631
|
+
return result;
|
|
657
632
|
}
|
|
658
633
|
getParams() {
|
|
659
634
|
return this._engineRunAsync('getParams');
|
|
@@ -668,38 +643,30 @@ class AuthmeEngineModuleBase {
|
|
|
668
643
|
positions
|
|
669
644
|
});
|
|
670
645
|
}
|
|
671
|
-
encryptString(str, key) {
|
|
672
|
-
return
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
key
|
|
676
|
-
});
|
|
646
|
+
async encryptString(str, key) {
|
|
647
|
+
return await this._engineRunAsync('encryptString', {
|
|
648
|
+
string: str,
|
|
649
|
+
key
|
|
677
650
|
});
|
|
678
651
|
}
|
|
679
|
-
encryptBlob(uint8Array, key) {
|
|
680
|
-
return
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
key
|
|
684
|
-
});
|
|
652
|
+
async encryptBlob(uint8Array, key) {
|
|
653
|
+
return await this._engineRunAsync('encryptBlob', {
|
|
654
|
+
uint8Array: uint8Array,
|
|
655
|
+
key
|
|
685
656
|
});
|
|
686
657
|
}
|
|
687
658
|
// 測試圖片上傳加密用,未來實作後請刪除。
|
|
688
|
-
_decryptString(str, key) {
|
|
689
|
-
return
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
key
|
|
693
|
-
});
|
|
659
|
+
async _decryptString(str, key) {
|
|
660
|
+
return await this._engineRunAsync('_decryptString', {
|
|
661
|
+
string: str,
|
|
662
|
+
key
|
|
694
663
|
});
|
|
695
664
|
}
|
|
696
|
-
destroy() {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return true;
|
|
702
|
-
});
|
|
665
|
+
async destroy() {
|
|
666
|
+
await this._engineRunAsync('destroy');
|
|
667
|
+
this.initialized = false;
|
|
668
|
+
this._initPromise = undefined;
|
|
669
|
+
return true;
|
|
703
670
|
}
|
|
704
671
|
getUIParams() {
|
|
705
672
|
return this.engine.run(this.moduleName, 'getUIParams');
|
|
@@ -711,7 +678,8 @@ class AuthmeEngineModuleBase {
|
|
|
711
678
|
this._MODEL_CACHE = {};
|
|
712
679
|
}
|
|
713
680
|
}
|
|
714
|
-
|
|
681
|
+
_AuthmeEngineModuleBase = AuthmeEngineModuleBase;
|
|
682
|
+
_AuthmeEngineModuleBase._MODEL_CACHE = {};
|
|
715
683
|
|
|
716
684
|
exports.AuthmeEngineModuleBase = AuthmeEngineModuleBase;
|
|
717
685
|
exports.AuthmeFunctionModule = AuthmeFunctionModule;
|