santoid-sdk 5.1.0 → 5.3.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 (65) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +278 -52
  3. package/api/ApiAsyncService.d.ts +32 -0
  4. package/api/ApiAsyncService.js +15 -0
  5. package/api/ApiFaceMatchService.d.ts +31 -0
  6. package/api/ApiFaceMatchService.js +32 -0
  7. package/api/ApiOcrService.d.ts +61 -0
  8. package/api/ApiOcrService.js +25 -0
  9. package/api/ApiTypificationService.d.ts +23 -0
  10. package/api/{TypificationService.js → ApiTypificationService.js} +8 -9
  11. package/browser/index.js +1 -1
  12. package/client/core/commons/BaseCoreService.d.ts +22 -0
  13. package/client/core/commons/BaseCoreService.js +150 -0
  14. package/client/core/index.d.ts +4 -0
  15. package/client/core/index.js +9 -0
  16. package/client/core/methods/faceMatch/Service.d.ts +20 -0
  17. package/client/core/methods/faceMatch/Service.js +126 -0
  18. package/client/core/methods/faceMatch/index.d.ts +15 -0
  19. package/client/core/methods/faceMatch/index.js +43 -0
  20. package/client/core/methods/ocr/Service.d.ts +13 -0
  21. package/client/core/methods/ocr/Service.js +56 -0
  22. package/client/core/methods/ocr/index.d.ts +10 -0
  23. package/client/core/methods/ocr/index.js +40 -0
  24. package/client/core/methods/typification/Service.d.ts +10 -0
  25. package/client/core/methods/typification/Service.js +56 -0
  26. package/client/core/methods/typification/index.d.ts +10 -0
  27. package/client/core/methods/typification/index.js +41 -0
  28. package/client/core/utils/types.d.ts +26 -0
  29. package/client/core/utils/types.js +2 -0
  30. package/client/index.d.ts +6 -0
  31. package/client/index.js +6 -0
  32. package/client/liveness/methods/livenessDetection/Service.js +10 -2
  33. package/client/liveness/methods/livenessDetection/index.js +5 -1
  34. package/client/liveness/methods/uploadIdentificationDocument/Service.d.ts +20 -19
  35. package/client/liveness/methods/uploadIdentificationDocument/Service.js +38 -5
  36. package/client/liveness/methods/uploadIdentificationDocument/index.d.ts +4 -6
  37. package/client/liveness/utils/getNextFrame.js +7 -2
  38. package/package.json +1 -1
  39. package/server/core/index.d.ts +4 -0
  40. package/server/core/index.js +9 -0
  41. package/server/core/methods/faceMatch/Service.d.ts +9 -0
  42. package/server/core/methods/faceMatch/Service.js +23 -0
  43. package/server/core/methods/faceMatch/index.d.ts +7 -0
  44. package/server/core/methods/faceMatch/index.js +28 -0
  45. package/server/core/methods/ocr/Service.d.ts +9 -0
  46. package/server/core/methods/ocr/Service.js +23 -0
  47. package/server/core/methods/ocr/index.d.ts +7 -0
  48. package/server/core/methods/ocr/index.js +28 -0
  49. package/server/core/methods/typification/Service.d.ts +9 -0
  50. package/server/core/methods/typification/Service.js +23 -0
  51. package/server/core/methods/typification/index.d.ts +7 -0
  52. package/server/core/methods/typification/index.js +28 -0
  53. package/server/index.d.ts +6 -0
  54. package/server/index.js +6 -0
  55. package/server/liveness/methods/livenessDetection/index.js +5 -1
  56. package/server/liveness/methods/uploadIdentificationDocument/Service.d.ts +2 -2
  57. package/server/liveness/methods/uploadIdentificationDocument/Service.js +4 -4
  58. package/server/liveness/methods/uploadIdentificationDocument/index.d.ts +6 -8
  59. package/utils/error.d.ts +19 -2
  60. package/utils/error.js +21 -2
  61. package/utils/types.d.ts +1 -0
  62. package/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log +0 -286
  63. package/api/FaceMatchService.d.ts +0 -9
  64. package/api/FaceMatchService.js +0 -19
  65. package/api/TypificationService.d.ts +0 -90
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FaceMatchService = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const error_1 = require("../../../../utils/error");
6
+ const utils_1 = require("../../../liveness/utils");
7
+ const ApiFaceMatchService_1 = require("../../../../api/ApiFaceMatchService");
8
+ const BaseCoreService_1 = require("../../commons/BaseCoreService");
9
+ class FaceMatchService extends BaseCoreService_1.BaseCoreService {
10
+ constructor(options) {
11
+ super(options);
12
+ this.selectedFile1 = undefined;
13
+ this.selectedFile2 = undefined;
14
+ this.service = new ApiFaceMatchService_1.ApiFaceMatchService(options, { FormDataClass: FormData, tryDecodeJwt: utils_1.tryDecodeJwt });
15
+ }
16
+ async initialize(file1, file2) {
17
+ var _a;
18
+ if (file1) {
19
+ // Start processing immediately
20
+ this.startProcessing(file1, file2);
21
+ }
22
+ else {
23
+ // If necessary, open camera and take photo before start processing
24
+ const startTheCameraImmediately = (_a = this.options.startTheCameraImmediately) !== null && _a !== void 0 ? _a : this.options.startTheCameraImmediately === undefined;
25
+ if (startTheCameraImmediately) {
26
+ await this.startCamera();
27
+ }
28
+ }
29
+ }
30
+ getVideoStream() {
31
+ var _a;
32
+ return (_a = this.frameGetControls) === null || _a === void 0 ? void 0 : _a.videoStream;
33
+ }
34
+ async captureFirstImage({ startProcessing = true } = {}) {
35
+ // The superclass only works with one file
36
+ const bytes = await super.captureImage({ startProcessing: false });
37
+ this.selectedFile1 = bytes;
38
+ if (startProcessing) {
39
+ await this.stopCamera();
40
+ await this.startProcessing(this.selectedFile1);
41
+ }
42
+ return bytes;
43
+ }
44
+ async captureSecondImage({ startProcessing = true } = {}) {
45
+ if (!this.selectedFile1) {
46
+ throw new error_1.SDKError({
47
+ message: 'Select the first image before selecting the second',
48
+ code: error_1.EFaceMatchErrorCodes.FIRST_IMAGE_NOT_SELECTED,
49
+ fatal: false,
50
+ });
51
+ }
52
+ // The superclass only works with one file
53
+ const bytes = await super.captureImage({ startProcessing: false });
54
+ this.selectedFile2 = bytes;
55
+ if (startProcessing) {
56
+ await this.stopCamera();
57
+ await this.startProcessing(this.selectedFile1, this.selectedFile2);
58
+ }
59
+ return bytes;
60
+ }
61
+ async startProcessing(file1, file2) {
62
+ var _a, _b, _c, _d, _e, _f, _g;
63
+ try {
64
+ if (this.cameraIsActive) {
65
+ throw new error_1.SDKError({
66
+ message: 'Cannot start because the camera is running',
67
+ code: error_1.ECameraErrorCodes.IS_RUNNING,
68
+ fatal: false,
69
+ });
70
+ }
71
+ if ((_a = this.results) === null || _a === void 0 ? void 0 : _a.loading) {
72
+ throw new error_1.SDKError({
73
+ message: 'Processing has already started',
74
+ code: error_1.EProcessingErrorCodes.ALREADY_STARTED,
75
+ fatal: false,
76
+ });
77
+ }
78
+ this.updateResults({ status: null, results: null, loading: true, error: null });
79
+ const { requestId } = await this.service.faceMatch(file1, file2, `sdk-ocr-${(0, uuid_1.v4)()}`);
80
+ const results = await this.waitForResultsFaceMatch(requestId);
81
+ this.updateResults({ status: 'success', results, loading: false, error: null });
82
+ (_c = (_b = this.options).onSuccess) === null || _c === void 0 ? void 0 : _c.call(_b, results);
83
+ (_e = (_d = this.options).onEnd) === null || _e === void 0 ? void 0 : _e.call(_d);
84
+ }
85
+ catch (err) {
86
+ const validatedError = err instanceof error_1.SDKError
87
+ ? err
88
+ : new error_1.SDKError({
89
+ message: 'Error during document upload/analysis',
90
+ code: error_1.EProcessingErrorCodes.PROCESSING_ERROR,
91
+ fatal: false,
92
+ details: err,
93
+ });
94
+ await ((_g = (_f = this.options).onError) === null || _g === void 0 ? void 0 : _g.call(_f, validatedError));
95
+ this.updateResults({ status: 'error', results: null, loading: false, error: validatedError });
96
+ }
97
+ }
98
+ async waitForResultsFaceMatch(requestId) {
99
+ return await new Promise((resolve, reject) => {
100
+ const interval = setInterval(async () => {
101
+ var _a, _b, _c, _d;
102
+ try {
103
+ (_b = (_a = this.options).onClearInterval) === null || _b === void 0 ? void 0 : _b.call(_a, interval);
104
+ const data = await this.service.get(requestId);
105
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'error' || (data === null || data === void 0 ? void 0 : data.status) === 'error_connector') {
106
+ throw new Error('Não foi possível processar os resultados do FaceMatch');
107
+ }
108
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'processed' && data.fileURL) {
109
+ const response = await fetch(data.fileURL);
110
+ let faceMatchResults = await response.json();
111
+ faceMatchResults = Object.assign(Object.assign({}, faceMatchResults), { fileImage1: (_c = data.fileImage1) !== null && _c !== void 0 ? _c : '', fileImage2: (_d = data.fileImage2) !== null && _d !== void 0 ? _d : '' });
112
+ if (faceMatchResults) {
113
+ clearInterval(interval);
114
+ resolve(faceMatchResults);
115
+ }
116
+ }
117
+ }
118
+ catch (error) {
119
+ clearInterval(interval);
120
+ reject(new Error(error));
121
+ }
122
+ }, 5000);
123
+ });
124
+ }
125
+ }
126
+ exports.FaceMatchService = FaceMatchService;
@@ -0,0 +1,15 @@
1
+ import { type TFaceMatchServiceOptions } from './Service';
2
+ export type TFrameType = File | Blob;
3
+ export type TMediaType = MediaStream | undefined;
4
+ export declare function faceMatch(options: TFaceMatchServiceOptions<TMediaType>, file1?: TFrameType, file2?: TFrameType): Promise<{
5
+ startCamera: () => Promise<void>;
6
+ stopCamera: () => Promise<void>;
7
+ captureFirstImage: (rest_0?: {
8
+ startProcessing?: boolean | undefined;
9
+ } | undefined) => Promise<NonNullable<TFrameType>>;
10
+ captureSecondImage: (rest_0?: {
11
+ startProcessing?: boolean | undefined;
12
+ } | undefined) => Promise<NonNullable<TFrameType>>;
13
+ getVideoStream: () => TMediaType;
14
+ sendFiles: (file1: TFrameType, file2?: TFrameType | undefined) => Promise<void>;
15
+ }>;
@@ -0,0 +1,43 @@
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.FaceMatchService(options);
10
+ await service.initialize(file1, file2);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a, { videoStream: service.getVideoStream() }));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ startCamera: async () => {
15
+ await service.startCamera();
16
+ },
17
+ stopCamera: async () => {
18
+ await service.stopCamera();
19
+ },
20
+ captureFirstImage: async (...rest) => {
21
+ return await service.captureFirstImage(...rest);
22
+ },
23
+ captureSecondImage: async (...rest) => {
24
+ return await service.captureSecondImage(...rest);
25
+ },
26
+ getVideoStream: () => {
27
+ return service.getVideoStream();
28
+ },
29
+ sendFiles: async (...rest) => {
30
+ await service.startProcessing(...rest);
31
+ },
32
+ };
33
+ }
34
+ catch (err) {
35
+ throw new error_1.SDKError({
36
+ message: 'Error while starting SDK',
37
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
38
+ fatal: true,
39
+ details: err,
40
+ });
41
+ }
42
+ }
43
+ exports.faceMatch = faceMatch;
@@ -0,0 +1,13 @@
1
+ import { type ITypificationResult } from '../../../../api/ApiTypificationService';
2
+ import { ApiOcrService } from '../../../../api/ApiOcrService';
3
+ import { type TCoreServiceOptions } from '../../utils/types';
4
+ import { BaseCoreService } from '../../commons/BaseCoreService';
5
+ export type TOcrServiceOptions<TMediaType> = TCoreServiceOptions<TMediaType, ITypificationResult> & {
6
+ template: string;
7
+ };
8
+ export declare class OcrService<TFrameType, TMediaType> extends BaseCoreService<TFrameType, TMediaType, ITypificationResult> {
9
+ service: ApiOcrService<TFrameType>;
10
+ constructor(options: TOcrServiceOptions<TMediaType>);
11
+ getVideoStream(): TMediaType | undefined;
12
+ startProcessing(file: TFrameType): Promise<void>;
13
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OcrService = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const error_1 = require("../../../../utils/error");
6
+ const utils_1 = require("../../../liveness/utils");
7
+ const ApiOcrService_1 = require("../../../../api/ApiOcrService");
8
+ const BaseCoreService_1 = require("../../commons/BaseCoreService");
9
+ class OcrService extends BaseCoreService_1.BaseCoreService {
10
+ constructor(options) {
11
+ super(options);
12
+ this.service = new ApiOcrService_1.ApiOcrService(options, { FormDataClass: FormData, tryDecodeJwt: utils_1.tryDecodeJwt });
13
+ }
14
+ getVideoStream() {
15
+ var _a;
16
+ return (_a = this.frameGetControls) === null || _a === void 0 ? void 0 : _a.videoStream;
17
+ }
18
+ async startProcessing(file) {
19
+ var _a, _b, _c, _d, _e, _f, _g;
20
+ try {
21
+ if (this.cameraIsActive) {
22
+ throw new error_1.SDKError({
23
+ message: 'Cannot start because the camera is running',
24
+ code: error_1.ECameraErrorCodes.IS_RUNNING,
25
+ fatal: false,
26
+ });
27
+ }
28
+ if ((_a = this.results) === null || _a === void 0 ? void 0 : _a.loading) {
29
+ throw new error_1.SDKError({
30
+ message: 'Processing has already started',
31
+ code: error_1.EProcessingErrorCodes.ALREADY_STARTED,
32
+ fatal: false,
33
+ });
34
+ }
35
+ this.updateResults({ status: null, results: null, loading: true, error: null });
36
+ const { requestId } = await this.service.extract(file, `sdk-ocr-${(0, uuid_1.v4)()}`);
37
+ const results = await this.waitForResults(requestId);
38
+ this.updateResults({ status: 'success', results, loading: false, error: null });
39
+ (_c = (_b = this.options).onSuccess) === null || _c === void 0 ? void 0 : _c.call(_b, results);
40
+ (_e = (_d = this.options).onEnd) === null || _e === void 0 ? void 0 : _e.call(_d);
41
+ }
42
+ catch (err) {
43
+ const validatedError = err instanceof error_1.SDKError
44
+ ? err
45
+ : new error_1.SDKError({
46
+ message: 'Error during document upload/analysis',
47
+ code: error_1.EProcessingErrorCodes.PROCESSING_ERROR,
48
+ fatal: false,
49
+ details: err,
50
+ });
51
+ await ((_g = (_f = this.options).onError) === null || _g === void 0 ? void 0 : _g.call(_f, validatedError));
52
+ this.updateResults({ status: 'error', results: null, loading: false, error: validatedError });
53
+ }
54
+ }
55
+ }
56
+ exports.OcrService = OcrService;
@@ -0,0 +1,10 @@
1
+ import { type TOcrServiceOptions } from './Service';
2
+ export type TFrameType = File | Blob;
3
+ export type TMediaType = MediaStream | undefined;
4
+ export declare function ocr(options: TOcrServiceOptions<TMediaType>, file?: TFrameType): Promise<{
5
+ startCamera: () => Promise<void>;
6
+ stopCamera: () => Promise<void>;
7
+ captureImage: () => Promise<NonNullable<TFrameType>>;
8
+ getVideoStream: () => TMediaType;
9
+ sendFile: (file: TFrameType) => Promise<void>;
10
+ }>;
@@ -0,0 +1,40 @@
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.OcrService(options);
10
+ await service.initialize(file);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a, { videoStream: service.getVideoStream() }));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ startCamera: async () => {
15
+ await service.startCamera();
16
+ },
17
+ stopCamera: async () => {
18
+ await service.stopCamera();
19
+ },
20
+ captureImage: async () => {
21
+ return await service.captureImage();
22
+ },
23
+ getVideoStream: () => {
24
+ return service.getVideoStream();
25
+ },
26
+ sendFile: async (file) => {
27
+ await service.startProcessing(file);
28
+ },
29
+ };
30
+ }
31
+ catch (err) {
32
+ throw new error_1.SDKError({
33
+ message: 'Error while starting SDK',
34
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
35
+ fatal: true,
36
+ details: err,
37
+ });
38
+ }
39
+ }
40
+ exports.ocr = ocr;
@@ -0,0 +1,10 @@
1
+ import { ApiTypificationService, type ITypificationResult } from '../../../../api/ApiTypificationService';
2
+ import { type TCoreServiceOptions } from '../../utils/types';
3
+ import { BaseCoreService } from '../../commons/BaseCoreService';
4
+ export type TTypificationServiceOptions<TMediaType> = Omit<TCoreServiceOptions<TMediaType, ITypificationResult>, 'template'>;
5
+ export declare class TypificationService<TFrameType, TMediaType> extends BaseCoreService<TFrameType, TMediaType, ITypificationResult> {
6
+ service: ApiTypificationService<TFrameType>;
7
+ constructor(options: TTypificationServiceOptions<TMediaType>);
8
+ getVideoStream(): TMediaType;
9
+ startProcessing(file: TFrameType): Promise<void>;
10
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypificationService = void 0;
4
+ const uuid_1 = require("uuid");
5
+ const error_1 = require("../../../../utils/error");
6
+ const utils_1 = require("../../../liveness/utils");
7
+ const ApiTypificationService_1 = require("../../../../api/ApiTypificationService");
8
+ const BaseCoreService_1 = require("../../commons/BaseCoreService");
9
+ class TypificationService extends BaseCoreService_1.BaseCoreService {
10
+ constructor(options) {
11
+ super(options);
12
+ this.service = new ApiTypificationService_1.ApiTypificationService(options, { FormDataClass: FormData, tryDecodeJwt: utils_1.tryDecodeJwt });
13
+ }
14
+ getVideoStream() {
15
+ var _a;
16
+ return (_a = this.frameGetControls) === null || _a === void 0 ? void 0 : _a.videoStream;
17
+ }
18
+ async startProcessing(file) {
19
+ var _a, _b, _c, _d, _e, _f, _g;
20
+ try {
21
+ if (this.cameraIsActive) {
22
+ throw new error_1.SDKError({
23
+ message: 'Cannot start because the camera is running',
24
+ code: error_1.ECameraErrorCodes.IS_RUNNING,
25
+ fatal: false,
26
+ });
27
+ }
28
+ if ((_a = this.results) === null || _a === void 0 ? void 0 : _a.loading) {
29
+ throw new error_1.SDKError({
30
+ message: 'Processing has already started',
31
+ code: error_1.EProcessingErrorCodes.ALREADY_STARTED,
32
+ fatal: false,
33
+ });
34
+ }
35
+ this.updateResults({ status: null, results: null, loading: true, error: null });
36
+ const { requestId } = await this.service.predict(file, `sdk-typification-${(0, uuid_1.v4)()}`);
37
+ const results = await this.waitForResults(requestId);
38
+ this.updateResults({ status: 'success', results, loading: false, error: null });
39
+ (_c = (_b = this.options).onSuccess) === null || _c === void 0 ? void 0 : _c.call(_b, results);
40
+ (_e = (_d = this.options).onEnd) === null || _e === void 0 ? void 0 : _e.call(_d);
41
+ }
42
+ catch (err) {
43
+ const validatedError = err instanceof error_1.SDKError
44
+ ? err
45
+ : new error_1.SDKError({
46
+ message: 'Error during document upload/analysis',
47
+ code: error_1.EProcessingErrorCodes.PROCESSING_ERROR,
48
+ fatal: false,
49
+ details: err,
50
+ });
51
+ await ((_g = (_f = this.options).onError) === null || _g === void 0 ? void 0 : _g.call(_f, validatedError));
52
+ this.updateResults({ status: 'error', results: null, loading: false, error: validatedError });
53
+ }
54
+ }
55
+ }
56
+ exports.TypificationService = TypificationService;
@@ -0,0 +1,10 @@
1
+ import { type TTypificationServiceOptions } from './Service';
2
+ export type TFrameType = File | Blob;
3
+ export type TMediaType = MediaStream | undefined;
4
+ export declare function typification(options: TTypificationServiceOptions<TMediaType>, file?: TFrameType): Promise<{
5
+ startCamera: () => Promise<void>;
6
+ stopCamera: () => Promise<void>;
7
+ captureImage: () => Promise<NonNullable<TFrameType>>;
8
+ getVideoStream: () => TMediaType;
9
+ sendFile: (file: TFrameType) => Promise<void>;
10
+ }>;
@@ -0,0 +1,41 @@
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.TypificationService(options);
10
+ await service.initialize(file);
11
+ await ((_b = (_a = service.options).onStart) === null || _b === void 0 ? void 0 : _b.call(_a, { videoStream: service.getVideoStream() }));
12
+ // Methods are exported like this to prevent the value of "this" from changing
13
+ return {
14
+ startCamera: async () => {
15
+ await service.startCamera();
16
+ },
17
+ stopCamera: async () => {
18
+ await service.stopCamera();
19
+ },
20
+ captureImage: async () => {
21
+ return await service.captureImage();
22
+ },
23
+ getVideoStream: () => {
24
+ return service.getVideoStream();
25
+ },
26
+ sendFile: async (file) => {
27
+ await service.startProcessing(file);
28
+ },
29
+ };
30
+ }
31
+ catch (err) {
32
+ console.error(err);
33
+ throw new error_1.SDKError({
34
+ message: 'Error while starting SDK',
35
+ code: error_1.EDefaultErrorCodes.INITIALIZATION_ERROR,
36
+ fatal: true,
37
+ details: err,
38
+ });
39
+ }
40
+ }
41
+ exports.typification = typification;
@@ -0,0 +1,26 @@
1
+ import { type SDKError } from '../../../utils/error';
2
+ import { type IBaseSDKOptions, type TCallbackFunction } from '../../../utils/types';
3
+ export type TCoreServiceOptions<TMediaType, TResultsContentType> = IBaseSDKOptions & {
4
+ onStart?: (params: {
5
+ videoStream: TMediaType;
6
+ }) => void | Promise<void>;
7
+ onUpdate?: (results?: ICoreServiceResult<TResultsContentType>) => void | Promise<void>;
8
+ onValidationRequested?: (requestInformation: IRequestInformation) => void | Promise<void>;
9
+ onClearInterval?: (interval: ReturnType<typeof setInterval>) => void | Promise<void>;
10
+ onError?: (error?: SDKError) => void | Promise<void>;
11
+ onSuccess?: (results: unknown) => void | Promise<void>;
12
+ onEnd?: TCallbackFunction;
13
+ startTheCameraImmediately?: boolean;
14
+ };
15
+ interface IRequestInformation {
16
+ track: string;
17
+ requestId: string;
18
+ }
19
+ export type TResultStatuses = 'success' | 'error' | null;
20
+ export interface ICoreServiceResult<TResultsContentType> {
21
+ status: TResultStatuses;
22
+ results: TResultsContentType | null;
23
+ loading: boolean;
24
+ error: SDKError | null;
25
+ }
26
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/client/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import { livenessDetection } from './liveness/methods/livenessDetection';
2
2
  import { uploadIdentificationDocument } from './liveness/methods/uploadIdentificationDocument';
3
3
  import { insertUploadIdentificationDocument } from './embedded/methods/insertUploadIdentificationDocument';
4
+ import { typification } from './core/methods/typification';
5
+ import { faceMatch } from './core/methods/faceMatch';
6
+ import { ocr } from './core/methods/ocr';
4
7
  export default class SantoiDSDK {
5
8
  static readonly livenessDetection: typeof livenessDetection;
6
9
  static readonly uploadIdentificationDocument: typeof uploadIdentificationDocument;
7
10
  static readonly insertUploadIdentificationDocument: typeof insertUploadIdentificationDocument;
11
+ static readonly typification: typeof typification;
12
+ static readonly ocr: typeof ocr;
13
+ static readonly faceMatch: typeof faceMatch;
8
14
  }
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,28 +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
- startDocumentUpload(file: TFileType): Promise<void>;
17
+ waitForResultsFaceMatch(requestId: string): Promise<IFaceMatchResult>;
18
+ startDocumentUpload(file: TFrameType): Promise<void>;
18
19
  startLivenessDetection(startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): TLivenessDetectionReturn<TMediaType> | undefined;
19
- startFaceMatch(firstImage: TFileType, secondImage: TFileType): Promise<void>;
20
+ startFaceMatch(firstImage: TFrameType, secondImage: TFrameType): Promise<void>;
20
21
  tryStartFaceMatch(): Promise<void>;
21
- startAll(file: TFileType, startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): void;
22
+ startAll(file: TFrameType, startLivenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>): void;
22
23
  }
23
24
  type TResultStatuses = 'success' | 'error' | null;
24
- export interface IUploadIdentificationDocumentResults<TFileType> {
25
- uploadedDocument: TFileType | null;
25
+ export interface IUploadIdentificationDocumentResults<TFrameType> {
26
+ uploadedDocument: TFrameType | null;
26
27
  typification: {
27
28
  status: TResultStatuses;
28
29
  results: ITypificationResult | null;
@@ -31,7 +32,7 @@ export interface IUploadIdentificationDocumentResults<TFileType> {
31
32
  };
32
33
  liveness: {
33
34
  status: TResultStatuses;
34
- results: ILivenessResults<TFileType | null | undefined> | null;
35
+ results: ILivenessResults<TFrameType | null | undefined> | null;
35
36
  loading: boolean;
36
37
  error: SDKError | null;
37
38
  };
@@ -46,9 +47,9 @@ type ICustomLivenessOptions<TFrameType, TMediaType> = Omit<ISDKOptions<TFrameTyp
46
47
  track?: string;
47
48
  token?: string;
48
49
  };
49
- export interface IServiceOptions<TFrameType, TMediaType, TFileType> extends IBaseSDKOptions {
50
+ export interface IServiceOptions<TFrameType, TMediaType> extends IBaseSDKOptions {
50
51
  livenessDetectionOptions?: ICustomLivenessOptions<TFrameType, TMediaType>;
51
- onUpdate?: (results?: IUploadIdentificationDocumentResults<TFileType>) => void | Promise<void>;
52
+ onUpdate?: (results?: IUploadIdentificationDocumentResults<TFrameType>) => void | Promise<void>;
52
53
  onSuccess?: <TFrameType, ResultsType = ILivenessResults<TFrameType>>(results?: ResultsType) => void | Promise<void>;
53
54
  onError?: (error?: SDKError) => void | Promise<void>;
54
55
  onEnd?: TCallbackFunction;