Try to improve handling on image-only PDFs which are detected as QC SHC PDFs
* Also remove .png from select box since we don't actually support it right now
This commit is contained in:
parent
38a02e5d00
commit
384624605a
|
@ -141,7 +141,6 @@ function Form(): JSX.Element {
|
||||||
Sentry.captureException(e);
|
Sentry.captureException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (e.message != undefined) {
|
if (e.message != undefined) {
|
||||||
setFileErrorMessage(e.message);
|
setFileErrorMessage(e.message);
|
||||||
} else {
|
} else {
|
||||||
|
@ -448,7 +447,7 @@ function Form(): JSX.Element {
|
||||||
|
|
||||||
<input type='file'
|
<input type='file'
|
||||||
id='file'
|
id='file'
|
||||||
accept="application/pdf,.png"
|
accept="application/pdf"
|
||||||
ref={inputFile}
|
ref={inputFile}
|
||||||
style={{display: 'none'}}
|
style={{display: 'none'}}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -36,7 +36,7 @@ function Page(props: PageProps): JSX.Element {
|
||||||
<a href="https://github.com/billylo1/covidpass" className="underline">{t('common:gitHub')}</a>
|
<a href="https://github.com/billylo1/covidpass" className="underline">{t('common:gitHub')}</a>
|
||||||
<a href="https://vaccine-ontario.ca" className="underline">{t('common:returnToMainSite')}</a>
|
<a href="https://vaccine-ontario.ca" className="underline">{t('common:returnToMainSite')}</a>
|
||||||
</nav>
|
</nav>
|
||||||
<div className="flex pt-4 flex-row space-x-4 justify-center text-md flex-wrap">Last updated: 2021-10-06 (v1.9.20)</div>
|
<div className="flex pt-4 flex-row space-x-4 justify-center text-md flex-wrap">Last updated: 2021-10-06 (v1.9.22)</div>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -73,7 +73,7 @@ const issuers = [
|
||||||
id: "ca.ab",
|
id: "ca.ab",
|
||||||
iss: "https://covidrecords.alberta.ca/smarthealth/issuer",
|
iss: "https://covidrecords.alberta.ca/smarthealth/issuer",
|
||||||
keys: [
|
keys: [
|
||||||
{ kid: "JoO-sJHpheZboXdsUK4NtfulfvpiN1GlTdNnXN3XAnM",
|
{ kid: "JoO-sJHpheZboXdsUK4NtfulfvpiN1GlTdNnXN3XAnM",
|
||||||
alg: "ES256", kty: "EC", crv: "P-256", use: "sig" }
|
alg: "ES256", kty: "EC", crv: "P-256", use: "sig" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,24 +275,34 @@ async function processSHC(fileBuffer : ArrayBuffer) : Promise<any> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const typedArray = new Uint8Array(fileBuffer);
|
const typedArray = new Uint8Array(fileBuffer);
|
||||||
let loadingTask = PdfJS.getDocument(typedArray);
|
const loadingTask = PdfJS.getDocument(typedArray);
|
||||||
|
|
||||||
const pdfDocument = await loadingTask.promise;
|
const pdfDocument = await loadingTask.promise;
|
||||||
|
console.log('SHC PDF loaded');
|
||||||
// Load all dose numbers
|
// Load all dose numbers
|
||||||
const pdfPage = await pdfDocument.getPage(1);
|
const pdfPage = await pdfDocument.getPage(1);
|
||||||
|
console.log('SHC PDF Page 1 loaded');
|
||||||
const imageData = await getImageDataFromPdf(pdfPage);
|
const imageData = await getImageDataFromPdf(pdfPage);
|
||||||
|
console.log('SHC PDF Page 1 image data loaded');
|
||||||
const code : QRCode = await Decode.getQRFromImage(imageData);
|
const code : QRCode = await Decode.getQRFromImage(imageData);
|
||||||
let rawData = code.data;
|
console.log('SHC code detected:');
|
||||||
|
console.log(code);
|
||||||
|
|
||||||
|
if (!code) {
|
||||||
|
return Promise.reject('No valid ON proof-of-vaccination digital signature found! Please make sure you download the PDF directly from covid19.ontariohealth.ca, Save as Files on your iPhone, and do NOT save/print it as a PDF!');
|
||||||
|
}
|
||||||
|
|
||||||
|
const rawData = code.data;
|
||||||
const jws = getScannedJWS(rawData);
|
const jws = getScannedJWS(rawData);
|
||||||
|
|
||||||
let decoded = await decodeJWS(jws);
|
const decoded = await decodeJWS(jws);
|
||||||
|
|
||||||
// console.log(decoded);
|
// console.log(decoded);
|
||||||
|
|
||||||
const verified = verifyJWS(jws, decoded.iss);
|
const verified = verifyJWS(jws, decoded.iss);
|
||||||
|
|
||||||
if (verified) {
|
if (verified) {
|
||||||
let receipts = Decode.decodedStringToReceipt(decoded);
|
const receipts = Decode.decodedStringToReceipt(decoded);
|
||||||
//console.log(receipts);
|
//console.log(receipts);
|
||||||
return Promise.resolve({receipts: receipts, rawData: rawData});
|
return Promise.resolve({receipts: receipts, rawData: rawData});
|
||||||
|
|
||||||
|
@ -301,7 +311,8 @@ async function processSHC(fileBuffer : ArrayBuffer) : Promise<any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Promise.reject(e);
|
Sentry.captureException(e);
|
||||||
|
return Promise.reject(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Integrations } from '@sentry/tracing';
|
||||||
|
|
||||||
export const initSentry = () => {
|
export const initSentry = () => {
|
||||||
SentryModule.init({
|
SentryModule.init({
|
||||||
release: 'grassroots_covidpass@1.9.20', // App version. Needs to be manually updated as we go unless we make the build smarter
|
release: 'grassroots_covidpass@1.9.22', // App version. Needs to be manually updated as we go unless we make the build smarter
|
||||||
dsn: 'https://7120dcf8548c4c5cb148cdde2ed6a778@o1015766.ingest.sentry.io/5981424',
|
dsn: 'https://7120dcf8548c4c5cb148cdde2ed6a778@o1015766.ingest.sentry.io/5981424',
|
||||||
integrations: [
|
integrations: [
|
||||||
new Integrations.BrowserTracing(),
|
new Integrations.BrowserTracing(),
|
||||||
|
|
Loading…
Reference in New Issue