@authme/engine 2.7.4 → 2.8.1-rc.1

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/index.cjs CHANGED
@@ -245,9 +245,9 @@ const defaultMlEngineConfig = {
245
245
  };
246
246
 
247
247
  var name = "authme/sdk";
248
- var version$1 = "2.7.4";
249
- var date = "2024-12-04T02:44:31+0000";
250
- var packageInfo = {
248
+ var version$1 = "2.8.1-rc.1";
249
+ var date = "2025-06-10T11:06:25+0000";
250
+ var sdkInfo = {
251
251
  name: name,
252
252
  version: version$1,
253
253
  date: date
@@ -255,9 +255,23 @@ var packageInfo = {
255
255
 
256
256
  var _a;
257
257
  var _b, _c;
258
- const version = packageInfo.version;
258
+ const version = sdkInfo.version;
259
259
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
260
- window[Symbol.for('authme-sdk')][packageInfo.name] = version;
260
+ window[Symbol.for('authme-sdk')][sdkInfo.name] = version;
261
+
262
+ function logCollect(message, stackTrace) {
263
+ const body = {
264
+ message: message,
265
+ stack_trace: stackTrace,
266
+ metadata: {
267
+ platform: 'web',
268
+ sdkVersion: sdkInfo.version
269
+ }
270
+ };
271
+ return core.sendRequest('/api/identity-verification/v1/logs/collect', 'POST', {
272
+ body: JSON.stringify(body)
273
+ });
274
+ }
261
275
 
262
276
  const getDownloadOrder = function () {
263
277
  // model 越大,在後續 worker service 載入與解密的時間越長,
@@ -403,8 +417,9 @@ class MlEngine {
403
417
  // * https://web.dev/workers-basics/
404
418
  const worker = yield createWorkerWithObjectUrlAsync(`${(_a = this.config.scriptPath) !== null && _a !== void 0 ? _a : ''}engine-worker.js?t=${Date.now()}`);
405
419
  const workerMessage$ = rxjs.fromEvent(worker, 'message').pipe(rxjs.map(x => {
406
- var _a, _b;
420
+ var _a, _b, _c, _d;
407
421
  if ((_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.error) {
422
+ logCollect('workerMessage error', JSON.stringify((_d = (_c = x.data) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.error));
408
423
  throw new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, 'unexpected worker error');
409
424
  }
410
425
  return x.data;
@@ -440,6 +455,7 @@ class MlEngine {
440
455
  return __awaiter(this, void 0, void 0, function* () {
441
456
  const problem = yield this._run(worker, workerMessage$, 'Core', 'checkEnumConsistency', Object.assign(Object.assign(Object.assign({}, authEnumModule), idRecognitionEnumModule), fasRecognitionEnumModule));
442
457
  if (problem.length > 0) {
458
+ logCollect('enum consistency problem', JSON.stringify(problem));
443
459
  throw new core.AuthmeError(core.ErrorCode.SDK_INTERNAL_ERROR, {
444
460
  problem
445
461
  });
@@ -543,6 +559,7 @@ class AuthmeEngineModuleBase {
543
559
  this.initialized = true;
544
560
  return result;
545
561
  } catch (error) {
562
+ logCollect('engine init error', JSON.stringify(error));
546
563
  throw new core.AuthmeError(core.ErrorCode.ENGINE_MODULE_INIT_ERROR, error);
547
564
  } finally {
548
565
  this.initializing = false;
@@ -573,6 +590,7 @@ class AuthmeEngineModuleBase {
573
590
  return __awaiter(this, void 0, void 0, function* () {
574
591
  // status control
575
592
  if (!this.received || !this.initialized || !this.setSized) {
593
+ logCollect('recognition not available', JSON.stringify(core.ErrorCode.RECOGNITION_NOT_AVAILABLE));
576
594
  throw new core.AuthmeError(core.ErrorCode.RECOGNITION_NOT_AVAILABLE);
577
595
  }
578
596
  try {
@@ -589,6 +607,7 @@ class AuthmeEngineModuleBase {
589
607
  });
590
608
  } catch (error) {
591
609
  this.received = true;
610
+ logCollect('recognition error', JSON.stringify(error));
592
611
  throw new core.AuthmeError(core.ErrorCode.RECOGNITION_ERROR, error);
593
612
  }
594
613
  });
@@ -597,6 +616,7 @@ class AuthmeEngineModuleBase {
597
616
  return __awaiter(this, void 0, void 0, function* () {
598
617
  // status control
599
618
  if (!this.received || !this.initialized || !this.setSized) {
619
+ logCollect('getDebugImageData recognition not available', JSON.stringify(core.ErrorCode.RECOGNITION_NOT_AVAILABLE));
600
620
  throw new core.AuthmeError(core.ErrorCode.RECOGNITION_NOT_AVAILABLE);
601
621
  }
602
622
  try {
@@ -612,6 +632,7 @@ class AuthmeEngineModuleBase {
612
632
  return return$;
613
633
  } catch (error) {
614
634
  this.received = true;
635
+ logCollect('getDebugImageData recognition error', JSON.stringify(error));
615
636
  throw new core.AuthmeError(core.ErrorCode.RECOGNITION_ERROR, error);
616
637
  }
617
638
  });
package/index.js CHANGED
@@ -15,7 +15,7 @@ import 'core-js/modules/es.parse-int.js';
15
15
  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
- import { AuthmeError, ErrorCode, sendRequest } from '@authme/core';
18
+ import { sendRequest, AuthmeError, ErrorCode } from '@authme/core';
19
19
  import { debugTools, isMobile, Storage } from '@authme/util';
20
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';
@@ -241,9 +241,9 @@ const defaultMlEngineConfig = {
241
241
  };
242
242
 
243
243
  var name = "authme/sdk";
244
- var version$1 = "2.7.4";
245
- var date = "2024-12-04T02:44:31+0000";
246
- var packageInfo = {
244
+ var version$1 = "2.8.1-rc.1";
245
+ var date = "2025-06-10T11:06:25+0000";
246
+ var sdkInfo = {
247
247
  name: name,
248
248
  version: version$1,
249
249
  date: date
@@ -251,9 +251,23 @@ var packageInfo = {
251
251
 
252
252
  var _a;
253
253
  var _b, _c;
254
- const version = packageInfo.version;
254
+ const version = sdkInfo.version;
255
255
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
256
- window[Symbol.for('authme-sdk')][packageInfo.name] = version;
256
+ window[Symbol.for('authme-sdk')][sdkInfo.name] = version;
257
+
258
+ function logCollect(message, stackTrace) {
259
+ const body = {
260
+ message: message,
261
+ stack_trace: stackTrace,
262
+ metadata: {
263
+ platform: 'web',
264
+ sdkVersion: sdkInfo.version
265
+ }
266
+ };
267
+ return sendRequest('/api/identity-verification/v1/logs/collect', 'POST', {
268
+ body: JSON.stringify(body)
269
+ });
270
+ }
257
271
 
258
272
  const getDownloadOrder = function () {
259
273
  // model 越大,在後續 worker service 載入與解密的時間越長,
@@ -399,8 +413,9 @@ class MlEngine {
399
413
  // * https://web.dev/workers-basics/
400
414
  const worker = yield createWorkerWithObjectUrlAsync(`${(_a = this.config.scriptPath) !== null && _a !== void 0 ? _a : ''}engine-worker.js?t=${Date.now()}`);
401
415
  const workerMessage$ = fromEvent(worker, 'message').pipe(map(x => {
402
- var _a, _b;
416
+ var _a, _b, _c, _d;
403
417
  if ((_b = (_a = x.data) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.error) {
418
+ logCollect('workerMessage error', JSON.stringify((_d = (_c = x.data) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.error));
404
419
  throw new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, 'unexpected worker error');
405
420
  }
406
421
  return x.data;
@@ -436,6 +451,7 @@ class MlEngine {
436
451
  return __awaiter(this, void 0, void 0, function* () {
437
452
  const problem = yield this._run(worker, workerMessage$, 'Core', 'checkEnumConsistency', Object.assign(Object.assign(Object.assign({}, authEnumModule), idRecognitionEnumModule), fasRecognitionEnumModule));
438
453
  if (problem.length > 0) {
454
+ logCollect('enum consistency problem', JSON.stringify(problem));
439
455
  throw new AuthmeError(ErrorCode.SDK_INTERNAL_ERROR, {
440
456
  problem
441
457
  });
@@ -539,6 +555,7 @@ class AuthmeEngineModuleBase {
539
555
  this.initialized = true;
540
556
  return result;
541
557
  } catch (error) {
558
+ logCollect('engine init error', JSON.stringify(error));
542
559
  throw new AuthmeError(ErrorCode.ENGINE_MODULE_INIT_ERROR, error);
543
560
  } finally {
544
561
  this.initializing = false;
@@ -569,6 +586,7 @@ class AuthmeEngineModuleBase {
569
586
  return __awaiter(this, void 0, void 0, function* () {
570
587
  // status control
571
588
  if (!this.received || !this.initialized || !this.setSized) {
589
+ logCollect('recognition not available', JSON.stringify(ErrorCode.RECOGNITION_NOT_AVAILABLE));
572
590
  throw new AuthmeError(ErrorCode.RECOGNITION_NOT_AVAILABLE);
573
591
  }
574
592
  try {
@@ -585,6 +603,7 @@ class AuthmeEngineModuleBase {
585
603
  });
586
604
  } catch (error) {
587
605
  this.received = true;
606
+ logCollect('recognition error', JSON.stringify(error));
588
607
  throw new AuthmeError(ErrorCode.RECOGNITION_ERROR, error);
589
608
  }
590
609
  });
@@ -593,6 +612,7 @@ class AuthmeEngineModuleBase {
593
612
  return __awaiter(this, void 0, void 0, function* () {
594
613
  // status control
595
614
  if (!this.received || !this.initialized || !this.setSized) {
615
+ logCollect('getDebugImageData recognition not available', JSON.stringify(ErrorCode.RECOGNITION_NOT_AVAILABLE));
596
616
  throw new AuthmeError(ErrorCode.RECOGNITION_NOT_AVAILABLE);
597
617
  }
598
618
  try {
@@ -608,6 +628,7 @@ class AuthmeEngineModuleBase {
608
628
  return return$;
609
629
  } catch (error) {
610
630
  this.received = true;
631
+ logCollect('getDebugImageData recognition error', JSON.stringify(error));
611
632
  throw new AuthmeError(ErrorCode.RECOGNITION_ERROR, error);
612
633
  }
613
634
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@authme/engine",
3
- "version": "2.7.4",
3
+ "version": "2.8.1-rc.1",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
6
  "rxjs": "^7.4.0",
7
- "@authme/core": "2.7.4",
8
- "@authme/util": "2.7.4"
7
+ "@authme/core": "2.8.1-rc.1",
8
+ "@authme/util": "2.8.1-rc.1"
9
9
  },
10
10
  "module": "./index.js",
11
11
  "main": "./index.cjs",
@@ -0,0 +1 @@
1
+ export declare function logCollect(message: string, stackTrace: string): Promise<any>;