🐍 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
Insane Weather Bot is here! Give suggestions, fork, and do much more to help us enhance the abilities of Insane Weather Bot.

Insane_Weather_Bot Insane Weather Bot is here! Give suggestions, fork, and do much more to help us enhance the abilities of Insane Weather Bot. Weathe

1 Jan 02, 2022
A telegram user and chat info extractor with pyrogram python module

Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.com/FayasNoushad/Telegram-Info/blob/main/LICENSE

Fayas Noushad 8 Dec 22, 2021
Data Platform com AWS CDK

Welcome to your CDK Python project! This is a blank project for Python development with CDK. The cdk.json file tells the CDK Toolkit how to execute yo

Andre Sionek 8 Jul 02, 2022
Wrapper for Gismeteo.ru.

pygismeteo Обёртка для Gismeteo.ru. Асинхронная версия здесь. Установка python -m pip install -U pygismeteo Документация https://pygismeteo.readthedoc

Almaz 7 Dec 26, 2022
A simple tool that lets you know when you are out of Lost Ark's queues

Overview A simple tool that lets you know when you are out of Lost Ark's queues. You can be notified via: Sound: the app will play a sound Discord web

Nelson 3 Feb 15, 2022
Community-based extensions for the python-telegram-bot library.

Community-based extensions for the python-telegram-bot library. Table of contents Introduction Installing Getting help Contributing License Introducti

74 Dec 24, 2022
Python binding for Microsoft LightGBM

pyLightGBM: python binding for Microsoft LightGBM Features: Regression, Classification (binary, multi class) Feature importance (clf.feature_importanc

Ardalan 330 Nov 18, 2022
Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

1 May 20, 2022
Python SDK for 42DI

42di Python SDK Install pip install git+https://github.com/42di/python-sdk import import di #42di import pandas_datareader as pdr Init SDK project =

42DI 2 Nov 03, 2021
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 08, 2023
This bot will automatically like and follow users that post under a specified hashtag

Instagram-bot This bot will automatically like and follow users that post under a specified hashtag Dependencies Java JDK Selenium Updated version of

Makana Edwards 1 Nov 04, 2021
Sadew Jayasekara 23 Oct 21, 2022
BioThings API framework - Making high-performance API for biological annotation data

BioThings SDK Quick Summary BioThings SDK provides a Python-based toolkit to build high-performance data APIs (or web services) from a single data sou

BioThings 39 Jan 04, 2023
Discord bot that generates boba drinks. Submission for sunhacks 2021

boba-bot Team Poggies' submission for Sunhacks 2021. Find our project page on Devpost, and a video demonstration can be found on YouTube. Commands $he

Joshua Tenorio 3 Nov 02, 2022
Validate all your Customer IAM Policies against AWS Access Analyzer - Policy Validation

✅ Access Analyzer - Batch Policy Validator This script will analyze using AWS Access Analyzer - Policy Validation all your account customer managed IA

Victor GRENU 41 Dec 12, 2022
🐙 Share your Github stats for 2020 on Twitter

Year on Github 🐙 Share your Github stats for 2020 on Twitter. This project contains a small web app that let's you share stats about your Github acti

Johannes Rieke 129 Dec 25, 2022
Kanata Bot - a modular bot running on python3 with anime theme and have a lot features

Kanata Bot Kanata Bot is a modular bot running on python3 with anime theme and have a lot features. Easiest Way To Deploy On Heroku This Bot is Create

Rikka-Chan 2 Jan 16, 2022
Exporta archivos masivamente del TEC Digital.

TEC Digital Files Exporter Script que permite exportar los archivos de cursos del TEC Digital del Instituto Tecnológico de Costa Rica, debido al borra

Joseph Vargas 22 Apr 08, 2021
Checks instagram names to see if they're available

How to install You must have python 3.7.6 installed and make sure you click the 'ADD TO PATH' option when installing Open cmd and type pip install aio

2 Oct 20, 2021
Andrei 1.4k Dec 24, 2022