generalpiston / typeorm-encrypted

Encrypted field for typeorm.
MIT License
74 stars 19 forks source link

typeorm encryption nopt working in case of unique true column #68

Open Akaim07 opened 5 months ago

Akaim07 commented 5 months ago

@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

jvdutrag commented 3 months ago

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.

generalpiston commented 3 months ago

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.

jvdutrag commented 3 months ago

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