Skip to content

add notes #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ app.post('/verify-attestation', async (req, res) => {
if (!attestation) {
return res.status(400).send('Missing attestation');
}
/**
* Two potential uncaught errors are causing the server to shutdown:
*
* 1. fetchPublicKeyFromNotary will throw an error is notary url is localhost (invalid pub key)
* 2. I think verify would throw error or return null if notaryPem is undefined/invalid
*
* We should:
* 1. Refactor fetch public key from notary to return null on error
* 2. Refactor fetch public key to return a hardcoded pem of the localhost notary if url is localhost
* 3. Put this entire request handler in a try-catch and res.json({ error: error }) when an error is caught
* 4. Just in case, i would put the `/poap-claim` handler in a similar try-catch as well
*/
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl);
const presentation = verify(attestation.data, notaryPem);
Expand Down