From c5d6b7663cbddd4ff62260508b64faab90ade097 Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Mon, 22 Jan 2024 19:09:14 +0100 Subject: [PATCH] feat: Correct submission_data when send in incorrectly as string --- packages/siopv2-oid4vp-op-auth/package.json | 2 +- packages/siopv2-oid4vp-rp-auth/package.json | 2 +- .../siopv2-oid4vp-rp-rest-api/package.json | 2 +- .../src/siop-api-functions.ts | 8 ++++++- packages/w3c-vc-api/package.json | 2 +- pnpm-lock.yaml | 23 ++++++++++--------- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/siopv2-oid4vp-op-auth/package.json b/packages/siopv2-oid4vp-op-auth/package.json index fe25b6b6d..b08cc190a 100644 --- a/packages/siopv2-oid4vp-op-auth/package.json +++ b/packages/siopv2-oid4vp-op-auth/package.json @@ -14,7 +14,7 @@ "build:clean": "tsc --build --clean && tsc --build" }, "dependencies": { - "@sphereon/did-auth-siop": "0.6.0-unstable.1", + "@sphereon/did-auth-siop": "0.6.0-unstable.3", "@sphereon/pex": "3.0.1", "@sphereon/pex-models": "2.1.5", "@sphereon/ssi-sdk-ext.did-utils": "0.15.0", diff --git a/packages/siopv2-oid4vp-rp-auth/package.json b/packages/siopv2-oid4vp-rp-auth/package.json index e5375b273..2d605fe52 100644 --- a/packages/siopv2-oid4vp-rp-auth/package.json +++ b/packages/siopv2-oid4vp-rp-auth/package.json @@ -14,7 +14,7 @@ "build:clean": "tsc --build --clean && tsc --build" }, "dependencies": { - "@sphereon/did-auth-siop": "0.6.0-unstable.1", + "@sphereon/did-auth-siop": "0.6.0-unstable.3", "@sphereon/pex": "3.0.1", "@sphereon/ssi-sdk-ext.did-utils": "0.15.0", "@sphereon/ssi-sdk.core": "workspace:*", diff --git a/packages/siopv2-oid4vp-rp-rest-api/package.json b/packages/siopv2-oid4vp-rp-rest-api/package.json index d92574ebb..ba6f7e41d 100644 --- a/packages/siopv2-oid4vp-rp-rest-api/package.json +++ b/packages/siopv2-oid4vp-rp-rest-api/package.json @@ -11,7 +11,7 @@ "start:dev": "ts-node __tests__/RestAPI.ts" }, "dependencies": { - "@sphereon/did-auth-siop": "0.6.0-unstable.1", + "@sphereon/did-auth-siop": "0.6.0-unstable.3", "@sphereon/ssi-express-support": "workspace:*", "@sphereon/ssi-sdk.core": "workspace:*", "@sphereon/ssi-sdk.kv-store-temp": "workspace:*", diff --git a/packages/siopv2-oid4vp-rp-rest-api/src/siop-api-functions.ts b/packages/siopv2-oid4vp-rp-rest-api/src/siop-api-functions.ts index afc82282d..6443a5f06 100644 --- a/packages/siopv2-oid4vp-rp-rest-api/src/siop-api-functions.ts +++ b/packages/siopv2-oid4vp-rp-rest-api/src/siop-api-functions.ts @@ -1,5 +1,6 @@ import { AuthorizationResponsePayload, PresentationDefinitionLocation } from '@sphereon/did-auth-siop' import { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support' +import { PresentationSubmission } from '@sphereon/ssi-types' import { Request, Response, Router } from 'express' import { IRequiredContext } from './types' @@ -24,7 +25,12 @@ export function verifyAuthResponseSIOPv2Endpoint( console.log('Authorization Response (siop-sessions') console.log(JSON.stringify(request.body, null, 2)) const definition = await context.agent.pexStoreGetDefinition({ definitionId }) - const authorizationResponse = typeof request.body === 'string' ? request.body : (request.body as AuthorizationResponsePayload) + const authorizationResponse = + typeof request.body === 'string' ? (JSON.parse(request.body) as AuthorizationResponsePayload) : (request.body as AuthorizationResponsePayload) + if (typeof authorizationResponse.presentation_submission === 'string') { + console.log(`Supplied presentation_submission was a string instead of JSON. Correctig, but external party should fix their implementation!`) + authorizationResponse.presentation_submission = JSON.parse(authorizationResponse.presentation_submission) as PresentationSubmission + } console.log(`URI: ${JSON.stringify(authorizationResponse)}`) if (!definition) { response.statusCode = 404 diff --git a/packages/w3c-vc-api/package.json b/packages/w3c-vc-api/package.json index 8b5e1c02c..1362c4b6d 100644 --- a/packages/w3c-vc-api/package.json +++ b/packages/w3c-vc-api/package.json @@ -11,7 +11,7 @@ "start:dev": "ts-node __tests__/agent.ts" }, "dependencies": { - "@sphereon/did-auth-siop": "0.6.0-unstable.1", + "@sphereon/did-auth-siop": "0.6.0-unstable.3", "@sphereon/ssi-express-support": "workspace:*", "@sphereon/ssi-sdk.core": "workspace:*", "@sphereon/ssi-sdk.kv-store-temp": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1f95bd82c..77b67d0d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1089,8 +1089,8 @@ importers: packages/siopv2-oid4vp-op-auth: dependencies: '@sphereon/did-auth-siop': - specifier: 0.6.0-unstable.1 - version: 0.6.0-unstable.1 + specifier: 0.6.0-unstable.3 + version: 0.6.0-unstable.3 '@sphereon/pex': specifier: 3.0.1 version: 3.0.1 @@ -1162,8 +1162,8 @@ importers: packages/siopv2-oid4vp-rp-auth: dependencies: '@sphereon/did-auth-siop': - specifier: 0.6.0-unstable.1 - version: 0.6.0-unstable.1 + specifier: 0.6.0-unstable.3 + version: 0.6.0-unstable.3 '@sphereon/pex': specifier: 3.0.1 version: 3.0.1 @@ -1226,8 +1226,8 @@ importers: packages/siopv2-oid4vp-rp-rest-api: dependencies: '@sphereon/did-auth-siop': - specifier: 0.6.0-unstable.1 - version: 0.6.0-unstable.1 + specifier: 0.6.0-unstable.3 + version: 0.6.0-unstable.3 '@sphereon/ssi-express-support': specifier: workspace:* version: link:../ssi-express-support @@ -2175,8 +2175,8 @@ importers: packages/w3c-vc-api: dependencies: '@sphereon/did-auth-siop': - specifier: 0.6.0-unstable.1 - version: 0.6.0-unstable.1 + specifier: 0.6.0-unstable.3 + version: 0.6.0-unstable.3 '@sphereon/ssi-express-support': specifier: workspace:* version: link:../ssi-express-support @@ -6785,7 +6785,7 @@ packages: chromium-edge-launcher: 1.0.0 connect: 3.7.0 debug: 2.6.9 - node-fetch: 2.6.12 + node-fetch: 2.7.0 open: 7.4.2 serve-static: 1.15.0 temp-dir: 2.0.0 @@ -7093,8 +7093,8 @@ packages: - encoding dev: false - /@sphereon/did-auth-siop@0.6.0-unstable.1: - resolution: {integrity: sha512-Q0ABHQ3VFQ49CRH9XWMKeMmHLWFjGb7/dhJY+Zi9hn2Z3jgwJqSWqVN4TN94Cmwt0UQBWhz7ZTCO4sBZKcdqGw==} + /@sphereon/did-auth-siop@0.6.0-unstable.3: + resolution: {integrity: sha512-0d2A3EPsywkHw5zfR3JWu0sjy3FACtpAlnWabol/5C8/C1Ys1hCk+X995aADqs8DRtdVFX8TFJkCMshp7pLyEg==} engines: {node: '>=18'} dependencies: '@astronautlabs/jsonpath': 1.1.2 @@ -17444,6 +17444,7 @@ packages: optional: true dependencies: whatwg-url: 5.0.0 + optional: true /node-fetch@2.6.7: resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}