Skip to content

Commit

Permalink
chore: PR feedback (partly)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Oct 10, 2024
1 parent d6854b9 commit d0b4ad4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 144 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parse } from 'querystring'

import { SigningAlgo } from '@sphereon/oid4vc-common'
import { IPresentationDefinition } from '@sphereon/pex'
import { IProofType } from '@sphereon/ssi-types'

import {
Expand All @@ -13,7 +12,7 @@ import {
SubjectIdentifierType,
SubjectType,
SupportedVersion,
URI,
URI
} from '..'
import SIOPErrors from '../types/Errors'

Expand All @@ -24,7 +23,7 @@ import {
VERIFIER_NAME_FOR_CLIENT,
VERIFIER_NAME_FOR_CLIENT_NL,
VERIFIERZ_PURPOSE_TO_VERIFY,
VERIFIERZ_PURPOSE_TO_VERIFY_NL,
VERIFIERZ_PURPOSE_TO_VERIFY_NL
} from './data/mockedData'

const EXAMPLE_REDIRECT_URL = 'https://acme.com/hello'
Expand Down Expand Up @@ -98,26 +97,6 @@ describe('create Request Uri should', () => {
response_type: 'id_token',
request_object_signing_alg_values_supported: [SigningAlgo.EDDSA, SigningAlgo.ES256],
redirect_uri: EXAMPLE_REDIRECT_URL,
claims: {
vp_token: {
presentation_definition: {
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
purpose: 'purpose',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},
requestObject: {
jwtIssuer: {
Expand Down Expand Up @@ -193,26 +172,6 @@ describe('create Request Uri should', () => {
response_type: 'id_token',
request_object_signing_alg_values_supported: [SigningAlgo.ES256, SigningAlgo.EDDSA],
redirect_uri: EXAMPLE_REDIRECT_URL,
claims: {
vp_token: {
presentation_definition: {
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
purpose: 'purpose',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},
requestObject: {
jwtIssuer: { method: 'did', didUrl: KID, alg: SigningAlgo.ES256 },
Expand All @@ -231,26 +190,6 @@ describe('create Request Uri should', () => {
response_type: 'id_token',
request_object_signing_alg_values_supported: [SigningAlgo.ES256, SigningAlgo.EDDSA],
redirect_uri: EXAMPLE_REDIRECT_URL,
claims: {
vp_token: {
presentation_definition: {
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
purpose: 'purpose',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},
},
clientMetadata: {
Expand Down Expand Up @@ -295,26 +234,6 @@ describe('create Request Uri should', () => {
response_type: 'id_token',
request_object_signing_alg_values_supported: [SigningAlgo.ES256, SigningAlgo.EDDSA],
redirect_uri: EXAMPLE_REDIRECT_URL,
claims: {
vp_token: {
presentation_definition: {
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
purpose: 'purpose',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},
requestObject: {
passBy: PassBy.VALUE,
Expand Down Expand Up @@ -612,26 +531,6 @@ describe('create Request JWT should', () => {
response_type: 'id_token',
request_object_signing_alg_values_supported: [SigningAlgo.ES256, SigningAlgo.EDDSA],
redirect_uri: EXAMPLE_REDIRECT_URL,
claims: {
vp_token: {
presentation_definition: {
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
purpose: 'purpose',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
name: 'Ontario',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},
requestObject: {
jwtIssuer: { method: 'did', didUrl: KID, alg: SigningAlgo.ES256K },
Expand All @@ -650,23 +549,6 @@ describe('create Request JWT should', () => {
response_type: 'id_token',
redirect_uri: EXAMPLE_REDIRECT_URL,
request_object_signing_alg_values_supported: [SigningAlgo.EDDSA, SigningAlgo.ES256],
claims: {
vp_token: {
presentation_definition: {
id: 'Insurance Plans',
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
},
},
},
},
},
clientMetadata: {
Expand Down Expand Up @@ -696,7 +578,7 @@ describe('create Request JWT should', () => {
const uriRequest = await URI.fromOpts(opts)

const uriDecoded = decodeURIComponent(uriRequest.encodedUri)
expect(uriDecoded).toEqual(`openid4vp://?client_id=https://www.example.com/.well-known/openid-federation&scope=test&response_type=id_token&request_object_signing_alg_values_supported=[\"ES256\",\"EdDSA\"]&redirect_uri=https://acme.com/hello&claims={"vp_token\":{\"presentation_definition":{\"id\":\"Ontario Health Insurance Plan\",\"name\":"Ontario\",\"purpose":"purpose\","input_descriptors":[{\"id":\"Ontario Health Insurance Plan\",\"name":\"Ontario\",\"schema":[{\"uri\":\"https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan\"}]}]}}}&request_uri=https://rp.acme.com/siop/jwts`)
expect(uriDecoded).toEqual(`openid4vp://?client_id=https://www.example.com/.well-known/openid-federation&scope=test&response_type=id_token&request_object_signing_alg_values_supported=["ES256","EdDSA"]&redirect_uri=https://acme.com/hello&claims={"vp_token":{"presentation_definition":{"id":"Ontario Health Insurance Plan","name":"Ontario","purpose":"purpose","input_descriptors":[{"id":"Ontario Health Insurance Plan","name":"Ontario","schema":[{"uri":"https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan"}]}]}}}&request_uri=https://rp.acme.com/siop/jwts`)
expect((await (await uriRequest.toAuthorizationRequest())?.requestObject?.getPayload())?.claims.vp_token).toBeDefined()
})

Expand All @@ -709,22 +591,6 @@ describe('create Request JWT should', () => {
response_type: 'id_token',
redirect_uri: EXAMPLE_REDIRECT_URL,
request_object_signing_alg_values_supported: [SigningAlgo.EDDSA, SigningAlgo.ES256],
claims: {
vp_token: {
presentation_definition: {
input_descriptors: [
{
id: 'Ontario Health Insurance Plan',
schema: [
{
uri: 'https://did.itsourweb.org:3000/smartcredential/Ontario-Health-Insurance-Plan',
},
],
},
],
} as IPresentationDefinition,
},
},
},

requestObject: {
Expand All @@ -738,7 +604,7 @@ describe('create Request JWT should', () => {
kid: KID,
alg: SigningAlgo.ES256K,
}),
payload: {
/* payload: {
client_id: 'test_client_id',
scope: 'test',
response_type: 'id_token',
Expand All @@ -760,7 +626,7 @@ describe('create Request JWT should', () => {
} as IPresentationDefinition,
},
},
},
},*/
},
clientMetadata: {
idTokenSigningAlgValuesSupported: [SigningAlgo.EDDSA, SigningAlgo.ES256],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class PresentationExchange {
keyEncoding: options?.signatureOptions?.keyEncoding ?? KeyEncoding.Hex,
},
}
return await this.pex.verifiablePresentationFrom(presentationDefinition, this.removeMDocCredentials(selectedCredentials), presentationSignCallback, signOptions)

// When there are MDoc credentials among the selected ones, filter those out as pex does not support mdoc credentials
const filteredCredentials = this.removeMDocCredentials(selectedCredentials)
return await this.pex.verifiablePresentationFrom(presentationDefinition, filteredCredentials, presentationSignCallback, signOptions)
}

private removeMDocCredentials(selectedCredentials: OriginalVerifiableCredential[]) {
Expand Down Expand Up @@ -383,7 +386,7 @@ export class PresentationExchange {
throw new Error(SIOPErrors.NO_PRESENTATION_SUBMISSION)
}

if (!evaluationResults.areRequiredCredentialsPresent || (evaluationResults.errors && evaluationResults.errors.length > 0) || !evaluationResults.value) {
if (evaluationResults.areRequiredCredentialsPresent === Status.ERROR || (evaluationResults.errors && evaluationResults.errors.length > 0) || !evaluationResults.value) {
throw new Error(`message: ${SIOPErrors.COULD_NOT_FIND_VCS_MATCHING_PD}, details: ${JSON.stringify(evaluationResults.errors)}`)
}

Expand Down
6 changes: 3 additions & 3 deletions packages/siop-oid4vp/lib/helpers/Metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ function supportedSubjectSyntaxTypes(rpMethods: string[] | string, opMethods: st
return supportedSubjectSyntaxTypes
}

export function collectAlgValues(o: any): string[] {
function collectAlgValues(algTableObject: any): string[] {
const algValues: string[] = [];
for (const key of Object.keys(o)) {
algValues.push(...o[key]);
for (const key of Object.keys(algTableObject)) {
algValues.push(...algTableObject[key]);
}

return algValues;
Expand Down

0 comments on commit d0b4ad4

Please sign in to comment.