An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.

Overview

v0.1.0 (experimental)



An implementation of Saudi Arabia ZATCA's E-Invoicing requirements, processes, and standards in TypeScript.

Read the documentation PDFs or Systems Developers for more details.

GitHub license

Dependencies

If you plan on using the built in EGS module to generate keys, and CSR. The EGS module in the package is dependent on OpenSSL 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.

All other parts of the package will work fine without OpenSSL. (meaning it supports react-native and other frameworks)

Supports

All tha main futures required to on-board a new EGS. Create, sign, and report a simplified tax invoice are currently supported.

  • EGS (E-Invoice Generation System).
    • Creation/on-boarding (Compliance and Production x.509 CSIDs).
    • Cryptographic stamps generation.
  • Simplified Tax Invoice.
    • Creation.
    • Signing.
    • Compliance checking.
    • Reporting.

Installation

npm install zatca-xml-js

Usage

View full example at examples

import {
    EGS, EGSUnitInfo,
    ZATCASimplifiedTaxInvoice,
} from "zatca-xml-js";


// New Invoice and EGS Unit
const invoice: ZATCASimplifiedTaxInvoice = {/*...*/};
const egsunit: EGSUnitInfo = {/*...*/};

// Init EGS unit
const egs = new EGS(egsunit);
// New Keys & CSR for the EGS
await egs.generateNewKeysAndCSR(false);
// Issue a new compliance cert for the EGS
const compliance_rid = await egs.issueComplianceCertificate("123345");
// Sign invoice
const {signed_invoice_string, invoice_hash} = egs.signInvoice(invoice);
// Check invoice compliance
await egs.checkInvoiceCompliance(signed_invoice_string, invoice_hash);
// Issue production certificate
await egs.issueProductionCertificate(compliance_rid);
// Report invoice
await egs.reportInvoice(signed_invoice_string, invoice_hash);

Implementation

  • General implementation (More details)
    • KSA Rules & Business
    • UBL 2.1 Spec
    • ISO EN16931
    • UN/CEFACT Code List 1001
    • ISO 3166
    • ISO 4217:2015
    • UN/CEFACT Code List 5305, D.16B
  • Security standards (More details)
    • NCA National Cryptographic Standards (NCS - 1 : 2020)
    • NCDC Digital Signing Policy (Version 1.1: 2020)
    • ETSI EN 319 102-1
    • ETSI EN 319 132-1
    • ETSI EN 319 142-1
    • W3C XML-Signature Syntax and Processing
    • ETSI EN 319 122-1
    • IETF RFC 5035 (2007)
    • RFC 5280
    • ISO 32000-1
    • IETF RFC 5652 (2009)
    • RFP6749
    • NIST SP 56A

Notice of Non-Affiliation and Disclaimer

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.

Contribution

All contributions are appreciated.

Roadmap

  • CSIDs renewal, revoking.
  • Populating templates using a template engine instead of replace
  • Getting ZATCA to hopefully minify the XMLs before hashing ?

I'm not planning on supporting Tax Invoices (Not simplified ones). If any one wants to tackle that part.

You might also like...

This project is a boilerplate for Next and TypeScript projects. This template was built with Vite, TypeScript and Stitches.

This project is a boilerplate for Next and TypeScript projects. This template was built with Vite, TypeScript and Stitches.

Awesome Template Stitches — NextJS, TypeScript, Stitches and Design Tokens Summary About this template Avaliale scripts Other scripts available Main t

Sep 25, 2022

An implementation for FIWARE Orion and Cygnus on AWS.

An implementation for FIWARE Orion and Cygnus on AWS.

FIWARE: Orion and Cygnus on AWS This guide will help you to deploy Fiware's Orion and Cygnus components into a serverless architecture. What does this

Apr 12, 2022

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

Ancon ParkyDB A data mesh database using Web 3.0 technology Note: Requires Node v17.7.2 and up for development More about data mesh architecture Block

Aug 16, 2022

An implementation of ERC1155D, a record setter for minting and transfer gas efficiency.

ERC1155D An implementation of ERC1155D, a record setter for minting and transfer gas efficiency. This contract is in alpha stage and has not been audi

Sep 19, 2022

Simple Library implemented using HTML, CSS and JavaScript. This is a simple implementation of JavaScript Modules of ES6.

Awesome-books A single page project with the porpuse of storing books' titles and authors. Built With CSS, HTML & Javascript. How to run in your local

Feb 21, 2022

Implementation of Widmark Formula and Seidl et al. reductionfactor.

promille_calculator who doesn't have this problem? You are coding away into the darkness while drinking a few beers, get a text from buddy asking if y

Feb 18, 2022

A CRUD implementation using sequelize, mySQL, NODEJS, Express, JWT and other technologies.

A CRUD implementation using sequelize, mySQL, NODEJS, Express, JWT and other technologies.

A ideia do projeto é simular o funcionamento do backend de um blog através da implementação de uma aplicação em Node.js usando o pacote sequelize para

May 11, 2022

A lightweight Nano Node implementation made for wallets, exchanges and other services.

About This is a Light Nano Node implementation made for Wallets, Exchanges and other services. This Node has been built to be compatible with the offi

Jun 25, 2022

A RESP 'Redis Serialization Protocol' library implementation to generate a server, uses a similar approach to express to define you serer, making it easy and fast.

A RESP 'Redis Serialization Protocol' library implementation to generate a server, uses a similar approach to express to define you serer, making it easy and fast.

RESPRESS A RESP 'Redis Serialization Protocol' library implementation to generate a server, uses a similar approach to express to define you serer, ma

Aug 29, 2022
Comments
  • Worked, How do I get PIH (previous invoice hash)?

    Worked, How do I get PIH (previous invoice hash)?

    I have pretty much the same example as you. When I run checkInvoiceCompliance or reportInvoice I get Request failed with status code 400.

    One more question, do I store PIH in a DB or how do you get it?

    opened by sudo-sand 4
Releases(v0.1.1)
  • v0.1.1(Sep 23, 2022)

    What's Changed

    • Readme examples path fix by @wes4m in https://github.com/wes4m/zatca-xml-js/pull/2
    • version fix by @wes4m in https://github.com/wes4m/zatca-xml-js/pull/3
    • Experimental release v0.1.1 release by @wes4m in https://github.com/wes4m/zatca-xml-js/pull/5

    Full Changelog: https://github.com/wes4m/zatca-xml-js/compare/v0.10...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.10(Sep 16, 2022)

Owner
wes4m
wes4m
Reinforcement learning using Markov Decision Processes. For JS, written in C++.

Pavlov.js About Pavlov.js uses Markov Decision Processes to implement reinforcement learning. It is written in C++ and compiled to JavaScript. For mor

Nathan Epstein 501 Sep 16, 2022
Parallel/concurrent async work, optionally using multiple threads or processes

parallel-park Parallel/concurrent async work, optionally using multiple processes Usage parallel-park exports two functions: runJobs and inChildProces

Lily Scott 10 Mar 1, 2022
An easy-to-read, quick reference for JS best practices, accepted coding standards, and links around the Web

Feel free to contribute! Where? http://www.jstherightway.org Why? Today we have a bunch of websites running JavaScript. I think we need a place to put

BrazilJS 8.5k Sep 14, 2022
JavaScript library of crypto standards.

crypto-js JavaScript library of crypto standards. Node.js (Install) Requirements: Node.js npm (Node.js package manager) npm install crypto-js Usage ES

Brix 13.4k Sep 17, 2022
Fast & Robust Front-End Micro-framework based on modern standards

Chat on gitter Hello slim.js - your declarative web components library import { Slim } from 'slim-js'; import { tag, template } from 'slim-js/decorato

slim.js 919 Sep 20, 2022
🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

?? HypeScript Introduction This is a simplified implementation of TypeScript's type system that's written in TypeScript's type annotations. This means

Ronen Amiel 1.7k Sep 22, 2022
Charm implementation in JavaScript (TypeScript)

charm.js A tiny, self-contained cryptography library, implementing authenticated encryption and keyed hashing. Any number of hashing and authenticated

Frank Denis 11 Jun 11, 2022
Implementation of original Lisp as described in Paul Graham's article "The Roots of Lisp". In Typescript

Roots of Lisp This is the implementation of original Lisp from 1960 as described in Paul Graham's article How to use Building If you just want to run

Serhii Dolia 6 Jun 25, 2022
A TypeScript implementation of High-Performance Polynomial Root Finding for Graphics (Yuksel 2022)

Nomial Nomial is a TypeScript implementation of Cem Yuksel's extremely fast, robust, and simple root finding algorithm presented in the paper "High-Pe

Peter Boyer 10 Aug 3, 2022
:books: The definitive guide to TypeScript and possibly the best TypeScript book :book:. Free and Open Source 🌹

TypeScript Deep Dive I've been looking at the issues that turn up commonly when people start using TypeScript. This is based on the lessons from Stack

Basarat Ali Syed 18.2k Sep 26, 2022