|
| 1 | +<div align="center"> |
| 2 | + <br/> |
| 3 | + <img src="./docs/logo.png"/> |
| 4 | + <p>v0.10 (experimental)</p> |
| 5 | + <br/> |
| 6 | + <br/> |
| 7 | + <p> |
| 8 | + An implementation of Saudi Arabia ZATCA's E-Invocing requirements, processes, and standards in TypeScript. <br/> |
| 9 | + </p> |
| 10 | + Read the <a href="/docs">documentation PDFs</a> or <a href="https://zatca.gov.sa/en/E-Invoicing/SystemsDevelopers/Pages/TechnicalRequirementsSpec.aspx">Systems Developers</a> for more details. |
| 11 | + <br/> |
| 12 | + <br/> |
| 13 | + <p> |
| 14 | + |
| 15 | +[](https://github.com/wes4m/zatca-xml-js/blob/main/LICENSE) |
| 16 | + <a href="https://github.com/wes4m"> |
| 17 | + <img src="https://img.shields.io/badge/maintainer-wes4m-blue"/> |
| 18 | + </a> |
| 19 | + <a href="https://badge.fury.io/js/zatca-xml-js"> |
| 20 | + <img src="https://badge.fury.io/js/zatca-xml-js.svg"/> |
| 21 | + </a> |
| 22 | + </p> |
| 23 | +</div> |
| 24 | + |
| 25 | +# Dependencies |
| 26 | +If you plan on using the built in `EGS` module to generate keys, and CSR. The `EGS` module in the package is dependent on <a href="https://www.openssl.org">OpenSSL</a> being installed in the system it's running on. It's being used to generate an `ECDSA` key pair using the `secp256k1` curve. also to generate and sign a CSR. |
| 27 | + |
| 28 | +All other parts of the package will work fine without `OpenSSL`. (meaning it supports react-native and other frameworks) |
| 29 | + |
| 30 | +# Supports |
| 31 | +All tha main futures required to on-board a new EGS. Create, sign, and report a simplified tax invoice are currently supported. |
| 32 | +- EGS (E-Invoice Generation System). |
| 33 | + - Creation/on-boarding (Compliance and Production x.509 CSIDs). |
| 34 | + - Cryptographic stamps generation. |
| 35 | +- Simplified Tax Invoice. |
| 36 | + - Creation. |
| 37 | + - Signing. |
| 38 | + - Compliance checking. |
| 39 | + - Reporting. |
| 40 | + |
| 41 | +# Installation |
| 42 | +``` |
| 43 | +npm install zatca-xml-js |
| 44 | +``` |
| 45 | + |
| 46 | +# Usage |
| 47 | +View full example at <a href="/examples">examples</a> |
| 48 | +```typescript |
| 49 | +import { |
| 50 | + EGS, EGSUnitInfo, |
| 51 | + ZATCASimplifiedTaxInvoice, |
| 52 | +} from "zatca-xml-js"; |
| 53 | + |
| 54 | + |
| 55 | +// New Invoice and EGS Unit |
| 56 | +const invoice: ZATCASimplifiedTaxInvoice = {/*...*/}; |
| 57 | +const egsunit: EGSUnitInfo = {/*...*/}; |
| 58 | + |
| 59 | +// Init EGS unit |
| 60 | +const egs = new EGS(egsunit); |
| 61 | +// New Keys & CSR for the EGS |
| 62 | +await egs.generateNewKeysAndCSR(false); |
| 63 | +// Issue a new compliance cert for the EGS |
| 64 | +const compliance_rid = await egs.issueComplianceCertificate("123345"); |
| 65 | +// Sign invoice |
| 66 | +const {signed_invoice_string, invoice_hash} = egs.signInvoice(invoice); |
| 67 | +// Check invoice compliance |
| 68 | +await egs.checkInvoiceCompliance(signed_invoice_string, invoice_hash); |
| 69 | +// Issue production certificate |
| 70 | +await egs.issueProductionCertificate(compliance_rid); |
| 71 | +// Report invoice |
| 72 | +await egs.reportInvoice(signed_invoice_string, invoice_hash); |
| 73 | +``` |
| 74 | + |
| 75 | +# Implementation |
| 76 | +- General implementation (<a href="/docs/20220624_ZATCA_Electronic_Invoice_XML_Implementation_Standard_vF.pdf">More details</a>) |
| 77 | + - KSA Rules & Business |
| 78 | + - UBL 2.1 Spec |
| 79 | + - ISO EN16931 |
| 80 | + - UN/CEFACT Code List 1001 |
| 81 | + - ISO 3166 |
| 82 | + - ISO 4217:2015 |
| 83 | + - UN/CEFACT Code List 5305, D.16B |
| 84 | +- Security standards (<a href="/docs/20220624_ZATCA_Electronic_Invoice_Security_Features_Implementation_Standards.pdf">More details</a>) |
| 85 | + - NCA National Cryptographic Standards (NCS - 1 : 2020) |
| 86 | + - NCDC Digital Signing Policy (Version 1.1: 2020) |
| 87 | + - ETSI EN 319 102-1 |
| 88 | + - ETSI EN 319 132-1 |
| 89 | + - ETSI EN 319 142-1 |
| 90 | + - W3C XML-Signature Syntax and Processing |
| 91 | + - ETSI EN 319 122-1 |
| 92 | + - IETF RFC 5035 (2007) |
| 93 | + - RFC 5280 |
| 94 | + - ISO 32000-1 |
| 95 | + - IETF RFC 5652 (2009) |
| 96 | + - RFP6749 |
| 97 | + - NIST SP 56A |
| 98 | + |
| 99 | +# Notice of Non-Affiliation and Disclaimer |
| 100 | +`zatca-xml-js` is not affiliated, associated, authorized, endorsed by, or in any way officially connected with ZATCA (Zakat, Tax and Customs Authority), or any of its subsidiaries or its affiliates. The official ZATCA website can be found at https://zatca.gov.sa. |
| 101 | + |
| 102 | +# Contribution |
| 103 | +All contributions are appreciated. |
| 104 | + |
| 105 | +## Roadmap |
| 106 | +- CSIDs renewal, revoking. |
| 107 | +- Populating templates using a template engine instead of `replace` |
| 108 | +- Getting ZATCA to hopefully minify the XMLs before hashing ? |
| 109 | + |
| 110 | + |
| 111 | +I'm not planning on supporting `Tax Invoices` (Not simplified ones). If any one wants to tackle that part. |
0 commit comments