1

Good day. I am creating covid greenpass decoder in React App, and I need help with pako.js. I am trying to inflate Unit8Array which i got from base45 decoding. And I am getting "uncaught incorrect header check" error. I have tried adding {to: "string"} to inflate() method, or using inflateRaw(). I'll be greatful for help. Here's code:

import React from 'react';
import cbor from 'cbor-web';
import base45 from 'base45-js';

const CovidPass = () => {

    const pako = require('pako')

    const decodedBase45 = base45.decode('I2B-KEP2');
    console.log(decodedBase45);
    const decodedPako = pako.inflate(decodedBase45);
    console.log(decodedPako);

    return (
        <>
            <p>{decodedBase45}</p>
        </>
    );
}

export default CovidPass;

decodedBase45 looks like this in console:

Uint8Array(5) [87, 111, 114, 107, 115, buffer: ArrayBuffer(5), byteLength: 5, byteOffset: 0, length: 5, Symbol(Symbol.toStringTag): 'Uint8Array']
0: 87
1: 111
2: 114
3: 107
4: 115
buffer: 
ArrayBuffer(5)
byteLength: 5
byteOffset: 0
length: 5
Symbol(Symbol.toStringTag): "Uint8Array"
[[Prototype]]: Uint8Array

Or maybe you can tell me the way how to do it with zlib?

szemeg
  • 51
  • 1
  • 7
  • The bytes `Works` is obviously not zlib or deflate data. Do you have an actual example of the data you're trying to decode? – Mark Adler Jan 19 '22 at 18:22
  • @MarkAdler what I am trying to do is exactly this: [link](https://dev.to/lmillucci/javascript-how-to-decode-the-greenpass-qr-code-3dh0) . Data looks something like that in link above: `HC1: 6BFOXM% TS3DHPVO13J /G-/2YKVA.R/K86PP2FC1J9M$DI9C3 [....] CS62GMVR + B1YM K5MJ1K: K: 2JZLT6KM + DTVKPDUG $ E7F06FA3O6I-VA126Y0`. And i need it to be decoded by `base45` first, for which I had to downgrade `react-scritpt` to `4.0.3` in `package.json` – szemeg Jan 20 '22 at 08:05
  • Did you follow the directions there? You need to remove the "HC1:" first. Then after base45 decoding, you have a zlib stream. – Mark Adler Jan 20 '22 at 15:57
  • Thank you for the info. I didn't know that there's something like zlib stream, and data should be in specific way. I was so annoyed that functions isn't working that i didn't check it. Thanks again! Which docs do you recommend about this topic in general? Also can you give here an answer ? I'd like to mark it as solved. – szemeg Jan 21 '22 at 07:20

0 Answers0