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.
- package/CHANGELOG.md +10 -1
- package/README.md +278 -52
- package/api/ApiAsyncService.d.ts +32 -0
- package/api/ApiAsyncService.js +15 -0
- package/api/ApiFaceMatchService.d.ts +31 -0
- package/api/ApiFaceMatchService.js +32 -0
- package/api/ApiOcrService.d.ts +61 -0
- package/api/ApiOcrService.js +25 -0
- package/api/ApiTypificationService.d.ts +23 -0
- package/api/{TypificationService.js → ApiTypificationService.js} +8 -9
- package/browser/index.js +1 -1
- package/client/core/commons/BaseCoreService.d.ts +22 -0
- package/client/core/commons/BaseCoreService.js +150 -0
- package/client/core/index.d.ts +4 -0
- package/client/core/index.js +9 -0
- package/client/core/methods/faceMatch/Service.d.ts +20 -0
- package/client/core/methods/faceMatch/Service.js +126 -0
- package/client/core/methods/faceMatch/index.d.ts +15 -0
- package/client/core/methods/faceMatch/index.js +43 -0
- package/client/core/methods/ocr/Service.d.ts +13 -0
- package/client/core/methods/ocr/Service.js +56 -0
- package/client/core/methods/ocr/index.d.ts +10 -0
- package/client/core/methods/ocr/index.js +40 -0
- package/client/core/methods/typification/Service.d.ts +10 -0
- package/client/core/methods/typification/Service.js +56 -0
- package/client/core/methods/typification/index.d.ts +10 -0
- package/client/core/methods/typification/index.js +41 -0
- package/client/core/utils/types.d.ts +26 -0
- package/client/core/utils/types.js +2 -0
- package/client/index.d.ts +6 -0
- package/client/index.js +6 -0
- package/client/liveness/methods/livenessDetection/Service.js +10 -2
- package/client/liveness/methods/livenessDetection/index.js +5 -1
- package/client/liveness/methods/uploadIdentificationDocument/Service.d.ts +20 -19
- package/client/liveness/methods/uploadIdentificationDocument/Service.js +38 -5
- package/client/liveness/methods/uploadIdentificationDocument/index.d.ts +4 -6
- package/client/liveness/utils/getNextFrame.js +7 -2
- package/package.json +1 -1
- package/server/core/index.d.ts +4 -0
- package/server/core/index.js +9 -0
- package/server/core/methods/faceMatch/Service.d.ts +9 -0
- package/server/core/methods/faceMatch/Service.js +23 -0
- package/server/core/methods/faceMatch/index.d.ts +7 -0
- package/server/core/methods/faceMatch/index.js +28 -0
- package/server/core/methods/ocr/Service.d.ts +9 -0
- package/server/core/methods/ocr/Service.js +23 -0
- package/server/core/methods/ocr/index.d.ts +7 -0
- package/server/core/methods/ocr/index.js +28 -0
- package/server/core/methods/typification/Service.d.ts +9 -0
- package/server/core/methods/typification/Service.js +23 -0
- package/server/core/methods/typification/index.d.ts +7 -0
- package/server/core/methods/typification/index.js +28 -0
- package/server/index.d.ts +6 -0
- package/server/index.js +6 -0
- package/server/liveness/methods/livenessDetection/index.js +5 -1
- package/server/liveness/methods/uploadIdentificationDocument/Service.d.ts +2 -2
- package/server/liveness/methods/uploadIdentificationDocument/Service.js +4 -4
- package/server/liveness/methods/uploadIdentificationDocument/index.d.ts +6 -8
- package/utils/error.d.ts +19 -2
- package/utils/error.js +21 -2
- package/utils/types.d.ts +1 -0
- package/.bitbucket/pipelines/generated/pipeline/pipes/sonarsource/sonarcloud-scan/sonarcloud-scan.log +0 -286
- package/api/FaceMatchService.d.ts +0 -9
- package/api/FaceMatchService.js +0 -19
- package/api/TypificationService.d.ts +0 -90
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UploadIdentificationDocumentService = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
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
|
|
20
|
-
this.faceMatchService = new
|
|
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;
|
|
@@ -73,6 +73,34 @@ class UploadIdentificationDocumentService {
|
|
|
73
73
|
}, 5000);
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
async waitForResultsFaceMatch(requestId) {
|
|
77
|
+
return await new Promise((resolve, reject) => {
|
|
78
|
+
const interval = setInterval(async () => {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
80
|
+
try {
|
|
81
|
+
(_b = (_a = this.options).onClearInterval) === null || _b === void 0 ? void 0 : _b.call(_a, interval);
|
|
82
|
+
const data = await this.faceMatchService.get(requestId);
|
|
83
|
+
if ((data === null || data === void 0 ? void 0 : data.status) === 'error' || (data === null || data === void 0 ? void 0 : data.status) === 'error_connector') {
|
|
84
|
+
clearInterval(interval);
|
|
85
|
+
reject(new Error('Não foi possível processar os resultados do FaceMatch'));
|
|
86
|
+
}
|
|
87
|
+
else if ((data === null || data === void 0 ? void 0 : data.status) === 'processed' && data.fileURL) {
|
|
88
|
+
const response = await fetch(data.fileURL);
|
|
89
|
+
let faceMatchResults = await response.json();
|
|
90
|
+
faceMatchResults = Object.assign(Object.assign({}, faceMatchResults), { fileImage1: (_c = data.fileImage1) !== null && _c !== void 0 ? _c : '', fileImage2: (_d = data.fileImage2) !== null && _d !== void 0 ? _d : '' });
|
|
91
|
+
if (faceMatchResults) {
|
|
92
|
+
clearInterval(interval);
|
|
93
|
+
resolve(faceMatchResults);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
clearInterval(interval);
|
|
99
|
+
reject(new Error(error));
|
|
100
|
+
}
|
|
101
|
+
}, 5000);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
76
104
|
async startDocumentUpload(file) {
|
|
77
105
|
var _a, _b;
|
|
78
106
|
try {
|
|
@@ -86,6 +114,7 @@ class UploadIdentificationDocumentService {
|
|
|
86
114
|
const adaptedError = new error_1.SDKError({
|
|
87
115
|
message: 'Error during document upload/analysis',
|
|
88
116
|
code: error_1.EUploadIdentificationDocumentErrorCodes.DOCUMENT_ANALYSIS_ERROR,
|
|
117
|
+
fatal: false,
|
|
89
118
|
details: err,
|
|
90
119
|
});
|
|
91
120
|
await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError));
|
|
@@ -126,6 +155,7 @@ class UploadIdentificationDocumentService {
|
|
|
126
155
|
const adaptedError = new error_1.SDKError({
|
|
127
156
|
message: 'Error during liveness detection',
|
|
128
157
|
code: error_1.EUploadIdentificationDocumentErrorCodes.LIVENESS_DETECTION_ERROR,
|
|
158
|
+
fatal: false,
|
|
129
159
|
details: err,
|
|
130
160
|
});
|
|
131
161
|
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError);
|
|
@@ -136,13 +166,15 @@ class UploadIdentificationDocumentService {
|
|
|
136
166
|
var _a, _b;
|
|
137
167
|
try {
|
|
138
168
|
this.updateResults({ faceMatch: { status: null, results: null, loading: true, error: null } });
|
|
139
|
-
const
|
|
169
|
+
const { requestId } = await this.faceMatchService.faceMatch(firstImage, secondImage, `sdk-facematch-${(0, uuid_1.v4)()}`);
|
|
170
|
+
const faceMatchResults = await this.waitForResultsFaceMatch(requestId);
|
|
140
171
|
this.updateResults({ faceMatch: { results: faceMatchResults, status: 'success', loading: false, error: null } });
|
|
141
172
|
}
|
|
142
173
|
catch (err) {
|
|
143
174
|
const adaptedError = new error_1.SDKError({
|
|
144
175
|
message: 'Error when comparing the face with the document',
|
|
145
176
|
code: error_1.EUploadIdentificationDocumentErrorCodes.FACE_MATCH_ERROR,
|
|
177
|
+
fatal: false,
|
|
146
178
|
details: err,
|
|
147
179
|
});
|
|
148
180
|
await ((_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedError));
|
|
@@ -162,6 +194,7 @@ class UploadIdentificationDocumentService {
|
|
|
162
194
|
await ((_c = (_b = this.options).onError) === null || _c === void 0 ? void 0 : _c.call(_b, new error_1.SDKError({
|
|
163
195
|
message: 'Unavailable faces',
|
|
164
196
|
code: error_1.EUploadIdentificationDocumentErrorCodes.FACE_MATCH_UNAVAILABLE_FACES_ERROR,
|
|
197
|
+
fatal: false,
|
|
165
198
|
})));
|
|
166
199
|
}
|
|
167
200
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type IServiceOptions } from './Service';
|
|
2
2
|
import { type TFrameType, type TMediaType } from '../livenessDetection';
|
|
3
|
-
|
|
4
|
-
|
|
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:
|
|
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<
|
|
21
|
+
getResults: () => import("./Service").IUploadIdentificationDocumentResults<TFrameType>;
|
|
23
22
|
};
|
|
24
|
-
export {};
|
|
@@ -43,12 +43,17 @@ async function getDefaultFrameControls() {
|
|
|
43
43
|
}
|
|
44
44
|
async function startGettingFrames() {
|
|
45
45
|
if (!videoStream || !videoElement || !canvasElement) {
|
|
46
|
-
videoStream = await navigator.mediaDevices.getUserMedia({
|
|
46
|
+
videoStream = await navigator.mediaDevices.getUserMedia({
|
|
47
|
+
audio: false,
|
|
48
|
+
video: {
|
|
49
|
+
facingMode: 'environment',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
47
52
|
videoElement = document.createElement('video');
|
|
48
53
|
videoElement.setAttribute('autoplay', 'true');
|
|
49
54
|
videoElement.style.transform = 'scale(-1, 1)';
|
|
50
55
|
videoElement.style.position = 'absolute';
|
|
51
|
-
videoElement.style.left = '99999px';
|
|
56
|
+
videoElement.style.left = '-99999px';
|
|
52
57
|
document.body.appendChild(videoElement);
|
|
53
58
|
videoElement.srcObject = videoStream;
|
|
54
59
|
canvasElement = document.createElement('canvas');
|
package/package.json
CHANGED
|
@@ -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'> & {
|
|
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'> & {
|
|
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'> & {
|
|
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({
|
|
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
|
|
3
|
-
constructor(options: IServiceOptions<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
|
|
10
|
-
const
|
|
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
|
|
16
|
-
this.faceMatchService = new
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
38
|
+
fatal: boolean;
|
|
39
|
+
constructor({ message, code, fatal, details }: ISDKErrorConstructorParams);
|
|
23
40
|
}
|
|
24
41
|
export {};
|
package/utils/error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SDKError = exports.EUploadIdentificationDocumentErrorCodes = exports.ELivenessDetectionErrorCodes = exports.EDefaultErrorCodes = void 0;
|
|
3
|
+
exports.SDKError = exports.EProcessingErrorCodes = exports.ECameraErrorCodes = exports.EFaceMatchErrorCodes = exports.EUploadIdentificationDocumentErrorCodes = exports.ELivenessDetectionErrorCodes = exports.EDefaultErrorCodes = void 0;
|
|
4
4
|
var EDefaultErrorCodes;
|
|
5
5
|
(function (EDefaultErrorCodes) {
|
|
6
6
|
EDefaultErrorCodes["INITIALIZATION_ERROR"] = "initialization-error";
|
|
@@ -17,10 +17,29 @@ var EUploadIdentificationDocumentErrorCodes;
|
|
|
17
17
|
EUploadIdentificationDocumentErrorCodes["DOCUMENT_ANALYSIS_ERROR"] = "upload-identification-document/document-analysis-error";
|
|
18
18
|
EUploadIdentificationDocumentErrorCodes["LIVENESS_DETECTION_ERROR"] = "upload-identification-document/liveness-detection-error";
|
|
19
19
|
})(EUploadIdentificationDocumentErrorCodes || (exports.EUploadIdentificationDocumentErrorCodes = EUploadIdentificationDocumentErrorCodes = {}));
|
|
20
|
+
var EFaceMatchErrorCodes;
|
|
21
|
+
(function (EFaceMatchErrorCodes) {
|
|
22
|
+
EFaceMatchErrorCodes["FIRST_IMAGE_NOT_SELECTED"] = "face-match/first-image-not-selected";
|
|
23
|
+
})(EFaceMatchErrorCodes || (exports.EFaceMatchErrorCodes = EFaceMatchErrorCodes = {}));
|
|
24
|
+
var ECameraErrorCodes;
|
|
25
|
+
(function (ECameraErrorCodes) {
|
|
26
|
+
ECameraErrorCodes["INITIALIZATION_ERROR"] = "camera/initialization-error";
|
|
27
|
+
ECameraErrorCodes["IS_RUNNING"] = "camera/is-running";
|
|
28
|
+
ECameraErrorCodes["ALREADY_STARTED"] = "camera/already-started";
|
|
29
|
+
ECameraErrorCodes["NOT_INITIALIZED"] = "camera/not-initialized";
|
|
30
|
+
ECameraErrorCodes["CANNOT_CAPTURE_IMAGE"] = "camera/cannot-capture-image";
|
|
31
|
+
ECameraErrorCodes["SHUTDOWN_ERROR"] = "camera/shutdown-error";
|
|
32
|
+
})(ECameraErrorCodes || (exports.ECameraErrorCodes = ECameraErrorCodes = {}));
|
|
33
|
+
var EProcessingErrorCodes;
|
|
34
|
+
(function (EProcessingErrorCodes) {
|
|
35
|
+
EProcessingErrorCodes["PROCESSING_ERROR"] = "processing/processing-error";
|
|
36
|
+
EProcessingErrorCodes["ALREADY_STARTED"] = "processing/already-started";
|
|
37
|
+
})(EProcessingErrorCodes || (exports.EProcessingErrorCodes = EProcessingErrorCodes = {}));
|
|
20
38
|
class SDKError extends Error {
|
|
21
|
-
constructor({ message, code, details }) {
|
|
39
|
+
constructor({ message, code, fatal, details }) {
|
|
22
40
|
super(message);
|
|
23
41
|
this.code = code;
|
|
42
|
+
this.fatal = fatal;
|
|
24
43
|
this.details = details;
|
|
25
44
|
}
|
|
26
45
|
}
|
package/utils/types.d.ts
CHANGED