🐍 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
A Telegram Bot to display Codeforces Contest Ranklist

CFRankListBot A bot that displays the top ranks for a Codeforces contest. Participants' Details All the details of a participant is in the utils/__ini

Code IIEST 5 Dec 25, 2021
discord vc exploit to lightly lag vcs

discord-vc-reconnector discord vc exploit to lag vcs how to use open the py file, then open devtools on discord, go to network and join a vc, dont sta

Tesco 30 Aug 09, 2022
Python: Asynchronous client for the Open-Meteo API.

Python: Asynchronous client for the Open-Meteo API. Asynchronous client for the Open-Meteo API. About Open-Meteo offers free weather forecast APIs for

Franck Nijhof 11 Dec 21, 2022
Unofficial Coinbase Python Library

Unofficial Coinbase Python Library Python Library for the Coinbase API for use with three legged oAuth2 and classic API key usage Version 0.3.0 Requir

George Sibble 104 Dec 01, 2022
Go-cqhttp Plugin for EFB QQ Slave.

efb-qq-plugin-go-cqhttp efb-qq-plugin-go-cqhttp 是 efb-qq-slave 的插件,需要配合 efb-qq-slave 使用,使用前请先阅读 efb-qq-slave 的文档。

XYenon 26 Dec 11, 2022
Neubot client

Neubot, the network neutrality bot Neubot is a research project on network neutrality of the Nexa Center for Internet & Society at Politecnico di Tori

Neubot 57 Nov 02, 2021
💖 Telegram - Telethon - UserBot 💖

『᭙ꪖ᥅ƺẞø†』 🇮🇳 ⚡ ᭙ꪖ᥅ƺBot Is One Of The Fastest & Smoothest Bot On Telegram Based on Telethon ⚡ Status Of Bot Telegram 🏪 YouTube 📺 Dєρℓογ το нєяοκυ D

Team WarZ 1 Mar 28, 2022
A cs:go cheat/hack made in Python3.

Atomic 💖 Cheat for cs:go written in Python. Features. Glow Esp No Flash Bunny Hop Third Person To-Do. It is prefered to start the cheat when you are

Sofia 6 Feb 12, 2022
Scripts to help you win the Pizza Express

Slice of the Prizes Slice of the Prizes is a Python Script designed to enter the "Slice of the Action" competition hosted by Pizza Express the competi

Luke Bendall 1 Nov 04, 2021
Discord Unverified Token Gen

Discord-Unverified-Token-Gen This is a token gen that was made in an hour and just generates unverified tokens, most will be locked. Usage: in cmd jus

Aran 2 Oct 23, 2022
Github repository started notify 💕

Github repository started notify 💕

4 Aug 06, 2022
Tools to download and aggregate feeds of vaccination clinic location information in the United States.

vaccine-feed-ingest Pipeline for ingesting nationwide feeds of vaccine facilities. Contributing How to Configure your environment (instructions on the

Call the Shots 26 Aug 05, 2022
ELiza music is a telegram music bot project, allow you to play music on voice chat group telegram.

❤️ 𝗘𝗹𝗶𝘇𝗮 𝗠𝘂𝘀𝗶𝗰 ❤️ Unmaintained. The new repo of @MrsElizaRobot is private. (It is no longer based on this source code. The completely rewrit

Team Eliza 2 Dec 08, 2022
Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Keagan Landfried 3 Jul 17, 2022
Wallpaper API from wallpaperscraft.com

wallpaper-api Wallpaper API from https://wallpaperscraft.com for API documentation see https://maajid-wallpaper-api.deta.dev/docs How to Run first, cl

Athallah Muhammad Maajid 2 Apr 06, 2022
The community bot for the Python Discord community

Python Utility Bot This project is a Discord bot specifically for use with the Python Discord server. It provides numerous utilities and other tools t

Python Discord 998 Jan 03, 2023
A Discord bot to play bluffing games like Dobbins or Bobbins

Usage: pip install -r requirements.txt python3 bot.py DISCORD_BOT_TOKEN Gameplay: All commands are case-insensitive, with trailing punctuation and spa

4 May 27, 2022
A pypi package that helps in generating discord bots.

A pypi package that helps in generating discord bots.

PineCode Corp 3 Nov 17, 2021
A Discord bot that rewards players in Minecraft for sending messages on Discord

MCRewards-Discord-Bot A Discord bot that rewards players in Minecraft for sending messages on Discord How to setup: Download this git as a .zip, or cl

3 Dec 26, 2021
Contrastive Language-Audio Pretraining

CLAP Contrastive Language-Audio Pretraining In due time this repo will be full of lovely things, I hope. Feel free to check out the Issues if you're i

Charles Foster 83 Dec 01, 2022