Encrypt archives at rest

This commit is contained in:
Dragory 2020-09-16 22:42:25 +03:00
parent 7562a886e1
commit a017aa7bfe
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
3 changed files with 47 additions and 1 deletions

View file

@ -0,0 +1,21 @@
import { decrypt, encrypt } from "../utils/crypt";
import { ValueTransformer } from "typeorm";
interface EncryptedTextTransformer extends ValueTransformer {
from(dbValue: any): string;
to(entityValue: string): any;
}
export function createEncryptedTextTransformer(): EncryptedTextTransformer {
return {
// Database -> Entity
from(dbValue) {
return decrypt(dbValue);
},
// Entity -> Database
to(entityValue) {
return encrypt(entityValue);
},
};
}