Skip to content

Commit

Permalink
feat: Correct submission_data when send in incorrectly as string
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jan 22, 2024
1 parent 1ae4b94 commit c5d6b76
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
8 changes: 7 additions & 1 deletion packages/siopv2-oid4vp-rp-rest-api/src/siop-api-functions.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/w3c-vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
23 changes: 12 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5d6b76

Please sign in to comment.