apacuana-sdk-core 1.26.1 → 1.26.2

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 (46) hide show
  1. package/.env +8 -0
  2. package/README.md +69 -0
  3. package/coverage/clover.xml +181 -136
  4. package/coverage/coverage-final.json +4 -4
  5. package/coverage/lcov-report/index.html +27 -27
  6. package/coverage/lcov-report/src/api/certs.js.html +1 -1
  7. package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
  8. package/coverage/lcov-report/src/api/index.html +18 -18
  9. package/coverage/lcov-report/src/api/revocations.js.html +1 -1
  10. package/coverage/lcov-report/src/api/signatures.js.html +417 -9
  11. package/coverage/lcov-report/src/api/users.js.html +1 -1
  12. package/coverage/lcov-report/src/config/index.html +1 -1
  13. package/coverage/lcov-report/src/config/index.js.html +1 -1
  14. package/coverage/lcov-report/src/errors/index.html +1 -1
  15. package/coverage/lcov-report/src/errors/index.js.html +8 -8
  16. package/coverage/lcov-report/src/index.html +15 -15
  17. package/coverage/lcov-report/src/index.js.html +41 -8
  18. package/coverage/lcov-report/src/success/index.html +1 -1
  19. package/coverage/lcov-report/src/success/index.js.html +5 -5
  20. package/coverage/lcov-report/src/utils/constant.js.html +1 -1
  21. package/coverage/lcov-report/src/utils/helpers.js.html +1 -1
  22. package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
  23. package/coverage/lcov-report/src/utils/index.html +1 -1
  24. package/coverage/lcov.info +325 -235
  25. package/dist/api/signatures.d.ts +5 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +288 -90
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +288 -90
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/src/api/signatures.js +136 -0
  33. package/src/index.js +11 -0
  34. package/tests/api/signatures.test.js +166 -2
  35. package/tests/integration/createAndLockDocument.test.js +93 -0
  36. package/coverage/lcov-report/api/index.html +0 -131
  37. package/coverage/lcov-report/api/signatures.js.html +0 -1093
  38. package/coverage/lcov-report/api/users.js.html +0 -292
  39. package/coverage/lcov-report/certs.js.html +0 -175
  40. package/coverage/lcov-report/config/index.html +0 -116
  41. package/coverage/lcov-report/config/index.js.html +0 -208
  42. package/coverage/lcov-report/errors/index.html +0 -116
  43. package/coverage/lcov-report/errors/index.js.html +0 -148
  44. package/coverage/lcov-report/utils/constant.js.html +0 -145
  45. package/coverage/lcov-report/utils/httpClient.js.html +0 -646
  46. package/coverage/lcov-report/utils/index.html +0 -131
package/dist/index.js CHANGED
@@ -34015,6 +34015,104 @@ var addMemberOnPremise = /*#__PURE__*/function () {
34015
34015
  return _ref15.apply(this, arguments);
34016
34016
  };
34017
34017
  }();
34018
+ var createDocumentOnBoarding = /*#__PURE__*/function () {
34019
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(documentData) {
34020
+ var formData, response, _t9;
34021
+ return _regenerator().w(function (_context15) {
34022
+ while (1) switch (_context15.p = _context15.n) {
34023
+ case 0:
34024
+ formData = new FormData();
34025
+ formData.append("name", documentData.name);
34026
+ formData.append("reference", documentData.reference);
34027
+ _context15.p = 1;
34028
+ _context15.n = 2;
34029
+ return httpRequest("services/api/documents", formData, "POST");
34030
+ case 2:
34031
+ response = _context15.v;
34032
+ return _context15.a(2, new ApacuanaSuccess({
34033
+ msg: response.msg,
34034
+ id: response.id
34035
+ }));
34036
+ case 3:
34037
+ _context15.p = 3;
34038
+ _t9 = _context15.v;
34039
+ if (!(_t9 instanceof ApacuanaAPIError)) {
34040
+ _context15.n = 4;
34041
+ break;
34042
+ }
34043
+ throw _t9;
34044
+ case 4:
34045
+ throw new ApacuanaAPIError("Failed to create document: ".concat(_t9.message || "Unknown error"));
34046
+ case 5:
34047
+ return _context15.a(2);
34048
+ }
34049
+ }, _callee15, null, [[1, 3]]);
34050
+ }));
34051
+ return function createDocumentOnBoarding(_x7) {
34052
+ return _ref16.apply(this, arguments);
34053
+ };
34054
+ }();
34055
+ var createDocumentOnPremise = /*#__PURE__*/function () {
34056
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
34057
+ return _regenerator().w(function (_context16) {
34058
+ while (1) switch (_context16.n) {
34059
+ case 0:
34060
+ throw new ApacuanaAPIError("Creating documents is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
34061
+ case 1:
34062
+ return _context16.a(2);
34063
+ }
34064
+ }, _callee16);
34065
+ }));
34066
+ return function createDocumentOnPremise() {
34067
+ return _ref17.apply(this, arguments);
34068
+ };
34069
+ }();
34070
+ var lockDocumentOnBoarding = /*#__PURE__*/function () {
34071
+ var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(documentId) {
34072
+ var response, _t0;
34073
+ return _regenerator().w(function (_context17) {
34074
+ while (1) switch (_context17.p = _context17.n) {
34075
+ case 0:
34076
+ _context17.p = 0;
34077
+ _context17.n = 1;
34078
+ return httpRequest("services/api/documents/lock/".concat(documentId), {}, "PUT");
34079
+ case 1:
34080
+ response = _context17.v;
34081
+ return _context17.a(2, new ApacuanaSuccess(response));
34082
+ case 2:
34083
+ _context17.p = 2;
34084
+ _t0 = _context17.v;
34085
+ if (!(_t0 instanceof ApacuanaAPIError)) {
34086
+ _context17.n = 3;
34087
+ break;
34088
+ }
34089
+ throw _t0;
34090
+ case 3:
34091
+ throw new ApacuanaAPIError("Failed to lock document: ".concat(_t0.message || "Unknown error"));
34092
+ case 4:
34093
+ return _context17.a(2);
34094
+ }
34095
+ }, _callee17, null, [[0, 2]]);
34096
+ }));
34097
+ return function lockDocumentOnBoarding(_x8) {
34098
+ return _ref18.apply(this, arguments);
34099
+ };
34100
+ }();
34101
+ var lockDocumentOnPremise = /*#__PURE__*/function () {
34102
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
34103
+ return _regenerator().w(function (_context18) {
34104
+ while (1) switch (_context18.n) {
34105
+ case 0:
34106
+ throw new ApacuanaAPIError("Locking documents is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
34107
+ case 1:
34108
+ return _context18.a(2);
34109
+ }
34110
+ }, _callee18);
34111
+ }));
34112
+ return function lockDocumentOnPremise() {
34113
+ return _ref19.apply(this, arguments);
34114
+ };
34115
+ }();
34018
34116
 
34019
34117
  // =================================================================
34020
34118
  // Exported Functions
@@ -34028,32 +34126,32 @@ var addMemberOnPremise = /*#__PURE__*/function () {
34028
34126
  * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
34029
34127
  */
34030
34128
  var signDocument = /*#__PURE__*/function () {
34031
- var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signData) {
34129
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(signData) {
34032
34130
  var _getConfig3, integrationType;
34033
- return _regenerator().w(function (_context15) {
34034
- while (1) switch (_context15.n) {
34131
+ return _regenerator().w(function (_context19) {
34132
+ while (1) switch (_context19.n) {
34035
34133
  case 0:
34036
34134
  _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
34037
34135
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34038
- _context15.n = 1;
34136
+ _context19.n = 1;
34039
34137
  break;
34040
34138
  }
34041
- return _context15.a(2, signDocumentOnBoarding(signData));
34139
+ return _context19.a(2, signDocumentOnBoarding(signData));
34042
34140
  case 1:
34043
34141
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34044
- _context15.n = 2;
34142
+ _context19.n = 2;
34045
34143
  break;
34046
34144
  }
34047
- return _context15.a(2, signDocumentOnPremise());
34145
+ return _context19.a(2, signDocumentOnPremise());
34048
34146
  case 2:
34049
34147
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34050
34148
  case 3:
34051
- return _context15.a(2);
34149
+ return _context19.a(2);
34052
34150
  }
34053
- }, _callee15);
34151
+ }, _callee19);
34054
34152
  }));
34055
- return function signDocument(_x7) {
34056
- return _ref16.apply(this, arguments);
34153
+ return function signDocument(_x9) {
34154
+ return _ref20.apply(this, arguments);
34057
34155
  };
34058
34156
  }();
34059
34157
 
@@ -34064,33 +34162,33 @@ var signDocument = /*#__PURE__*/function () {
34064
34162
  * @throws {ApacuanaAPIError} Si los datos de entrada son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
34065
34163
  */
34066
34164
  var getDigest = /*#__PURE__*/function () {
34067
- var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(signData) {
34165
+ var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(signData) {
34068
34166
  var _getConfig4, integrationType;
34069
- return _regenerator().w(function (_context16) {
34070
- while (1) switch (_context16.n) {
34167
+ return _regenerator().w(function (_context20) {
34168
+ while (1) switch (_context20.n) {
34071
34169
  case 0:
34072
34170
  helpers.validateGetDigestData(signData);
34073
34171
  _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
34074
34172
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34075
- _context16.n = 1;
34173
+ _context20.n = 1;
34076
34174
  break;
34077
34175
  }
34078
- return _context16.a(2, getDigestToSignOnBoarding(signData));
34176
+ return _context20.a(2, getDigestToSignOnBoarding(signData));
34079
34177
  case 1:
34080
34178
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34081
- _context16.n = 2;
34179
+ _context20.n = 2;
34082
34180
  break;
34083
34181
  }
34084
- return _context16.a(2, getDigestToSignOnPremise());
34182
+ return _context20.a(2, getDigestToSignOnPremise());
34085
34183
  case 2:
34086
34184
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
34087
34185
  case 3:
34088
- return _context16.a(2);
34186
+ return _context20.a(2);
34089
34187
  }
34090
- }, _callee16);
34188
+ }, _callee20);
34091
34189
  }));
34092
- return function getDigest(_x8) {
34093
- return _ref17.apply(this, arguments);
34190
+ return function getDigest(_x0) {
34191
+ return _ref21.apply(this, arguments);
34094
34192
  };
34095
34193
  }();
34096
34194
 
@@ -34101,38 +34199,38 @@ var getDigest = /*#__PURE__*/function () {
34101
34199
  * @throws {ApacuanaAPIError} Si los datos del firmante son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
34102
34200
  */
34103
34201
  var addSigner = /*#__PURE__*/function () {
34104
- var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(signerData) {
34202
+ var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(signerData) {
34105
34203
  var _getConfig5, integrationType;
34106
- return _regenerator().w(function (_context17) {
34107
- while (1) switch (_context17.n) {
34204
+ return _regenerator().w(function (_context21) {
34205
+ while (1) switch (_context21.n) {
34108
34206
  case 0:
34109
34207
  if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
34110
- _context17.n = 1;
34208
+ _context21.n = 1;
34111
34209
  break;
34112
34210
  }
34113
34211
  throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
34114
34212
  case 1:
34115
34213
  _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
34116
34214
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34117
- _context17.n = 2;
34215
+ _context21.n = 2;
34118
34216
  break;
34119
34217
  }
34120
- return _context17.a(2, addSignerOnBoarding(signerData));
34218
+ return _context21.a(2, addSignerOnBoarding(signerData));
34121
34219
  case 2:
34122
34220
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34123
- _context17.n = 3;
34221
+ _context21.n = 3;
34124
34222
  break;
34125
34223
  }
34126
- return _context17.a(2, addSignerOnPremise());
34224
+ return _context21.a(2, addSignerOnPremise());
34127
34225
  case 3:
34128
34226
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34129
34227
  case 4:
34130
- return _context17.a(2);
34228
+ return _context21.a(2);
34131
34229
  }
34132
- }, _callee17);
34230
+ }, _callee21);
34133
34231
  }));
34134
- return function addSigner(_x9) {
34135
- return _ref18.apply(this, arguments);
34232
+ return function addSigner(_x1) {
34233
+ return _ref22.apply(this, arguments);
34136
34234
  };
34137
34235
  }();
34138
34236
 
@@ -34143,33 +34241,33 @@ var addSigner = /*#__PURE__*/function () {
34143
34241
  * @throws {ApacuanaAPIError} Si los parámetros de paginación son inválidos, 'customerId' no está configurado, la llamada a la API falla, o el tipo de integración no es soportado.
34144
34242
  */
34145
34243
  var getDocs = /*#__PURE__*/function () {
34146
- var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(data) {
34244
+ var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(data) {
34147
34245
  var _getConfig6, integrationType;
34148
- return _regenerator().w(function (_context18) {
34149
- while (1) switch (_context18.n) {
34246
+ return _regenerator().w(function (_context22) {
34247
+ while (1) switch (_context22.n) {
34150
34248
  case 0:
34151
34249
  helpers.validateGetDocsData(data);
34152
34250
  _getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
34153
34251
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34154
- _context18.n = 1;
34252
+ _context22.n = 1;
34155
34253
  break;
34156
34254
  }
34157
- return _context18.a(2, getDocsOnBoarding(data));
34255
+ return _context22.a(2, getDocsOnBoarding(data));
34158
34256
  case 1:
34159
34257
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34160
- _context18.n = 2;
34258
+ _context22.n = 2;
34161
34259
  break;
34162
34260
  }
34163
- return _context18.a(2, getDocsOnPremise());
34261
+ return _context22.a(2, getDocsOnPremise());
34164
34262
  case 2:
34165
34263
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
34166
34264
  case 3:
34167
- return _context18.a(2);
34265
+ return _context22.a(2);
34168
34266
  }
34169
- }, _callee18);
34267
+ }, _callee22);
34170
34268
  }));
34171
- return function getDocs(_x0) {
34172
- return _ref19.apply(this, arguments);
34269
+ return function getDocs(_x10) {
34270
+ return _ref23.apply(this, arguments);
34173
34271
  };
34174
34272
  }();
34175
34273
 
@@ -34181,50 +34279,50 @@ var getDocs = /*#__PURE__*/function () {
34181
34279
  * @throws {ApacuanaAPIError} Si los datos son inválidos o la llamada a la API falla.
34182
34280
  */
34183
34281
  var uploadSignatureVariant = /*#__PURE__*/function () {
34184
- var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(data) {
34282
+ var _ref24 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(data) {
34185
34283
  var _getConfig7, integrationType;
34186
- return _regenerator().w(function (_context19) {
34187
- while (1) switch (_context19.n) {
34284
+ return _regenerator().w(function (_context23) {
34285
+ while (1) switch (_context23.n) {
34188
34286
  case 0:
34189
34287
  if (!(!data || !data.file)) {
34190
- _context19.n = 1;
34288
+ _context23.n = 1;
34191
34289
  break;
34192
34290
  }
34193
34291
  throw new ApacuanaAPIError("El parámetro 'file' es requerido.", 400, "INVALID_PARAMETER");
34194
34292
  case 1:
34195
34293
  if (!(typeof File === "undefined" || !(data.file instanceof File))) {
34196
- _context19.n = 2;
34294
+ _context23.n = 2;
34197
34295
  break;
34198
34296
  }
34199
34297
  throw new ApacuanaAPIError("El parámetro 'file' debe ser una instancia de 'File'.", 400, "INVALID_PARAMETER");
34200
34298
  case 2:
34201
34299
  if (!(data.file.type !== "image/png")) {
34202
- _context19.n = 3;
34300
+ _context23.n = 3;
34203
34301
  break;
34204
34302
  }
34205
34303
  throw new ApacuanaAPIError("El archivo debe ser de tipo PNG (image/png).", 400, "INVALID_PARAMETER");
34206
34304
  case 3:
34207
34305
  _getConfig7 = getConfig(), integrationType = _getConfig7.integrationType;
34208
34306
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34209
- _context19.n = 4;
34307
+ _context23.n = 4;
34210
34308
  break;
34211
34309
  }
34212
- return _context19.a(2, uploadSignatureVariantOnBoarding(data));
34310
+ return _context23.a(2, uploadSignatureVariantOnBoarding(data));
34213
34311
  case 4:
34214
34312
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34215
- _context19.n = 5;
34313
+ _context23.n = 5;
34216
34314
  break;
34217
34315
  }
34218
- return _context19.a(2, uploadSignatureVariantOnPremise());
34316
+ return _context23.a(2, uploadSignatureVariantOnPremise());
34219
34317
  case 5:
34220
34318
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34221
34319
  case 6:
34222
- return _context19.a(2);
34320
+ return _context23.a(2);
34223
34321
  }
34224
- }, _callee19);
34322
+ }, _callee23);
34225
34323
  }));
34226
- return function uploadSignatureVariant(_x1) {
34227
- return _ref20.apply(this, arguments);
34324
+ return function uploadSignatureVariant(_x11) {
34325
+ return _ref24.apply(this, arguments);
34228
34326
  };
34229
34327
  }();
34230
34328
 
@@ -34234,32 +34332,32 @@ var uploadSignatureVariant = /*#__PURE__*/function () {
34234
34332
  * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34235
34333
  */
34236
34334
  var getSignatureVariant = /*#__PURE__*/function () {
34237
- var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
34335
+ var _ref25 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
34238
34336
  var _getConfig8, integrationType;
34239
- return _regenerator().w(function (_context20) {
34240
- while (1) switch (_context20.n) {
34337
+ return _regenerator().w(function (_context24) {
34338
+ while (1) switch (_context24.n) {
34241
34339
  case 0:
34242
34340
  _getConfig8 = getConfig(), integrationType = _getConfig8.integrationType;
34243
34341
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34244
- _context20.n = 1;
34342
+ _context24.n = 1;
34245
34343
  break;
34246
34344
  }
34247
- return _context20.a(2, getSignatureVariantOnBoarding());
34345
+ return _context24.a(2, getSignatureVariantOnBoarding());
34248
34346
  case 1:
34249
34347
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34250
- _context20.n = 2;
34348
+ _context24.n = 2;
34251
34349
  break;
34252
34350
  }
34253
- return _context20.a(2, getSignatureVariantOnPremise());
34351
+ return _context24.a(2, getSignatureVariantOnPremise());
34254
34352
  case 2:
34255
34353
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34256
34354
  case 3:
34257
- return _context20.a(2);
34355
+ return _context24.a(2);
34258
34356
  }
34259
- }, _callee20);
34357
+ }, _callee24);
34260
34358
  }));
34261
34359
  return function getSignatureVariant() {
34262
- return _ref21.apply(this, arguments);
34360
+ return _ref25.apply(this, arguments);
34263
34361
  };
34264
34362
  }();
34265
34363
 
@@ -34269,32 +34367,32 @@ var getSignatureVariant = /*#__PURE__*/function () {
34269
34367
  * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34270
34368
  */
34271
34369
  var deleteSignatureVariant = /*#__PURE__*/function () {
34272
- var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
34370
+ var _ref26 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
34273
34371
  var _getConfig9, integrationType;
34274
- return _regenerator().w(function (_context21) {
34275
- while (1) switch (_context21.n) {
34372
+ return _regenerator().w(function (_context25) {
34373
+ while (1) switch (_context25.n) {
34276
34374
  case 0:
34277
34375
  _getConfig9 = getConfig(), integrationType = _getConfig9.integrationType;
34278
34376
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34279
- _context21.n = 1;
34377
+ _context25.n = 1;
34280
34378
  break;
34281
34379
  }
34282
- return _context21.a(2, deleteSignatureVariantOnBoarding());
34380
+ return _context25.a(2, deleteSignatureVariantOnBoarding());
34283
34381
  case 1:
34284
34382
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34285
- _context21.n = 2;
34383
+ _context25.n = 2;
34286
34384
  break;
34287
34385
  }
34288
- return _context21.a(2, deleteSignatureVariantOnPremise());
34386
+ return _context25.a(2, deleteSignatureVariantOnPremise());
34289
34387
  case 2:
34290
34388
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34291
34389
  case 3:
34292
- return _context21.a(2);
34390
+ return _context25.a(2);
34293
34391
  }
34294
- }, _callee21);
34392
+ }, _callee25);
34295
34393
  }));
34296
34394
  return function deleteSignatureVariant() {
34297
- return _ref22.apply(this, arguments);
34395
+ return _ref26.apply(this, arguments);
34298
34396
  };
34299
34397
  }();
34300
34398
 
@@ -34305,32 +34403,124 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
34305
34403
  * @throws {ApacuanaAPIError} Si los datos del signatario son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
34306
34404
  */
34307
34405
  var addMember = /*#__PURE__*/function () {
34308
- var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(memberData) {
34406
+ var _ref27 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(memberData) {
34309
34407
  var _getConfig0, integrationType;
34310
- return _regenerator().w(function (_context22) {
34311
- while (1) switch (_context22.n) {
34408
+ return _regenerator().w(function (_context26) {
34409
+ while (1) switch (_context26.n) {
34312
34410
  case 0:
34313
34411
  _getConfig0 = getConfig(), integrationType = _getConfig0.integrationType;
34314
34412
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34315
- _context22.n = 1;
34413
+ _context26.n = 1;
34316
34414
  break;
34317
34415
  }
34318
- return _context22.a(2, addMemberOnBoarding(memberData));
34416
+ return _context26.a(2, addMemberOnBoarding(memberData));
34319
34417
  case 1:
34320
34418
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34321
- _context22.n = 2;
34419
+ _context26.n = 2;
34322
34420
  break;
34323
34421
  }
34324
- return _context22.a(2, addMemberOnPremise());
34422
+ return _context26.a(2, addMemberOnPremise());
34325
34423
  case 2:
34326
34424
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34327
34425
  case 3:
34328
- return _context22.a(2);
34426
+ return _context26.a(2);
34329
34427
  }
34330
- }, _callee22);
34428
+ }, _callee26);
34331
34429
  }));
34332
- return function addMember(_x10) {
34333
- return _ref23.apply(this, arguments);
34430
+ return function addMember(_x12) {
34431
+ return _ref27.apply(this, arguments);
34432
+ };
34433
+ }();
34434
+
34435
+ /**
34436
+ * Crea un nuevo documento para ser firmado.
34437
+ * @param {object} documentData - Datos del documento a crear.
34438
+ * @param {string} documentData.name - Nombre del documento.
34439
+ * @param {string} documentData.reference - Referencia del documento.
34440
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con `{ msg, id }` del documento creado.
34441
+ * @throws {ApacuanaAPIError} Si los datos son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
34442
+ */
34443
+ var createDocument = /*#__PURE__*/function () {
34444
+ var _ref28 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(documentData) {
34445
+ var _getConfig1, integrationType;
34446
+ return _regenerator().w(function (_context27) {
34447
+ while (1) switch (_context27.n) {
34448
+ case 0:
34449
+ if (!(!documentData || _typeof(documentData) !== "object" || Object.keys(documentData).length === 0)) {
34450
+ _context27.n = 1;
34451
+ break;
34452
+ }
34453
+ throw new ApacuanaAPIError("Document data (documentData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
34454
+ case 1:
34455
+ if (!(!documentData.name || !documentData.reference)) {
34456
+ _context27.n = 2;
34457
+ break;
34458
+ }
34459
+ throw new ApacuanaAPIError("Fields 'name' and 'reference' are required.", 400, "INVALID_PARAMETER");
34460
+ case 2:
34461
+ _getConfig1 = getConfig(), integrationType = _getConfig1.integrationType;
34462
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34463
+ _context27.n = 3;
34464
+ break;
34465
+ }
34466
+ return _context27.a(2, createDocumentOnBoarding(documentData));
34467
+ case 3:
34468
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34469
+ _context27.n = 4;
34470
+ break;
34471
+ }
34472
+ return _context27.a(2, createDocumentOnPremise());
34473
+ case 4:
34474
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34475
+ case 5:
34476
+ return _context27.a(2);
34477
+ }
34478
+ }, _callee27);
34479
+ }));
34480
+ return function createDocument(_x13) {
34481
+ return _ref28.apply(this, arguments);
34482
+ };
34483
+ }();
34484
+
34485
+ /**
34486
+ * Bloquea un documento para evitar modificaciones.
34487
+ * @param {string} documentId - ID (UUID) del documento a bloquear.
34488
+ * @returns {Promise<object>} Una promesa que resuelve al response de la API.
34489
+ * @throws {ApacuanaAPIError} Si el documentId es inválido, la llamada a la API falla, o el tipo de integración no es soportado.
34490
+ */
34491
+ var lockDocument = /*#__PURE__*/function () {
34492
+ var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(documentId) {
34493
+ var _getConfig10, integrationType;
34494
+ return _regenerator().w(function (_context28) {
34495
+ while (1) switch (_context28.n) {
34496
+ case 0:
34497
+ if (!(!documentId || typeof documentId !== "string")) {
34498
+ _context28.n = 1;
34499
+ break;
34500
+ }
34501
+ throw new ApacuanaAPIError("Field 'documentId' is required and must be a string.", 400, "INVALID_PARAMETER");
34502
+ case 1:
34503
+ _getConfig10 = getConfig(), integrationType = _getConfig10.integrationType;
34504
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34505
+ _context28.n = 2;
34506
+ break;
34507
+ }
34508
+ return _context28.a(2, lockDocumentOnBoarding(documentId));
34509
+ case 2:
34510
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34511
+ _context28.n = 3;
34512
+ break;
34513
+ }
34514
+ return _context28.a(2, lockDocumentOnPremise());
34515
+ case 3:
34516
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34517
+ case 4:
34518
+ return _context28.a(2);
34519
+ }
34520
+ }, _callee28);
34521
+ }));
34522
+ return function lockDocument(_x14) {
34523
+ return _ref29.apply(this, arguments);
34334
34524
  };
34335
34525
  }();
34336
34526
 
@@ -34576,6 +34766,14 @@ var apacuana = {
34576
34766
  checkSdk(true);
34577
34767
  return sendFaceLiveness(data);
34578
34768
  },
34769
+ createDocument: function createDocument$1(data) {
34770
+ checkSdk(false);
34771
+ return createDocument(data);
34772
+ },
34773
+ lockDocument: function lockDocument$1(documentId) {
34774
+ checkSdk(false);
34775
+ return lockDocument(documentId);
34776
+ },
34579
34777
  close: function close$1() {
34580
34778
  return close();
34581
34779
  },