@authme/id-recognition 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/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');
@@ -18,6 +19,7 @@ exports.ResourceImageType = void 0;
18
19
  exports.CountryCode = void 0;
19
20
  (function (CountryCode) {
20
21
  CountryCode["TWN"] = "TWN";
22
+ CountryCode["JPW"] = "JP";
21
23
  })(exports.CountryCode || (exports.CountryCode = {}));
22
24
  exports.IdRecognitionCardType = void 0;
23
25
  (function (IdRecognitionCardType) {
@@ -41,6 +43,11 @@ exports.ServerSideEAuthMeCardClass = void 0;
41
43
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
42
44
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
43
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 = {}));
44
51
 
45
52
  class CardOCR extends engine.AuthmeEngineModuleBase {
46
53
  constructor(engine$1) {
@@ -57,6 +64,13 @@ class CardOCR extends engine.AuthmeEngineModuleBase {
57
64
  getType() {
58
65
  return this.type;
59
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
+ }
60
74
  }
61
75
  class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
62
76
  constructor(engine$1) {
@@ -67,11 +81,19 @@ class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
67
81
  const stageStrList = stageList.map(x => x.split('_')[1]);
68
82
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
69
83
  }
84
+ getCardMatchROI() {
85
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
86
+ }
70
87
  }
71
88
  class MRZService extends engine.AuthmeEngineModuleBase {
72
- constructor(engine$1) {
89
+ constructor(engine$1, type = 'passport') {
73
90
  super(engine$1);
74
- this.moduleName = engine.EngineModule.PassportService;
91
+ this.type = type;
92
+ if (this.type === 'passport') {
93
+ this.moduleName = engine.EngineModule.MRZPassportService;
94
+ } else if (this.type === 'residentCard') {
95
+ this.moduleName = engine.EngineModule.MRZResidentCardService;
96
+ }
75
97
  }
76
98
  getFinalResult() {
77
99
  return this.engine.run(this.moduleName, 'getFinalResult');
@@ -135,11 +157,12 @@ const twoWayAuthmeCardClassMap = (() => {
135
157
  };
136
158
  })();
137
159
 
138
- function init(type, country, needConfirm) {
160
+ function init(type, country, needConfirm, encrypt = true) {
139
161
  const body = {
140
162
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
141
163
  cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
142
- needConfirm
164
+ needConfirm,
165
+ encrypt
143
166
  };
144
167
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
145
168
  body: JSON.stringify(body)
@@ -172,6 +195,52 @@ function recognition(documentId, file) {
172
195
  throw error;
173
196
  });
174
197
  }
198
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
199
+ return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
200
+ body: JSON.stringify({
201
+ scanDocumentId: documentId,
202
+ image: base64Text,
203
+ fileType: fileType,
204
+ info: {
205
+ report
206
+ }
207
+ }),
208
+ contentType: 'application/json'
209
+ }).catch(error => {
210
+ var _a, _b, _c;
211
+ 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') {
212
+ return {
213
+ retry: true,
214
+ details: {}
215
+ };
216
+ }
217
+ throw error;
218
+ });
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
+ }
175
244
  function saveResourceImage(documentId, type, file) {
176
245
  const formData = new FormData();
177
246
  formData.append('scanDocumentId', documentId);
@@ -215,7 +284,7 @@ function saveExtraDoc(params) {
215
284
  }
216
285
 
217
286
  var name = "@authme/id-recognition";
218
- var version$1 = "2.3.1-rc.3";
287
+ var version$1 = "2.4.6";
219
288
  var peerDependencies = {
220
289
  "core-js": "^3.6.0"
221
290
  };
@@ -255,9 +324,9 @@ Object.defineProperty(exports, 'EAuthMeMRZRecogStatus', {
255
324
  enumerable: true,
256
325
  get: function () { return engine.EAuthMeMRZRecogStatus; }
257
326
  });
258
- Object.defineProperty(exports, 'EAuthMePassportServiceStatus', {
327
+ Object.defineProperty(exports, 'EAuthMeMRZServiceStatus', {
259
328
  enumerable: true,
260
- get: function () { return engine.EAuthMePassportServiceStatus; }
329
+ get: function () { return engine.EAuthMeMRZServiceStatus; }
261
330
  });
262
331
  exports.CardOCR = CardOCR;
263
332
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
@@ -270,7 +339,9 @@ exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
270
339
  exports.init = init;
271
340
  exports.initScanDocument = initScanDocument;
272
341
  exports.recognition = recognition;
342
+ exports.recognitionEncrypt = recognitionEncrypt;
273
343
  exports.saveExtraDoc = saveExtraDoc;
274
344
  exports.saveResourceImage = saveResourceImage;
275
345
  exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
346
+ exports.uploadFrameBase64 = uploadFrameBase64;
276
347
  exports.version = version;
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import 'core-js/modules/es.object.assign.js';
1
2
  import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/engine';
2
- export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus } from '@authme/engine';
3
+ export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '@authme/engine';
3
4
  import 'core-js/modules/es.array.iterator.js';
4
5
  import 'core-js/modules/es.object.from-entries.js';
5
6
  import 'core-js/modules/web.dom-collections.iterator.js';
@@ -15,6 +16,7 @@ var ResourceImageType;
15
16
  var CountryCode;
16
17
  (function (CountryCode) {
17
18
  CountryCode["TWN"] = "TWN";
19
+ CountryCode["JPW"] = "JP";
18
20
  })(CountryCode || (CountryCode = {}));
19
21
  var IdRecognitionCardType;
20
22
  (function (IdRecognitionCardType) {
@@ -38,6 +40,11 @@ var ServerSideEAuthMeCardClass;
38
40
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
39
41
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
40
42
  })(ServerSideEAuthMeCardClass || (ServerSideEAuthMeCardClass = {}));
43
+ var RecognitionFileType;
44
+ (function (RecognitionFileType) {
45
+ RecognitionFileType["OriginImage"] = "OriginImage";
46
+ RecognitionFileType["FlatImage"] = "FlatImage";
47
+ })(RecognitionFileType || (RecognitionFileType = {}));
41
48
 
42
49
  class CardOCR extends AuthmeEngineModuleBase {
43
50
  constructor(engine) {
@@ -54,6 +61,13 @@ class CardOCR extends AuthmeEngineModuleBase {
54
61
  getType() {
55
62
  return this.type;
56
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
+ }
57
71
  }
58
72
  class IdCardAntiFraudService extends AuthmeEngineModuleBase {
59
73
  constructor(engine) {
@@ -64,11 +78,19 @@ class IdCardAntiFraudService extends AuthmeEngineModuleBase {
64
78
  const stageStrList = stageList.map(x => x.split('_')[1]);
65
79
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
66
80
  }
81
+ getCardMatchROI() {
82
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
83
+ }
67
84
  }
68
85
  class MRZService extends AuthmeEngineModuleBase {
69
- constructor(engine) {
86
+ constructor(engine, type = 'passport') {
70
87
  super(engine);
71
- this.moduleName = EngineModule.PassportService;
88
+ this.type = type;
89
+ if (this.type === 'passport') {
90
+ this.moduleName = EngineModule.MRZPassportService;
91
+ } else if (this.type === 'residentCard') {
92
+ this.moduleName = EngineModule.MRZResidentCardService;
93
+ }
72
94
  }
73
95
  getFinalResult() {
74
96
  return this.engine.run(this.moduleName, 'getFinalResult');
@@ -132,11 +154,12 @@ const twoWayAuthmeCardClassMap = (() => {
132
154
  };
133
155
  })();
134
156
 
135
- function init(type, country, needConfirm) {
157
+ function init(type, country, needConfirm, encrypt = true) {
136
158
  const body = {
137
159
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
138
160
  cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
139
- needConfirm
161
+ needConfirm,
162
+ encrypt
140
163
  };
141
164
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
142
165
  body: JSON.stringify(body)
@@ -169,6 +192,52 @@ function recognition(documentId, file) {
169
192
  throw error;
170
193
  });
171
194
  }
195
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
196
+ return sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
197
+ body: JSON.stringify({
198
+ scanDocumentId: documentId,
199
+ image: base64Text,
200
+ fileType: fileType,
201
+ info: {
202
+ report
203
+ }
204
+ }),
205
+ contentType: 'application/json'
206
+ }).catch(error => {
207
+ var _a, _b, _c;
208
+ 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') {
209
+ return {
210
+ retry: true,
211
+ details: {}
212
+ };
213
+ }
214
+ throw error;
215
+ });
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
+ }
172
241
  function saveResourceImage(documentId, type, file) {
173
242
  const formData = new FormData();
174
243
  formData.append('scanDocumentId', documentId);
@@ -212,7 +281,7 @@ function saveExtraDoc(params) {
212
281
  }
213
282
 
214
283
  var name = "@authme/id-recognition";
215
- var version$1 = "2.3.1-rc.3";
284
+ var version$1 = "2.4.6";
216
285
  var peerDependencies = {
217
286
  "core-js": "^3.6.0"
218
287
  };
@@ -228,4 +297,4 @@ const version = packageInfo.version;
228
297
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
229
298
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
230
299
 
231
- export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, 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.3.1-rc.3",
3
+ "version": "2.4.6",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/core": "2.3.1-rc.3",
7
- "@authme/engine": "2.3.1-rc.3"
6
+ "@authme/core": "2.4.6",
7
+ "@authme/engine": "2.4.6"
8
8
  },
9
9
  "module": "./index.js",
10
10
  "main": "./index.cjs",
@@ -1,6 +1,6 @@
1
- import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
1
+ import { CountryCode, IdRecognitionCardType, RecognitionFileType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
2
2
  import { InitScanResponse } from '../model';
3
- export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean): Promise<InitScanResponse>;
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<{
5
5
  scanDocumentId: string;
6
6
  }>;
@@ -10,6 +10,18 @@ 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, 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<{
20
+ retry?: boolean;
21
+ details: {
22
+ [key: string]: string | null;
23
+ };
24
+ }>;
13
25
  export declare function saveResourceImage(documentId: string, type: ResourceImageType, file: Blob): Promise<any>;
14
26
  export declare function finishScanDocument(documentId: string, details: {
15
27
  [key: string]: string | null;
@@ -1,11 +1,12 @@
1
- export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus, } from '@authme/engine';
1
+ export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus, } from '@authme/engine';
2
2
  export declare enum ResourceImageType {
3
3
  Recognition = "Recognition",
4
4
  Fraud = "Fraud",
5
5
  Manual = "Manual"
6
6
  }
7
7
  export declare enum CountryCode {
8
- TWN = "TWN"
8
+ TWN = "TWN",
9
+ JPW = "JP"
9
10
  }
10
11
  export declare enum IdRecognitionCardType {
11
12
  IDCard = "IDCard",
@@ -27,3 +28,7 @@ export declare enum ServerSideEAuthMeCardClass {
27
28
  TWN_HealthCard_Front = "TWN_HealthCard_Front",
28
29
  TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
29
30
  }
31
+ export declare enum RecognitionFileType {
32
+ OriginImage = "OriginImage",
33
+ FlatImage = "FlatImage"
34
+ }
@@ -1,5 +1,5 @@
1
1
  import { EAuthMeIDCardMetalTagStatus } from '@authme/engine';
2
- import { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus } from '../enum';
2
+ import { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '../enum';
3
3
  export interface IDCardAntiFraudResult {
4
4
  info: AuthMeIDCardAntiFraudInfo;
5
5
  statistics: AuthMeIDCardAntiFraudStatistics;
@@ -52,7 +52,12 @@ export interface AuthMeCardOCRInfo {
52
52
  }
53
53
  export interface PassportResult {
54
54
  info: AuthMeMRZInfo;
55
- eStatus: EAuthMePassportServiceStatus;
55
+ eStatus: EAuthMeMRZServiceStatus;
56
+ tField: MRZFieldTD3;
57
+ }
58
+ export interface ResidentCardResult {
59
+ info: AuthMeMRZInfo;
60
+ eStatus: EAuthMeMRZServiceStatus;
56
61
  tField: MRZFieldTD3;
57
62
  }
58
63
  export interface MRZFieldTD3 {
@@ -13,5 +13,14 @@ export interface InitScanResponse {
13
13
  fraudRetryTimes: number;
14
14
  fraudTimeout: number;
15
15
  fraudMaxFps: number;
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
+ };
16
25
  };
17
26
  }
@@ -1,18 +1,25 @@
1
1
  import { AuthmeEngineModuleBase, MlEngine } from '@authme/engine';
2
- import { CardOCRResult, IDCardAntiFraudResult, PassportResult } from './interface';
2
+ import { CardOCRResult, IDCardAntiFraudResult, PassportResult, ResidentCardResult } from './interface';
3
3
  import { EAuthMeCardClass, EAuthMeIDCardAntiFraudStage } from './enum';
4
4
  export declare class CardOCR extends AuthmeEngineModuleBase<CardOCRResult> {
5
5
  private type;
6
6
  constructor(engine: MlEngine);
7
7
  setType(type: EAuthMeCardClass): Promise<unknown>;
8
8
  getType(): EAuthMeCardClass;
9
+ setParams(params: any): Promise<unknown>;
10
+ }
11
+ export interface Point {
12
+ x: number;
13
+ y: number;
9
14
  }
10
15
  export declare class IdCardAntiFraudService extends AuthmeEngineModuleBase<IDCardAntiFraudResult> {
11
16
  constructor(engine: MlEngine);
12
17
  setStage(stageList: EAuthMeIDCardAntiFraudStage[]): Promise<unknown>;
18
+ getCardMatchROI(): Promise<Point[]>;
13
19
  }
14
- export declare class MRZService extends AuthmeEngineModuleBase<PassportResult> {
15
- constructor(engine: MlEngine);
20
+ export declare class MRZService<T extends PassportResult | ResidentCardResult> extends AuthmeEngineModuleBase<T> {
21
+ private type;
22
+ constructor(engine: MlEngine, type?: 'passport' | 'residentCard');
16
23
  getFinalResult(): Promise<unknown>;
17
24
  toJson(params: unknown): Promise<string>;
18
25
  }