diff --git a/lib/rp.ts b/lib/rp.ts index 0ac864c3..3e6672d4 100644 --- a/lib/rp.ts +++ b/lib/rp.ts @@ -56,7 +56,7 @@ const verifyJwtCallback = ( }, ): VerifyJwtCallback => { return async (jwtVerifier, jwt) => { - resolver = resolver ?? getResolver(['ethr', 'ion', 'jwk']) + resolver = resolver ?? getResolver(['ethr', 'ion', 'jwk', 'key', 'web']) const audience = jwtVerifier.type === 'request-object' ? (verifyOpts?.audience ?? getAudience(jwt.raw)) @@ -102,7 +102,7 @@ const verifyDidJWT = async(jwt: string, resolver: Resolvable, options: JWTVerify } } -const resolver = getResolver('ethr'); +// const resolver = getResolver('ethr'); export const rp = (type:string, id:string) => { let constraints = {}; @@ -148,7 +148,7 @@ export const rp = (type:string, id:string) => { .withResponseMode(ResponseMode.POST) .withAuthorizationEndpoint(url_auth) .withRedirectUri(url_res) - .withVerifyJwtCallback(verifyJwtCallback(resolver)) + .withVerifyJwtCallback(verifyJwtCallback()) .withRequestBy(PassBy.VALUE) .withCreateJwtCallback(createJwtCallback()) // .withSupportedVersions(SupportedVersion.SIOPv2_ID1) diff --git a/pages/api/vp/authorize.ts b/pages/api/vp/authorize.ts index 672483df..606ad3c7 100644 --- a/pages/api/vp/authorize.ts +++ b/pages/api/vp/authorize.ts @@ -21,6 +21,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { optionsSuccessStatus: 200 }); console.log('got to authorize'); + console.log(req.body); const gnap = await nano.db.use("gnap"); const patients = await nano.db.use("patients"); const {state} = req.body; @@ -38,9 +39,11 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { console.log(doc); console.log(req.body); console.log(req.body.vp_token); - const { payload } = decodeJWT(req.body.vp_token); - const verifiedAuthResponse = await rp(doc.vc_type, doc.vc_id).verifyAuthorizationResponse(payload, { + // const { payload } = decodeJWT(req.body.vp_token); + const verifiedAuthResponse = await rp(doc.vc_type, doc.vc_id).verifyAuthorizationResponse(req.body, { correlationId: doc._id, + state: doc.vp_state, + nonce: doc.vp_nonce, audience: url.protocol + "//" + url.hostname + "/api/vp/vp_response", }) console.log(verifiedAuthResponse) diff --git a/pages/api/vp/response.ts b/pages/api/vp/response.ts index 7bf54d87..7cdf9167 100644 --- a/pages/api/vp/response.ts +++ b/pages/api/vp/response.ts @@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import NextCors from '../../../lib/cors'; import objectPath from 'object-path'; import { rp } from '../../../lib/rp'; -import { decodeJWT, verifyJWT } from 'did-jwt'; +import { decodeJWT } from 'did-jwt'; var user = process.env.COUCHDB_USER; var pass = process.env.COUCHDB_PASSWORD;