aws.js 1.1 KB

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.loadAWSCredentials = loadAWSCredentials;
  4. const aws_temporary_credentials_1 = require("../../cmap/auth/aws_temporary_credentials");
  5. /**
  6. * @internal
  7. */
  8. async function loadAWSCredentials(kmsProviders, provider) {
  9. const credentialProvider = new aws_temporary_credentials_1.AWSSDKCredentialProvider(provider);
  10. // We shouldn't ever receive a response from the AWS SDK that doesn't have a `SecretAccessKey`
  11. // or `AccessKeyId`. However, TS says these fields are optional. We provide empty strings
  12. // and let libmongocrypt error if we're unable to fetch the required keys.
  13. const { SecretAccessKey = '', AccessKeyId = '', Token } = await credentialProvider.getCredentials();
  14. const aws = {
  15. secretAccessKey: SecretAccessKey,
  16. accessKeyId: AccessKeyId
  17. };
  18. // the AWS session token is only required for temporary credentials so only attach it to the
  19. // result if it's present in the response from the aws sdk
  20. Token != null && (aws.sessionToken = Token);
  21. return { ...kmsProviders, aws };
  22. }
  23. //# sourceMappingURL=aws.js.map