An open API service indexing awesome lists of open source software.

https://github.com/ed-itsolutions/typeorm-encrypted-column

Provides a decorator for encrypted columns in TypeORM.
https://github.com/ed-itsolutions/typeorm-encrypted-column

decorators encrypted-columns encryption typeorm

Last synced: 11 months ago
JSON representation

Provides a decorator for encrypted columns in TypeORM.

Awesome Lists containing this project

README

          

# Typeorm Encrypted Column

[![Build Status](https://travis-ci.org/Ed-ITSolutions/typeorm-encrypted-column.svg?branch=master)](https://travis-ci.org/Ed-ITSolutions/typeorm-encrypted-column) [![Coverage Status](https://coveralls.io/repos/github/Ed-ITSolutions/typeorm-encrypted-column/badge.svg?branch=master)](https://coveralls.io/github/Ed-ITSolutions/typeorm-encrypted-column?branch=master)

Typeorm Encrypted Column is a replacement for [typeorm-encrypted](https://github.com/generalpiston/typeorm-encrypted).

## Differences

Typeorm Encrypted Column works slightly differently.

Typeorm Encrypted Column uses a decorator instead of retyping the options object passed to column. Using this decorator it validates the key and algorithm provided throwing an error if they are not valid. This moves config errors to startup not the first time the encrypted column is accessed.

## Usage

```ts
import {Entity, PrimaryGeneratedColumn, Column, createConnection} from 'typeorm'
import {Subscriber as EncryptedColumnSubscriber, EncryptedColumn} from 'typeorm-encrypted-column'

@Entity()
class ProtectedData{
@PrimaryGeneratedColumn()
id: number

@Column()
name: string

@EncryptedColumn({
encrypt: {
key: 'd85117047fd06d3afa79b6e44ee3a52eb426fc24c3a2e3667732e8da0342b4da',
algorithm: 'aes-256-cbc',
ivLength: 16,
looseMatching: false // If true existance of the column will not be checked.
}
})
}

let connection = createConnection({
...
entities: [ProtectedData],
subscribers: [EncryptedColumnSubscriber]
})
```

## Contributing

Pull requests and issues are welcome on this repository.

To build locally pull a copy of the repository and run npm install to get the dependecies.

Testing is done with `npm test` which will test the code.