envio-comprobantes-sri
Version:
Envia comprobantes electronicos al SRI (Ecuador). Recibe un objeto JSON. Lo convierte a XML, lo firma, lo envía al servicio web del SRI y devuelve la respuesta.
14 lines (13 loc) • 754 B
TypeScript
/**
* Normalizes XML output from x2js to match C14N canonicalization behavior.
*
* x2js escapes `'` → `'` and `"` → `"`. The XAdES-BES signature hashes the raw XML,
* but the SRI verifies using C14N which resolves these character references back to literal chars.
* This mismatch causes FIRMA_INVALIDA. We pre-resolve them so the hash matches what the SRI computes.
*
* Safe because:
* - `'` in attributes is valid since x2js uses double-quote delimiters (`useDoubleQuotes: true`)
* - `"` is only replaced in text content (between > and <), not inside attribute values
* - `&`, `<`, `>` are NOT touched — these require escaping in XML
*/
export declare function normalizeXmlForC14N(xml: string): string;