field-redactor 1.1.0 → 1.5.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.
Files changed (123) hide show
  1. package/.github/workflows/ci.yml +38 -0
  2. package/CHANGELOG.md +156 -0
  3. package/README.md +64 -647
  4. package/dist/configValidator.d.ts +10 -0
  5. package/dist/configValidator.d.ts.map +1 -0
  6. package/dist/configValidator.js +94 -0
  7. package/dist/configValidator.js.map +1 -0
  8. package/dist/copyOnWriteHelpers.d.ts +20 -0
  9. package/dist/copyOnWriteHelpers.d.ts.map +1 -0
  10. package/dist/copyOnWriteHelpers.js +58 -0
  11. package/dist/copyOnWriteHelpers.js.map +1 -0
  12. package/dist/customObjectManager.d.ts +13 -7
  13. package/dist/customObjectManager.d.ts.map +1 -1
  14. package/dist/customObjectManager.js +30 -29
  15. package/dist/customObjectManager.js.map +1 -1
  16. package/dist/dryRun.d.ts +8 -0
  17. package/dist/dryRun.d.ts.map +1 -0
  18. package/dist/dryRun.js +75 -0
  19. package/dist/dryRun.js.map +1 -0
  20. package/dist/dryRunAttribution.d.ts +8 -0
  21. package/dist/dryRunAttribution.d.ts.map +1 -0
  22. package/dist/dryRunAttribution.js +106 -0
  23. package/dist/dryRunAttribution.js.map +1 -0
  24. package/dist/fieldRedactor.d.ts +43 -5
  25. package/dist/fieldRedactor.d.ts.map +1 -1
  26. package/dist/fieldRedactor.js +124 -23
  27. package/dist/fieldRedactor.js.map +1 -1
  28. package/dist/fieldRedactorConfigBuilder.d.ts +49 -0
  29. package/dist/fieldRedactorConfigBuilder.d.ts.map +1 -0
  30. package/dist/fieldRedactorConfigBuilder.js +98 -0
  31. package/dist/fieldRedactorConfigBuilder.js.map +1 -0
  32. package/dist/fieldRedactorDeps.d.ts +17 -0
  33. package/dist/fieldRedactorDeps.d.ts.map +1 -0
  34. package/dist/fieldRedactorDeps.js +41 -0
  35. package/dist/fieldRedactorDeps.js.map +1 -0
  36. package/dist/index.d.ts +7 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +14 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/jsonWalk.d.ts +11 -0
  41. package/dist/jsonWalk.d.ts.map +1 -0
  42. package/dist/jsonWalk.js +86 -0
  43. package/dist/jsonWalk.js.map +1 -0
  44. package/dist/objectRedactor.d.ts +9 -34
  45. package/dist/objectRedactor.d.ts.map +1 -1
  46. package/dist/objectRedactor.js +11 -271
  47. package/dist/objectRedactor.js.map +1 -1
  48. package/dist/objectRedactorCow.d.ts +35 -0
  49. package/dist/objectRedactorCow.d.ts.map +1 -0
  50. package/dist/objectRedactorCow.js +300 -0
  51. package/dist/objectRedactorCow.js.map +1 -0
  52. package/dist/objectRedactorCustomObject.d.ts +49 -0
  53. package/dist/objectRedactorCustomObject.d.ts.map +1 -0
  54. package/dist/objectRedactorCustomObject.js +138 -0
  55. package/dist/objectRedactorCustomObject.js.map +1 -0
  56. package/dist/objectRedactorHelpers.d.ts +9 -0
  57. package/dist/objectRedactorHelpers.d.ts.map +1 -0
  58. package/dist/objectRedactorHelpers.js +58 -0
  59. package/dist/objectRedactorHelpers.js.map +1 -0
  60. package/dist/objectRedactorMutation.d.ts +10 -0
  61. package/dist/objectRedactorMutation.d.ts.map +1 -0
  62. package/dist/objectRedactorMutation.js +89 -0
  63. package/dist/objectRedactorMutation.js.map +1 -0
  64. package/dist/objectRedactorSync.d.ts +2 -0
  65. package/dist/objectRedactorSync.d.ts.map +1 -0
  66. package/dist/objectRedactorSync.js +7 -0
  67. package/dist/objectRedactorSync.js.map +1 -0
  68. package/dist/objectRedactorTraversal.d.ts +57 -0
  69. package/dist/objectRedactorTraversal.d.ts.map +1 -0
  70. package/dist/objectRedactorTraversal.js +576 -0
  71. package/dist/objectRedactorTraversal.js.map +1 -0
  72. package/dist/presets.d.ts +22 -0
  73. package/dist/presets.d.ts.map +1 -0
  74. package/dist/presets.js +50 -0
  75. package/dist/presets.js.map +1 -0
  76. package/dist/primitiveRedactor.d.ts +13 -8
  77. package/dist/primitiveRedactor.d.ts.map +1 -1
  78. package/dist/primitiveRedactor.js +32 -27
  79. package/dist/primitiveRedactor.js.map +1 -1
  80. package/dist/redactionRules.d.ts +23 -0
  81. package/dist/redactionRules.d.ts.map +1 -0
  82. package/dist/redactionRules.js +76 -0
  83. package/dist/redactionRules.js.map +1 -0
  84. package/dist/regexUtils.d.ts +3 -0
  85. package/dist/regexUtils.d.ts.map +1 -0
  86. package/dist/regexUtils.js +8 -0
  87. package/dist/regexUtils.js.map +1 -0
  88. package/dist/secretManager.d.ts +18 -5
  89. package/dist/secretManager.d.ts.map +1 -1
  90. package/dist/secretManager.js +49 -11
  91. package/dist/secretManager.js.map +1 -1
  92. package/dist/types.d.ts +110 -7
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js +13 -6
  95. package/dist/types.js.map +1 -1
  96. package/dist/valuePatternMatcher.d.ts +15 -0
  97. package/dist/valuePatternMatcher.d.ts.map +1 -0
  98. package/dist/valuePatternMatcher.js +30 -0
  99. package/dist/valuePatternMatcher.js.map +1 -0
  100. package/docs/guides/anti-patterns.md +107 -0
  101. package/docs/guides/metadata-redaction.md +112 -0
  102. package/docs/guides/migration-1.2-to-1.5.md +106 -0
  103. package/docs/guides/secret-key-modes.md +108 -0
  104. package/docs/guides/value-pattern-redaction.md +58 -0
  105. package/docs/reference/config.md +135 -0
  106. package/docs/release-notes/2.0.0.md +19 -0
  107. package/docs/release-notes/2.1.0.md +17 -0
  108. package/docs/release-notes/2.2.0.md +16 -0
  109. package/docs/release-notes/2.3.0.md +17 -0
  110. package/docs/release-notes/2.3.1.md +17 -0
  111. package/docs/release-notes/2.4.0.md +30 -0
  112. package/docs/release-notes/2.5.0.md +33 -0
  113. package/docs/release-notes/2.5.1.md +17 -0
  114. package/docs/release-notes/README.md +30 -0
  115. package/docs/release-notes/v1.0.0.md +17 -0
  116. package/docs/release-notes/v1.1.0.md +18 -0
  117. package/docs/release-notes/v1.2.0.md +18 -0
  118. package/docs/release-notes/v1.2.1.md +16 -0
  119. package/docs/release-notes/v1.2.2.md +19 -0
  120. package/docs/release-notes/v1.3.0.md +112 -0
  121. package/docs/release-notes/v1.5.0.md +88 -0
  122. package/jest.config.js +4 -1
  123. package/package.json +3 -3
@@ -0,0 +1,38 @@
1
+ # Build and test on push/PR. Intentionally minimal permissions and no secrets.
2
+ name: CI
3
+
4
+ on:
5
+ push:
6
+ branches: [master, main]
7
+ pull_request:
8
+
9
+ # Default GITHUB_TOKEN is read-only; no packages, deployments, or repo writes.
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: ci-${{ github.workflow }}-${{ github.ref }}
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ build-and-test:
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 15
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
+
25
+ - name: Setup Node.js
26
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
27
+ with:
28
+ node-version-file: .nvmrc
29
+ cache: yarn
30
+
31
+ - name: Install dependencies
32
+ run: yarn install --frozen-lockfile --non-interactive
33
+
34
+ - name: Build
35
+ run: yarn build
36
+
37
+ - name: Test
38
+ run: yarn test
package/CHANGELOG.md ADDED
@@ -0,0 +1,156 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.5.0] - 2026-06-24
9
+
10
+ Published npm release bundling **v1.2.1**–**v1.3.0** git work and former internal milestones **2.4.0**–**2.5.1**. See [docs/guides/migration-1.2-to-1.5.md](docs/guides/migration-1.2-to-1.5.md) when upgrading from npm **1.2.x**.
11
+
12
+ ### Added
13
+
14
+ - **`FieldRedactorConfigBuilder.usePreset()`** — merge preset or partial config into the builder; regex/schemas accumulate, scalars apply only when unset.
15
+ - **`dryRun` path rule attribution** — `report.pathRules` explains which rule (`schema`, `opaque`, `deep`, `remove`, `shallow`, `value`, `default`) caused each redacted or deleted path, with optional regex `pattern` and schema metadata.
16
+ - **Value-pattern redaction** — opt-in `valuePatterns` redacts scalars when their string form matches a regex, regardless of key name; lowest precedence after key and schema rules.
17
+ - **`FieldRedactorConfigBuilder.valuePattern()`** — fluent builder support for value patterns.
18
+ - **Anti-patterns guide** — [docs/guides/anti-patterns.md](docs/guides/anti-patterns.md).
19
+ - **Value-pattern guide** — [docs/guides/value-pattern-redaction.md](docs/guides/value-pattern-redaction.md).
20
+ - **Migration guide** — [docs/guides/migration-1.2-to-1.5.md](docs/guides/migration-1.2-to-1.5.md).
21
+ - **Exported types** — `DryRunPathRule`, `RedactionRuleLabel`, `MatchedSchemaReport`.
22
+ - **Release notes** — see [docs/release-notes/v1.5.0.md](docs/release-notes/v1.5.0.md).
23
+
24
+ ### Changed
25
+
26
+ - **Unified JSON traversal** — `ObjectRedactorTraversal` handles sync in-place, copy-on-write, and async in-place redaction via a shared `ContainerMutation` adapter.
27
+ - **Shared custom-object handlers** — match-type dispatch consolidated in `objectRedactorCustomObject.ts`.
28
+ - Config validator duplicate-regex warnings apply across key-rule fields only (not between `secretKeys` and `valuePatterns`).
29
+ - Internal refactor: `fieldRedactorDeps`, `regexUtils`, dry-run attribution resolvers, shared test helpers.
30
+ - Git tags `2.0.0`–`2.5.1` removed; development milestones are consolidated under this release.
31
+
32
+ ### Fixed
33
+
34
+ - Async in-place redaction uses the same traversal adapter as sync, aligning nested object and array behavior across modes.
35
+
36
+ ## [2.5.1] - 2026-06-24 (internal milestone — included in 1.5.0)
37
+
38
+ ### Changed
39
+
40
+ - **Unified JSON traversal** — `ObjectRedactorTraversal` handles sync in-place, copy-on-write, and async in-place redaction via a shared `ContainerMutation` adapter; `ObjectRedactor` is now a thin orchestrator.
41
+ - **Shared custom-object handlers** — match-type dispatch consolidated in `objectRedactorCustomObject.ts` for sync and async paths.
42
+ - **Release notes** — see [docs/release-notes/2.5.1.md](docs/release-notes/2.5.1.md).
43
+
44
+ ### Fixed
45
+
46
+ - Async in-place redaction uses the same traversal adapter as sync, aligning nested object and array behavior across modes.
47
+
48
+ ## [2.5.0] - 2026-06-24 (internal milestone — included in 1.5.0)
49
+
50
+ ### Added
51
+
52
+ - **Value-pattern redaction** — opt-in `valuePatterns` redacts scalars when their string form matches a regex, regardless of key name; lowest precedence after key and schema rules.
53
+ - **`FieldRedactorConfigBuilder.valuePattern()`** — fluent builder support for value patterns.
54
+ - **`dryRun` value attribution** — `report.pathRules` includes `rule: 'value'` with the matching pattern.
55
+ - **Value-pattern guide** — [docs/guides/value-pattern-redaction.md](docs/guides/value-pattern-redaction.md).
56
+ - **Release notes** — see [docs/release-notes/2.5.0.md](docs/release-notes/2.5.0.md).
57
+
58
+ ### Changed
59
+
60
+ - Config validator duplicate-regex warnings apply across key-rule fields only (not between `secretKeys` and `valuePatterns`, which match different targets).
61
+ - Internal refactor: `fieldRedactorDeps`, `regexUtils`, dry-run attribution resolvers, shared test helpers.
62
+
63
+ ### Internal milestones (`2.x` tags)
64
+
65
+ Superseded by **v1.5.0** npm release. See [docs/release-notes/v1.5.0.md](docs/release-notes/v1.5.0.md).
66
+
67
+ ## [2.4.0] - 2026-06-24 (internal milestone — included in 1.5.0)
68
+
69
+ ### Added
70
+
71
+ - **`FieldRedactorConfigBuilder.usePreset()`** — merge preset or partial config into the builder; regex/schemas accumulate, scalars apply only when unset.
72
+ - **`dryRun` path rule attribution** — `report.pathRules` explains which rule (`schema`, `opaque`, `deep`, `remove`, `shallow`, `default`) caused each redacted or deleted path, with optional regex `pattern` and schema metadata.
73
+ - **Anti-patterns guide** — [docs/guides/anti-patterns.md](docs/guides/anti-patterns.md) for common configuration mistakes.
74
+ - **Exported types** — `DryRunPathRule`, `RedactionRuleLabel`, `MatchedSchemaReport`.
75
+ - **Release notes** — see [docs/release-notes/2.4.0.md](docs/release-notes/2.4.0.md).
76
+
77
+ ### Internal milestones (`2.x` tags)
78
+
79
+ Superseded by **v1.5.0** npm release. See [docs/release-notes/v1.5.0.md](docs/release-notes/v1.5.0.md).
80
+
81
+ ## [1.3.0] - 2026-06-24
82
+
83
+ ### Added
84
+
85
+ - **Sync redaction API** — `redactSync()`, `redactInPlaceSync()`, and `syncRedactor` config option for redaction without per-field `Promise` overhead.
86
+ - **Copy-on-write redaction** — `redact()` and `redactSync()` use structural sharing by default (`cloneInput: true`); only mutated branches are cloned. Set `cloneInput: false` to mutate in place.
87
+ - **`FieldRedactor.createSafe()`** — factory that requires at least one explicit redaction rule and throws `FieldRedactorConfigurationError` otherwise.
88
+ - **`FieldRedactorConfigBuilder`** — fluent builder mapping doc labels (Shallow, Deep, Opaque, Remove, Schema) to config fields; `build()`, `buildRedactor()`, and `buildSafeRedactor()`.
89
+ - **`dryRun()` / `dryRunSync()`** — redact a snapshot and return `{ result, report }` with `redactedPaths`, `deletedPaths`, and `matchedSchemas` (optional `schemaName` when schemas are named via the builder).
90
+ - **Configuration validation** — `validateFieldRedactorConfig()`, `hasExplicitRedactionRules()`, `configWarnings` on instances, `strict` and `onConfigWarning` options.
91
+ - **Presets** — `presets.loggingMetadata()`, `presets.applicationLogging()`, and `presets.keyValueEntries()` derived from integration test fixtures.
92
+ - **Documentation** — split into `docs/guides/` (secret key modes, metadata redaction) and `docs/reference/config.md`; README quickstart and decision guide.
93
+ - **Release notes** — see [docs/release-notes/v1.3.0.md](docs/release-notes/v1.3.0.md).
94
+
95
+ ### Internal milestones (`2.x` tags)
96
+
97
+ Development tags `2.0.0`–`2.3.1` track incremental work toward `1.3.0`. See [docs/release-notes/README.md](docs/release-notes/README.md).
98
+
99
+ ### Changed
100
+
101
+ - Default `redact()` / `redactSync()` behavior now uses copy-on-write instead of a full deep clone of the input. The input is still not mutated unless `cloneInput: false`.
102
+ - Documentation and JSDoc adopt conceptual labels (Shallow, Deep, Opaque, Remove, Schema) alongside existing config field names.
103
+
104
+ ### Fixed
105
+
106
+ - Internal sync and copy-on-write traversal unified behind a shared `ContainerMutation` layer (correctness and maintainability).
107
+
108
+ ## [1.2.2] - 2026-06-24
109
+
110
+ ### Added
111
+
112
+ - Export `FieldRedactorError` and `FieldRedactorConfigurationError` from the public API.
113
+
114
+ ### Changed
115
+
116
+ - Replace heavy `any` usage with explicit JSON and redaction types (`JsonValue`, `RedactableInput`, generic `redact<T>()`, etc.).
117
+
118
+ ## [1.2.1] - 2026-06-24
119
+
120
+ ### Changed
121
+
122
+ - Relax custom object schema matching: objects match when they contain every schema key; extra keys on the input are allowed.
123
+
124
+ ### Fixed
125
+
126
+ - Sibling-key custom object redaction for falsy values (`""`, `0`, `false`) when the sibling key is present.
127
+ - `ignoreBooleans` default documented to match code (`false` — booleans are redacted by default).
128
+
129
+ ## [1.2.0] - 2025-02-10
130
+
131
+ ### Added
132
+
133
+ - **`deleteSecretKeys`** — Remove matching keys from output entirely.
134
+
135
+ ## [1.1.0] - 2025-01-30
136
+
137
+ ### Changed
138
+
139
+ - Primitives, `null`, `undefined`, `Date`, and functions at the root are returned unchanged instead of throwing.
140
+
141
+ ## [1.0.0] - 2025-01-24
142
+
143
+ ### Added
144
+
145
+ - Initial public release: regex key rules, custom object schemas with sibling-key indirection, async `redact()` / `redactInPlace()`, and configurable redactor functions.
146
+
147
+ [1.5.0]: https://github.com/mologna/field-redactor/releases/tag/v1.5.0
148
+ [2.5.1]: https://github.com/mologna/field-redactor/compare/2.5.0...2.5.1
149
+ [2.5.0]: https://github.com/mologna/field-redactor/compare/2.4.0...2.5.0
150
+ [2.4.0]: https://github.com/mologna/field-redactor/compare/2.3.1...2.4.0
151
+ [1.3.0]: https://github.com/mologna/field-redactor/compare/v1.2.2...v1.3.0
152
+ [1.2.2]: https://github.com/mologna/field-redactor/compare/v1.2.1...v1.2.2
153
+ [1.2.1]: https://github.com/mologna/field-redactor/compare/v1.2.0...v1.2.1
154
+ [1.2.0]: https://github.com/mologna/field-redactor/compare/v1.1.0...v1.2.0
155
+ [1.1.0]: https://github.com/mologna/field-redactor/compare/v1.0.0...v1.1.0
156
+ [1.0.0]: https://github.com/mologna/field-redactor/releases/tag/v1.0.0