Skip to content

Commit 38d90f4

Browse files
authored
Merge pull request #62 from Cimpress-MCP/mh/PRC-8229_RetryServiceTokenCalls
TokenProviderHttpClient now uses the http client with retries as default.
2 parents 05f062d + 706816f commit 38d90f4

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66

7-
## [6.0.0] - 2022-02-22
7+
## [6.1.1] - 2025-10-27
8+
9+
### Changed
10+
11+
- TokenProviderHttpClient now uses the http client with retries as default.
12+
13+
## [6.1.0] - 2024-09-30
14+
15+
### Changed
16+
17+
- Preserve the original message in ClientException
18+
19+
## [6.0.0] - 2024-02-22
820

921
### Changed
1022

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambda-essentials-ts",
3-
"version": "6.1.0",
3+
"version": "6.1.1",
44
"description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
55
"main": "lib/index.js",
66
"private": false,

src/tokenProvider/tokenProvider.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import jwtManager from 'jsonwebtoken';
2-
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
2+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
3+
import HttpClient from '../httpClient/httpClient';
34

45
export default abstract class TokenProvider {
56
private httpClient: TokenProviderHttpClient;
@@ -12,7 +13,15 @@ export default abstract class TokenProvider {
1213
* Create a new Instance of the TokenProvider
1314
*/
1415
protected constructor(options: TokenProviderOptions) {
15-
this.httpClient = options.httpClient ?? axios.create();
16+
this.httpClient =
17+
options.httpClient ??
18+
new HttpClient({
19+
enableCache: false,
20+
enableRetry: true,
21+
retryOptions: {
22+
retry: 3,
23+
},
24+
});
1625
this.configuration = options.tokenConfiguration;
1726
}
1827

@@ -71,7 +80,8 @@ export interface Auth0Secret {
7180

7281
export interface TokenProviderOptions {
7382
/**
74-
* Either an Axios instance or an @atsquad/httpclient instance, by default it creates an axios instance
83+
* Either an Axios instance or an @atsquad/httpclient instance, by default it creates an @atsquad/httpclient instance without cache
84+
* with retries
7585
*/
7686
httpClient?: TokenProviderHttpClient;
7787
/**

0 commit comments

Comments
 (0)