Skip to content

Commit 7449f61

Browse files
committed
Improving safety of scrubKeys utility
1 parent cd07681 commit 7449f61

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyapi",
3-
"version": "0.23.23",
3+
"version": "0.23.24",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

templates/axios.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ axios.interceptors.request.use(
4343
);
4444

4545
const scrubKeys = (err) => {
46-
if (err.request) {
47-
// Scrub the api key in the authorization header
48-
err.request.headers['Authorization'] = `Bearer ********`;
46+
if (err.request && typeof err.request.headers === 'object' && err.request.headers.Authorization) {
47+
// Scrub any credentials in the authorization header
48+
const [type, ...rest] = err.request.headers.Authorization.split(' ');
49+
err.request.headers.Authorization = rest.length && type
50+
? `${type} ********`
51+
: `********`;
4952
}
5053
throw err;
5154
};

0 commit comments

Comments
 (0)