From 691afea3fa47ed8dd7a653707b1af1362d908dca Mon Sep 17 00:00:00 2001 From: Siddhant Khare Date: Tue, 7 Jan 2025 19:22:36 +0000 Subject: [PATCH] fix: use provided axios instance in credentials refresh --- base.ts | 2 +- credentials/credentials.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base.ts b/base.ts index 0ee85f8..58d84cb 100644 --- a/base.ts +++ b/base.ts @@ -48,7 +48,7 @@ export class BaseAPI { } this.configuration.isValid(); - this.credentials = Credentials.init(this.configuration); + this.credentials = Credentials.init(this.configuration, this.axios); if (!this.axios) { const httpAgent = new http.Agent({ keepAlive: true }); diff --git a/credentials/credentials.ts b/credentials/credentials.ts index 3156aa0..c7e16e6 100644 --- a/credentials/credentials.ts +++ b/credentials/credentials.ts @@ -26,9 +26,9 @@ export class Credentials { private accessToken?: string; private accessTokenExpiryDate?: Date; - public static init(configuration: { credentials: AuthCredentialsConfig, telemetry: TelemetryConfiguration, baseOptions?: any }): Credentials { - return new Credentials(configuration.credentials, globalAxios, configuration.telemetry, configuration.baseOptions); - } + public static init(configuration: { credentials: AuthCredentialsConfig, telemetry: TelemetryConfiguration, baseOptions?: any }, axios: AxiosInstance = globalAxios): Credentials { + return new Credentials(configuration.credentials, axios, configuration.telemetry, configuration.baseOptions); +} public constructor(private authConfig: AuthCredentialsConfig, private axios: AxiosInstance = globalAxios, private telemetryConfig: TelemetryConfiguration, private baseOptions?: any) { this.initConfig(); @@ -155,7 +155,7 @@ export class Credentials { }, { maxRetry: 3, minWaitInMs: 100, - }, globalAxios); + }, this.axios); const response = wrappedResponse?.response; if (response) { @@ -180,7 +180,7 @@ export class Credentials { attributes = TelemetryAttributes.fromResponse({ response, - attributes, + attributes, }); attributes = TelemetryAttributes.prepare(attributes, this.telemetryConfig.metrics?.counterCredentialsRequest?.attributes);