@authme/id-recognition 2.3.1-rc.3 → 2.4.2

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
@@ -18,6 +18,7 @@ exports.ResourceImageType = void 0;
18
18
  exports.CountryCode = void 0;
19
19
  (function (CountryCode) {
20
20
  CountryCode["TWN"] = "TWN";
21
+ CountryCode["JPW"] = "JP";
21
22
  })(exports.CountryCode || (exports.CountryCode = {}));
22
23
  exports.IdRecognitionCardType = void 0;
23
24
  (function (IdRecognitionCardType) {
@@ -48,10 +49,11 @@ class CardOCR extends engine.AuthmeEngineModuleBase {
48
49
  this.type = engine.EAuthMeCardClass.Invalid;
49
50
  this.moduleName = engine.EngineModule.CardOCR;
50
51
  }
51
- setType(type) {
52
+ setType(type, options) {
52
53
  this.type = type;
53
54
  return this.engine.run(this.moduleName, 'setType', {
54
- type
55
+ type,
56
+ options
55
57
  });
56
58
  }
57
59
  getType() {
@@ -69,9 +71,14 @@ class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
69
71
  }
70
72
  }
71
73
  class MRZService extends engine.AuthmeEngineModuleBase {
72
- constructor(engine$1) {
74
+ constructor(engine$1, type = 'passport') {
73
75
  super(engine$1);
74
- this.moduleName = engine.EngineModule.PassportService;
76
+ this.type = type;
77
+ if (this.type === 'passport') {
78
+ this.moduleName = engine.EngineModule.MRZPassportService;
79
+ } else if (this.type === 'residentCard') {
80
+ this.moduleName = engine.EngineModule.MRZResidentCardService;
81
+ }
75
82
  }
76
83
  getFinalResult() {
77
84
  return this.engine.run(this.moduleName, 'getFinalResult');
@@ -135,11 +142,12 @@ const twoWayAuthmeCardClassMap = (() => {
135
142
  };
136
143
  })();
137
144
 
138
- function init(type, country, needConfirm) {
145
+ function init(type, country, needConfirm, encrypt = true) {
139
146
  const body = {
140
147
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
141
148
  cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
142
- needConfirm
149
+ needConfirm,
150
+ encrypt
143
151
  };
144
152
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
145
153
  body: JSON.stringify(body)
@@ -172,6 +180,28 @@ function recognition(documentId, file) {
172
180
  throw error;
173
181
  });
174
182
  }
183
+ function recognitionEncrypt(documentId, base64Text, report) {
184
+ return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
185
+ body: JSON.stringify({
186
+ scanDocumentId: documentId,
187
+ image: base64Text,
188
+ fileType: 'image/jpeg',
189
+ info: {
190
+ report
191
+ }
192
+ }),
193
+ contentType: 'application/json'
194
+ }).catch(error => {
195
+ var _a, _b, _c;
196
+ 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') {
197
+ return {
198
+ retry: true,
199
+ details: {}
200
+ };
201
+ }
202
+ throw error;
203
+ });
204
+ }
175
205
  function saveResourceImage(documentId, type, file) {
176
206
  const formData = new FormData();
177
207
  formData.append('scanDocumentId', documentId);
@@ -215,7 +245,7 @@ function saveExtraDoc(params) {
215
245
  }
216
246
 
217
247
  var name = "@authme/id-recognition";
218
- var version$1 = "2.3.1-rc.3";
248
+ var version$1 = "2.4.2";
219
249
  var peerDependencies = {
220
250
  "core-js": "^3.6.0"
221
251
  };
@@ -255,9 +285,9 @@ Object.defineProperty(exports, 'EAuthMeMRZRecogStatus', {
255
285
  enumerable: true,
256
286
  get: function () { return engine.EAuthMeMRZRecogStatus; }
257
287
  });
258
- Object.defineProperty(exports, 'EAuthMePassportServiceStatus', {
288
+ Object.defineProperty(exports, 'EAuthMeMRZServiceStatus', {
259
289
  enumerable: true,
260
- get: function () { return engine.EAuthMePassportServiceStatus; }
290
+ get: function () { return engine.EAuthMeMRZServiceStatus; }
261
291
  });
262
292
  exports.CardOCR = CardOCR;
263
293
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
@@ -270,6 +300,7 @@ exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
270
300
  exports.init = init;
271
301
  exports.initScanDocument = initScanDocument;
272
302
  exports.recognition = recognition;
303
+ exports.recognitionEncrypt = recognitionEncrypt;
273
304
  exports.saveExtraDoc = saveExtraDoc;
274
305
  exports.saveResourceImage = saveResourceImage;
275
306
  exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/engine';
2
- export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMePassportServiceStatus } from '@authme/engine';
2
+ export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '@authme/engine';
3
3
  import 'core-js/modules/es.array.iterator.js';
4
4
  import 'core-js/modules/es.object.from-entries.js';
5
5
  import 'core-js/modules/web.dom-collections.iterator.js';
@@ -15,6 +15,7 @@ var ResourceImageType;
15
15
  var CountryCode;
16
16
  (function (CountryCode) {
17
17
  CountryCode["TWN"] = "TWN";
18
+ CountryCode["JPW"] = "JP";
18
19
  })(CountryCode || (CountryCode = {}));
19
20
  var IdRecognitionCardType;
20
21
  (function (IdRecognitionCardType) {
@@ -45,10 +46,11 @@ class CardOCR extends AuthmeEngineModuleBase {
45
46
  this.type = EAuthMeCardClass.Invalid;
46
47
  this.moduleName = EngineModule.CardOCR;
47
48
  }
48
- setType(type) {
49
+ setType(type, options) {
49
50
  this.type = type;
50
51
  return this.engine.run(this.moduleName, 'setType', {
51
- type
52
+ type,
53
+ options
52
54
  });
53
55
  }
54
56
  getType() {
@@ -66,9 +68,14 @@ class IdCardAntiFraudService extends AuthmeEngineModuleBase {
66
68
  }
67
69
  }
68
70
  class MRZService extends AuthmeEngineModuleBase {
69
- constructor(engine) {
71
+ constructor(engine, type = 'passport') {
70
72
  super(engine);
71
- this.moduleName = EngineModule.PassportService;
73
+ this.type = type;
74
+ if (this.type === 'passport') {
75
+ this.moduleName = EngineModule.MRZPassportService;
76
+ } else if (this.type === 'residentCard') {
77
+ this.moduleName = EngineModule.MRZResidentCardService;
78
+ }
72
79
  }
73
80
  getFinalResult() {
74
81
  return this.engine.run(this.moduleName, 'getFinalResult');
@@ -132,11 +139,12 @@ const twoWayAuthmeCardClassMap = (() => {
132
139
  };
133
140
  })();
134
141
 
135
- function init(type, country, needConfirm) {
142
+ function init(type, country, needConfirm, encrypt = true) {
136
143
  const body = {
137
144
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
138
145
  cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
139
- needConfirm
146
+ needConfirm,
147
+ encrypt
140
148
  };
141
149
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
142
150
  body: JSON.stringify(body)
@@ -169,6 +177,28 @@ function recognition(documentId, file) {
169
177
  throw error;
170
178
  });
171
179
  }
180
+ function recognitionEncrypt(documentId, base64Text, report) {
181
+ return sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
182
+ body: JSON.stringify({
183
+ scanDocumentId: documentId,
184
+ image: base64Text,
185
+ fileType: 'image/jpeg',
186
+ info: {
187
+ report
188
+ }
189
+ }),
190
+ contentType: 'application/json'
191
+ }).catch(error => {
192
+ var _a, _b, _c;
193
+ 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') {
194
+ return {
195
+ retry: true,
196
+ details: {}
197
+ };
198
+ }
199
+ throw error;
200
+ });
201
+ }
172
202
  function saveResourceImage(documentId, type, file) {
173
203
  const formData = new FormData();
174
204
  formData.append('scanDocumentId', documentId);
@@ -212,7 +242,7 @@ function saveExtraDoc(params) {
212
242
  }
213
243
 
214
244
  var name = "@authme/id-recognition";
215
- var version$1 = "2.3.1-rc.3";
245
+ var version$1 = "2.4.2";
216
246
  var peerDependencies = {
217
247
  "core-js": "^3.6.0"
218
248
  };
@@ -228,4 +258,4 @@ const version = packageInfo.version;
228
258
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
229
259
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
230
260
 
231
- export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, version };
261
+ export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, 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.2",
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.2",
7
+ "@authme/engine": "2.4.2"
8
8
  },
9
9
  "module": "./index.js",
10
10
  "main": "./index.cjs",
@@ -1,6 +1,6 @@
1
1
  import { CountryCode, IdRecognitionCardType, 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,12 @@ 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<{
14
+ retry?: boolean;
15
+ details: {
16
+ [key: string]: string | null;
17
+ };
18
+ }>;
13
19
  export declare function saveResourceImage(documentId: string, type: ResourceImageType, file: Blob): Promise<any>;
14
20
  export declare function finishScanDocument(documentId: string, details: {
15
21
  [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",
@@ -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,6 @@ export interface InitScanResponse {
13
13
  fraudRetryTimes: number;
14
14
  fraudTimeout: number;
15
15
  fraudMaxFps: number;
16
+ pubKey: string;
16
17
  };
17
18
  }
@@ -1,18 +1,21 @@
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
- setType(type: EAuthMeCardClass): Promise<unknown>;
7
+ setType(type: EAuthMeCardClass, options?: {
8
+ [key: string]: unknown;
9
+ }): Promise<unknown>;
8
10
  getType(): EAuthMeCardClass;
9
11
  }
10
12
  export declare class IdCardAntiFraudService extends AuthmeEngineModuleBase<IDCardAntiFraudResult> {
11
13
  constructor(engine: MlEngine);
12
14
  setStage(stageList: EAuthMeIDCardAntiFraudStage[]): Promise<unknown>;
13
15
  }
14
- export declare class MRZService extends AuthmeEngineModuleBase<PassportResult> {
15
- constructor(engine: MlEngine);
16
+ export declare class MRZService<T extends PassportResult | ResidentCardResult> extends AuthmeEngineModuleBase<T> {
17
+ private type;
18
+ constructor(engine: MlEngine, type?: 'passport' | 'residentCard');
16
19
  getFinalResult(): Promise<unknown>;
17
20
  toJson(params: unknown): Promise<string>;
18
21
  }