santoid-sdk 5.2.0 → 5.4.0

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.
Files changed (66) hide show
  1. package/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log +263 -295
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +455 -143
  4. package/api/ApiAsyncService.d.ts +32 -0
  5. package/api/ApiAsyncService.js +15 -0
  6. package/api/ApiFaceMatchService.d.ts +30 -0
  7. package/api/ApiFaceMatchService.js +32 -0
  8. package/api/ApiOcrService.d.ts +62 -0
  9. package/api/ApiOcrService.js +25 -0
  10. package/api/ApiTypificationService.d.ts +23 -0
  11. package/api/{TypificationService.js → ApiTypificationService.js} +8 -9
  12. package/browser/index.js +1 -1
  13. package/client/core/commons/BaseCoreService.d.ts +23 -0
  14. package/client/core/commons/BaseCoreService.js +156 -0
  15. package/client/core/index.d.ts +4 -0
  16. package/client/core/index.js +9 -0
  17. package/client/core/methods/faceMatch/Service.d.ts +19 -0
  18. package/client/core/methods/faceMatch/Service.js +122 -0
  19. package/client/core/methods/faceMatch/index.d.ts +15 -0
  20. package/client/core/methods/faceMatch/index.js +43 -0
  21. package/client/core/methods/ocr/Service.d.ts +11 -0
  22. package/client/core/methods/ocr/Service.js +52 -0
  23. package/client/core/methods/ocr/index.d.ts +10 -0
  24. package/client/core/methods/ocr/index.js +40 -0
  25. package/client/core/methods/typification/Service.d.ts +9 -0
  26. package/client/core/methods/typification/Service.js +52 -0
  27. package/client/core/methods/typification/index.d.ts +10 -0
  28. package/client/core/methods/typification/index.js +40 -0
  29. package/client/core/utils/types.d.ts +30 -0
  30. package/client/core/utils/types.js +2 -0
  31. package/client/index.d.ts +6 -0
  32. package/client/index.js +6 -0
  33. package/client/liveness/methods/livenessDetection/Service.js +10 -2
  34. package/client/liveness/methods/livenessDetection/index.js +5 -1
  35. package/client/liveness/methods/uploadIdentificationDocument/Service.d.ts +19 -19
  36. package/client/liveness/methods/uploadIdentificationDocument/Service.js +8 -4
  37. package/client/liveness/methods/uploadIdentificationDocument/index.d.ts +4 -6
  38. package/client/liveness/utils/getNextFrame.d.ts +4 -1
  39. package/client/liveness/utils/getNextFrame.js +9 -3
  40. package/package.json +1 -1
  41. package/server/core/index.d.ts +4 -0
  42. package/server/core/index.js +9 -0
  43. package/server/core/methods/faceMatch/Service.d.ts +9 -0
  44. package/server/core/methods/faceMatch/Service.js +23 -0
  45. package/server/core/methods/faceMatch/index.d.ts +7 -0
  46. package/server/core/methods/faceMatch/index.js +28 -0
  47. package/server/core/methods/ocr/Service.d.ts +9 -0
  48. package/server/core/methods/ocr/Service.js +23 -0
  49. package/server/core/methods/ocr/index.d.ts +7 -0
  50. package/server/core/methods/ocr/index.js +28 -0
  51. package/server/core/methods/typification/Service.d.ts +9 -0
  52. package/server/core/methods/typification/Service.js +23 -0
  53. package/server/core/methods/typification/index.d.ts +7 -0
  54. package/server/core/methods/typification/index.js +28 -0
  55. package/server/index.d.ts +6 -0
  56. package/server/index.js +6 -0
  57. package/server/liveness/methods/livenessDetection/index.js +5 -1
  58. package/server/liveness/methods/uploadIdentificationDocument/Service.d.ts +2 -2
  59. package/server/liveness/methods/uploadIdentificationDocument/Service.js +4 -4
  60. package/server/liveness/methods/uploadIdentificationDocument/index.d.ts +6 -8
  61. package/utils/error.d.ts +19 -2
  62. package/utils/error.js +21 -2
  63. package/utils/types.d.ts +1 -0
  64. package/api/FaceMatchService.d.ts +0 -42
  65. package/api/FaceMatchService.js +0 -26
  66. package/api/TypificationService.d.ts +0 -90
package/client/index.js CHANGED
@@ -3,9 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const livenessDetection_1 = require("./liveness/methods/livenessDetection");
4
4
  const uploadIdentificationDocument_1 = require("./liveness/methods/uploadIdentificationDocument");
5
5
  const insertUploadIdentificationDocument_1 = require("./embedded/methods/insertUploadIdentificationDocument");
6
+ const typification_1 = require("./core/methods/typification");
7
+ const faceMatch_1 = require("./core/methods/faceMatch");
8
+ const ocr_1 = require("./core/methods/ocr");
6
9
  class SantoiDSDK {
7
10
  }
8
11
  SantoiDSDK.livenessDetection = livenessDetection_1.livenessDetection;
9
12
  SantoiDSDK.uploadIdentificationDocument = uploadIdentificationDocument_1.uploadIdentificationDocument;
10
13
  SantoiDSDK.insertUploadIdentificationDocument = insertUploadIdentificationDocument_1.insertUploadIdentificationDocument;
14
+ SantoiDSDK.typification = typification_1.typification;
15
+ SantoiDSDK.ocr = ocr_1.ocr;
16
+ SantoiDSDK.faceMatch = faceMatch_1.faceMatch;
11
17
  exports.default = SantoiDSDK;
@@ -50,7 +50,11 @@ class LivenessDetectionService {
50
50
  await this.stopLivenessDetection();
51
51
  }
52
52
  if (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.error) {
53
- await ((_h = (_g = this.options).onError) === null || _h === void 0 ? void 0 : _h.call(_g, new error_1.SDKError({ message: 'Wrong position', code: error_1.ELivenessDetectionErrorCodes.WRONG_POSITION })));
53
+ await ((_h = (_g = this.options).onError) === null || _h === void 0 ? void 0 : _h.call(_g, new error_1.SDKError({
54
+ message: 'Wrong position',
55
+ code: error_1.ELivenessDetectionErrorCodes.WRONG_POSITION,
56
+ fatal: false,
57
+ })));
54
58
  }
55
59
  return parsedMessage;
56
60
  }
@@ -112,7 +116,11 @@ class LivenessDetectionService {
112
116
  async onError() {
113
117
  var _a, _b;
114
118
  if (!this.validationSuccess) {
115
- await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, new error_1.SDKError({ message: 'Internal Error', code: error_1.EDefaultErrorCodes.INTERNAL_ERROR })));
119
+ await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, new error_1.SDKError({
120
+ message: 'Internal Error',
121
+ code: error_1.EDefaultErrorCodes.INTERNAL_ERROR,
122
+ fatal: false,
123
+ })));
116
124
  await this.stopLivenessDetection();
117
125
  }
118
126
  }
@@ -40,7 +40,11 @@ function livenessDetection(options) {
40
40
  };
41
41
  }
42
42
  catch (err) {
43
- throw new error_1.SDKError({ message: 'Error while starting SDK', code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR });
43
+ throw new error_1.SDKError({
44
+ message: 'Error while starting SDK',
45
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
46
+ fatal: true,
47
+ });
44
48
  }
45
49
  }
46
50
  exports.livenessDetection = livenessDetection;
@@ -1,29 +1,29 @@
1
- import { TypificationService, type ITypificationResult } from '../../../../api/TypificationService';
2
- import { FaceMatchService, type IFaceMatchResult } from '../../../../api/FaceMatchService';
1
+ import { ApiTypificationService, type ITypificationResult } from '../../../../api/ApiTypificationService';
2
+ import { ApiFaceMatchService, type IFaceMatchResult } from '../../../../api/ApiFaceMatchService';
3
3
  import { type ILivenessResults, type IBaseSDKOptions, type TCallbackFunction, type ISDKOptions } from '../../../../utils/types';
4
4
  import { SDKError } from '../../../../utils/error';
5
5
  import { type livenessDetection } from '../livenessDetection';
6
- export declare class UploadIdentificationDocumentService<TFrameType, TMediaType, TFileType> {
7
- options: IServiceOptions<TFrameType, TMediaType, TFileType>;
6
+ export declare class UploadIdentificationDocumentService<TFrameType, TMediaType> {
7
+ options: IServiceOptions<TFrameType, TMediaType>;
8
8
  internalOptions: IInternalServiceOptions<TFrameType, TMediaType>;
9
- typificationService: TypificationService<TFileType>;
10
- faceMatchService: FaceMatchService<TFileType>;
11
- results: IUploadIdentificationDocumentResults<TFileType>;
12
- constructor(options: IServiceOptions<TFrameType, TMediaType, TFileType>, internalOptions: IInternalServiceOptions<TFrameType, TMediaType>);
13
- getResults(): IUploadIdentificationDocumentResults<TFileType>;
14
- updateResults(updatedResults: Partial<IUploadIdentificationDocumentResults<TFileType>>): Promise<void>;
15
- updateUploadedDocument(file: TFileType): void;
9
+ typificationService: ApiTypificationService<TFrameType>;
10
+ faceMatchService: ApiFaceMatchService<TFrameType>;
11
+ results: IUploadIdentificationDocumentResults<TFrameType>;
12
+ constructor(options: IServiceOptions<TFrameType, TMediaType>, internalOptions: IInternalServiceOptions<TFrameType, TMediaType>);
13
+ getResults(): IUploadIdentificationDocumentResults<TFrameType>;
14
+ updateResults(updatedResults: Partial<IUploadIdentificationDocumentResults<TFrameType>>): Promise<void>;
15
+ updateUploadedDocument(file: TFrameType): void;
16
16
  waitForResults(requestId: string): Promise<ITypificationResult>;
17
17
  waitForResultsFaceMatch(requestId: string): Promise<IFaceMatchResult>;
18
- startDocumentUpload(file: TFileType): Promise<void>;
18
+ startDocumentUpload(file: TFrameType): Promise<void>;
19
19
  startLivenessDetection(startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): TLivenessDetectionReturn<TMediaType> | undefined;
20
- startFaceMatch(firstImage: TFileType, secondImage: TFileType): Promise<void>;
20
+ startFaceMatch(firstImage: TFrameType, secondImage: TFrameType): Promise<void>;
21
21
  tryStartFaceMatch(): Promise<void>;
22
- startAll(file: TFileType, startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): void;
22
+ startAll(file: TFrameType, startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): void;
23
23
  }
24
24
  type TResultStatuses = 'success' | 'error' | null;
25
- export interface IUploadIdentificationDocumentResults<TFileType> {
26
- uploadedDocument: TFileType | null;
25
+ export interface IUploadIdentificationDocumentResults<TFrameType> {
26
+ uploadedDocument: TFrameType | null;
27
27
  typification: {
28
28
  status: TResultStatuses;
29
29
  results: ITypificationResult | null;
@@ -32,7 +32,7 @@ export interface IUploadIdentificationDocumentResults<TFileType> {
32
32
  };
33
33
  liveness: {
34
34
  status: TResultStatuses;
35
- results: ILivenessResults<TFileType | null | undefined> | null;
35
+ results: ILivenessResults<TFrameType | null | undefined> | null;
36
36
  loading: boolean;
37
37
  error: SDKError | null;
38
38
  };
@@ -47,9 +47,9 @@ type ICustomLivenessOptions<TFrameType, TMediaType> = Omit<ISDKOptions<TFrameTyp
47
47
  track?: string;
48
48
  token?: string;
49
49
  };
50
- export interface IServiceOptions<TFrameType, TMediaType, TFileType> extends IBaseSDKOptions {
50
+ export interface IServiceOptions<TFrameType, TMediaType> extends IBaseSDKOptions {
51
51
  livenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>;
52
- onUpdate?: (results?: IUploadIdentificationDocumentResults<TFileType>) => void | Promise<void>;
52
+ onUpdate?: (results?: IUploadIdentificationDocumentResults<TFrameType>) => void | Promise<void>;
53
53
  onSuccess?: <TFrameType, ResultsType = ILivenessResults<TFrameType>>(results?: ResultsType) => void | Promise<void>;
54
54
  onError?: (error?: SDKError) => void | Promise<void>;
55
55
  onEnd?: TCallbackFunction;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UploadIdentificationDocumentService = void 0;
4
- const TypificationService_1 = require("../../../../api/TypificationService");
5
- const FaceMatchService_1 = require("../../../../api/FaceMatchService");
4
+ const ApiTypificationService_1 = require("../../../../api/ApiTypificationService");
5
+ const ApiFaceMatchService_1 = require("../../../../api/ApiFaceMatchService");
6
6
  const error_1 = require("../../../../utils/error");
7
7
  const uuid_1 = require("uuid");
8
8
  const index_1 = require("../../utils/index");
@@ -16,8 +16,8 @@ class UploadIdentificationDocumentService {
16
16
  };
17
17
  this.options = options;
18
18
  this.internalOptions = internalOptions;
19
- this.typificationService = new TypificationService_1.TypificationService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
20
- this.faceMatchService = new FaceMatchService_1.FaceMatchService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
19
+ this.typificationService = new ApiTypificationService_1.ApiTypificationService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
20
+ this.faceMatchService = new ApiFaceMatchService_1.ApiFaceMatchService(options, { FormDataClass: FormData, tryDecodeJwt: index_1.tryDecodeJwt });
21
21
  }
22
22
  getResults() {
23
23
  return this.results;
@@ -114,6 +114,7 @@ class UploadIdentificationDocumentService {
114
114
  const adaptedError = new error_1.SDKError({
115
115
  message: 'Error during document upload/analysis',
116
116
  code: error_1.EUploadIdentificationDocumentErrorCodes.DOCUMENT_ANALYSIS_ERROR,
117
+ fatal: false,
117
118
  details: err,
118
119
  });
119
120
  await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError));
@@ -154,6 +155,7 @@ class UploadIdentificationDocumentService {
154
155
  const adaptedError = new error_1.SDKError({
155
156
  message: 'Error during liveness detection',
156
157
  code: error_1.EUploadIdentificationDocumentErrorCodes.LIVENESS_DETECTION_ERROR,
158
+ fatal: false,
157
159
  details: err,
158
160
  });
159
161
  (_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError);
@@ -172,6 +174,7 @@ class UploadIdentificationDocumentService {
172
174
  const adaptedError = new error_1.SDKError({
173
175
  message: 'Error when comparing the face with the document',
174
176
  code: error_1.EUploadIdentificationDocumentErrorCodes.FACE_MATCH_ERROR,
177
+ fatal: false,
175
178
  details: err,
176
179
  });
177
180
  await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError));
@@ -191,6 +194,7 @@ class UploadIdentificationDocumentService {
191
194
  await ((_c = (_b = this.options).onError) === null || _c === void 0 ? void 0 : _c.call(_b, new error_1.SDKError({
192
195
  message: 'Unavailable faces',
193
196
  code: error_1.EUploadIdentificationDocumentErrorCodes.FACE_MATCH_UNAVAILABLE_FACES_ERROR,
197
+ fatal: false,
194
198
  })));
195
199
  }
196
200
  }
@@ -1,8 +1,7 @@
1
1
  import { type IServiceOptions } from './Service';
2
2
  import { type TFrameType, type TMediaType } from '../livenessDetection';
3
- type TFileType = Blob | File;
4
- export declare function uploadIdentificationDocument(options: IServiceOptions<TFrameType, TMediaType, TFileType>): {
5
- startDocumentUpload: (file: TFileType) => Promise<void>;
3
+ export declare function uploadIdentificationDocument(options: IServiceOptions<TFrameType, TMediaType>): {
4
+ startDocumentUpload: (file: TFrameType) => Promise<void>;
6
5
  startLivenessDetection: (startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<TFrameType, TMediaType>, "token" | "track"> & {
7
6
  track?: string | undefined;
8
7
  token?: string | undefined;
@@ -15,10 +14,9 @@ export declare function uploadIdentificationDocument(options: IServiceOptions<TF
15
14
  getVideoStream?: (() => TMediaType) | undefined;
16
15
  }) | undefined;
17
16
  startFaceComparison: () => Promise<void>;
18
- startAll: (file: TFileType, startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<TFrameType, TMediaType>, "token" | "track"> & {
17
+ startAll: (file: TFrameType, startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<TFrameType, TMediaType>, "token" | "track"> & {
19
18
  track?: string | undefined;
20
19
  token?: string | undefined;
21
20
  }) | undefined) => void;
22
- getResults: () => import("./Service").IUploadIdentificationDocumentResults<TFileType>;
21
+ getResults: () => import("./Service").IUploadIdentificationDocumentResults<TFrameType>;
23
22
  };
24
- export {};
@@ -1,5 +1,8 @@
1
+ export interface IStartGettingFramesOptions {
2
+ facingMode?: 'user' | 'environment';
3
+ }
1
4
  export interface IFrameControls<TFrameType, TMediaType> {
2
- startGettingFrames?: () => TMediaType | Promise<TMediaType>;
5
+ startGettingFrames?: (cameraOptions?: IStartGettingFramesOptions) => TMediaType | Promise<TMediaType>;
3
6
  getNextFrame?: () => TFrameType | Promise<TFrameType>;
4
7
  stopGettingFrames?: () => void | Promise<void>;
5
8
  videoStream?: TMediaType;
@@ -41,14 +41,20 @@ async function getDefaultFrameControls() {
41
41
  videoStream = undefined;
42
42
  }
43
43
  }
44
- async function startGettingFrames() {
44
+ async function startGettingFrames(cameraOptions) {
45
+ var _a;
45
46
  if (!videoStream || !videoElement || !canvasElement) {
46
- videoStream = await navigator.mediaDevices.getUserMedia({ video: true });
47
+ videoStream = await navigator.mediaDevices.getUserMedia({
48
+ audio: false,
49
+ video: {
50
+ facingMode: (_a = cameraOptions === null || cameraOptions === void 0 ? void 0 : cameraOptions.facingMode) !== null && _a !== void 0 ? _a : 'user',
51
+ },
52
+ });
47
53
  videoElement = document.createElement('video');
48
54
  videoElement.setAttribute('autoplay', 'true');
49
55
  videoElement.style.transform = 'scale(-1, 1)';
50
56
  videoElement.style.position = 'absolute';
51
- videoElement.style.left = '99999px';
57
+ videoElement.style.left = '-99999px';
52
58
  document.body.appendChild(videoElement);
53
59
  videoElement.srcObject = videoStream;
54
60
  canvasElement = document.createElement('canvas');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "santoid-sdk",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -0,0 +1,4 @@
1
+ import { typification } from './methods/typification';
2
+ import { faceMatch } from './methods/faceMatch';
3
+ import { ocr } from './methods/ocr';
4
+ export { typification, faceMatch, ocr, };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ocr = exports.faceMatch = exports.typification = void 0;
4
+ const typification_1 = require("./methods/typification");
5
+ Object.defineProperty(exports, "typification", { enumerable: true, get: function () { return typification_1.typification; } });
6
+ const faceMatch_1 = require("./methods/faceMatch");
7
+ Object.defineProperty(exports, "faceMatch", { enumerable: true, get: function () { return faceMatch_1.faceMatch; } });
8
+ const ocr_1 = require("./methods/ocr");
9
+ Object.defineProperty(exports, "ocr", { enumerable: true, get: function () { return ocr_1.ocr; } });
@@ -0,0 +1,9 @@
1
+ import { FaceMatchService, type TFaceMatchServiceOptions } from '../../../../client/core/methods/faceMatch/Service';
2
+ export type TNodeFaceMatchServiceOptions<TMediaType> = Omit<TFaceMatchServiceOptions<TMediaType>, 'onStart' | 'onCameraStart' | 'onCameraStop'> & {
3
+ onStart?: () => void | Promise<void>;
4
+ };
5
+ export declare class NodeFaceMatchService<TFrameType, TMediaType> extends FaceMatchService<TFrameType, TMediaType> {
6
+ options: TNodeFaceMatchServiceOptions<TMediaType>;
7
+ constructor(options: TNodeFaceMatchServiceOptions<TMediaType>);
8
+ initialize(file1?: TFrameType, file2?: TFrameType): Promise<void>;
9
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NodeFaceMatchService = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ const Service_1 = require("../../../../client/core/methods/faceMatch/Service");
9
+ const ApiFaceMatchService_1 = require("../../../../api/ApiFaceMatchService");
10
+ const index_1 = require("../../../liveness/utils/index");
11
+ class NodeFaceMatchService extends Service_1.FaceMatchService {
12
+ constructor(options) {
13
+ super(options);
14
+ this.service = new ApiFaceMatchService_1.ApiFaceMatchService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
15
+ }
16
+ async initialize(file1, file2) {
17
+ if (file1) {
18
+ // Start processing immediately
19
+ this.startProcessing(file1, file2);
20
+ }
21
+ }
22
+ }
23
+ exports.NodeFaceMatchService = NodeFaceMatchService;
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { type TNodeFaceMatchServiceOptions } from './Service';
3
+ export type TFrameType = string | Buffer | ArrayBuffer | Buffer;
4
+ export type TMediaType = undefined;
5
+ export declare function faceMatch(options: TNodeFaceMatchServiceOptions<TMediaType>, file1?: TFrameType, file2?: TFrameType): Promise<{
6
+ sendFiles: (file1: TFrameType, file2?: TFrameType | undefined) => Promise<void>;
7
+ }>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.faceMatch = void 0;
4
+ const error_1 = require("../../../../utils/error");
5
+ const Service_1 = require("./Service");
6
+ async function faceMatch(options, file1, file2) {
7
+ var _a, _b;
8
+ try {
9
+ const service = new Service_1.NodeFaceMatchService(options);
10
+ await service.initialize(file1, file2);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ sendFiles: async (...rest) => {
15
+ await service.startProcessing(...rest);
16
+ },
17
+ };
18
+ }
19
+ catch (err) {
20
+ throw new error_1.SDKError({
21
+ message: 'Error while starting SDK',
22
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
23
+ fatal: true,
24
+ details: err,
25
+ });
26
+ }
27
+ }
28
+ exports.faceMatch = faceMatch;
@@ -0,0 +1,9 @@
1
+ import { OcrService, type TOcrServiceOptions } from '../../../../client/core/methods/ocr/Service';
2
+ export type TNodeOcrServiceOptions<TMediaType> = Omit<TOcrServiceOptions<TMediaType>, 'onStart' | 'onCameraStart' | 'onCameraStop'> & {
3
+ onStart?: () => void | Promise<void>;
4
+ };
5
+ export declare class NodeOcrService<TFrameType, TMediaType> extends OcrService<TFrameType, TMediaType> {
6
+ options: TNodeOcrServiceOptions<TMediaType>;
7
+ constructor(options: TNodeOcrServiceOptions<TMediaType>);
8
+ initialize(file?: TFrameType): Promise<void>;
9
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NodeOcrService = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ const Service_1 = require("../../../../client/core/methods/ocr/Service");
9
+ const ApiOcrService_1 = require("../../../../api/ApiOcrService");
10
+ const index_1 = require("../../../liveness/utils/index");
11
+ class NodeOcrService extends Service_1.OcrService {
12
+ constructor(options) {
13
+ super(options);
14
+ this.service = new ApiOcrService_1.ApiOcrService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
15
+ }
16
+ async initialize(file) {
17
+ if (file) {
18
+ // Start processing immediately
19
+ this.startProcessing(file);
20
+ }
21
+ }
22
+ }
23
+ exports.NodeOcrService = NodeOcrService;
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { type TNodeOcrServiceOptions } from './Service';
3
+ export type TFrameType = string | Buffer | ArrayBuffer | Buffer;
4
+ export type TMediaType = undefined;
5
+ export declare function ocr(options: TNodeOcrServiceOptions<TMediaType>, file?: TFrameType): Promise<{
6
+ sendFile: (file: TFrameType) => Promise<void>;
7
+ }>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ocr = void 0;
4
+ const error_1 = require("../../../../utils/error");
5
+ const Service_1 = require("./Service");
6
+ async function ocr(options, file) {
7
+ var _a, _b;
8
+ try {
9
+ const service = new Service_1.NodeOcrService(options);
10
+ await service.initialize(file);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ sendFile: async (file) => {
15
+ await service.startProcessing(file);
16
+ },
17
+ };
18
+ }
19
+ catch (err) {
20
+ throw new error_1.SDKError({
21
+ message: 'Error while starting SDK',
22
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
23
+ fatal: true,
24
+ details: err,
25
+ });
26
+ }
27
+ }
28
+ exports.ocr = ocr;
@@ -0,0 +1,9 @@
1
+ import { TypificationService, type TTypificationServiceOptions } from '../../../../client/core/methods/typification/Service';
2
+ export type TNodeTypificationServiceOptions<TMediaType> = Omit<TTypificationServiceOptions<TMediaType>, 'onStart' | 'onCameraStart' | 'onCameraStop'> & {
3
+ onStart?: () => void | Promise<void>;
4
+ };
5
+ export declare class NodeTypificationService<TFrameType, TMediaType> extends TypificationService<TFrameType, TMediaType> {
6
+ options: TNodeTypificationServiceOptions<TMediaType>;
7
+ constructor(options: TNodeTypificationServiceOptions<TMediaType>);
8
+ initialize(file?: TFrameType): Promise<void>;
9
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NodeTypificationService = void 0;
7
+ const form_data_1 = __importDefault(require("form-data"));
8
+ const Service_1 = require("../../../../client/core/methods/typification/Service");
9
+ const ApiTypificationService_1 = require("../../../../api/ApiTypificationService");
10
+ const index_1 = require("../../../liveness/utils/index");
11
+ class NodeTypificationService extends Service_1.TypificationService {
12
+ constructor(options) {
13
+ super(options);
14
+ this.service = new ApiTypificationService_1.ApiTypificationService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
15
+ }
16
+ async initialize(file) {
17
+ if (file) {
18
+ // Start processing immediately
19
+ this.startProcessing(file);
20
+ }
21
+ }
22
+ }
23
+ exports.NodeTypificationService = NodeTypificationService;
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { type TNodeTypificationServiceOptions } from './Service';
3
+ export type TFrameType = string | Buffer | ArrayBuffer | Buffer;
4
+ export type TMediaType = undefined;
5
+ export declare function typification(options: TNodeTypificationServiceOptions<TMediaType>, file?: TFrameType): Promise<{
6
+ sendFile: (file: TFrameType) => Promise<void>;
7
+ }>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typification = void 0;
4
+ const error_1 = require("../../../../utils/error");
5
+ const Service_1 = require("./Service");
6
+ async function typification(options, file) {
7
+ var _a, _b;
8
+ try {
9
+ const service = new Service_1.NodeTypificationService(options);
10
+ await service.initialize(file);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ sendFile: async (file) => {
15
+ await service.startProcessing(file);
16
+ },
17
+ };
18
+ }
19
+ catch (err) {
20
+ throw new error_1.SDKError({
21
+ message: 'Error while starting SDK',
22
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
23
+ fatal: true,
24
+ details: err,
25
+ });
26
+ }
27
+ }
28
+ exports.typification = typification;
package/server/index.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { livenessDetection } from './liveness/methods/livenessDetection';
2
2
  import { uploadIdentificationDocument } from './liveness/methods/uploadIdentificationDocument';
3
+ import { typification } from './core/methods/typification';
4
+ import { faceMatch } from './core/methods/faceMatch';
5
+ import { ocr } from './core/methods/ocr';
3
6
  export default class SantoiDSDK {
4
7
  static readonly livenessDetection: typeof livenessDetection;
5
8
  static readonly uploadIdentificationDocument: typeof uploadIdentificationDocument;
9
+ static readonly typification: typeof typification;
10
+ static readonly faceMatch: typeof faceMatch;
11
+ static readonly ocr: typeof ocr;
6
12
  }
package/server/index.js CHANGED
@@ -2,8 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const livenessDetection_1 = require("./liveness/methods/livenessDetection");
4
4
  const uploadIdentificationDocument_1 = require("./liveness/methods/uploadIdentificationDocument");
5
+ const typification_1 = require("./core/methods/typification");
6
+ const faceMatch_1 = require("./core/methods/faceMatch");
7
+ const ocr_1 = require("./core/methods/ocr");
5
8
  class SantoiDSDK {
6
9
  }
7
10
  SantoiDSDK.livenessDetection = livenessDetection_1.livenessDetection;
8
11
  SantoiDSDK.uploadIdentificationDocument = uploadIdentificationDocument_1.uploadIdentificationDocument;
12
+ SantoiDSDK.typification = typification_1.typification;
13
+ SantoiDSDK.faceMatch = faceMatch_1.faceMatch;
14
+ SantoiDSDK.ocr = ocr_1.ocr;
9
15
  exports.default = SantoiDSDK;
@@ -40,7 +40,11 @@ function livenessDetection(options) {
40
40
  };
41
41
  }
42
42
  catch (err) {
43
- throw new error_1.SDKError({ message: 'Error while starting SDK', code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR });
43
+ throw new error_1.SDKError({
44
+ message: 'Error while starting SDK',
45
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
46
+ fatal: true,
47
+ });
44
48
  }
45
49
  }
46
50
  exports.livenessDetection = livenessDetection;
@@ -1,4 +1,4 @@
1
1
  import { UploadIdentificationDocumentService, type IServiceOptions, type IInternalServiceOptions } from '../../../../client/liveness/methods/uploadIdentificationDocument/Service';
2
- export declare class NodeUploadIdentificationDocumentService<TFrameType, TMediaType, TFileType> extends UploadIdentificationDocumentService<TFrameType, TMediaType, TFileType> {
3
- constructor(options: IServiceOptions<TFrameType, TMediaType, TFileType>, internalOptions: IInternalServiceOptions<TFrameType, TMediaType>);
2
+ export declare class NodeUploadIdentificationDocumentService<TFrameType, TMediaType> extends UploadIdentificationDocumentService<TFrameType, TMediaType> {
3
+ constructor(options: IServiceOptions<TFrameType, TMediaType>, internalOptions: IInternalServiceOptions<TFrameType, TMediaType>);
4
4
  }
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NodeUploadIdentificationDocumentService = void 0;
7
7
  const form_data_1 = __importDefault(require("form-data"));
8
8
  const Service_1 = require("../../../../client/liveness/methods/uploadIdentificationDocument/Service");
9
- const TypificationService_1 = require("../../../../api/TypificationService");
10
- const FaceMatchService_1 = require("../../../../api/FaceMatchService");
9
+ const ApiTypificationService_1 = require("../../../../api/ApiTypificationService");
10
+ const ApiFaceMatchService_1 = require("../../../../api/ApiFaceMatchService");
11
11
  const index_1 = require("../../utils/index");
12
12
  class NodeUploadIdentificationDocumentService extends Service_1.UploadIdentificationDocumentService {
13
13
  constructor(options, internalOptions) {
14
14
  super(options, internalOptions);
15
- this.typificationService = new TypificationService_1.TypificationService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
16
- this.faceMatchService = new FaceMatchService_1.FaceMatchService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
15
+ this.typificationService = new ApiTypificationService_1.ApiTypificationService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
16
+ this.faceMatchService = new ApiFaceMatchService_1.ApiFaceMatchService(options, { FormDataClass: form_data_1.default, tryDecodeJwt: index_1.tryDecodeJwt });
17
17
  }
18
18
  }
19
19
  exports.NodeUploadIdentificationDocumentService = NodeUploadIdentificationDocumentService;
@@ -1,10 +1,9 @@
1
- import { type Data } from 'ws';
1
+ /// <reference types="ws" />
2
2
  import { type IServiceOptions } from '../../../../client/liveness/methods/uploadIdentificationDocument/Service';
3
3
  import { type TFrameType, type TMediaType } from '../livenessDetection';
4
- type TFileType = Data;
5
- export declare function uploadIdentificationDocument(options: IServiceOptions<TFrameType, TMediaType, TFileType>): {
6
- startDocumentUpload: (file: Data) => Promise<void>;
7
- startLivenessDetection: (startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<Data, undefined>, "token" | "track"> & {
4
+ export declare function uploadIdentificationDocument(options: IServiceOptions<TFrameType, TMediaType>): {
5
+ startDocumentUpload: (file: import("ws").Data) => Promise<void>;
6
+ startLivenessDetection: (startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<import("ws").Data, undefined>, "token" | "track"> & {
8
7
  track?: string | undefined;
9
8
  token?: string | undefined;
10
9
  }) | undefined) => (Omit<{
@@ -16,10 +15,9 @@ export declare function uploadIdentificationDocument(options: IServiceOptions<TF
16
15
  getVideoStream?: (() => undefined) | undefined;
17
16
  }) | undefined;
18
17
  startFaceComparison: () => Promise<void>;
19
- startAll: (file: Data, startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<Data, undefined>, "token" | "track"> & {
18
+ startAll: (file: import("ws").Data, startLivenessDetectionOptions?: (Omit<import("../../../../utils/types").ISDKOptions<import("ws").Data, undefined>, "token" | "track"> & {
20
19
  track?: string | undefined;
21
20
  token?: string | undefined;
22
21
  }) | undefined) => void;
23
- getResults: () => import("../../../../client/liveness/methods/uploadIdentificationDocument/Service").IUploadIdentificationDocumentResults<Data>;
22
+ getResults: () => import("../../../../client/liveness/methods/uploadIdentificationDocument/Service").IUploadIdentificationDocumentResults<import("ws").Data>;
24
23
  };
25
- export {};
package/utils/error.d.ts CHANGED
@@ -11,14 +11,31 @@ export declare enum EUploadIdentificationDocumentErrorCodes {
11
11
  DOCUMENT_ANALYSIS_ERROR = "upload-identification-document/document-analysis-error",
12
12
  LIVENESS_DETECTION_ERROR = "upload-identification-document/liveness-detection-error"
13
13
  }
14
+ export declare enum EFaceMatchErrorCodes {
15
+ FIRST_IMAGE_NOT_SELECTED = "face-match/first-image-not-selected"
16
+ }
17
+ export declare enum ECameraErrorCodes {
18
+ INITIALIZATION_ERROR = "camera/initialization-error",
19
+ IS_RUNNING = "camera/is-running",
20
+ ALREADY_STARTED = "camera/already-started",
21
+ NOT_INITIALIZED = "camera/not-initialized",
22
+ CANNOT_CAPTURE_IMAGE = "camera/cannot-capture-image",
23
+ SHUTDOWN_ERROR = "camera/shutdown-error"
24
+ }
25
+ export declare enum EProcessingErrorCodes {
26
+ PROCESSING_ERROR = "processing/processing-error",
27
+ ALREADY_STARTED = "processing/already-started"
28
+ }
14
29
  interface ISDKErrorConstructorParams {
15
30
  message: string;
16
- code: EDefaultErrorCodes | ELivenessDetectionErrorCodes | EUploadIdentificationDocumentErrorCodes;
31
+ code: EDefaultErrorCodes | ELivenessDetectionErrorCodes | EUploadIdentificationDocumentErrorCodes | EFaceMatchErrorCodes | EProcessingErrorCodes | ECameraErrorCodes;
32
+ fatal: boolean;
17
33
  details?: any;
18
34
  }
19
35
  export declare class SDKError extends Error {
20
36
  code: string;
21
37
  details?: any;
22
- constructor({ message, code, details }: ISDKErrorConstructorParams);
38
+ fatal: boolean;
39
+ constructor({ message, code, fatal, details }: ISDKErrorConstructorParams);
23
40
  }
24
41
  export {};