From 2871564f65f7beac901102b51d29a818eaf68626 Mon Sep 17 00:00:00 2001 From: Ganesh Annan Date: Tue, 26 Nov 2024 20:12:52 +0100 Subject: [PATCH] Add debug statements. --- lib/oid4/http.js | 9 +++++++++ lib/oid4/oid4vp.js | 5 ++++- lib/verify.js | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/oid4/http.js b/lib/oid4/http.js index 44b16b8..0550018 100644 --- a/lib/oid4/http.js +++ b/lib/oid4/http.js @@ -245,6 +245,7 @@ export async function createRoutes({ } catch(error) { return _sendOID4Error({res, error}); } + logger.info('=== POST /credential (credential response)', result); res.json(result); })); @@ -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}); })); @@ -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}); })); @@ -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); diff --git a/lib/oid4/oid4vp.js b/lib/oid4/oid4vp.js index 8311124..6c6a76c 100644 --- a/lib/oid4/oid4vp.js +++ b/lib/oid4/oid4vp.js @@ -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; @@ -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, diff --git a/lib/verify.js b/lib/verify.js index afcfa9e..58b4bac 100644 --- a/lib/verify.js +++ b/lib/verify.js @@ -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; @@ -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}); @@ -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: {