Skip to content

Commit

Permalink
fix handle chainalysis invalid response
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Nov 21, 2024
1 parent b2504d2 commit a7d5cf2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const handler = async (req, res, apiKey, fetch) => {
)
assert(fetchRes.ok, `Chainalysis API status ${fetchRes.status}`)
const body = await fetchRes.json()
if (typeof body !== 'object' || body === null || !Array.isArray(body.identifications)) {
const err = new Error('Invalid Chainalysis response')
err.body = body
throw err
}
res.statusCode = body.identifications.length > 0 ? 403 : 200
res.end(STATUS_CODES[res.statusCode])
}
Expand Down

0 comments on commit a7d5cf2

Please sign in to comment.