Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-6584): improve typing for files in AutoEncryptionOptions #4341

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client-side-encryption/auto_encrypter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface AutoEncryptionOptions {
/** If true, autoEncryption will not attempt to spawn a mongocryptd before connecting */
mongocryptdBypassSpawn?: boolean;
/** The path to the mongocryptd executable on the system */
mongocryptdSpawnPath?: string;
mongocryptdSpawnPath?: `${string}mongocryptd${'.exe' | ''}`;
/** Command line arguments to use when auto-spawning a mongocryptd */
mongocryptdSpawnArgs?: string[];
/**
Expand All @@ -83,7 +83,7 @@ export interface AutoEncryptionOptions {
*
* Requires the MongoDB Crypt shared library, available in MongoDB 6.0 or higher.
*/
cryptSharedLibPath?: string;
cryptSharedLibPath?: `${string}mongo_crypt_v${number}.${'so' | 'dll' | 'dylib'}`;
/**
* If specified, never use mongocryptd and instead fail when the MongoDB Crypt
* shared library could not be loaded.
Expand Down
50 changes: 50 additions & 0 deletions test/types/client-side-encryption.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expectAssignable, expectError, expectNotAssignable, expectType } from '

import type {
AWSEncryptionKeyOptions,
AutoEncryptionOptions,
AzureEncryptionKeyOptions,
ClientEncryption,
ClientEncryptionEncryptOptions,
Expand Down Expand Up @@ -107,3 +108,52 @@ expectAssignable<RequiredCreateEncryptedCollectionSettings>({

expectNotAssignable<ClientEncryptionDataKeyProvider>('arbitrary string');
}

{
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
mongocryptdSpawnPath: 'mongocryptd'
}
});
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
mongocryptdSpawnPath: 'mongocryptd.exe'
}
});
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
mongocryptdSpawnPath: '/usr/bin/mongocryptd'
}
});
expectNotAssignable<AutoEncryptionOptions>({
extraOptions: {
mongocryptdSpawnPath: 'mongo_crypt_v1.so'
}
});

expectAssignable<AutoEncryptionOptions>({
extraOptions: {
cryptSharedLibPath: 'mongo_crypt_v1.so'
}
});
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
cryptSharedLibPath: 'mongo_crypt_v1.dll'
}
});
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
cryptSharedLibPath: 'mongo_crypt_v1.dylib'
}
});
expectAssignable<AutoEncryptionOptions>({
extraOptions: {
cryptSharedLibPath: '/usr/lib/mongo_crypt_v1.dylib'
}
});
expectNotAssignable<AutoEncryptionOptions>({
extraOptions: {
cryptSharedLibPath: 'libmongocrypt.so'
}
});
}
Loading