arca-sdk 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -338,6 +338,7 @@ async function callArcaApi(url, options) {
338
338
  }
339
339
 
340
340
  // src/auth/wsaa.ts
341
+ import { XMLParser as XMLParser2 } from "fast-xml-parser";
341
342
  var WsaaService = class {
342
343
  config;
343
344
  ticketManager;
@@ -439,13 +440,27 @@ var WsaaService = class {
439
440
  body: this.buildSoapRequest(cms),
440
441
  timeout: this.config.timeout
441
442
  });
443
+ const responseText = await response.text();
442
444
  if (!response.ok) {
445
+ let errorMessage = `Error HTTP al comunicarse con WSAA: ${response.status} ${response.statusText}`;
446
+ try {
447
+ const parser = new XMLParser2({
448
+ ignoreAttributes: false,
449
+ removeNSPrefix: true
450
+ });
451
+ const result = parser.parse(responseText);
452
+ const fault = result.Envelope?.Body?.Fault;
453
+ if (fault && fault.faultstring) {
454
+ errorMessage = `Error AFIP WSAA: ${fault.faultstring}`;
455
+ }
456
+ } catch (e) {
457
+ }
443
458
  throw new ArcaAuthError(
444
- `Error HTTP al comunicarse con WSAA: ${response.status} ${response.statusText}`,
445
- { status: response.status, statusText: response.statusText }
459
+ errorMessage,
460
+ { status: response.status, statusText: response.statusText, body: responseText }
446
461
  );
447
462
  }
448
- const responseXml = await response.text();
463
+ const responseXml = responseText;
449
464
  return parseWsaaResponse(responseXml);
450
465
  }
451
466
  /**
@@ -1347,7 +1362,7 @@ var WsfeService = class _WsfeService {
1347
1362
  };
1348
1363
 
1349
1364
  // src/services/padron.ts
1350
- import { XMLParser as XMLParser2 } from "fast-xml-parser";
1365
+ import { XMLParser as XMLParser3 } from "fast-xml-parser";
1351
1366
  var PadronService = class {
1352
1367
  wsaa;
1353
1368
  config;
@@ -1406,7 +1421,7 @@ var PadronService = class {
1406
1421
  * Parsea la respuesta XML de getPersona
1407
1422
  */
1408
1423
  parseResponse(xml) {
1409
- const parser = new XMLParser2({
1424
+ const parser = new XMLParser3({
1410
1425
  ignoreAttributes: false,
1411
1426
  removeNSPrefix: true
1412
1427
  });