@ddd-ts-kit/winston 0.105.0 → 0.106.0

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/README.fr.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [English](README.md) · **Français**
2
- <!-- translation-of: README.md sha256:ab7605c80e1a9d8d -->
2
+ <!-- translation-of: README.md sha256:bc4f0653dd403f2d -->
3
3
 
4
4
  # @ddd-ts-kit/winston
5
5
 
@@ -50,7 +50,8 @@ export function createLogger(scope: ExecutionScope, settings: LogSettings): Wins
50
50
  import { tracing } from '@/platform/observability/tracing'; // en premier
51
51
  import { createLogger } from '@/platform/observability/create-logger';
52
52
  import { AsyncLocalStorageExecutionScope } from '@ddd-ts-kit/kernel';
53
- import { createApplication, kernelModule } from '@ddd-ts-kit/di';
53
+ import { kernelModule } from '@ddd-ts-kit/di';
54
+ import { createApplication } from '@ddd-ts-kit/di/tsyringe';
54
55
 
55
56
  const scope = new AsyncLocalStorageExecutionScope();
56
57
  const logger = createLogger(scope, config.log);
@@ -171,11 +172,14 @@ ligne, d'un enfant et de `fields` de la même façon. La valeur de ces clés est
171
172
  `[redacted]`, au premier niveau d'une ligne et un niveau en dessous (`headers.authorization`,
172
173
  `body.password`) :
173
174
 
174
- `password`, `authorization`, `cookie`, `set-cookie`, `token`, `secret`, `apiKey`, `api_key`,
175
- `access_token`, `refresh_token`, `accessToken`, `refreshToken`, `client_secret`
175
+ `password`, `passwd`, `authorization`, `cookie`, `set-cookie`, `token`, `secret`, `apiKey`,
176
+ `api_key`, `x-api-key`, `access_token`, `refresh_token`, `id_token`, `accessToken`,
177
+ `refreshToken`, `idToken`, `client_secret`, `clientSecret`, `client-secret`, `private_key`,
178
+ `privateKey`
176
179
 
177
- `redact: ['iban', 'ssn']` complète la liste. Les noms sont comparés exactement, casse comprise,
178
- et rien n'est cherché plus profond qu'un niveau : journalisez la partie que vous visez, pas une
180
+ `redact: ['iban', 'ssn']` complète la liste. Les noms sont comparés quelle que soit leur casse
181
+ (`Authorization`, `X-Api-Key`), comme le fait `isCredentialKey` du noyau, et rien n'est cherché
182
+ plus profond qu'un niveau, ni dans une liste : journalisez la partie que vous visez, pas une
179
183
  requête HTTP entière. Les objets que vous passez ne sont jamais modifiés : un objet imbriqué est
180
184
  copié quand une clé doit être masquée.
181
185
 
package/README.md CHANGED
@@ -47,7 +47,8 @@ export function createLogger(scope: ExecutionScope, settings: LogSettings): Wins
47
47
  import { tracing } from '@/platform/observability/tracing'; // first
48
48
  import { createLogger } from '@/platform/observability/create-logger';
49
49
  import { AsyncLocalStorageExecutionScope } from '@ddd-ts-kit/kernel';
50
- import { createApplication, kernelModule } from '@ddd-ts-kit/di';
50
+ import { kernelModule } from '@ddd-ts-kit/di';
51
+ import { createApplication } from '@ddd-ts-kit/di/tsyringe';
51
52
 
52
53
  const scope = new AsyncLocalStorageExecutionScope();
53
54
  const logger = createLogger(scope, config.log);
@@ -163,11 +164,14 @@ for long. Three things are done in the adapter, so that no call site has to reme
163
164
  `fields` alike. The value of these keys is replaced by `[redacted]`, at the top of a line and
164
165
  one level below (`headers.authorization`, `body.password`):
165
166
 
166
- `password`, `authorization`, `cookie`, `set-cookie`, `token`, `secret`, `apiKey`, `api_key`,
167
- `access_token`, `refresh_token`, `accessToken`, `refreshToken`, `client_secret`
167
+ `password`, `passwd`, `authorization`, `cookie`, `set-cookie`, `token`, `secret`, `apiKey`,
168
+ `api_key`, `x-api-key`, `access_token`, `refresh_token`, `id_token`, `accessToken`,
169
+ `refreshToken`, `idToken`, `client_secret`, `clientSecret`, `client-secret`, `private_key`,
170
+ `privateKey`
168
171
 
169
- `redact: ['iban', 'ssn']` adds to the list. Names are matched exactly, case included, and
170
- nothing is looked for deeper than one level: log the part you mean, not a whole request. The
172
+ `redact: ['iban', 'ssn']` adds to the list. Names are matched whatever their case
173
+ (`Authorization`, `X-Api-Key`), as `isCredentialKey` of the kernel does, and nothing is looked
174
+ for deeper than one level, nor inside a list: log the part you mean, not a whole request. The
171
175
  objects you pass are never written to: a nested one is copied when a key has to be hidden.
172
176
 
173
177
  **An error passed as a field** (`logger.error('payment failed', { error })`: the `LogValue` of
@@ -1,7 +1,8 @@
1
1
  import winston from 'winston';
2
2
  /**
3
- * A winston format hiding the value of the given keys at the top of a line and one level
4
- * below. Names are matched exactly, case included. Place it after the formats that add fields.
3
+ * A winston format hiding the value of `CREDENTIAL_KEYS` and of the given keys at the top of a
4
+ * line and one level below. Names are matched without case, as `isCredentialKey` of the kernel
5
+ * does. Place it after the formats that add fields.
5
6
  */
6
7
  export declare function redactCredentials(keys?: readonly string[]): winston.Logform.Format;
7
8
  //# sourceMappingURL=redact-credentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redact-credentials.d.ts","sourceRoot":"","sources":["../../src/formats/redact-credentials.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAcnG"}
1
+ {"version":3,"file":"redact-credentials.d.ts","sourceRoot":"","sources":["../../src/formats/redact-credentials.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAenG"}
@@ -1,14 +1,16 @@
1
- import { CREDENTIAL_KEYS, REDACTED } from '@ddd-ts-kit/kernel';
1
+ import { CREDENTIAL_KEYS, REDACTED, isCredentialKey } from '@ddd-ts-kit/kernel';
2
2
  import winston from 'winston';
3
3
  /**
4
- * A winston format hiding the value of the given keys at the top of a line and one level
5
- * below. Names are matched exactly, case included. Place it after the formats that add fields.
4
+ * A winston format hiding the value of `CREDENTIAL_KEYS` and of the given keys at the top of a
5
+ * line and one level below. Names are matched without case, as `isCredentialKey` of the kernel
6
+ * does. Place it after the formats that add fields.
6
7
  */
7
8
  export function redactCredentials(keys = CREDENTIAL_KEYS) {
8
- const hidden = new Set(keys);
9
+ const added = new Set(keys.map((key) => key.toLowerCase()));
10
+ const hidden = (key) => isCredentialKey(key) || added.has(key.toLowerCase());
9
11
  return winston.format((info) => {
10
12
  for (const [key, value] of Object.entries(info)) {
11
- if (hidden.has(key)) {
13
+ if (hidden(key)) {
12
14
  info[key] = REDACTED;
13
15
  }
14
16
  else if (isRecord(value)) {
@@ -23,7 +25,7 @@ function isRecord(value) {
23
25
  }
24
26
  /** A nested object belongs to the caller: it is copied when a key has to be hidden, never written to. */
25
27
  function withoutCredentials(nested, hidden) {
26
- const credentials = Object.keys(nested).filter((key) => hidden.has(key));
28
+ const credentials = Object.keys(nested).filter(hidden);
27
29
  if (credentials.length === 0) {
28
30
  return nested;
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"redact-credentials.js","sourceRoot":"","sources":["../../src/formats/redact-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAI,GAAsB,eAAe;IACzE,MAAM,MAAM,GAAwB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAElD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;YACvB,CAAC;iBAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,C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QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AACzF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-ts-kit/winston",
3
- "version": "0.105.0",
3
+ "version": "0.106.0",
4
4
  "description": "Adapter of the kernel Logger port on winston, with trace and execution correlation on every line.",
5
5
  "keywords": [
6
6
  "ddd",
@@ -27,6 +27,9 @@
27
27
  },
28
28
  "type": "module",
29
29
  "sideEffects": false,
30
+ "engines": {
31
+ "node": ">=22.12.0"
32
+ },
30
33
  "exports": {
31
34
  ".": {
32
35
  "types": "./dist/index.d.ts",
@@ -37,10 +40,10 @@
37
40
  "dist"
38
41
  ],
39
42
  "dependencies": {
40
- "@ddd-ts-kit/kernel": "0.105.0"
43
+ "@ddd-ts-kit/kernel": "0.106.0"
41
44
  },
42
45
  "devDependencies": {
43
- "@ddd-ts-kit/testing": "0.105.0",
46
+ "@ddd-ts-kit/testing": "0.106.0",
44
47
  "winston": "^3.19.0"
45
48
  },
46
49
  "peerDependencies": {