@authme/id-recognition 2.4.6 → 2.4.8

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
@@ -6,8 +6,10 @@ require('core-js/modules/es.object.assign.js');
6
6
  var engine = require('@authme/engine');
7
7
  require('core-js/modules/es.array.iterator.js');
8
8
  require('core-js/modules/es.object.from-entries.js');
9
+ require('core-js/modules/es.regexp.to-string.js');
9
10
  require('core-js/modules/web.dom-collections.iterator.js');
10
11
  var core = require('@authme/core');
12
+ var util = require('@authme/util');
11
13
  require('core-js/modules/es.symbol.description.js');
12
14
 
13
15
  exports.ResourceImageType = void 0;
@@ -19,7 +21,25 @@ exports.ResourceImageType = void 0;
19
21
  exports.CountryCode = void 0;
20
22
  (function (CountryCode) {
21
23
  CountryCode["TWN"] = "TWN";
22
- 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";
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";
23
43
  })(exports.CountryCode || (exports.CountryCode = {}));
24
44
  exports.IdRecognitionCardType = void 0;
25
45
  (function (IdRecognitionCardType) {
@@ -140,6 +160,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
140
160
  function getCardSubTypes(type, country) {
141
161
  return CardTypeMapping[type];
142
162
  }
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
+ }
143
224
  function getRecognitionColumnOrder(column) {
144
225
  var _a;
145
226
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -157,12 +238,30 @@ const twoWayAuthmeCardClassMap = (() => {
157
238
  };
158
239
  })();
159
240
 
160
- function init(type, country, needConfirm, encrypt = true) {
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
+ }
161
255
  const body = {
162
256
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
163
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
257
+ cardTypes: useCardTypes,
164
258
  needConfirm,
165
- encrypt
259
+ encrypt,
260
+ clientInfo: {
261
+ os: 'web',
262
+ os_ver: util.osVersion(),
263
+ client_ver: packageInfo.version
264
+ }
166
265
  };
167
266
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
168
267
  body: JSON.stringify(body)
@@ -283,17 +382,6 @@ function saveExtraDoc(params) {
283
382
  });
284
383
  }
285
384
 
286
- var name = "@authme/id-recognition";
287
- var version$1 = "2.4.6";
288
- var peerDependencies = {
289
- "core-js": "^3.6.0"
290
- };
291
- var packageInfo = {
292
- name: name,
293
- version: version$1,
294
- peerDependencies: peerDependencies
295
- };
296
-
297
385
  var _a;
298
386
  var _b, _c;
299
387
  const version = packageInfo.version;
@@ -332,12 +420,15 @@ exports.CardOCR = CardOCR;
332
420
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
333
421
  exports.IdTypeConfig = IdTypeConfig;
334
422
  exports.MRZService = MRZService;
423
+ exports.cardTypeConfirmTitle = cardTypeConfirmTitle;
424
+ exports.cardTypeTitle = cardTypeTitle;
335
425
  exports.confirmScan = confirmScan;
336
426
  exports.finishScanDocument = finishScanDocument;
337
427
  exports.getCardSubTypes = getCardSubTypes;
338
428
  exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
339
429
  exports.init = init;
340
430
  exports.initScanDocument = initScanDocument;
431
+ exports.mapCardtypeToAuthmeClass = mapCardtypeToAuthmeClass;
341
432
  exports.recognition = recognition;
342
433
  exports.recognitionEncrypt = recognitionEncrypt;
343
434
  exports.saveExtraDoc = saveExtraDoc;
package/index.js CHANGED
@@ -3,8 +3,10 @@ import { AuthmeEngineModuleBase, EAuthMeCardClass, EngineModule } from '@authme/
3
3
  export { EAuthMeCardClass, EAuthMeCardMatchStatus, EAuthMeCardOCRStatus, EAuthMeIDCardAntiFraudStage, EAuthMeIDCardAntiFraudStatus, EAuthMeMRZRecogStatus, EAuthMeMRZServiceStatus } from '@authme/engine';
4
4
  import 'core-js/modules/es.array.iterator.js';
5
5
  import 'core-js/modules/es.object.from-entries.js';
6
+ import 'core-js/modules/es.regexp.to-string.js';
6
7
  import 'core-js/modules/web.dom-collections.iterator.js';
7
8
  import { sendRequest, AuthmeError } from '@authme/core';
9
+ import { osVersion } from '@authme/util';
8
10
  import 'core-js/modules/es.symbol.description.js';
9
11
 
10
12
  var ResourceImageType;
@@ -16,7 +18,25 @@ var ResourceImageType;
16
18
  var CountryCode;
17
19
  (function (CountryCode) {
18
20
  CountryCode["TWN"] = "TWN";
19
- 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";
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";
20
40
  })(CountryCode || (CountryCode = {}));
21
41
  var IdRecognitionCardType;
22
42
  (function (IdRecognitionCardType) {
@@ -137,6 +157,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
137
157
  function getCardSubTypes(type, country) {
138
158
  return CardTypeMapping[type];
139
159
  }
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
+ }
140
221
  function getRecognitionColumnOrder(column) {
141
222
  var _a;
142
223
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -154,12 +235,30 @@ const twoWayAuthmeCardClassMap = (() => {
154
235
  };
155
236
  })();
156
237
 
157
- function init(type, country, needConfirm, encrypt = true) {
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
+ }
158
252
  const body = {
159
253
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
160
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
254
+ cardTypes: useCardTypes,
161
255
  needConfirm,
162
- encrypt
256
+ encrypt,
257
+ clientInfo: {
258
+ os: 'web',
259
+ os_ver: osVersion(),
260
+ client_ver: packageInfo.version
261
+ }
163
262
  };
164
263
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
165
264
  body: JSON.stringify(body)
@@ -280,21 +379,10 @@ function saveExtraDoc(params) {
280
379
  });
281
380
  }
282
381
 
283
- var name = "@authme/id-recognition";
284
- var version$1 = "2.4.6";
285
- var peerDependencies = {
286
- "core-js": "^3.6.0"
287
- };
288
- var packageInfo = {
289
- name: name,
290
- version: version$1,
291
- peerDependencies: peerDependencies
292
- };
293
-
294
382
  var _a;
295
383
  var _b, _c;
296
384
  const version = packageInfo.version;
297
385
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
298
386
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
299
387
 
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 };
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 };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@authme/id-recognition",
3
- "version": "2.4.6",
3
+ "version": "2.4.8",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/core": "2.4.6",
7
- "@authme/engine": "2.4.6"
6
+ "@authme/core": "2.4.8",
7
+ "@authme/util": "2.4.8",
8
+ "@authme/engine": "2.4.8"
8
9
  },
9
10
  "module": "./index.js",
10
11
  "main": "./index.cjs",
@@ -1,7 +1,7 @@
1
- import { CountryCode, IdRecognitionCardType, RecognitionFileType, 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<{
@@ -6,7 +6,25 @@ 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",
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"
10
28
  }
11
29
  export declare enum IdRecognitionCardType {
12
30
  IDCard = "IDCard",
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}`;