From c69a72cef7bb98596055db8f554e018783fdee12 Mon Sep 17 00:00:00 2001 From: sanderPostma Date: Fri, 30 Aug 2024 12:32:53 +0200 Subject: [PATCH] chore: use PresentationEvaluationResults & fixe build:clean scipts --- packages/did-auth-siop-adapter/package.json | 1 + .../PresentationExchange.ts | 29 +++++++++++-------- packages/siop-oid4vp/package.json | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/did-auth-siop-adapter/package.json b/packages/did-auth-siop-adapter/package.json index ea283780..d4866a1a 100644 --- a/packages/did-auth-siop-adapter/package.json +++ b/packages/did-auth-siop-adapter/package.json @@ -7,6 +7,7 @@ "types": "dist/index.d.ts", "scripts": { "build": "tsc", + "build:clean": "tsc --build --clean && tsc --build", "clean": "rimraf dist coverage" }, "dependencies": { diff --git a/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts b/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts index 2aa96631..9439672d 100644 --- a/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts +++ b/packages/siop-oid4vp/lib/authorization-response/PresentationExchange.ts @@ -1,5 +1,4 @@ import { - EvaluationResults, IPresentationDefinition, KeyEncoding, PEX, @@ -7,9 +6,14 @@ import { SelectResults, Status, VerifiablePresentationFromOpts, - VerifiablePresentationResult, -} from '@sphereon/pex' -import { Format, PresentationDefinitionV1, PresentationDefinitionV2, PresentationSubmission } from '@sphereon/pex-models' + VerifiablePresentationResult +} from '@sphereon/pex'; +import { + Format, + PresentationDefinitionV1, + PresentationDefinitionV2, + PresentationSubmission +} from '@sphereon/pex-models'; import { CredentialMapper, Hasher, @@ -18,18 +22,19 @@ import { OriginalVerifiableCredential, OriginalVerifiablePresentation, W3CVerifiablePresentation, - WrappedVerifiablePresentation, -} from '@sphereon/ssi-types' + WrappedVerifiablePresentation +} from '@sphereon/ssi-types'; -import { extractDataFromPath, getWithUrl } from '../helpers' -import { AuthorizationRequestPayload, SIOPErrors, SupportedVersion } from '../types' +import { extractDataFromPath, getWithUrl } from '../helpers'; +import { AuthorizationRequestPayload, SIOPErrors, SupportedVersion } from '../types'; import { PresentationDefinitionLocation, PresentationDefinitionWithLocation, PresentationSignCallback, - PresentationVerificationCallback, -} from './types' + PresentationVerificationCallback +} from './types'; +import { PresentationEvaluationResults } from '@sphereon/pex/dist/main/lib/evaluation/core/evaluationResults'; export class PresentationExchange { readonly pex: PEX @@ -133,7 +138,7 @@ export class PresentationExchange { presentationSubmission?: PresentationSubmission hasher?: Hasher }, - ): Promise { + ): Promise { const wvp: WrappedVerifiablePresentation = typeof verifiablePresentation === 'object' && 'original' in verifiablePresentation ? (verifiablePresentation as WrappedVerifiablePresentation) @@ -149,7 +154,7 @@ export class PresentationExchange { throw new Error(SIOPErrors.NO_VERIFIABLE_PRESENTATION_NO_CREDENTIALS) } // console.log(`Presentation (validate): ${JSON.stringify(verifiablePresentation)}`); - const evaluationResults: EvaluationResults = new PEX({ hasher: opts?.hasher }).evaluatePresentation(presentationDefinition, wvp.original, opts) + const evaluationResults: PresentationEvaluationResults = new PEX({ hasher: opts?.hasher }).evaluatePresentation(presentationDefinition, wvp.original, opts) if (evaluationResults.errors.length) { throw new Error(`message: ${SIOPErrors.COULD_NOT_FIND_VCS_MATCHING_PD}, details: ${JSON.stringify(evaluationResults.errors)}`) } diff --git a/packages/siop-oid4vp/package.json b/packages/siop-oid4vp/package.json index 8ea0fbef..0e276da1 100644 --- a/packages/siop-oid4vp/package.json +++ b/packages/siop-oid4vp/package.json @@ -7,6 +7,7 @@ "types": "dist/index.d.ts", "scripts": { "build": "pnpm build:schemaGenerator && tsc", + "build:clean": "pnpm build:schemaGenerator && tsc --build --clean && tsc --build", "build:main": "tsc -p tsconfig.build.json", "build:schemaGenerator": "node --loader=tsimp/loader ./lib/generator/schemaGenerator.ts", "clean": "rimraf dist coverage",