facturas 0.21.0 → 0.22.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 (37) hide show
  1. package/README.md +4 -2
  2. package/dist/{chunk-C2KX652X.mjs → chunk-5CGIRDZY.mjs} +5 -2
  3. package/dist/chunk-5CGIRDZY.mjs.map +1 -0
  4. package/dist/{chunk-FQD2PZXE.mjs → chunk-67ISWKGE.mjs} +3 -2
  5. package/dist/{chunk-4PSLYA2B.mjs → chunk-7MNVZSW6.mjs} +12 -3
  6. package/dist/chunk-7MNVZSW6.mjs.map +1 -0
  7. package/dist/{chunk-QHNI4ZIA.mjs → chunk-FSJHE4VS.mjs} +2 -2
  8. package/dist/{chunk-HSGTCGUX.mjs → chunk-GQGYO2Z2.mjs} +2 -2
  9. package/dist/{chunk-WEEV76IC.mjs → chunk-R4MOVPYT.mjs} +2815 -299
  10. package/dist/chunk-R4MOVPYT.mjs.map +1 -0
  11. package/dist/cli.d.ts +4 -4
  12. package/dist/cli.mjs +9 -9
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/{client-CP1PQD_j.d.ts → client-ghHzZdu8.d.ts} +613 -73
  15. package/dist/constants.d.ts +3 -0
  16. package/dist/constants.mjs +1 -1
  17. package/dist/errors.d.ts +2 -2
  18. package/dist/{fiscal-evidence-Cp-ntg5p.d.ts → fiscal-evidence-DjG8zB3o.d.ts} +2 -2
  19. package/dist/{index-abxokwjJ.d.ts → index-BSTxy3nN.d.ts} +1 -1
  20. package/dist/index.d.ts +5 -5
  21. package/dist/index.mjs +10 -10
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/padron.d.ts +2 -2
  24. package/dist/padron.mjs +2 -2
  25. package/dist/{types-DhrPnj3r.d.ts → types-CbvsjIhf.d.ts} +2 -2
  26. package/dist/types.d.ts +1 -1
  27. package/dist/wsfe.d.ts +3 -3
  28. package/dist/wsfe.mjs +2 -2
  29. package/dist/wsmtxca.d.ts +3 -3
  30. package/dist/wsmtxca.mjs +2 -2
  31. package/package.json +1 -1
  32. package/dist/chunk-4PSLYA2B.mjs.map +0 -1
  33. package/dist/chunk-C2KX652X.mjs.map +0 -1
  34. package/dist/chunk-WEEV76IC.mjs.map +0 -1
  35. /package/dist/{chunk-FQD2PZXE.mjs.map → chunk-67ISWKGE.mjs.map} +0 -0
  36. /package/dist/{chunk-QHNI4ZIA.mjs.map → chunk-FSJHE4VS.mjs.map} +0 -0
  37. /package/dist/{chunk-HSGTCGUX.mjs.map → chunk-GQGYO2Z2.mjs.map} +0 -0
package/README.md CHANGED
@@ -127,6 +127,8 @@ una reserva sin emitir.
127
127
  contrato fiscal de emisión.
128
128
  - [Notas de crédito](https://facturas-sdk.dev/guides/credit-notes): `issueCreditNote()`, modo
129
129
  parcial y modo total.
130
+ - [Factura E](https://facturas-sdk.dev/guides/export): exportación de bienes y servicios por
131
+ WSFEX con el mismo `issue()`.
130
132
  - [Evitar comprobantes duplicados](https://facturas-sdk.dev/guides/avoid-duplicates): claves para
131
133
  reintentos, Postgres, Redis, archivos y memoria.
132
134
  - [WSMTXCA para casos requeridos](https://facturas-sdk.dev/guides/wsmtxca): configuración
@@ -134,8 +136,8 @@ una reserva sin emitir.
134
136
  - [Configuración](https://facturas-sdk.dev/reference/configuration): variables de entorno, opciones del
135
137
  cliente, sesiones WSAA, logs, reintentos y límites de tiempo.
136
138
  - [Módulos de transporte](https://facturas-sdk.dev/reference/arca-services): `client.wsfe`,
137
- `client.wsmtxca` y `client.padron` para lecturas, catálogos, estado del
138
- servicio y Padrón.
139
+ `client.wsfex`, `client.wsmtxca` y `client.padron` para lecturas, catálogos,
140
+ estado del servicio y Padrón.
139
141
  - [Errores](https://facturas-sdk.dev/reference/errors): clases de error y diagnóstico.
140
142
  - [Referencia](https://facturas-sdk.dev/reference/public-api): constantes, API pública con semver y
141
143
  seguridad.
@@ -8,7 +8,10 @@ var ARCA_VOUCHER_TYPES = {
8
8
  NOTA_CREDITO_B: 8,
9
9
  FACTURA_C: 11,
10
10
  NOTA_DEBITO_C: 12,
11
- NOTA_CREDITO_C: 13
11
+ NOTA_CREDITO_C: 13,
12
+ FACTURA_E: 19,
13
+ NOTA_DEBITO_E: 20,
14
+ NOTA_CREDITO_E: 21
12
15
  };
13
16
  var ARCA_DOCUMENT_TYPES = {
14
17
  CUIT: 80,
@@ -117,4 +120,4 @@ export {
117
120
  ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
118
121
  ARCA_INVOICE_CLASS_BY_ISSUER
119
122
  };
120
- //# sourceMappingURL=chunk-C2KX652X.mjs.map
123
+ //# sourceMappingURL=chunk-5CGIRDZY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/** Common ARCA reference data for readable userland code and examples. */\nexport const ARCA_VOUCHER_TYPES = {\n FACTURA_A: 1,\n NOTA_DEBITO_A: 2,\n NOTA_CREDITO_A: 3,\n FACTURA_B: 6,\n NOTA_DEBITO_B: 7,\n NOTA_CREDITO_B: 8,\n FACTURA_C: 11,\n NOTA_DEBITO_C: 12,\n NOTA_CREDITO_C: 13,\n FACTURA_E: 19,\n NOTA_DEBITO_E: 20,\n NOTA_CREDITO_E: 21,\n} as const;\n\n/** Common document types accepted by ARCA services. */\nexport const ARCA_DOCUMENT_TYPES = {\n CUIT: 80,\n DNI: 96,\n CONSUMIDOR_FINAL: 99,\n} as const;\n\n/**\n * ARCA's generic WSMTXCA item codes, keyed by the `matrixCode` to send.\n * RG 2904, Anexo VII: for concepts outside the issuer's main line of goods,\n * which carry their GTIN instead. Samples and promotional material use\n * `7790001001054` (Ventas varias).\n * https://www.afip.gob.ar/fe/documentos/codigosGenericosYEspecificos.xls\n */\nexport const ARCA_WSMTXCA_GENERIC_CODES = {\n \"7790001001030\": \"Descuentos y bonificaciones comerciales\",\n \"7790001001047\": \"Conceptos financieros\",\n \"7790001001054\": \"Ventas varias\",\n \"7790001001061\": \"Bienes de uso\",\n \"7790001001078\": \"Servicios prestados\",\n \"7790001001085\": \"Fletes\",\n \"7790001001092\": \"Alquileres\",\n \"7790001001115\": \"Depósito y servicios de logística\",\n \"7790001001122\": \"Repuestos y accesorios\",\n \"7790001001139\": \"Ajustes impositivos\",\n \"7790001001146\": \"Actividades comerciales no codificadas\",\n \"7790001001153\": \"Venta de material de rezago\",\n \"7790001001856\": \"Anticipos y señas\",\n} as const;\n\n/**\n * Common receiver IVA condition identifiers used by WSFE.\n * Allowed values depend on the voucher class and ARCA's live catalog.\n */\nexport const ARCA_RECEIVER_VAT_CONDITIONS = {\n RESPONSABLE_INSCRIPTO: 1,\n EXENTO: 4,\n CONSUMIDOR_FINAL: 5,\n MONOTRIBUTISTA: 6,\n IVA_NO_ALCANZADO: 15,\n} as const;\n\n/** Supported invoice concept types for WSFE requests. */\nexport const ARCA_CONCEPT_TYPES = {\n PRODUCTOS: 1,\n SERVICIOS: 2,\n PRODUCTOS_Y_SERVICIOS: 3,\n} as const;\n\n/** Common IVA rate identifiers used by WSFE. */\nexport const ARCA_VAT_RATES = {\n IVA_0: 3,\n IVA_10_5: 4,\n IVA_21: 5,\n IVA_27: 6,\n IVA_5: 8,\n IVA_2_5: 9,\n} as const;\n\n/** ISO currency codes accepted by the high-level WSFE builders. */\nexport const ISO_CURRENCIES = {\n ARS: \"ARS\",\n USD: \"USD\",\n} as const;\n\n/** ARCA currency identifiers keyed by their corresponding ISO currency. */\nexport const ARCA_CURRENCY_IDS = {\n ARS: \"PES\",\n USD: \"DOL\",\n} as const;\n\n/** Legal assertions supported by the invoice high-level API; never inferred from Padrón. */\nexport type IssuerCondition =\n | \"responsable_inscripto\"\n | \"monotributo\"\n | \"exento\"\n | \"no_alcanzado\";\nexport type ReceiverCondition = IssuerCondition | \"consumidor_final\";\nexport type VoucherClass = \"A\" | \"B\" | \"C\";\n\nexport const ARCA_RECEIVER_CONDITION_IDS = {\n responsable_inscripto: ARCA_RECEIVER_VAT_CONDITIONS.RESPONSABLE_INSCRIPTO,\n monotributo: ARCA_RECEIVER_VAT_CONDITIONS.MONOTRIBUTISTA,\n exento: ARCA_RECEIVER_VAT_CONDITIONS.EXENTO,\n consumidor_final: ARCA_RECEIVER_VAT_CONDITIONS.CONSUMIDOR_FINAL,\n no_alcanzado: ARCA_RECEIVER_VAT_CONDITIONS.IVA_NO_ALCANZADO,\n} as const satisfies Record<ReceiverCondition, number>;\n\nexport const ARCA_ISSUER_CONDITION_IDS = {\n responsable_inscripto: 1,\n monotributo: 6,\n exento: 4,\n no_alcanzado: 15,\n} as const satisfies Record<IssuerCondition, number>;\n\n/** The ARCA identifier of each issuer condition, accepted wherever a name is. */\nexport type IssuerConditionId =\n (typeof ARCA_ISSUER_CONDITION_IDS)[IssuerCondition];\n\n// RG 5866/2026, art. 1(f), effective 2026-07-01 (art. 4).\n// https://www.argentina.gob.ar/normativa/nacional/norma-427092/texto\nexport const ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS =\n 1_000_000_000n;\n\n// WSFE v4.7, physical PDF p. 203, validations 10243/10246; issuer asserted first.\n// ARCA checks actual issuer eligibility independently at authorization.\nexport const ARCA_INVOICE_CLASS_BY_ISSUER = {\n responsable_inscripto: {\n responsable_inscripto: \"A\",\n monotributo: \"A\",\n exento: \"B\",\n consumidor_final: \"B\",\n no_alcanzado: \"B\",\n },\n monotributo: {\n responsable_inscripto: \"C\",\n monotributo: \"C\",\n exento: \"C\",\n consumidor_final: \"C\",\n no_alcanzado: \"C\",\n },\n exento: {\n responsable_inscripto: \"C\",\n monotributo: \"C\",\n exento: \"C\",\n consumidor_final: \"C\",\n no_alcanzado: \"C\",\n },\n no_alcanzado: {\n responsable_inscripto: \"C\",\n monotributo: \"C\",\n exento: \"C\",\n consumidor_final: \"C\",\n no_alcanzado: \"C\",\n },\n} as const satisfies Record<\n IssuerCondition,\n Record<ReceiverCondition, VoucherClass>\n>;\n"],"mappings":";AACO,IAAM,qBAAqB;AAAA,EAChC,WAAW;AAAA,EACX,e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uB;AAAA,EACvB,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,cAAc;AAChB;AAQO,IAAM,2DACX;AAIK,IAAM,+BAA+B;AAAA,EAC1C,uBAAuB;AAAA,IACrB,uBAAuB;AAAA,IACvB,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAChB;AAAA,EACA,aAAa;AAAA,IACX,uBAAuB;AAAA,IACvB,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAChB;AAAA,EACA,QAAQ;AAAA,IACN,uBAAuB;AAAA,IACvB,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAChB;AAAA,EACA,cAAc;AAAA,IACZ,uBAAuB;AAAA,IACvB,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAChB;AACF;","names":[]}
@@ -8,7 +8,7 @@ import {
8
8
  classifyArcaAuthenticationIssues,
9
9
  createArcaAuthenticationEvidence,
10
10
  executeWithAuthenticationRecovery
11
- } from "./chunk-4PSLYA2B.mjs";
11
+ } from "./chunk-7MNVZSW6.mjs";
12
12
  import {
13
13
  ArcaInputError,
14
14
  ArcaInvalidSoapResponseError,
@@ -1523,6 +1523,7 @@ function getWsfeNumericResultEntries(result, key) {
1523
1523
  export {
1524
1524
  toIsoDate,
1525
1525
  normalizeArcaAmountToMinorUnits,
1526
+ serializeArcaAmount,
1526
1527
  serializeArcaExchangeRate,
1527
1528
  assertArcaMinorUnits,
1528
1529
  arcaMinorUnitsToNumber,
@@ -1532,4 +1533,4 @@ export {
1532
1533
  normalizeWsfeVoucherInput,
1533
1534
  normalizeWsfeDateInput
1534
1535
  };
1535
- //# sourceMappingURL=chunk-FQD2PZXE.mjs.map
1536
+ //# sourceMappingURL=chunk-67ISWKGE.mjs.map
@@ -10,6 +10,14 @@ var WSFE_AUTHENTICATION_CODES = {
10
10
  "600": "invalid_token",
11
11
  "601": "missing_relationship"
12
12
  };
13
+ var WSFEX_AUTHENTICATION_CODES = {
14
+ "1000": "invalid_token",
15
+ "1001": "missing_relationship"
16
+ };
17
+ var STRUCTURED_AUTHENTICATION_CODES = {
18
+ wsfe: WSFE_AUTHENTICATION_CODES,
19
+ wsfex: WSFEX_AUTHENTICATION_CODES
20
+ };
13
21
  function classifyArcaAuthenticationCandidate(candidate) {
14
22
  const providerCode = normalizeProviderCode(candidate.providerCode);
15
23
  const reason = getStructuredAuthenticationReason(candidate.service, providerCode) ?? getTextAuthenticationReason(candidate.message);
@@ -101,10 +109,11 @@ async function executeWithAuthenticationRecovery(options) {
101
109
  }
102
110
  }
103
111
  function getStructuredAuthenticationReason(service, providerCode) {
104
- if (service !== "wsfe" || providerCode === void 0) {
112
+ const codes = STRUCTURED_AUTHENTICATION_CODES[service];
113
+ if (!codes || providerCode === void 0) {
105
114
  return void 0;
106
115
  }
107
- return WSFE_AUTHENTICATION_CODES[String(providerCode).trim()];
116
+ return codes[String(providerCode).trim()];
108
117
  }
109
118
  function getTextAuthenticationReason(message) {
110
119
  if (!message) {
@@ -176,4 +185,4 @@ export {
176
185
  createArcaAuthenticationEvidence,
177
186
  executeWithAuthenticationRecovery
178
187
  };
179
- //# sourceMappingURL=chunk-4PSLYA2B.mjs.map
188
+ //# sourceMappingURL=chunk-7MNVZSW6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/authentication.ts"],"sourcesContent":["import {\n ArcaAuthenticationError,\n type ArcaAuthenticationReason,\n ArcaServiceError,\n ArcaSoapFaultError,\n isArcaAuthenticationError,\n} from \"../errors\";\nimport type {\n ArcaAuthenticationEvidence,\n ArcaFiscalIssue,\n} from \"../services/fiscal-evidence\";\nimport type { ArcaServiceName } from \"./types\";\n\ntype AuthenticationContext = {\n service: ArcaServiceName;\n operation: string;\n};\n\ntype AuthenticationCandidate = AuthenticationContext & {\n providerCode?: string | number;\n message?: string;\n cause?: unknown;\n};\n\ntype AuthenticationRecoveryOptions<T> = AuthenticationContext & {\n forceRefresh?: boolean;\n allowRetry?: boolean;\n execute(forceRefresh?: boolean): Promise<T>;\n};\n\nconst WSFE_AUTHENTICATION_CODES: Readonly<\n Record<string, ArcaAuthenticationReason>\n> = {\n \"600\": \"invalid_token\",\n \"601\": \"missing_relationship\",\n};\n\n// WSFEX answers every operation's token check with 1000 and a CUIT outside the\n// ticket's represented taxpayers with 1001.\nconst WSFEX_AUTHENTICATION_CODES: Readonly<\n Record<string, ArcaAuthenticationReason>\n> = {\n \"1000\": \"invalid_token\",\n \"1001\": \"missing_relationship\",\n};\n\nconst STRUCTURED_AUTHENTICATION_CODES: Partial<\n Record<ArcaServiceName, Readonly<Record<string, ArcaAuthenticationReason>>>\n> = {\n wsfe: WSFE_AUTHENTICATION_CODES,\n wsfex: WSFEX_AUTHENTICATION_CODES,\n};\n\n/** Classifies one safe provider code/message pair without inspecting object graphs. */\nexport function classifyArcaAuthenticationCandidate(\n candidate: AuthenticationCandidate\n): ArcaAuthenticationError | undefined {\n const providerCode = normalizeProviderCode(candidate.providerCode);\n const reason =\n getStructuredAuthenticationReason(candidate.service, providerCode) ??\n getTextAuthenticationReason(candidate.message);\n\n if (!reason) {\n return undefined;\n }\n\n return new ArcaAuthenticationError(\n formatAuthenticationMessage(candidate.service, candidate.operation, reason),\n {\n reason,\n service: candidate.service,\n operation: candidate.operation,\n ...(providerCode === undefined ? {} : { providerCode }),\n ...(candidate.cause === undefined ? {} : { cause: candidate.cause }),\n }\n );\n}\n\n/** Classifies supported public ARCA errors while ignoring arbitrary errors and causes. */\nexport function classifyArcaAuthenticationError(\n error: unknown,\n context: AuthenticationContext\n): ArcaAuthenticationError | undefined {\n if (isArcaAuthenticationError(error)) {\n return error;\n }\n\n if (error instanceof ArcaSoapFaultError) {\n return classifyArcaAuthenticationCandidate({\n ...context,\n providerCode: error.faultCode,\n message: error.message,\n cause: error,\n });\n }\n\n if (error instanceof ArcaServiceError) {\n const issueError = classifyArcaAuthenticationIssues(\n error.issues ?? [],\n context\n );\n if (issueError) {\n return new ArcaAuthenticationError(issueError.message, {\n reason: issueError.reason,\n service: issueError.service,\n operation: issueError.operation,\n ...(issueError.providerCode === undefined\n ? {}\n : { providerCode: issueError.providerCode }),\n cause: error,\n });\n }\n\n return classifyArcaAuthenticationCandidate({\n ...context,\n providerCode: error.serviceCode,\n message: error.message,\n cause: error,\n });\n }\n\n return undefined;\n}\n\n/** Classifies structured service issues in provider order. */\nexport function classifyArcaAuthenticationIssues(\n issues: readonly ArcaFiscalIssue[],\n context: AuthenticationContext\n): ArcaAuthenticationError | undefined {\n for (const issue of issues) {\n const authenticationError = classifyArcaAuthenticationCandidate({\n ...context,\n providerCode: issue.code,\n message: issue.message,\n });\n if (authenticationError) {\n return authenticationError;\n }\n }\n return undefined;\n}\n\n/** Converts the public error to safe serializable exact-attempt evidence. */\nexport function createArcaAuthenticationEvidence(\n error: ArcaAuthenticationError\n): ArcaAuthenticationEvidence {\n return {\n code: \"ARCA_AUTHENTICATION_ERROR\",\n reason: error.reason,\n ...(error.providerCode === undefined\n ? {}\n : { providerCode: error.providerCode }),\n };\n}\n\n/** Recreates the throwable contract from safe exact-attempt evidence. */\nexport function createArcaAuthenticationErrorFromEvidence(\n evidence: ArcaAuthenticationEvidence,\n context: AuthenticationContext\n): ArcaAuthenticationError {\n return new ArcaAuthenticationError(\n formatAuthenticationMessage(\n context.service,\n context.operation,\n evidence.reason\n ),\n {\n reason: evidence.reason,\n service: context.service,\n operation: context.operation,\n ...(evidence.providerCode === undefined\n ? {}\n : { providerCode: evidence.providerCode }),\n }\n );\n}\n\n/** Runs one convenience operation and permits one proven-safe forced refresh. */\nexport async function executeWithAuthenticationRecovery<T>(\n options: AuthenticationRecoveryOptions<T>\n): Promise<T> {\n const executeAttempt = async (forceRefresh?: boolean): Promise<T> => {\n try {\n return await options.execute(forceRefresh);\n } catch (error) {\n throw classifyArcaAuthenticationError(error, options) ?? error;\n }\n };\n\n try {\n return await executeAttempt(options.forceRefresh);\n } catch (error) {\n const allowRetry =\n options.allowRetry !== false && options.forceRefresh !== true;\n if (!(allowRetry && isArcaAuthenticationError(error))) {\n throw error;\n }\n return executeAttempt(true);\n }\n}\n\nfunction getStructuredAuthenticationReason(\n service: ArcaServiceName,\n providerCode: string | number | undefined\n): ArcaAuthenticationReason | undefined {\n const codes = STRUCTURED_AUTHENTICATION_CODES[service];\n if (!codes || providerCode === undefined) {\n return undefined;\n }\n return codes[String(providerCode).trim()];\n}\n\nfunction getTextAuthenticationReason(\n message: string | undefined\n): ArcaAuthenticationReason | undefined {\n if (!message) {\n return undefined;\n }\n const normalized = normalizeAuthenticationText(message);\n\n if (\n includesWholePhrase(\n normalized,\n \"no aparecio cuit en lista de relaciones\"\n ) ||\n includesWholePhrase(normalized, \"cuit representada no incluida en token\")\n ) {\n return \"missing_relationship\";\n }\n if (includesWholePhrase(normalized, \"computador no autorizado\")) {\n return \"unauthorized_computer\";\n }\n if (\n includesWholePhrase(normalized, \"validaciondetoken\") ||\n includesWholePhrase(normalized, \"token vencido\") ||\n includesWholePhrase(normalized, \"no se corresponden token y firma\")\n ) {\n return \"invalid_token\";\n }\n if (\n includesWholePhrase(normalized, \"no autorizado a acceder al servicio\") ||\n includesWholePhrase(normalized, \"no autorizado a acceder a los servicios\")\n ) {\n return \"authentication_rejected\";\n }\n return undefined;\n}\n\nfunction normalizeAuthenticationText(value: string): string {\n return value\n .normalize(\"NFD\")\n .replace(/\\p{Diacritic}/gu, \"\")\n .toLowerCase()\n .replace(/\\s+/g, \" \")\n .trim();\n}\n\nfunction includesWholePhrase(value: string, phrase: string): boolean {\n let searchFrom = 0;\n while (searchFrom <= value.length - phrase.length) {\n const index = value.indexOf(phrase, searchFrom);\n if (index < 0) {\n return false;\n }\n const before = value[index - 1];\n const after = value[index + phrase.length];\n if (!(isWordCharacter(before) || isWordCharacter(after))) {\n return true;\n }\n searchFrom = index + phrase.length;\n }\n return false;\n}\n\nfunction isWordCharacter(value: string | undefined): boolean {\n return value !== undefined && /[a-z0-9]/.test(value);\n}\n\nfunction normalizeProviderCode(\n providerCode: string | number | undefined\n): string | number | undefined {\n if (typeof providerCode === \"number\") {\n return Number.isFinite(providerCode) ? providerCode : undefined;\n }\n if (typeof providerCode === \"string\") {\n const normalized = providerCode.trim();\n return normalized || undefined;\n }\n return undefined;\n}\n\nfunction formatAuthenticationMessage(\n service: ArcaServiceName,\n operation: string,\n reason: ArcaAuthenticationReason\n): string {\n const descriptions: Record<ArcaAuthenticationReason, string> = {\n invalid_token: \"the token or signature was rejected\",\n unauthorized_computer: \"the certificate or computer is not authorized\",\n missing_relationship: \"the represented taxpayer relationship is missing\",\n authentication_rejected: \"the service denied authenticated access\",\n };\n return `ARCA rejected authentication for ${service}.${operation}: ${descriptions[reason]}.`;\n}\n"],"mappings":";;;;;;;;AA8BA,IAAM,4BAEF;AAAA,EACF,OAAO;AAAA,EACP,OAAO;AACT;AAIA,IAAM,6BAEF;AAAA,EACF,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,IAAM,kCAEF;AAAA,EACF,MAAM;AAAA,EACN,OAAO;AACT;AAGO,SAAS,oCACd,WACqC;AACrC,QAAM,eAAe,sBAAsB,UAAU,YAAY;AACjE,QAAM,SACJ,kCAAkC,UAAU,SAAS,YAAY,KACjE,4BAA4B,UAAU,OAAO;AAE/C,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,SAAO,IAAI;AAAA,IACT,4BAA4B,UAAU,SAAS,UAAU,WAAW,MAAM;AAAA,IAC1E;AAAA,MACE;AAAA,MACA,SAAS,UAAU;AAAA,MACnB,WAAW,UAAU;AAAA,MACrB,GAAI,iBAAiB,SAAY,CAAC,IAAI,EAAE,aAAa;AAAA,MACrD,GAAI,UAAU,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,UAAU,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAGO,SAAS,gCACd,OACA,SACqC;AACrC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D,UAAM,QAAQ,MAAM,QAAQ,QAAQ,UAAU;AAC9C,QAAI,QAAQ,GAAG;AACb,aAAO;AAAA,IACT;AACA,UAAM,SAAS,MAAM,QAAQ,CAAC;AAC9B,UAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM;AACzC,QAAI,EAAE,gBAAgB,MAAM,KAAK,gBAAgB,KAAK,IAAI;AACxD,aAAO;AAAA,IACT;AACA,iBAAa,QAAQ,OAAO;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,SAAS,gBAAgB,OAAoC;AAC3D,SAAO,UAAU,UAAa,WAAW,KAAK,KAAK;AACrD;AAEA,SAAS,sBACP,cAC6B;AAC7B,MAAI,OAAO,iBAAiB,UAAU;AACpC,WAAO,OAAO,SAAS,YAAY,IAAI,eAAe;AAAA,EACxD;AACA,MAAI,OAAO,iBAAiB,UAAU;AACpC,UAAM,aAAa,aAAa,KAAK;AACrC,WAAO,cAAc;AAAA,EACvB;AACA,SAAO;AACT;AAEA,SAAS,4BACP,SACA,WACA,QACQ;AACR,QAAM,eAAyD;AAAA,IAC7D,eAAe;AAAA,IACf,uBAAuB;AAAA,IACvB,sBAAsB;AAAA,IACtB,yBAAyB;AAAA,EAC3B;AACA,SAAO,oCAAoC,OAAO,IAAI,SAAS,KAAK,aAAa,MAAM,CAAC;AAC1F;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  classifyArcaAuthenticationError
3
- } from "./chunk-4PSLYA2B.mjs";
3
+ } from "./chunk-7MNVZSW6.mjs";
4
4
  import {
5
5
  ArcaSoapFaultError
6
6
  } from "./chunk-Q7IURW54.mjs";
@@ -248,4 +248,4 @@ async function executePadronOperation(options, service, operation, body) {
248
248
  export {
249
249
  createPadronService
250
250
  };
251
- //# sourceMappingURL=chunk-QHNI4ZIA.mjs.map
251
+ //# sourceMappingURL=chunk-FSJHE4VS.mjs.map
@@ -8,7 +8,7 @@ import {
8
8
  classifyArcaAuthenticationIssues,
9
9
  createArcaAuthenticationEvidence,
10
10
  executeWithAuthenticationRecovery
11
- } from "./chunk-4PSLYA2B.mjs";
11
+ } from "./chunk-7MNVZSW6.mjs";
12
12
  import {
13
13
  ArcaInputError,
14
14
  ArcaInvalidSoapResponseError,
@@ -677,4 +677,4 @@ function formatCompactDateToIso(dateValue) {
677
677
  export {
678
678
  createWsmtxcaService
679
679
  };
680
- //# sourceMappingURL=chunk-HSGTCGUX.mjs.map
680
+ //# sourceMappingURL=chunk-GQGYO2Z2.mjs.map