apacuana-sdk-core 0.6.0 → 0.6.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/README.md +38 -0
  2. package/babel.config.cjs +11 -0
  3. package/coverage/clover.xml +76 -88
  4. package/coverage/coverage-final.json +4 -4
  5. package/coverage/lcov-report/api/index.html +131 -0
  6. package/coverage/lcov-report/api/signatures.js.html +1093 -0
  7. package/coverage/lcov-report/api/users.js.html +292 -0
  8. package/coverage/lcov-report/config/index.html +116 -0
  9. package/coverage/lcov-report/config/index.js.html +208 -0
  10. package/coverage/lcov-report/errors/index.html +116 -0
  11. package/coverage/lcov-report/errors/index.js.html +148 -0
  12. package/coverage/lcov-report/index.html +22 -22
  13. package/coverage/lcov-report/src/api/certs.js.html +30 -36
  14. package/coverage/lcov-report/src/api/index.html +15 -15
  15. package/coverage/lcov-report/src/api/revocations.js.html +1 -1
  16. package/coverage/lcov-report/src/api/signatures.js.html +1 -1
  17. package/coverage/lcov-report/src/api/users.js.html +1 -1
  18. package/coverage/lcov-report/src/config/index.html +1 -1
  19. package/coverage/lcov-report/src/config/index.js.html +1 -1
  20. package/coverage/lcov-report/src/errors/index.html +1 -1
  21. package/coverage/lcov-report/src/errors/index.js.html +8 -8
  22. package/coverage/lcov-report/src/index.html +1 -1
  23. package/coverage/lcov-report/src/index.js.html +1 -1
  24. package/coverage/lcov-report/src/utils/constant.js.html +1 -1
  25. package/coverage/lcov-report/src/utils/helpers.js.html +18 -51
  26. package/coverage/lcov-report/src/utils/httpClient.js.html +6 -72
  27. package/coverage/lcov-report/src/utils/index.html +19 -19
  28. package/coverage/lcov-report/utils/constant.js.html +145 -0
  29. package/coverage/lcov-report/utils/httpClient.js.html +646 -0
  30. package/coverage/lcov-report/utils/index.html +131 -0
  31. package/coverage/lcov.info +151 -162
  32. package/dist/api/certs.d.ts +1 -1
  33. package/dist/index.js +281 -220
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +281 -220
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/utils/helpers.d.ts +1 -1
  38. package/jest.config.cjs +6 -1
  39. package/package.json +12 -7
  40. package/rollup.config.js +1 -1
  41. package/src/api/certs.js +7 -9
  42. package/src/utils/helpers.js +11 -22
  43. package/src/utils/httpClient.js +0 -22
  44. package/tests/api/certs.test.js +30 -48
  45. package/tsconfig.json +2 -1
  46. package/.babelrc +0 -3
package/README.md CHANGED
@@ -444,3 +444,41 @@ El SDK implementa las siguientes medidas de seguridad:
444
444
  ## Licencia
445
445
 
446
446
  Este SDK está licenciado bajo términos propietarios. Consulte el acuerdo de licencia para más detalles.
447
+
448
+ #### `generateCert(encryptedCSR)`
449
+
450
+ Genera un nuevo certificado para un usuario ya existente.
451
+
452
+ - **Parámetros:**
453
+ - `encryptedCSR` (Object): Un objeto que contiene la Solicitud de Firma de Certificado (CSR) encriptada. Este objeto debe tener la siguiente estructura:
454
+ ```json
455
+ {
456
+ "csr": "string"
457
+ }
458
+ ```
459
+ Donde el valor de `csr` es la cadena de texto resultante de la encriptación.
460
+
461
+ - **Retorna:** `Promise<Object>`
462
+ - `Promise<GenerateCertResponse>` que se resuelve con un objeto que contiene:
463
+ - `cert` (String): El certificado generado.
464
+ - `success` (Boolean): Indicador de éxito de la operación.
465
+
466
+ **Ejemplo:**
467
+
468
+ ```javascript
469
+ // Asumiendo que 'myBase64Csr' es una variable que contiene tu CSR en formato Base64
470
+ const myBase64Csr = "MIIC...==";
471
+
472
+ try {
473
+ const { cert, success } = await apacuana.generateCert(myBase64Csr);
474
+ if (success) {
475
+ console.log("Certificado generado exitosamente:", cert);
476
+ }
477
+ } catch (error) {
478
+ if (error.name === "ApacuanaAPIError") {
479
+ console.error(`Error de API (${error.code}):`, error.message);
480
+ } else {
481
+ console.error("Ocurrió un error inesperado:", error);
482
+ }
483
+ }
484
+ ```
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ presets: [
3
+ '@babel/preset-env',
4
+ '@babel/preset-flow'
5
+ ],
6
+ plugins: [
7
+ ['@babel/plugin-transform-class-properties', { loose: true }],
8
+ ['@babel/plugin-transform-private-methods', { loose: true }],
9
+ ['@babel/plugin-transform-private-property-in-object', { loose: true }]
10
+ ]
11
+ };
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1756163918389" clover="3.2.0">
3
- <project timestamp="1756163918389" name="All files">
4
- <metrics statements="289" coveredstatements="120" conditionals="230" coveredconditionals="38" methods="38" coveredmethods="13" elements="557" coveredelements="171" complexity="0" loc="289" ncloc="289" packages="5" files="10" classes="10"/>
2
+ <coverage generated="1756239717215" clover="3.2.0">
3
+ <project timestamp="1756239717215" name="All files">
4
+ <metrics statements="277" coveredstatements="115" conditionals="231" coveredconditionals="37" methods="38" coveredmethods="13" elements="546" coveredelements="165" complexity="0" loc="277" ncloc="277" packages="5" files="10" classes="10"/>
5
5
  <package name="src">
6
6
  <metrics statements="15" coveredstatements="14" conditionals="2" coveredconditionals="1" methods="1" coveredmethods="1"/>
7
7
  <file name="index.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/index.js">
@@ -24,34 +24,33 @@
24
24
  </file>
25
25
  </package>
26
26
  <package name="src.api">
27
- <metrics statements="133" coveredstatements="81" conditionals="70" coveredconditionals="34" methods="19" coveredmethods="11"/>
27
+ <metrics statements="132" coveredstatements="76" conditionals="72" coveredconditionals="33" methods="19" coveredmethods="11"/>
28
28
  <file name="certs.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/api/certs.js">
29
- <metrics statements="25" coveredstatements="25" conditionals="11" coveredconditionals="8" methods="4" coveredmethods="4"/>
29
+ <metrics statements="24" coveredstatements="20" conditionals="13" coveredconditionals="7" methods="4" coveredmethods="4"/>
30
30
  <line num="19" count="2" type="cond" truecount="0" falsecount="1"/>
31
- <line num="20" count="4" type="stmt"/>
32
- <line num="21" count="4" type="stmt"/>
33
- <line num="23" count="4" type="stmt"/>
34
- <line num="28" count="2" type="stmt"/>
35
- <line num="29" count="2" type="cond" truecount="2" falsecount="0"/>
36
- <line num="30" count="1" type="stmt"/>
37
- <line num="37" count="1" type="stmt"/>
38
- <line num="40" count="3" type="cond" truecount="2" falsecount="0"/>
39
- <line num="41" count="2" type="stmt"/>
40
- <line num="43" count="1" type="stmt"/>
41
- <line num="47" count="2" type="stmt"/>
42
- <line num="48" count="1" type="stmt"/>
43
- <line num="62" count="2" type="cond" truecount="0" falsecount="1"/>
44
- <line num="63" count="6" type="stmt"/>
45
- <line num="64" count="6" type="stmt"/>
46
- <line num="65" count="6" type="cond" truecount="2" falsecount="0"/>
47
- <line num="66" count="4" type="stmt"/>
48
- <line num="68" count="2" type="cond" truecount="2" falsecount="0"/>
49
- <line num="69" count="1" type="stmt"/>
50
- <line num="72" count="1" type="stmt"/>
51
- <line num="84" count="2" type="cond" truecount="0" falsecount="1"/>
52
- <line num="85" count="1" type="stmt"/>
53
- <line num="86" count="1" type="stmt"/>
54
- <line num="90" count="1" type="stmt"/>
31
+ <line num="20" count="1" type="stmt"/>
32
+ <line num="21" count="1" type="stmt"/>
33
+ <line num="26" count="1" type="stmt"/>
34
+ <line num="27" count="1" type="cond" truecount="3" falsecount="1"/>
35
+ <line num="28" count="0" type="stmt"/>
36
+ <line num="35" count="1" type="stmt"/>
37
+ <line num="38" count="0" type="cond" truecount="0" falsecount="2"/>
38
+ <line num="39" count="0" type="stmt"/>
39
+ <line num="41" count="0" type="stmt"/>
40
+ <line num="45" count="2" type="stmt"/>
41
+ <line num="46" count="1" type="stmt"/>
42
+ <line num="60" count="2" type="cond" truecount="0" falsecount="1"/>
43
+ <line num="61" count="3" type="stmt"/>
44
+ <line num="62" count="3" type="stmt"/>
45
+ <line num="63" count="3" type="cond" truecount="2" falsecount="0"/>
46
+ <line num="64" count="1" type="stmt"/>
47
+ <line num="66" count="2" type="cond" truecount="2" falsecount="0"/>
48
+ <line num="67" count="1" type="stmt"/>
49
+ <line num="70" count="1" type="stmt"/>
50
+ <line num="82" count="2" type="cond" truecount="0" falsecount="1"/>
51
+ <line num="83" count="1" type="stmt"/>
52
+ <line num="84" count="1" type="stmt"/>
53
+ <line num="88" count="1" type="stmt"/>
55
54
  </file>
56
55
  <file name="revocations.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/api/revocations.js">
57
56
  <metrics statements="12" coveredstatements="1" conditionals="8" coveredconditionals="0" methods="1" coveredmethods="0"/>
@@ -191,17 +190,17 @@
191
190
  <metrics statements="7" coveredstatements="7" conditionals="4" coveredconditionals="3" methods="1" coveredmethods="1"/>
192
191
  <file name="index.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/errors/index.js">
193
192
  <metrics statements="7" coveredstatements="7" conditionals="4" coveredconditionals="3" methods="1" coveredmethods="1"/>
194
- <line num="8" count="21" type="stmt"/>
195
- <line num="9" count="21" type="stmt"/>
196
- <line num="10" count="21" type="stmt"/>
197
- <line num="11" count="21" type="stmt"/>
198
- <line num="12" count="21" type="stmt"/>
199
- <line num="15" count="21" type="cond" truecount="1" falsecount="1"/>
200
- <line num="16" count="21" type="stmt"/>
193
+ <line num="8" count="19" type="stmt"/>
194
+ <line num="9" count="19" type="stmt"/>
195
+ <line num="10" count="19" type="stmt"/>
196
+ <line num="11" count="19" type="stmt"/>
197
+ <line num="12" count="19" type="stmt"/>
198
+ <line num="15" count="19" type="cond" truecount="1" falsecount="1"/>
199
+ <line num="16" count="19" type="stmt"/>
201
200
  </file>
202
201
  </package>
203
202
  <package name="src.utils">
204
- <metrics statements="124" coveredstatements="15" conditionals="145" coveredconditionals="0" methods="15" coveredmethods="0"/>
203
+ <metrics statements="113" coveredstatements="15" conditionals="144" coveredconditionals="0" methods="15" coveredmethods="0"/>
205
204
  <file name="constant.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/utils/constant.js">
206
205
  <metrics statements="3" coveredstatements="3" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0"/>
207
206
  <line num="1" count="6" type="stmt"/>
@@ -209,7 +208,7 @@
209
208
  <line num="17" count="6" type="stmt"/>
210
209
  </file>
211
210
  <file name="helpers.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/utils/helpers.js">
212
- <metrics statements="75" coveredstatements="9" conditionals="105" coveredconditionals="0" methods="10" coveredmethods="0"/>
211
+ <metrics statements="70" coveredstatements="9" conditionals="104" coveredconditionals="0" methods="10" coveredmethods="0"/>
213
212
  <line num="6" count="2" type="stmt"/>
214
213
  <line num="8" count="2" type="stmt"/>
215
214
  <line num="9" count="0" type="cond" truecount="0" falsecount="2"/>
@@ -258,36 +257,31 @@
258
257
  <line num="134" count="0" type="cond" truecount="0" falsecount="5"/>
259
258
  <line num="135" count="0" type="stmt"/>
260
259
  <line num="146" count="2" type="stmt"/>
261
- <line num="147" count="0" type="stmt"/>
262
- <line num="149" count="0" type="cond" truecount="0" falsecount="2"/>
263
- <line num="150" count="0" type="stmt"/>
264
- <line num="157" count="0" type="cond" truecount="0" falsecount="4"/>
265
- <line num="158" count="0" type="stmt"/>
266
- <line num="165" count="0" type="cond" truecount="0" falsecount="2"/>
267
- <line num="166" count="0" type="stmt"/>
268
- <line num="174" count="2" type="stmt"/>
269
- <line num="175" count="0" type="cond" truecount="0" falsecount="2"/>
260
+ <line num="147" count="0" type="cond" truecount="0" falsecount="2"/>
261
+ <line num="154" count="0" type="stmt"/>
262
+ <line num="163" count="2" type="stmt"/>
263
+ <line num="164" count="0" type="cond" truecount="0" falsecount="2"/>
264
+ <line num="169" count="0" type="stmt"/>
265
+ <line num="176" count="0" type="cond" truecount="0" falsecount="2"/>
270
266
  <line num="180" count="0" type="stmt"/>
271
- <line num="187" count="0" type="cond" truecount="0" falsecount="2"/>
272
- <line num="191" count="0" type="stmt"/>
273
- <line num="199" count="2" type="stmt"/>
274
- <line num="200" count="0" type="cond" truecount="0" falsecount="2"/>
275
- <line num="207" count="0" type="stmt"/>
276
- <line num="215" count="2" type="stmt"/>
277
- <line num="216" count="0" type="cond" truecount="0" falsecount="4"/>
278
- <line num="217" count="0" type="stmt"/>
267
+ <line num="188" count="2" type="stmt"/>
268
+ <line num="189" count="0" type="cond" truecount="0" falsecount="2"/>
269
+ <line num="196" count="0" type="stmt"/>
270
+ <line num="204" count="2" type="stmt"/>
271
+ <line num="205" count="0" type="cond" truecount="0" falsecount="4"/>
272
+ <line num="206" count="0" type="stmt"/>
273
+ <line num="213" count="0" type="stmt"/>
274
+ <line num="215" count="0" type="cond" truecount="0" falsecount="5"/>
275
+ <line num="216" count="0" type="stmt"/>
276
+ <line num="223" count="0" type="cond" truecount="0" falsecount="2"/>
279
277
  <line num="224" count="0" type="stmt"/>
280
- <line num="226" count="0" type="cond" truecount="0" falsecount="5"/>
281
- <line num="227" count="0" type="stmt"/>
282
- <line num="234" count="0" type="cond" truecount="0" falsecount="2"/>
283
- <line num="235" count="0" type="stmt"/>
284
- <line num="242" count="0" type="cond" truecount="0" falsecount="4"/>
285
- <line num="243" count="0" type="stmt"/>
286
- <line num="250" count="0" type="cond" truecount="0" falsecount="4"/>
287
- <line num="251" count="0" type="stmt"/>
278
+ <line num="231" count="0" type="cond" truecount="0" falsecount="4"/>
279
+ <line num="232" count="0" type="stmt"/>
280
+ <line num="239" count="0" type="cond" truecount="0" falsecount="4"/>
281
+ <line num="240" count="0" type="stmt"/>
288
282
  </file>
289
283
  <file name="httpClient.js" path="/builds/3dlinkweb/apacuana/libs/apacuana-sdk-core/main/src/utils/httpClient.js">
290
- <metrics statements="46" coveredstatements="3" conditionals="40" coveredconditionals="0" methods="5" coveredmethods="0"/>
284
+ <metrics statements="40" coveredstatements="3" conditionals="40" coveredconditionals="0" methods="5" coveredmethods="0"/>
291
285
  <line num="12" count="2" type="stmt"/>
292
286
  <line num="13" count="0" type="stmt"/>
293
287
  <line num="15" count="0" type="cond" truecount="0" falsecount="2"/>
@@ -304,36 +298,30 @@
304
298
  <line num="69" count="0" type="cond" truecount="0" falsecount="2"/>
305
299
  <line num="71" count="0" type="stmt"/>
306
300
  <line num="78" count="0" type="stmt"/>
307
- <line num="88" count="0" type="stmt"/>
308
- <line num="99" count="2" type="stmt"/>
309
- <line num="100" count="0" type="cond" truecount="0" falsecount="2"/>
310
- <line num="101" count="0" type="stmt"/>
311
- <line num="105" count="0" type="cond" truecount="0" falsecount="4"/>
312
- <line num="106" count="0" type="stmt"/>
313
- <line num="110" count="0" type="stmt"/>
314
- <line num="112" count="0" type="stmt"/>
315
- <line num="126" count="2" type="cond" truecount="0" falsecount="2"/>
316
- <line num="127" count="0" type="cond" truecount="0" falsecount="2"/>
317
- <line num="128" count="0" type="stmt"/>
301
+ <line num="93" count="2" type="stmt"/>
302
+ <line num="94" count="0" type="cond" truecount="0" falsecount="2"/>
303
+ <line num="95" count="0" type="stmt"/>
304
+ <line num="99" count="0" type="cond" truecount="0" falsecount="4"/>
305
+ <line num="100" count="0" type="stmt"/>
306
+ <line num="104" count="0" type="stmt"/>
307
+ <line num="117" count="2" type="cond" truecount="0" falsecount="2"/>
308
+ <line num="118" count="0" type="cond" truecount="0" falsecount="2"/>
309
+ <line num="119" count="0" type="stmt"/>
310
+ <line num="127" count="0" type="stmt"/>
311
+ <line num="131" count="0" type="stmt"/>
312
+ <line num="133" count="0" type="cond" truecount="0" falsecount="5"/>
313
+ <line num="135" count="0" type="stmt"/>
318
314
  <line num="136" count="0" type="stmt"/>
315
+ <line num="138" count="0" type="stmt"/>
316
+ <line num="139" count="0" type="stmt"/>
319
317
  <line num="141" count="0" type="stmt"/>
318
+ <line num="142" count="0" type="stmt"/>
319
+ <line num="144" count="0" type="stmt"/>
320
320
  <line num="145" count="0" type="stmt"/>
321
- <line num="150" count="0" type="stmt"/>
322
- <line num="152" count="0" type="stmt"/>
323
- <line num="154" count="0" type="cond" truecount="0" falsecount="5"/>
324
- <line num="156" count="0" type="stmt"/>
321
+ <line num="147" count="0" type="stmt"/>
325
322
  <line num="157" count="0" type="stmt"/>
326
- <line num="159" count="0" type="stmt"/>
327
- <line num="160" count="0" type="stmt"/>
328
323
  <line num="162" count="0" type="stmt"/>
329
324
  <line num="163" count="0" type="stmt"/>
330
- <line num="165" count="0" type="stmt"/>
331
- <line num="166" count="0" type="stmt"/>
332
- <line num="168" count="0" type="stmt"/>
333
- <line num="178" count="0" type="stmt"/>
334
- <line num="179" count="0" type="stmt"/>
335
- <line num="184" count="0" type="stmt"/>
336
- <line num="185" count="0" type="stmt"/>
337
325
  </file>
338
326
  </package>
339
327
  </project>