UNPKG

@godspeedsystems/prisma-deterministic-search-field-encryption

Version:

Transparent and customizable field-level encryption at rest for Prisma based on prisma-field-encryption package

315 lines (314 loc) 9.19 kB
/** * Prisma types -- * * We're copying just what we need for local type safety * without importing Prisma-generated types, as the location * of the generated client can be unknown (when using custom * or multiple client locations). */ import { z } from 'zod'; /** * Not ideal to use `any` on model & action, but Prisma's * strong typing there actually prevents using the correct * type without excessive generics wizardry. */ export declare type MiddlewareParams<Models extends string, Actions extends string> = { model?: Models; action: Actions; args: any; dataPath: string[]; runInTransaction: boolean; }; export declare type Middleware<Models extends string, Actions extends string, Result = any> = (params: MiddlewareParams<Models, Actions>, next: (params: MiddlewareParams<Models, Actions>) => Promise<Result>) => Promise<Result>; declare const dmmfFieldParser: z.ZodObject<{ name: z.ZodString; isList: z.ZodBoolean; isUnique: z.ZodBoolean; isId: z.ZodBoolean; type: z.ZodAny; documentation: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }>; declare const dmmfModelParser: z.ZodObject<{ name: z.ZodString; fields: z.ZodArray<z.ZodObject<{ name: z.ZodString; isList: z.ZodBoolean; isUnique: z.ZodBoolean; isId: z.ZodBoolean; type: z.ZodAny; documentation: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }>; export declare const dmmfDocumentParser: z.ZodObject<{ datamodel: z.ZodObject<{ models: z.ZodArray<z.ZodObject<{ name: z.ZodString; fields: z.ZodArray<z.ZodObject<{ name: z.ZodString; isList: z.ZodBoolean; isUnique: z.ZodBoolean; isId: z.ZodBoolean; type: z.ZodAny; documentation: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }>, "many">; types: z.ZodArray<z.ZodObject<{ name: z.ZodString; fields: z.ZodArray<z.ZodObject<{ name: z.ZodString; isList: z.ZodBoolean; isUnique: z.ZodBoolean; isId: z.ZodBoolean; type: z.ZodAny; documentation: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }, { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }>, "many">; }, "strip", z.ZodTypeAny, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }, { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }>, "many">; }, "strip", z.ZodTypeAny, { models: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; types: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; }, { models: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; types: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; }>; }, "strip", z.ZodTypeAny, { datamodel: { models: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; types: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; }; }, { datamodel: { models: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; types: { name: string; fields: { name: string; isList: boolean; isUnique: boolean; isId: boolean; type?: any; documentation?: string | undefined; }[]; }[]; }; }>; export declare type DMMFModel = z.TypeOf<typeof dmmfModelParser>; export declare type DMMFField = z.TypeOf<typeof dmmfFieldParser>; export declare type DMMFDocument = z.TypeOf<typeof dmmfDocumentParser>; export declare type EncryptionFn = (clearText: any) => string; export declare type DecryptionFn = (cipherText: string) => any; export declare type CipherFunctions = { encryptFn: EncryptionFn; decryptFn: DecryptionFn; dmmf?: DMMFDocument; encryptionKey?: never; decryptionKeys?: never; }; export declare type Keys = { encryptionKey?: string; decryptionKeys?: string[]; dmmf?: DMMFDocument; encryptFn?: never; decryptFn?: never; }; export declare type Configuration = CipherFunctions | Keys | { encryptionKey?: string; decryptionKeys?: string[]; dmmf?: DMMFDocument; encryptFn: EncryptionFn; decryptFn: DecryptionFn; }; export interface FieldConfiguration { encrypt: boolean; strictDecryption: boolean; } export interface FieldMatcher { regexp: RegExp; fieldConfig: FieldConfiguration; } export {};