# @medikura/redact-secrets

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

Latest version **2.1.1** (published 2021-12-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @medikura/redact-secrets
pnpm add @medikura/redact-secrets
yarn add @medikura/redact-secrets
bun add @medikura/redact-secrets
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2021-12-29 |
| First published | 2019-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Medikura Digital Health GmbH |
| Maintainers | johannes.medikura |
| Keywords | secret, hidden, redact, redacting |

## Links

- npm: https://www.npmjs.com/package/@medikura/redact-secrets
- Repository: https://gitlab.com/medikura/libs/redact-secrets
- npm.io page: https://npm.io/package/@medikura/redact-secrets

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [deepdash](https://npm.io/package/deepdash.md) ^5.3.9

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2021-12-29
- 2.1.0 — 2019-10-22

## 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
//Redact without any otptions
var redact = require('@medikura/redact-secrets')()

// add custom key regex
var redactConstants = require('@medikura/constants')
var customRedact = require('@medikura/redact-secrets')({ keys: [ /email/, ...redactConstants.KEYS ] })

var obj = {
  username: 'watson',
  email: 'test@example.com',
  password: 'hhGu38gf',
  extra: {
    id: 1,
    token: 'some-secret-stuff'
    card: '1234 1234 1234 1234'
  }
}

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


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

## API

### `redact = Redact(options)`

This module exposes a init function which takes an optional object with several options:
* `redactedText` - the `string` used as a replacement variable for values that are redacted, defaults to `"[REDACTED]"`
* `keys` - an array of regexes for keys that are considered secret, defaults to `constants.KEYS`
* `values` - an array of regexes for values that are considered secret, defaults to `constants.VALUES`

The init function returns an object holding one function called `map`

### `redact.map(obj)`

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

## License

MIT

forked from https://github.com/watson/redact-secrets; major changes:
* uses deepdash instead of traverse (traverse is unmaintained)
* allows for adding custom regexes for secret keys and values

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