Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/app/core/constants/attestations-per-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {AGE_OVER_18_ATTESTATION, MDL_ATTESTATION, PHOTO_ID_ATTESTATION, PID_ATTE
import {AttestationFormat} from "@core/models/attestation/AttestationFormat";
import {AttestationType} from "@core/models/attestation/AttestationType";
import {DataElement} from "@core/models/attestation/AttestationDefinition";
import { ClaimsQuery } from "../models/dcql/DCQL";

export const SUPPORTED_FORMATS: AttestationFormat[] = [
AttestationFormat.MSO_MDOC,
Expand All @@ -16,7 +17,7 @@ export const MDL_MSO_MDOC: MsoMdocAttestation = {
doctype: 'org.iso.18013.5.1.mDL',
namespace: 'org.iso.18013.5.1',
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'org.iso.18013.5.1') },
claimPath: (attribute: DataElement) => { return { namespace: 'org.iso.18013.5.1', claim_name: attribute.identifier } }
claimQuery: (attribute: DataElement) => { return msoMdocClaimQuery('org.iso.18013.5.1', attribute.identifier) }
}

/*---- PID ATTESTATION INSTANCES PER FORMAT ----*/
Expand All @@ -26,14 +27,14 @@ export const PID_MSO_MDOC: MsoMdocAttestation = {
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') },
claimPath: (attribute: DataElement) => { return { namespace: 'eu.europa.ec.eudi.pid.1', claim_name: attribute.identifier } }
claimQuery: (attribute: DataElement) => { return msoMdocClaimQuery('eu.europa.ec.eudi.pid.1', attribute.identifier) }
}
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)}` },
claimPath: (attribute: DataElement) => { return { path: sdJwtVcAttributePath(attribute, AttestationType.PID).split('.') } }
claimQuery: (attribute: DataElement) => { return { path: sdJwtVcAttributePath(attribute, AttestationType.PID).split('.') } }
}

/*---- AGE OVER 18 ATTESTATION INSTANCES PER FORMAT ----*/
Expand All @@ -43,7 +44,7 @@ export const AGE_OVER_18_MSO_MDOC: MsoMdocAttestation = {
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') },
claimPath: (attribute: DataElement) => { return { namespace: 'eu.europa.ec.eudi.pseudonym.age_over_18.1', claim_name: attribute.identifier } }
claimQuery: (attribute: DataElement) => { return msoMdocClaimQuery('eu.europa.ec.eudi.pseudonym.age_over_18.1', attribute.identifier) }
}

/*---- PHOTO ID ATTESTATION INSTANCES PER FORMAT ----*/
Expand All @@ -53,7 +54,7 @@ export const PHOTO_ID_MSO_MDOC: MsoMdocAttestation = {
doctype: 'org.iso.23220.2.photoid.1',
namespace: 'org.iso.23220.photoid.1',
attributePath: (attribute: DataElement) => { return msoMdocAttributePath(attribute, 'org.iso.23220.photoid.1') },
claimPath: (attribute: DataElement) => { return { namespace: 'org.iso.23220.photoid.1', claim_name: attribute.identifier } }
claimQuery: (attribute: DataElement) => { return msoMdocClaimQuery('org.iso.23220.photoid.1', attribute.identifier) }
}

function msoMdocAttributePath(attribute: DataElement, namespace: string): string {
Expand All @@ -69,6 +70,10 @@ function sdJwtVcAttributePath(attribute: DataElement, attestationType: Attestati
return resolvedAttribute;
}

function msoMdocClaimQuery(namespace: string, claimName: string): ClaimsQuery {
return { path: [namespace, claimName], intent_to_retain: false }
}

export const PID_SD_JWT_VC_ATTRIBUTE_MAP: { [id: string]: string } = {
"birth_date": "birthdate",
"age_over_18": "age_equal_or_over.18",
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/models/attestation/Attestations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export type MsoMdocAttestation = {
namespace: string,
attestationDef: AttestationDefinition,
attributePath: (attribute: DataElement) => string,
claimPath: (attribute: DataElement) => ClaimsQuery,
claimQuery: (attribute: DataElement) => ClaimsQuery,
}

export type SdJwtVcAttestation = {
format: AttestationFormat.SD_JWT_VC,
vct: string,
attestationDef: AttestationDefinition
attributePath: (attribute: DataElement) => string,
claimPath: (attribute: DataElement) => ClaimsQuery,
claimQuery: (attribute: DataElement) => ClaimsQuery,
}
15 changes: 6 additions & 9 deletions src/app/core/models/dcql/DCQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@ export type CredentialSetQuery = {
required?: boolean;
};

export type BaseClaimQuery = {
export type ClaimQuery = {
id?: ClaimId;
path: ClaimPath;
values?: Object[];
};

export type JsonClaimQuery = {
path: string[];
};

export type MsoMdocClaimQueryExtension = {
namespace: string;
claim_name: string;
intent_to_retain: boolean;
};

export type ClaimsQuery = BaseClaimQuery &
(JsonClaimQuery | MsoMdocClaimQueryExtension);
export type ClaimsQuery = ClaimQuery &
(ClaimQuery | MsoMdocClaimQueryExtension);


export type QueryId = string;
export type ClaimId = string;
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/dcql-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DCQLService {
return {
type: 'vp_token',
dcql_query: {
credentials: dcqlQueries!,
credentials: dcqlQueries,
},
nonce: uuidv4(),
};
Expand Down Expand Up @@ -71,7 +71,7 @@ export class DCQLService {
selectedAttributes!.includes(dataElement.identifier)
)
.map((dataElement) => {
return attestation!!.claimPath(dataElement);
return attestation!.claimQuery(dataElement);
});

if (claims.length > 0) {
Expand Down