DCC Utils
Python library to decode the EU Covid-19 vaccine certificate, as specified by the EU.
Setup
pip install dcc-utils
Make sure zbar is installed in your system * For Mac OS X, it can be installed via brew install zbar * Debian systems via apt install libzbar0. Source * Fedora / Red Hat dnf install zbar
Usage
Parse DCC
This library takes an image with a QR code or a raw repr. of a vaccine certificate as the parameter and will show the certificate’s content.
from dcc_utils import dcc
dcc_from_img = dcc.from_image("/my/certificate/path")
dcc_from_raw = dcc.from_raw("HC1:6BF...FTPQ3C3F")
Then you can access to payload and kid
assert dcc_from_img.kid == "53FOjX/4aJs="
assert dcc_from_img.payload["v"][0]["ci"] == "URN:UVCI:01:FR:W7V2BE46QSBJ#L"
👉🏻 payload follows EU Digital COVID Certificates JSON Schema Specification
from_image and from_raw methods may rise DCCParsingError
from dcc_utils.exceptions import DCCParsingError
Validate DCC digital signature
signature = b"""
-----BEGIN CERTIFICATE-----
MIIIAjCCBeqgAwIBAgIQAnq8g/T
-----END CERTIFICATE-----
"""
assert my_dcc.check_signature(signature)
check_signature method may rise DCCSignatureError
from dcc_utils.exceptions import DCCSignatureError
Evaluate CertLogic business rules
With dcc-utils you can evaluate business rules against a DCC
from dcc_utils import rule, dcc
my_dcc = dcc.from_image("/my/certificate/path")
my_rule = rule.from_file("/my/rule.json")
print(my_rule.description["en"])
my_rule.evaluate_dcc(my_dcc) # True or False
evaluate_dcc accepts extra variables as a second parameter, e.g. validationClock
import datetime
clock = datetime.datetime(2022, 10, 10, 0, 0, tzinfo=datetime.timezone.utc)
my_rule.evaluate_dcc(
my_dcc,
{
"validationClock": clock,
},
)
you can also load rules from JSON (from_json), useful to evaluate rules exposed on a server
my_rule = rule.from_json({...})
from_file and from_json method may rise DCCRuleError
from dcc_utils.exceptions import DCCRuleError
Dev setup
Install dependencies using pip:
pip install -r requirements-dev.txt
Run tests
make test
EU Digital COVID Certificate Specifications
What’s in a EU Digital COVID/Green Certificate? * Value Sets for Digital Green Certificates https://ec.europa.eu/health/sites/default/files/ehealth/docs/digital-green-certificates_dt-specifications_en.pdf * JSON schema: https://github.com/ehn-dcc-development/ehn-dcc-schema
Sample data
Digital Green Certificate Gateway (DGCG) samples for all participating countries: https://github.com/eu-digital-green-certificates/dgc-testdata
Credits
Parts of this code are adapted from vacdec project.
License
This library is available under the MIT license.
Metadata
Release files for dcc-utils 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dcc-utils-0.2.1.tar.gz | 5.8 kB | Without provenance | Details for dcc-utils-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dcc_utils-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for dcc_utils-0.2.1-py3-none-any.whl |
Total release size: 12.6 kB
Release files / dcc-utils-0.2.1.tar.gz
| Download URL | dcc-utils-0.2.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0992c6fe86c0cd467ab6b01611441034f494cc93c16953712390cc03f9afcc24
|
|
BLAKE2b-256 checksum How to use checksums |
94bdfefa44968e3c9c6ebbfe1db395b5629f61eac412689a2028ea5c66b673bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Release files / dcc_utils-0.2.1-py3-none-any.whl
| Download URL | dcc_utils-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a59272e0cd3aed18b0df31a51ee5319f753f70b1cbad1a9855fe34329facd43
|
|
BLAKE2b-256 checksum How to use checksums |
c8508d1888a06320fc8edca324e338ffba965131087074ce5f1861ba43710036
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Security for dcc-utils 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.