Skip to content

Commit

Permalink
Add detail to error
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlee85 committed Jan 9, 2024
1 parent 9576505 commit de965da
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async function verifyAndFetch(request, key) {
const url = new URL(request.url);

if (!url.searchParams.has('mac') || !url.searchParams.has('expiry')) {
invalidResponse.body += ' - Missing MAC or expiry';
return invalidResponse;
}

Expand All @@ -88,11 +89,13 @@ async function verifyAndFetch(request, key) {

// Ensure that the MAC is valid
if (hashInBase64 !== receivedMacBase64) {
invalidResponse.body += ' - Bad MAC';
return invalidResponse;
}

// Ensure that the URL has not expired
if (Date.now() > expiry) {
invalidResponse.body += ' - Expired';
return invalidResponse;
}

Expand Down

0 comments on commit de965da

Please sign in to comment.