ec-sri-invoice-signer
Version:
Ecuador SRI invoice signer.
28 lines (27 loc) • 1.35 kB
TypeScript
/**
* This doesn't implement the http://www.w3.org/TR/2001/REC-xml-c14n-20010315 specification entirely. Currently it's just
* good enough to work with xml invoices that align with below requirements (which should cover most of the cases).
* At first, won't implement the complete specification considering that the SRI software doesn't need many XML features
* that the specification supports. In the future, if really needed, a complete canonicalization may be implemented.
*
* The requirements for the input invoice XML are (none of these are needed to interchange XML data with the):
* - The invoice to sign should consist of the 'factura' node and its children (e.g. <?xml version="1.0" encoding="UTF-8"?><factura Id="comprobante">...</factura>).
* The document declaration (i.e. <?xml version="1.0" encoding="UTF-8"?>) is optional.
* - The invoice should be utf-8 encoded.
* - No namespaces.
* - No DOCTYPE entities.
* - No Document type definition (DTD) tags.
* - No xml-prefixed attributes (xml:<attr_name>).
*
* Canonicalization based on:
* - https://www.w3.org/TR/xml-c14n
* - https://www.di-mgt.com.au/xmldsig-c14n.html
*/
interface Namespace {
prefix?: string;
uri: string;
}
declare const c14nCanonicalize: (xml: string, options?: {
inheritedNamespaces: Namespace[];
}) => string;
export { c14nCanonicalize };