stwon/covpasscheck-php

1.5.3 2021-11-20 09:45 UTC

This package is auto-updated.

Last update: 2022-11-20 12:03:00 UTC


README

A PHP library to read and validate EU Digital COVID Certificates.

Install

composer require stwon/covpasscheck-php

Usage

Currently, the library only ships with a file based trust store. You need to download and store valid certificates manually or implement your own custom TrustStore class. The FileTrustStore reads JSON files matching the schema described here. Note that you MUST NOT include the signature part (i.e. first line) of DSC TrustList Update API responses.

$trustStore = new FileTrustStore('./certs.json');
$check = new CovPassCheck($trustStore);

try {
    // This is the scanned QR code content ↓
    $certificate = $check->readCertificate('HC1:...');

    $subject = $certificate->getSubject();

    if ($certificate->isCovered(Target::COVID19, HealthCertificate::TYPE_VACCINATION | HealthCertificate::TYPE_RECOVERY)) {
        $this->line($subject->getFirstName() . ' does conform to 2G rules.');
    } else {
        $this->line($subject->getFirstName() . ' does not conform to 2G rules.');
    }
} catch (InvalidSignatureException $exception) {
    // oh noo
}

License

See LICENSE.md.