Skip to content

Commit

Permalink
NOBUG: Use axios. (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
marklise authored May 14, 2024
1 parent f99db37 commit d75ab00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lambda/permissionUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const jwksClient = require('jwks-rsa');
const SSO_ISSUER = process.env.SSO_ISSUER || 'https://dev.loginproxy.gov.bc.ca/auth/realms/bcparks-service-transformation';
const SSO_JWKSURI = process.env.SSO_JWKSURI || 'https://dev.loginproxy.gov.bc.ca/auth/realms/bcparks-service-transformation/protocol/openid-connect/certs';
const CF_SECRET_KEY = process.env.CF_SECRET_KEY;
const fetch = require('fetch');
const axios = require('axios');
const INVALID_TOKEN = {
decoded: false,
data: null
Expand Down Expand Up @@ -227,17 +227,17 @@ exports.validateToken = async function (token) {
});

const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
const result = await fetch(url, {
body: body,
method: 'POST',
const res = await axios({
method: 'post',
url: url,
headers: {
'Content-Type': 'application/json'
}
},
data: body
});

const res = await result.json();
logger.debug(res);
if (!res.success) {
logger.debug(res.data);
if (!res.status == 200) {
throw new CustomError('Invalid token.', 400);
}
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"csvjson": "^5.1.0",
"csvtojson": "^2.0.10",
"date-fns": "^2.28.0",
"fetch": "^1.1.0",
"fs": "^0.0.1-security",
"jsonwebtoken": "^9.0.0",
"jwks-rsa": "^3.0.0",
Expand Down

0 comments on commit d75ab00

Please sign in to comment.