diff --git a/config/clients/js/CHANGELOG.md.mustache b/config/clients/js/CHANGELOG.md.mustache index 0b2c2f0f..8b25dc96 100644 --- a/config/clients/js/CHANGELOG.md.mustache +++ b/config/clients/js/CHANGELOG.md.mustache @@ -4,6 +4,7 @@ ## [Unreleased](https://github.com/openfga/js-sdk/compare/v{{packageVersion}}...HEAD) - fix: error correctly if apiUrl is not provided (#161) +- fix: use provided axios instance in credentials refresh (#193) - feat: add support for `start_time` parameter in `ReadChanges` endpoint - BREAKING: As of this release, the min node version required by the SDK is now v16.15.0 - feat!: add support for server-side `BatchCheck` method. diff --git a/config/clients/js/template/baseApi.mustache b/config/clients/js/template/baseApi.mustache index 5b431691..e63f6eac 100644 --- a/config/clients/js/template/baseApi.mustache +++ b/config/clients/js/template/baseApi.mustache @@ -37,7 +37,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/config/clients/js/template/credentials/credentials.ts.mustache b/config/clients/js/template/credentials/credentials.ts.mustache index b1619037..c7a57cd8 100644 --- a/config/clients/js/template/credentials/credentials.ts.mustache +++ b/config/clients/js/template/credentials/credentials.ts.mustache @@ -15,8 +15,8 @@ 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) { @@ -144,7 +144,7 @@ export class Credentials { }, { maxRetry: 3, minWaitInMs: 100, - }, globalAxios); + }, this.axios); const response = wrappedResponse?.response; if (response) {