Skip to content

Commit a34596f

Browse files
committed
debug
1 parent 2665613 commit a34596f

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

pages/api/vp/response.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,24 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
3737
const patient_doc = await patients.get(doc.email);
3838
console.log(doc);
3939
console.log(req.body);
40-
console.log(req.body.vp_token);
41-
const { payload } = decodeJWT(req.body.vp_token);
42-
const verifiedAuthResponse = await rp.verifyAuthorizationResponse(payload, {
43-
correlationId: doc._id,
44-
audience: url.protocol + "//" + url.hostname + "/api/vp/vp_response",
45-
})
46-
console.log(verifiedAuthResponse)
47-
if (objectPath.get(verifiedAuthResponse, 'payload.state') === doc.vp_state) {
48-
console.log('state matches')
40+
const { payload } = decodeJWT(req.body.id_token);
41+
try {
42+
const verifiedAuthResponse = await rp.verifyAuthorizationResponse(payload, {
43+
correlationId: doc._id,
44+
audience: url.protocol + "//" + url.hostname + "/api/vp/vp_response",
45+
})
46+
console.log(verifiedAuthResponse)
47+
if (objectPath.get(verifiedAuthResponse, 'payload.state') === doc.vp_state) {
48+
console.log('state matches')
49+
}
50+
if (objectPath.get(verifiedAuthResponse, 'payload.nonce') === doc.vp_state) {
51+
console.log('state matches')
52+
}
53+
res.status(200).json({message: 'OK'});
54+
} catch (e) {
55+
console.log(e)
56+
res.status(400).json({error: 'invalid_request'});
4957
}
50-
if (objectPath.get(verifiedAuthResponse, 'payload.nonce') === doc.vp_state) {
51-
console.log('state matches')
52-
}
53-
res.status(200).json({message: 'OK'});
5458
// if (objectPath.has(payload, 'vp.verifiableCredential')) {
5559
// const vc = jose.decodeJwt(objectPath.get(payload, 'vp.verifiableCredential.0'));
5660
// if (objectPath.has(doc, 'vc')) {

pages/myTrustee/dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export default function Dashboard({
4242
return (
4343
<div>
4444
<div>
45-
<PolicySummary />
4645
<Stack spacing={2} direction="row">
4746
<Button variant="contained" onClick={() => logout()}>
4847
Logout
@@ -54,6 +53,7 @@ export default function Dashboard({
5453
Review Pending Requests
5554
</Button>
5655
</Stack>
56+
<PolicySummary />
5757
</div>
5858
</div>
5959
);

0 commit comments

Comments
 (0)