diff options
| author | Yuval Adam <_@yuv.al> | 2021-12-31 11:05:24 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2021-12-31 11:05:24 +0200 |
| commit | 361da8e734f63c1ce9391085399e258388ebd45e (patch) | |
| tree | 8da731248b4588cbf519518c3034f7b967e88ddd | |
| parent | 9aa2e675f538bbcdf0d5bd1d27f39fceb6bcd30f (diff) | |
Initial structure refactoring
| -rw-r--r-- | Pipfile | 5 | ||||
| -rw-r--r-- | Pipfile.lock | 122 | ||||
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | greenpass/__init__.py | 0 | ||||
| -rw-r--r-- | greenpass/__main__.py | 3 | ||||
| -rw-r--r-- | greenpass/certs/IL-NB-DSC-01.der (renamed from certs/IL-NB-DSC-01.der) | bin | 1052 -> 1052 bytes | |||
| -rw-r--r-- | greenpass/certs/IL-NB-DSC-01.pem (renamed from certs/IL-NB-DSC-01.pem) | 0 | ||||
| -rw-r--r-- | greenpass/certs/RamzorQRPubKey.der (renamed from certs/RamzorQRPubKey.der) | bin | 1313 -> 1313 bytes | |||
| -rw-r--r-- | greenpass/certs/RamzorQRPubKey.pem (renamed from certs/RamzorQRPubKey.pem) | 0 | ||||
| -rw-r--r-- | greenpass/cli.py | 31 | ||||
| -rw-r--r-- | greenpass/tests/__init__.py | 0 | ||||
| -rw-r--r-- | greenpass/tests/test_verifier.py | 0 | ||||
| -rw-r--r-- | greenpass/verifier.py (renamed from verify.py) | 34 |
13 files changed, 162 insertions, 39 deletions
@@ -12,6 +12,9 @@ click = "*" colorama = "*" [dev-packages] +pytest = "*" +black = "*" [scripts] -verify = "python verify.py" +greenpass = "python -m greenpass" +test = "pytest" diff --git a/Pipfile.lock b/Pipfile.lock index 245bf15..3dc289b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ae87784ddff12b0dd87073de786b2bfb79d9660c535ea1b487946b0cfcebecc5" + "sha256": "66090bf6d49afb65adab47769152fd6244d119fa8e97d7aecf5a2bc332a7cfb9" }, "pipfile-spec": 6, "requires": {}, @@ -203,5 +203,123 @@ "version": "==0.1.8" } }, - "develop": {} + "develop": { + "attrs": { + "hashes": [ + "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4", + "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==21.4.0" + }, + "black": { + "hashes": [ + "sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3", + "sha256:a615e69ae185e08fdd73e4715e260e2479c861b5740057fde6e8b4e3b7dd589f" + ], + "index": "pypi", + "version": "==21.12b0" + }, + "click": { + "hashes": [ + "sha256:353f466495adaeb40b6b5f592f9f91cb22372351c84caeb068132442a4518ef3", + "sha256:410e932b050f5eed773c4cda94de75971c89cdb3155a72a0831139a79e5ecb5b" + ], + "index": "pypi", + "version": "==8.0.3" + }, + "iniconfig": { + "hashes": [ + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + ], + "version": "==1.1.1" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, + "packaging": { + "hashes": [ + "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", + "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" + ], + "markers": "python_version >= '3.6'", + "version": "==21.3" + }, + "pathspec": { + "hashes": [ + "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a", + "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1" + ], + "version": "==0.9.0" + }, + "platformdirs": { + "hashes": [ + "sha256:1d7385c7db91728b83efd0ca99a5afb296cab9d0ed8313a45ed8ba17967ecfca", + "sha256:440633ddfebcc36264232365d7840a970e75e1018d15b4327d11f91909045fda" + ], + "markers": "python_version >= '3.7'", + "version": "==2.4.1" + }, + "pluggy": { + "hashes": [ + "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", + "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" + ], + "markers": "python_version >= '3.6'", + "version": "==1.0.0" + }, + "py": { + "hashes": [ + "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719", + "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==1.11.0" + }, + "pyparsing": { + "hashes": [ + "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4", + "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81" + ], + "markers": "python_version >= '3.6'", + "version": "==3.0.6" + }, + "pytest": { + "hashes": [ + "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89", + "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134" + ], + "index": "pypi", + "version": "==6.2.5" + }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" + }, + "tomli": { + "hashes": [ + "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f", + "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c" + ], + "markers": "python_version >= '3.6'", + "version": "==1.2.3" + }, + "typing-extensions": { + "hashes": [ + "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e", + "sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b" + ], + "markers": "python_version >= '3.10'", + "version": "==4.0.1" + } + } } @@ -25,7 +25,7 @@ Generate a Green Pass or Vaccination Certificate at https://corona.health.gov.il Directly verify your `GreenPass.pdf` or `VaccinationCertificate.pdf`: ```bash -$ pipenv run verify -p GreenPass.pdf +$ pipenv run greenpass -p GreenPass.pdf ``` #### Option 2 - from QR code image @@ -33,7 +33,7 @@ $ pipenv run verify -p GreenPass.pdf Save the QR code as a `.png` file (e.g. from screenshot) and execute: ```bash -$ pipenv run verify -i green_pass_image.png +$ pipenv run greenpass -i green_pass_image.png ``` #### Option 3 - from QR code decoded textual content @@ -41,7 +41,7 @@ $ pipenv run verify -i green_pass_image.png Decode the QR code payload yourself, put it in a txt file and then execute: ```bash -$ pipenv run verify -t green_pass_payload.txt +$ pipenv run greenpass -t green_pass_payload.txt ``` ### Output example diff --git a/greenpass/__init__.py b/greenpass/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/greenpass/__init__.py diff --git a/greenpass/__main__.py b/greenpass/__main__.py new file mode 100644 index 0000000..a6f669d --- /dev/null +++ b/greenpass/__main__.py @@ -0,0 +1,3 @@ +from .cli import verify + +verify() diff --git a/certs/IL-NB-DSC-01.der b/greenpass/certs/IL-NB-DSC-01.der Binary files differindex c52c364..c52c364 100644 --- a/certs/IL-NB-DSC-01.der +++ b/greenpass/certs/IL-NB-DSC-01.der diff --git a/certs/IL-NB-DSC-01.pem b/greenpass/certs/IL-NB-DSC-01.pem index f73acd5..f73acd5 100644 --- a/certs/IL-NB-DSC-01.pem +++ b/greenpass/certs/IL-NB-DSC-01.pem diff --git a/certs/RamzorQRPubKey.der b/greenpass/certs/RamzorQRPubKey.der Binary files differindex ad3df76..ad3df76 100644 --- a/certs/RamzorQRPubKey.der +++ b/greenpass/certs/RamzorQRPubKey.der diff --git a/certs/RamzorQRPubKey.pem b/greenpass/certs/RamzorQRPubKey.pem index db3731d..db3731d 100644 --- a/certs/RamzorQRPubKey.pem +++ b/greenpass/certs/RamzorQRPubKey.pem diff --git a/greenpass/cli.py b/greenpass/cli.py new file mode 100644 index 0000000..3546aeb --- /dev/null +++ b/greenpass/cli.py @@ -0,0 +1,31 @@ +import click + +from .verifier import GreenPassVerifier + + +@click.command() +@click.option("-p", "--pdf-path", type=click.Path(exists=True), help="Path to PDF file") +@click.option( + "-i", + "--image-path", + type=click.Path(exists=True), + help="Path to an image with the QR code", +) +@click.option( + "-t", + "--txt-path", + type=click.Path(exists=True), + help="Path to decoded QR code textual content", +) +def verify(pdf_path="", image_path="", txt_path=""): + if image_path: + verifier = GreenPassVerifier.from_qr(image_path) + elif pdf_path: + verifier = GreenPassVerifier.from_pdf(pdf_path) + elif txt_path: + verifier = GreenPassVerifier.from_payload(txt_path) + else: + ctx = click.get_current_context() + click.echo(ctx.get_help()) + ctx.exit() + verifier.verify() diff --git a/greenpass/tests/__init__.py b/greenpass/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/greenpass/tests/__init__.py diff --git a/greenpass/tests/test_verifier.py b/greenpass/tests/test_verifier.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/greenpass/tests/test_verifier.py diff --git a/verify.py b/greenpass/verifier.py index 23823d2..9bfce3b 100644 --- a/verify.py +++ b/greenpass/verifier.py @@ -1,5 +1,5 @@ import base64 -import click + import fitz import json @@ -132,35 +132,3 @@ class GreenPassVerifier(object): pass else: click.secho("❌ Invalid signature!", fg="red", bold=True) - - -@click.command() -@click.option("-p", "--pdf-path", type=click.Path(exists=True), help="Path to PDF file") -@click.option( - "-i", - "--image-path", - type=click.Path(exists=True), - help="Path to an image with the QR code", -) -@click.option( - "-t", - "--txt-path", - type=click.Path(exists=True), - help="Path to decoded QR code textual content", -) -def verify(pdf_path="", image_path="", txt_path=""): - if image_path: - verifier = GreenPassVerifier.from_qr(image_path) - elif pdf_path: - verifier = GreenPassVerifier.from_pdf(pdf_path) - elif txt_path: - verifier = GreenPassVerifier.from_payload(txt_path) - else: - ctx = click.get_current_context() - click.echo(ctx.get_help()) - ctx.exit() - verifier.verify() - - -if __name__ == "__main__": - verify() |
