field-redactor 1.6.1 → 1.6.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/.github/workflows/publish.yml +55 -0
- package/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +26 -3
- package/README.md +3 -2
- package/dist/api/fieldRedactor.d.ts +4 -4
- package/dist/api/fieldRedactor.js +8 -8
- package/dist/api/fieldRedactor.js.map +1 -1
- package/dist/api/fieldRedactorConfigBuilder.d.ts +3 -3
- package/dist/api/fieldRedactorConfigBuilder.d.ts.map +1 -1
- package/dist/api/fieldRedactorConfigBuilder.js +7 -9
- package/dist/api/fieldRedactorConfigBuilder.js.map +1 -1
- package/dist/api/fieldRedactorDeps.d.ts +2 -2
- package/dist/api/fieldRedactorDeps.d.ts.map +1 -1
- package/dist/api/fieldRedactorDeps.js +6 -6
- package/dist/api/fieldRedactorDeps.js.map +1 -1
- package/dist/config/configValidator.d.ts.map +1 -1
- package/dist/config/configValidator.js +16 -0
- package/dist/config/configValidator.js.map +1 -1
- package/dist/config/presets.d.ts +2 -2
- package/dist/config/presets.js +1 -1
- package/dist/config/redactionRules.d.ts +10 -5
- package/dist/config/redactionRules.d.ts.map +1 -1
- package/dist/config/redactionRules.js +16 -11
- package/dist/config/redactionRules.js.map +1 -1
- package/dist/engine/objectRedactorHelpers.js +2 -2
- package/dist/engine/objectRedactorHelpers.js.map +1 -1
- package/dist/engine/objectRedactorTraversal.d.ts +1 -0
- package/dist/engine/objectRedactorTraversal.d.ts.map +1 -1
- package/dist/engine/objectRedactorTraversal.js +1 -0
- package/dist/engine/objectRedactorTraversal.js.map +1 -1
- package/dist/rules/ruleResolver.js +2 -2
- package/dist/rules/ruleResolver.js.map +1 -1
- package/dist/rules/secretManager.d.ts +5 -5
- package/dist/rules/secretManager.d.ts.map +1 -1
- package/dist/rules/secretManager.js +13 -8
- package/dist/rules/secretManager.js.map +1 -1
- package/dist/types.d.ts +39 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -4
- package/dist/types.js.map +1 -1
- package/docs/guides/anti-patterns.md +1 -1
- package/docs/guides/metadata-redaction.md +2 -2
- package/docs/guides/migration-1.5-to-1.6.md +6 -4
- package/docs/guides/secret-key-modes.md +9 -14
- package/docs/reference/config.md +2 -2
- package/docs/release-notes/README.md +5 -1
- package/docs/release-notes/v1.6.2.md +26 -0
- package/docs/release-notes/v1.6.3.md +25 -0
- package/examples/README.md +14 -0
- package/examples/dry-run.ts +21 -0
- package/examples/logging-metadata.ts +18 -0
- package/examples/path-rules.ts +23 -0
- package/examples/value-patterns.ts +16 -0
- package/package.json +1 -1
- package/dist/arrayRedaction.d.ts +0 -12
- package/dist/arrayRedaction.d.ts.map +0 -1
- package/dist/arrayRedaction.js +0 -70
- package/dist/arrayRedaction.js.map +0 -1
- package/dist/configValidator.d.ts +0 -9
- package/dist/configValidator.d.ts.map +0 -1
- package/dist/configValidator.js +0 -77
- package/dist/configValidator.js.map +0 -1
- package/dist/copyOnWriteHelpers.d.ts +0 -20
- package/dist/copyOnWriteHelpers.d.ts.map +0 -1
- package/dist/copyOnWriteHelpers.js +0 -58
- package/dist/copyOnWriteHelpers.js.map +0 -1
- package/dist/customObjectFieldHandler.d.ts +0 -21
- package/dist/customObjectFieldHandler.d.ts.map +0 -1
- package/dist/customObjectFieldHandler.js +0 -159
- package/dist/customObjectFieldHandler.js.map +0 -1
- package/dist/customObjectManager.d.ts +0 -28
- package/dist/customObjectManager.d.ts.map +0 -1
- package/dist/customObjectManager.js +0 -60
- package/dist/customObjectManager.js.map +0 -1
- package/dist/customObjectSchemas.d.ts +0 -7
- package/dist/customObjectSchemas.d.ts.map +0 -1
- package/dist/customObjectSchemas.js +0 -35
- package/dist/customObjectSchemas.js.map +0 -1
- package/dist/dryRun.d.ts +0 -9
- package/dist/dryRun.d.ts.map +0 -1
- package/dist/dryRun.js +0 -75
- package/dist/dryRun.js.map +0 -1
- package/dist/dryRunAttribution.d.ts +0 -10
- package/dist/dryRunAttribution.d.ts.map +0 -1
- package/dist/dryRunAttribution.js +0 -14
- package/dist/dryRunAttribution.js.map +0 -1
- package/dist/dryrun/dryRunAttribution.d.ts +0 -10
- package/dist/dryrun/dryRunAttribution.d.ts.map +0 -1
- package/dist/dryrun/dryRunAttribution.js +0 -14
- package/dist/dryrun/dryRunAttribution.js.map +0 -1
- package/dist/engine/objectRedactor.d.ts +0 -18
- package/dist/engine/objectRedactor.d.ts.map +0 -1
- package/dist/engine/objectRedactor.js +0 -38
- package/dist/engine/objectRedactor.js.map +0 -1
- package/dist/engine/objectRedactorSync.d.ts +0 -2
- package/dist/engine/objectRedactorSync.d.ts.map +0 -1
- package/dist/engine/objectRedactorSync.js +0 -7
- package/dist/engine/objectRedactorSync.js.map +0 -1
- package/dist/fieldDisposition.d.ts +0 -3
- package/dist/fieldDisposition.d.ts.map +0 -1
- package/dist/fieldDisposition.js +0 -6
- package/dist/fieldDisposition.js.map +0 -1
- package/dist/fieldRedactor.d.ts +0 -51
- package/dist/fieldRedactor.d.ts.map +0 -1
- package/dist/fieldRedactor.js +0 -165
- package/dist/fieldRedactor.js.map +0 -1
- package/dist/fieldRedactorConfigBuilder.d.ts +0 -55
- package/dist/fieldRedactorConfigBuilder.d.ts.map +0 -1
- package/dist/fieldRedactorConfigBuilder.js +0 -111
- package/dist/fieldRedactorConfigBuilder.js.map +0 -1
- package/dist/fieldRedactorDeps.d.ts +0 -19
- package/dist/fieldRedactorDeps.d.ts.map +0 -1
- package/dist/fieldRedactorDeps.js +0 -43
- package/dist/fieldRedactorDeps.js.map +0 -1
- package/dist/jsonWalk.d.ts +0 -11
- package/dist/jsonWalk.d.ts.map +0 -1
- package/dist/jsonWalk.js +0 -55
- package/dist/jsonWalk.js.map +0 -1
- package/dist/maybeAsync.d.ts +0 -7
- package/dist/maybeAsync.d.ts.map +0 -1
- package/dist/maybeAsync.js +0 -56
- package/dist/maybeAsync.js.map +0 -1
- package/dist/objectRedactor.d.ts +0 -18
- package/dist/objectRedactor.d.ts.map +0 -1
- package/dist/objectRedactor.js +0 -38
- package/dist/objectRedactor.js.map +0 -1
- package/dist/objectRedactorCow.d.ts +0 -35
- package/dist/objectRedactorCow.d.ts.map +0 -1
- package/dist/objectRedactorCow.js +0 -300
- package/dist/objectRedactorCow.js.map +0 -1
- package/dist/objectRedactorCustomObject.d.ts +0 -28
- package/dist/objectRedactorCustomObject.d.ts.map +0 -1
- package/dist/objectRedactorCustomObject.js +0 -57
- package/dist/objectRedactorCustomObject.js.map +0 -1
- package/dist/objectRedactorHelpers.d.ts +0 -9
- package/dist/objectRedactorHelpers.d.ts.map +0 -1
- package/dist/objectRedactorHelpers.js +0 -61
- package/dist/objectRedactorHelpers.js.map +0 -1
- package/dist/objectRedactorMutation.d.ts +0 -10
- package/dist/objectRedactorMutation.d.ts.map +0 -1
- package/dist/objectRedactorMutation.js +0 -89
- package/dist/objectRedactorMutation.js.map +0 -1
- package/dist/objectRedactorSync.d.ts +0 -2
- package/dist/objectRedactorSync.d.ts.map +0 -1
- package/dist/objectRedactorSync.js +0 -7
- package/dist/objectRedactorSync.js.map +0 -1
- package/dist/objectRedactorTraversal.d.ts +0 -41
- package/dist/objectRedactorTraversal.d.ts.map +0 -1
- package/dist/objectRedactorTraversal.js +0 -201
- package/dist/objectRedactorTraversal.js.map +0 -1
- package/dist/pathParsing.d.ts +0 -11
- package/dist/pathParsing.d.ts.map +0 -1
- package/dist/pathParsing.js +0 -53
- package/dist/pathParsing.js.map +0 -1
- package/dist/pathRuleMatcher.d.ts +0 -19
- package/dist/pathRuleMatcher.d.ts.map +0 -1
- package/dist/pathRuleMatcher.js +0 -42
- package/dist/pathRuleMatcher.js.map +0 -1
- package/dist/presets.d.ts +0 -22
- package/dist/presets.d.ts.map +0 -1
- package/dist/presets.js +0 -50
- package/dist/presets.js.map +0 -1
- package/dist/primitiveRedactor.d.ts +0 -33
- package/dist/primitiveRedactor.d.ts.map +0 -1
- package/dist/primitiveRedactor.js +0 -75
- package/dist/primitiveRedactor.js.map +0 -1
- package/dist/redactionRules.d.ts +0 -22
- package/dist/redactionRules.d.ts.map +0 -1
- package/dist/redactionRules.js +0 -74
- package/dist/redactionRules.js.map +0 -1
- package/dist/regexUtils.d.ts +0 -3
- package/dist/regexUtils.d.ts.map +0 -1
- package/dist/regexUtils.js +0 -8
- package/dist/regexUtils.js.map +0 -1
- package/dist/ruleResolver.d.ts +0 -65
- package/dist/ruleResolver.d.ts.map +0 -1
- package/dist/ruleResolver.js +0 -193
- package/dist/ruleResolver.js.map +0 -1
- package/dist/rules/fieldDisposition.d.ts +0 -3
- package/dist/rules/fieldDisposition.d.ts.map +0 -1
- package/dist/rules/fieldDisposition.js +0 -6
- package/dist/rules/fieldDisposition.js.map +0 -1
- package/dist/secretManager.d.ts +0 -32
- package/dist/secretManager.d.ts.map +0 -1
- package/dist/secretManager.js +0 -85
- package/dist/secretManager.js.map +0 -1
- package/dist/traversalServices.d.ts +0 -21
- package/dist/traversalServices.d.ts.map +0 -1
- package/dist/traversalServices.js +0 -3
- package/dist/traversalServices.js.map +0 -1
- package/dist/valuePatternMatcher.d.ts +0 -15
- package/dist/valuePatternMatcher.d.ts.map +0 -1
- package/dist/valuePatternMatcher.js +0 -30
- package/dist/valuePatternMatcher.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Secret key modes
|
|
2
2
|
|
|
3
|
-
FieldRedactor applies **Shallow**, **Deep**, **Opaque**, and **Remove** rules via regex key matching. Throughout the docs, these are the conceptual names; the config fields are `secretKeys`, `deepSecretKeys`, `
|
|
3
|
+
FieldRedactor applies **Shallow**, **Deep**, **Opaque**, and **Remove** rules via regex key matching. Throughout the docs, these are the conceptual names; the config fields are `secretKeys`, `deepSecretKeys`, `opaqueSecretKeys`, and `removeSecretKeys` (legacy aliases `fullSecretKeys` / `deleteSecretKeys` still work).
|
|
4
4
|
|
|
5
5
|
**Precedence** (highest wins): Schema (`customObjects`) → Opaque → Deep → Remove → Shallow → Value-pattern (`valuePatterns`)
|
|
6
6
|
|
|
@@ -20,8 +20,8 @@ Same input for every row:
|
|
|
20
20
|
| --- | --- | --- | --- |
|
|
21
21
|
| **Shallow** | `secretKeys` | `[/email/]` | `contactInfo.email` → `"REDACTED"`; `city`, `username` unchanged |
|
|
22
22
|
| **Deep** | `deepSecretKeys` | `[/contactInfo/]` | All primitives inside `contactInfo` redacted |
|
|
23
|
-
| **Opaque** | `
|
|
24
|
-
| **Remove** | `
|
|
23
|
+
| **Opaque** | `opaqueSecretKeys` | `[/contactInfo/]` | Entire `contactInfo` replaced with `"REDACTED"` |
|
|
24
|
+
| **Remove** | `removeSecretKeys` | `[/authKey/]` | `authKey` key removed from output |
|
|
25
25
|
|
|
26
26
|
### Builder API
|
|
27
27
|
|
|
@@ -74,13 +74,13 @@ await fieldRedactor.redact({
|
|
|
74
74
|
// → email, id, and other primitives under contactInfo are redacted
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
## Opaque (`
|
|
77
|
+
## Opaque (`opaqueSecretKeys`)
|
|
78
78
|
|
|
79
79
|
Stringify the entire value at matching keys, then redact. Typical for objects and arrays you want to hide completely.
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
82
|
const fieldRedactor = new FieldRedactor({
|
|
83
|
-
|
|
83
|
+
opaqueSecretKeys: [/contactInfo/i]
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
await fieldRedactor.redact({
|
|
@@ -89,20 +89,15 @@ await fieldRedactor.redact({
|
|
|
89
89
|
// → { contactInfo: "REDACTED" }
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
## Remove (`
|
|
92
|
+
## Remove (`removeSecretKeys`)
|
|
93
93
|
|
|
94
94
|
Delete matching keys from the output.
|
|
95
95
|
|
|
96
96
|
```typescript
|
|
97
97
|
const fieldRedactor = new FieldRedactor({
|
|
98
|
-
|
|
98
|
+
removeSecretKeys: [/authKey/i]
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
await fieldRedactor.redact({
|
|
102
|
-
// → {
|
|
101
|
+
await fieldRedactor.redact({ authKey: 'secret-token', username: 'alice' });
|
|
102
|
+
// → { username: 'alice' }
|
|
103
103
|
```
|
|
104
|
-
|
|
105
|
-
## Related
|
|
106
|
-
|
|
107
|
-
- [Metadata redaction](metadata-redaction.md) — when sensitivity depends on sibling fields
|
|
108
|
-
- [Configuration reference](../reference/config.md) — all options and API details
|
package/docs/reference/config.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
| — | `syncRedactor` | `(val) => string` | `"REDACTED"` sync | Sync redactor; enables `redactSync()` without per-field Promises |
|
|
9
9
|
| **Shallow** | `secretKeys` | `RegExp[]` | `null` | Redact matching scalar values; if no rules at all, everything matches |
|
|
10
10
|
| **Deep** | `deepSecretKeys` | `RegExp[]` | `[]` | Deeply redact all primitives under matching keys |
|
|
11
|
-
| **Opaque** | `
|
|
12
|
-
| **Remove** | `
|
|
11
|
+
| **Opaque** | `opaqueSecretKeys` | `RegExp[]` | `[]` | Stringify and redact entire values (legacy alias: `fullSecretKeys`) |
|
|
12
|
+
| **Remove** | `removeSecretKeys` | `RegExp[]` | `[]` | Delete matching keys (legacy alias: `deleteSecretKeys`) |
|
|
13
13
|
| **Schema** | `customObjects` | `CustomObject[]` | `[]` | Per-shape rules; see [metadata guide](../guides/metadata-redaction.md) |
|
|
14
14
|
| **Value-pattern** | `valuePatterns` | `RegExp[]` | `[]` | Opt-in: redact scalars whose string form matches a pattern |
|
|
15
15
|
| **Path rule** | `pathRules` | `PathRule[]` | `[]` | Apply a mode at a JSON path (`metadata.*.value`) |
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Release notes index
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Publishing
|
|
4
|
+
|
|
5
|
+
npm versions use the same `v1.x.x` git tags. Pushing a version tag runs [`.github/workflows/publish.yml`](../../.github/workflows/publish.yml) (build, test, `npm publish` via OIDC trusted publishing). Configure a Trusted Publisher on npm for `mologna/field-redactor` with workflow filename `publish.yml` — see [CONTRIBUTING.md](../../CONTRIBUTING.md#publishing).
|
|
4
6
|
|
|
5
7
|
| Version | npm | Notes |
|
|
6
8
|
| --- | --- | --- |
|
|
9
|
+
| **v1.6.3** | Yes | [v1.6.3.md](v1.6.3.md) — examples, OIDC publish, legacy naming warnings |
|
|
10
|
+
| **v1.6.2** | Yes | [v1.6.2.md](v1.6.2.md) — canonical opaque/remove naming; drop ObjectRedactor façade |
|
|
7
11
|
| **v1.6.1** | Yes | [v1.6.1.md](v1.6.1.md) — internal simplification / layering cleanup |
|
|
8
12
|
| **v1.6.0** | Yes | [v1.6.0.md](v1.6.0.md) — path rules, passKeys, naming aliases, architecture |
|
|
9
13
|
| **v1.5.0** | Yes | [v1.5.0.md](v1.5.0.md) — DX polish, value patterns, unified traversal |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Release notes — v1.6.2
|
|
2
|
+
|
|
3
|
+
Field Redactor **1.6.2** folds two internal cleanups onto **1.6.1**: Opaque/Remove as the canonical config and runtime vocabulary, and removal of the thin `ObjectRedactor` orchestrator. Typical `import { … } from 'field-redactor'` consumers need no call-site changes.
|
|
4
|
+
|
|
5
|
+
**Upgrade from 1.6.1:** Install `1.6.2`. Prefer `opaqueSecretKeys` / `removeSecretKeys` and `CustomObjectMatchType.Opaque` / `Remove` in new config; legacy `fullSecretKeys` / `deleteSecretKeys` and `Full` / `Delete` still work.
|
|
6
|
+
|
|
7
|
+
## Highlights
|
|
8
|
+
|
|
9
|
+
| Area | What changed |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| **Naming** | Canonical storage and matching use opaque/remove; full/delete are input-only aliases |
|
|
12
|
+
| **SecretManager** | `isOpaqueSecretKey` / `isRemoveSecretKey` (legacy config keys still accepted) |
|
|
13
|
+
| **Builder / presets** | Write preferred field names |
|
|
14
|
+
| **Engine** | `FieldRedactor` → `ObjectRedactorTraversal` directly; builder uses a static import |
|
|
15
|
+
|
|
16
|
+
## Compatibility
|
|
17
|
+
|
|
18
|
+
- Public root API unchanged for normal usage
|
|
19
|
+
- `FieldRedactorConfigBuilder.buildRedactor()` / `buildSafeRedactor()` behavior unchanged
|
|
20
|
+
- Docs and presets lead with Opaque/Remove vocabulary
|
|
21
|
+
|
|
22
|
+
## Links
|
|
23
|
+
|
|
24
|
+
- [CHANGELOG](../../CHANGELOG.md)
|
|
25
|
+
- [Release notes v1.6.1](v1.6.1.md)
|
|
26
|
+
- [Migration 1.5 → 1.6](../guides/migration-1.5-to-1.6.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Release notes — v1.6.3
|
|
2
|
+
|
|
3
|
+
Field Redactor **1.6.3** is a patch release focused on DX and release hygiene after **1.6.2**. Redaction behavior is unchanged for typical consumers.
|
|
4
|
+
|
|
5
|
+
**Upgrade from 1.6.2:** Install `1.6.3`. If you still pass `fullSecretKeys` / `deleteSecretKeys`, you will see deprecation warnings at construction — migrate to `opaqueSecretKeys` / `removeSecretKeys` when convenient (legacy fields still work).
|
|
6
|
+
|
|
7
|
+
## Highlights
|
|
8
|
+
|
|
9
|
+
| Area | What changed |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| **Examples** | Copy-paste recipes under [`examples/`](../../examples/) |
|
|
12
|
+
| **Publishing** | Tag → OIDC Trusted Publishing workflow (no `NPM_TOKEN`) |
|
|
13
|
+
| **Naming** | Deprecation warnings for legacy `full` / `delete` config fields |
|
|
14
|
+
| **Types** | Incidental exports marked `@internal` in JSDoc |
|
|
15
|
+
|
|
16
|
+
## Publishing note
|
|
17
|
+
|
|
18
|
+
Configure npm Trusted Publisher for `mologna/field-redactor` with workflow filename `publish.yml` before relying on the new publish Action. See [CONTRIBUTING.md](../../CONTRIBUTING.md#publishing).
|
|
19
|
+
|
|
20
|
+
## Links
|
|
21
|
+
|
|
22
|
+
- [CHANGELOG](../../CHANGELOG.md)
|
|
23
|
+
- [Release notes v1.6.2](v1.6.2.md)
|
|
24
|
+
- [Migration 1.5 → 1.6](../guides/migration-1.5-to-1.6.md)
|
|
25
|
+
- [Examples](../../examples/README.md)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Copy-paste recipes for common Field Redactor setups. Run with:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx ts-node examples/logging-metadata.ts
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
| File | Covers |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [logging-metadata.ts](logging-metadata.ts) | Schema sibling-key redaction + auth key removal |
|
|
12
|
+
| [path-rules.ts](path-rules.ts) | Path patterns, modes, and pass keys |
|
|
13
|
+
| [value-patterns.ts](value-patterns.ts) | Value-pattern redaction regardless of key name |
|
|
14
|
+
| [dry-run.ts](dry-run.ts) | Preview redactions/deletes with attribution |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dryRun: preview redacted output plus path attribution without guessing rules by hand.
|
|
3
|
+
*/
|
|
4
|
+
import { FieldRedactorConfigBuilder } from '../src';
|
|
5
|
+
|
|
6
|
+
const redactor = FieldRedactorConfigBuilder.create()
|
|
7
|
+
.shallow(/email/i)
|
|
8
|
+
.remove(/authKey/i)
|
|
9
|
+
.opaque(/rawPayload/i)
|
|
10
|
+
.buildSafeRedactor();
|
|
11
|
+
|
|
12
|
+
const input = {
|
|
13
|
+
email: 'alice@example.com',
|
|
14
|
+
authKey: 'secret',
|
|
15
|
+
rawPayload: { token: 'x' },
|
|
16
|
+
note: 'ok'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const { result, report } = redactor.dryRunSync(input);
|
|
20
|
+
console.log('result', JSON.stringify(result, null, 2));
|
|
21
|
+
console.log('report', JSON.stringify(report, null, 2));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging metadata: `{ name, type, value }` schemas + auth key removal.
|
|
3
|
+
*/
|
|
4
|
+
import { FieldRedactor, FieldRedactorConfigBuilder, presets } from '../src';
|
|
5
|
+
|
|
6
|
+
const redactor = FieldRedactorConfigBuilder.create()
|
|
7
|
+
.usePreset(presets.applicationLogging())
|
|
8
|
+
.buildSafeRedactor();
|
|
9
|
+
|
|
10
|
+
const input = {
|
|
11
|
+
email: 'alice@example.com',
|
|
12
|
+
authKey: 'secret-token',
|
|
13
|
+
events: [{ name: 'email', value: 'bob@example.com' }]
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const result = redactor.redactSync(input);
|
|
17
|
+
console.log(JSON.stringify(result, null, 2));
|
|
18
|
+
// authKey removed; email / events[0].value redacted
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path rules and pass-key allowlists under deep parents.
|
|
3
|
+
*/
|
|
4
|
+
import { FieldRedactorConfigBuilder } from '../src';
|
|
5
|
+
|
|
6
|
+
const redactor = FieldRedactorConfigBuilder.create()
|
|
7
|
+
.pathRule('session.token', 'remove')
|
|
8
|
+
.pathRule('logs.*.message', 'deep')
|
|
9
|
+
.deep(/accountInfo/)
|
|
10
|
+
.passKey(/^id$/, /^profile$/)
|
|
11
|
+
.buildSafeRedactor();
|
|
12
|
+
|
|
13
|
+
const input = {
|
|
14
|
+
session: { token: 'abc', id: '1' },
|
|
15
|
+
logs: [{ message: 'secret', meta: { note: 'nested' } }],
|
|
16
|
+
accountInfo: {
|
|
17
|
+
id: 'user-1',
|
|
18
|
+
profile: { displayName: 'Alice' },
|
|
19
|
+
ssn: '111-22-3333'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
console.log(JSON.stringify(redactor.redactSync(input), null, 2));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-pattern redaction: match scalar string forms regardless of key name.
|
|
3
|
+
*/
|
|
4
|
+
import { FieldRedactor } from '../src';
|
|
5
|
+
|
|
6
|
+
const redactor = FieldRedactor.createSafe({
|
|
7
|
+
secretKeys: [],
|
|
8
|
+
valuePatterns: [/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/, /\d{3}-\d{2}-\d{4}/]
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const input = {
|
|
12
|
+
note: 'Contact alice@example.com or SSN 111-22-3333',
|
|
13
|
+
label: 'safe'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
console.log(JSON.stringify(redactor.redactSync(input), null, 2));
|
package/package.json
CHANGED
package/dist/arrayRedaction.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { JsonArray, JsonObject } from './types';
|
|
2
|
-
import { ContainerMutation } from './objectRedactorMutation';
|
|
3
|
-
import { MaybeAsync } from './maybeAsync';
|
|
4
|
-
import { TraversalServices } from './traversalServices';
|
|
5
|
-
export declare class ArrayRedactor {
|
|
6
|
-
private readonly services;
|
|
7
|
-
constructor(services: TraversalServices);
|
|
8
|
-
redactArrayInObject(array: JsonArray, key: string, forceDeepRedaction: boolean, parent: ContainerMutation<JsonObject | JsonArray>, pathSegments: Array<string | number>): MaybeAsync<void>;
|
|
9
|
-
redactObjectsInArray(array: JsonArray, copyOnWrite: boolean, pathSegments: Array<string | number>): MaybeAsync<JsonArray>;
|
|
10
|
-
redactAllArrayValues(array: JsonArray, forceDeepRedaction: boolean, copyOnWrite: boolean, pathSegments: Array<string | number>): MaybeAsync<JsonArray>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=arrayRedaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayRedaction.d.ts","sourceRoot":"","sources":["../src/arrayRedaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAsB,UAAU,EAAiB,MAAM,cAAc,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,iBAAiB;IAExD,mBAAmB,CACjB,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,MAAM,EACX,kBAAkB,EAAE,OAAO,EAC3B,MAAM,EAAE,iBAAiB,CAAC,UAAU,GAAG,SAAS,CAAC,EACjD,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GACnC,UAAU,CAAC,IAAI,CAAC;IAmBnB,oBAAoB,CAClB,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GACnC,UAAU,CAAC,SAAS,CAAC;IA6BxB,oBAAoB,CAClB,KAAK,EAAE,SAAS,EAChB,kBAAkB,EAAE,OAAO,EAC3B,WAAW,EAAE,OAAO,EACpB,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GACnC,UAAU,CAAC,SAAS,CAAC;CA0CzB"}
|
package/dist/arrayRedaction.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayRedactor = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
const objectRedactorMutation_1 = require("./objectRedactorMutation");
|
|
6
|
-
const maybeAsync_1 = require("./maybeAsync");
|
|
7
|
-
const objectRedactorHelpers_1 = require("./objectRedactorHelpers");
|
|
8
|
-
class ArrayRedactor {
|
|
9
|
-
constructor(services) {
|
|
10
|
-
this.services = services;
|
|
11
|
-
}
|
|
12
|
-
redactArrayInObject(array, key, forceDeepRedaction, parent, pathSegments) {
|
|
13
|
-
const redacted = this.services.ruleResolver.shouldTraverseContainerByKey(key, forceDeepRedaction)
|
|
14
|
-
? this.redactAllArrayValues(array, this.services.ruleResolver.containerForceDeepRedaction(key, forceDeepRedaction), parent.copyOnWrite, pathSegments)
|
|
15
|
-
: this.redactObjectsInArray(array, parent.copyOnWrite, pathSegments);
|
|
16
|
-
if (redacted instanceof Promise) {
|
|
17
|
-
return redacted.then((result) => {
|
|
18
|
-
parent.set(key, result);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
parent.set(key, redacted);
|
|
22
|
-
}
|
|
23
|
-
redactObjectsInArray(array, copyOnWrite, pathSegments) {
|
|
24
|
-
const container = (0, objectRedactorMutation_1.createContainerMutation)(array, copyOnWrite);
|
|
25
|
-
const work = (0, maybeAsync_1.runSequential)(array, (item, index) => {
|
|
26
|
-
if (!(0, types_1.isJsonObject)(item)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const customObject = this.services.ruleResolver.getMatchingSchema(item);
|
|
30
|
-
const child = (0, objectRedactorMutation_1.createContainerMutation)(item, copyOnWrite);
|
|
31
|
-
const itemPath = [...pathSegments, index];
|
|
32
|
-
return (0, maybeAsync_1.finalizeMaybeAsync)(customObject
|
|
33
|
-
? this.services.handleCustomObject(child, customObject)
|
|
34
|
-
: this.services.redactSecretFields(child, false, itemPath), () => {
|
|
35
|
-
container.set(String(index), child.result());
|
|
36
|
-
}, this.services.asyncMode);
|
|
37
|
-
}, this.services.asyncMode);
|
|
38
|
-
return (0, maybeAsync_1.finalizeMaybeAsync)(work, () => container.result(), this.services.asyncMode);
|
|
39
|
-
}
|
|
40
|
-
redactAllArrayValues(array, forceDeepRedaction, copyOnWrite, pathSegments) {
|
|
41
|
-
const container = (0, objectRedactorMutation_1.createContainerMutation)(array, copyOnWrite);
|
|
42
|
-
const work = (0, maybeAsync_1.runSequential)(array, (item, index) => {
|
|
43
|
-
const key = String(index);
|
|
44
|
-
const itemPath = [...pathSegments, index];
|
|
45
|
-
if (Array.isArray(item)) {
|
|
46
|
-
const nested = this.redactAllArrayValues(item, forceDeepRedaction, copyOnWrite, itemPath);
|
|
47
|
-
if (nested instanceof Promise) {
|
|
48
|
-
return nested.then((result) => {
|
|
49
|
-
container.set(key, result);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
container.set(key, nested);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (!(0, types_1.isJsonObject)(item)) {
|
|
56
|
-
return this.services.setPrimitive(container, key, (0, objectRedactorHelpers_1.toRedactablePrimitive)(item));
|
|
57
|
-
}
|
|
58
|
-
const customObject = this.services.ruleResolver.getMatchingSchema(item);
|
|
59
|
-
const child = (0, objectRedactorMutation_1.createContainerMutation)(item, copyOnWrite);
|
|
60
|
-
return (0, maybeAsync_1.finalizeMaybeAsync)(customObject
|
|
61
|
-
? this.services.handleCustomObject(child, customObject)
|
|
62
|
-
: this.services.redactSecretFields(child, forceDeepRedaction, itemPath), () => {
|
|
63
|
-
container.set(key, child.result());
|
|
64
|
-
}, this.services.asyncMode);
|
|
65
|
-
}, this.services.asyncMode);
|
|
66
|
-
return (0, maybeAsync_1.finalizeMaybeAsync)(work, () => container.result(), this.services.asyncMode);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.ArrayRedactor = ArrayRedactor;
|
|
70
|
-
//# sourceMappingURL=arrayRedaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayRedaction.js","sourceRoot":"","sources":["../src/arrayRedaction.ts"],"names":[],"mappings":";;;AAAA,mCAA8D;AAC9D,qEAAsF;AACtF,6CAA6E;AAC7E,mEAAgE;AAGhE,MAAa,aAAa;IACxB,YAA6B,QAA2B;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;IAAG,CAAC;IAE5D,mBAAmB,CACjB,KAAgB,EAChB,GAAW,EACX,kBAA2B,EAC3B,MAAiD,EACjD,YAAoC;QAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,4BAA4B,CAAC,GAAG,EAAE,kBAAkB,CAAC;YAC/F,CAAC,CAAC,IAAI,CAAC,oBAAoB,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;YACT,CAAC;YAED,IAAI,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,EAAE,GAAG,EAAE,IAAA,6CAAqB,EAAC,IAAI,CAAC,CAAC,CAAC;YACjF,CAAC;YAED,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxE,MAAM,KAAK,GAAG,IAAA,gDAAuB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACzD,OAAO,IAAA,+BAAkB,EACvB,YAAY;gBACV,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,EAAE,YAAY,CAAC;gBACvD,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EACzE,GAAG,EAAE;gBACH,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YACrC,CAAC,EACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CACxB,CAAC;QACJ,CAAC,EACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CACxB,CAAC;QAEF,OAAO,IAAA,+BAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACrF,CAAC;CACF;AA5GD,sCA4GC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FieldRedactorConfig } from './types';
|
|
2
|
-
export { hasExplicitRedactionRules } from './redactionRules';
|
|
3
|
-
export { assertNoIdenticalCustomObjectSchemas } from './customObjectSchemas';
|
|
4
|
-
/**
|
|
5
|
-
* Returns non-fatal configuration warnings. Throws {@link FieldRedactorConfigurationError} for
|
|
6
|
-
* invalid custom object duplicates and when `strict` is true on any warning.
|
|
7
|
-
*/
|
|
8
|
-
export declare const validateFieldRedactorConfig: (config?: FieldRedactorConfig) => string[];
|
|
9
|
-
//# sourceMappingURL=configValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configValidator.d.ts","sourceRoot":"","sources":["../src/configValidator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAgE7E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,YAAa,mBAAmB,KAAG,MAAM,EAiBhF,CAAC"}
|
package/dist/configValidator.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFieldRedactorConfig = exports.assertNoIdenticalCustomObjectSchemas = exports.hasExplicitRedactionRules = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
const regexUtils_1 = require("./regexUtils");
|
|
6
|
-
const redactionRules_1 = require("./redactionRules");
|
|
7
|
-
const customObjectSchemas_1 = require("./customObjectSchemas");
|
|
8
|
-
var redactionRules_2 = require("./redactionRules");
|
|
9
|
-
Object.defineProperty(exports, "hasExplicitRedactionRules", { enumerable: true, get: function () { return redactionRules_2.hasExplicitRedactionRules; } });
|
|
10
|
-
var customObjectSchemas_2 = require("./customObjectSchemas");
|
|
11
|
-
Object.defineProperty(exports, "assertNoIdenticalCustomObjectSchemas", { enumerable: true, get: function () { return customObjectSchemas_2.assertNoIdenticalCustomObjectSchemas; } });
|
|
12
|
-
const KEY_RULE_FIELDS = new Set(redactionRules_1.SECRET_REGEX_FIELDS);
|
|
13
|
-
const collectRegexWarnings = (config) => {
|
|
14
|
-
const warnings = [];
|
|
15
|
-
const keyRuleDuplicates = new Map();
|
|
16
|
-
for (const field of redactionRules_1.REGEX_ARRAY_CONFIG_FIELDS) {
|
|
17
|
-
const regexes = config[field];
|
|
18
|
-
if (!regexes) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
for (const regex of regexes) {
|
|
22
|
-
if (regex.global) {
|
|
23
|
-
warnings.push(`Global regex ${(0, regexUtils_1.formatRegExp)(regex)} in \`${field}\` can produce surprising \`.test()\` results; remove the \`g\` flag.`);
|
|
24
|
-
}
|
|
25
|
-
if (!KEY_RULE_FIELDS.has(field)) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const identity = (0, regexUtils_1.regexIdentity)(regex);
|
|
29
|
-
const prior = keyRuleDuplicates.get(identity);
|
|
30
|
-
if (prior && prior !== field) {
|
|
31
|
-
warnings.push(`${(0, regexUtils_1.formatRegExp)(regex)} appears in both \`${prior}\` and \`${field}\` — only the higher-precedence rule applies.`);
|
|
32
|
-
}
|
|
33
|
-
else if (!prior) {
|
|
34
|
-
keyRuleDuplicates.set(identity, field);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return warnings;
|
|
39
|
-
};
|
|
40
|
-
const collectSchemaWarnings = (customObjects) => {
|
|
41
|
-
const warnings = [];
|
|
42
|
-
customObjects.forEach((schema, schemaIndex) => {
|
|
43
|
-
for (const [field, rule] of Object.entries(schema)) {
|
|
44
|
-
if (typeof rule === 'string' && !Object.prototype.hasOwnProperty.call(schema, rule)) {
|
|
45
|
-
warnings.push(`Schema at index ${schemaIndex}: field \`${field}: '${rule}'\` references sibling key \`${rule}\` which is not defined in the schema.`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
for (const [i, j] of (0, customObjectSchemas_1.analyzeSchemaPairs)(customObjects).subsetPairs) {
|
|
50
|
-
const keysA = Object.keys(customObjects[i]);
|
|
51
|
-
const keysB = Object.keys(customObjects[j]);
|
|
52
|
-
warnings.push(`Schemas at index ${i} and ${j} may both match the same object; index ${keysB.length > keysA.length ? j : i} wins only when it has more keys.`);
|
|
53
|
-
}
|
|
54
|
-
return warnings;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Returns non-fatal configuration warnings. Throws {@link FieldRedactorConfigurationError} for
|
|
58
|
-
* invalid custom object duplicates and when `strict` is true on any warning.
|
|
59
|
-
*/
|
|
60
|
-
const validateFieldRedactorConfig = (config) => {
|
|
61
|
-
var _a;
|
|
62
|
-
const resolved = config !== null && config !== void 0 ? config : {};
|
|
63
|
-
(0, customObjectSchemas_1.assertNoIdenticalCustomObjectSchemas)(resolved.customObjects);
|
|
64
|
-
const warnings = [
|
|
65
|
-
...(!(0, redactionRules_1.hasExplicitRedactionRules)(resolved)
|
|
66
|
-
? ['All values will be redacted. Did you mean to set `secretKeys` or use `FieldRedactor.createSafe()`?']
|
|
67
|
-
: []),
|
|
68
|
-
...collectRegexWarnings(resolved),
|
|
69
|
-
...collectSchemaWarnings((_a = resolved.customObjects) !== null && _a !== void 0 ? _a : [])
|
|
70
|
-
];
|
|
71
|
-
if (resolved.strict && warnings[0]) {
|
|
72
|
-
throw new errors_1.FieldRedactorConfigurationError(warnings[0]);
|
|
73
|
-
}
|
|
74
|
-
return warnings;
|
|
75
|
-
};
|
|
76
|
-
exports.validateFieldRedactorConfig = validateFieldRedactorConfig;
|
|
77
|
-
//# sourceMappingURL=configValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configValidator.js","sourceRoot":"","sources":["../src/configValidator.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAC3D,6CAA2D;AAC3D,qDAA6G;AAC7G,+DAAiG;AAGjG,mDAA6D;AAApD,2HAAA,yBAAyB,OAAA;AAClC,6DAA6E;AAApE,2IAAA,oCAAoC,OAAA;AAE7C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS,oCAAmB,CAAC,CAAC;AAE7D,MAAM,oBAAoB,GAAG,CAAC,MAA2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C;QACP,GAAG,oBAAoB,CAAC,QAAQ,CAAC;QACjC,GAAG,qBAAqB,CAAC,MAAA,QAAQ,CAAC,aAAa,mCAAI,EAAE,CAAC;KACvD,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,wCAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAjBW,QAAA,2BAA2B,+BAiBtC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JsonArray, JsonObject, JsonValue } from './types';
|
|
2
|
-
export type ObjectCopyState<T extends JsonObject> = {
|
|
3
|
-
source: T;
|
|
4
|
-
current: T;
|
|
5
|
-
copied: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type ArrayCopyState<T extends JsonArray> = {
|
|
8
|
-
source: T;
|
|
9
|
-
current: T;
|
|
10
|
-
copied: boolean;
|
|
11
|
-
};
|
|
12
|
-
export declare const createObjectCopyState: <T extends JsonObject>(source: T) => ObjectCopyState<T>;
|
|
13
|
-
export declare const createArrayCopyState: <T extends JsonArray>(source: T) => ArrayCopyState<T>;
|
|
14
|
-
export declare const finishObjectCopy: <T extends JsonObject>(state: ObjectCopyState<T>) => T;
|
|
15
|
-
export declare const finishArrayCopy: <T extends JsonArray>(state: ArrayCopyState<T>) => T;
|
|
16
|
-
export declare const setObjectKey: <T extends JsonObject>(state: ObjectCopyState<T>, key: string, value: JsonValue | undefined) => void;
|
|
17
|
-
export declare const deleteObjectKey: <T extends JsonObject>(state: ObjectCopyState<T>, key: string) => void;
|
|
18
|
-
export declare const setArrayIndex: <T extends JsonArray>(state: ArrayCopyState<T>, index: number, value: JsonValue | undefined) => void;
|
|
19
|
-
export declare const deleteArrayIndex: <T extends JsonArray>(state: ArrayCopyState<T>, index: number) => void;
|
|
20
|
-
//# sourceMappingURL=copyOnWriteHelp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SACjB,MAAM,SACN,SAAS,GAAG,SAAS,KAC3B,IAIF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,SAAS,SAAS,cAAc,CAAC,CAAC,CAAC,SAAS,MAAM,KAAG,IAI/F,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteArrayIndex = exports.setArrayIndex = exports.deleteObjectKey = exports.setObjectKey = exports.finishArrayCopy = exports.finishObjectCopy = exports.createArrayCopyState = exports.createObjectCopyState = void 0;
|
|
4
|
-
const createObjectCopyState = (source) => ({
|
|
5
|
-
source,
|
|
6
|
-
current: source,
|
|
7
|
-
copied: false
|
|
8
|
-
});
|
|
9
|
-
exports.createObjectCopyState = createObjectCopyState;
|
|
10
|
-
const createArrayCopyState = (source) => ({
|
|
11
|
-
source,
|
|
12
|
-
current: source,
|
|
13
|
-
copied: false
|
|
14
|
-
});
|
|
15
|
-
exports.createArrayCopyState = createArrayCopyState;
|
|
16
|
-
const finishObjectCopy = (state) => state.copied ? state.current : state.source;
|
|
17
|
-
exports.finishObjectCopy = finishObjectCopy;
|
|
18
|
-
const finishArrayCopy = (state) => state.copied ? state.current : state.source;
|
|
19
|
-
exports.finishArrayCopy = finishArrayCopy;
|
|
20
|
-
const ensureObjectCopy = (state) => {
|
|
21
|
-
if (!state.copied) {
|
|
22
|
-
state.current = Object.assign({}, state.source);
|
|
23
|
-
state.copied = true;
|
|
24
|
-
}
|
|
25
|
-
return state.current;
|
|
26
|
-
};
|
|
27
|
-
const ensureArrayCopy = (state) => {
|
|
28
|
-
if (!state.copied) {
|
|
29
|
-
state.current = state.source.slice();
|
|
30
|
-
state.copied = true;
|
|
31
|
-
}
|
|
32
|
-
return state.current;
|
|
33
|
-
};
|
|
34
|
-
const setObjectKey = (state, key, value) => {
|
|
35
|
-
if (state.source[key] !== value) {
|
|
36
|
-
ensureObjectCopy(state)[key] = value;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.setObjectKey = setObjectKey;
|
|
40
|
-
const deleteObjectKey = (state, key) => {
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(state.source, key)) {
|
|
42
|
-
delete ensureObjectCopy(state)[key];
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
exports.deleteObjectKey = deleteObjectKey;
|
|
46
|
-
const setArrayIndex = (state, index, value) => {
|
|
47
|
-
if (state.source[index] !== value) {
|
|
48
|
-
ensureArrayCopy(state)[index] = value;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.setArrayIndex = setArrayIndex;
|
|
52
|
-
const deleteArrayIndex = (state, index) => {
|
|
53
|
-
if (index < state.source.length) {
|
|
54
|
-
delete ensureArrayCopy(state)[index];
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.deleteArrayIndex = deleteArrayIndex;
|
|
58
|
-
//# sourceMappingURL=copyOnWriteHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"copyOnWriteHelpers.js","sourceRoot":"","sources":["../src/copyOnWriteHelpers.ts"],"names":[],"mappings":";;;AAcO,MAAM,qBAAqB,GAAG,CAAuB,MAAS,EAAsB,EAAE,CAAC,CAAC;IAC7F,MAAM;IACN,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,KAAK;CACd,CAAC,CAAC;AAJU,QAAA,qBAAqB,yBAI/B;AAEI,MAAM,oBAAoB,GAAG,CAAsB,MAAS,EAAqB,EAAE,CAAC,CAAC;IAC1F,MAAM;IACN,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,KAAK;CACd,CAAC,CAAC;AAJU,QAAA,oBAAoB,wBAI9B;AAEI,MAAM,gBAAgB,GAAG,CAAuB,KAAyB,EAAK,EAAE,CACrF,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM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,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;AACH,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEK,MAAM,aAAa,GAAG,CAC3B,KAAwB,EACxB,KAAa,EACb,KAA4B,EACtB,EAAE;IACR,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;QAClC,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACxC,CAAC;AACH,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB;AAEK,MAAM,gBAAgB,GAAG,CAAsB,KAAwB,EAAE,KAAa,EAAQ,EAAE;IACrG,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;AACH,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CustomObject, JsonObject } from './types';
|
|
2
|
-
import { ContainerMutation } from './objectRedactorMutation';
|
|
3
|
-
import { MaybeAsync } from './maybeAsync';
|
|
4
|
-
import { TraversalServices } from './traversalServices';
|
|
5
|
-
export declare class CustomObjectFieldHandler {
|
|
6
|
-
private readonly services;
|
|
7
|
-
constructor(services: TraversalServices);
|
|
8
|
-
handleCustomObject(container: ContainerMutation<JsonObject>, customObject: CustomObject): MaybeAsync<void>;
|
|
9
|
-
private handleCustomObjectValueIfArray;
|
|
10
|
-
private handleCustomObjectArrayValueIfStringKeySpecified;
|
|
11
|
-
private handleCustomObjectArrayValueIfMatchTypeSpecified;
|
|
12
|
-
private setRedactedArray;
|
|
13
|
-
private handleCustomObjectValueIfObject;
|
|
14
|
-
private handleCustomObjectObjectValueIfStringKeySpecified;
|
|
15
|
-
private handleCustomObjectObjectValueIfMatchTypeSpecified;
|
|
16
|
-
private setRedactedObject;
|
|
17
|
-
private handleCustomObjectValueIfPrimitive;
|
|
18
|
-
private handleCustomObjectPrimitiveValueIfMatchTypeSpecified;
|
|
19
|
-
private handleCustomObjectPrimitiveValueIfStringKeySpecified;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=customObjectFieldHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customObjectFieldHandler.d.ts","sourceRoot":"","sources":["../src/customObjectFieldHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIZ,UAAU,EAGX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AAOtF,OAAO,EAAsB,UAAU,EAAoC,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,iBAAiB;IAExD,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;IAmB1G,OAAO,CAAC,8BAA8B;IAiBtC,OAAO,CAAC,gDAAgD;IAkCxD,OAAO,CAAC,gDAAgD;IAsBxD,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,+BAA+B;IAiBvC,OAAO,CAAC,iDAAiD;IA8CzD,OAAO,CAAC,iDAAiD;IAsBzD,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,kCAAkC;IAiB1C,OAAO,CAAC,oDAAoD;IAgB5D,OAAO,CAAC,oDAAoD;CAkB7D"}
|