Skip to content

Commit

Permalink
Add debug statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
gannan08 committed Nov 26, 2024
1 parent fbb1dd0 commit 2871564
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/oid4/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export async function createRoutes({
} catch(error) {
return _sendOID4Error({res, error});
}
logger.info('=== POST /credential (credential response)', result);
res.json(result);
}));

Expand Down Expand Up @@ -276,6 +277,7 @@ export async function createRoutes({
// serve exchange ID as nonce
const exchangeRecord = await req.getExchange();
const {exchange} = exchangeRecord;
logger.info('=== POST /nonce (create nonce)', {c_nonce: exchange.id});
res.json({c_nonce: exchange.id});
}));

Expand Down Expand Up @@ -346,6 +348,9 @@ export async function createRoutes({
} catch(error) {
return _sendOID4Error({res, error});
}
logger.info('=== POST /batch_credential (credential response)', {
credential_responses: result
});
res.json({credential_responses: result});
}));

Expand Down Expand Up @@ -387,6 +392,10 @@ export async function createRoutes({
try {
result = await oid4vp.processAuthorizationResponse({req});
} catch(error) {
logger.info('=== POST /client/authorization/response ERROR', {
req,
error
});
return _sendOID4Error({res, error});
}
res.json(result);
Expand Down
5 changes: 4 additions & 1 deletion lib/oid4/oid4vp.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export async function processAuthorizationResponse({req}) {
const {
presentation, envelope, presentationSubmission
} = await _parseAuthorizationResponse({req});

logger.info('=== _parseAuthorizationResponse', {
presentation, envelope, presentationSubmission
});
const {config: workflow} = req.serviceObject;
const exchangeRecord = await req.getExchange();
let {exchange} = exchangeRecord;
Expand Down Expand Up @@ -192,6 +194,7 @@ export async function processAuthorizationResponse({req}) {
// verify the received VP
const {verifiablePresentationRequest} = await oid4vp.toVpr(
{authorizationRequest});
logger.info('=== oid4vp.toVpr', {verifiablePresentationRequest});
const {allowUnprotectedPresentation = false} = step;
const verifyResult = await verify({
workflow,
Expand Down
15 changes: 15 additions & 0 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Ed25519Multikey from '@digitalbazaar/ed25519-multikey';
import {getZcapClient, stripStacktrace} from './helpers.js';
import {importJWK, jwtVerify} from 'jose';
import {didIo} from '@bedrock/did-io';
import {logger} from './logger.js';

const {util: {BedrockError}} = bedrock;

Expand All @@ -28,6 +29,10 @@ export async function verify({
workflow, verifiablePresentationRequest, presentation,
allowUnprotectedPresentation = false, expectedChallenge
} = {}) {
logger.info('=== verify()', {
workflow, verifiablePresentationRequest, presentation,
allowUnprotectedPresentation, expectedChallenge
});
// create zcap client for verifying
const {zcapClient, zcaps} = await getZcapClient({workflow});

Expand All @@ -46,6 +51,16 @@ export async function verify({
new URL(workflow.id).origin;
let result;
try {
logger.info('=== VC_VERIFIER.verify()', {
options: {
challenge: expectedChallenge ??
verifiablePresentationRequest.challenge ??
presentation?.proof?.challenge,
domain,
checks
},
verifiablePresentation: presentation
});
result = await zcapClient.write({
capability,
json: {
Expand Down

0 comments on commit 2871564

Please sign in to comment.