🐍 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
Automatically check for free Anmeldung appointments.

Berlin Anmeldung Appointments (Python) This Python script will automatically check for free Anmeldung appointments in Berlin, and find them for you. T

Martín Aberastegue 6 May 19, 2022
Rio Userbot Adalah Bot Untuk Membantu Mempermudahkan Sesuatu Di Telegram, Last Repository With Pytgcalls v0.8.3

RIO - USERBOT Disclaimer Saya tidak bertanggung jawab atas penyalahgunaan bot ini. Bot ini dimaksudkan untuk bersenang-senang sekaligus membantu Anda

RioProjectX 4 Oct 18, 2022
A liblary whre you can find helpful functions for your discord bot

DBotUtils A liblary whre you can find helpful functions for your discord bot Easy setup Setup is easily and flexible. Change anytime. After setup just

Kondek286 1 Nov 02, 2021
An Async Bot/API wrapper for Twitch made in Python.

TwitchIO is an asynchronous Python wrapper around the Twitch API and IRC, with a powerful command extension for creating Twitch Chat Bots. TwitchIO co

TwitchIO 590 Jan 03, 2023
A Telegram bot that scrapes websites for available vaccination appointments to notify users. (German)

@dachau_impf_bot 🇬🇧 A Telegram bot to check the contents of https://termin.dachau-med.de for available slots and inform users of the available dates

1 Nov 21, 2021
The public discord bot, created by: primitt, further developed by: duino-coin team.

Duino Stats Mini A public Duino-Stats Discord bot. Click this link to invite the bot to your server. License Duino Stats Mini distributed under the MI

primboi 8 Mar 14, 2022
Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user

Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user.

Parthesh Soni 1 Jan 24, 2022
My homeserver setup. Everything managed securely using Portainer.

homeserver-traefik-portainer Features: access all services with free TLS from letsencrypt using your own domain running a side project is super simple

Tomasz Wójcik 44 Jan 03, 2023
A Discord/Xenforo bot!

telathbot A Discord/Xenforo bot! Pre-requisites pyenv (via installer) poetry Docker (with Go version of docker compose enabled) Local development Crea

Telath 4 Mar 09, 2022
Automatic SystemVerilog linting in github actions with the help of Verible

Verible Lint Action Usage See action.yml This is a GitHub Action used to lint Verilog and SystemVerilog source files and comment erroneous lines of co

CHIPS Alliance 10 Dec 26, 2022
A very basic starter bot based on CryptoKKing with a small balance

starterbot A very basic starter bot based on CryptoKKing with a small balance, use at your own risk. I have since upgraded this script significantly a

Danny Kendrick 2 Dec 05, 2021
A Discord bot written in Python that can be used to control event management on a server.

Event Management Discord Bot A Discord bot written in Python that can be used to control event management on a Discord server. Made originally for GDS

Suvaditya Mukherjee 2 Dec 07, 2021
A Really Simple and Advanced Google Colab NoteBook to Setup and start using Rclone on Google Colab easily.

Rclone on Google Colab (Advanced!) 🔥 1.Setup and Start using Rclone on Google Colab and Create/Edit/View and delete your Rclone config file and keep

Dr.Caduceus 14 May 24, 2022
A tool for extracting plain text from Wikipedia dumps

WikiExtractor WikiExtractor.py is a Python script that extracts and cleans text from a Wikipedia database dump. The tool is written in Python and requ

Giuseppe Attardi 3.2k Dec 31, 2022
Scrape Twitter for Tweets

Backers Thank you to all our backers! 🙏 [Become a backer] Sponsors Support this project by becoming a sponsor. Your logo will show up here with a lin

Ahmet Taspinar 2.2k Jan 02, 2023
SEMID - OSINT module with lots of discord functions

SEMID Framework About Semid is a framework with different Discord functions and

Hima 20 Sep 23, 2022
Melissa Songs is a telegram bot to easily find songs sending music snippets and search tracks 💃🏽🎵

Find songs on Telegram, like on Shazam... 😎 Open on telegram · Report Bug · Request Feature ⬇️ Installation To get a local copy installed and working

Joaquim Roque 21 Nov 10, 2022
Modified Version of mega.py package for Pyrogram Bots

Pyro Mega.py Python library for the Mega.co.nz API, currently supporting: login uploading downloading deleting searching sharing renaming moving files

I'm Not A Bot #Left_TG 10 Aug 03, 2022
Clash of Clans developer unofficial api Wrapper to generate ip based token

Clash of Clans developer unofficial api Wrapper to generate ip based token

Aryan Vikash 6 Apr 01, 2022
PR Changes Matrix Builder

Pr-changes-matrix-builder - A Github Action that will output a variable to be used in a matrix strategy job based on a PR&'s changes

Kyle James Walker (he/him) 21 Oct 04, 2022