Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add @encrypted enhancer #1922

Merged
merged 20 commits into from
Dec 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
23a06cc
feat: add encrypted kind
genu Dec 20, 2024
7784099
chore: add encrypt function
genu Dec 20, 2024
f8ee204
test: add integration tests for encrypted model functionality
genu Dec 20, 2024
6bff7f4
test: Add test
genu Dec 20, 2024
b86e814
fix: require encryption options for @encrypted enhancement
genu Dec 23, 2024
e0789b7
feat: enhance encryption handling in EncryptedHandler and update sche…
genu Dec 23, 2024
688d92d
fix: remove hardcoded encryption key from schema loading command
genu Dec 23, 2024
aedbd93
feat: implement custom encryption handling in EncryptedHandler
genu Dec 23, 2024
8752f06
fix: update encryption methods to return promises in EncryptedHandler
genu Dec 23, 2024
83c242c
test: add integration tests for custom encryption handling in Encrypt…
genu Dec 23, 2024
d9b95ef
chore: Add symlink
genu Dec 24, 2024
2ea8bd2
refactor: streamline encryption handling by moving key retrieval and …
genu Dec 24, 2024
78046b3
refactor: don't enable `encrypted` enhancement by default
genu Dec 24, 2024
9d16be0
refactor: change encryptionKey type from string to Uint8Array in Simp…
genu Dec 24, 2024
29b7d15
refactor: enhance encryption validation and update key handling in En…
genu Dec 24, 2024
a7169ef
refactor: prevent encryption of null, undefined, or empty string valu…
genu Dec 24, 2024
acb2ee2
refactor: prevent decryption and encryption of null, undefined, or em…
genu Dec 24, 2024
f4dda18
refactor: continue instead of return
genu Dec 26, 2024
4e5a2be
refactor: add 'encrypted' enhancement kind to ALL_ENHANCEMENTS
genu Dec 27, 2024
fa5c065
refactor: improve error handling for encryption and decryption in Enc…
genu Dec 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: prevent encryption of null, undefined, or empty string valu…
…es in EncryptedHandler
genu committed Dec 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a7169ef055ff1ae2ed1d8b9487d056a5e0128b90
3 changes: 3 additions & 0 deletions packages/runtime/src/enhancements/node/encrypted.ts
Original file line number Diff line number Diff line change
@@ -149,6 +149,9 @@ class EncryptedHandler extends DefaultPrismaProxyHandler {
private async preprocessWritePayload(model: string, action: PrismaWriteActionType, args: any) {
const visitor = new NestedWriteVisitor(this.options.modelMeta, {
field: async (field, _action, data, context) => {
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
// Don't encrypt null, undefined or empty string values
if (!data) return;

const encAttr = field.attributes?.find((attr) => attr.name === '@encrypted');
if (encAttr && field.type === 'String') {
context.parent[field.name] = await this.encrypt(field, data);