@authme/id-recognition 2.4.6 → 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
@@ -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,13 @@ 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";
23
31
  })(exports.CountryCode || (exports.CountryCode = {}));
24
32
  exports.IdRecognitionCardType = void 0;
25
33
  (function (IdRecognitionCardType) {
@@ -140,6 +148,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
140
148
  function getCardSubTypes(type, country) {
141
149
  return CardTypeMapping[type];
142
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
+ }
143
212
  function getRecognitionColumnOrder(column) {
144
213
  var _a;
145
214
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -157,12 +226,30 @@ const twoWayAuthmeCardClassMap = (() => {
157
226
  };
158
227
  })();
159
228
 
160
- 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
+ }
161
243
  const body = {
162
244
  scanType: type === exports.IdRecognitionCardType.Passport ? type : `${country}_${type}`,
163
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
245
+ cardTypes: useCardTypes,
164
246
  needConfirm,
165
- encrypt
247
+ encrypt,
248
+ clientInfo: {
249
+ os: 'web',
250
+ os_ver: util.osVersion(),
251
+ client_ver: packageInfo.version
252
+ }
166
253
  };
167
254
  return core.sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
168
255
  body: JSON.stringify(body)
@@ -283,17 +370,6 @@ function saveExtraDoc(params) {
283
370
  });
284
371
  }
285
372
 
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
373
  var _a;
298
374
  var _b, _c;
299
375
  const version = packageInfo.version;
@@ -332,12 +408,15 @@ exports.CardOCR = CardOCR;
332
408
  exports.IdCardAntiFraudService = IdCardAntiFraudService;
333
409
  exports.IdTypeConfig = IdTypeConfig;
334
410
  exports.MRZService = MRZService;
411
+ exports.cardTypeConfirmTitle = cardTypeConfirmTitle;
412
+ exports.cardTypeTitle = cardTypeTitle;
335
413
  exports.confirmScan = confirmScan;
336
414
  exports.finishScanDocument = finishScanDocument;
337
415
  exports.getCardSubTypes = getCardSubTypes;
338
416
  exports.getRecognitionColumnOrder = getRecognitionColumnOrder;
339
417
  exports.init = init;
340
418
  exports.initScanDocument = initScanDocument;
419
+ exports.mapCardtypeToAuthmeClass = mapCardtypeToAuthmeClass;
341
420
  exports.recognition = recognition;
342
421
  exports.recognitionEncrypt = recognitionEncrypt;
343
422
  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,13 @@ 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";
20
28
  })(CountryCode || (CountryCode = {}));
21
29
  var IdRecognitionCardType;
22
30
  (function (IdRecognitionCardType) {
@@ -137,6 +145,67 @@ const RECOGNITION_COLUMNS_ORDER = Object.fromEntries(['surname', 'givenName', 'n
137
145
  function getCardSubTypes(type, country) {
138
146
  return CardTypeMapping[type];
139
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
+ }
140
209
  function getRecognitionColumnOrder(column) {
141
210
  var _a;
142
211
  return (_a = RECOGNITION_COLUMNS_ORDER[column]) !== null && _a !== void 0 ? _a : Number.MAX_VALUE;
@@ -154,12 +223,30 @@ const twoWayAuthmeCardClassMap = (() => {
154
223
  };
155
224
  })();
156
225
 
157
- 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
+ }
158
240
  const body = {
159
241
  scanType: type === IdRecognitionCardType.Passport ? type : `${country}_${type}`,
160
- cardTypes: getCardSubTypes(type).map(c => twoWayAuthmeCardClassMap.toServer(c)),
242
+ cardTypes: useCardTypes,
161
243
  needConfirm,
162
- encrypt
244
+ encrypt,
245
+ clientInfo: {
246
+ os: 'web',
247
+ os_ver: osVersion(),
248
+ client_ver: packageInfo.version
249
+ }
163
250
  };
164
251
  return sendRequest('/api/identity-verification/id-recognition/v3/init-scan', 'POST', {
165
252
  body: JSON.stringify(body)
@@ -280,21 +367,10 @@ function saveExtraDoc(params) {
280
367
  });
281
368
  }
282
369
 
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
370
  var _a;
295
371
  var _b, _c;
296
372
  const version = packageInfo.version;
297
373
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
298
374
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
299
375
 
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 };
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.6",
3
+ "version": "2.4.7",
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.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, 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,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",
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}`;