apacuana-sdk-core 1.26.0 → 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 +192 -147
  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 +413 -11
  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 +343 -253
  25. package/dist/api/signatures.d.ts +5 -0
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +290 -93
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +290 -93
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/src/api/signatures.js +136 -2
  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
@@ -33969,12 +33969,11 @@ var addMemberOnBoarding = /*#__PURE__*/function () {
33969
33969
  return _regenerator().w(function (_context13) {
33970
33970
  while (1) switch (_context13.p = _context13.n) {
33971
33971
  case 0:
33972
- payload = helpers.validateAddMemberData(memberData); // Transform documentId to docid for API compatibility
33972
+ payload = helpers.validateAddMemberData(memberData);
33973
33973
  apiPayload = {
33974
33974
  docid: payload.documentId,
33975
33975
  kinddoc: payload.typedoc,
33976
- doc: payload.doc,
33977
- signature: payload.signature
33976
+ doc: payload.doc
33978
33977
  };
33979
33978
  _context13.p = 1;
33980
33979
  _context13.n = 2;
@@ -34016,6 +34015,104 @@ var addMemberOnPremise = /*#__PURE__*/function () {
34016
34015
  return _ref15.apply(this, arguments);
34017
34016
  };
34018
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
+ }();
34019
34116
 
34020
34117
  // =================================================================
34021
34118
  // Exported Functions
@@ -34029,32 +34126,32 @@ var addMemberOnPremise = /*#__PURE__*/function () {
34029
34126
  * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
34030
34127
  */
34031
34128
  var signDocument = /*#__PURE__*/function () {
34032
- var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signData) {
34129
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(signData) {
34033
34130
  var _getConfig3, integrationType;
34034
- return _regenerator().w(function (_context15) {
34035
- while (1) switch (_context15.n) {
34131
+ return _regenerator().w(function (_context19) {
34132
+ while (1) switch (_context19.n) {
34036
34133
  case 0:
34037
34134
  _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
34038
34135
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34039
- _context15.n = 1;
34136
+ _context19.n = 1;
34040
34137
  break;
34041
34138
  }
34042
- return _context15.a(2, signDocumentOnBoarding(signData));
34139
+ return _context19.a(2, signDocumentOnBoarding(signData));
34043
34140
  case 1:
34044
34141
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34045
- _context15.n = 2;
34142
+ _context19.n = 2;
34046
34143
  break;
34047
34144
  }
34048
- return _context15.a(2, signDocumentOnPremise());
34145
+ return _context19.a(2, signDocumentOnPremise());
34049
34146
  case 2:
34050
34147
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34051
34148
  case 3:
34052
- return _context15.a(2);
34149
+ return _context19.a(2);
34053
34150
  }
34054
- }, _callee15);
34151
+ }, _callee19);
34055
34152
  }));
34056
- return function signDocument(_x7) {
34057
- return _ref16.apply(this, arguments);
34153
+ return function signDocument(_x9) {
34154
+ return _ref20.apply(this, arguments);
34058
34155
  };
34059
34156
  }();
34060
34157
 
@@ -34065,33 +34162,33 @@ var signDocument = /*#__PURE__*/function () {
34065
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.
34066
34163
  */
34067
34164
  var getDigest = /*#__PURE__*/function () {
34068
- var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(signData) {
34165
+ var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(signData) {
34069
34166
  var _getConfig4, integrationType;
34070
- return _regenerator().w(function (_context16) {
34071
- while (1) switch (_context16.n) {
34167
+ return _regenerator().w(function (_context20) {
34168
+ while (1) switch (_context20.n) {
34072
34169
  case 0:
34073
34170
  helpers.validateGetDigestData(signData);
34074
34171
  _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
34075
34172
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34076
- _context16.n = 1;
34173
+ _context20.n = 1;
34077
34174
  break;
34078
34175
  }
34079
- return _context16.a(2, getDigestToSignOnBoarding(signData));
34176
+ return _context20.a(2, getDigestToSignOnBoarding(signData));
34080
34177
  case 1:
34081
34178
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34082
- _context16.n = 2;
34179
+ _context20.n = 2;
34083
34180
  break;
34084
34181
  }
34085
- return _context16.a(2, getDigestToSignOnPremise());
34182
+ return _context20.a(2, getDigestToSignOnPremise());
34086
34183
  case 2:
34087
34184
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
34088
34185
  case 3:
34089
- return _context16.a(2);
34186
+ return _context20.a(2);
34090
34187
  }
34091
- }, _callee16);
34188
+ }, _callee20);
34092
34189
  }));
34093
- return function getDigest(_x8) {
34094
- return _ref17.apply(this, arguments);
34190
+ return function getDigest(_x0) {
34191
+ return _ref21.apply(this, arguments);
34095
34192
  };
34096
34193
  }();
34097
34194
 
@@ -34102,38 +34199,38 @@ var getDigest = /*#__PURE__*/function () {
34102
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.
34103
34200
  */
34104
34201
  var addSigner = /*#__PURE__*/function () {
34105
- var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(signerData) {
34202
+ var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(signerData) {
34106
34203
  var _getConfig5, integrationType;
34107
- return _regenerator().w(function (_context17) {
34108
- while (1) switch (_context17.n) {
34204
+ return _regenerator().w(function (_context21) {
34205
+ while (1) switch (_context21.n) {
34109
34206
  case 0:
34110
34207
  if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
34111
- _context17.n = 1;
34208
+ _context21.n = 1;
34112
34209
  break;
34113
34210
  }
34114
34211
  throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
34115
34212
  case 1:
34116
34213
  _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
34117
34214
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34118
- _context17.n = 2;
34215
+ _context21.n = 2;
34119
34216
  break;
34120
34217
  }
34121
- return _context17.a(2, addSignerOnBoarding(signerData));
34218
+ return _context21.a(2, addSignerOnBoarding(signerData));
34122
34219
  case 2:
34123
34220
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34124
- _context17.n = 3;
34221
+ _context21.n = 3;
34125
34222
  break;
34126
34223
  }
34127
- return _context17.a(2, addSignerOnPremise());
34224
+ return _context21.a(2, addSignerOnPremise());
34128
34225
  case 3:
34129
34226
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34130
34227
  case 4:
34131
- return _context17.a(2);
34228
+ return _context21.a(2);
34132
34229
  }
34133
- }, _callee17);
34230
+ }, _callee21);
34134
34231
  }));
34135
- return function addSigner(_x9) {
34136
- return _ref18.apply(this, arguments);
34232
+ return function addSigner(_x1) {
34233
+ return _ref22.apply(this, arguments);
34137
34234
  };
34138
34235
  }();
34139
34236
 
@@ -34144,33 +34241,33 @@ var addSigner = /*#__PURE__*/function () {
34144
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.
34145
34242
  */
34146
34243
  var getDocs = /*#__PURE__*/function () {
34147
- var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(data) {
34244
+ var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(data) {
34148
34245
  var _getConfig6, integrationType;
34149
- return _regenerator().w(function (_context18) {
34150
- while (1) switch (_context18.n) {
34246
+ return _regenerator().w(function (_context22) {
34247
+ while (1) switch (_context22.n) {
34151
34248
  case 0:
34152
34249
  helpers.validateGetDocsData(data);
34153
34250
  _getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
34154
34251
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34155
- _context18.n = 1;
34252
+ _context22.n = 1;
34156
34253
  break;
34157
34254
  }
34158
- return _context18.a(2, getDocsOnBoarding(data));
34255
+ return _context22.a(2, getDocsOnBoarding(data));
34159
34256
  case 1:
34160
34257
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34161
- _context18.n = 2;
34258
+ _context22.n = 2;
34162
34259
  break;
34163
34260
  }
34164
- return _context18.a(2, getDocsOnPremise());
34261
+ return _context22.a(2, getDocsOnPremise());
34165
34262
  case 2:
34166
34263
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
34167
34264
  case 3:
34168
- return _context18.a(2);
34265
+ return _context22.a(2);
34169
34266
  }
34170
- }, _callee18);
34267
+ }, _callee22);
34171
34268
  }));
34172
- return function getDocs(_x0) {
34173
- return _ref19.apply(this, arguments);
34269
+ return function getDocs(_x10) {
34270
+ return _ref23.apply(this, arguments);
34174
34271
  };
34175
34272
  }();
34176
34273
 
@@ -34182,50 +34279,50 @@ var getDocs = /*#__PURE__*/function () {
34182
34279
  * @throws {ApacuanaAPIError} Si los datos son inválidos o la llamada a la API falla.
34183
34280
  */
34184
34281
  var uploadSignatureVariant = /*#__PURE__*/function () {
34185
- var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(data) {
34282
+ var _ref24 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(data) {
34186
34283
  var _getConfig7, integrationType;
34187
- return _regenerator().w(function (_context19) {
34188
- while (1) switch (_context19.n) {
34284
+ return _regenerator().w(function (_context23) {
34285
+ while (1) switch (_context23.n) {
34189
34286
  case 0:
34190
34287
  if (!(!data || !data.file)) {
34191
- _context19.n = 1;
34288
+ _context23.n = 1;
34192
34289
  break;
34193
34290
  }
34194
34291
  throw new ApacuanaAPIError("El parámetro 'file' es requerido.", 400, "INVALID_PARAMETER");
34195
34292
  case 1:
34196
34293
  if (!(typeof File === "undefined" || !(data.file instanceof File))) {
34197
- _context19.n = 2;
34294
+ _context23.n = 2;
34198
34295
  break;
34199
34296
  }
34200
34297
  throw new ApacuanaAPIError("El parámetro 'file' debe ser una instancia de 'File'.", 400, "INVALID_PARAMETER");
34201
34298
  case 2:
34202
34299
  if (!(data.file.type !== "image/png")) {
34203
- _context19.n = 3;
34300
+ _context23.n = 3;
34204
34301
  break;
34205
34302
  }
34206
34303
  throw new ApacuanaAPIError("El archivo debe ser de tipo PNG (image/png).", 400, "INVALID_PARAMETER");
34207
34304
  case 3:
34208
34305
  _getConfig7 = getConfig(), integrationType = _getConfig7.integrationType;
34209
34306
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34210
- _context19.n = 4;
34307
+ _context23.n = 4;
34211
34308
  break;
34212
34309
  }
34213
- return _context19.a(2, uploadSignatureVariantOnBoarding(data));
34310
+ return _context23.a(2, uploadSignatureVariantOnBoarding(data));
34214
34311
  case 4:
34215
34312
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34216
- _context19.n = 5;
34313
+ _context23.n = 5;
34217
34314
  break;
34218
34315
  }
34219
- return _context19.a(2, uploadSignatureVariantOnPremise());
34316
+ return _context23.a(2, uploadSignatureVariantOnPremise());
34220
34317
  case 5:
34221
34318
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34222
34319
  case 6:
34223
- return _context19.a(2);
34320
+ return _context23.a(2);
34224
34321
  }
34225
- }, _callee19);
34322
+ }, _callee23);
34226
34323
  }));
34227
- return function uploadSignatureVariant(_x1) {
34228
- return _ref20.apply(this, arguments);
34324
+ return function uploadSignatureVariant(_x11) {
34325
+ return _ref24.apply(this, arguments);
34229
34326
  };
34230
34327
  }();
34231
34328
 
@@ -34235,32 +34332,32 @@ var uploadSignatureVariant = /*#__PURE__*/function () {
34235
34332
  * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34236
34333
  */
34237
34334
  var getSignatureVariant = /*#__PURE__*/function () {
34238
- var _ref21 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20() {
34335
+ var _ref25 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24() {
34239
34336
  var _getConfig8, integrationType;
34240
- return _regenerator().w(function (_context20) {
34241
- while (1) switch (_context20.n) {
34337
+ return _regenerator().w(function (_context24) {
34338
+ while (1) switch (_context24.n) {
34242
34339
  case 0:
34243
34340
  _getConfig8 = getConfig(), integrationType = _getConfig8.integrationType;
34244
34341
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34245
- _context20.n = 1;
34342
+ _context24.n = 1;
34246
34343
  break;
34247
34344
  }
34248
- return _context20.a(2, getSignatureVariantOnBoarding());
34345
+ return _context24.a(2, getSignatureVariantOnBoarding());
34249
34346
  case 1:
34250
34347
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34251
- _context20.n = 2;
34348
+ _context24.n = 2;
34252
34349
  break;
34253
34350
  }
34254
- return _context20.a(2, getSignatureVariantOnPremise());
34351
+ return _context24.a(2, getSignatureVariantOnPremise());
34255
34352
  case 2:
34256
34353
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34257
34354
  case 3:
34258
- return _context20.a(2);
34355
+ return _context24.a(2);
34259
34356
  }
34260
- }, _callee20);
34357
+ }, _callee24);
34261
34358
  }));
34262
34359
  return function getSignatureVariant() {
34263
- return _ref21.apply(this, arguments);
34360
+ return _ref25.apply(this, arguments);
34264
34361
  };
34265
34362
  }();
34266
34363
 
@@ -34270,32 +34367,32 @@ var getSignatureVariant = /*#__PURE__*/function () {
34270
34367
  * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34271
34368
  */
34272
34369
  var deleteSignatureVariant = /*#__PURE__*/function () {
34273
- var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21() {
34370
+ var _ref26 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25() {
34274
34371
  var _getConfig9, integrationType;
34275
- return _regenerator().w(function (_context21) {
34276
- while (1) switch (_context21.n) {
34372
+ return _regenerator().w(function (_context25) {
34373
+ while (1) switch (_context25.n) {
34277
34374
  case 0:
34278
34375
  _getConfig9 = getConfig(), integrationType = _getConfig9.integrationType;
34279
34376
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34280
- _context21.n = 1;
34377
+ _context25.n = 1;
34281
34378
  break;
34282
34379
  }
34283
- return _context21.a(2, deleteSignatureVariantOnBoarding());
34380
+ return _context25.a(2, deleteSignatureVariantOnBoarding());
34284
34381
  case 1:
34285
34382
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34286
- _context21.n = 2;
34383
+ _context25.n = 2;
34287
34384
  break;
34288
34385
  }
34289
- return _context21.a(2, deleteSignatureVariantOnPremise());
34386
+ return _context25.a(2, deleteSignatureVariantOnPremise());
34290
34387
  case 2:
34291
34388
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34292
34389
  case 3:
34293
- return _context21.a(2);
34390
+ return _context25.a(2);
34294
34391
  }
34295
- }, _callee21);
34392
+ }, _callee25);
34296
34393
  }));
34297
34394
  return function deleteSignatureVariant() {
34298
- return _ref22.apply(this, arguments);
34395
+ return _ref26.apply(this, arguments);
34299
34396
  };
34300
34397
  }();
34301
34398
 
@@ -34306,32 +34403,124 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
34306
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.
34307
34404
  */
34308
34405
  var addMember = /*#__PURE__*/function () {
34309
- var _ref23 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(memberData) {
34406
+ var _ref27 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(memberData) {
34310
34407
  var _getConfig0, integrationType;
34311
- return _regenerator().w(function (_context22) {
34312
- while (1) switch (_context22.n) {
34408
+ return _regenerator().w(function (_context26) {
34409
+ while (1) switch (_context26.n) {
34313
34410
  case 0:
34314
34411
  _getConfig0 = getConfig(), integrationType = _getConfig0.integrationType;
34315
34412
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34316
- _context22.n = 1;
34413
+ _context26.n = 1;
34317
34414
  break;
34318
34415
  }
34319
- return _context22.a(2, addMemberOnBoarding(memberData));
34416
+ return _context26.a(2, addMemberOnBoarding(memberData));
34320
34417
  case 1:
34321
34418
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34322
- _context22.n = 2;
34419
+ _context26.n = 2;
34323
34420
  break;
34324
34421
  }
34325
- return _context22.a(2, addMemberOnPremise());
34422
+ return _context26.a(2, addMemberOnPremise());
34326
34423
  case 2:
34327
34424
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34328
34425
  case 3:
34329
- return _context22.a(2);
34426
+ return _context26.a(2);
34330
34427
  }
34331
- }, _callee22);
34428
+ }, _callee26);
34332
34429
  }));
34333
- return function addMember(_x10) {
34334
- 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);
34335
34524
  };
34336
34525
  }();
34337
34526
 
@@ -34577,6 +34766,14 @@ var apacuana = {
34577
34766
  checkSdk(true);
34578
34767
  return sendFaceLiveness(data);
34579
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
+ },
34580
34777
  close: function close$1() {
34581
34778
  return close();
34582
34779
  },