Revert and improve pass fields

This commit is contained in:
Marvin Sextro 2021-07-26 02:13:59 +02:00
parent 17a09e1e21
commit d280be51ac
2 changed files with 64 additions and 42 deletions

View File

@ -25,7 +25,7 @@ function Page(props: PageProps): JSX.Element {
<footer> <footer>
<nav className="nav flex pt-4 flex-row space-x-4 justify-center text-md font-bold flex-wrap"> <nav className="nav flex pt-4 flex-row space-x-4 justify-center text-md font-bold flex-wrap">
<a href="https://www.paypal.com/paypalme/msextro" className="hover:underline">{t('common:donate')}</a> <a href="https://ko-fi.com/marvinsxtr" className="hover:underline">{t('common:donate')}</a>
<a href="https://github.com/marvinsxtr/covidpass" className="hover:underline">{t('common:gitHub')}</a> <a href="https://github.com/marvinsxtr/covidpass" className="hover:underline">{t('common:gitHub')}</a>
<Link href="/privacy"><a className="hover:underline">{t('common:privacyPolicy')}</a></Link> <Link href="/privacy"><a className="hover:underline">{t('common:privacyPolicy')}</a></Link>
<Link href="/imprint"><a className="hover:underline">{t('common:imprint')}</a></Link> <Link href="/imprint"><a className="hover:underline">{t('common:imprint')}</a></Link>

View File

@ -63,12 +63,16 @@ export class Payload {
throw new Error('certificateData'); throw new Error('certificateData');
} }
// Get name information // Get name and date of birth information
const nameInformation = covidCertificate['nam']; const nameInformation = covidCertificate['nam'];
const dateOfBirth = covidCertificate['dob'];
if (nameInformation == undefined) { if (nameInformation == undefined) {
throw new Error('nameMissing'); throw new Error('nameMissing');
} }
if (dateOfBirth == undefined) {
throw new Error('dobMissing');
}
const firstName = nameInformation['gn']; const firstName = nameInformation['gn'];
const lastName = nameInformation['fn']; const lastName = nameInformation['fn'];
@ -106,10 +110,17 @@ export class Payload {
throw new Error('certificateType') throw new Error('certificateType')
} }
// Get identifier and issuer // Get country, identifier and issuer
const countryCode = properties['co'];
const uvci = properties['ci']; const uvci = properties['ci'];
const certificateIssuer = properties['is']; const certificateIssuer = properties['is'];
if (!(countryCode in valueSets.countryCodes)) {
throw new Error('invalidCountryCode');
}
const country = valueSets.countryCodes[countryCode].display;
const generic: PassDictionary = { const generic: PassDictionary = {
headerFields: [ headerFields: [
{ {
@ -151,19 +162,10 @@ export class Payload {
this.img2x = dark ? Constants.img2xWhite : Constants.img2xBlack this.img2x = dark ? Constants.img2xWhite : Constants.img2xBlack
this.dark = dark; this.dark = dark;
this.generic = Payload.fillPassData(this.certificateType, generic, properties, valueSets); this.generic = Payload.fillPassData(this.certificateType, generic, properties, valueSets, country, dateOfBirth);
} }
static fillPassData(type: CertificateType, data: PassDictionary, properties: Object, valueSets: ValueSets): PassDictionary { static fillPassData(type: CertificateType, data: PassDictionary, properties: Object, valueSets: ValueSets, country: string, dateOfBirth: string): PassDictionary {
// Get country name
const countryCode = properties['co'];
if (!(countryCode in valueSets.countryCodes)) {
throw new Error('invalidCountryCode');
}
const country = valueSets.countryCodes[countryCode].display;
switch (type) { switch (type) {
case CertificateType.Vaccine: case CertificateType.Vaccine:
const dose = `${properties['dn']}/${properties['sd']}`; const dose = `${properties['dn']}/${properties['sd']}`;
@ -201,13 +203,18 @@ export class Payload {
value: vaccineName value: vaccineName
}, },
{ {
key: "cov", key: "dob",
label: "Country of Vaccination", label: "Date of Birth",
value: country, value: dateOfBirth,
textAlignment: TextAlignment.right textAlignment: TextAlignment.right
} }
]); ]);
data.backFields.push(...[ data.backFields.push(...[
{
key: "cov",
label: "Country of Vaccination",
value: country
},
{ {
key: "manufacturer", key: "manufacturer",
label: "Manufacturer", label: "Manufacturer",
@ -216,7 +223,7 @@ export class Payload {
{ {
key: "disclaimer", key: "disclaimer",
label: "Disclaimer", label: "Disclaimer",
value: "This certificate is only valid in combination with the ID card of the certificate holder and expires one year + 14 days after the last dose. The validity of this certificate was not checked by CovidPass." value: "This certificate is not a travel document. It is only valid in combination with the ID card of the certificate holder and may expire one year + 14 days after the last dose. The validity of this certificate was not checked by CovidPass."
} }
]); ]);
break; break;
@ -253,15 +260,15 @@ export class Payload {
} }
]); ]);
data.auxiliaryFields.push(...[ data.auxiliaryFields.push(...[
{
key: "test",
label: "Test Type",
value: testType
},
{ {
key: "time", key: "time",
label: "Time of Test", label: "Time of Test",
value: testTime, value: testTime
},
{
key: "dob",
label: "Date of Birth",
value: dateOfBirth,
textAlignment: TextAlignment.right textAlignment: TextAlignment.right
}, },
]); ]);
@ -276,11 +283,18 @@ export class Payload {
label: "Testing Centre", label: "Testing Centre",
value: testingCentre value: testingCentre
}); });
data.backFields.push({ data.backFields.push(...[
key: "disclaimer", {
label: "Disclaimer", key: "test",
value: "This certificate is only valid in combination with the ID card of the certificate holder and may expire 24h after the test. The validity of this certificate was not checked by CovidPass." label: "Test Type",
}); value: testType
},
{
key: "disclaimer",
label: "Disclaimer",
value: "This certificate is not a travel document. It is only valid in combination with the ID card of the certificate holder and may expire 24h after the test. The validity of this certificate was not checked by CovidPass."
}
]);
break; break;
case CertificateType.Recovery: case CertificateType.Recovery:
const firstPositiveTestDate = properties['fr']; const firstPositiveTestDate = properties['fr'];
@ -289,12 +303,12 @@ export class Payload {
data.secondaryFields.push(...[ data.secondaryFields.push(...[
{ {
key: "from", key: "until",
label: "Valid From", label: "Valid Until",
value: validFrom, value: validUntil,
}, },
{ {
key: "dov", key: "dot",
label: "Date of positive Test", label: "Date of positive Test",
value: firstPositiveTestDate, value: firstPositiveTestDate,
textAlignment: TextAlignment.right textAlignment: TextAlignment.right
@ -302,22 +316,30 @@ export class Payload {
]); ]);
data.auxiliaryFields.push(...[ data.auxiliaryFields.push(...[
{ {
key: "until", key: "from",
label: "Valid Until", label: "Valid From",
value: validUntil, value: validFrom,
}, },
{ {
key: "cov", key: "dob",
label: "Date of Birth",
value: dateOfBirth,
textAlignment: TextAlignment.right
}
]);
data.backFields.push(...[
{
key: "cot",
label: "Country of Test", label: "Country of Test",
value: country, value: country,
textAlignment: TextAlignment.right textAlignment: TextAlignment.right
}, },
{
key: "disclaimer",
label: "Disclaimer",
value: "This certificate is not a travel document. It is only valid in combination with the ID card of the certificate holder. The validity of this certificate was not checked by CovidPass."
}
]); ]);
data.backFields.push({
key: "disclaimer",
label: "Disclaimer",
value: "This certificate is only valid in combination with the ID card of the certificate holder. The validity of this certificate was not checked by CovidPass."
});
break; break;
default: default:
throw new Error('certificateType'); throw new Error('certificateType');