Skip to content

Commit

Permalink
deploy: f433904
Browse files Browse the repository at this point in the history
  • Loading branch information
Neztore committed Jul 31, 2024
1 parent 0996b05 commit 6d3ecc5
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions lib_util_http.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,32 @@ <h1>lib/util/http.js</h1>
}
return http(args.url, opt).then(function (res) {
if (opt &amp;&amp; opt.headers &amp;&amp; opt.headers['X-CSRF-TOKEN']) {
if (res.statusCode === 403 &amp;&amp; (res.statusMessage === 'XSRF Token Validation Failed' || res.statusMessage === 'Token Validation Failed')) {
depth++
if (depth >= 3) {
throw new Error('Tried ' + depth + ' times and could not refresh XCSRF token successfully')
if (res.statusCode === 403) {
let message

try {
message = typeof res.body === 'string' ? JSON.parse(res.body).message : res.body.message
} catch (_) {
// Roblox didn't send back a properly formed json object
}
const token = res.headers['x-csrf-token']
if (token) {
opt.headers['X-CSRF-TOKEN'] = token
opt.jar = jar
args.depth = depth + 1
return exports.func(args)
} else {
throw new Error('Could not refresh X-CSRF-TOKEN')

if (message === 'XSRF Token Validation Failed' || message === 'Token Validation Failed') {
depth++

if (depth >= 3) {
throw new Error('Tried ' + depth + ' times and could not refresh XCSRF token successfully')
}

const token = res.headers['x-csrf-token']

if (token) {
opt.headers['X-CSRF-TOKEN'] = token
opt.jar = jar
args.depth = depth + 1
return exports.func(args)
} else {
throw new Error('Could not refresh X-CSRF-TOKEN')
}
}
} else {
if (depth > 0) {
Expand Down

0 comments on commit 6d3ecc5

Please sign in to comment.