apacuana-sdk-core 1.3.0 → 1.7.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/coverage/clover.xml +168 -165
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov-report/src/api/certs.js.html +16 -10
- package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
- package/coverage/lcov-report/src/api/index.html +11 -11
- 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 +3 -3
- 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 +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.js.html +1 -1
- package/coverage/lcov-report/src/success/index.html +1 -1
- package/coverage/lcov-report/src/success/index.js.html +1 -1
- package/coverage/lcov-report/src/utils/constant.js.html +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +25 -7
- 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 +340 -333
- package/dist/index.js +228 -206
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +228 -206
- package/dist/index.mjs.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/certs.js +5 -3
- package/src/utils/helpers.js +6 -0
- package/tests/api/certs.test.js +38 -14
package/dist/index.js
CHANGED
|
@@ -32858,10 +32858,11 @@ var getCertificateStatus = function getCertificateStatus(userData, certificateIn
|
|
|
32858
32858
|
throw new ApacuanaAPIError("El parámetro certificateInDevice es requerido y debe ser un valor booleano.", 404, "INVALID_CERTIFICATE_IN_DEVICE");
|
|
32859
32859
|
}
|
|
32860
32860
|
if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
|
|
32861
|
-
var _userData$verificatio, _userData$
|
|
32861
|
+
var _userData$verificatio, _userData$requestscer, _userData$certificate, _userData$requestscer2, _userData$requestscer3, _userData$certificate2, _userData$certificate3;
|
|
32862
32862
|
if ((userData === null || userData === void 0 || (_userData$verificatio = userData.verificationstatus) === null || _userData$verificatio === void 0 ? void 0 : _userData$verificatio.id) !== VERIFICATION_STATUS.APPROVED) return STATUS_CERTIFICATE.request;
|
|
32863
|
-
if (
|
|
32864
|
-
if (userData !== null && userData !== void 0 && (_userData$requestscer2 = userData.requestscert) !== null && _userData$requestscer2 !== void 0 && _userData$requestscer2.pending) return STATUS_CERTIFICATE.
|
|
32863
|
+
if (!(userData !== null && userData !== void 0 && userData.certificationId) && (userData === null || userData === void 0 || (_userData$requestscer = userData.requestscert) === null || _userData$requestscer === void 0 ? void 0 : _userData$requestscer.requests.length) === 0) return STATUS_CERTIFICATE.request_cert;
|
|
32864
|
+
if (userData !== null && userData !== void 0 && userData.certifiedid && !(userData !== null && userData !== void 0 && (_userData$certificate = userData.certificatestatus) !== null && _userData$certificate !== void 0 && _userData$certificate.cangenerate) && !(userData !== null && userData !== void 0 && (_userData$requestscer2 = userData.requestscert) !== null && _userData$requestscer2 !== void 0 && _userData$requestscer2.pending) && !certificateInDevice && (userData === null || userData === void 0 ? void 0 : userData.certificatestatus) !== STATUS_CERTIFICATE.revoque) return STATUS_CERTIFICATE.certificate_another_device;
|
|
32865
|
+
if (userData !== null && userData !== void 0 && (_userData$requestscer3 = userData.requestscert) !== null && _userData$requestscer3 !== void 0 && _userData$requestscer3.pending) return STATUS_CERTIFICATE.request_revoque;
|
|
32865
32866
|
if (!(userData !== null && userData !== void 0 && (_userData$certificate2 = userData.certificatestatus) !== null && _userData$certificate2 !== void 0 && _userData$certificate2.cangenerate) && (userData === null || userData === void 0 ? void 0 : userData.certificatestatus) === STATUS_CERTIFICATE.revoque) return STATUS_CERTIFICATE.revoque;
|
|
32866
32867
|
if (userData !== null && userData !== void 0 && (_userData$certificate3 = userData.certificatestatus) !== null && _userData$certificate3 !== void 0 && _userData$certificate3.cangenerate) return STATUS_CERTIFICATE.generate;
|
|
32867
32868
|
if (userData !== null && userData !== void 0 && userData.certifiedid) return STATUS_CERTIFICATE.current;
|
|
@@ -33050,6 +33051,141 @@ var helpers = {
|
|
|
33050
33051
|
createPayloadGetDigest: createPayloadGetDigest
|
|
33051
33052
|
};
|
|
33052
33053
|
|
|
33054
|
+
/**
|
|
33055
|
+
* @typedef {object} GetCustomerData
|
|
33056
|
+
* @property {string} token - El token de sesión del usuario.
|
|
33057
|
+
* @property {object} userData - Los datos del usuario obtenidos.
|
|
33058
|
+
*/
|
|
33059
|
+
|
|
33060
|
+
/**
|
|
33061
|
+
* @typedef {object} GetCustomerResponse
|
|
33062
|
+
* @property {true} success - Indica que la operación fue exitosa.
|
|
33063
|
+
* @property {GetCustomerData} data - El payload de la respuesta.
|
|
33064
|
+
*/
|
|
33065
|
+
|
|
33066
|
+
/**
|
|
33067
|
+
* Obtiene el token de un usuario a través de una petición POST.
|
|
33068
|
+
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
33069
|
+
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
33070
|
+
*
|
|
33071
|
+
* @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
33072
|
+
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
33073
|
+
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
33074
|
+
*/
|
|
33075
|
+
var getCustomer = /*#__PURE__*/function () {
|
|
33076
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
33077
|
+
var _getConfig, verificationId, customerId, body, response, _t;
|
|
33078
|
+
return _regenerator().w(function (_context) {
|
|
33079
|
+
while (1) switch (_context.p = _context.n) {
|
|
33080
|
+
case 0:
|
|
33081
|
+
_getConfig = getConfig(), verificationId = _getConfig.verificationId, customerId = _getConfig.customerId;
|
|
33082
|
+
if (!(!verificationId || !customerId)) {
|
|
33083
|
+
_context.n = 1;
|
|
33084
|
+
break;
|
|
33085
|
+
}
|
|
33086
|
+
throw new ApacuanaAPIError("Both 'verificationId' and 'customerId' must be configured.", 400, "CONFIGURATION_ERROR");
|
|
33087
|
+
case 1:
|
|
33088
|
+
body = {
|
|
33089
|
+
verificationid: verificationId,
|
|
33090
|
+
customerid: customerId
|
|
33091
|
+
};
|
|
33092
|
+
_context.p = 2;
|
|
33093
|
+
_context.n = 3;
|
|
33094
|
+
return httpRequest("services/api/register/init", body, "POST");
|
|
33095
|
+
case 3:
|
|
33096
|
+
response = _context.v;
|
|
33097
|
+
if (!(!response.sessionid || !response.entry)) {
|
|
33098
|
+
_context.n = 4;
|
|
33099
|
+
break;
|
|
33100
|
+
}
|
|
33101
|
+
throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
|
|
33102
|
+
case 4:
|
|
33103
|
+
return _context.a(2, new ApacuanaSuccess({
|
|
33104
|
+
token: response.sessionid,
|
|
33105
|
+
userData: response.entry
|
|
33106
|
+
}));
|
|
33107
|
+
case 5:
|
|
33108
|
+
_context.p = 5;
|
|
33109
|
+
_t = _context.v;
|
|
33110
|
+
if (!(_t instanceof ApacuanaAPIError)) {
|
|
33111
|
+
_context.n = 6;
|
|
33112
|
+
break;
|
|
33113
|
+
}
|
|
33114
|
+
throw _t;
|
|
33115
|
+
case 6:
|
|
33116
|
+
throw new ApacuanaAPIError("Unexpected failure getting token: ".concat(_t.message || "Unknown error"));
|
|
33117
|
+
case 7:
|
|
33118
|
+
return _context.a(2);
|
|
33119
|
+
}
|
|
33120
|
+
}, _callee, null, [[2, 5]]);
|
|
33121
|
+
}));
|
|
33122
|
+
return function getCustomer() {
|
|
33123
|
+
return _ref.apply(this, arguments);
|
|
33124
|
+
};
|
|
33125
|
+
}();
|
|
33126
|
+
|
|
33127
|
+
/**
|
|
33128
|
+
* @typedef {object} CreateUserPayload
|
|
33129
|
+
* @property {string} usr - Correo electrónico del usuario.
|
|
33130
|
+
* @property {string} pwd - Contraseña del usuario.
|
|
33131
|
+
* @property {string} kinddoc - Tipo de documento de identidad (ej. 'V', 'P', 'E').
|
|
33132
|
+
* @property {string} doc - Número de documento de identidad.
|
|
33133
|
+
*/
|
|
33134
|
+
|
|
33135
|
+
/**
|
|
33136
|
+
* @typedef {object} CreateUserResponse
|
|
33137
|
+
* @property {string} message - Mensaje de confirmación de la creación del usuario.
|
|
33138
|
+
*/
|
|
33139
|
+
|
|
33140
|
+
/**
|
|
33141
|
+
* Crea un nuevo usuario en la plataforma de Apacuana.
|
|
33142
|
+
* @param {CreateUserPayload} userData - Objeto con los datos del usuario a crear.
|
|
33143
|
+
* @returns {Promise<ApacuanaSuccess>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
33144
|
+
* @throws {ApacuanaAPIError} Si los datos de entrada son inválidos o si ocurre un error en la API.
|
|
33145
|
+
*/
|
|
33146
|
+
|
|
33147
|
+
var createApacuanaUser = /*#__PURE__*/function () {
|
|
33148
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(userData) {
|
|
33149
|
+
var formData, response, _t2;
|
|
33150
|
+
return _regenerator().w(function (_context2) {
|
|
33151
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
33152
|
+
case 0:
|
|
33153
|
+
_context2.p = 0;
|
|
33154
|
+
formData = new FormData();
|
|
33155
|
+
Object.keys(userData).forEach(function (key) {
|
|
33156
|
+
var value = userData[key];
|
|
33157
|
+
var isRNFile = value && _typeof(value) === "object" && value.uri && value.name && value.type;
|
|
33158
|
+
if (value instanceof File || isRNFile) {
|
|
33159
|
+
formData.append(key, value);
|
|
33160
|
+
} else if (value !== null && value !== undefined) {
|
|
33161
|
+
formData.append(key, String(value));
|
|
33162
|
+
}
|
|
33163
|
+
});
|
|
33164
|
+
_context2.n = 1;
|
|
33165
|
+
return httpRequest("services/api/register/initial", formData, "POST");
|
|
33166
|
+
case 1:
|
|
33167
|
+
response = _context2.v;
|
|
33168
|
+
return _context2.a(2, new ApacuanaSuccess(_objectSpread2({}, response)));
|
|
33169
|
+
case 2:
|
|
33170
|
+
_context2.p = 2;
|
|
33171
|
+
_t2 = _context2.v;
|
|
33172
|
+
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
33173
|
+
_context2.n = 3;
|
|
33174
|
+
break;
|
|
33175
|
+
}
|
|
33176
|
+
throw _t2;
|
|
33177
|
+
case 3:
|
|
33178
|
+
throw new ApacuanaAPIError("Unexpected failure creating user: ".concat(_t2.message || "Unknown error"));
|
|
33179
|
+
case 4:
|
|
33180
|
+
return _context2.a(2);
|
|
33181
|
+
}
|
|
33182
|
+
}, _callee2, null, [[0, 2]]);
|
|
33183
|
+
}));
|
|
33184
|
+
return function createApacuanaUser(_x) {
|
|
33185
|
+
return _ref2.apply(this, arguments);
|
|
33186
|
+
};
|
|
33187
|
+
}();
|
|
33188
|
+
|
|
33053
33189
|
/**
|
|
33054
33190
|
* @param {EncryptedCSRObject} encryptedCSR
|
|
33055
33191
|
*/
|
|
@@ -33153,60 +33289,81 @@ var generateCert = /*#__PURE__*/function () {
|
|
|
33153
33289
|
* @param {boolean} [isCertificateInDevice=false] - Indicates if the certificate is already on the device.
|
|
33154
33290
|
* @returns {GetCertStatusResponse} Object with the certificate status and a success indicator.
|
|
33155
33291
|
*/
|
|
33156
|
-
var getCertStatus = function
|
|
33157
|
-
var isCertificateInDevice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
33158
|
-
var config = getConfig();
|
|
33159
|
-
var status = helpers.getCertificateStatus(config.userData, isCertificateInDevice, config.integrationType);
|
|
33160
|
-
console.log(status, "Core sdk");
|
|
33161
|
-
var parseStatus = PARSE_STATUS[status];
|
|
33162
|
-
return new ApacuanaSuccess({
|
|
33163
|
-
status: parseStatus
|
|
33164
|
-
});
|
|
33165
|
-
};
|
|
33166
|
-
var getCertTypesOnBoarding = /*#__PURE__*/function () {
|
|
33292
|
+
var getCertStatus = /*#__PURE__*/function () {
|
|
33167
33293
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
33168
|
-
var
|
|
33294
|
+
var isCertificateInDevice,
|
|
33295
|
+
config,
|
|
33296
|
+
customer,
|
|
33297
|
+
userData,
|
|
33298
|
+
status,
|
|
33299
|
+
parseStatus,
|
|
33300
|
+
_args4 = arguments;
|
|
33169
33301
|
return _regenerator().w(function (_context4) {
|
|
33170
|
-
while (1) switch (_context4.
|
|
33302
|
+
while (1) switch (_context4.n) {
|
|
33171
33303
|
case 0:
|
|
33172
|
-
|
|
33304
|
+
isCertificateInDevice = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : false;
|
|
33305
|
+
config = getConfig();
|
|
33173
33306
|
_context4.n = 1;
|
|
33307
|
+
return getCustomer();
|
|
33308
|
+
case 1:
|
|
33309
|
+
customer = _context4.v;
|
|
33310
|
+
userData = customer.data.userData;
|
|
33311
|
+
status = helpers.getCertificateStatus(userData, isCertificateInDevice, config.integrationType);
|
|
33312
|
+
parseStatus = PARSE_STATUS[status];
|
|
33313
|
+
return _context4.a(2, new ApacuanaSuccess({
|
|
33314
|
+
status: parseStatus
|
|
33315
|
+
}));
|
|
33316
|
+
}
|
|
33317
|
+
}, _callee4);
|
|
33318
|
+
}));
|
|
33319
|
+
return function getCertStatus() {
|
|
33320
|
+
return _ref4.apply(this, arguments);
|
|
33321
|
+
};
|
|
33322
|
+
}();
|
|
33323
|
+
var getCertTypesOnBoarding = /*#__PURE__*/function () {
|
|
33324
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
33325
|
+
var response, _t2;
|
|
33326
|
+
return _regenerator().w(function (_context5) {
|
|
33327
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
33328
|
+
case 0:
|
|
33329
|
+
_context5.p = 0;
|
|
33330
|
+
_context5.n = 1;
|
|
33174
33331
|
return httpRequest("services/api/customer/typeusers", {}, "GET");
|
|
33175
33332
|
case 1:
|
|
33176
|
-
response =
|
|
33177
|
-
return
|
|
33333
|
+
response = _context5.v;
|
|
33334
|
+
return _context5.a(2, new ApacuanaSuccess(response));
|
|
33178
33335
|
case 2:
|
|
33179
|
-
|
|
33180
|
-
_t2 =
|
|
33336
|
+
_context5.p = 2;
|
|
33337
|
+
_t2 = _context5.v;
|
|
33181
33338
|
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
33182
|
-
|
|
33339
|
+
_context5.n = 3;
|
|
33183
33340
|
break;
|
|
33184
33341
|
}
|
|
33185
33342
|
throw _t2;
|
|
33186
33343
|
case 3:
|
|
33187
33344
|
throw new Error("Failed to get certificate types: ".concat(_t2.message));
|
|
33188
33345
|
case 4:
|
|
33189
|
-
return
|
|
33346
|
+
return _context5.a(2);
|
|
33190
33347
|
}
|
|
33191
|
-
},
|
|
33348
|
+
}, _callee5, null, [[0, 2]]);
|
|
33192
33349
|
}));
|
|
33193
33350
|
return function getCertTypesOnBoarding() {
|
|
33194
|
-
return
|
|
33351
|
+
return _ref5.apply(this, arguments);
|
|
33195
33352
|
};
|
|
33196
33353
|
}();
|
|
33197
33354
|
var getCertTypesOnPremise = /*#__PURE__*/function () {
|
|
33198
|
-
var
|
|
33199
|
-
return _regenerator().w(function (
|
|
33200
|
-
while (1) switch (
|
|
33355
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
33356
|
+
return _regenerator().w(function (_context6) {
|
|
33357
|
+
while (1) switch (_context6.n) {
|
|
33201
33358
|
case 0:
|
|
33202
33359
|
throw new ApacuanaAPIError("Getting certificate types is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
33203
33360
|
case 1:
|
|
33204
|
-
return
|
|
33361
|
+
return _context6.a(2);
|
|
33205
33362
|
}
|
|
33206
|
-
},
|
|
33363
|
+
}, _callee6);
|
|
33207
33364
|
}));
|
|
33208
33365
|
return function getCertTypesOnPremise() {
|
|
33209
|
-
return
|
|
33366
|
+
return _ref6.apply(this, arguments);
|
|
33210
33367
|
};
|
|
33211
33368
|
}();
|
|
33212
33369
|
|
|
@@ -33217,78 +33374,78 @@ var getCertTypesOnPremise = /*#__PURE__*/function () {
|
|
|
33217
33374
|
* @throws {Error} If the request fails for another reason.
|
|
33218
33375
|
*/
|
|
33219
33376
|
var getCertTypes = /*#__PURE__*/function () {
|
|
33220
|
-
var
|
|
33377
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
33221
33378
|
var _getConfig2, integrationType;
|
|
33222
|
-
return _regenerator().w(function (
|
|
33223
|
-
while (1) switch (
|
|
33379
|
+
return _regenerator().w(function (_context7) {
|
|
33380
|
+
while (1) switch (_context7.n) {
|
|
33224
33381
|
case 0:
|
|
33225
33382
|
_getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
|
|
33226
33383
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33227
|
-
|
|
33384
|
+
_context7.n = 1;
|
|
33228
33385
|
break;
|
|
33229
33386
|
}
|
|
33230
|
-
return
|
|
33387
|
+
return _context7.a(2, getCertTypesOnBoarding());
|
|
33231
33388
|
case 1:
|
|
33232
33389
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33233
|
-
|
|
33390
|
+
_context7.n = 2;
|
|
33234
33391
|
break;
|
|
33235
33392
|
}
|
|
33236
|
-
return
|
|
33393
|
+
return _context7.a(2, getCertTypesOnPremise());
|
|
33237
33394
|
case 2:
|
|
33238
33395
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33239
33396
|
case 3:
|
|
33240
|
-
return
|
|
33397
|
+
return _context7.a(2);
|
|
33241
33398
|
}
|
|
33242
|
-
},
|
|
33399
|
+
}, _callee7);
|
|
33243
33400
|
}));
|
|
33244
33401
|
return function getCertTypes() {
|
|
33245
|
-
return
|
|
33402
|
+
return _ref7.apply(this, arguments);
|
|
33246
33403
|
};
|
|
33247
33404
|
}();
|
|
33248
33405
|
var getRequerimentsByTypeUserOnBoarding = /*#__PURE__*/function () {
|
|
33249
|
-
var
|
|
33406
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(type) {
|
|
33250
33407
|
var response, _t3;
|
|
33251
|
-
return _regenerator().w(function (
|
|
33252
|
-
while (1) switch (
|
|
33408
|
+
return _regenerator().w(function (_context8) {
|
|
33409
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
33253
33410
|
case 0:
|
|
33254
|
-
|
|
33255
|
-
|
|
33411
|
+
_context8.p = 0;
|
|
33412
|
+
_context8.n = 1;
|
|
33256
33413
|
return httpRequest("services/api/customer/documentspref?typeuser=".concat(type), {}, "GET");
|
|
33257
33414
|
case 1:
|
|
33258
|
-
response =
|
|
33259
|
-
return
|
|
33415
|
+
response = _context8.v;
|
|
33416
|
+
return _context8.a(2, new ApacuanaSuccess(response));
|
|
33260
33417
|
case 2:
|
|
33261
|
-
|
|
33262
|
-
_t3 =
|
|
33418
|
+
_context8.p = 2;
|
|
33419
|
+
_t3 = _context8.v;
|
|
33263
33420
|
if (!(_t3 instanceof ApacuanaAPIError)) {
|
|
33264
|
-
|
|
33421
|
+
_context8.n = 3;
|
|
33265
33422
|
break;
|
|
33266
33423
|
}
|
|
33267
33424
|
throw _t3;
|
|
33268
33425
|
case 3:
|
|
33269
33426
|
throw new Error("Failed to get requirements: ".concat(_t3.message));
|
|
33270
33427
|
case 4:
|
|
33271
|
-
return
|
|
33428
|
+
return _context8.a(2);
|
|
33272
33429
|
}
|
|
33273
|
-
},
|
|
33430
|
+
}, _callee8, null, [[0, 2]]);
|
|
33274
33431
|
}));
|
|
33275
33432
|
return function getRequerimentsByTypeUserOnBoarding(_x3) {
|
|
33276
|
-
return
|
|
33433
|
+
return _ref8.apply(this, arguments);
|
|
33277
33434
|
};
|
|
33278
33435
|
}();
|
|
33279
33436
|
var getRequerimentsByTypeUserOnPremise = /*#__PURE__*/function () {
|
|
33280
|
-
var
|
|
33281
|
-
return _regenerator().w(function (
|
|
33282
|
-
while (1) switch (
|
|
33437
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
33438
|
+
return _regenerator().w(function (_context9) {
|
|
33439
|
+
while (1) switch (_context9.n) {
|
|
33283
33440
|
case 0:
|
|
33284
33441
|
throw new ApacuanaAPIError("Getting requirements by user type is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
33285
33442
|
case 1:
|
|
33286
|
-
return
|
|
33443
|
+
return _context9.a(2);
|
|
33287
33444
|
}
|
|
33288
|
-
},
|
|
33445
|
+
}, _callee9);
|
|
33289
33446
|
}));
|
|
33290
33447
|
return function getRequerimentsByTypeUserOnPremise() {
|
|
33291
|
-
return
|
|
33448
|
+
return _ref9.apply(this, arguments);
|
|
33292
33449
|
};
|
|
33293
33450
|
}();
|
|
33294
33451
|
|
|
@@ -33301,13 +33458,13 @@ var getRequerimentsByTypeUserOnPremise = /*#__PURE__*/function () {
|
|
|
33301
33458
|
* @throws {Error} If the request fails for another reason or the type is invalid.
|
|
33302
33459
|
*/
|
|
33303
33460
|
var getRequerimentsByTypeUser = /*#__PURE__*/function () {
|
|
33304
|
-
var
|
|
33461
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(params) {
|
|
33305
33462
|
var type, _getConfig3, integrationType;
|
|
33306
|
-
return _regenerator().w(function (
|
|
33307
|
-
while (1) switch (
|
|
33463
|
+
return _regenerator().w(function (_context0) {
|
|
33464
|
+
while (1) switch (_context0.n) {
|
|
33308
33465
|
case 0:
|
|
33309
33466
|
if (!(!params || typeof params.type !== "number")) {
|
|
33310
|
-
|
|
33467
|
+
_context0.n = 1;
|
|
33311
33468
|
break;
|
|
33312
33469
|
}
|
|
33313
33470
|
throw new Error('The "params" object with a numeric "type" property is required.');
|
|
@@ -33315,25 +33472,25 @@ var getRequerimentsByTypeUser = /*#__PURE__*/function () {
|
|
|
33315
33472
|
type = params.type;
|
|
33316
33473
|
_getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
|
|
33317
33474
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33318
|
-
|
|
33475
|
+
_context0.n = 2;
|
|
33319
33476
|
break;
|
|
33320
33477
|
}
|
|
33321
|
-
return
|
|
33478
|
+
return _context0.a(2, getRequerimentsByTypeUserOnBoarding(type));
|
|
33322
33479
|
case 2:
|
|
33323
33480
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33324
|
-
|
|
33481
|
+
_context0.n = 3;
|
|
33325
33482
|
break;
|
|
33326
33483
|
}
|
|
33327
|
-
return
|
|
33484
|
+
return _context0.a(2, getRequerimentsByTypeUserOnPremise());
|
|
33328
33485
|
case 3:
|
|
33329
33486
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33330
33487
|
case 4:
|
|
33331
|
-
return
|
|
33488
|
+
return _context0.a(2);
|
|
33332
33489
|
}
|
|
33333
|
-
},
|
|
33490
|
+
}, _callee0);
|
|
33334
33491
|
}));
|
|
33335
33492
|
return function getRequerimentsByTypeUser(_x4) {
|
|
33336
|
-
return
|
|
33493
|
+
return _ref0.apply(this, arguments);
|
|
33337
33494
|
};
|
|
33338
33495
|
}();
|
|
33339
33496
|
|
|
@@ -34204,141 +34361,6 @@ var validateFaceLiveness = /*#__PURE__*/function () {
|
|
|
34204
34361
|
};
|
|
34205
34362
|
}();
|
|
34206
34363
|
|
|
34207
|
-
/**
|
|
34208
|
-
* @typedef {object} GetCustomerData
|
|
34209
|
-
* @property {string} token - El token de sesión del usuario.
|
|
34210
|
-
* @property {object} userData - Los datos del usuario obtenidos.
|
|
34211
|
-
*/
|
|
34212
|
-
|
|
34213
|
-
/**
|
|
34214
|
-
* @typedef {object} GetCustomerResponse
|
|
34215
|
-
* @property {true} success - Indica que la operación fue exitosa.
|
|
34216
|
-
* @property {GetCustomerData} data - El payload de la respuesta.
|
|
34217
|
-
*/
|
|
34218
|
-
|
|
34219
|
-
/**
|
|
34220
|
-
* Obtiene el token de un usuario a través de una petición POST.
|
|
34221
|
-
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
34222
|
-
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
34223
|
-
*
|
|
34224
|
-
* @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
34225
|
-
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
34226
|
-
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
34227
|
-
*/
|
|
34228
|
-
var getCustomer = /*#__PURE__*/function () {
|
|
34229
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
34230
|
-
var _getConfig, verificationId, customerId, body, response, _t;
|
|
34231
|
-
return _regenerator().w(function (_context) {
|
|
34232
|
-
while (1) switch (_context.p = _context.n) {
|
|
34233
|
-
case 0:
|
|
34234
|
-
_getConfig = getConfig(), verificationId = _getConfig.verificationId, customerId = _getConfig.customerId;
|
|
34235
|
-
if (!(!verificationId || !customerId)) {
|
|
34236
|
-
_context.n = 1;
|
|
34237
|
-
break;
|
|
34238
|
-
}
|
|
34239
|
-
throw new ApacuanaAPIError("Both 'verificationId' and 'customerId' must be configured.", 400, "CONFIGURATION_ERROR");
|
|
34240
|
-
case 1:
|
|
34241
|
-
body = {
|
|
34242
|
-
verificationid: verificationId,
|
|
34243
|
-
customerid: customerId
|
|
34244
|
-
};
|
|
34245
|
-
_context.p = 2;
|
|
34246
|
-
_context.n = 3;
|
|
34247
|
-
return httpRequest("services/api/register/init", body, "POST");
|
|
34248
|
-
case 3:
|
|
34249
|
-
response = _context.v;
|
|
34250
|
-
if (!(!response.sessionid || !response.entry)) {
|
|
34251
|
-
_context.n = 4;
|
|
34252
|
-
break;
|
|
34253
|
-
}
|
|
34254
|
-
throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
|
|
34255
|
-
case 4:
|
|
34256
|
-
return _context.a(2, new ApacuanaSuccess({
|
|
34257
|
-
token: response.sessionid,
|
|
34258
|
-
userData: response.entry
|
|
34259
|
-
}));
|
|
34260
|
-
case 5:
|
|
34261
|
-
_context.p = 5;
|
|
34262
|
-
_t = _context.v;
|
|
34263
|
-
if (!(_t instanceof ApacuanaAPIError)) {
|
|
34264
|
-
_context.n = 6;
|
|
34265
|
-
break;
|
|
34266
|
-
}
|
|
34267
|
-
throw _t;
|
|
34268
|
-
case 6:
|
|
34269
|
-
throw new ApacuanaAPIError("Unexpected failure getting token: ".concat(_t.message || "Unknown error"));
|
|
34270
|
-
case 7:
|
|
34271
|
-
return _context.a(2);
|
|
34272
|
-
}
|
|
34273
|
-
}, _callee, null, [[2, 5]]);
|
|
34274
|
-
}));
|
|
34275
|
-
return function getCustomer() {
|
|
34276
|
-
return _ref.apply(this, arguments);
|
|
34277
|
-
};
|
|
34278
|
-
}();
|
|
34279
|
-
|
|
34280
|
-
/**
|
|
34281
|
-
* @typedef {object} CreateUserPayload
|
|
34282
|
-
* @property {string} usr - Correo electrónico del usuario.
|
|
34283
|
-
* @property {string} pwd - Contraseña del usuario.
|
|
34284
|
-
* @property {string} kinddoc - Tipo de documento de identidad (ej. 'V', 'P', 'E').
|
|
34285
|
-
* @property {string} doc - Número de documento de identidad.
|
|
34286
|
-
*/
|
|
34287
|
-
|
|
34288
|
-
/**
|
|
34289
|
-
* @typedef {object} CreateUserResponse
|
|
34290
|
-
* @property {string} message - Mensaje de confirmación de la creación del usuario.
|
|
34291
|
-
*/
|
|
34292
|
-
|
|
34293
|
-
/**
|
|
34294
|
-
* Crea un nuevo usuario en la plataforma de Apacuana.
|
|
34295
|
-
* @param {CreateUserPayload} userData - Objeto con los datos del usuario a crear.
|
|
34296
|
-
* @returns {Promise<ApacuanaSuccess>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
34297
|
-
* @throws {ApacuanaAPIError} Si los datos de entrada son inválidos o si ocurre un error en la API.
|
|
34298
|
-
*/
|
|
34299
|
-
|
|
34300
|
-
var createApacuanaUser = /*#__PURE__*/function () {
|
|
34301
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(userData) {
|
|
34302
|
-
var formData, response, _t2;
|
|
34303
|
-
return _regenerator().w(function (_context2) {
|
|
34304
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
34305
|
-
case 0:
|
|
34306
|
-
_context2.p = 0;
|
|
34307
|
-
formData = new FormData();
|
|
34308
|
-
Object.keys(userData).forEach(function (key) {
|
|
34309
|
-
var value = userData[key];
|
|
34310
|
-
var isRNFile = value && _typeof(value) === "object" && value.uri && value.name && value.type;
|
|
34311
|
-
if (value instanceof File || isRNFile) {
|
|
34312
|
-
formData.append(key, value);
|
|
34313
|
-
} else if (value !== null && value !== undefined) {
|
|
34314
|
-
formData.append(key, String(value));
|
|
34315
|
-
}
|
|
34316
|
-
});
|
|
34317
|
-
_context2.n = 1;
|
|
34318
|
-
return httpRequest("services/api/register/initial", formData, "POST");
|
|
34319
|
-
case 1:
|
|
34320
|
-
response = _context2.v;
|
|
34321
|
-
return _context2.a(2, new ApacuanaSuccess(_objectSpread2({}, response)));
|
|
34322
|
-
case 2:
|
|
34323
|
-
_context2.p = 2;
|
|
34324
|
-
_t2 = _context2.v;
|
|
34325
|
-
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
34326
|
-
_context2.n = 3;
|
|
34327
|
-
break;
|
|
34328
|
-
}
|
|
34329
|
-
throw _t2;
|
|
34330
|
-
case 3:
|
|
34331
|
-
throw new ApacuanaAPIError("Unexpected failure creating user: ".concat(_t2.message || "Unknown error"));
|
|
34332
|
-
case 4:
|
|
34333
|
-
return _context2.a(2);
|
|
34334
|
-
}
|
|
34335
|
-
}, _callee2, null, [[0, 2]]);
|
|
34336
|
-
}));
|
|
34337
|
-
return function createApacuanaUser(_x) {
|
|
34338
|
-
return _ref2.apply(this, arguments);
|
|
34339
|
-
};
|
|
34340
|
-
}();
|
|
34341
|
-
|
|
34342
34364
|
/**
|
|
34343
34365
|
* Valida si el SDK está inicializado y si se dispone de un customerId.
|
|
34344
34366
|
* @param {boolean} requiresCustomerId - Indica si la operación necesita un customerId.
|