lambda-essentials-ts 6.0.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/lib/exceptions/clientException.d.ts +1 -1
- package/lib/exceptions/clientException.js +2 -2
- package/lib/httpClient/httpClient.js +2 -2
- package/lib/tokenProvider/tokenProvider.d.ts +2 -1
- package/lib/tokenProvider/tokenProvider.js +9 -2
- package/lib/util.d.ts +1 -0
- package/lib/util.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
|
|
7
|
-
## [6.
|
|
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
|
|
8
20
|
|
|
9
21
|
### Changed
|
|
10
22
|
|
|
@@ -3,6 +3,6 @@ export declare class ClientException extends Exception {
|
|
|
3
3
|
readonly serviceName: string;
|
|
4
4
|
readonly originalStatusCode?: number;
|
|
5
5
|
private static readonly statusCodeMap;
|
|
6
|
-
constructor(serviceName: string, originalStatusCode?: number, details?: any, statusCodeMapOverride?: Record<number, number>);
|
|
6
|
+
constructor(serviceName: string, originalStatusCode?: number, details?: any, originalMessage?: string, statusCodeMapOverride?: Record<number, number>);
|
|
7
7
|
private static convertStatusCode;
|
|
8
8
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClientException = void 0;
|
|
4
4
|
const exception_1 = require("./exception");
|
|
5
5
|
class ClientException extends exception_1.Exception {
|
|
6
|
-
constructor(serviceName, originalStatusCode, details, statusCodeMapOverride) {
|
|
7
|
-
super(`Dependent service "${serviceName}" returned error`, ClientException.convertStatusCode(originalStatusCode, statusCodeMapOverride), details);
|
|
6
|
+
constructor(serviceName, originalStatusCode, details, originalMessage, statusCodeMapOverride) {
|
|
7
|
+
super(`Dependent service "${serviceName}" returned error: ${originalMessage !== null && originalMessage !== void 0 ? originalMessage : 'Unknown error'}`, ClientException.convertStatusCode(originalStatusCode, statusCodeMapOverride), details);
|
|
8
8
|
this.serviceName = serviceName;
|
|
9
9
|
this.originalStatusCode = originalStatusCode;
|
|
10
10
|
}
|
|
@@ -130,7 +130,7 @@ class HttpClient {
|
|
|
130
130
|
const hostname = ((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)
|
|
131
131
|
? new url_1.URL(error.config.url, error.config.baseURL).hostname
|
|
132
132
|
: 'N/A';
|
|
133
|
-
throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, this.clientExceptionStatusCodeMapOverride);
|
|
133
|
+
throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.message, this.clientExceptionStatusCodeMapOverride);
|
|
134
134
|
});
|
|
135
135
|
this.client.interceptors.response.use((response) => {
|
|
136
136
|
if (this.logOptions.enabledLogs.includes(HttpLogType.responses)) {
|
|
@@ -169,7 +169,7 @@ class HttpClient {
|
|
|
169
169
|
const hostname = ((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)
|
|
170
170
|
? new url_1.URL(error.config.url, error.config.baseURL).hostname
|
|
171
171
|
: 'N/A';
|
|
172
|
-
throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, this.clientExceptionStatusCodeMapOverride);
|
|
172
|
+
throw new clientException_1.ClientException(hostname, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.status, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.details, serializedAxiosError === null || serializedAxiosError === void 0 ? void 0 : serializedAxiosError.message, this.clientExceptionStatusCodeMapOverride);
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
static extractRequestLogData(requestConfig) {
|
|
@@ -23,7 +23,8 @@ export interface Auth0Secret {
|
|
|
23
23
|
}
|
|
24
24
|
export interface TokenProviderOptions {
|
|
25
25
|
/**
|
|
26
|
-
* Either an Axios instance or an @atsquad/httpclient instance, by default it creates an
|
|
26
|
+
* Either an Axios instance or an @atsquad/httpclient instance, by default it creates an @atsquad/httpclient instance without cache
|
|
27
|
+
* with retries
|
|
27
28
|
*/
|
|
28
29
|
httpClient?: TokenProviderHttpClient;
|
|
29
30
|
/**
|
|
@@ -4,14 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
7
|
-
const
|
|
7
|
+
const httpClient_1 = __importDefault(require("../httpClient/httpClient"));
|
|
8
8
|
class TokenProvider {
|
|
9
9
|
/**
|
|
10
10
|
* Create a new Instance of the TokenProvider
|
|
11
11
|
*/
|
|
12
12
|
constructor(options) {
|
|
13
13
|
var _a;
|
|
14
|
-
this.httpClient =
|
|
14
|
+
this.httpClient =
|
|
15
|
+
(_a = options.httpClient) !== null && _a !== void 0 ? _a : new httpClient_1.default({
|
|
16
|
+
enableCache: false,
|
|
17
|
+
enableRetry: true,
|
|
18
|
+
retryOptions: {
|
|
19
|
+
retry: 3,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
15
22
|
this.configuration = options.tokenConfiguration;
|
|
16
23
|
}
|
|
17
24
|
/**
|
package/lib/util.d.ts
CHANGED
package/lib/util.js
CHANGED
|
@@ -53,7 +53,8 @@ function serializeAxiosError(error) {
|
|
|
53
53
|
const { status, data } = error.response;
|
|
54
54
|
return {
|
|
55
55
|
status: (_a = data.originalStatusCode) !== null && _a !== void 0 ? _a : status,
|
|
56
|
-
details: data.details && Object.keys(data.details).length > 0 ? data.details : data,
|
|
56
|
+
details: data.details && Object.keys(data.details).length > 0 ? data.details : data,
|
|
57
|
+
message: data.message,
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
exports.serializeAxiosError = serializeAxiosError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-essentials-ts",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|