Skip to content

Commit 79272e8

Browse files
committed
feat: add auto encryption option
1 parent d97c40d commit 79272e8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/client-side-encryption/auto_encrypter.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export interface AutoEncryptionOptions {
105105
proxyOptions?: ProxyOptions;
106106
/** The TLS options to use connecting to the KMS provider */
107107
tlsOptions?: CSFLEKMSTlsOptions;
108+
/** Optional custom credential provider to use for KMS requests. */
109+
awsCredentialProvider?: AWSCredentialProvider;
108110
}
109111

110112
/**
@@ -239,6 +241,7 @@ export class AutoEncrypter {
239241
this._proxyOptions = options.proxyOptions || {};
240242
this._tlsOptions = options.tlsOptions || {};
241243
this._kmsProviders = options.kmsProviders || {};
244+
this._awsCredentialProvider = options.awsCredentialProvider;
242245

243246
const mongoCryptOptions: MongoCryptOptions = {
244247
cryptoCallbacks
@@ -329,11 +332,6 @@ export class AutoEncrypter {
329332
* This function is a no-op when bypassSpawn is set or the crypt shared library is used.
330333
*/
331334
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-
337335
if (this._bypassMongocryptdAndCryptShared || this.cryptSharedLibVersionInfo) {
338336
return;
339337
}

0 commit comments

Comments
 (0)