🐍 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
Create Basic ERC20 token with Solidity, Brownie and Python

Create Basic ERC20 token with Solidity, Brownie and Python Demo Check out Cornell Token on Rinnkeby network with Etherscan. Installation Install brown

Ethan Huang 2 Feb 16, 2022
Ein PY-Skript, mit dem tiled-Editor-Maps bearbeitet werden

tilesetCopyrighter Ein PY-Skript, mit dem tiled-Editor-Maps bearbeitet werden können fügt je Tileset eine custom-Property tilesetCopyright (string) hi

1 Dec 26, 2021
Discondelete, is a Discord self-bot to delete dm's or purge all messages from a guild.

Discondelete Discondelete, is a Discord self-bot to delete dm's or purge all messages from a guild. Report Bug · Request Feature Table of Contents Abo

core 4 Feb 28, 2022
Fetch torrent links from nyaa, according to releases by smoke index.

Nyaa - Smoke's index torrent fetcher Description This script parses the local (or online) anime release index (csv format) made by Big Smoke. And uses

Dinank 21 Jun 08, 2022
⚔️ Fastest tibia bot API

📝 Description tibia bot api using python ⌨ Development ⚙ Running the app python bot.py ✅ ROADMAP Add confidence to floor level to have more accuracy

Lucas Santos 133 Dec 28, 2022
This will create new discord accounts and add them to your server

Discord-Botter This tool will create new discord accounts add them to your server, this tool needs a captcha api like capmonster.cloud or anti-captcha

Shahzain 27 Nov 30, 2022
Manage Proxmox KVM Virtual Machines via Slack bot.

proxmox-slack-bot Create KVM Virtual Machines on Proxmox, the easy way. Not much works works here yet... Setup dev environment Setup fully editable st

Plenus Pyramis 3 Mar 20, 2022
This is to notify you via Discord whenever there is a new beacon.

BeaconNotifier-Discord This is to notify you via Discord whenever there is a new beacon. Make sure you have python3 installed Steps: Create a Discord

26 Dec 28, 2022
Python wrapper for Wikipedia

Wikipedia API Wikipedia-API is easy to use Python wrapper for Wikipedias' API. It supports extracting texts, sections, links, categories, translations

Martin Majlis 369 Dec 30, 2022
An hcaptcha-solving discord account generator; capable of randomizing names, profile pictures, and verifying phone numbers.

discord-account-generator An hcaptcha-solving discord account generator; capable of randomizing names, profile pictures, and verifying phone numbers.

Acier 61 Dec 10, 2022
A Discord token grabber written in Python3, with awesome obfuscation and anti-debug protection.

☣️ Plague ☣️ Plague is a Discord token grabber written in Python3, obfuscated with Kramer, protected from traffic analysers with Scarecrow and using t

Billy 125 Dec 20, 2022
A course on getting started with the Twitter API v2 for academic research

Getting started with the Twitter API v2 for academic research Welcome to this '101 course' on getting started with academic research using the Twitter

@TwitterDev 426 Jan 04, 2023
Add members to unlimited telegram channels and groups

Program Features 📌 Coded with Python version 10. 📌 without the need for a proxy. 📌 without the need for a Telegram ID. 📌 Ability to add infinite p

hack4lx 10 Nov 25, 2022
A simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statistical tables and plots to users as Telegram messages.

telegram-stats-bot Telegram-stats-bot is a simple bot that lives in your Telegram group, logging messages to a Postgresql database and serving statist

22 Dec 26, 2022
AWS Lambda Fast API starter application

AWS Lambda Fast API Fast API starter application compatible with API Gateway and Lambda Function. How to deploy it? Terraform AWS Lambda API is a reus

OBytes 6 Apr 20, 2022
Disctopia-c2 - Windows Backdoor that is controlled through Discord

Disctopia Disctopia Command and Control What is Disctopia? Disctopia is an open

Dimitris Kalopisis 218 Dec 26, 2022
An API wrapper library for opensea api.

Opensea API An API wrapper library for opensea api. Installation pip3 install opensea Usage Retrieving assets: from opensea import get_assets # This

Ankush Singh 38 Jul 17, 2022
Instagram boosting

instagram boosting bot This bot can boost your instagram account! Rules and Instruction Use git clone to download this repository Open cmd/terminal an

Eskimo 4 Oct 20, 2022
A Python library for loading data from a SpaceX Starlink satellite.

Starlink Python A Python library for loading data from a SpaceX Starlink satellite. The goal is to be a simple interface for Starlink. It builds upon

Austin 2 Jan 16, 2022
Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and other financial information. This repository provides an SDK for developing applications to access the NCDS.

Nasdaq Cloud Data Service (NCDS) Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and ot

Nasdaq 8 Dec 01, 2022