Unverified Commit d038d4e0 authored by ggrund-tsi's avatar ggrund-tsi Committed by GitHub
Browse files

Fix/expiration for vac and tst (#93)



* calculate expiration

* use expiredDuration from issuance service
Co-authored-by: default avatarGordon Grund <gordon.grund@outlook.de>
parent 23918519
......@@ -225,8 +225,8 @@ const RecordRecoveryCertData = (props: any) => {
showYearDropdown
dropdownMode="select"
maxDate={new Date()}
minDate={new Date(2020, 10)}
openToDate={new Date()}
minDate={new Date(Date.now() - expirationMilSeconds)}
openToDate={dateValidFrom ? dateValidFrom : new Date()}
required
/>
</Col>
......@@ -250,7 +250,7 @@ const RecordRecoveryCertData = (props: any) => {
/>
{/* Date: Certificate Valid From - To */}
<Form.Group as={Row} controlId='formDateOfBirthInput' className='pb-3 mb-0'>
<Form.Group as={Row} controlId='formDateValidFromToInput' className='pb-3 mb-0'>
<Form.Label className='input-label ' column xs='5' sm='3'>{t('translation:cert-valid-from-to') + '*'}</Form.Label>
<Col xs='7' sm='9' className='d-flex'>
......
......@@ -34,7 +34,8 @@ export interface CertificateMetaData {
kid: string,
algId: number,
countryCode: string,
expired: number
expired: number,
expiredDuration: number
}
export interface SignService {
......@@ -64,8 +65,18 @@ const encodeCBOR = (certData: EUDGC, certMetaData: CertificateMetaData): Buffer
const getExpiration = (certData: EUDGC, certMetaData: CertificateMetaData) => {
let result = certMetaData.expired;
if (certData && certData.r && certData.r[0]) {
result = new Date(certData.r[0].du).getTime() / 1000 | 0;
if (certData) {
if (certData.r && certData.r[0] && certData.r[0].du) {
result = new Date(certData.r[0].du).getTime() / 1000 | 0;
}
if (certData.v && certData.v[0] && certData.v[0].dt) {
result = new Date(certData.v[0].dt).getTime() / 1000 + certMetaData.expiredDuration;
}
if (certData.t && certData.t[0] && certData.t[0].sc) {
result = new Date(certData.t[0].sc).getTime() / 1000 + certMetaData.expiredDuration;
}
}
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment