npm.io
1.0.3 • Published 2 years ago

@types/redact-secrets

Licence
MIT
Version
1.0.3
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/redact-secrets

Summary

This package contains type definitions for redact-secrets (https://github.com/watson/redact-secrets#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redact-secrets.

index.d.ts

interface Redactor {
    /**
     * @param obj The object to redact.
     * @returns A clone of the given `obj` with its secret values redacted.
     */
    map<TObj extends Record<string, any>>(obj: TObj): TObj;
    /**
     * Redacts the secret values of the `obj` in-place.
     *
     * @param obj The object to redact.
     */
    forEach(obj: Record<string, unknown>): void;
}

/**
 * Create a redactor instance.
 *
 * @param redacted The string used as a replacement variable for values that are redacted.
 *
 * @example
 * const makeRedact = require('redact-secrets')
 *
 * const redact = makeRedact('[REDACTED]')
 *
 * const 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]'
 * //   }
 * // }
 */
declare function Redact(redacted: string): Redactor;

export = Redact;

Additional Details

  • Last updated: Tue, 07 Nov 2023 0939 GMT
  • Dependencies: none

Credits

These definitions were written by wrumsby.