diff --git a/package-lock.json b/package-lock.json index 9dcae7a648..f629079291 100644 --- a/package-lock.json +++ b/package-lock.json @@ -992,9 +992,9 @@ } }, "node_modules/@types/node": { - "version": "22.15.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.11.tgz", - "integrity": "sha512-rlyK0vuU7VLEYQfXuC7QTFxDvkb6tKhDI7wR4r6ZzM0k8BJd44W0jxo6xmUjqSs4AlYmiYfLJU2f0pAG/FtCRw==", + "version": "22.15.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.14.tgz", + "integrity": "sha512-BL1eyu/XWsFGTtDWOYULQEs4KR0qdtYfCxYAUYRoB7JP7h9ETYLgQTww6kH8Sj2C0pFGgrpM0XKv6/kbIzYJ1g==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" diff --git a/src/azure_auth.ts b/src/azure_auth.ts index 1b69048ddd..2db7c6601e 100644 --- a/src/azure_auth.ts +++ b/src/azure_auth.ts @@ -29,7 +29,7 @@ export class AzureAuth implements Authenticator { public async applyAuthentication(user: User, opts: https.RequestOptions): Promise { const token = this.getToken(user); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/config_test.ts b/src/config_test.ts index c2544a82e8..ea8e4e2dc1 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -962,7 +962,7 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate from auth provider', async () => { const config = new KubeConfig(); @@ -982,11 +982,11 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); opts.headers = {}; opts.headers.Host = 'foo.com'; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate from auth provider without expirty', async () => { @@ -1006,7 +1006,7 @@ describe('KubeConfig', () => { const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should populate rejectUnauthorized=false when skipTLSVerify is set', async () => { @@ -1115,7 +1115,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with expired token', async () => { @@ -1143,7 +1143,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec without access-token', async () => { @@ -1170,7 +1170,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec without access-token', async () => { // TODO: fix this test for Windows @@ -1196,7 +1196,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec succesfully with spaces in cmd', async () => { // TODO: fix this test for Windows @@ -1222,7 +1222,7 @@ describe('KubeConfig', () => { ); const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth and env vars', async () => { // TODO: fix this test for Windows @@ -1255,7 +1255,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here and validate env vars? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth', async () => { // TODO: fix this test for Windows @@ -1288,7 +1288,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should exec with exec auth (other location)', async () => { // TODO: fix this test for Windows @@ -1316,7 +1316,7 @@ describe('KubeConfig', () => { // TODO: inject the exec command here? const opts = {} as RequestOptions; await config.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, `Bearer ${token}`); + strictEqual(opts.headers!['Authorization'], `Bearer ${token}`); }); it('should cache exec with name', async () => { // TODO: fix this test for Windows @@ -1776,7 +1776,7 @@ describe('KubeConfig', () => { // Simulate token retrieval const token = 'test-token'; opts.headers = opts.headers || {}; - opts.headers.Authorization = `Bearer ${token}`; + opts.headers['Authorization'] = `Bearer ${token}`; } else { throw new Error('No custom configuration found'); } @@ -1802,7 +1802,7 @@ describe('KubeConfig', () => { const opts: RequestOptions = {}; await kc.applyToHTTPSOptions(opts); - strictEqual(opts.headers!.Authorization, 'Bearer test-token'); + strictEqual(opts.headers!['Authorization'], 'Bearer test-token'); }); }); diff --git a/src/exec_auth.ts b/src/exec_auth.ts index 3ac70dfa4e..fbd97a26f8 100644 --- a/src/exec_auth.ts +++ b/src/exec_auth.ts @@ -56,7 +56,7 @@ export class ExecAuth implements Authenticator { if (!opts.headers) { opts.headers = {} as OutgoingHttpHeaders; } - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/exec_auth_test.ts b/src/exec_auth_test.ts index 9be3e262d5..e323b5880e 100644 --- a/src/exec_auth_test.ts +++ b/src/exec_auth_test.ts @@ -486,7 +486,7 @@ describe('ExecAuth', () => { }, opts, ); - strictEqual(opts.headers?.Authorization, 'Bearer foo'); + strictEqual(opts.headers!['Authorization'], 'Bearer foo'); }); it('should handle null credentials correctly', async () => { const auth = new ExecAuth(); diff --git a/src/file_auth.ts b/src/file_auth.ts index b8b7644636..d6d4f56c9b 100644 --- a/src/file_auth.ts +++ b/src/file_auth.ts @@ -20,7 +20,7 @@ export class FileAuth implements Authenticator { this.refreshToken(user.authProvider.config.tokenFile); } if (this.token) { - opts.headers!.Authorization = `Bearer ${this.token}`; + opts.headers!['Authorization'] = `Bearer ${this.token}`; } } diff --git a/src/gcp_auth.ts b/src/gcp_auth.ts index 0f3d680e08..1bf1089618 100644 --- a/src/gcp_auth.ts +++ b/src/gcp_auth.ts @@ -28,7 +28,7 @@ export class GoogleCloudPlatformAuth implements Authenticator { public async applyAuthentication(user: User, opts: https.RequestOptions): Promise { const token = this.getToken(user); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } } diff --git a/src/oidc_auth.ts b/src/oidc_auth.ts index af5e0c1311..f8c1536ac9 100644 --- a/src/oidc_auth.ts +++ b/src/oidc_auth.ts @@ -85,7 +85,7 @@ export class OpenIDConnectAuth implements Authenticator { ): Promise { const token = await this.getToken(user, overrideClient); if (token) { - opts.headers!.Authorization = `Bearer ${token}`; + opts.headers!['Authorization'] = `Bearer ${token}`; } }