@authme/id-recognition 2.4.8 → 2.4.11

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,14 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('core-js/modules/es.object.assign.js');
6
5
  var engine = require('@authme/engine');
7
6
  require('core-js/modules/es.array.iterator.js');
8
7
  require('core-js/modules/es.object.from-entries.js');
9
- require('core-js/modules/es.regexp.to-string.js');
10
8
  require('core-js/modules/web.dom-collections.iterator.js');
11
9
  var core = require('@authme/core');
12
- var util = require('@authme/util');
13
10
  require('core-js/modules/es.symbol.description.js');
14
11
 
15
12
  exports.ResourceImageType = void 0;
@@ -21,25 +18,7 @@ exports.ResourceImageType = void 0;
21
18
  exports.CountryCode = void 0;
22
19
  (function (CountryCode) {
23
20
  CountryCode["TWN"] = "TWN";
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";
31
- CountryCode["HKG"] = "HKG";
32
- CountryCode["FRA"] = "FRA";
33
- CountryCode["ESP"] = "ESP";
34
- CountryCode["MEX"] = "MEX";
35
- CountryCode["ITA"] = "ITA";
36
- CountryCode["IND"] = "IND";
37
- CountryCode["COL"] = "COL";
38
- CountryCode["RUS"] = "RUS";
39
- CountryCode["DEU"] = "DEU";
40
- CountryCode["TUR"] = "TUR";
41
- CountryCode["CAN"] = "CAN";
42
- CountryCode["AUS"] = "AUS";
21
+ CountryCode["JPW"] = "JP";
43
22
  })(exports.CountryCode || (exports.CountryCode = {}));
44
23
  exports.IdRecognitionCardType = void 0;
45
24
  (function (IdRecognitionCardType) {
@@ -75,22 +54,16 @@ class CardOCR extends engine.AuthmeEngineModuleBase {
75
54
  this.type = engine.EAuthMeCardClass.Invalid;
76
55
  this.moduleName = engine.EngineModule.CardOCR;
77
56
  }
78
- setType(type) {
57
+ setType(type, options) {
79
58
  this.type = type;
80
59
  return this.engine.run(this.moduleName, 'setType', {
81
- type
60
+ type,
61
+ options
82
62
  });
83
63
  }
84
64
  getType() {
85
65
  return this.type;
86
66
  }
87
- setParams(params) {
88
- var _a;
89
- if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === engine.EAuthMeCardClass.Invalid) throw new Error('Please set type first');
90
- return this.engine.run(this.moduleName, 'setParams', Object.assign({
91
- type: this.type
92
- }, params));
93
- }
94
67
  }
95
68
  class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
96
69
  constructor(engine$1) {
@@ -160,67 +133,6 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
160
133
  function getCardSubTypes(type, country) {
161
134
  return CardTypeMapping[type];
162
135
  }
163
- function cardTypeTitle(cardType) {
164
- if (cardType == null) {
165
- return '';
166
- }
167
- const cardTypeLower = cardType.toLowerCase();
168
- let titleKey = null;
169
- if (cardTypeLower.indexOf('idcard') != -1) {
170
- if (cardTypeLower.indexOf('front')) {
171
- titleKey = 'verify.idCardFrontSide';
172
- } else {
173
- titleKey = 'verify.idCardBackSide';
174
- }
175
- } else if (cardTypeLower.indexOf('driverlicense') != -1) {
176
- if (cardTypeLower.indexOf('front')) {
177
- titleKey = 'verify.licenseFrontSide';
178
- } else {
179
- titleKey = 'verify.licenseBackSide';
180
- }
181
- } else if (cardTypeLower.indexOf('resident') != -1) {
182
- if (cardTypeLower.indexOf('front')) {
183
- titleKey = 'verify.residentCardFrontSide';
184
- } else {
185
- titleKey = 'verify.residentCardBackSide';
186
- }
187
- }
188
- return titleKey;
189
- }
190
- function cardTypeConfirmTitle(cardType) {
191
- if (cardType == null) {
192
- return '';
193
- }
194
- const cardTypeLower = cardType.toLowerCase();
195
- let titleKey = null;
196
- if (cardTypeLower.indexOf('idcard') != -1) {
197
- if (cardTypeLower.indexOf('front')) {
198
- titleKey = 'verify.confirmIdCardFront';
199
- } else {
200
- titleKey = 'verify.confirmIdCardBack';
201
- }
202
- } else if (cardTypeLower.indexOf('driverlicense') != -1) {
203
- if (cardTypeLower.indexOf('front')) {
204
- titleKey = 'verify.confirmLicenseFront';
205
- } else {
206
- titleKey = 'verify.confirmLicenseBack';
207
- }
208
- } else if (cardTypeLower.indexOf('resident') != -1) {
209
- if (cardTypeLower.indexOf('front')) {
210
- titleKey = 'verify.confirmResidentCardFrontSide';
211
- } else {
212
- titleKey = 'verify.confirmResidentCardBackSide';
213
- }
214
- }
215
- return titleKey;
216
- }
217
- function mapCardtypeToAuthmeClass(type) {
218
- const known_type = Object.keys(engine.EAuthMeCardClass).filter(key => engine.EAuthMeCardClass[key].toString().toLowerCase() == ('EAuthMeCardClass_' + type).toLowerCase())[0];
219
- if (known_type == null) {
220
- return engine.EAuthMeCardClass.Unknown;
221
- }
222
- return engine.EAuthMeCardClass[known_type];
223
- }
224
136
  function getRecognitionColumnOrder(column) {
225
137
  var _a;
226
138
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -238,30 +150,12 @@ const twoWayAuthmeCardClassMap = (() => {
238
150
  };
239
151
  })();
240
152
 
241
- var name = "authme/sdk";
242
- var version$1 = "2.4.8";
243
- var date = "2023-12-20T07:24:47+0000";
244
- var packageInfo = {
245
- name: name,
246
- version: version$1,
247
- date: date
248
- };
249
-
250
- function init(type, country, needConfirm, cardTypes, encrypt = true) {
251
- let useCardTypes = getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c));
252
- if (cardTypes.length) {
253
- useCardTypes = cardTypes;
254
- }
153
+ function init(type, country, needConfirm, encrypt = true) {
255
154
  const body = {
256
155
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
257
- cardTypes: useCardTypes,
156
+ cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
258
157
  needConfirm,
259
- encrypt,
260
- clientInfo: {
261
- os: 'web',
262
- os_ver: util.osVersion(),
263
- client_ver: packageInfo.version
264
- }
158
+ encrypt
265
159
  };
266
160
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
267
161
  body: JSON.stringify(body)
@@ -382,6 +276,17 @@ function saveExtraDoc(params) {
382
276
  });
383
277
  }
384
278
 
279
+ var name = "@authme/id-recognition";
280
+ var version$1 = "2.4.11";
281
+ var peerDependencies = {
282
+ "core-js": "^3.6.0"
283
+ };
284
+ var packageInfo = {
285
+ name: name,
286
+ version: version$1,
287
+ peerDependencies: peerDependencies
288
+ };
289
+
385
290
  var _a;
386
291
  var _b, _c;
387
292
  const version = packageInfo.version;
@@ -420,15 +325,12 @@ exports.CardOCR = CardOCR;
420
325
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
421
326
  exports.IdTypeConfig = IdTypeConfig;
422
327
  exports.MRZService = MRZService;
423
- exports.cardTypeConfirmTitle = cardTypeConfirmTitle;
424
- exports.cardTypeTitle = cardTypeTitle;
425
328
  exports.confirmScan = confirmScan;
426
329
  exports.finishScanDocument = finishScanDocument;
427
330
  exports.getCardSubTypes = getCardSubTypes;
428
331
  exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
429
332
  exports.init = init;
430
333
  exports.initScanDocument = initScanDocument;
431
- exports.mapCardtypeToAuthmeClass = mapCardtypeToAuthmeClass;
432
334
  exports.recognition = recognition;
433
335
  exports.recognitionEncrypt = recognitionEncrypt;
434
336
  exports.saveExtraDoc = saveExtraDoc;
package/index.js CHANGED
@@ -1,12 +1,9 @@
1
- import 'core-js/modules/es.object.assign.js';
2
1
  import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/engine';
3
2
  export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '@authme/engine';
4
3
  import 'core-js/modules/es.array.iterator.js';
5
4
  import 'core-js/modules/es.object.from-entries.js';
6
- import 'core-js/modules/es.regexp.to-string.js';
7
5
  import 'core-js/modules/web.dom-collections.iterator.js';
8
6
  import { sendRequest, AuthmeError } from '@authme/core';
9
- import { osVersion } from '@authme/util';
10
7
  import 'core-js/modules/es.symbol.description.js';
11
8
 
12
9
  var ResourceImageType;
@@ -18,25 +15,7 @@ var ResourceImageType;
18
15
  var CountryCode;
19
16
  (function (CountryCode) {
20
17
  CountryCode["TWN"] = "TWN";
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";
28
- CountryCode["HKG"] = "HKG";
29
- CountryCode["FRA"] = "FRA";
30
- CountryCode["ESP"] = "ESP";
31
- CountryCode["MEX"] = "MEX";
32
- CountryCode["ITA"] = "ITA";
33
- CountryCode["IND"] = "IND";
34
- CountryCode["COL"] = "COL";
35
- CountryCode["RUS"] = "RUS";
36
- CountryCode["DEU"] = "DEU";
37
- CountryCode["TUR"] = "TUR";
38
- CountryCode["CAN"] = "CAN";
39
- CountryCode["AUS"] = "AUS";
18
+ CountryCode["JPW"] = "JP";
40
19
  })(CountryCode || (CountryCode = {}));
41
20
  var IdRecognitionCardType;
42
21
  (function (IdRecognitionCardType) {
@@ -72,22 +51,16 @@ class CardOCR extends AuthmeEngineModuleBase {
72
51
  this.type = EAuthMeCardClass.Invalid;
73
52
  this.moduleName = EngineModule.CardOCR;
74
53
  }
75
- setType(type) {
54
+ setType(type, options) {
76
55
  this.type = type;
77
56
  return this.engine.run(this.moduleName, 'setType', {
78
- type
57
+ type,
58
+ options
79
59
  });
80
60
  }
81
61
  getType() {
82
62
  return this.type;
83
63
  }
84
- setParams(params) {
85
- var _a;
86
- if (((_a = params.type) !== null && _a !== void 0 ? _a : this.type) === EAuthMeCardClass.Invalid) throw new Error('Please set type first');
87
- return this.engine.run(this.moduleName, 'setParams', Object.assign({
88
- type: this.type
89
- }, params));
90
- }
91
64
  }
92
65
  class IdCardAntiFraudService extends AuthmeEngineModuleBase {
93
66
  constructor(engine) {
@@ -157,67 +130,6 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
157
130
  function getCardSubTypes(type, country) {
158
131
  return CardTypeMapping[type];
159
132
  }
160
- function cardTypeTitle(cardType) {
161
- if (cardType == null) {
162
- return '';
163
- }
164
- const cardTypeLower = cardType.toLowerCase();
165
- let titleKey = null;
166
- if (cardTypeLower.indexOf('idcard') != -1) {
167
- if (cardTypeLower.indexOf('front')) {
168
- titleKey = 'verify.idCardFrontSide';
169
- } else {
170
- titleKey = 'verify.idCardBackSide';
171
- }
172
- } else if (cardTypeLower.indexOf('driverlicense') != -1) {
173
- if (cardTypeLower.indexOf('front')) {
174
- titleKey = 'verify.licenseFrontSide';
175
- } else {
176
- titleKey = 'verify.licenseBackSide';
177
- }
178
- } else if (cardTypeLower.indexOf('resident') != -1) {
179
- if (cardTypeLower.indexOf('front')) {
180
- titleKey = 'verify.residentCardFrontSide';
181
- } else {
182
- titleKey = 'verify.residentCardBackSide';
183
- }
184
- }
185
- return titleKey;
186
- }
187
- function cardTypeConfirmTitle(cardType) {
188
- if (cardType == null) {
189
- return '';
190
- }
191
- const cardTypeLower = cardType.toLowerCase();
192
- let titleKey = null;
193
- if (cardTypeLower.indexOf('idcard') != -1) {
194
- if (cardTypeLower.indexOf('front')) {
195
- titleKey = 'verify.confirmIdCardFront';
196
- } else {
197
- titleKey = 'verify.confirmIdCardBack';
198
- }
199
- } else if (cardTypeLower.indexOf('driverlicense') != -1) {
200
- if (cardTypeLower.indexOf('front')) {
201
- titleKey = 'verify.confirmLicenseFront';
202
- } else {
203
- titleKey = 'verify.confirmLicenseBack';
204
- }
205
- } else if (cardTypeLower.indexOf('resident') != -1) {
206
- if (cardTypeLower.indexOf('front')) {
207
- titleKey = 'verify.confirmResidentCardFrontSide';
208
- } else {
209
- titleKey = 'verify.confirmResidentCardBackSide';
210
- }
211
- }
212
- return titleKey;
213
- }
214
- function mapCardtypeToAuthmeClass(type) {
215
- const known_type = Object.keys(EAuthMeCardClass).filter(key => EAuthMeCardClass[key].toString().toLowerCase() == ('EAuthMeCardClass_' + type).toLowerCase())[0];
216
- if (known_type == null) {
217
- return EAuthMeCardClass.Unknown;
218
- }
219
- return EAuthMeCardClass[known_type];
220
- }
221
133
  function getRecognitionColumnOrder(column) {
222
134
  var _a;
223
135
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -235,30 +147,12 @@ const twoWayAuthmeCardClassMap = (() => {
235
147
  };
236
148
  })();
237
149
 
238
- var name = "authme/sdk";
239
- var version$1 = "2.4.8";
240
- var date = "2023-12-20T07:24:47+0000";
241
- var packageInfo = {
242
- name: name,
243
- version: version$1,
244
- date: date
245
- };
246
-
247
- function init(type, country, needConfirm, cardTypes, encrypt = true) {
248
- let useCardTypes = getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c));
249
- if (cardTypes.length) {
250
- useCardTypes = cardTypes;
251
- }
150
+ function init(type, country, needConfirm, encrypt = true) {
252
151
  const body = {
253
152
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
254
- cardTypes: useCardTypes,
153
+ cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
255
154
  needConfirm,
256
- encrypt,
257
- clientInfo: {
258
- os: 'web',
259
- os_ver: osVersion(),
260
- client_ver: packageInfo.version
261
- }
155
+ encrypt
262
156
  };
263
157
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
264
158
  body: JSON.stringify(body)
@@ -379,10 +273,21 @@ function saveExtraDoc(params) {
379
273
  });
380
274
  }
381
275
 
276
+ var name = "@authme/id-recognition";
277
+ var version$1 = "2.4.11";
278
+ var peerDependencies = {
279
+ "core-js": "^3.6.0"
280
+ };
281
+ var packageInfo = {
282
+ name: name,
283
+ version: version$1,
284
+ peerDependencies: peerDependencies
285
+ };
286
+
382
287
  var _a;
383
288
  var _b, _c;
384
289
  const version = packageInfo.version;
385
290
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
386
291
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
387
292
 
388
- 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 };
293
+ 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,11 +1,10 @@
1
1
  {
2
2
  "name": "@authme/id-recognition",
3
- "version": "2.4.8",
3
+ "version": "2.4.11",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/core": "2.4.8",
7
- "@authme/util": "2.4.8",
8
- "@authme/engine": "2.4.8"
6
+ "@authme/core": "2.4.11",
7
+ "@authme/engine": "2.4.11"
9
8
  },
10
9
  "module": "./index.js",
11
10
  "main": "./index.cjs",
@@ -1,7 +1,7 @@
1
- import { CountryCode, IdRecognitionCardType, RecognitionFileType, ResourceImageType } 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, cardTypes: string[], encrypt?: boolean): Promise<InitScanResponse>;
4
- export declare function initScanDocument(scanId: string, cardType: string): Promise<{
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<{
5
5
  scanDocumentId: string;
6
6
  }>;
7
7
  export declare function recognition(documentId: string, file: Blob): Promise<{
@@ -6,25 +6,7 @@ export declare enum ResourceImageType {
6
6
  }
7
7
  export declare enum CountryCode {
8
8
  TWN = "TWN",
9
- JPN = "JPN",
10
- ZAF = "ZAF",
11
- USA = "USA",
12
- CHN = "CHN",
13
- PHL = "PHL",
14
- GBR = "GBR",
15
- KOR = "KOR",
16
- HKG = "HKG",
17
- FRA = "FRA",
18
- ESP = "ESP",
19
- MEX = "MEX",
20
- ITA = "ITA",
21
- IND = "IND",
22
- COL = "COL",
23
- RUS = "RUS",
24
- DEU = "DEU",
25
- TUR = "TUR",
26
- CAN = "CAN",
27
- AUS = "AUS"
9
+ JPW = "JP"
28
10
  }
29
11
  export declare enum IdRecognitionCardType {
30
12
  IDCard = "IDCard",
@@ -4,9 +4,10 @@ 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
- setParams(params: any): Promise<unknown>;
10
11
  }
11
12
  export interface Point {
12
13
  x: number;
package/src/lib/util.d.ts CHANGED
@@ -1,8 +1,5 @@
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;
6
3
  export declare function getRecognitionColumnOrder(column: string): number;
7
4
  export declare const twoWayAuthmeCardClassMap: {
8
5
  toServer(clientEnum: `${EAuthMeCardClass}`): `${ServerSideEAuthMeCardClass}`;