@godspeedsystems/prisma-deterministic-search-field-encryption
Version:
Transparent and customizable field-level encryption at rest for Prisma based on prisma-field-encryption package
30 lines (29 loc) • 1.76 kB
TypeScript
import { CloakKeychain, ParsedCloakKey } from '@47ng/cloak';
import type { DMMFModels } from './dmmf';
import type { MiddlewareParams, EncryptionFn, DecryptionFn, Configuration, CipherFunctions } from './types';
export interface KeysConfiguration {
encryptionKey: ParsedCloakKey;
keychain: CloakKeychain;
}
export interface FunctionsConfiguration {
encryptFn: EncryptionFn;
decryptFn: DecryptionFn;
}
export interface ConfigureKeysParams {
encryptionKey?: string;
decryptionKeys?: string[];
}
export interface KeysAndFunctionsConfiguration {
keys: KeysConfiguration | null;
cipherFunctions: CipherFunctions | null;
method: Method;
}
export declare type Method = 'CUSTOM' | 'DEFAULT';
export declare function configureKeysAndFunctions(config: Configuration): KeysAndFunctionsConfiguration;
export declare function getMethod(config: Configuration): Method;
export declare function isDefaultConfiguration(config: Configuration): boolean;
export declare function isCustomConfiguration(config: Configuration): boolean;
export declare function configureFunctions(config: Configuration): FunctionsConfiguration;
export declare function configureKeys(config: Configuration): KeysConfiguration;
export declare function encryptOnWrite<Models extends string, Actions extends string>(params: MiddlewareParams<Models, Actions>, models: DMMFModels, operation: string, method: Method, keys: KeysConfiguration | null, encryptFn?: EncryptionFn): MiddlewareParams<Models, Actions>;
export declare function decryptOnRead<Models extends string, Actions extends string>(params: MiddlewareParams<Models, Actions>, result: any, models: DMMFModels, operation: string, method: Method, keys: KeysConfiguration | null, decryptFn?: DecryptionFn): void;