I wanted to try to decode my EU covid passport, and found these instructions for python. I was trying to do it in nodejs which I am more familiar with
There is a 3 stage process
- decode Base 45
- decompress
- extract cose data
I have the code below, but the cose.encrypt.read is hitting the catch method with an error Unknown tag, 18
Any ideas?
const base45 = require("base45");
const zlib = require("zlib");
const cose = require("cose-js");
passport =
"HC1:NCFO...";
// removes HC1:
payload = passport.slice(4);
// returns buffer
const decoded = base45.decode(payload);
// Use inflate https://stackoverflow.com/questions/47652769/zlib-node-js-cant-extract-compressed-data-from-python
const decompressed = zlib.inflateSync(decoded);
console.log(decompressed);
cose.encrypt
.read(decompressed)
.then((buf) => {
console.log("Protected message: " + buf.toString("utf8"));
})
.catch((error) => {
console.log("!!", error);
});