forked from fproulx/shc-covid19-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_shc.js
41 lines (35 loc) · 1009 Bytes
/
dump_shc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const fs = require("fs");
const PNG = require("pngjs").PNG;
const pdf2img = require("pdf2img");
const base64url = require("base64url");
const {
getQRFromImage,
getScannedJWS,
verifyJWS,
decodeJWS,
} = require("./src/shc");
const input = process.argv[2];
if (input === undefined) {
console.log(
"Provide path to PNG screenshot of the PDF (yeah I know, it's hackish for now)"
);
process.exit(-1);
}
imageData = PNG.sync.read(fs.readFileSync(input));
const scannedQR = getQRFromImage(imageData);
const scannedJWS = getScannedJWS(scannedQR.data);
console.log("QR-Code payload --> JWS");
console.log("-----");
console.log(scannedJWS);
console.log("-----");
console.log("JWS Header");
console.log(base64url.decode(scannedJWS.split(".")[0]));
console.log("-----");
verifyJWS(scannedJWS).then(
function (result) {
return decodeJWS(scannedJWS).then((decoded) => console.log(decoded));
},
function (e) {
console.log("Ooooh crap - this looks like a fake vacinnation proof");
}
);