Skip to content

Commit ce6013c

Browse files
fix: remove auth lib version from x-goog-api-client header (#1558)
1 parent 3563c16 commit ce6013c

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/transporters.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,9 @@ export class DefaultTransporter implements Transporter {
6868
] = `${uaValue} ${DefaultTransporter.USER_AGENT}`;
6969
}
7070
// track google-auth-library-nodejs version:
71-
const authVersion = `auth/${pkg.version}`;
72-
if (
73-
opts.headers['x-goog-api-client'] &&
74-
!opts.headers['x-goog-api-client'].includes(authVersion)
75-
) {
76-
opts.headers[
77-
'x-goog-api-client'
78-
] = `${opts.headers['x-goog-api-client']} ${authVersion}`;
79-
} else if (!opts.headers['x-goog-api-client']) {
71+
if (!opts.headers['x-goog-api-client']) {
8072
const nodeVersion = process.version.replace(/^v/, '');
81-
opts.headers[
82-
'x-goog-api-client'
83-
] = `gl-node/${nodeVersion} ${authVersion}`;
73+
opts.headers['x-goog-api-client'] = `gl-node/${nodeVersion}`;
8474
}
8575
}
8676
return opts;

test/test.transporters.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,15 @@ describe('transporters', () => {
5858
const opts = transporter.configure({
5959
url: '',
6060
});
61-
assert(
62-
/^gl-node\/[.-\w$]+ auth\/[.-\w$]+$/.test(
63-
opts.headers!['x-goog-api-client']
64-
)
65-
);
61+
assert(/^gl-node\/[.-\w$]+$/.test(opts.headers!['x-goog-api-client']));
6662
});
6763

6864
it('should append to x-goog-api-client header if it exists', () => {
6965
const opts = transporter.configure({
7066
headers: {'x-goog-api-client': 'gdcl/1.0.0'},
7167
url: '',
7268
});
73-
assert(
74-
/^gdcl\/[.-\w$]+ auth\/[.-\w$]+$/.test(opts.headers!['x-goog-api-client'])
75-
);
69+
assert(/^gdcl\/[.-\w$]+$/.test(opts.headers!['x-goog-api-client']));
7670
});
7771

7872
// see: https://github.com/googleapis/google-auth-library-nodejs/issues/819
@@ -84,9 +78,7 @@ describe('transporters', () => {
8478
let configuredOpts = transporter.configure(opts);
8579
configuredOpts = transporter.configure(opts);
8680
assert(
87-
/^gdcl\/[.-\w$]+ auth\/[.-\w$]+$/.test(
88-
configuredOpts.headers!['x-goog-api-client']
89-
)
81+
/^gdcl\/[.-\w$]+$/.test(configuredOpts.headers!['x-goog-api-client'])
9082
);
9183
});
9284

0 commit comments

Comments
 (0)