@authme/id-recognition 2.4.2 → 2.4.7

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,11 +2,14 @@
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');
9
+ require('core-js/modules/es.regexp.to-string.js');
8
10
  require('core-js/modules/web.dom-collections.iterator.js');
9
11
  var core = require('@authme/core');
12
+ var util = require('@authme/util');
10
13
  require('core-js/modules/es.symbol.description.js');
11
14
 
12
15
  exports.ResourceImageType = void 0;
@@ -18,7 +21,13 @@ exports.ResourceImageType = void 0;
18
21
  exports.CountryCode = void 0;
19
22
  (function (CountryCode) {
20
23
  CountryCode["TWN"] = "TWN";
21
- CountryCode["JPW"] = "JP";
24
+ CountryCode["JPN"] = "JPN";
25
+ CountryCode["ZAF"] = "ZAF";
26
+ CountryCode["USA"] = "USA";
27
+ CountryCode["CHN"] = "CHN";
28
+ CountryCode["PHL"] = "PHL";
29
+ CountryCode["GBR"] = "GBR";
30
+ CountryCode["KOR"] = "KOR";
22
31
  })(exports.CountryCode || (exports.CountryCode = {}));
23
32
  exports.IdRecognitionCardType = void 0;
24
33
  (function (IdRecognitionCardType) {
@@ -42,6 +51,11 @@ exports.ServerSideEAuthMeCardClass = void 0;
42
51
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
43
52
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
44
53
  })(exports.ServerSideEAuthMeCardClass || (exports.ServerSideEAuthMeCardClass = {}));
54
+ exports.RecognitionFileType = void 0;
55
+ (function (RecognitionFileType) {
56
+ RecognitionFileType["OriginImage"] = "OriginImage";
57
+ RecognitionFileType["FlatImage"] = "FlatImage";
58
+ })(exports.RecognitionFileType || (exports.RecognitionFileType = {}));
45
59
 
46
60
  class CardOCR extends engine.AuthmeEngineModuleBase {
47
61
  constructor(engine$1) {
@@ -49,16 +63,22 @@ class CardOCR extends engine.AuthmeEngineModuleBase {
49
63
  this.type = engine.EAuthMeCardClass.Invalid;
50
64
  this.moduleName = engine.EngineModule.CardOCR;
51
65
  }
52
- setType(type, options) {
66
+ setType(type) {
53
67
  this.type = type;
54
68
  return this.engine.run(this.moduleName, 'setType', {
55
- type,
56
- options
69
+ type
57
70
  });
58
71
  }
59
72
  getType() {
60
73
  return this.type;
61
74
  }
75
+ setParams(params) {
76
+ var _a;
77
+ if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === engine.EAuthMeCardClass.Invalid) throw new Error('Please set type first');
78
+ return this.engine.run(this.moduleName, 'setParams', Object.assign({
79
+ type: this.type
80
+ }, params));
81
+ }
62
82
  }
63
83
  class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
64
84
  constructor(engine$1) {
@@ -69,6 +89,9 @@ class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
69
89
  const stageStrList = stageList.map(x => x.split('_')[1]);
70
90
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
71
91
  }
92
+ getCardMatchROI() {
93
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
94
+ }
72
95
  }
73
96
  class MRZService extends engine.AuthmeEngineModuleBase {
74
97
  constructor(engine$1, type = 'passport') {
@@ -125,6 +148,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
125
148
  function getCardSubTypes(type, country) {
126
149
  return CardTypeMapping[type];
127
150
  }
151
+ function cardTypeTitle(cardType) {
152
+ if (cardType == null) {
153
+ return '';
154
+ }
155
+ const cardTypeLower = cardType.toLowerCase();
156
+ let titleKey = null;
157
+ if (cardTypeLower.indexOf('idcard') != -1) {
158
+ if (cardTypeLower.indexOf('front')) {
159
+ titleKey = 'verify.idCardFrontSide';
160
+ } else {
161
+ titleKey = 'verify.idCardBackSide';
162
+ }
163
+ } else if (cardTypeLower.indexOf('driverlicense') != -1) {
164
+ if (cardTypeLower.indexOf('front')) {
165
+ titleKey = 'verify.licenseFrontSide';
166
+ } else {
167
+ titleKey = 'verify.licenseBackSide';
168
+ }
169
+ } else if (cardTypeLower.indexOf('resident') != -1) {
170
+ if (cardTypeLower.indexOf('front')) {
171
+ titleKey = 'verify.residentCardFrontSide';
172
+ } else {
173
+ titleKey = 'verify.residentCardBackSide';
174
+ }
175
+ }
176
+ return titleKey;
177
+ }
178
+ function cardTypeConfirmTitle(cardType) {
179
+ if (cardType == null) {
180
+ return '';
181
+ }
182
+ const cardTypeLower = cardType.toLowerCase();
183
+ let titleKey = null;
184
+ if (cardTypeLower.indexOf('idcard') != -1) {
185
+ if (cardTypeLower.indexOf('front')) {
186
+ titleKey = 'verify.confirmIdCardFront';
187
+ } else {
188
+ titleKey = 'verify.confirmIdCardBack';
189
+ }
190
+ } else if (cardTypeLower.indexOf('driverlicense') != -1) {
191
+ if (cardTypeLower.indexOf('front')) {
192
+ titleKey = 'verify.confirmLicenseFront';
193
+ } else {
194
+ titleKey = 'verify.confirmLicenseBack';
195
+ }
196
+ } else if (cardTypeLower.indexOf('resident') != -1) {
197
+ if (cardTypeLower.indexOf('front')) {
198
+ titleKey = 'verify.confirmResidentCardFrontSide';
199
+ } else {
200
+ titleKey = 'verify.confirmResidentCardBackSide';
201
+ }
202
+ }
203
+ return titleKey;
204
+ }
205
+ function mapCardtypeToAuthmeClass(type) {
206
+ const known_type = Object.keys(engine.EAuthMeCardClass).filter(key => engine.EAuthMeCardClass[key].toString().toLowerCase() == ('EAuthMeCardClass_' + type).toLowerCase())[0];
207
+ if (known_type == null) {
208
+ return engine.EAuthMeCardClass.Unknown;
209
+ }
210
+ return engine.EAuthMeCardClass[known_type];
211
+ }
128
212
  function getRecognitionColumnOrder(column) {
129
213
  var _a;
130
214
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -142,12 +226,30 @@ const twoWayAuthmeCardClassMap = (() => {
142
226
  };
143
227
  })();
144
228
 
145
- function init(type, country, needConfirm, encrypt = true) {
229
+ var name = "authme/sdk";
230
+ var version$1 = "2.4.7";
231
+ var date = "2023-12-14T08:29:41+0000";
232
+ var packageInfo = {
233
+ name: name,
234
+ version: version$1,
235
+ date: date
236
+ };
237
+
238
+ function init(type, country, needConfirm, cardTypes, encrypt = true) {
239
+ let useCardTypes = getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c));
240
+ if (cardTypes.length) {
241
+ useCardTypes = cardTypes;
242
+ }
146
243
  const body = {
147
244
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
148
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
245
+ cardTypes: useCardTypes,
149
246
  needConfirm,
150
- encrypt
247
+ encrypt,
248
+ clientInfo: {
249
+ os: 'web',
250
+ os_ver: util.osVersion(),
251
+ client_ver: packageInfo.version
252
+ }
151
253
  };
152
254
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
153
255
  body: JSON.stringify(body)
@@ -180,12 +282,12 @@ function recognition(documentId, file) {
180
282
  throw error;
181
283
  });
182
284
  }
183
- function recognitionEncrypt(documentId, base64Text, report) {
285
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
184
286
  return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
185
287
  body: JSON.stringify({
186
288
  scanDocumentId: documentId,
187
289
  image: base64Text,
188
- fileType: 'image/jpeg',
290
+ fileType: fileType,
189
291
  info: {
190
292
  report
191
293
  }
@@ -202,6 +304,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
202
304
  throw error;
203
305
  });
204
306
  }
307
+ function uploadFrameBase64(documentId, base64Text, index, type = exports.ResourceImageType.Recognition, report) {
308
+ return core.sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
309
+ body: JSON.stringify({
310
+ scanDocumentId: documentId,
311
+ image: base64Text,
312
+ type,
313
+ // fileType: 'image/jpeg',
314
+ info: {
315
+ report,
316
+ index
317
+ }
318
+ }),
319
+ contentType: 'application/json'
320
+ }).catch(error => {
321
+ var _a, _b, _c;
322
+ 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') {
323
+ return {
324
+ retry: true,
325
+ details: {}
326
+ };
327
+ }
328
+ throw error;
329
+ });
330
+ }
205
331
  function saveResourceImage(documentId, type, file) {
206
332
  const formData = new FormData();
207
333
  formData.append('scanDocumentId', documentId);
@@ -244,17 +370,6 @@ function saveExtraDoc(params) {
244
370
  });
245
371
  }
246
372
 
247
- var name = "@authme/id-recognition";
248
- var version$1 = "2.4.2";
249
- var peerDependencies = {
250
- "core-js": "^3.6.0"
251
- };
252
- var packageInfo = {
253
- name: name,
254
- version: version$1,
255
- peerDependencies: peerDependencies
256
- };
257
-
258
373
  var _a;
259
374
  var _b, _c;
260
375
  const version = packageInfo.version;
@@ -293,15 +408,19 @@ exports.CardOCR = CardOCR;
293
408
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
294
409
  exports.IdTypeConfig = IdTypeConfig;
295
410
  exports.MRZService = MRZService;
411
+ exports.cardTypeConfirmTitle = cardTypeConfirmTitle;
412
+ exports.cardTypeTitle = cardTypeTitle;
296
413
  exports.confirmScan = confirmScan;
297
414
  exports.finishScanDocument = finishScanDocument;
298
415
  exports.getCardSubTypes = getCardSubTypes;
299
416
  exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
300
417
  exports.init = init;
301
418
  exports.initScanDocument = initScanDocument;
419
+ exports.mapCardtypeToAuthmeClass = mapCardtypeToAuthmeClass;
302
420
  exports.recognition = recognition;
303
421
  exports.recognitionEncrypt = recognitionEncrypt;
304
422
  exports.saveExtraDoc = saveExtraDoc;
305
423
  exports.saveResourceImage = saveResourceImage;
306
424
  exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
425
+ exports.uploadFrameBase64 = uploadFrameBase64;
307
426
  exports.version = version;
package/index.js CHANGED
@@ -1,9 +1,12 @@
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';
4
5
  import 'core-js/modules/es.object.from-entries.js';
6
+ import 'core-js/modules/es.regexp.to-string.js';
5
7
  import 'core-js/modules/web.dom-collections.iterator.js';
6
8
  import { sendRequest, AuthmeError } from '@authme/core';
9
+ import { osVersion } from '@authme/util';
7
10
  import 'core-js/modules/es.symbol.description.js';
8
11
 
9
12
  var ResourceImageType;
@@ -15,7 +18,13 @@ var ResourceImageType;
15
18
  var CountryCode;
16
19
  (function (CountryCode) {
17
20
  CountryCode["TWN"] = "TWN";
18
- CountryCode["JPW"] = "JP";
21
+ CountryCode["JPN"] = "JPN";
22
+ CountryCode["ZAF"] = "ZAF";
23
+ CountryCode["USA"] = "USA";
24
+ CountryCode["CHN"] = "CHN";
25
+ CountryCode["PHL"] = "PHL";
26
+ CountryCode["GBR"] = "GBR";
27
+ CountryCode["KOR"] = "KOR";
19
28
  })(CountryCode || (CountryCode = {}));
20
29
  var IdRecognitionCardType;
21
30
  (function (IdRecognitionCardType) {
@@ -39,6 +48,11 @@ var ServerSideEAuthMeCardClass;
39
48
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
40
49
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
41
50
  })(ServerSideEAuthMeCardClass || (ServerSideEAuthMeCardClass = {}));
51
+ var RecognitionFileType;
52
+ (function (RecognitionFileType) {
53
+ RecognitionFileType["OriginImage"] = "OriginImage";
54
+ RecognitionFileType["FlatImage"] = "FlatImage";
55
+ })(RecognitionFileType || (RecognitionFileType = {}));
42
56
 
43
57
  class CardOCR extends AuthmeEngineModuleBase {
44
58
  constructor(engine) {
@@ -46,16 +60,22 @@ class CardOCR extends AuthmeEngineModuleBase {
46
60
  this.type = EAuthMeCardClass.Invalid;
47
61
  this.moduleName = EngineModule.CardOCR;
48
62
  }
49
- setType(type, options) {
63
+ setType(type) {
50
64
  this.type = type;
51
65
  return this.engine.run(this.moduleName, 'setType', {
52
- type,
53
- options
66
+ type
54
67
  });
55
68
  }
56
69
  getType() {
57
70
  return this.type;
58
71
  }
72
+ setParams(params) {
73
+ var _a;
74
+ if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === EAuthMeCardClass.Invalid) throw new Error('Please set type first');
75
+ return this.engine.run(this.moduleName, 'setParams', Object.assign({
76
+ type: this.type
77
+ }, params));
78
+ }
59
79
  }
60
80
  class IdCardAntiFraudService extends AuthmeEngineModuleBase {
61
81
  constructor(engine) {
@@ -66,6 +86,9 @@ class IdCardAntiFraudService extends AuthmeEngineModuleBase {
66
86
  const stageStrList = stageList.map(x => x.split('_')[1]);
67
87
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
68
88
  }
89
+ getCardMatchROI() {
90
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
91
+ }
69
92
  }
70
93
  class MRZService extends AuthmeEngineModuleBase {
71
94
  constructor(engine, type = 'passport') {
@@ -122,6 +145,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
122
145
  function getCardSubTypes(type, country) {
123
146
  return CardTypeMapping[type];
124
147
  }
148
+ function cardTypeTitle(cardType) {
149
+ if (cardType == null) {
150
+ return '';
151
+ }
152
+ const cardTypeLower = cardType.toLowerCase();
153
+ let titleKey = null;
154
+ if (cardTypeLower.indexOf('idcard') != -1) {
155
+ if (cardTypeLower.indexOf('front')) {
156
+ titleKey = 'verify.idCardFrontSide';
157
+ } else {
158
+ titleKey = 'verify.idCardBackSide';
159
+ }
160
+ } else if (cardTypeLower.indexOf('driverlicense') != -1) {
161
+ if (cardTypeLower.indexOf('front')) {
162
+ titleKey = 'verify.licenseFrontSide';
163
+ } else {
164
+ titleKey = 'verify.licenseBackSide';
165
+ }
166
+ } else if (cardTypeLower.indexOf('resident') != -1) {
167
+ if (cardTypeLower.indexOf('front')) {
168
+ titleKey = 'verify.residentCardFrontSide';
169
+ } else {
170
+ titleKey = 'verify.residentCardBackSide';
171
+ }
172
+ }
173
+ return titleKey;
174
+ }
175
+ function cardTypeConfirmTitle(cardType) {
176
+ if (cardType == null) {
177
+ return '';
178
+ }
179
+ const cardTypeLower = cardType.toLowerCase();
180
+ let titleKey = null;
181
+ if (cardTypeLower.indexOf('idcard') != -1) {
182
+ if (cardTypeLower.indexOf('front')) {
183
+ titleKey = 'verify.confirmIdCardFront';
184
+ } else {
185
+ titleKey = 'verify.confirmIdCardBack';
186
+ }
187
+ } else if (cardTypeLower.indexOf('driverlicense') != -1) {
188
+ if (cardTypeLower.indexOf('front')) {
189
+ titleKey = 'verify.confirmLicenseFront';
190
+ } else {
191
+ titleKey = 'verify.confirmLicenseBack';
192
+ }
193
+ } else if (cardTypeLower.indexOf('resident') != -1) {
194
+ if (cardTypeLower.indexOf('front')) {
195
+ titleKey = 'verify.confirmResidentCardFrontSide';
196
+ } else {
197
+ titleKey = 'verify.confirmResidentCardBackSide';
198
+ }
199
+ }
200
+ return titleKey;
201
+ }
202
+ function mapCardtypeToAuthmeClass(type) {
203
+ const known_type = Object.keys(EAuthMeCardClass).filter(key => EAuthMeCardClass[key].toString().toLowerCase() == ('EAuthMeCardClass_' + type).toLowerCase())[0];
204
+ if (known_type == null) {
205
+ return EAuthMeCardClass.Unknown;
206
+ }
207
+ return EAuthMeCardClass[known_type];
208
+ }
125
209
  function getRecognitionColumnOrder(column) {
126
210
  var _a;
127
211
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -139,12 +223,30 @@ const twoWayAuthmeCardClassMap = (() => {
139
223
  };
140
224
  })();
141
225
 
142
- function init(type, country, needConfirm, encrypt = true) {
226
+ var name = "authme/sdk";
227
+ var version$1 = "2.4.7";
228
+ var date = "2023-12-14T08:29:41+0000";
229
+ var packageInfo = {
230
+ name: name,
231
+ version: version$1,
232
+ date: date
233
+ };
234
+
235
+ function init(type, country, needConfirm, cardTypes, encrypt = true) {
236
+ let useCardTypes = getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c));
237
+ if (cardTypes.length) {
238
+ useCardTypes = cardTypes;
239
+ }
143
240
  const body = {
144
241
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
145
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
242
+ cardTypes: useCardTypes,
146
243
  needConfirm,
147
- encrypt
244
+ encrypt,
245
+ clientInfo: {
246
+ os: 'web',
247
+ os_ver: osVersion(),
248
+ client_ver: packageInfo.version
249
+ }
148
250
  };
149
251
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
150
252
  body: JSON.stringify(body)
@@ -177,12 +279,12 @@ function recognition(documentId, file) {
177
279
  throw error;
178
280
  });
179
281
  }
180
- function recognitionEncrypt(documentId, base64Text, report) {
282
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
181
283
  return sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
182
284
  body: JSON.stringify({
183
285
  scanDocumentId: documentId,
184
286
  image: base64Text,
185
- fileType: 'image/jpeg',
287
+ fileType: fileType,
186
288
  info: {
187
289
  report
188
290
  }
@@ -199,6 +301,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
199
301
  throw error;
200
302
  });
201
303
  }
304
+ function uploadFrameBase64(documentId, base64Text, index, type = ResourceImageType.Recognition, report) {
305
+ return sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
306
+ body: JSON.stringify({
307
+ scanDocumentId: documentId,
308
+ image: base64Text,
309
+ type,
310
+ // fileType: 'image/jpeg',
311
+ info: {
312
+ report,
313
+ index
314
+ }
315
+ }),
316
+ contentType: 'application/json'
317
+ }).catch(error => {
318
+ var _a, _b, _c;
319
+ 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') {
320
+ return {
321
+ retry: true,
322
+ details: {}
323
+ };
324
+ }
325
+ throw error;
326
+ });
327
+ }
202
328
  function saveResourceImage(documentId, type, file) {
203
329
  const formData = new FormData();
204
330
  formData.append('scanDocumentId', documentId);
@@ -241,21 +367,10 @@ function saveExtraDoc(params) {
241
367
  });
242
368
  }
243
369
 
244
- var name = "@authme/id-recognition";
245
- var version$1 = "2.4.2";
246
- var peerDependencies = {
247
- "core-js": "^3.6.0"
248
- };
249
- var packageInfo = {
250
- name: name,
251
- version: version$1,
252
- peerDependencies: peerDependencies
253
- };
254
-
255
370
  var _a;
256
371
  var _b, _c;
257
372
  const version = packageInfo.version;
258
373
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
259
374
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
260
375
 
261
- export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, version };
376
+ export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, RecognitionFileType, ResourceImageType, ServerSideEAuthMeCardClass, cardTypeConfirmTitle, cardTypeTitle, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, mapCardtypeToAuthmeClass, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, uploadFrameBase64, version };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@authme/id-recognition",
3
- "version": "2.4.2",
3
+ "version": "2.4.7",
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.7",
7
+ "@authme/util": "2.4.7",
8
+ "@authme/engine": "2.4.7"
8
9
  },
9
10
  "module": "./index.js",
10
11
  "main": "./index.cjs",
@@ -1,7 +1,7 @@
1
- import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
1
+ import { CountryCode, IdRecognitionCardType, RecognitionFileType, ResourceImageType } from '../enum';
2
2
  import { InitScanResponse } from '../model';
3
- export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean, encrypt?: boolean): Promise<InitScanResponse>;
4
- export declare function initScanDocument(scanId: string, cardType: `${ServerSideEAuthMeCardClass}`): Promise<{
3
+ export declare function init(type: IdRecognitionCardType, country: CountryCode, needConfirm: boolean, cardTypes: string[], encrypt?: boolean): Promise<InitScanResponse>;
4
+ export declare function initScanDocument(scanId: string, cardType: string): Promise<{
5
5
  scanDocumentId: string;
6
6
  }>;
7
7
  export declare function recognition(documentId: string, file: Blob): 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;
@@ -6,7 +6,13 @@ export declare enum ResourceImageType {
6
6
  }
7
7
  export declare enum CountryCode {
8
8
  TWN = "TWN",
9
- JPW = "JP"
9
+ JPN = "JPN",
10
+ ZAF = "ZAF",
11
+ USA = "USA",
12
+ CHN = "CHN",
13
+ PHL = "PHL",
14
+ GBR = "GBR",
15
+ KOR = "KOR"
10
16
  }
11
17
  export declare enum IdRecognitionCardType {
12
18
  IDCard = "IDCard",
@@ -28,3 +34,7 @@ export declare enum ServerSideEAuthMeCardClass {
28
34
  TWN_HealthCard_Front = "TWN_HealthCard_Front",
29
35
  TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
30
36
  }
37
+ export declare enum RecognitionFileType {
38
+ OriginImage = "OriginImage",
39
+ FlatImage = "FlatImage"
40
+ }
@@ -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;
package/src/lib/util.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { CountryCode, EAuthMeCardClass, IdRecognitionCardType, ServerSideEAuthMeCardClass } from './enum';
2
2
  export declare function getCardSubTypes(type: IdRecognitionCardType, country: CountryCode): EAuthMeCardClass[];
3
+ export declare function cardTypeTitle(cardType: string): any;
4
+ export declare function cardTypeConfirmTitle(cardType: string): any;
5
+ export declare function mapCardtypeToAuthmeClass(type: string): any;
3
6
  export declare function getRecognitionColumnOrder(column: string): number;
4
7
  export declare const twoWayAuthmeCardClassMap: {
5
8
  toServer(clientEnum: `${EAuthMeCardClass}`): `${ServerSideEAuthMeCardClass}`;