@authme/id-recognition 2.4.2 → 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.
package/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ require('core-js/modules/es.object.assign.js');
5
6
  var engine = require('@authme/engine');
6
7
  require('core-js/modules/es.array.iterator.js');
7
8
  require('core-js/modules/es.object.from-entries.js');
@@ -42,6 +43,11 @@ exports.ServerSideEAuthMeCardClass = void 0;
42
43
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
43
44
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
44
45
  })(exports.ServerSideEAuthMeCardClass || (exports.ServerSideEAuthMeCardClass = {}));
46
+ exports.RecognitionFileType = void 0;
47
+ (function (RecognitionFileType) {
48
+ RecognitionFileType["OriginImage"] = "OriginImage";
49
+ RecognitionFileType["FlatImage"] = "FlatImage";
50
+ })(exports.RecognitionFileType || (exports.RecognitionFileType = {}));
45
51
 
46
52
  class CardOCR extends engine.AuthmeEngineModuleBase {
47
53
  constructor(engine$1) {
@@ -49,16 +55,22 @@ class CardOCR extends engine.AuthmeEngineModuleBase {
49
55
  this.type = engine.EAuthMeCardClass.Invalid;
50
56
  this.moduleName = engine.EngineModule.CardOCR;
51
57
  }
52
- setType(type, options) {
58
+ setType(type) {
53
59
  this.type = type;
54
60
  return this.engine.run(this.moduleName, 'setType', {
55
- type,
56
- options
61
+ type
57
62
  });
58
63
  }
59
64
  getType() {
60
65
  return this.type;
61
66
  }
67
+ setParams(params) {
68
+ var _a;
69
+ if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === engine.EAuthMeCardClass.Invalid) throw new Error('Please set type first');
70
+ return this.engine.run(this.moduleName, 'setParams', Object.assign({
71
+ type: this.type
72
+ }, params));
73
+ }
62
74
  }
63
75
  class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
64
76
  constructor(engine$1) {
@@ -69,6 +81,9 @@ class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
69
81
  const stageStrList = stageList.map(x => x.split('_')[1]);
70
82
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
71
83
  }
84
+ getCardMatchROI() {
85
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
86
+ }
72
87
  }
73
88
  class MRZService extends engine.AuthmeEngineModuleBase {
74
89
  constructor(engine$1, type = 'passport') {
@@ -180,12 +195,12 @@ function recognition(documentId, file) {
180
195
  throw error;
181
196
  });
182
197
  }
183
- function recognitionEncrypt(documentId, base64Text, report) {
198
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
184
199
  return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
185
200
  body: JSON.stringify({
186
201
  scanDocumentId: documentId,
187
202
  image: base64Text,
188
- fileType: 'image/jpeg',
203
+ fileType: fileType,
189
204
  info: {
190
205
  report
191
206
  }
@@ -202,6 +217,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
202
217
  throw error;
203
218
  });
204
219
  }
220
+ function uploadFrameBase64(documentId, base64Text, index, type = exports.ResourceImageType.Recognition, report) {
221
+ return core.sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
222
+ body: JSON.stringify({
223
+ scanDocumentId: documentId,
224
+ image: base64Text,
225
+ type,
226
+ // fileType: 'image/jpeg',
227
+ info: {
228
+ report,
229
+ index
230
+ }
231
+ }),
232
+ contentType: 'application/json'
233
+ }).catch(error => {
234
+ var _a, _b, _c;
235
+ if (error instanceof core.AuthmeError && ((_c = (_b = (_a = error.cause) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) === 'AuthMe.IDRecognition:000201') {
236
+ return {
237
+ retry: true,
238
+ details: {}
239
+ };
240
+ }
241
+ throw error;
242
+ });
243
+ }
205
244
  function saveResourceImage(documentId, type, file) {
206
245
  const formData = new FormData();
207
246
  formData.append('scanDocumentId', documentId);
@@ -245,7 +284,7 @@ function saveExtraDoc(params) {
245
284
  }
246
285
 
247
286
  var name = "@authme/id-recognition";
248
- var version$1 = "2.4.2";
287
+ var version$1 = "2.4.5";
249
288
  var peerDependencies = {
250
289
  "core-js": "^3.6.0"
251
290
  };
@@ -304,4 +343,5 @@ exports.recognitionEncrypt = recognitionEncrypt;
304
343
  exports.saveExtraDoc = saveExtraDoc;
305
344
  exports.saveResourceImage = saveResourceImage;
306
345
  exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
346
+ exports.uploadFrameBase64 = uploadFrameBase64;
307
347
  exports.version = version;
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import 'core-js/modules/es.object.assign.js';
1
2
  import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/engine';
2
3
  export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '@authme/engine';
3
4
  import 'core-js/modules/es.array.iterator.js';
@@ -39,6 +40,11 @@ var ServerSideEAuthMeCardClass;
39
40
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
40
41
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
41
42
  })(ServerSideEAuthMeCardClass || (ServerSideEAuthMeCardClass = {}));
43
+ var RecognitionFileType;
44
+ (function (RecognitionFileType) {
45
+ RecognitionFileType["OriginImage"] = "OriginImage";
46
+ RecognitionFileType["FlatImage"] = "FlatImage";
47
+ })(RecognitionFileType || (RecognitionFileType = {}));
42
48
 
43
49
  class CardOCR extends AuthmeEngineModuleBase {
44
50
  constructor(engine) {
@@ -46,16 +52,22 @@ class CardOCR extends AuthmeEngineModuleBase {
46
52
  this.type = EAuthMeCardClass.Invalid;
47
53
  this.moduleName = EngineModule.CardOCR;
48
54
  }
49
- setType(type, options) {
55
+ setType(type) {
50
56
  this.type = type;
51
57
  return this.engine.run(this.moduleName, 'setType', {
52
- type,
53
- options
58
+ type
54
59
  });
55
60
  }
56
61
  getType() {
57
62
  return this.type;
58
63
  }
64
+ setParams(params) {
65
+ var _a;
66
+ if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === EAuthMeCardClass.Invalid) throw new Error('Please set type first');
67
+ return this.engine.run(this.moduleName, 'setParams', Object.assign({
68
+ type: this.type
69
+ }, params));
70
+ }
59
71
  }
60
72
  class IdCardAntiFraudService extends AuthmeEngineModuleBase {
61
73
  constructor(engine) {
@@ -66,6 +78,9 @@ class IdCardAntiFraudService extends AuthmeEngineModuleBase {
66
78
  const stageStrList = stageList.map(x => x.split('_')[1]);
67
79
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
68
80
  }
81
+ getCardMatchROI() {
82
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
83
+ }
69
84
  }
70
85
  class MRZService extends AuthmeEngineModuleBase {
71
86
  constructor(engine, type = 'passport') {
@@ -177,12 +192,12 @@ function recognition(documentId, file) {
177
192
  throw error;
178
193
  });
179
194
  }
180
- function recognitionEncrypt(documentId, base64Text, report) {
195
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
181
196
  return sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
182
197
  body: JSON.stringify({
183
198
  scanDocumentId: documentId,
184
199
  image: base64Text,
185
- fileType: 'image/jpeg',
200
+ fileType: fileType,
186
201
  info: {
187
202
  report
188
203
  }
@@ -199,6 +214,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
199
214
  throw error;
200
215
  });
201
216
  }
217
+ function uploadFrameBase64(documentId, base64Text, index, type = ResourceImageType.Recognition, report) {
218
+ return sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
219
+ body: JSON.stringify({
220
+ scanDocumentId: documentId,
221
+ image: base64Text,
222
+ type,
223
+ // fileType: 'image/jpeg',
224
+ info: {
225
+ report,
226
+ index
227
+ }
228
+ }),
229
+ contentType: 'application/json'
230
+ }).catch(error => {
231
+ var _a, _b, _c;
232
+ if (error instanceof AuthmeError && ((_c = (_b = (_a = error.cause) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) === 'AuthMe.IDRecognition:000201') {
233
+ return {
234
+ retry: true,
235
+ details: {}
236
+ };
237
+ }
238
+ throw error;
239
+ });
240
+ }
202
241
  function saveResourceImage(documentId, type, file) {
203
242
  const formData = new FormData();
204
243
  formData.append('scanDocumentId', documentId);
@@ -242,7 +281,7 @@ function saveExtraDoc(params) {
242
281
  }
243
282
 
244
283
  var name = "@authme/id-recognition";
245
- var version$1 = "2.4.2";
284
+ var version$1 = "2.4.5";
246
285
  var peerDependencies = {
247
286
  "core-js": "^3.6.0"
248
287
  };
@@ -258,4 +297,4 @@ const version = packageInfo.version;
258
297
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
259
298
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
260
299
 
261
- export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, version };
300
+ export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, RecognitionFileType, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, uploadFrameBase64, version };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@authme/id-recognition",
3
- "version": "2.4.2",
3
+ "version": "2.4.5",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/core": "2.4.2",
7
- "@authme/engine": "2.4.2"
6
+ "@authme/core": "2.4.5",
7
+ "@authme/engine": "2.4.5"
8
8
  },
9
9
  "module": "./index.js",
10
10
  "main": "./index.cjs",
@@ -1,4 +1,4 @@
1
- import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
1
+ import { CountryCode, IdRecognitionCardType, RecognitionFileType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
2
2
  import { InitScanResponse } from '../model';
3
3
  export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean, encrypt?: boolean): Promise<InitScanResponse>;
4
4
  export declare function initScanDocument(scanId: string, cardType: `${ServerSideEAuthMeCardClass}`): Promise<{
@@ -10,7 +10,13 @@ export declare function recognition(documentId: string, file: Blob): Promise<{
10
10
  [key: string]: string | null;
11
11
  };
12
12
  }>;
13
- export declare function recognitionEncrypt(documentId: string, base64Text: string, report: string): Promise<{
13
+ export declare function recognitionEncrypt(documentId: string, base64Text: string, report: string, fileType: RecognitionFileType): Promise<{
14
+ retry?: boolean;
15
+ details: {
16
+ [key: string]: string | null;
17
+ };
18
+ }>;
19
+ export declare function uploadFrameBase64(documentId: string, base64Text: string, index: number, type?: ResourceImageType, report?: string): Promise<{
14
20
  retry?: boolean;
15
21
  details: {
16
22
  [key: string]: string | null;
@@ -28,3 +28,7 @@ export declare enum ServerSideEAuthMeCardClass {
28
28
  TWN_HealthCard_Front = "TWN_HealthCard_Front",
29
29
  TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
30
30
  }
31
+ export declare enum RecognitionFileType {
32
+ OriginImage = "OriginImage",
33
+ FlatImage = "FlatImage"
34
+ }
@@ -14,5 +14,13 @@ export interface InitScanResponse {
14
14
  fraudTimeout: number;
15
15
  fraudMaxFps: number;
16
16
  pubKey: string;
17
+ fraud?: {
18
+ collectAllFrames: boolean;
19
+ maxFps: number;
20
+ retryTimes: number;
21
+ stages: Array<unknown>;
22
+ timeout: number;
23
+ totalTimeout: number;
24
+ };
17
25
  };
18
26
  }
@@ -4,14 +4,18 @@ import { EAuthMeCardClass, EAuthMeIDCardAntiFraudStage } from './enum';
4
4
  export declare class CardOCR extends AuthmeEngineModuleBase<CardOCRResult> {
5
5
  private type;
6
6
  constructor(engine: MlEngine);
7
- setType(type: EAuthMeCardClass, options?: {
8
- [key: string]: unknown;
9
- }): Promise<unknown>;
7
+ setType(type: EAuthMeCardClass): Promise<unknown>;
10
8
  getType(): EAuthMeCardClass;
9
+ setParams(params: any): Promise<unknown>;
10
+ }
11
+ export interface Point {
12
+ x: number;
13
+ y: number;
11
14
  }
12
15
  export declare class IdCardAntiFraudService extends AuthmeEngineModuleBase<IDCardAntiFraudResult> {
13
16
  constructor(engine: MlEngine);
14
17
  setStage(stageList: EAuthMeIDCardAntiFraudStage[]): Promise<unknown>;
18
+ getCardMatchROI(): Promise<Point[]>;
15
19
  }
16
20
  export declare class MRZService<T extends PassportResult | ResidentCardResult> extends AuthmeEngineModuleBase<T> {
17
21
  private type;