@defra/lis-hubs-infra-access 0.6.0 → 0.7.0-lreg-406.alpha.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/auth/logging.js +14 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-hubs-infra-access",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-lreg-406.alpha.2",
4
4
  "description": "Shared hub access and capability resolution for the livestock platform.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -3,12 +3,10 @@
3
3
  * @param {object} request Hapi request.
4
4
  */
5
5
  export function logMissingHubServiceJwt(request) {
6
+ const headerPresent = typeof request.headers?.authorization === 'string'
7
+
6
8
  request.logger?.warn?.(
7
- {
8
- authorizationHeaderPresent:
9
- typeof request.headers?.authorization === 'string'
10
- },
11
- 'Hub service JWT missing or bearer authorization header is malformed'
9
+ `Hub service JWT missing or bearer authorization header is malformed [authorizationHeaderPresent=${headerPresent}]`
12
10
  )
13
11
  }
14
12
 
@@ -18,13 +16,15 @@ export function logMissingHubServiceJwt(request) {
18
16
  * @param {Error & { code?: string, claim?: string, reason?: string }} error Validation error.
19
17
  */
20
18
  export function logInvalidHubServiceJwt(request, error) {
21
- request.logger?.warn?.(
22
- {
23
- code: error?.code,
24
- claim: error?.claim,
25
- reason: error?.reason,
26
- message: error?.message
27
- },
28
- 'Hub service JWT validation failed'
29
- )
19
+ const diagnostics = [
20
+ ['code', error?.code],
21
+ ['claim', error?.claim],
22
+ ['reason', error?.reason],
23
+ ['message', error?.message]
24
+ ]
25
+ .filter(([, value]) => value !== undefined)
26
+ .map(([name, value]) => `${name}=${value}`)
27
+ .join(' | ')
28
+
29
+ request.logger?.warn?.(`Hub service JWT validation failed [${diagnostics}]`)
30
30
  }