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