1
0
mirror of https://github.com/covidpass-org/covidpass.git synced 2025-02-22 06:27:49 +01:00

generalize client side code we can switch from loyalty to covidcard smoothly

This commit is contained in:
Billy Lo 2021-10-20 10:23:48 -04:00
parent e625cadd00
commit 8b8a08558a
5 changed files with 12 additions and 9 deletions

View File

@ -3,4 +3,5 @@ VERIFIER_HOST=http://localhost:5001/grassroot-verifier/us-central1
HITCOUNT_HOST=http://localhost:8080
REGISTRATION_HOST=http://localhost:5001/grassroot-verifier/us-central1
FUNCTION_SUFFIX=v2
GPAY_BASE_URL=http://localhost:5001/grassroots-gpay/us-central1
GPAY_BASE_URL=http://localhost:5002/grassroots-gpay/us-central1
GPAY_PASS_TYPE=covidcard

View File

@ -12,7 +12,7 @@ import {PayloadBody} from "../src/payload";
import {getPayloadBodyFromFile, processSHCCode} from "../src/process";
import {PassData} from "../src/pass";
import {Photo} from "../src/photo";
import {isIOS, isMacOs, isSafari, osVersion, getUA, browserName, browserVersion} from 'react-device-detect';
import {isIOS, isMacOs, isAndroid, isSafari, osVersion, getUA, browserName, browserVersion} from 'react-device-detect';
import * as Sentry from '@sentry/react';
import Bullet from './Bullet';
import { GPayData } from '../src/gpay';
@ -351,9 +351,9 @@ function Form(): JSX.Element {
let selectedReceipt;
if (payloadBody.rawData.length > 0) { // shc stuff
const sortedKeys = Object.keys(payloadBody.receipts).sort(); // pickup the last key in the receipt table
const sortedKeys = Object.keys(payloadBody.shcReceipt.vaccinations).sort(); // pickup the last key in the receipt table
const lastKey = sortedKeys[sortedKeys.length - 1];
selectedReceipt = payloadBody.receipts[lastKey];
selectedReceipt = payloadBody.shcReceipt.vaccinations[lastKey];
} else {
selectedReceipt = payloadBody.receipts[selectedDose];
}

View File

@ -7,12 +7,12 @@ type ConfigData = {
registrationHost: string
functionSuffix: string
gpayBaseUrl: string
gpayPassType: string
}
export default function handler(req: NextApiRequest, res: NextApiResponse<ConfigData>) {
// Return the API_BASE_URL. This Endpoint allows us to access the env Variable in client javascript
res.status(200).json({apiBaseUrl: process.env.API_BASE_URL, verifierHost: process.env.VERIFIER_HOST, hitcountHost: process.env.HITCOUNT_HOST, registrationHost: process.env.REGISTRATION_HOST, functionSuffix: process.env.FUNCTION_SUFFIX, gpayBaseUrl: process.env.GPAY_BASE_URL})
res.status(200).json({apiBaseUrl: process.env.API_BASE_URL, verifierHost: process.env.VERIFIER_HOST, hitcountHost: process.env.HITCOUNT_HOST, registrationHost: process.env.REGISTRATION_HOST, functionSuffix: process.env.FUNCTION_SUFFIX, gpayBaseUrl: process.env.GPAY_BASE_URL, gpayPassType: process.env.GPAY_PASS_TYPE})
}

View File

@ -16,7 +16,7 @@ reminderNotToRepeat: If you have completed this step before, simply proceed to S
addToWallet: Add to Apple Wallet
addToGooglePay: Add to Google Pay
addToWalletHeader: Add to Wallet / Save as Photo
saveAsPhoto: Save as Photo
saveAsPhoto: Save as Photo Card
createdOnDevice: Your receipt is processed on your device only
piiNotSent: No personally-identifiable information is sent to servers
openSourceTransparent: Source code is open for re-use/contributions on GitHub

View File

@ -52,9 +52,11 @@ export class GPayData {
// Create pass data
const configResponse = await fetch('/api/config')
const apiBaseUrl = (await configResponse.json()).gpayBaseUrl
const configJson = (await configResponse.json())
const apiBaseUrl = configJson.gpayBaseUrl
const gpayPassType = configJson.gpayPassType
const result = await fetch(`${apiBaseUrl}/api/loyalty/create`, {
const result = await fetch(`${apiBaseUrl}/api/${gpayPassType}/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',