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);
|
||||
}
|
||||
|
||||
|
||||
if (e.message != undefined) {
|
||||
setFileErrorMessage(e.message);
|
||||
} else {
|
||||
|
@ -448,7 +447,7 @@ function Form(): JSX.Element {
|
|||
|
||||
<input type='file'
|
||||
id='file'
|
||||
accept="application/pdf,.png"
|
||||
accept="application/pdf"
|
||||
ref={inputFile}
|
||||
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://vaccine-ontario.ca" className="underline">{t('common:returnToMainSite')}</a>
|
||||
</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>
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
@ -73,7 +73,7 @@ const issuers = [
|
|||
id: "ca.ab",
|
||||
iss: "https://covidrecords.alberta.ca/smarthealth/issuer",
|
||||
keys: [
|
||||
{ kid: "JoO-sJHpheZboXdsUK4NtfulfvpiN1GlTdNnXN3XAnM",
|
||||
{ kid: "JoO-sJHpheZboXdsUK4NtfulfvpiN1GlTdNnXN3XAnM",
|
||||
alg: "ES256", kty: "EC", crv: "P-256", use: "sig" }
|
||||
]
|
||||
}
|
||||
|
|
|
@ -275,24 +275,34 @@ async function processSHC(fileBuffer : ArrayBuffer) : Promise<any> {
|
|||
|
||||
try {
|
||||
const typedArray = new Uint8Array(fileBuffer);
|
||||
let loadingTask = PdfJS.getDocument(typedArray);
|
||||
const loadingTask = PdfJS.getDocument(typedArray);
|
||||
|
||||
const pdfDocument = await loadingTask.promise;
|
||||
console.log('SHC PDF loaded');
|
||||
// Load all dose numbers
|
||||
const pdfPage = await pdfDocument.getPage(1);
|
||||
console.log('SHC PDF Page 1 loaded');
|
||||
const imageData = await getImageDataFromPdf(pdfPage);
|
||||
console.log('SHC PDF Page 1 image data loaded');
|
||||
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);
|
||||
|
||||
let decoded = await decodeJWS(jws);
|
||||
const decoded = await decodeJWS(jws);
|
||||
|
||||
// console.log(decoded);
|
||||
|
||||
const verified = verifyJWS(jws, decoded.iss);
|
||||
|
||||
if (verified) {
|
||||
let receipts = Decode.decodedStringToReceipt(decoded);
|
||||
const receipts = Decode.decodedStringToReceipt(decoded);
|
||||
//console.log(receipts);
|
||||
return Promise.resolve({receipts: receipts, rawData: rawData});
|
||||
|
||||
|
@ -301,7 +311,8 @@ async function processSHC(fileBuffer : ArrayBuffer) : Promise<any> {
|
|||
}
|
||||
|
||||
} catch (e) {
|
||||
Promise.reject(e);
|
||||
Sentry.captureException(e);
|
||||
return Promise.reject(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Integrations } from '@sentry/tracing';
|
|||
|
||||
export const initSentry = () => {
|
||||
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',
|
||||
integrations: [
|
||||
new Integrations.BrowserTracing(),
|
||||
|
|
Loading…
Reference in New Issue