|
1 | 1 | import {Attestation, MsoMdocAttestation, SdJwtVcAttestation} from "@core/models/attestation/Attestations"; |
2 | | -import {AGE_OVER_18_ATTESTATION, MDL_ATTESTATION, PHOTO_ID_ATTESTATION, PID_ATTESTATION} from "@core/constants/attestation-definitions"; |
| 2 | +import {AGE_OVER_18_ATTESTATION, EHIC_ATTESTATION, MDL_ATTESTATION, PDA1_ATTESTATION, PHOTO_ID_ATTESTATION, PID_ATTESTATION} from "@core/constants/attestation-definitions"; |
3 | 3 | import {AttestationFormat} from "@core/models/attestation/AttestationFormat"; |
4 | 4 | import {AttestationType} from "@core/models/attestation/AttestationType"; |
5 | 5 | import {DataElement} from "@core/models/attestation/AttestationDefinition"; |
@@ -57,8 +57,46 @@ export const PHOTO_ID_MSO_MDOC: MsoMdocAttestation = { |
57 | 57 | claimQuery: (attribute: DataElement) => { return msoMdocClaimQuery('org.iso.23220.photoid.1', attribute.identifier) } |
58 | 58 | } |
59 | 59 |
|
| 60 | +/*---- EHIC INSTANCES PER FORMAT ----*/ |
| 61 | +export const EHIC_MSO_MDOC: MsoMdocAttestation = { |
| 62 | + format: AttestationFormat.MSO_MDOC, |
| 63 | + attestationDef: EHIC_ATTESTATION, |
| 64 | + doctype: 'eu.europa.ec.eudi.ehic.1', |
| 65 | + namespace: 'eu.europa.ec.eudi.ehic.1', |
| 66 | + attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'eu.europa.ec.eudi.ehic.1') }, |
| 67 | + claimPath: (attribute: DataElement) => { return { namespace: 'eu.europa.ec.eudi.ehic.1', claim_name: attribute.identifier } } |
| 68 | +} |
| 69 | +export const EHIC_SD_JWT_VC: SdJwtVcAttestation = { |
| 70 | + format: AttestationFormat.SD_JWT_VC, |
| 71 | + attestationDef: EHIC_ATTESTATION, |
| 72 | + vct: 'urn:eu.europa.ec.eudi:ehic:1', |
| 73 | + attributePath: (attribute: DataElement) => { return `$.${sdJwtVcAttributePath(attribute, AttestationType.EHIC)}` }, |
| 74 | + claimPath: (attribute: DataElement) => { return { path: sdJwtVcAttributePath(attribute, AttestationType.EHIC).split('.') } } |
| 75 | +} |
| 76 | + |
| 77 | +/*---- PDA1 INSTANCES PER FORMAT ----*/ |
| 78 | +export const PDA1_MSO_MDOC: MsoMdocAttestation = { |
| 79 | + format: AttestationFormat.MSO_MDOC, |
| 80 | + attestationDef: PDA1_ATTESTATION, |
| 81 | + doctype: 'eu.europa.ec.eudi.pda1.1', |
| 82 | + namespace: 'eu.europa.ec.eudi.pda1.1', |
| 83 | + attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'eu.europa.ec.eudi.pda1.1') }, |
| 84 | + claimPath: (attribute: DataElement) => { return { namespace: 'eu.europa.ec.eudi.pda1.1', claim_name: attribute.identifier } } |
| 85 | +} |
| 86 | +export const PDA1_SD_JWT_VC: SdJwtVcAttestation = { |
| 87 | + format: AttestationFormat.SD_JWT_VC, |
| 88 | + attestationDef: PDA1_ATTESTATION, |
| 89 | + vct: 'urn:eu.europa.ec.eudi:pda1:1', |
| 90 | + attributePath: (attribute: DataElement) => { return `$.${sdJwtVcAttributePath(attribute, AttestationType.PDA1)}` }, |
| 91 | + claimPath: (attribute: DataElement) => { return { path: sdJwtVcAttributePath(attribute, AttestationType.PDA1).split('.') } } |
| 92 | +} |
| 93 | + |
60 | 94 | function msoMdocAttributePath(attribute: DataElement, namespace: string): string { |
61 | | - return '$[\'' + namespace + '\'][\'' + attribute.identifier + '\']' |
| 95 | + if(attribute.identifier.includes('.')) { |
| 96 | + return '$[\'' + namespace + '\'][\'' + attribute.identifier.split('.').join('\'][\'') + '\']' |
| 97 | + } else { |
| 98 | + return '$[\'' + namespace + '\'][\'' + attribute.identifier + '\']' |
| 99 | + } |
62 | 100 | } |
63 | 101 |
|
64 | 102 | function sdJwtVcAttributePath(attribute: DataElement, attestationType: AttestationType): string { |
@@ -93,8 +131,8 @@ export const PID_SD_JWT_VC_ATTRIBUTE_MAP: { [id: string]: string } = { |
93 | 131 | } |
94 | 132 |
|
95 | 133 | export const ATTESTATIONS_BY_FORMAT: { [id: string]: Attestation[] } = { |
96 | | - "mso_mdoc": [PID_MSO_MDOC, MDL_MSO_MDOC, PHOTO_ID_MSO_MDOC, AGE_OVER_18_MSO_MDOC], |
97 | | - "vc+sd-jwt": [PID_SD_JWT_VC] |
| 134 | + "mso_mdoc": [PID_MSO_MDOC, MDL_MSO_MDOC, PHOTO_ID_MSO_MDOC, AGE_OVER_18_MSO_MDOC, EHIC_MSO_MDOC, PDA1_MSO_MDOC], |
| 135 | + "vc+sd-jwt": [PID_SD_JWT_VC, EHIC_SD_JWT_VC, PDA1_SD_JWT_VC] |
98 | 136 | } |
99 | 137 |
|
100 | 138 | export const getAttestationByFormatAndType = |
|
0 commit comments