@authme/id-recognition 2.4.2 → 2.4.4-rc.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
@@ -42,6 +42,11 @@ exports.ServerSideEAuthMeCardClass = void 0;
42
42
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
43
43
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
44
44
  })(exports.ServerSideEAuthMeCardClass || (exports.ServerSideEAuthMeCardClass = {}));
45
+ exports.RecognitionFileType = void 0;
46
+ (function (RecognitionFileType) {
47
+ RecognitionFileType["OriginImage"] = "OriginImage";
48
+ RecognitionFileType["FlatImage"] = "FlatImage";
49
+ })(exports.RecognitionFileType || (exports.RecognitionFileType = {}));
45
50
 
46
51
  class CardOCR extends engine.AuthmeEngineModuleBase {
47
52
  constructor(engine$1) {
@@ -69,6 +74,9 @@ class IdCardAntiFraudService extends engine.AuthmeEngineModuleBase {
69
74
  const stageStrList = stageList.map(x => x.split('_')[1]);
70
75
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
71
76
  }
77
+ getCardMatchROI() {
78
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
79
+ }
72
80
  }
73
81
  class MRZService extends engine.AuthmeEngineModuleBase {
74
82
  constructor(engine$1, type = 'passport') {
@@ -180,12 +188,12 @@ function recognition(documentId, file) {
180
188
  throw error;
181
189
  });
182
190
  }
183
- function recognitionEncrypt(documentId, base64Text, report) {
191
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
184
192
  return core.sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
185
193
  body: JSON.stringify({
186
194
  scanDocumentId: documentId,
187
195
  image: base64Text,
188
- fileType: 'image/jpeg',
196
+ fileType: fileType,
189
197
  info: {
190
198
  report
191
199
  }
@@ -202,6 +210,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
202
210
  throw error;
203
211
  });
204
212
  }
213
+ function uploadFrameBase64(documentId, base64Text, index, type = exports.ResourceImageType.Recognition, report) {
214
+ return core.sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
215
+ body: JSON.stringify({
216
+ scanDocumentId: documentId,
217
+ image: base64Text,
218
+ type,
219
+ // fileType: 'image/jpeg',
220
+ info: {
221
+ report,
222
+ index
223
+ }
224
+ }),
225
+ contentType: 'application/json'
226
+ }).catch(error => {
227
+ var _a, _b, _c;
228
+ 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') {
229
+ return {
230
+ retry: true,
231
+ details: {}
232
+ };
233
+ }
234
+ throw error;
235
+ });
236
+ }
205
237
  function saveResourceImage(documentId, type, file) {
206
238
  const formData = new FormData();
207
239
  formData.append('scanDocumentId', documentId);
@@ -245,7 +277,7 @@ function saveExtraDoc(params) {
245
277
  }
246
278
 
247
279
  var name = "@authme/id-recognition";
248
- var version$1 = "2.4.2";
280
+ var version$1 = "2.4.4-rc.7";
249
281
  var peerDependencies = {
250
282
  "core-js": "^3.6.0"
251
283
  };
@@ -304,4 +336,5 @@ exports.recognitionEncrypt = recognitionEncrypt;
304
336
  exports.saveExtraDoc = saveExtraDoc;
305
337
  exports.saveResourceImage = saveResourceImage;
306
338
  exports.twoWayAuthmeCardClassMap = twoWayAuthmeCardClassMap;
339
+ exports.uploadFrameBase64 = uploadFrameBase64;
307
340
  exports.version = version;
package/index.js CHANGED
@@ -39,6 +39,11 @@ var ServerSideEAuthMeCardClass;
39
39
  ServerSideEAuthMeCardClass["TWN_HealthCard_Front"] = "TWN_HealthCard_Front";
40
40
  ServerSideEAuthMeCardClass["TWN_VehiclesLicense_Front"] = "TWN_VehiclesLicense_Front";
41
41
  })(ServerSideEAuthMeCardClass || (ServerSideEAuthMeCardClass = {}));
42
+ var RecognitionFileType;
43
+ (function (RecognitionFileType) {
44
+ RecognitionFileType["OriginImage"] = "OriginImage";
45
+ RecognitionFileType["FlatImage"] = "FlatImage";
46
+ })(RecognitionFileType || (RecognitionFileType = {}));
42
47
 
43
48
  class CardOCR extends AuthmeEngineModuleBase {
44
49
  constructor(engine) {
@@ -66,6 +71,9 @@ class IdCardAntiFraudService extends AuthmeEngineModuleBase {
66
71
  const stageStrList = stageList.map(x => x.split('_')[1]);
67
72
  return this.engine.run(this.moduleName, 'setStage', stageStrList);
68
73
  }
74
+ getCardMatchROI() {
75
+ return this.engine.run(this.moduleName, 'getCardMatchROI');
76
+ }
69
77
  }
70
78
  class MRZService extends AuthmeEngineModuleBase {
71
79
  constructor(engine, type = 'passport') {
@@ -177,12 +185,12 @@ function recognition(documentId, file) {
177
185
  throw error;
178
186
  });
179
187
  }
180
- function recognitionEncrypt(documentId, base64Text, report) {
188
+ function recognitionEncrypt(documentId, base64Text, report, fileType) {
181
189
  return sendRequest('/api/identity-verification/id-recognition/v3/recognize-base64', 'POST', {
182
190
  body: JSON.stringify({
183
191
  scanDocumentId: documentId,
184
192
  image: base64Text,
185
- fileType: 'image/jpeg',
193
+ fileType: fileType,
186
194
  info: {
187
195
  report
188
196
  }
@@ -199,6 +207,30 @@ function recognitionEncrypt(documentId, base64Text, report) {
199
207
  throw error;
200
208
  });
201
209
  }
210
+ function uploadFrameBase64(documentId, base64Text, index, type = ResourceImageType.Recognition, report) {
211
+ return sendRequest('/api/identity-verification/id-recognition/v3/upload-frame-base64', 'POST', {
212
+ body: JSON.stringify({
213
+ scanDocumentId: documentId,
214
+ image: base64Text,
215
+ type,
216
+ // fileType: 'image/jpeg',
217
+ info: {
218
+ report,
219
+ index
220
+ }
221
+ }),
222
+ contentType: 'application/json'
223
+ }).catch(error => {
224
+ var _a, _b, _c;
225
+ 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') {
226
+ return {
227
+ retry: true,
228
+ details: {}
229
+ };
230
+ }
231
+ throw error;
232
+ });
233
+ }
202
234
  function saveResourceImage(documentId, type, file) {
203
235
  const formData = new FormData();
204
236
  formData.append('scanDocumentId', documentId);
@@ -242,7 +274,7 @@ function saveExtraDoc(params) {
242
274
  }
243
275
 
244
276
  var name = "@authme/id-recognition";
245
- var version$1 = "2.4.2";
277
+ var version$1 = "2.4.4-rc.7";
246
278
  var peerDependencies = {
247
279
  "core-js": "^3.6.0"
248
280
  };
@@ -258,4 +290,4 @@ const version = packageInfo.version;
258
290
  (_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
259
291
  window[Symbol.for('authme-sdk')][packageInfo.name] = version;
260
292
 
261
- export { CardOCR, CountryCode, IdCardAntiFraudService, IdRecognitionCardType, IdType, IdTypeConfig, MRZService, ResourceImageType, ServerSideEAuthMeCardClass, confirmScan, finishScanDocument, getCardSubTypes, getRecognitionColumnOrder, init, initScanDocument, recognition, recognitionEncrypt, saveExtraDoc, saveResourceImage, twoWayAuthmeCardClassMap, 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,10 +1,10 @@
1
1
  {
2
2
  "name": "@authme/id-recognition",
3
- "version": "2.4.2",
3
+ "version": "2.4.4-rc.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.4-rc.7",
7
+ "@authme/engine": "2.4.4-rc.7"
8
8
  },
9
9
  "module": "./index.js",
10
10
  "main": "./index.cjs",
@@ -1,4 +1,4 @@
1
- import { CountryCode, IdRecognitionCardType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
1
+ import { CountryCode, IdRecognitionCardType, RecognitionFileType, ResourceImageType, ServerSideEAuthMeCardClass } from '../enum';
2
2
  import { InitScanResponse } from '../model';
3
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<{
@@ -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;
@@ -28,3 +28,7 @@ export declare enum ServerSideEAuthMeCardClass {
28
28
  TWN_HealthCard_Front = "TWN_HealthCard_Front",
29
29
  TWN_VehiclesLicense_Front = "TWN_VehiclesLicense_Front"
30
30
  }
31
+ export declare enum RecognitionFileType {
32
+ OriginImage = "OriginImage",
33
+ FlatImage = "FlatImage"
34
+ }
@@ -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
  }
@@ -9,9 +9,14 @@ export declare class CardOCR extends AuthmeEngineModuleBase<CardOCRResult> {
9
9
  }): Promise<unknown>;
10
10
  getType(): EAuthMeCardClass;
11
11
  }
12
+ export interface Point {
13
+ x: number;
14
+ y: number;
15
+ }
12
16
  export declare class IdCardAntiFraudService extends AuthmeEngineModuleBase<IDCardAntiFraudResult> {
13
17
  constructor(engine: MlEngine);
14
18
  setStage(stageList: EAuthMeIDCardAntiFraudStage[]): Promise<unknown>;
19
+ getCardMatchROI(): Promise<Point[]>;
15
20
  }
16
21
  export declare class MRZService<T extends PassportResult | ResidentCardResult> extends AuthmeEngineModuleBase<T> {
17
22
  private type;