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

'cursor' conversion is wrong #64

Closed martijn-dev closed 1 year ago

martijn-dev commented 1 year ago

The situation is the following:

The prisma schema:

model Visitor {
  id             String            @id @default(uuid())
  key            String            @unique /// @encrypted
  keyHash        String?           @unique /// @encryption:hash(key)
  created_at     DateTime          @default(now())

  @@map("visitors")
}

I would like to do a findMany with a cursor. So I will do the following:

 this.prisma.visitor.findMany({
           take: 5,
           skip: 1,
           cursor: {
             key: 'xxxxx-key-xxxxx',
           },
         })

But this gets converted to:

 this.prisma.visitor.findMany({
           take: 5,
           skip: 1,
           cursor: {
             key: 'v1.aesgcm256.xxxxxxx.8xxxxxxxxxxxxxxxxxxWhfw==',
             keyHash: 'xxxxxxxxx-hash-xxxxxxxxxxxx'
           },
         })

Which results in a Prisma error: Argument cursor of type VisitorWhereUniqueInput needs exactly one argument, but you provided key and keyHash. Please choose one.

I would expect it to convert to:

 this.prisma.visitor.findMany({
           take: 5,
           skip: 1,
           cursor: {
             keyHash: 'xxxxxxxxx-hash-xxxxxxxxxxxx',
           },
         })

Please let me know if you need more information!

franky47 commented 1 year ago

Ah, this is the same issue we just had with connect a few days ago, it should be an easy fix.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.4.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: