Skip to content

Commit 9c4a420

Browse files
authored
Merge pull request #1 from wes4m/dev
Initial experimental release v0.10
2 parents aac2a57 + 08cb929 commit 9c4a420

26 files changed

+2707
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,9 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
107+
/lib
108+
/testing_lib
109+
/src/tests
110+
.DS_STORE

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Wesam Alzahir
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
[![GitHub license](https://badgen.net/github/license/wes4m/zatca-xml-js)](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.
Binary file not shown.
Binary file not shown.
4.13 MB
Binary file not shown.

docs/EInvoice_Data_Dictionary.xlsx

158 KB
Binary file not shown.

docs/logo.png

8.81 KB
Loading

0 commit comments

Comments
 (0)