🐍 VerificaC19 SDK implementation for Python

Overview

VerificaC19 Python SDK

🐍 VerificaC19 SDK implementation for Python.

Latest Version CI codecov Supported Python versions

Requirements

  • Python version >= 3.7

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

Install

pip install verificac19

Usage

Download and cache rules and DSCs

You can download and cache rules and DSCs using service.

from verificac19 import service

service.update_all()

update_all may rise VerificaC19Error

from verificac19.exceptions import VerificaC19Error

⚠️ By default rules and DSCs will be cached in local folder, to change it please set VC19_CACHE_FOLDER env variable.

Verify a DCC

You can verify a DCC using verifier. You can verify a DCC using verify_image for images and verify_raw for raw data.

from verificac19 import verifier

result = verifier.verify_image("my_dcc.png")
result = verifier.verify_raw("HC1:GH.....1GH")

verify_image and verify_raw return a dictionary containing person name, date_of_birth, code and a message alongside the result

{
  'code': verifier.Codes.NOT_VALID, 
  'result': False, 
  'message': 'Certificate is not valid', 
  'person': 'Sčasný Svätozár', 
  'date_of_birth': '1984-09-27'
}

you can compare the resulting code with verifier.Codes values

Code Description
✅ VALID Certificate is valid
❌ NOT_VALID Certificate is not valid
❌ NOT_VALID_YET Certificate is not valid yet
❌ NOT_EU_DCC Certificate is not an EU DCC

for example

result = verifier.verify_image("my_dcc.png")
assert result['code'] == verifier.Codes.NOT_VALID

⚠️ verify_image and verify_raw may rise VerificaC19Error in case you cache is not initialized. You need to call service.update_all() at least once!

Verification mode

If you want to change verification mode and verify whether a certificate is a Super Green Pass or not, you need to pass verifier.Mode.SUPER_DGP to verify_image and verify_raw methods.

from verificac19 import verifier

result = verifier.verify_image("my_dcc.png", verifier.Mode.SUPER_DGP)

verifier.Mode exposes 2 possible values

Code Description
NORMAL_DGP Normal verification (default value)
SUPER_DGP Super Green Pass verification

Super Green Pass, which will come into force from 6 December to 15 January 2021, will be a certificate valid only for people who have been vaccinated against or who have recovered from Covid19, and will prevent all the others from entering bars, restaurants, cinemas, gyms, theatres, discos and stadiums.

Development

Install dev dependencies

pip install -r requirements-dev.txt

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

Run tests

make test

Run examples

python -m examples.<example_name>

Authors

Copyright (c) 2021 - Lotrèk Digital Agency

Contributors

Thank you to everyone involved for improving this project, day by day.

License

This library is available under the MIT license.

Comments
  • 24h validation limit implemented

    24h validation limit implemented

    The service module now implements an improved caching system. The cache is responsable for storing the current datetime along side the data itself. When that same file is reloaded later, it compares the datetime in the file with the current datetime. If there is a difference of 24 hours or greater, the cached data is dropped and new data is refetched from the APIs.

    The limit of 24 hours can be changed in the file: verificac19/service/_cache.py

    opened by Freder211 1
  • Inserire l'apposito header User-agent nelle richieste verso le API

    Inserire l'apposito header User-agent nelle richieste verso le API

    Inserire all'interno delle richieste verso le API l'apposito header User-Agent nella forma

    User-Agent: <sdk>-<sdk-technology>/<sdk-version>
    

    È possibile omettere -<sdk-technology> se la tecnologia è già specificata nel nome (ad esempio verificac19-sdk-php).

    Ad esempio nel caso verificac19-sdk per Node.js lo User-Agent sarĂ 

    User-Agent: verificac19-sdk-node/0.9.3
    
    opened by astagi 0
  • Add Booster Mode

    Add Booster Mode

    • [x] Add booster mode for vaccines, recovery statements and tests
    • [x] Check recovery bis

    Initial branch: feat/booster Booster Documentation:https://github.com/ministero-salute/it-dgc-documentation/blob/master/SCANMODE.md NodeJS Implementation: https://github.com/italia/verificac19-sdk/pull/17

    opened by b0tero 0
  • Create CRL

    Create CRL

    • [x] Add MongoDB
    • [x] Add CRL to Service

    Initial branch: feat/crl CRL Documentation: https://github.com/ministero-salute/it-dgc-documentation/blob/master/DRL.md NodeJS Implementation: https://github.com/italia/verificac19-sdk/pull/8/files

    opened by b0tero 0
  • Creare un metodo per catalogare il DCC

    Creare un metodo per catalogare il DCC

    • [x] Creare un metodo che riceverĂ  in input un DCC e deciderĂ  se si tratta di

    • Vaccino

    • Recovery

    • Test rapido/molecolare

    Reference Technical Specifications for EU Digital COVID Certificates JSON Schema Specification

    • [x] Definire una struttura di ritorno del risultato di verifica, ricordarsi che i codici di ritorno devono variare a seconda del risultato

    | | Code | Description | |-| --------------- | ---------------------------------------- | |✅| VALID | Certificate is valid | |❌| NOT_VALID | Certificate is not valid | |❌| NOT_VALID_YET | Certificate is not valid yet | |❌| NOT_EU_DCC | Certificate is not an EU DCC |

    Un possibile esempio di valore di ritorno è

    {
       code: NOT_VALID,
       result: False
       message: 'Invalid signature',
    }
    
    • [x] Implementare il fatto che se si tratta di Test rapido/molecolare e la modalitĂ  super green pass è attiva, allora il certificato non è valido (NOT_VALID)
    • [x] Implementare il fatto che se il Vaccino è Sputnik-V e non è stato fatto a San Marino 🇸🇲 allora bisogna rifiutarlo (NOT_VALID)
    Verifica 
    opened by b0tero 0
  • Creare un metodo per scaricare i DSC

    Creare un metodo per scaricare i DSC

    • [x] Creare un metodo richiamabile dall'utente per scaricare i DSC

    I DSC vengono scaricati attraverso una API che deve essere richiamata ciclicamente per scaricare i DSC

    https://get.dgc.gov.it/v1/dgc/signercertificate/update

    In risposta oltre al DSC si ottengono negli header il KID corrispondente e il token necessario per ottenere il prossimo DSC

    X-KID: 25QCxBrBJvA=
    X-RESUME-TOKEN: 1
    

    Un esempio semplice: https://github.com/ministero-salute/dcc-utils/issues/1#issuecomment-893580695

    • [x] Memorizzare i DSC in un file JSON in memoria, indicizzando i DSC con il relativo KID
    {
      "5EiHqlAm4=": "-----BEGIN CERTIFICATE-----\nMIIH9jCQA...jkYBBgIpdw=\n-----END CERTIFICATE-----",
      "nJkLGpT68=": "-----BEGIN CERTIFICATE-----\nMIIDpqHbd...IIxA==\n-----END CERTIFICATE-----",
      "TmDTMuL6E=": "-----BEGIN CERTIFICATE-----\nMIIDJTCCAsy...nrDq+NRUg=\n-----END CERTIFICATE-----",
    }
    
    Provider & Storage 
    opened by b0tero 0
  • Creare un metodo per esporre i DSC

    Creare un metodo per esporre i DSC

    • [x] Creare un metodo che dato un KID ritorna il DSC corrispondente
    my_dsc = get_dsc_by_kid(dcc.kid)
    # A seguire, verifica firma DCC
    

    Questo metodo verrĂ  usato dal team di Verifica per prendere un DSC per verificare il certificato

    Provider & Storage 
    opened by b0tero 0
  • Validare il vaccino con le regole italiane

    Validare il vaccino con le regole italiane

    opened by b0tero 0
  • Validare il recovery con le regole italiane

    Validare il recovery con le regole italiane

    opened by b0tero 0
  • Validare i test con le regole italiane

    Validare i test con le regole italiane

    opened by b0tero 0
  • Creare metodo per esporre i settings e la blacklist

    Creare metodo per esporre i settings e la blacklist

    • [x] Creare un metodo per esporre i settings in modo che sia facile per gli sviluppatori trovare gli elementi

    Ad esempio

    get_setting_value('vaccine_end_day_complete', 'Sputnik-V')
    
    • [x] Creare un metodo per chiedere se un elemento è presente o meno in blacklist

    Ad esempio

    is_blacklisted('il mio UVCI')
    
    Provider & Storage 
    opened by b0tero 0
Releases(v1.2.0)
Owner
Lotrèk
💚 Human Before Digital 🌈 ⚗️ Experiments on @lotreklab
Lotrèk
Graviti-python-sdk - Graviti Data Platform Python SDK

Graviti Python SDK Graviti Python SDK is a python library to access Graviti Data

Graviti 13 Dec 15, 2022
A wrapper for aqquiring Choice Coin directly through a Python Terminal. Leverages the TinyMan Python-SDK.

CHOICE_TinyMan_Wrapper A wrapper that allows users to acquire Choice Coin directly through their Terminal using ALGO and various Algorand Standard Ass

Choice Coin 16 Sep 24, 2022
AWS SDK for Python

Boto3 - The AWS SDK for Python Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to wri

the boto project 7.8k Jan 8, 2023
Python SDK for Facebook's Graph API

Facebook Python SDK This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical

Mobolic 2.7k Jan 7, 2023
Box SDK for Python

Box Python SDK Installing Getting Started Authorization Server-to-Server Auth with JWT Traditional 3-legged OAuth2 Other Auth Options Usage Documentat

Box 371 Dec 29, 2022
The Official Dropbox API V2 SDK for Python

The offical Dropbox SDK for Python. Documentation can be found on Read The Docs. Installation Create an app via the Developer Console. Install via pip

Dropbox 828 Jan 5, 2023
Evernote SDK for Python

Evernote SDK for Python Evernote API version 1.28 This SDK is intended for use with Python 2.X For Evernote's beta Python 3 SDK see https://github.com

Evernote 612 Dec 30, 2022
Python SDK for IEX Cloud

iexfinance Python SDK for IEX Cloud. Architecture mirrors that of the IEX Cloud API (and its documentation). An easy-to-use toolkit to obtain data for

Addison Lynch 640 Jan 7, 2023
Unofficial Medium Python Flask API and SDK

PyMedium - Unofficial Medium API PyMedium is an unofficial Medium API written in python flask. It provides developers to access to user, post list and

Engine Bai 157 Nov 11, 2022
The Python SDK for the Rackspace Cloud

pyrax Python SDK for OpenStack/Rackspace APIs DEPRECATED: Pyrax is no longer being developed or supported. See openstacksdk and the rackspacesdk plugi

PyContribs 238 Sep 21, 2022
:snake: Python SDK to query Scaleway APIs.

Scaleway SDK Python SDK to query Scaleway's APIs. Stable release: Development: Installation The package is available on pip. To install it in a virtua

Scaleway 114 Dec 11, 2022
Skyscanner Python SDK

Skyscanner Python SDK Important As of May 1st, 2020, the project is deprecated and no longer maintained. The latest update in v1.1.5 includes changing

Skyscanner 118 Sep 23, 2022
WeChat SDK for Python

___ __ _______ ________ ___ ___ ________ _________ ________ ___ ___ |\ \ |\ \|\ ___ \ |\ ____\|\ \|\ \|\ __ \|\___

wechatpy 3.3k Dec 26, 2022
Python SDK for the Buycoins API.

This library provides easy access to the Buycoins API using the Python programming language. It provides all the feature of the API so that you don't need to interact with the API directly. This library can be used with Python 3.6+

Musa Rasheed 48 May 4, 2022
Graviti TensorBay Python SDK

TensorBay Python SDK is a python library to access TensorBay and manage your datasets. It provides: A pythonic way to access your

Graviti 72 Aug 22, 2022
A Python script for rendering glTF files with V-Ray App SDK

V-Ray glTF viewer Overview The V-Ray glTF viewer is a set of Python scripts for the V-Ray App SDK that allow the parsing and rendering of glTF (.gltf

Chaos 24 Dec 5, 2022
qualysclient - a python SDK for interacting with the Qualys API

qualysclient - a python SDK for interacting with the Qualys API

null 5 Oct 28, 2022
A Python SDK for connecting devices to Microsoft Azure IoT services

V2 - We are now GA! This repository contains code for the Azure IoT SDKs for Python. This enables python developers to easily create IoT device soluti

Microsoft Azure 381 Dec 30, 2022
Tinyman Python SDK

tinyman-py-sdk Tinyman Python SDK Design Goal This SDK is designed for automated interaction with the Tinyman AMM. It will be most useful for develope

Tinyman 113 Dec 30, 2022