# eliware/redact architecture

> Architecture diagram of the GitHub repository eliware/redact, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eliware/redact
- Repository: https://github.com/eliware/redact

## Overview

@eliware/redact is a Node.js library for redacting sensitive data and safely serializing values before logging, persistence, or transport. Its public workflow begins at the package entry point and branches into structured-value, header, text, serialization, and error APIs. Policy defaults and bounded, defensive inspection support those operations. The graph follows documented exports and source-index references; unsampled implementations are represented only where the tree supplies an exact path, and uncertain relationships are omitted.

Main entry points: [`src/index.mjs`](https://github.com/eliware/redact/blob/main/src/index.mjs) (Package entry), [`src/text/redact-text.mjs`](https://github.com/eliware/redact/blob/main/src/text/redact-text.mjs) (Text redaction), [`src/headers/redact-headers.mjs`](https://github.com/eliware/redact/blob/main/src/headers/redact-headers.mjs) (Header redaction), [`src/errors/safe-error-value.mjs`](https://github.com/eliware/redact/blob/main/src/errors/safe-error-value.mjs) (Safe error value)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_entry["Package entry<br/>[index.mjs]"]
end

subgraph group_redact["Redaction"]
  node_structured["Structured redaction<br/>[redact-value.mjs]"]
  node_headers["Header redaction<br/>[redact-headers.mjs]"]
  node_headerreader["Header entry reader"]
  node_headernames["Header name policy"]
  node_text["Text redaction<br/>[redact-text.mjs]"]
  node_textrules["Text rule set"]
end

subgraph group_safety["Policy and safety"]
  node_policy["Policy creation<br/>[create-policy.mjs]"]
  node_defaults["Default policy<br/>[default-policy.mjs]"]
  node_inspection["Safe entry inspection"]
  node_limits["Serialization limits"]
end

subgraph group_serialize["Serialization and errors"]
  node_serialize["Safe serialization<br/>[safe-serialize.mjs]"]
  node_errorsafe["Safe error value"]
  node_errormessage["Error message redaction"]
  node_errordetails["Error details redaction"]
end

node_caller(("Library caller"))

node_caller -->|"imports"| node_entry
node_entry -->|"exports"| node_policy
node_entry -->|"exports"| node_defaults
node_entry -->|"exports"| node_structured
node_entry -->|"exports"| node_headers
node_entry -->|"exports"| node_text
node_entry -->|"exports"| node_serialize
node_entry -->|"exports"| node_errorsafe
node_entry -->|"exports"| node_errormessage
node_entry -->|"exports"| node_errordetails
node_headers -->|"reads entries"| node_headerreader
node_headers -->|"normalizes names"| node_headernames
node_text -->|"applies rules"| node_textrules
node_text -->|"normalizes limits"| node_limits
node_errorsafe -->|"redacts message"| node_errormessage
node_errorsafe -->|"redacts details"| node_errordetails
node_errormessage -->|"redacts text"| node_text
node_errordetails -->|"redacts value"| node_structured
node_serialize -->|"reads safe entries"| node_inspection

click node_entry "https://github.com/eliware/redact/blob/main/src/index.mjs"
click node_policy "https://github.com/eliware/redact/blob/main/src/policy/create-policy.mjs"
click node_defaults "https://github.com/eliware/redact/blob/main/src/policy/default-policy.mjs"
click node_structured "https://github.com/eliware/redact/blob/main/src/structured/redact-value.mjs"
click node_headers "https://github.com/eliware/redact/blob/main/src/headers/redact-headers.mjs"
click node_headerreader "https://github.com/eliware/redact/blob/main/src/headers/header-entry-reader.mjs"
click node_headernames "https://github.com/eliware/redact/blob/main/src/headers/header-name-normalizer.mjs"
click node_text "https://github.com/eliware/redact/blob/main/src/text/redact-text.mjs"
click node_textrules "https://github.com/eliware/redact/blob/main/src/text/text-redaction-rule-set.mjs"
click node_serialize "https://github.com/eliware/redact/blob/main/src/serialization/safe-serialize.mjs"
click node_errorsafe "https://github.com/eliware/redact/blob/main/src/errors/safe-error-value.mjs"
click node_errormessage "https://github.com/eliware/redact/blob/main/src/errors/redact-error-message.mjs"
click node_errordetails "https://github.com/eliware/redact/blob/main/src/errors/redact-error-details.mjs"
click node_inspection "https://github.com/eliware/redact/blob/main/src/inspection/read-safe-entries.mjs"
click node_limits "https://github.com/eliware/redact/blob/main/src/serialization/serialization-limits.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry toneBlue
class node_structured,node_headers,node_headerreader,node_headernames,node_text,node_textrules toneAmber
class node_policy,node_defaults,node_inspection,node_limits toneMint
class node_serialize,node_errorsafe,node_errormessage,node_errordetails toneRose
class node_caller toneIndigo
```

## Components

### Public API

- [Package entry](https://github.com/eliware/redact/blob/main/src/index.mjs): `src/index.mjs`

### Redaction

- [Structured redaction](https://github.com/eliware/redact/blob/main/src/structured/redact-value.mjs): `src/structured/redact-value.mjs`
- [Header redaction](https://github.com/eliware/redact/blob/main/src/headers/redact-headers.mjs): `src/headers/redact-headers.mjs`
- [Header entry reader](https://github.com/eliware/redact/blob/main/src/headers/header-entry-reader.mjs): `src/headers/header-entry-reader.mjs`
- [Header name policy](https://github.com/eliware/redact/blob/main/src/headers/header-name-normalizer.mjs): `src/headers/header-name-normalizer.mjs`
- [Text redaction](https://github.com/eliware/redact/blob/main/src/text/redact-text.mjs): `src/text/redact-text.mjs`
- [Text rule set](https://github.com/eliware/redact/blob/main/src/text/text-redaction-rule-set.mjs): `src/text/text-redaction-rule-set.mjs`

### Policy and safety

- [Policy creation](https://github.com/eliware/redact/blob/main/src/policy/create-policy.mjs): `src/policy/create-policy.mjs`
- [Default policy](https://github.com/eliware/redact/blob/main/src/policy/default-policy.mjs): `src/policy/default-policy.mjs`
- [Safe entry inspection](https://github.com/eliware/redact/blob/main/src/inspection/read-safe-entries.mjs): `src/inspection/read-safe-entries.mjs`
- [Serialization limits](https://github.com/eliware/redact/blob/main/src/serialization/serialization-limits.mjs): `src/serialization/serialization-limits.mjs`

### Serialization and errors

- [Safe serialization](https://github.com/eliware/redact/blob/main/src/serialization/safe-serialize.mjs): `src/serialization/safe-serialize.mjs`
- [Safe error value](https://github.com/eliware/redact/blob/main/src/errors/safe-error-value.mjs): `src/errors/safe-error-value.mjs`
- [Error message redaction](https://github.com/eliware/redact/blob/main/src/errors/redact-error-message.mjs): `src/errors/redact-error-message.mjs`
- [Error details redaction](https://github.com/eliware/redact/blob/main/src/errors/redact-error-details.mjs): `src/errors/redact-error-details.mjs`

### Other components

- **Library caller**

## Connections

- Library caller → Package entry: imports (evidence: `README.md`)
- Package entry → Policy creation: exports (evidence: `src/index.mjs`)
- Package entry → Default policy: exports (evidence: `src/index.mjs`)
- Package entry → Structured redaction: exports (evidence: `src/index.mjs`)
- Package entry → Header redaction: exports (evidence: `src/index.mjs`)
- Package entry → Text redaction: exports (evidence: `src/index.mjs`)
- Package entry → Safe serialization: exports (evidence: `src/index.mjs`)
- Package entry → Safe error value: exports (evidence: `src/index.mjs`)
- Package entry → Error message redaction: exports (evidence: `src/index.mjs`)
- Package entry → Error details redaction: exports (evidence: `src/index.mjs`)
- Header redaction → Header entry reader: reads entries (evidence: `src/headers/redact-headers.mjs`)
- Header redaction → Header name policy: normalizes names (evidence: `src/headers/redact-headers.mjs`)
- Text redaction → Text rule set: applies rules (evidence: `src/text/redact-text.mjs`)
- Text redaction → Serialization limits: normalizes limits (evidence: `src/text/redact-text.mjs`)
- Safe error value → Error message redaction: redacts message (evidence: `src/errors/safe-error-value.mjs`)
- Safe error value → Error details redaction: redacts details (evidence: `src/errors/safe-error-value.mjs`)
- Error message redaction → Text redaction: redacts text (evidence: `src/errors/redact-error-message.mjs`)
- Error details redaction → Structured redaction: redacts value (evidence: `src/errors/redact-error-details.mjs`)
- Safe serialization → Safe entry inspection: reads safe entries
