Skip to content

Commit

Permalink
feat: encryption predicate option
Browse files Browse the repository at this point in the history
  • Loading branch information
basz committed Apr 17, 2024
1 parent 8f963a9 commit 4d27298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export function encrypt<T extends ObjectLiteral>(entity: any): any {
let { propertyName, mode, target } = columnMetadata;
let options: ExtendedColumnOptions = columnMetadata.options;
let encrypt = options.encrypt;
if (encrypt?.encryptionPredicate && !encrypt?.encryptionPredicate(entity)) {
continue;
}
if (
encrypt &&
mode === 'regular' &&
Expand Down Expand Up @@ -42,6 +45,9 @@ export function decrypt<T extends ObjectLiteral>(entity: any): any {
let { propertyName, mode, target } = columnMetadata;
let options: ExtendedColumnOptions = columnMetadata.options;
let encrypt = options.encrypt;
if (encrypt?.encryptionPredicate && !encrypt?.encryptionPredicate(entity)) {
continue;
}
if (
encrypt &&
mode === 'regular' &&
Expand Down
1 change: 1 addition & 0 deletions src/options/EncryptionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export interface EncryptionOptions {
iv?: string; //// For testing mainly.
authTagLength?: number;
looseMatching?: boolean;
encryptionPredicate?: (entity: any) => boolean;
}

0 comments on commit 4d27298

Please sign in to comment.