From 3be5cc0f65c548adc32295332c386caa86e8e354 Mon Sep 17 00:00:00 2001 From: Mehdi GHESH Date: Fri, 29 Sep 2023 12:57:40 +0200 Subject: [PATCH] fix: use RequestInit from node-fetch instead of inbuilt typescript Fix based on this stackoverflow answer https://stackoverflow.com/a/67870352/5868851 --- src/utils/auth.util.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/auth.util.ts b/src/utils/auth.util.ts index f207ae7..4d702a4 100644 --- a/src/utils/auth.util.ts +++ b/src/utils/auth.util.ts @@ -1,11 +1,14 @@ import { SonarQubeSDKAuth } from '../interfaces'; +import { RequestInit } from 'node-fetch' export class AuthUtils { static setAuthInHeadersIfConfigured = (auth?: SonarQubeSDKAuth) => { - const options: Record = {}; + const options: RequestInit = {}; if (auth) { - options['Authorization'] = - 'Basic ' + this.getBaseEncodedAuthCredentials(auth); + const headersInit: HeadersInit = {}; + headersInit.Authorization = + 'Basic ' + this.getBaseEncodedAuthCredentials(auth); + options.headers = headersInit; } return options; };