typeorm-encrypted icon indicating copy to clipboard operation
typeorm-encrypted copied to clipboard

typeorm encryption nopt working in case of unique true column

Open Akaim07 opened this issue 1 year ago • 3 comments

@Entity() export class UserEntity extends BaseEntity { @PrimaryGeneratedColumn() id: number; @Column() name: string; @Column() age: string; @Column({ type: "varchar", nullable: false, unique: true, transformer: new EncryptionTransformer({ key: 'e41c966f21f9e1577802463f8924e6a3fe3e9751f201304213b2f845d8841d61', algorithm: 'aes-256-gcm', ivLength: 16 }) }) email: string; } in this case it always generate new cyper even if the email is same expected it need to throw error of duplicate please take a look at this issue

Akaim07 avatar Feb 18 '24 13:02 Akaim07

Just came across through this.

This library is not working anymore because it's outdated. Newer TypeORM versions introduced a subscriber for beforeQuery event, that can be used to decrypt/encrypt parameters directly into the query, this way all cases are covered. So you have to implement this yourself manually as of this date there is no another option when using TypeORM.

jvdutrag avatar Mar 28 '24 19:03 jvdutrag

Good to know @jvdutrag . I've been too busy lately to keep up with this. If there are other people open to help maintaining it, I'd be happy to include them as a maintainer.

generalpiston avatar Mar 28 '24 19:03 generalpiston

I'm gonna try it and if it works will request a PR @generalpiston

jvdutrag avatar Mar 28 '24 20:03 jvdutrag