lambda-essentials-ts 7.0.0-beta → 7.0.3
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/lib/tokenProvider/tokenProvider.js +2 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -280
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
7
7
|
const httpClient_1 = __importDefault(require("../httpClient/httpClient"));
|
|
8
|
+
const logger_1 = __importDefault(require("../logger/logger"));
|
|
8
9
|
class TokenProvider {
|
|
9
10
|
/**
|
|
10
11
|
* Create a new Instance of the TokenProvider
|
|
@@ -13,6 +14,7 @@ class TokenProvider {
|
|
|
13
14
|
this.httpClient =
|
|
14
15
|
options.httpClient ??
|
|
15
16
|
new httpClient_1.default({
|
|
17
|
+
logFunction: (msg) => new logger_1.default().log(msg),
|
|
16
18
|
enableCache: false,
|
|
17
19
|
enableRetry: true,
|
|
18
20
|
retryOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-essentials-ts",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3",
|
|
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,
|
package/CHANGELOG.md
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
6
|
-
|
|
7
|
-
## [7.0.0-beta] - 2025-11-14
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
|
|
11
|
-
- Add 429 status code mapping
|
|
12
|
-
- Changed logging format. Removed the inner `message` object.
|
|
13
|
-
- Update packages
|
|
14
|
-
- Use axios-cache-interceptor instead of axios-cache-adapter
|
|
15
|
-
|
|
16
|
-
## [6.1.1] - 2025-10-27
|
|
17
|
-
|
|
18
|
-
### Changed
|
|
19
|
-
|
|
20
|
-
- TokenProviderHttpClient now uses the http client with retries as default.
|
|
21
|
-
|
|
22
|
-
## [6.1.0] - 2024-09-30
|
|
23
|
-
|
|
24
|
-
### Changed
|
|
25
|
-
|
|
26
|
-
- Preserve the original message in ClientException
|
|
27
|
-
|
|
28
|
-
## [6.0.0] - 2024-02-22
|
|
29
|
-
|
|
30
|
-
### Changed
|
|
31
|
-
|
|
32
|
-
- **[Breaking change]** Upgraded aws-sdk to v3 which has `SecretsManager` and `KMS` replaced by `SecretsManagerClient` and `KMSClient` class.
|
|
33
|
-
The functionality and interface remains the same, the imports need to be changed.
|
|
34
|
-
|
|
35
|
-
## [5.4.0] - 2024-02-08
|
|
36
|
-
|
|
37
|
-
### Added
|
|
38
|
-
|
|
39
|
-
HttpClient options now accept `clientExceptionStatusCodeMapOverride` which can be used to override the default HTTP error status code mapping. This is useful e.g. when a dependent service is not following REST-ful best practices and e.g. returns a 403 when there's an intermittent network error communicating with the authorization service
|
|
40
|
-
|
|
41
|
-
## [5.3.2] - 2024-02-08
|
|
42
|
-
|
|
43
|
-
### Fixed
|
|
44
|
-
|
|
45
|
-
Error details of external HTTP error responses are propagated correctly
|
|
46
|
-
|
|
47
|
-
## [5.3.1] - 2023-10-25
|
|
48
|
-
|
|
49
|
-
### Fixed
|
|
50
|
-
|
|
51
|
-
The `getUserToken()` and `getUserPrincipal()` order was wrongly set in version `5.3.0`. The new fixed
|
|
52
|
-
priority order:
|
|
53
|
-
|
|
54
|
-
`getUserToken()`
|
|
55
|
-
|
|
56
|
-
1. `request.authorizerContext.jwt`
|
|
57
|
-
2. `request.authorizerContext.accessToken` (new)
|
|
58
|
-
3. `request.headers.Authorization`
|
|
59
|
-
|
|
60
|
-
`getUserPrincipal()`
|
|
61
|
-
|
|
62
|
-
1. `authorizerContext.canonicalId` (**prefer canonicalId**)
|
|
63
|
-
2. `authorizerContext.principalId` (new)
|
|
64
|
-
3. `request.headers.Authorization`
|
|
65
|
-
|
|
66
|
-
## [5.3.0] - 2023-09-07
|
|
67
|
-
|
|
68
|
-
### Changed
|
|
69
|
-
|
|
70
|
-
The `getUserToken()` and `getUserPrincipal()` methods now support multiple sources of for their values
|
|
71
|
-
|
|
72
|
-
`getUserToken()` in priority order:
|
|
73
|
-
|
|
74
|
-
1. `request.authorizerContext.accessToken` (new)
|
|
75
|
-
2. `request.authorizerContext.jwt`
|
|
76
|
-
3. `request.headers.Authorization`
|
|
77
|
-
|
|
78
|
-
`getUserPrincipal()` in priority order:
|
|
79
|
-
|
|
80
|
-
1. `authorizerContext.principalId` (new)
|
|
81
|
-
2. `authorizerContext.canonicalId`
|
|
82
|
-
3. `request.headers.Authorization`
|
|
83
|
-
|
|
84
|
-
## [5.2.2] - 2023-08-25
|
|
85
|
-
|
|
86
|
-
### Added
|
|
87
|
-
|
|
88
|
-
HttpClient now also logs unexpected (e.g. network) errors that are not coming from Axios
|
|
89
|
-
|
|
90
|
-
## [5.2.0] - 2023-06-08
|
|
91
|
-
|
|
92
|
-
### Added
|
|
93
|
-
|
|
94
|
-
Tracking of `canonicalId` and `correlationId` in New Relic.
|
|
95
|
-
|
|
96
|
-
!IMPORTANT! You must exclude the `newrelic` module from `webpack.config.ts` like so:
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
externals: ['newrelic']
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Added
|
|
103
|
-
|
|
104
|
-
The `DeleteRequest` model.
|
|
105
|
-
|
|
106
|
-
## [5.1.10] - 2023-01-13
|
|
107
|
-
|
|
108
|
-
### Changed
|
|
109
|
-
|
|
110
|
-
The error middleware logs `4xx` errors with log level `WARN` (previously `INFO`).
|
|
111
|
-
|
|
112
|
-
## [5.1.9] - 2023-01-04
|
|
113
|
-
|
|
114
|
-
### Changed
|
|
115
|
-
|
|
116
|
-
Upgraded jsonwebtoken version to 9.0.0 and aws-sdk to version 2.1287.0
|
|
117
|
-
|
|
118
|
-
## [5.1.8] - 2022-12-15
|
|
119
|
-
|
|
120
|
-
### Changed
|
|
121
|
-
|
|
122
|
-
Removed client_secret from API response
|
|
123
|
-
|
|
124
|
-
## [5.1.7] - 2022-12-13
|
|
125
|
-
|
|
126
|
-
### Changed
|
|
127
|
-
|
|
128
|
-
Add timeout option in HttpClient. If no value is provided the default is no timeout.
|
|
129
|
-
|
|
130
|
-
## [5.1.6] - 2022-11-30
|
|
131
|
-
|
|
132
|
-
### Changed
|
|
133
|
-
|
|
134
|
-
Removed logging of client_secret
|
|
135
|
-
|
|
136
|
-
## [5.1.5] - 2022-11-15
|
|
137
|
-
|
|
138
|
-
### Changed
|
|
139
|
-
|
|
140
|
-
The fix described in 5.1.4 missed one instance where the bug can occur. This change covers all known instances.
|
|
141
|
-
|
|
142
|
-
## [5.1.4] - 2022-11-08
|
|
143
|
-
|
|
144
|
-
### Changed
|
|
145
|
-
|
|
146
|
-
Using `baseURL` in the axios config without specifying the full URL resulted in an error in the exception handling. So the `AxiosError` was thrown instead of a customer `ClientException`.
|
|
147
|
-
|
|
148
|
-
## [5.1.3] - 2022-10-03
|
|
149
|
-
|
|
150
|
-
### Changed
|
|
151
|
-
|
|
152
|
-
RequestLogger now logs only `Host`, 'User-Agent`, `orion-correlation-id-parent`, `orion-correlation-id-root` headers.
|
|
153
|
-
|
|
154
|
-
## [5.1.2] - 2022-09-14
|
|
155
|
-
|
|
156
|
-
### Changed
|
|
157
|
-
|
|
158
|
-
Properties `stageVariables`, `isBase64Encoded` and `route` from openapi-factory are available in the Typescript definitions.
|
|
159
|
-
|
|
160
|
-
## [5.1.1] - 2022-09-05
|
|
161
|
-
|
|
162
|
-
### Changed
|
|
163
|
-
|
|
164
|
-
HttpApi payload version 2.0 events supported for openApiWrapper.
|
|
165
|
-
|
|
166
|
-
## [5.1.0] - 2022-09-05
|
|
167
|
-
|
|
168
|
-
### Changed
|
|
169
|
-
|
|
170
|
-
Dependencies aren't pinned to a fixed version to allow users of the library to independently upgrade minor (devDependencies) and patch (dependencies) versions. This will simplify fixing security alerts faster than in this library, for example by applying `npm audit fix`.
|
|
171
|
-
|
|
172
|
-
## [5.0.0] - 2022-02-22
|
|
173
|
-
|
|
174
|
-
### Changed
|
|
175
|
-
|
|
176
|
-
- **[Breaking change]** `TokenProvider` was replaced by more specific `KmsTokenProvider` class.
|
|
177
|
-
The functionality and interface remains the same, the imports need to be changed.
|
|
178
|
-
|
|
179
|
-
### Added
|
|
180
|
-
|
|
181
|
-
- New `SecretsManagerTokenProvider` that relies on AWS Secrets Manager to retrieve client ID and client secret.
|
|
182
|
-
The advantage of using AWS Secrets Manager is that it can be supplied with a secret rotation function.
|
|
183
|
-
|
|
184
|
-
## [4.1.5] - 2022-02-10
|
|
185
|
-
|
|
186
|
-
### Changed
|
|
187
|
-
|
|
188
|
-
`ClientException` now maps `HTTP 422` client responses to `HTTP 422` server responses (was `HTTP 503` before).
|
|
189
|
-
|
|
190
|
-
## [4.1.2] - 2021-12-02
|
|
191
|
-
|
|
192
|
-
### Changed
|
|
193
|
-
|
|
194
|
-
Expose the `Location`, `Access-Control-Allow-Origin` and `orion-correlation-id-root` headers
|
|
195
|
-
|
|
196
|
-
## [4.1.1] - 2021-11-22
|
|
197
|
-
|
|
198
|
-
### Fixed
|
|
199
|
-
|
|
200
|
-
- `ApiResponse` default content-type header was renamed to `Content-Type` to overwrite the default header
|
|
201
|
-
of [openapi-factory.js](https://github.com/Rhosys/openapi-factory.js/blob/release/5.2/src/response.js#L15)
|
|
202
|
-
- Also upgraded `openapi-factory.js` to get support of over-writing response headers
|
|
203
|
-
|
|
204
|
-
## [4.1.0] - 2021-11-22
|
|
205
|
-
|
|
206
|
-
### Changed
|
|
207
|
-
|
|
208
|
-
- `ApiResponse` default content-type header was changed from `application/links+json` to `application/hal+json`
|
|
209
|
-
|
|
210
|
-
## [4.0.0] - 2021-11-12
|
|
211
|
-
|
|
212
|
-
### Changed
|
|
213
|
-
|
|
214
|
-
- `HttpClient` the [retryAdapterEnhancer axios adapter](https://github.com/kuitos/axios-extensions#cacheadapterenhancer)
|
|
215
|
-
was replaced by the more flexible [axios-cache-adapter](https://github.com/RasCarlito/axios-cache-adapter).
|
|
216
|
-
- **[Breaking change]** `HttpClientOptions.cacheOptions` now accepts [extensive cache configuration](https://github.com/RasCarlito/axios-cache-adapter/blob/master/axios-cache-adapter.d.ts#L26).
|
|
217
|
-
- The cache is now partitioned by `canonical_id` JWT claim.
|
|
218
|
-
|
|
219
|
-
## [3.0.1] - 2021-09-13
|
|
220
|
-
|
|
221
|
-
### Fixed
|
|
222
|
-
|
|
223
|
-
- Downgraded Axios to 0.21.1 due to response interceptors not being applied correctly in 0.21.2. [There has been a fix to
|
|
224
|
-
axios but a version with the fix is not available yet.](https://github.com/axios/axios/commit/83ae3830e4070adbcdcdcdd6e8afbac568afd708)
|
|
225
|
-
|
|
226
|
-
## [3.0.0] - 2021-09-10
|
|
227
|
-
|
|
228
|
-
### Changed
|
|
229
|
-
|
|
230
|
-
- `HttpClient` the [retryAdapterEnhancer axios adapter](https://github.com/kuitos/axios-extensions#retryadapterenhancer)
|
|
231
|
-
was replaced by the more flexible [retry-axios interceptor](https://github.com/JustinBeckwith/retry-axios).
|
|
232
|
-
- **[Breaking change]** `HttpClientOptions.retryOptions` now accepts [extensive retry configuration](https://github.com/JustinBeckwith/retry-axios/blob/v2.6.0/src/index.ts#L11)
|
|
233
|
-
such as specifying HTTP status codes that should be retried.
|
|
234
|
-
- **[Breaking change]** All HTTP status codes are no longer retried by default. The new default are these ranges:
|
|
235
|
-
- [100, 199] Informational, request still processing
|
|
236
|
-
- [429, 429] Too Many Requests
|
|
237
|
-
- [500, 599] Server errors
|
|
238
|
-
|
|
239
|
-
## [2.2.2] - 2021-07-08
|
|
240
|
-
|
|
241
|
-
### Fixed bugs
|
|
242
|
-
|
|
243
|
-
- Some HTTP error log statements were throwing exceptions. This was due to accessing `error.request.headers[orionCorrelationIdRoot]`
|
|
244
|
-
from Axios error object, where the `headers` object was `undefined`. The correct field was `error.config.headers`.
|
|
245
|
-
|
|
246
|
-
## [2.2.1] - 2021-07-08
|
|
247
|
-
|
|
248
|
-
### Changed
|
|
249
|
-
|
|
250
|
-
- `HttpClient` logs additional request data (query parameters, body).
|
|
251
|
-
|
|
252
|
-
### Added
|
|
253
|
-
|
|
254
|
-
- `HttpClientOptions` now accepts `logOptions` object that allows enabling informational request and **response (new)** logs.
|
|
255
|
-
|
|
256
|
-
```js
|
|
257
|
-
{
|
|
258
|
-
logOptions: {
|
|
259
|
-
enabledLogs: [HttpLogType.requests, HttpLogType.responses];
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## [2.1.0] - 2021-03-11
|
|
265
|
-
|
|
266
|
-
### Changed
|
|
267
|
-
|
|
268
|
-
- ClientException propagates the original status code and details through multiple services. E.g. instead of `error.detials?.data.details?.userDefinedProp` use `error.details?.userDefinedProp`
|
|
269
|
-
|
|
270
|
-
## [2.0.0] - 2021-03-08
|
|
271
|
-
|
|
272
|
-
### Changed
|
|
273
|
-
|
|
274
|
-
- ClientException no longer wraps details in an `error` property. Instead of `error.details?.error.userDefinedProp` use `error.details?.userDefinedProp`
|
|
275
|
-
|
|
276
|
-
## [1.2.0] - 2021-02-16
|
|
277
|
-
|
|
278
|
-
### Updated
|
|
279
|
-
|
|
280
|
-
- [IMPORTANT!] HttpClient throws serialized Axios errors through ClientExceptions.
|