@ministryofjustice/fb-jwt-client-node
Advanced tools
Comparing version 0.0.34 to 0.0.35
@@ -454,3 +454,2 @@ const got = require('got') | ||
if (requestMetricsEnd) requestMetricsEnd(getResponseLabels(response)) | ||
response.body = response.body || '{}' | ||
return response | ||
@@ -469,11 +468,29 @@ } | ||
if (response.body && /^\s*$/.test(response.body)) return {} | ||
return response.body | ||
/* | ||
* Return whatever has been parsed or an object | ||
* | ||
* `got` is transforming an undefined response body into a | ||
* zero-length string. We handle that by returning an object | ||
* | ||
* Our `responseType` is JSON so we expect an object or | ||
* an error | ||
*/ | ||
return response.body || {} | ||
} catch (e) { | ||
const {response = {}} = e | ||
if (response.statusCode < 300) { | ||
/* | ||
* The request was successful | ||
*/ | ||
apiMetricsEnd(getResponseLabels(e)) | ||
if (response.body && /^\s*$/.test(response.body)) return {} | ||
return response.body | ||
/* | ||
* But parsing the response failed | ||
*/ | ||
if (e.name === 'ParseError') this.throwRequestError(500, 'EINVALIDPAYLOAD') | ||
/* | ||
* Otherwise, we could test for other conditions and handle them ... | ||
* once we have encountered some (I'm sure it won't be long) | ||
*/ | ||
this.throwRequestError(500, 'EUNKNOWN') | ||
} | ||
@@ -480,0 +497,0 @@ |
{ | ||
"name": "@ministryofjustice/fb-jwt-client-node", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "Form Builder JSON Web Token Client (Node)", | ||
@@ -20,3 +20,3 @@ "main": "lib/fb-jwt-client.js", | ||
"aes256": "^1.0.4", | ||
"got": "10.0.2", | ||
"got": "10.0.4", | ||
"jsonwebtoken": "^8.5.1", | ||
@@ -23,0 +23,0 @@ "path-to-regexp": "^6.1.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23034
667
+ Addedgot@10.0.4(transitive)
- Removedgot@10.0.2(transitive)
Updatedgot@10.0.4