From b6b18c68e873fb0825b0605023ed81a302d5f356 Mon Sep 17 00:00:00 2001 From: Yen Le Diep Hoang <59736798+ldhyen99@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:55:19 +0700 Subject: [PATCH] fix: Provide meaningful error message when signature verification fails (#197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What type of PR is this? (check all applicable) - [ ] 🍕 Feature - [x] 🐛 Bug Fix - [ ] 📝 Documentation Update - [ ] 🎨 Style - [ ] 🧑‍💻 Code Refactor - [ ] 🔥 Performance Improvements - [ ] ✅ Test - [ ] 🤖 Build - [ ] 🔁 CI - [ ] 📦 Chore (Release) - [ ] ⏩ Revert ## Description I found something regarding this issue. If you want to know more, please read the comment in the attached ticket below. ## Related Tickets & Documents https://github.com/gs-gs/fa-ag-trace/issues/476 ## Mobile & Desktop Screenshots/Recordings image image ## Added tests? - [ ] 👍 yes - [x] 🙅 no, because they aren't needed - [ ] 🙋 no, because I need help ## Added to documentation? - [ ] 📜 README.md - [ ] 📓 [vc-kit doc site](https://uncefact.github.io/vckit/) - [ ] 📕 storybook - [x] 🙅 no documentation needed ## [optional] Are there any post-deployment tasks we need to perform? --- .../demo-explorer/src/pages/CredentialVerifier.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/demo-explorer/src/pages/CredentialVerifier.tsx b/packages/demo-explorer/src/pages/CredentialVerifier.tsx index 502b725b..59787bf4 100644 --- a/packages/demo-explorer/src/pages/CredentialVerifier.tsx +++ b/packages/demo-explorer/src/pages/CredentialVerifier.tsx @@ -75,11 +75,16 @@ const CredentialVerifier = () => { credential: JSON.parse(text), fetchRemoteContexts: true, }) - setVerificationResult(result) + if (result?.verified) { - setVerificationResult((result) => { - if (!result) return result - return { ...result, verifiableCredential: JSON.parse(text) } + setVerificationResult({ + ...result, + verifiableCredential: JSON.parse(text), + }) + } else { + setVerificationResult({ + verified: false, + error: { message: JSON.stringify(result?.error, null, 2) }, }) } } catch (e: any) {