diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-23 10:22:28 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-23 10:22:28 -0700 |
commit | a0bb38f97ac2a621daf9932d9b70c5a1c76f6d85 (patch) | |
tree | 1d537a17182b86cbd5327e03a08226cfbeec51fe /example/index.js | |
parent | 742985ed1a1ddf4bbc6907066fb781e5508f9168 (diff) |
Pass errors to front end when verification throws
Diffstat (limited to 'example/index.js')
-rw-r--r-- | example/index.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/example/index.js b/example/index.js index 3a58719..3b143b3 100644 --- a/example/index.js +++ b/example/index.js @@ -72,7 +72,13 @@ app.get('/generate-attestation-options', (req, res) => { app.post('/verify-attestation', (req, res) => { const { body } = req; - const verification = verifyAttestationResponse(body, `https://${origin}`); + let verification; + try { + verification = verifyAttestationResponse(body, `https://${origin}`); + } catch (error) { + console.error(error); + return res.status(400).send({ error: error.message }); + } const { verified, authenticatorInfo } = verification; @@ -120,7 +126,13 @@ app.post('/verify-assertion', (req, res) => { } }); - const verification = verifyAssertionResponse(body, `https://${origin}`, dbAuthenticator); + let verification; + try { + verification = verifyAssertionResponse(body, `https://${origin}`, dbAuthenticator); + } catch (error) { + console.error(error); + return res.status(400).send({ error: error.message }); + } const { verified, authenticatorInfo } = verification; |