fix for Apple Pass on new SHC receipts

This commit is contained in:
Billy Lo 2021-10-14 20:19:04 -04:00
parent 5d13a6f1ad
commit 7170372afa
3 changed files with 55 additions and 2 deletions

29
package-lock.json generated
View File

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@headlessui/react": "^1.3.0", "@headlessui/react": "^1.3.0",
"@ninja-labs/verify-pdf": "^0.3.9", "@ninja-labs/verify-pdf": "^0.3.9",
"@nuintun/qrcode": "^3.0.1",
"@sentry/browser": "^6.13.2", "@sentry/browser": "^6.13.2",
"@sentry/integrations": "^6.13.2", "@sentry/integrations": "^6.13.2",
"@sentry/react": "^6.13.2", "@sentry/react": "^6.13.2",
@ -308,6 +309,19 @@
"node": ">= 8" "node": ">= 8"
} }
}, },
"node_modules/@nuintun/qrcode": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@nuintun/qrcode/-/qrcode-3.0.1.tgz",
"integrity": "sha512-0dY347xYgJvmBP0I75UHeVEx7JeDczahhEYaS03uh9bhCqa3FycdtLPxWulQh/r3OsX5lpi+z3mEXfAaQtAPwQ==",
"dependencies": {
"tslib": "^2.0.1"
}
},
"node_modules/@nuintun/qrcode/node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/@sentry/browser": { "node_modules/@sentry/browser": {
"version": "6.13.2", "version": "6.13.2",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz",
@ -5555,6 +5569,21 @@
"fastq": "^1.6.0" "fastq": "^1.6.0"
} }
}, },
"@nuintun/qrcode": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@nuintun/qrcode/-/qrcode-3.0.1.tgz",
"integrity": "sha512-0dY347xYgJvmBP0I75UHeVEx7JeDczahhEYaS03uh9bhCqa3FycdtLPxWulQh/r3OsX5lpi+z3mEXfAaQtAPwQ==",
"requires": {
"tslib": "^2.0.1"
},
"dependencies": {
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}
}
},
"@sentry/browser": { "@sentry/browser": {
"version": "6.13.2", "version": "6.13.2",
"resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz",

View File

@ -3,6 +3,7 @@ import {toBuffer as createZip} from 'do-not-zip';
import {Constants} from "./constants"; import {Constants} from "./constants";
import {Payload, PayloadBody, PassDictionary} from "./payload"; import {Payload, PayloadBody, PassDictionary} from "./payload";
import {QrCode,PassPhotoCommon} from './passphoto-common'; import {QrCode,PassPhotoCommon} from './passphoto-common';
import {COLORS} from "./colors";
const crypto = require('crypto') const crypto = require('crypto')
@ -45,7 +46,7 @@ export class PassData {
const apiBaseUrl = (await configResponse.json()).apiBaseUrl const apiBaseUrl = (await configResponse.json()).apiBaseUrl
// console.log(`${apiBaseUrl}/sign`); // console.log(`${apiBaseUrl}/sign`);
// console.log(JSON.stringify(signData)); console.log(JSON.stringify(signData));
const response = await fetch(`${apiBaseUrl}/sign`, { const response = await fetch(`${apiBaseUrl}/sign`, {
method: 'POST', method: 'POST',
@ -74,6 +75,10 @@ export class PassData {
const pass: PassData = new PassData(results.payload, results.qrCode); const pass: PassData = new PassData(results.payload, results.qrCode);
if (!pass.expirationDate) {
delete pass['expirationDate'];
}
// Create new zip // Create new zip
const zip = [] as { path: string; data: Buffer | string }[]; const zip = [] as { path: string; data: Buffer | string }[];
@ -113,10 +118,12 @@ export class PassData {
// Create pass hash // Create pass hash
const passHash = PassData.getBufferHash(Buffer.from(passJson)); const passHash = PassData.getBufferHash(Buffer.from(passJson));
const useBlackVersion = (payload.backgroundColor == COLORS.WHITE);
// Sign hash with server // Sign hash with server
const manifestSignature = await PassData.signWithRemote({ const manifestSignature = await PassData.signWithRemote({
PassJsonHash: passHash, PassJsonHash: passHash,
useBlackVersion: false, useBlackVersion: useBlackVersion,
}); });
// Add signature to zip // Add signature to zip

View File

@ -145,6 +145,13 @@
"@nodelib/fs.scandir" "2.1.5" "@nodelib/fs.scandir" "2.1.5"
"fastq" "^1.6.0" "fastq" "^1.6.0"
"@nuintun/qrcode@^3.0.1":
"integrity" "sha512-0dY347xYgJvmBP0I75UHeVEx7JeDczahhEYaS03uh9bhCqa3FycdtLPxWulQh/r3OsX5lpi+z3mEXfAaQtAPwQ=="
"resolved" "https://registry.npmjs.org/@nuintun/qrcode/-/qrcode-3.0.1.tgz"
"version" "3.0.1"
dependencies:
"tslib" "^2.0.1"
"@sentry/browser@^6.13.2", "@sentry/browser@6.13.2": "@sentry/browser@^6.13.2", "@sentry/browser@6.13.2":
"integrity" "sha512-bkFXK4vAp2UX/4rQY0pj2Iky55Gnwr79CtveoeeMshoLy5iDgZ8gvnLNAz7om4B9OQk1u7NzLEa4IXAmHTUyag==" "integrity" "sha512-bkFXK4vAp2UX/4rQY0pj2Iky55Gnwr79CtveoeeMshoLy5iDgZ8gvnLNAz7om4B9OQk1u7NzLEa4IXAmHTUyag=="
"resolved" "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz" "resolved" "https://registry.npmjs.org/@sentry/browser/-/browser-6.13.2.tgz"
@ -1473,6 +1480,11 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" "resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0" "version" "1.0.0"
"fsevents@~2.3.1", "fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"
"function-bind@^1.1.1": "function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" "integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" "resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
@ -3315,6 +3327,11 @@
"resolved" "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" "resolved" "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz"
"version" "1.14.1" "version" "1.14.1"
"tslib@^2.0.1":
"integrity" "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
"resolved" "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz"
"version" "2.3.1"
"tty-browserify@0.0.0": "tty-browserify@0.0.0":
"integrity" "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=" "integrity" "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY="
"resolved" "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz" "resolved" "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz"