Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
shihjay2 committed Jan 29, 2025
1 parent 2a84322 commit 131553e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/rp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions pages/api/vp/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pages/api/vp/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 131553e

Please sign in to comment.