Skip to content

Commit

Permalink
fix: use provided axios instance in credentials refresh (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh authored Jan 14, 2025
2 parents 43cf83f + 7edf85a commit e9ff58a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/clients/js/CHANGELOG.md.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion config/clients/js/template/baseApi.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class Credentials {
}, {
maxRetry: 3,
minWaitInMs: 100,
}, globalAxios);
}, this.axios);

const response = wrappedResponse?.response;
if (response) {
Expand Down

0 comments on commit e9ff58a

Please sign in to comment.