Skip to content

Commit 6194951

Browse files
committed
fix(NODE-6584): improve typing for files in AutoEncryptionOptions
1 parent 1673748 commit 6194951

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/client-side-encryption/auto_encrypter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface AutoEncryptionOptions {
5757
/** If true, autoEncryption will not attempt to spawn a mongocryptd before connecting */
5858
mongocryptdBypassSpawn?: boolean;
5959
/** The path to the mongocryptd executable on the system */
60-
mongocryptdSpawnPath?: string;
60+
mongocryptdSpawnPath?: `${string}mongocryptd${'.exe' | ''}`;
6161
/** Command line arguments to use when auto-spawning a mongocryptd */
6262
mongocryptdSpawnArgs?: string[];
6363
/**
@@ -83,7 +83,7 @@ export interface AutoEncryptionOptions {
8383
*
8484
* Requires the MongoDB Crypt shared library, available in MongoDB 6.0 or higher.
8585
*/
86-
cryptSharedLibPath?: string;
86+
cryptSharedLibPath?: `${string}mongo_crypt_v${number}.${'so' | 'dll' | 'dylib'}`;
8787
/**
8888
* If specified, never use mongocryptd and instead fail when the MongoDB Crypt
8989
* shared library could not be loaded.

test/types/client-side-encryption.test-d.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expectAssignable, expectError, expectNotAssignable, expectType } from '
22

33
import type {
44
AWSEncryptionKeyOptions,
5+
AutoEncryptionOptions,
56
AzureEncryptionKeyOptions,
67
ClientEncryption,
78
ClientEncryptionEncryptOptions,
@@ -107,3 +108,52 @@ expectAssignable<RequiredCreateEncryptedCollectionSettings>({
107108

108109
expectNotAssignable<ClientEncryptionDataKeyProvider>('arbitrary string');
109110
}
111+
112+
{
113+
expectAssignable<AutoEncryptionOptions>({
114+
extraOptions: {
115+
mongocryptdSpawnPath: 'mongocryptd'
116+
}
117+
});
118+
expectAssignable<AutoEncryptionOptions>({
119+
extraOptions: {
120+
mongocryptdSpawnPath: 'mongocryptd.exe'
121+
}
122+
});
123+
expectAssignable<AutoEncryptionOptions>({
124+
extraOptions: {
125+
mongocryptdSpawnPath: '/usr/bin/mongocryptd'
126+
}
127+
});
128+
expectNotAssignable<AutoEncryptionOptions>({
129+
extraOptions: {
130+
mongocryptdSpawnPath: 'mongo_crypt_v1.so'
131+
}
132+
});
133+
134+
expectAssignable<AutoEncryptionOptions>({
135+
extraOptions: {
136+
cryptSharedLibPath: 'mongo_crypt_v1.so'
137+
}
138+
});
139+
expectAssignable<AutoEncryptionOptions>({
140+
extraOptions: {
141+
cryptSharedLibPath: 'mongo_crypt_v1.dll'
142+
}
143+
});
144+
expectAssignable<AutoEncryptionOptions>({
145+
extraOptions: {
146+
cryptSharedLibPath: 'mongo_crypt_v1.dylib'
147+
}
148+
});
149+
expectAssignable<AutoEncryptionOptions>({
150+
extraOptions: {
151+
cryptSharedLibPath: '/usr/lib/mongo_crypt_v1.dylib'
152+
}
153+
});
154+
expectNotAssignable<AutoEncryptionOptions>({
155+
extraOptions: {
156+
cryptSharedLibPath: 'libmongocrypt.so'
157+
}
158+
});
159+
}

0 commit comments

Comments
 (0)