47ng / 47ng/prisma-field-encryption
Fields that are selected through include are returned as cyphertext
- Lenguaje dominante
- TypeScript
- Estrellas
- 306
- Forks
- 40
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
When doing a query which includes encrypted fields, rather than selecting them directly, the field will return encrypted.
Example of my prisma schema:
```
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
generator fieldEncryptionMigrations {
provider = "prisma-field-encryption"
output = "./migrations"
// Optionally opt-in to concurrent model migration.
// Since this can cause timeouts and performance issues,
// it's off by default, and models are updated sequentially.
concurrently = true
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
}
enum Role {
USER
ADMIN
}
model User {
id String @id @default(cuid()) @map("_id")
accountId String @unique
email String /// @encrypted?mode=strict
role Role @default(USER)
subscriptions Subscription[] @relation("subscriptions")
createdSubscriptions Subscription[] @relation("createdSubscriptions")
}
model Subscription {
id String @id @default(cuid()) @map("_id")
name String
paymentUrl String
expiresOn DateTime
customerId String
customer User @relation("subscriptions", fields: [customerId], references: [id])
adminId String
admin User @relation("createdSubscriptions", fields: [adminId], references: [id])
}
```
Guía de contribución
Línea de trabajo
The issue describes encrypted fields being returned as ciphertext when selected via `include` in a query. Start by examining the middleware code that handles field encryption/decryption, likely in the main plugin or migration generator. Look for where `include` relations are processed versus direct field selection. Check the test suite for existing tests on relation queries to understand the expected behavior. Verify the fix by writing a test that reproduces the issue with a model that has encrypted fields and a relation.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- mongodb, typescript
- Área
- backend-api-design, databases
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100