# poom-requesthasher

> A plugin decrypts querystring, body data (except multipart) and encrypts response body data

Latest version **1.0.0** (published 2019-01-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install poom-requesthasher
pnpm add poom-requesthasher
yarn add poom-requesthasher
bun add poom-requesthasher
```

## 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.0.0 |
| Published | 2019-01-29 |
| First published | 2018-10-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | onapis.com@gmail.com |
| Maintainers | onapis |

## Links

- npm: https://www.npmjs.com/package/poom-requesthasher
- npm.io page: https://npm.io/package/poom-requesthasher

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [poom-log](https://npm.io/package/poom-log.md) ^1.0.0
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1
- [poom-utils](https://npm.io/package/poom-utils.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2019-01-29
- 0.0.1 — 2018-10-14

## README

# poom-requesthasher
A plugin decrypts querystring, request body data (except multipart) and encrypts response body data for [poom](https://github.com/onapiscom/poom)

# Install
```nodejs
npm i poom-requesthasher -S
```

# Examples

### Typescript
Use like a middleware
```nodejs
import { Server } from 'poom';
import { hasher } from 'poom-hasher';

Server.use(hasher('Key is 8 characters', {
    baseOnRequest: false,
    mode: ['query', 'body', 'response']
}))
```
Use in controller (Manual apis which you want encrypt data when you not declare in Server.use)
```nodejs
import { GET, POST, PUT, DELETE, HEAD, INJECT } from 'poom-route';
import { HASHER, Hasher } from 'poom-requesthasher';

const key = Hasher.create('Key is 8 characters');

export default class TestController {
    @GET('/test')
    @HASHER(key, {
        baseOnRequest: false,
        mode: ['query', 'body', 'response']
    })
    static async test({ body, headers, query }) {
    	return {
    		name: 'thanh'
    	};
    }
}
```
In that: 
* baseOnRequest: Plugin auto detect to encrypt, decrypt base on request from client via "accept" field is "text/encryption"
* mode: Which is encrypted or decrypted.  
    * query: Decrypt query string on request which is sent by client
    * body: Decrypt body data in POST, PUT (except multipart type) which is sent by client
    * response: Encrypt response body data which is sent from server to client

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