hinos-requesthasher
TypeScript icon, indicating that this package has built-in type declarations

1.2.6 • Public • Published

hinos-requesthasher

A plugin decrypts querystring, body data (except multipart) and encrypts response body data base on BlowFish for hinos

Install

npm i hinos-requesthasher -S

Examples

Typescript

Use like a middleware

import { Server } from 'hinos';
import { hasher } from 'hinos-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)

import { GET, POST, PUT, DELETE, HEAD, INJECT } from 'hinos-route';
import { HASHER, Hasher } from 'hinos-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

Readme

Keywords

none

Package Sidebar

Install

npm i hinos-requesthasher

Weekly Downloads

4

Version

1.2.6

License

ISC

Unpacked Size

11.5 kB

Total Files

13

Last publish

Collaborators

  • doanthuanthanh88