From 4acf6bfba56ac8a1e35a0c45e08ae2e356f44ea6 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Sat, 24 Aug 2024 23:26:53 -0400 Subject: [PATCH] Improve verification method controller check error. --- CHANGELOG.md | 1 + lib/vcjwt.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb3bdd8..d501158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Throw better error if JWT verification method cannot be retrieved from `kid` URL. +- Improve verification method controller check error. ## 21.0.0 - 2024-08-19 diff --git a/lib/vcjwt.js b/lib/vcjwt.js index 4174011..8f06fb6 100644 --- a/lib/vcjwt.js +++ b/lib/vcjwt.js @@ -109,9 +109,9 @@ async function _verifyJwt({jwt, proofPurpose, audience} = {}) { if(typeof match === 'string') { match = didDoc?.verificationMethod?.find?.(e => e.id === vm.id); } - if(!(match && Array.isArray(match.controller) ? + if(!(match && (Array.isArray(match.controller) ? match.controller.includes(vm.controller) : - match.controller === vm.controller)) { + match.controller === vm.controller))) { throw new BedrockError( `Verification method controller "${controller}" did not authorize ` + `verification method "${vm.id}" for the purpose ` +