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