From 664e41b703e70c9a05a2b4358b78fc5d56fa6173 Mon Sep 17 00:00:00 2001 From: Ganesh Annan Date: Wed, 6 Nov 2024 21:54:31 +0100 Subject: [PATCH] Add fix for jcs suites. --- CHANGELOG.md | 5 +++++ lib/ProofSet.js | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4325a5..a05027a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # jsonld-signatures ChangeLog +## 11.3.2 - 2024-11-xx + +### Fixed +- Ensure `proof.@context` is unmodified for JCS Data Integrity Cryptosuites. + ## 11.3.1 - 2024-10-02 ### Fixed diff --git a/lib/ProofSet.js b/lib/ProofSet.js index ae911e39..3641c79e 100644 --- a/lib/ProofSet.js +++ b/lib/ProofSet.js @@ -224,10 +224,14 @@ function _getProofs({document}) { // shallow copy proofs and add document context or SECURITY_CONTEXT_URL const context = document['@context'] || constants.SECURITY_CONTEXT_URL; - proofSet = proofSet.map(proof => ({ - '@context': context, - ...proof - })); + proofSet = proofSet.map(proof => { + const {cryptosuite} = proof; + // JCS Data Integrity Suites require unmodified proofs + if(cryptosuite && cryptosuite.includes('-jcs-')) { + return proof; + } + return {'@context': context, ...proof}; + }); return proofSet; }