# prisma-data-protector

> This is an extra line of defence to protect sensitive data in your database from being leaked due to lazy prisma queries that aren't selecting specific data. It works by applying a default `select` parameter to queries which do not contain one to filter o

Latest version **1.1.5** (published 2022-08-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install prisma-data-protector
pnpm add prisma-data-protector
yarn add prisma-data-protector
bun add prisma-data-protector
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2022-08-27 |
| First published | 2022-08-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | reesvarney |

## Links

- npm: https://www.npmjs.com/package/prisma-data-protector
- Repository: https://github.com/reesvarney/prisma-data-protector
- Homepage: https://github.com/reesvarney/prisma-data-protector#readme
- Issues: https://github.com/reesvarney/prisma-data-protector/issues
- npm.io page: https://npm.io/package/prisma-data-protector

## Recent versions

- 1.1.5 (latest) — 2022-08-27
- 1.1.4 — 2022-08-27
- 1.1.3 — 2022-08-27
- 1.1.2 — 2022-08-25
- 1.1.1 — 2022-08-25
- 1.1.0 — 2022-08-25
- 1.0.1 — 2022-08-25
- 1.0.0 — 2022-08-25

## README

# Prisma Data Protector Middleware
This is an extra line of defence to protect sensitive data in your database from being leaked due to lazy prisma queries that aren't selecting specific data. It works by applying a default `select` parameter to queries which do not contain one to filter out certain supplied fields. To access the "protected" data simply include it in a `select` on your query.

This should not be relied on as an excuse to not be careful when you select data, aside from the many performance drawbacks of retrieving every field there are probably some edge cases where it may not work.

## Usage
```js
import {Prisma, PrismaClient} from "@prisma/client";
import {protectData} from 'prisma-data-protector';

const db = new PrismaClient()

db.$use(protectData(Prisma.dmmf.datamodel.models, {
  // Data you want to protect
  User: {
    password: true
  }
}, {
  warn: true // Gives console warning when protected data is filtered
}));
```

## Supported Queries
Currently the middleware supports `findUnique`, `findMany` and `findFirst`.

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