2.0.1 • Published 5 months ago

@qiwi/masker v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@qiwi/masker

Composite data masking utility.

Key features

  • Composite and configurable
  • Sync and async API
  • TS and Flow typings

Install

yarn add @qiwi/masker

Usage

masker

Default masker is applicable for most std cases: for strings, objects, json strings, which may contain any standard secret keys, values or PANs.

import {masker} from '@qiwi/masker'

masker('411111111111111')       // Promise<4111 **** **** 1111>
masker.sync('4111111111111111') // 4111 **** **** 1111

masker.sync({
  token: 'foo bar',
  password: 'bazqux',
  details: {
    pans: ['4111111111111111', '1234123412341234'],
    some: 'value'
  }
})

/*
{
  token: '***',
  password: '***',
  details: {
    pans: ['4111 **** **** 1111', '1234123412341234'],
    some: 'value'
  }
}
*/

createMasker

The masker factory builds a new masker instance with custom options (pipeline, registry, etc):

import {createMasker, registry} from '@qiwi/masker'

const masker = createMasker({
  registry,
  pipeline: ['split', 'strike']
})

masker.sync({
  foo: {
    bar: {
      baz: 'baaaaz'
    },
    qux: null,
    quux: 'qu ux'
  }
})
/*
{
  foo: {
    bar: {
      baz: '******'
    },
    qux: null,
    quux: '** **'
  }
}
*/

registry

registry provides plugin-by-name resolution for pipelines. This mechanics is strictly required by the schema processor.

import {masker} from '@qiwi/masker'
import pan from '@qiwi/masker-pan'

masker('data', {pipeline: [pan]})
import {registry} from '@qiwi/masker'
import pan from '@qiwi/masker-pan'

registry.add(pan)

masker('data', {pipeline: ['pan'], registry})
2.0.1

5 months ago

2.0.0

5 months ago

1.5.3

2 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago