apacuana-sdk-core 1.22.0 → 1.25.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/README.md +39 -27
- package/coverage/clover.xml +195 -214
- package/coverage/coverage-final.json +5 -5
- package/coverage/lcov-report/index.html +33 -33
- package/coverage/lcov-report/src/api/certs.js.html +1 -1
- package/coverage/lcov-report/src/api/faceLiveness.js.html +35 -269
- package/coverage/lcov-report/src/api/index.html +18 -18
- package/coverage/lcov-report/src/api/revocations.js.html +1 -1
- package/coverage/lcov-report/src/api/signatures.js.html +1 -1
- package/coverage/lcov-report/src/api/users.js.html +1 -1
- package/coverage/lcov-report/src/config/index.html +1 -1
- package/coverage/lcov-report/src/config/index.js.html +1 -1
- package/coverage/lcov-report/src/errors/index.html +1 -1
- package/coverage/lcov-report/src/errors/index.js.html +8 -8
- package/coverage/lcov-report/src/index.html +15 -15
- package/coverage/lcov-report/src/index.js.html +12 -42
- package/coverage/lcov-report/src/success/index.html +1 -1
- package/coverage/lcov-report/src/success/index.js.html +5 -5
- package/coverage/lcov-report/src/utils/constant.js.html +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +59 -8
- package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +12 -12
- package/coverage/lcov.info +398 -434
- package/dist/api/faceLiveness.d.ts +3 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.js +61 -165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -165
- package/dist/index.mjs.map +1 -1
- package/dist/types/faceLiveness.d.ts +0 -10
- package/dist/utils/helpers.d.ts +2 -0
- package/package.json +3 -2
- package/src/api/faceLiveness.js +20 -98
- package/src/index.js +4 -14
- package/src/types/faceLiveness.js +1 -12
- package/src/utils/helpers.js +17 -0
- package/tests/api/faceLiveness.test.js +54 -115
package/dist/index.mjs
CHANGED
|
@@ -33039,6 +33039,22 @@ var validateOnBoardingSignDocumentData = function validateOnBoardingSignDocument
|
|
|
33039
33039
|
}
|
|
33040
33040
|
return formData;
|
|
33041
33041
|
};
|
|
33042
|
+
var base64ToFile = function base64ToFile(dataurl, filename) {
|
|
33043
|
+
var arr = dataurl.split(",");
|
|
33044
|
+
var mime = arr[0].match(/:(.*?);/)[1];
|
|
33045
|
+
var bstr = atob(arr[1]);
|
|
33046
|
+
var n = bstr.length;
|
|
33047
|
+
var u8arr = new Uint8Array(n);
|
|
33048
|
+
while (n--) {
|
|
33049
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
33050
|
+
}
|
|
33051
|
+
var blob = new Blob([u8arr], {
|
|
33052
|
+
type: mime
|
|
33053
|
+
});
|
|
33054
|
+
return new File([blob], filename, {
|
|
33055
|
+
type: mime
|
|
33056
|
+
});
|
|
33057
|
+
};
|
|
33042
33058
|
var helpers = {
|
|
33043
33059
|
getCertificateStatus: getCertificateStatus,
|
|
33044
33060
|
exportPrivateKey: exportPrivateKey,
|
|
@@ -33049,7 +33065,8 @@ var helpers = {
|
|
|
33049
33065
|
validateGetDocsData: validateGetDocsData,
|
|
33050
33066
|
validateGetDigestData: validateGetDigestData,
|
|
33051
33067
|
validateOnBoardingSignDocumentData: validateOnBoardingSignDocumentData,
|
|
33052
|
-
createPayloadGetDigest: createPayloadGetDigest
|
|
33068
|
+
createPayloadGetDigest: createPayloadGetDigest,
|
|
33069
|
+
base64ToFile: base64ToFile
|
|
33053
33070
|
};
|
|
33054
33071
|
|
|
33055
33072
|
/**
|
|
@@ -34210,213 +34227,101 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
|
|
|
34210
34227
|
};
|
|
34211
34228
|
}();
|
|
34212
34229
|
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
* @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
|
|
34217
|
-
* @throws {Error} If the request fails for another reason.
|
|
34218
|
-
*/
|
|
34219
|
-
var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
|
|
34220
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
34221
|
-
var response, _t;
|
|
34230
|
+
var sendFaceLivenessOnBoarding = /*#__PURE__*/function () {
|
|
34231
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(faceliveness, documentprefid) {
|
|
34232
|
+
var file, response, _t;
|
|
34222
34233
|
return _regenerator().w(function (_context) {
|
|
34223
34234
|
while (1) switch (_context.p = _context.n) {
|
|
34224
34235
|
case 0:
|
|
34225
34236
|
_context.p = 0;
|
|
34237
|
+
file = helpers.base64ToFile(faceliveness, "liveness_capture_".concat(Date.now(), ".png"));
|
|
34226
34238
|
_context.n = 1;
|
|
34227
|
-
return httpRequest("services/api/faceliveness/
|
|
34239
|
+
return httpRequest("services/api/faceliveness/uploadfaceliveness", {
|
|
34240
|
+
faceliveness: file,
|
|
34241
|
+
documentprefid: documentprefid
|
|
34242
|
+
}, "POST");
|
|
34228
34243
|
case 1:
|
|
34229
34244
|
response = _context.v;
|
|
34230
|
-
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
}
|
|
34234
|
-
throw new ApacuanaAPIError("The API response does not contain the session ID.", response.status, "INVALID_API_RESPONSE");
|
|
34245
|
+
return _context.a(2, new ApacuanaSuccess(_objectSpread2({
|
|
34246
|
+
status: "verified"
|
|
34247
|
+
}, response)));
|
|
34235
34248
|
case 2:
|
|
34236
|
-
|
|
34237
|
-
sessionId: response.sessionid
|
|
34238
|
-
}));
|
|
34239
|
-
case 3:
|
|
34240
|
-
_context.p = 3;
|
|
34249
|
+
_context.p = 2;
|
|
34241
34250
|
_t = _context.v;
|
|
34242
34251
|
if (!(_t instanceof ApacuanaAPIError)) {
|
|
34243
|
-
_context.n =
|
|
34252
|
+
_context.n = 3;
|
|
34244
34253
|
break;
|
|
34245
34254
|
}
|
|
34246
34255
|
throw _t;
|
|
34256
|
+
case 3:
|
|
34257
|
+
throw new Error("Failed to send faceliveness: ".concat(_t.message));
|
|
34247
34258
|
case 4:
|
|
34248
|
-
throw new ApacuanaAPIError("Failed to create Face Liveness session: ".concat(_t.message));
|
|
34249
|
-
case 5:
|
|
34250
34259
|
return _context.a(2);
|
|
34251
34260
|
}
|
|
34252
|
-
}, _callee, null, [[0,
|
|
34261
|
+
}, _callee, null, [[0, 2]]);
|
|
34253
34262
|
}));
|
|
34254
|
-
return function
|
|
34263
|
+
return function sendFaceLivenessOnBoarding(_x, _x2) {
|
|
34255
34264
|
return _ref.apply(this, arguments);
|
|
34256
34265
|
};
|
|
34257
34266
|
}();
|
|
34258
|
-
var
|
|
34267
|
+
var sendFaceLivenessOnPremise = /*#__PURE__*/function () {
|
|
34259
34268
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
34260
34269
|
return _regenerator().w(function (_context2) {
|
|
34261
34270
|
while (1) switch (_context2.n) {
|
|
34262
34271
|
case 0:
|
|
34263
|
-
throw new ApacuanaAPIError("
|
|
34272
|
+
throw new ApacuanaAPIError("Send a Face Liveness is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
34264
34273
|
case 1:
|
|
34265
34274
|
return _context2.a(2);
|
|
34266
34275
|
}
|
|
34267
34276
|
}, _callee2);
|
|
34268
34277
|
}));
|
|
34269
|
-
return function
|
|
34278
|
+
return function sendFaceLivenessOnPremise() {
|
|
34270
34279
|
return _ref2.apply(this, arguments);
|
|
34271
34280
|
};
|
|
34272
34281
|
}();
|
|
34273
|
-
var validateFaceLivenessOnBoarding = /*#__PURE__*/function () {
|
|
34274
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(sessionId) {
|
|
34275
|
-
var response, status, _t2, _t3;
|
|
34276
|
-
return _regenerator().w(function (_context3) {
|
|
34277
|
-
while (1) switch (_context3.p = _context3.n) {
|
|
34278
|
-
case 0:
|
|
34279
|
-
_context3.p = 0;
|
|
34280
|
-
_context3.n = 1;
|
|
34281
|
-
return httpRequest("services/api/faceliveness/validate", {
|
|
34282
|
-
sessionid: sessionId
|
|
34283
|
-
}, "POST");
|
|
34284
|
-
case 1:
|
|
34285
|
-
response = _context3.v;
|
|
34286
|
-
return _context3.a(2, new ApacuanaSuccess(_objectSpread2({
|
|
34287
|
-
status: "verified"
|
|
34288
|
-
}, response)));
|
|
34289
|
-
case 2:
|
|
34290
|
-
_context3.p = 2;
|
|
34291
|
-
_t2 = _context3.v;
|
|
34292
|
-
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
34293
|
-
_context3.n = 9;
|
|
34294
|
-
break;
|
|
34295
|
-
}
|
|
34296
|
-
_t3 = _t2.statusCode;
|
|
34297
|
-
_context3.n = _t3 === 402 ? 3 : _t3 === 403 ? 4 : _t3 === 406 ? 5 : _t3 === 408 ? 6 : 7;
|
|
34298
|
-
break;
|
|
34299
|
-
case 3:
|
|
34300
|
-
status = "waitingForScan";
|
|
34301
|
-
return _context3.a(3, 8);
|
|
34302
|
-
case 4:
|
|
34303
|
-
status = "rejected";
|
|
34304
|
-
return _context3.a(3, 8);
|
|
34305
|
-
case 5:
|
|
34306
|
-
status = "processing";
|
|
34307
|
-
return _context3.a(3, 8);
|
|
34308
|
-
case 6:
|
|
34309
|
-
status = "expired";
|
|
34310
|
-
return _context3.a(3, 8);
|
|
34311
|
-
case 7:
|
|
34312
|
-
throw _t2;
|
|
34313
|
-
case 8:
|
|
34314
|
-
return _context3.a(2, new ApacuanaSuccess({
|
|
34315
|
-
status: status
|
|
34316
|
-
}));
|
|
34317
|
-
case 9:
|
|
34318
|
-
throw _t2;
|
|
34319
|
-
case 10:
|
|
34320
|
-
return _context3.a(2);
|
|
34321
|
-
}
|
|
34322
|
-
}, _callee3, null, [[0, 2]]);
|
|
34323
|
-
}));
|
|
34324
|
-
return function validateFaceLivenessOnBoarding(_x) {
|
|
34325
|
-
return _ref3.apply(this, arguments);
|
|
34326
|
-
};
|
|
34327
|
-
}();
|
|
34328
|
-
var validateFaceLivenessOnPremise = /*#__PURE__*/function () {
|
|
34329
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
34330
|
-
return _regenerator().w(function (_context4) {
|
|
34331
|
-
while (1) switch (_context4.n) {
|
|
34332
|
-
case 0:
|
|
34333
|
-
throw new ApacuanaAPIError("Validating a Face Liveness session is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
34334
|
-
case 1:
|
|
34335
|
-
return _context4.a(2);
|
|
34336
|
-
}
|
|
34337
|
-
}, _callee4);
|
|
34338
|
-
}));
|
|
34339
|
-
return function validateFaceLivenessOnPremise() {
|
|
34340
|
-
return _ref4.apply(this, arguments);
|
|
34341
|
-
};
|
|
34342
|
-
}();
|
|
34343
|
-
|
|
34344
|
-
/**
|
|
34345
|
-
* Creates a new Face Liveness session.
|
|
34346
|
-
* @returns {Promise<CreateFaceLivenessSessionResponse>} Object with the session ID and a success indicator.
|
|
34347
|
-
* @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
|
|
34348
|
-
* @throws {Error} If the request fails for another reason.
|
|
34349
|
-
*/
|
|
34350
|
-
var createFaceLivenessSession = /*#__PURE__*/function () {
|
|
34351
|
-
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
34352
|
-
var _getConfig, integrationType;
|
|
34353
|
-
return _regenerator().w(function (_context5) {
|
|
34354
|
-
while (1) switch (_context5.n) {
|
|
34355
|
-
case 0:
|
|
34356
|
-
_getConfig = getConfig(), integrationType = _getConfig.integrationType;
|
|
34357
|
-
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
34358
|
-
_context5.n = 1;
|
|
34359
|
-
break;
|
|
34360
|
-
}
|
|
34361
|
-
return _context5.a(2, createFaceLivenessSessionOnBoarding());
|
|
34362
|
-
case 1:
|
|
34363
|
-
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
34364
|
-
_context5.n = 2;
|
|
34365
|
-
break;
|
|
34366
|
-
}
|
|
34367
|
-
return _context5.a(2, createFaceLivenessSessionOnPremise());
|
|
34368
|
-
case 2:
|
|
34369
|
-
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
34370
|
-
case 3:
|
|
34371
|
-
return _context5.a(2);
|
|
34372
|
-
}
|
|
34373
|
-
}, _callee5);
|
|
34374
|
-
}));
|
|
34375
|
-
return function createFaceLivenessSession() {
|
|
34376
|
-
return _ref5.apply(this, arguments);
|
|
34377
|
-
};
|
|
34378
|
-
}();
|
|
34379
34282
|
|
|
34380
34283
|
/**
|
|
34381
34284
|
* Validates a Face Liveness session and returns its status.
|
|
34382
|
-
* @param {
|
|
34285
|
+
* @param {object} params - Parámetros para la solicitud.
|
|
34286
|
+
* @param {string} params.faceLiveness - El faceLiveness.
|
|
34287
|
+
* @param {string} params.documentprefid - El documentprefid.
|
|
34383
34288
|
* @returns {Promise<ApacuanaSuccess>} Object with the validation status.
|
|
34384
34289
|
* @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
|
|
34385
34290
|
*/
|
|
34386
|
-
var
|
|
34387
|
-
var
|
|
34388
|
-
var
|
|
34389
|
-
return _regenerator().w(function (
|
|
34390
|
-
while (1) switch (
|
|
34291
|
+
var sendFaceLiveness = /*#__PURE__*/function () {
|
|
34292
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref3) {
|
|
34293
|
+
var faceLiveness, documentprefid, _getConfig, integrationType;
|
|
34294
|
+
return _regenerator().w(function (_context3) {
|
|
34295
|
+
while (1) switch (_context3.n) {
|
|
34391
34296
|
case 0:
|
|
34392
|
-
|
|
34393
|
-
if (
|
|
34394
|
-
|
|
34297
|
+
faceLiveness = _ref3.faceLiveness, documentprefid = _ref3.documentprefid;
|
|
34298
|
+
if (!(!faceLiveness || !documentprefid)) {
|
|
34299
|
+
_context3.n = 1;
|
|
34395
34300
|
break;
|
|
34396
34301
|
}
|
|
34397
|
-
throw new ApacuanaAPIError("
|
|
34302
|
+
throw new ApacuanaAPIError("faceLiveness and documentprefid is a required parameter.", 400, "INVALID_PARAMETER");
|
|
34398
34303
|
case 1:
|
|
34399
|
-
|
|
34304
|
+
_getConfig = getConfig(), integrationType = _getConfig.integrationType;
|
|
34400
34305
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
34401
|
-
|
|
34306
|
+
_context3.n = 2;
|
|
34402
34307
|
break;
|
|
34403
34308
|
}
|
|
34404
|
-
return
|
|
34309
|
+
return _context3.a(2, sendFaceLivenessOnBoarding(faceLiveness, documentprefid));
|
|
34405
34310
|
case 2:
|
|
34406
34311
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
34407
|
-
|
|
34312
|
+
_context3.n = 3;
|
|
34408
34313
|
break;
|
|
34409
34314
|
}
|
|
34410
|
-
return
|
|
34315
|
+
return _context3.a(2, sendFaceLivenessOnPremise());
|
|
34411
34316
|
case 3:
|
|
34412
34317
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
34413
34318
|
case 4:
|
|
34414
|
-
return
|
|
34319
|
+
return _context3.a(2);
|
|
34415
34320
|
}
|
|
34416
|
-
},
|
|
34321
|
+
}, _callee3);
|
|
34417
34322
|
}));
|
|
34418
|
-
return function
|
|
34419
|
-
return
|
|
34323
|
+
return function sendFaceLiveness(_x3) {
|
|
34324
|
+
return _ref4.apply(this, arguments);
|
|
34420
34325
|
};
|
|
34421
34326
|
}();
|
|
34422
34327
|
|
|
@@ -34552,23 +34457,14 @@ var apacuana = {
|
|
|
34552
34457
|
checkSdk(true);
|
|
34553
34458
|
return getCustomer();
|
|
34554
34459
|
},
|
|
34555
|
-
createFaceLivenessSession: function createFaceLivenessSession$1() {
|
|
34556
|
-
checkSdk(true);
|
|
34557
|
-
return createFaceLivenessSession();
|
|
34558
|
-
},
|
|
34559
34460
|
createApacuanaUser: function createApacuanaUser$1(data) {
|
|
34560
34461
|
checkSdk(false);
|
|
34561
34462
|
return createApacuanaUser(data);
|
|
34562
34463
|
},
|
|
34563
|
-
|
|
34464
|
+
sendFaceLiveness: function sendFaceLiveness$1(data) {
|
|
34564
34465
|
checkSdk(true);
|
|
34565
|
-
return
|
|
34466
|
+
return sendFaceLiveness(data);
|
|
34566
34467
|
},
|
|
34567
|
-
// validateCertificate: (data) => {
|
|
34568
|
-
// checkSdk(true);
|
|
34569
|
-
// validateCertificate(data);
|
|
34570
|
-
// },
|
|
34571
|
-
|
|
34572
34468
|
close: function close$1() {
|
|
34573
34469
|
return close();
|
|
34574
34470
|
},
|