Skip to content

Commit 9477255

Browse files
committed
fix: auto encrypter client options
1 parent 1e2a63a commit 9477255

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/client-side-encryption/auto_encrypter.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ export class AutoEncrypter {
239239
this._proxyOptions = options.proxyOptions || {};
240240
this._tlsOptions = options.tlsOptions || {};
241241
this._kmsProviders = options.kmsProviders || {};
242-
this._awsCredentialProvider =
243-
client.options.credentials?.mechanismProperties.AWS_CREDENTIAL_PROVIDER;
244242

245243
const mongoCryptOptions: MongoCryptOptions = {
246244
cryptoCallbacks
@@ -331,6 +329,11 @@ export class AutoEncrypter {
331329
* This function is a no-op when bypassSpawn is set or the crypt shared library is used.
332330
*/
333331
async init(): Promise<MongoClient | void> {
332+
// This is handled during init() as the auto encrypter is instantiated during the client's
333+
// parseOptions() call, so the client doesn't have its options set at that point.
334+
this._awsCredentialProvider =
335+
this._client.options.credentials?.mechanismProperties.AWS_CREDENTIAL_PROVIDER;
336+
334337
if (this._bypassMongocryptdAndCryptShared || this.cryptSharedLibVersionInfo) {
335338
return;
336339
}

0 commit comments

Comments
 (0)