GithubHelp home page GithubHelp logo

tdd's Introduction

2D-Doc parser library

This is a 2D-Doc parser library. It is able to decode and pretty-print a 2D-Doc as defined by French ANTS, and is also able to verify signature.

Usage

Dumper

There is a built-in dumper tool that can be called through command line with:

$ python3 -m tdd.dump samples/spec/3.1.3/15.2.2/17.txt
samples/spec/3.1.3/15.2.2/17.txt:
Version: 3
Country: FR
CA: FR00
Cert: 0001
Emit date: 2179-06-06
Sign date: 2017-06-18
Emitter doc type: Carte T3P
User doc type: Justificatif d'activité
Identifiants de données relatives aux véhicules
  Numéro de la carte: 12345678901
  Date d’expiration initiale: 2019-11-30
Sign: a06b0fb1979c3a526d797a019c78f969a09d9973553d3e353d79a4a29041a4100792ccce10821f328046a36a024a2f47366c2df0cc627344d2070aa987c8e047
Signature OK

API

A basic parsing sessions boils down to:

>>> from tdd.doc import TwoDDoc
>>> c = TwoDDoc.from_code(open('samples/spec/3.1.3/15.2.2/17.txt', 'r').read().strip())
>>> c.header.doc_type().user_type
"Justificatif d'activité"
>>> c.header.doc_type().emitter_type
'Carte T3P'
>>> c.message.dataset
[<tdd.message.FixedData object at 0x10ab320a0>, <tdd.message.FixedData object at 0x10ab32310>]
>>> c.message.dataset[0].definition.name
'Numéro de la carte'
>>> c.message.dataset[0].value
'12345678901'
>>> from tdd.keychain import internal
>>> chain = internal()
>>> c.header.ca_id
'FR00'
>>> c.header.cert_id
'0001'
>>> c.signature_is_valid(chain)
True

TODO

  • Documentation
    • Full API documentation, better pydoc strings.
  • Support for "binary" V4 messages
    • And support for V4 ancillary data
  • Proper certificate chain handling
    • Full certificate chain verification
    • Automatic chain lookup and updates (for now, this is lazy and there is a copy of public keychains in package).
  • Investigate why datatype "DP (EORI de l’exportateur)" does not parse correctly in spec samples. It seems samples are missing a <GS> after this field, or definition max size is broken in the spec.

License

MIT.

tdd's People

Contributors

drzraf avatar nipo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tdd's Issues

green pass

It doesn't work with the french version of the green pass, which is a 2D-DOC.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.