Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for overwritting presentation definition and rename dateOfBirth fields #71

Merged
merged 4 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { authorizationServerMetadataConfiguration } from "../../authorizationSer
import config from "../../../config";
import { VerifierConfigurationInterface } from "../../services/interfaces";
import { InputDescriptorType } from "@wwwallet/ssi-sdk";
import "reflect-metadata";

export type PresentationDefinitionTypeWithFormat = {
title: string;
Expand Down Expand Up @@ -40,7 +41,7 @@ const verifiableIdDescriptor = {
"filter": {}
},
{
"path": ['$.credentialSubject.dateOfBirth'],
"path": ['$.credentialSubject.birthdate'],
"filter": {}
}
]
Expand Down Expand Up @@ -164,7 +165,7 @@ const europeanHealthInsuranceCardDescriptor = {
"filter": {}
},
{
"path": ['$.credentialSubject.dateOfBirth'],
"path": ['$.credentialSubject.birthdate'],
"filter": {}
},
]
Expand All @@ -176,7 +177,7 @@ const europeanHealthInsuranceCardDescriptor = {
const verifiableIdWithBachelorPresentationDefinition = {
"id": "VerifiableIdWithBachelor",
"title": "Verifiable ID and Bachelor Diploma",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, dateOfBirth), Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate)",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, birthdate), Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate)",
"format": { "vc+sd-jwt": { alg: [ 'ES256' ] },jwt_vc_json: { alg: [ 'ES256' ] }, jwt_vp: { alg: [ 'ES256' ] } },
"input_descriptors": [
verifiableIdDescriptor,
Expand All @@ -187,7 +188,7 @@ const verifiableIdWithBachelorPresentationDefinition = {
const verifiableIdWithEuropeanHealthInsuranceCardPresentationDefinition = {
"id": "VerifiableIdWithEuropeanHealthInsuranceCard",
"title": "Verifiable ID and European Health Insurance Card",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, dateOfBirth), EHIC (id, firstName, familyName, personalIdentifier, dateOfBirth)",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, birthdate), EHIC (id, firstName, familyName, personalIdentifier, birthdate)",
"format": { "vc+sd-jwt": { alg: [ 'ES256' ] },jwt_vc_json: { alg: [ 'ES256' ] }, jwt_vp: { alg: [ 'ES256' ] } },
"input_descriptors": [
verifiableIdDescriptor,
Expand All @@ -198,7 +199,7 @@ const verifiableIdWithEuropeanHealthInsuranceCardPresentationDefinition = {
const bachelorWithEuropeanHealthInsuranceCardPresentationDefinition = {
"id": "BachelorWithEuropeanHealthInsuranceCard",
"title": "Bachelor Diploma and European Health Insurance Card",
"description": "Required Fields: Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate), EHIC (id, firstName, familyName, personalIdentifier, dateOfBirth)",
"description": "Required Fields: Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate), EHIC (id, firstName, familyName, personalIdentifier, birthdate)",
"format": { "vc+sd-jwt": { alg: [ 'ES256' ] },jwt_vc_json: { alg: [ 'ES256' ] }, jwt_vp: { alg: [ 'ES256' ] } },
"input_descriptors": [
bachelorDescriptor,
Expand All @@ -209,7 +210,7 @@ const bachelorWithEuropeanHealthInsuranceCardPresentationDefinition = {
const verifiableIdWithBachelorWithEuropeanHealthInsuranceCardPresentationDefinition = {
"id": "VerifiableIdWithBachelorWithEuropeanHealthInsuranceCard",
"title": "Verifiable ID, Bachelor Diploma and European Health Insurance Card",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, dateOfBirth), Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate), EHIC (id, firstName, familyName, personalIdentifier, dateOfBirth)",
"description": "Required Fields: Verifiable ID (type, personalIdentifier, firstName, familyName, dateOfBirth), Bachelor Diploma (id, firstName, familyName, diplomaTitle, grade, eqfLevel, certificateId, dateOfBirth, awardingDate, completionDate), EHIC (id, firstName, familyName, personalIdentifier, birthdate)",
"format": { "vc+sd-jwt": { alg: [ 'ES256' ] },jwt_vc_json: { alg: [ 'ES256' ] }, jwt_vp: { alg: [ 'ES256' ] } },
"input_descriptors": [
verifiableIdDescriptor,
Expand All @@ -231,7 +232,7 @@ const minimalBachelorSdJwtPresentationDefinition = {
const customVerifiableIdSdJwtPresentationDefinition = {
"id": "CustomVerifiableId",
"title": "Custom Verifiable ID",
"description": "Selectable Fields: personalIdentifier, firstName, familyName, dateOfBirth",
"description": "Selectable Fields: personalIdentifier, firstName, familyName, birthdate",
"selectable": true,
"format": { "vc+sd-jwt": { alg: ['ES256'] }, jwt_vc_json: { alg: ['ES256'] }, jwt_vp: { alg: ['ES256'] } },
"input_descriptors": [
Expand Down Expand Up @@ -338,7 +339,7 @@ export class VerifierConfigurationService implements VerifierConfigurationInterf
{
"id": "EuropeanHealthInsuranceCard",
"title": "European HealthInsurance Card",
"description": "Required Fields: id, firstName, familyName, personalIdentifier, dateOfBirth",
"description": "Required Fields: id, firstName, familyName, personalIdentifier, birthdate",
"format": { "vc+sd-jwt": { alg: [ 'ES256' ] },jwt_vc_json: { alg: [ 'ES256' ] }, jwt_vp: { alg: [ 'ES256' ] } },
"input_descriptors": [
europeanHealthInsuranceCardDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ export class EdiplomasBlueprintSdJwt implements SupportedCredentialProtocol {
"completionDate": diploma.completionDate,
"awardingDate": diploma.awardingDate,
"achievement": {
"name": "University Degree Credential",
"description": "A Europass Diploma issued by the University of Athens",
"type": "Bachelor",
"name": "Systems Programming",
"description": "This course examines in depth the Unix environment as a development environment. We will look at the Linux API for the C / C ++ languages as well as the Linux shell. We will cover topics such as: basic Unix commands, shell programming, script languages, programming of system functions in C / C ++ for error handling, creation and termination of processes, sending / receiving signals, low-level input / output system calls, communication between local processes, creation, termination and synchronization of threads, file system management, as well as network programming. This course requires independent and consistent effort from the student.",
"type": "Compulsory",
"image": config.url + "/images/EuropassUoaCard.png"
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { CONSENT_ENTRYPOINT } from "../../authorization/constants";
import { GrantType } from "../../types/oid4vci";
import locale from "../locale";
import * as qrcode from 'qrcode';
import { openidForPresentationReceivingService } from "../../services/instances";
import { openidForPresentationReceivingService, verifierConfigurationService } from "../../services/instances";
import { UserAuthenticationMethod } from "../../types/UserAuthenticationMethod.enum";
import { PresentationDefinitionTypeWithFormat } from "../verifier/VerifierConfigurationService";

export class VIDAuthenticationComponent extends AuthenticationComponent {

Expand Down Expand Up @@ -112,8 +113,9 @@ export class VIDAuthenticationComponent extends AuthenticationComponent {
}


const presentationDefinition = JSON.parse(JSON.stringify(verifierConfigurationService.getPresentationDefinitions().filter(pd => pd.id == "vid")[0])) as PresentationDefinitionTypeWithFormat;

const { url, stateId } = await openidForPresentationReceivingService.generateAuthorizationRequestURL({req, res}, "vid", config.url + CONSENT_ENTRYPOINT);
const { url, stateId } = await openidForPresentationReceivingService.generateAuthorizationRequestURL({req, res}, presentationDefinition, config.url + CONSENT_ENTRYPOINT);

// attach the vid_auth_state with an authorization server state
req.authorizationServerState.vid_auth_state = stateId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { authorizationServerMetadataConfiguration } from "../../authorizationSer
import config from "../../../config";
import { VerifierConfigurationInterface } from "../../services/interfaces";
import { InputDescriptorType } from "@wwwallet/ssi-sdk";
import "reflect-metadata";

export type PresentationDefinitionTypeWithFormat = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class EHICSupportedCredentialSdJwt implements SupportedCredentialProtocol
firstName: ehicEntry.firstName,
id: holderDID,
personalIdentifier: ehicEntry.personalIdentifier,
dateOfBirth: ehicEntry.birthdate
birthdate: ehicEntry.birthdate
} as any;

const payload = {
Expand All @@ -102,7 +102,7 @@ export class EHICSupportedCredentialSdJwt implements SupportedCredentialProtocol
const disclosureFrame = {
vc: {
credentialSubject: {
dateOfBirth: true,
birthdate: true,
personalIdentifier: true,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { CONSENT_ENTRYPOINT } from "../../authorization/constants";
import { GrantType } from "../../types/oid4vci";
import locale from "../locale";
import * as qrcode from 'qrcode';
import { openidForPresentationReceivingService } from "../../services/instances";
import { openidForPresentationReceivingService, verifierConfigurationService } from "../../services/instances";
import { UserAuthenticationMethod } from "../../types/UserAuthenticationMethod.enum";
import { PresentationDefinitionTypeWithFormat } from "../verifier/VerifierConfigurationService";

export class VIDAuthenticationComponent extends AuthenticationComponent {

Expand Down Expand Up @@ -112,8 +113,9 @@ export class VIDAuthenticationComponent extends AuthenticationComponent {
}


const presentationDefinition = JSON.parse(JSON.stringify(verifierConfigurationService.getPresentationDefinitions().filter(pd => pd.id == "vid")[0])) as PresentationDefinitionTypeWithFormat;

const { url, stateId } = await openidForPresentationReceivingService.generateAuthorizationRequestURL({req, res}, "vid", config.url + CONSENT_ENTRYPOINT);
const { url, stateId } = await openidForPresentationReceivingService.generateAuthorizationRequestURL({req, res}, presentationDefinition, config.url + CONSENT_ENTRYPOINT);

// attach the vid_auth_state with an authorization server state
req.authorizationServerState.vid_auth_state = stateId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { authorizationServerMetadataConfiguration } from "../../authorizationSer
import config from "../../../config";
import { VerifierConfigurationInterface } from "../../services/interfaces";
import { InputDescriptorType } from "@wwwallet/ssi-sdk";
import "reflect-metadata";

export type PresentationDefinitionTypeWithFormat = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class VIDSupportedCredentialSdJwt implements SupportedCredentialProtocol
familyName: vidEntry.familyName,
firstName: vidEntry.firstName,
personalIdentifier: vidEntry.personalIdentifier,
dateOfBirth: vidEntry.birthdate
birthdate: vidEntry.birthdate
} as any;

const payload = {
Expand Down Expand Up @@ -107,7 +107,7 @@ export class VIDSupportedCredentialSdJwt implements SupportedCredentialProtocol
credentialSubject: {
familyName: true,
firstName: true,
dateOfBirth: true,
birthdate: true,
personalIdentifier: true,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { authorizationServerMetadataConfiguration } from "../../authorizationSer
import config from "../../../config";
import { VerifierConfigurationInterface } from "../../services/interfaces";
import { InputDescriptorType } from "@wwwallet/ssi-sdk";
import "reflect-metadata";

export type PresentationDefinitionTypeWithFormat = {
id: string;
Expand Down