diff --git a/types/schemaoptions.d.ts b/types/schemaoptions.d.ts index 4df87a806e..d9bb080878 100644 --- a/types/schemaoptions.d.ts +++ b/types/schemaoptions.d.ts @@ -258,6 +258,8 @@ declare module 'mongoose' { * @default false */ overwriteModels?: boolean; + + encryptionType?: 'csfle' | 'queryableEncryption'; } interface DefaultSchemaOptions { diff --git a/types/schematypes.d.ts b/types/schematypes.d.ts index 5f364f0cea..22e2992f6e 100644 --- a/types/schematypes.d.ts +++ b/types/schematypes.d.ts @@ -1,3 +1,5 @@ +import * as BSON from 'bson'; + declare module 'mongoose' { /** The Mongoose Date [SchemaType](/docs/schematypes.html). */ @@ -207,6 +209,8 @@ declare module 'mongoose' { maxlength?: number | [number, string] | readonly [number, string]; [other: string]: any; + + encrypt?: EncryptSchemaTypeOptions; } interface Validator { @@ -218,6 +222,28 @@ declare module 'mongoose' { type ValidatorFunction = (this: DocType, value: any, validatorProperties?: Validator) => any; + export interface EncryptSchemaTypeOptions { + /** The id of the dataKey to use for encryption */ + keyId: BSON.UUID; + + /** + * Specifies the type of queries that the field can be queried on for Queryable Encryption. + * Required when `SchemaOptions.encryptionType` is 'queryableEncryption' + */ + queries?: 'equality' | 'range'; + + /** + * The algorithm to use for encryption. + * Required when `SchemaOptions.encryptionType` is 'csfle' + */ + algorithm?: + | 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic' + | 'AEAD_AES_256_CBC_HMAC_SHA_512-Random' + | 'Indexed' + | 'Unindexed' + | 'Range'; + } + class SchemaType { /** SchemaType constructor */ constructor(path: string, options?: AnyObject, instance?: string);