-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce sd-jwt-vc format in presentation definition preparation
- Loading branch information
Showing
27 changed files
with
430 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import {Attestation, MsoMdocAttestation, SdJwtVcAttestation} from "@core/models/attestation/Attestations"; | ||
import {AGE_OVER_18_ATTESTATION, MDL_ATTESTATION, PHOTO_ID_ATTESTATION, PID_ATTESTATION} from "@core/constants/attestation-definitions"; | ||
import {AttestationFormat} from "@core/models/attestation/AttestationFormat"; | ||
import {AttestationType} from "@core/models/attestation/AttestationType"; | ||
import {DataElement} from "@core/models/attestation/AttestationDefinition"; | ||
|
||
export const SUPPORTED_FORMATS: AttestationFormat[] = [ | ||
AttestationFormat.MSO_MDOC, | ||
AttestationFormat.SD_JWT_VC | ||
] | ||
|
||
/*---- MDL ATTESTATION INSTANCES PER FORMAT ----*/ | ||
export const MDL_MSO_MDOC: MsoMdocAttestation = { | ||
format: AttestationFormat.MSO_MDOC, | ||
attestationDef: MDL_ATTESTATION, | ||
doctype: 'org.iso.18013.5.1.mDL', | ||
namespace: 'org.iso.18013.5.1', | ||
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'org.iso.18013.5.1') } | ||
} | ||
export const MDL_SD_JWT_VC: SdJwtVcAttestation = { | ||
format: AttestationFormat.SD_JWT_VC, | ||
vct: "urn:eu.europa.ec.eudi:pid:1", | ||
attestationDef: MDL_ATTESTATION, | ||
attributePath: (attribute: DataElement) => { return sdJwtVcAttributePath(attribute, AttestationType.MDL) } | ||
} | ||
|
||
/*---- PID ATTESTATION INSTANCES PER FORMAT ----*/ | ||
export const PID_MSO_MDOC: MsoMdocAttestation = { | ||
format: AttestationFormat.MSO_MDOC, | ||
attestationDef: PID_ATTESTATION, | ||
doctype: 'eu.europa.ec.eudi.pid.1', | ||
namespace: 'eu.europa.ec.eudi.pid.1', | ||
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'eu.europa.ec.eudi.pid.1') } | ||
} | ||
export const PID_SD_JWT_VC: SdJwtVcAttestation = { | ||
format: AttestationFormat.SD_JWT_VC, | ||
vct: "urn:eu.europa.ec.eudi:pid:1", | ||
attestationDef: PID_ATTESTATION, | ||
attributePath: (attribute: DataElement) => { return sdJwtVcAttributePath(attribute, AttestationType.PID) } | ||
} | ||
|
||
/*---- AGE OVER 18 ATTESTATION INSTANCES PER FORMAT ----*/ | ||
export const AGE_OVER_18_MSO_MDOC: MsoMdocAttestation = { | ||
format: AttestationFormat.MSO_MDOC, | ||
attestationDef: AGE_OVER_18_ATTESTATION, | ||
doctype: 'eu.europa.ec.eudi.pseudonym.age_over_18.1', | ||
namespace: 'eu.europa.ec.eudi.pseudonym.age_over_18.1', | ||
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'eu.europa.ec.eudi.pseudonym.age_over_18.1') } | ||
} | ||
export const AGE_OVER_18_SD_JWT_VC: SdJwtVcAttestation = { | ||
format: AttestationFormat.SD_JWT_VC, | ||
vct: "urn:eu.europa.ec.eudi:pid:1", | ||
attestationDef: AGE_OVER_18_ATTESTATION, | ||
attributePath: (attribute: DataElement) => { return sdJwtVcAttributePath(attribute, AttestationType.AGE_OVER_18) } | ||
} | ||
|
||
/*---- PHOTO ID ATTESTATION INSTANCES PER FORMAT ----*/ | ||
export const PHOTO_ID_MSO_MDOC: MsoMdocAttestation = { | ||
format: AttestationFormat.MSO_MDOC, | ||
attestationDef: PHOTO_ID_ATTESTATION, | ||
doctype: 'org.iso.23220.2.photoid.1', | ||
namespace: 'org.iso.23220.2.photoid.1', | ||
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'org.iso.23220.2.photoid.1') } | ||
} | ||
export const PHOTO_ID_SD_JWT_VC: SdJwtVcAttestation = { | ||
format: AttestationFormat.SD_JWT_VC, | ||
vct: "urn:eu.europa.ec.eudi:pid:1", | ||
attestationDef: PHOTO_ID_ATTESTATION, | ||
attributePath: (attribute: DataElement) => { return sdJwtVcAttributePath(attribute, AttestationType.PHOTO_ID) } | ||
} | ||
|
||
function msoMdocAttributePath(attribute: DataElement, namespace: string): string { | ||
return '$[\'' + namespace + '\'][\'' + attribute.identifier + '\']' | ||
} | ||
|
||
function sdJwtVcAttributePath(attribute: DataElement, attestationType: AttestationType): string { | ||
let resolvedAttribute = attribute.identifier | ||
if (attestationType === AttestationType.PID) { | ||
let mappedAttribute = PID_SD_JWT_VC_ATTRIBUTE_MAP[attribute.identifier]; | ||
resolvedAttribute = mappedAttribute ? mappedAttribute : attribute.identifier; | ||
} | ||
return '$.' + resolvedAttribute; | ||
} | ||
|
||
export const PID_SD_JWT_VC_ATTRIBUTE_MAP: { [id: string]: string } = { | ||
"birth_date": "birthdate", | ||
"age_over_18": "age_equal_or_over.18", | ||
"age_over_NN": "age_equal_or_over.NN", | ||
"family_name_birth": "birth_family_name", | ||
"given_name_birth": "birth_given_name", | ||
"birth_place": "place_of_birth.locality", | ||
"birth_country": "place_of_birth.country", | ||
"birth_state": "place_of_birth.region", | ||
"birth_city": "place_of_birth.locality", | ||
"resident_address": "address.formatted", | ||
"resident_country": "address.country", | ||
"resident_state": "address.region", | ||
"resident_city": "address.locality", | ||
"resident_postal_code": "address.postal_code", | ||
"resident_street": "address.street_address", | ||
"resident_house_number": "address.house_number", | ||
"gender": "gender", | ||
"nationality": "nationalities", | ||
"issuance_date": "iat", | ||
"expiry_date": "exp" | ||
} | ||
|
||
|
||
export const MSO_MDOC_ATTESTATIONS: { [id: string]: MsoMdocAttestation } = { | ||
"pid": PID_MSO_MDOC, | ||
"mdl": MDL_MSO_MDOC, | ||
"photo_id": PHOTO_ID_MSO_MDOC, | ||
"age_over_18": AGE_OVER_18_MSO_MDOC, | ||
} | ||
|
||
export const ATTESTATIONS_BY_TYPE: { [id: string]: Attestation[] } = { | ||
"pid": [PID_MSO_MDOC, PID_SD_JWT_VC], | ||
"mdl": [MDL_MSO_MDOC, MDL_SD_JWT_VC], | ||
"photo_id": [PHOTO_ID_MSO_MDOC, PHOTO_ID_SD_JWT_VC], | ||
"age_over_18": [AGE_OVER_18_MSO_MDOC, AGE_OVER_18_SD_JWT_VC], | ||
} | ||
|
||
export const ATTESTATIONS_BY_FORMAT: { [id: string]: Attestation[] } = { | ||
"mso_mdoc": [PID_MSO_MDOC, MDL_MSO_MDOC, PHOTO_ID_MSO_MDOC, AGE_OVER_18_MSO_MDOC], | ||
"vc+sd-jwt": [PID_SD_JWT_VC, MDL_SD_JWT_VC, PHOTO_ID_SD_JWT_VC, AGE_OVER_18_SD_JWT_VC] | ||
} | ||
|
||
export const getAttestationByFormatAndType = | ||
(type: AttestationType, format: AttestationFormat): Attestation | null => { | ||
let filtered = ATTESTATIONS_BY_FORMAT[format as string].filter((attestation: Attestation) => | ||
attestation.attestationDef.type === type | ||
); | ||
return filtered ? filtered[0] : null; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pp/core/models/attestation/Attestation.ts → ...dels/attestation/AttestationDefinition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {AttestationDefinition, DataElement} from "@core/models/attestation/AttestationDefinition"; | ||
import {AttestationFormat} from "@core/models/attestation/AttestationFormat"; | ||
|
||
export type Attestation = MsoMdocAttestation | SdJwtVcAttestation; | ||
|
||
export type MsoMdocAttestation = { | ||
format: AttestationFormat.MSO_MDOC, | ||
doctype: string, | ||
namespace: string, | ||
attestationDef: AttestationDefinition, | ||
attributePath: (attribute: DataElement) => string, | ||
} | ||
|
||
export type SdJwtVcAttestation = { | ||
format: AttestationFormat.SD_JWT_VC, | ||
vct: string, | ||
attestationDef: AttestationDefinition | ||
attributePath: (attribute: DataElement) => string, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../models/presentation/SharedAttestation.ts → ...dels/presentation/PresentedAttestation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
src/app/core/services/attestation-selectable-model.service.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {AttestationFormat} from "@core/models/attestation/AttestationFormat"; | ||
import {SharedAttestation} from "@core/models/presentation/SharedAttestation"; | ||
import {PresentedAttestation} from "@core/models/presentation/PresentedAttestation"; | ||
|
||
export interface AttestationDecoder { | ||
supports(format: AttestationFormat): boolean; | ||
decode(attestation: string): SharedAttestation | ||
decode(attestation: string): PresentedAttestation | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.