|
6 | 6 | import * as net from 'net';
|
7 | 7 |
|
8 | 8 | import { deserialize, type Document, serialize } from '../bson';
|
| 9 | +import { type AWSCredentialProvider } from '../cmap/auth/aws_temporary_credentials'; |
9 | 10 | import { type CommandOptions, type ProxyOptions } from '../cmap/connection';
|
10 | 11 | import { kDecorateResult } from '../constants';
|
11 | 12 | import { getMongoDBClientEncryption } from '../deps';
|
@@ -153,6 +154,7 @@ export class AutoEncrypter {
|
153 | 154 | _kmsProviders: KMSProviders;
|
154 | 155 | _bypassMongocryptdAndCryptShared: boolean;
|
155 | 156 | _contextCounter: number;
|
| 157 | + _awsCredentialProvider?: AWSCredentialProvider; |
156 | 158 |
|
157 | 159 | _mongocryptdManager?: MongocryptdManager;
|
158 | 160 | _mongocryptdClient?: MongoClient;
|
@@ -327,6 +329,11 @@ export class AutoEncrypter {
|
327 | 329 | * This function is a no-op when bypassSpawn is set or the crypt shared library is used.
|
328 | 330 | */
|
329 | 331 | 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 | + |
330 | 337 | if (this._bypassMongocryptdAndCryptShared || this.cryptSharedLibVersionInfo) {
|
331 | 338 | return;
|
332 | 339 | }
|
@@ -438,7 +445,7 @@ export class AutoEncrypter {
|
438 | 445 | * the original ones.
|
439 | 446 | */
|
440 | 447 | async askForKMSCredentials(): Promise<KMSProviders> {
|
441 |
| - return await refreshKMSCredentials(this._kmsProviders); |
| 448 | + return await refreshKMSCredentials(this._kmsProviders, this._awsCredentialProvider); |
442 | 449 | }
|
443 | 450 |
|
444 | 451 | /**
|
|
0 commit comments