{"id":21569451,"url":"https://github.com/naturalcycles/scrubber-lib","last_synced_at":"2025-04-10T14:06:49.030Z","repository":{"id":34922699,"uuid":"186618671","full_name":"NaturalCycles/scrubber-lib","owner":"NaturalCycles","description":"Scrub data in JavaScript plain objects by using rules defined in a configuration object","archived":false,"fork":false,"pushed_at":"2025-01-25T13:05:16.000Z","size":803,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-22T02:33:58.349Z","etag":null,"topics":["gdpr","scrubber","sensitive"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NaturalCycles.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-14T12:35:58.000Z","updated_at":"2025-01-25T13:05:20.000Z","dependencies_parsed_at":"2024-07-25T07:53:06.430Z","dependency_job_id":"cecf521f-4dba-42be-b1e7-717a5ee9f8a6","html_url":"https://github.com/NaturalCycles/scrubber-lib","commit_stats":{"total_commits":56,"total_committers":7,"mean_commits":8.0,"dds":0.75,"last_synced_commit":"06c8845dba942f5616a934cc6dc1c2c17dab5eb0"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fscrubber-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fscrubber-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fscrubber-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaturalCycles%2Fscrubber-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaturalCycles","download_url":"https://codeload.github.com/NaturalCycles/scrubber-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231902,"owners_count":21069425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gdpr","scrubber","sensitive"],"created_at":"2024-11-24T11:09:32.402Z","updated_at":"2025-04-10T14:06:49.018Z","avatar_url":"https://github.com/NaturalCycles.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## @naturalcycles/scrubber-lib\n\n\u003e Scrub data in JavaScript plain objects by using rules defined in a configuration object\n\n[![npm](https://img.shields.io/npm/v/@naturalcycles/scrubber-lib/latest.svg)](https://www.npmjs.com/package/@naturalcycles/scrubber-lib)\n[![Maintainability](https://api.codeclimate.com/v1/badges/e8cd5b1b7cff8e1296fe/maintainability)](https://codeclimate.com/repos/e8cd5b1b7cff8e1296fe/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/e8cd5b1b7cff8e1296fe/test_coverage)](https://codeclimate.com/repos/e8cd5b1b7cff8e1296fe/test_coverage)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n## How to use\n\nInstall it:\n\n```\nyarn add -D @naturalcycles/scrubber-lib\n```\n\nDefine a scrubber configuration object:\n\n```ts\nimport { ScrubberConfig, Scrubber } from '@naturalcycles/scrubber-lib'\n\nconst cfg: ScrubberConfig = {\n  fields: {\n    name: {\n      scrubber: 'staticScrubber',\n      params: {\n        replacement: 'John Doe',\n      },\n    },\n    password: {\n      scrubber: 'undefinedScrubber',\n    },\n  },\n  throwOnError: true, // default: false,\n  preserveFalsy: false, // default: true\n}\n```\n\nScrub a single object:\n\n```ts\nconst object = { name: 'Real Name', password: 'secret' }\n\nconst scrubber = new Scrubber(cfg)\nconst scrubbedObject = scrubber.scrub(object)\n\n// scrubbedObject =  name: 'John Doe', password: undefined }\n```\n\nScrub an array of objects:\n\n```ts\nconst objects = [object1, object2, object3]\n\nconst scrubbedObjects = scrubber.scrub(objects)\n```\n\n## Public API\n\n```ts\nconstructor (private cfg: ScrubberConfig, additionalScrubbersImpl?: ScrubbersImpl)\nscrub\u003cT\u003e (data: T): T\n```\n\n## Features\n\n- **Objects are deep traversed**\n- **Immutable** changes (does not mutate the original object)\n- TypeScript library, compatible both on browsers and NodeJS\n- Fields are scrubbed if object keys match the field names on the configuration file\n- Provides a few built-in scrubber functions\n- Allows additional scrubber functions\n- Validates config object on class initialization to ensure all defined scrubber functions exist\n- Supports field names to be comma-separated on configuration file\n- Error handling: all errors are logged and allows a `cfg.throwOnError` optional configuration to\n  re-throw errors\n- Falsy values: allows a `cfg.preserveFalsy` optional configuration to control if falsy values\n  should be preserved or passed to scrubber functions. When inspecting scrubbed objects for\n  debugging purposes, it might be useful to set it to `true` to identify potential interesting\n  fields\n- [since 2.9] - support matching key only if parent key name(s) also match. Supported using dots `.`\n  in key name. Config with key `a.b` will match object key literally AND it will match object key\n  `b` if parent object key was `a`. Works at arbitrary depth. LIMITATION: parent matching currently\n  assumes final key (`b`) is unique. If multiple parent references end with the same key (e.g. `a.b`\n  \u0026 `c.b`), only last one will work.\n\n## Limitations\n\n- Objects of types `Map`, `Set` and `Buffer` are currently not traversed or modified\n\n## Vocabulary\n\nThe `scrubber-lib` supports a `ScrubberConfig` parameter on initialization which is usually defined\nby clients on a `scrubber configuration file` (YAML or JSON) with multiple `scrubbing profiles`\n(such as anonymization, pseudonymization, etc).\n\nThe library applies `scrubber functions` to the given objects. It provides some built-in\n`scrubber functions` while also allowing custom `scrubber functions implementations`.\n\n## Possible use cases\n\nAllows, for example, removal of sensitive data for:\n\n- Logs\n- Error reporting to third-party services\n- Data exports (such as staging or other data exports)\n- Anonymizing production users (GDPR \"_right to be forgotten_\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalcycles%2Fscrubber-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaturalcycles%2Fscrubber-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaturalcycles%2Fscrubber-lib/lists"}