# redact-secrets

> Deeply iterate over an object and redact secret values by replacing them with a predefined string

Latest version **1.0.0** (published 2016-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install redact-secrets
pnpm add redact-secrets
yarn add redact-secrets
bun add redact-secrets
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-11-15 |
| First published | 2016-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/redact-secrets) |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Thomas Watson Steen |
| Maintainers | watson |
| Keywords | secret, hidden, redact, redacting, iterate, walk, traverse, obj, object, json |

## Links

- npm: https://www.npmjs.com/package/redact-secrets
- Repository: https://github.com/watson/redact-secrets
- Homepage: https://github.com/watson/redact-secrets#readme
- Issues: https://github.com/watson/redact-secrets/issues
- npm.io page: https://npm.io/package/redact-secrets

## Dependencies (2)

- [traverse](https://npm.io/package/traverse.md) ^0.6.6
- [is-secret](https://npm.io/package/is-secret.md) ^1.0.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-11-15

## README

# redact-secrets

Deeply iterate over an object and redact secret values by replacing them
with a predefined string.

[![Build status](https://travis-ci.org/watson/redact-secrets.svg?branch=master)](https://travis-ci.org/watson/redact-secrets)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install redact-secrets --save
```

## Usage

```js
var redact = require('redact-secrets')('[REDACTED]')

var obj = {
  username: 'watson',
  password: 'hhGu38gf',
  extra: {
    id: 1,
    token: 'some-secret-stuff'
    card: '1234 1234 1234 1234'
  }
}

console.log(redact.map(obj))
// {
//   username: 'watson',
//   password: '[REDACTED]',
//   extra: {
//     id: 1,
//     token: '[REDACTED]'
//     card: '[REDACTED]'
//   }
// }
```

## API

### `redact = Redact(string)`

This module exposes a init function which takes a single argument: The
`string` used as a replacement variable for values that are redacted.

The init function returns an object holding two functions: `map` and
`forEach`.

### `redact.map(obj)`

Returns a clone of the given `obj` with its secret values redacted.

### `redact.forEach(obj)`

Redacts the secret values of the `obj` in-place.

## License

MIT

---
_Source: https://npm.io/package/redact-secrets · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
