47ng / prisma-field-encryption

Transparent field-level encryption at rest for Prisma
https://github.com/franky47/prisma-field-encryption-sandbox
MIT License
223 stars 27 forks source link

feat(normalize-hash): Add support for normalizing hashes #110

Closed martijn-dev closed 2 weeks ago

martijn-dev commented 2 weeks ago

What's changed:

Potential Risks / Breaking changes

Text from the README:

You can normalize a hash before creation and querying. This might be useful in case you would like to find a User with the name of François with a query input of francois.

There are several normalize options:

/// @encryption:hash(email)?normalize=lowercase  <- lowercase hash
/// @encryption:hash(email)?normalize=uppercase  <- uppercase hash
/// @encryption:hash(email)?normalize=trim       <- trim start and end of hash
/// @encryption:hash(email)?normalize=spaces     <- remove spaces in hash
/// @encryption:hash(email)?normalize=diacritics <- remove diacritics like ç or é in hash

You can also combine the normalize options:

/// @encryption:hash(email)?normalize=lowercase&normalize=trim&normalize=trim&normalize=diacritics

Be aware: Using the normalize hash feature in combination with unique could cause conflicts. Example: Users with the name François and francois result in the same hash which could result in a database conflict.

Questions?

Let me know what you think! Always open to discussion. I hope you see this feature as a catalyst to expand support for searching in encrypted db values. Cheers, Martijn


Fixes #109

coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9660461861

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dmmf.ts 6 7 85.71%
src/errors.ts 1 2 50.0%
src/hash.ts 14 16 87.5%
<!-- Total: 27 31 87.1% -->
Totals Coverage Status
Change from base Build 7807229309: -0.6%
Covered Lines: 269
Relevant Lines: 318

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9660494463

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dmmf.ts 6 7 85.71%
src/errors.ts 1 2 50.0%
src/hash.ts 14 16 87.5%
<!-- Total: 27 31 87.1% -->
Totals Coverage Status
Change from base Build 7807229309: -0.6%
Covered Lines: 269
Relevant Lines: 318

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9662361328

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dmmf.ts 6 8 75.0%
src/errors.ts 1 3 33.33%
src/hash.ts 14 16 87.5%
<!-- Total: 27 33 81.82% -->
Totals Coverage Status
Change from base Build 7807229309: -1.5%
Covered Lines: 269
Relevant Lines: 320

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9662382333

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dmmf.ts 6 8 75.0%
src/errors.ts 1 3 33.33%
src/hash.ts 14 16 87.5%
<!-- Total: 27 33 81.82% -->
Totals Coverage Status
Change from base Build 7807229309: -1.5%
Covered Lines: 269
Relevant Lines: 320

💛 - Coveralls
coveralls commented 2 weeks ago

Pull Request Test Coverage Report for Build 9662247468

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dmmf.ts 6 8 75.0%
src/errors.ts 1 3 33.33%
src/hash.ts 14 16 87.5%
<!-- Total: 27 33 81.82% -->
Totals Coverage Status
Change from base Build 7807229309: -1.5%
Covered Lines: 269
Relevant Lines: 320

💛 - Coveralls
franky47 commented 2 weeks ago

This has been released in 1.6.0-beta.1, if you want to give it a spin.