dotsec 0.10.0 → 0.10.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
7
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
8
  var __getProtoOf = Object.getPrototypeOf;
@@ -18,6 +20,7 @@ var __spreadValues = (a, b) => {
18
20
  }
19
21
  return a;
20
22
  };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
24
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
25
  var __export = (target, all) => {
23
26
  __markAsModule(target);
@@ -75,8 +78,7 @@ var commonCliOptions = {
75
78
  },
76
79
  envFile: {
77
80
  string: true,
78
- describe: ".env file",
79
- default: ".env"
81
+ describe: ".env file"
80
82
  },
81
83
  ignoreMissingEnvFile: {
82
84
  boolean: true,
@@ -99,6 +101,14 @@ var commonCliOptions = {
99
101
  boolean: true,
100
102
  describe: "Be verbose"
101
103
  },
104
+ encryptedSecretsFile: {
105
+ string: true,
106
+ describe: "filename of json file for reading encrypted secrets"
107
+ },
108
+ jsonFilter: {
109
+ string: true,
110
+ describe: "dot separated filter path, for example a.b.c will return { a: { b: { c: ... }}}"
111
+ },
102
112
  yes: {
103
113
  boolean: true,
104
114
  describe: "Proceeds without confirmation"
@@ -321,11 +331,11 @@ __export(decryptSecCommand_exports, {
321
331
  desc: () => desc2,
322
332
  handler: () => handler2
323
333
  });
324
- var import_client_kms = __toModule(require("@aws-sdk/client-kms"));
325
- var import_chalk2 = __toModule(require("chalk"));
326
- var import_dotenv = __toModule(require("dotenv"));
327
334
  var import_node_fs = __toModule(require("node:fs"));
328
335
  var import_node_path = __toModule(require("node:path"));
336
+ var import_client_kms2 = __toModule(require("@aws-sdk/client-kms"));
337
+ var import_chalk2 = __toModule(require("chalk"));
338
+ var import_dotenv = __toModule(require("dotenv"));
329
339
 
330
340
  // src/utils/io.ts
331
341
  var import_promises = __toModule(require("fs/promises"));
@@ -357,6 +367,27 @@ var promptOverwriteIfFileExists = async ({
357
367
  return overwriteResponse;
358
368
  };
359
369
 
370
+ // src/utils/kms.ts
371
+ var import_client_kms = __toModule(require("@aws-sdk/client-kms"));
372
+ var getKMSClient = ({
373
+ configuration
374
+ }) => {
375
+ const kmsClient = new import_client_kms.KMSClient(configuration);
376
+ return kmsClient;
377
+ };
378
+ var getEncryptionAlgorithm = async (kmsClient, awsKeyAlias) => {
379
+ var _a, _b;
380
+ const describeKeyCommand = new import_client_kms.DescribeKeyCommand({
381
+ KeyId: awsKeyAlias
382
+ });
383
+ const describeKeyResult = await kmsClient.send(describeKeyCommand);
384
+ const encryptionAlgorithm = (_b = (_a = describeKeyResult.KeyMetadata) == null ? void 0 : _a.EncryptionAlgorithms) == null ? void 0 : _b[0];
385
+ if (encryptionAlgorithm === void 0) {
386
+ throw new Error(`Could not determine encryption algorithm`);
387
+ }
388
+ return encryptionAlgorithm;
389
+ };
390
+
360
391
  // src/commands/decryptSecCommand.ts
361
392
  var command2 = "decrypt-sec";
362
393
  var desc2 = "Decrypts a dotsec file";
@@ -365,7 +396,7 @@ var builder2 = {
365
396
  "aws-region": commonCliOptions.awsRegion,
366
397
  "aws-key-alias": commonCliOptions.awsKeyAlias,
367
398
  "assume-role-arn": commonCliOptions.awsAssumeRoleArn,
368
- "env-file": commonCliOptions.envFile,
399
+ "env-file": __spreadProps(__spreadValues({}, commonCliOptions.envFile), { default: "env" }),
369
400
  "sec-file": commonCliOptions.secFile,
370
401
  verbose: commonCliOptions.verbose
371
402
  };
@@ -381,15 +412,16 @@ var handler2 = async (argv) => {
381
412
  return;
382
413
  }
383
414
  const parsedSec = (0, import_dotenv.parse)(import_node_fs.default.readFileSync(secSource, { encoding: "utf8" }));
384
- const kmsClient = new import_client_kms.KMSClient({
415
+ const kmsClient = new import_client_kms2.KMSClient({
385
416
  credentials: credentialsAndOrigin.value,
386
417
  region: regionAndOrigin.value
387
418
  });
419
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, argv.awsKeyAlias);
388
420
  const envEntries = await Promise.all(Object.entries(parsedSec).map(async ([key, cipherText]) => {
389
- const decryptCommand = new import_client_kms.DecryptCommand({
421
+ const decryptCommand = new import_client_kms2.DecryptCommand({
390
422
  KeyId: argv.awsKeyAlias,
391
423
  CiphertextBlob: Buffer.from(cipherText, "base64"),
392
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
424
+ EncryptionAlgorithm: encryptionAlgorithm
393
425
  });
394
426
  const decryptionResult = await kmsClient.send(decryptCommand);
395
427
  if (!(decryptionResult == null ? void 0 : decryptionResult.Plaintext)) {
@@ -416,22 +448,11 @@ __export(decryptSecretsJson_exports, {
416
448
  desc: () => desc3,
417
449
  handler: () => handler3
418
450
  });
451
+ var import_node_fs2 = __toModule(require("node:fs"));
452
+ var import_node_path2 = __toModule(require("node:path"));
419
453
  var import_client_kms3 = __toModule(require("@aws-sdk/client-kms"));
420
454
  var import_chalk3 = __toModule(require("chalk"));
421
455
  var import_flat = __toModule(require("flat"));
422
- var import_node_fs2 = __toModule(require("node:fs"));
423
- var import_node_path2 = __toModule(require("node:path"));
424
-
425
- // src/utils/kms.ts
426
- var import_client_kms2 = __toModule(require("@aws-sdk/client-kms"));
427
- var getKMSClient = ({
428
- configuration
429
- }) => {
430
- const kmsClient = new import_client_kms2.KMSClient(configuration);
431
- return kmsClient;
432
- };
433
-
434
- // src/commands/decryptSecretsJson.ts
435
456
  var command3 = "decrypt-secrets-json";
436
457
  var desc3 = "Derypts an encrypted file";
437
458
  var builder3 = {
@@ -443,11 +464,9 @@ var builder3 = {
443
464
  describe: "filename of json file writing secrets",
444
465
  default: "secrets.json"
445
466
  },
446
- "encrypted-secrets-file": {
447
- string: true,
448
- describe: "filename of json file for reading encrypted secrets",
467
+ "encrypted-secrets-file": __spreadProps(__spreadValues({}, commonCliOptions.encryptedSecretsFile), {
449
468
  default: "secrets.encrypted.json"
450
- },
469
+ }),
451
470
  "assume-role-arn": commonCliOptions.awsAssumeRoleArn,
452
471
  verbose: commonCliOptions.verbose,
453
472
  yes: __spreadValues({}, commonCliOptions.yes)
@@ -484,11 +503,12 @@ var handler3 = async (argv) => {
484
503
  const describeKeyResult = await kmsClient.send(describeKeyCommand);
485
504
  console.log("describeKeyResult", { describeKeyResult });
486
505
  }
506
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, argv.awsKeyAlias);
487
507
  const flatParameters = Object.fromEntries(await Promise.all(Object.entries(flatEncryptedParameters).map(async ([parameterName, encryptedParameter]) => {
488
508
  const decryptCommand = new import_client_kms3.DecryptCommand({
489
509
  KeyId: argv.awsKeyAlias,
490
510
  CiphertextBlob: Buffer.from(encryptedParameter, "base64"),
491
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
511
+ EncryptionAlgorithm: encryptionAlgorithm
492
512
  });
493
513
  const decryptionResult = await kmsClient.send(decryptCommand);
494
514
  if (!decryptionResult.Plaintext) {
@@ -533,9 +553,34 @@ __export(defaultCommand_exports, {
533
553
  var import_node_fs3 = __toModule(require("node:fs"));
534
554
  var import_node_path3 = __toModule(require("node:path"));
535
555
  var import_client_kms4 = __toModule(require("@aws-sdk/client-kms"));
536
- var import_chalk4 = __toModule(require("chalk"));
556
+ var import_chalk5 = __toModule(require("chalk"));
557
+ var import_constant_case = __toModule(require("constant-case"));
537
558
  var import_cross_spawn = __toModule(require("cross-spawn"));
538
559
  var import_dotenv2 = __toModule(require("dotenv"));
560
+ var import_flat2 = __toModule(require("flat"));
561
+
562
+ // src/lib/encryptedSecrets.ts
563
+ var import_fs = __toModule(require("fs"));
564
+ var import_path = __toModule(require("path"));
565
+ var import_chalk4 = __toModule(require("chalk"));
566
+ var loadEncryptedSecrets = async ({
567
+ encryptedSecretsFile
568
+ }) => {
569
+ const encryptedSecretsPath = import_path.default.resolve(process.cwd(), encryptedSecretsFile);
570
+ if (!await fileExists(encryptedSecretsPath)) {
571
+ throw new Error(`Could not open ${(0, import_chalk4.redBright)(encryptedSecretsPath)}`);
572
+ }
573
+ const encryptedSecrets = JSON.parse(import_fs.default.readFileSync(encryptedSecretsPath, { encoding: "utf8" }));
574
+ if (!encryptedSecrets) {
575
+ throw new Error(`No encrypted secrets found in ${(0, import_chalk4.redBright)(encryptedSecretsPath)}`);
576
+ }
577
+ if (!encryptedSecrets.encryptedParameters) {
578
+ throw new Error(`Expected 'encryptedParameters' property, but got none`);
579
+ }
580
+ return encryptedSecrets;
581
+ };
582
+
583
+ // src/commands/defaultCommand.ts
539
584
  var command4 = "$0 <command>";
540
585
  var desc4 = "Decrypts a .sec file, injects the results into a separate process and runs a command";
541
586
  var builder4 = {
@@ -547,6 +592,8 @@ var builder4 = {
547
592
  "ignore-missing-env-file": commonCliOptions.ignoreMissingEnvFile,
548
593
  "aws-assume-role-arn": commonCliOptions.awsAssumeRoleArn,
549
594
  "aws-assume-role-session-duration": commonCliOptions.awsAssumeRoleSessionDuration,
595
+ "encrypted-secrets-file": commonCliOptions.encryptedSecretsFile,
596
+ "json-filter": commonCliOptions.jsonFilter,
550
597
  verbose: commonCliOptions.verbose,
551
598
  command: { string: true, required: true }
552
599
  };
@@ -558,7 +605,7 @@ var handleSec = async ({
558
605
  }) => {
559
606
  const secSource = import_node_path3.default.resolve(process.cwd(), secFile);
560
607
  if (!await fileExists(secSource)) {
561
- console.error(`Could not open ${(0, import_chalk4.redBright)(secSource)}`);
608
+ console.error(`Could not open ${(0, import_chalk5.redBright)(secSource)}`);
562
609
  return;
563
610
  }
564
611
  const parsedSec = (0, import_dotenv2.parse)(import_node_fs3.default.readFileSync(secSource, { encoding: "utf8" }));
@@ -566,11 +613,59 @@ var handleSec = async ({
566
613
  credentials: credentialsAndOrigin.value,
567
614
  region: regionAndOrigin.value
568
615
  });
616
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, awsKeyAlias);
569
617
  const envEntries = await Promise.all(Object.entries(parsedSec).map(async ([key, cipherText]) => {
570
618
  const decryptCommand = new import_client_kms4.DecryptCommand({
571
619
  KeyId: awsKeyAlias,
572
620
  CiphertextBlob: Buffer.from(cipherText, "base64"),
573
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
621
+ EncryptionAlgorithm: encryptionAlgorithm
622
+ });
623
+ const decryptionResult = await kmsClient.send(decryptCommand);
624
+ if (!(decryptionResult == null ? void 0 : decryptionResult.Plaintext)) {
625
+ throw new Error(`No: ${JSON.stringify({
626
+ key,
627
+ cipherText,
628
+ decryptCommand
629
+ })}`);
630
+ }
631
+ const value = Buffer.from(decryptionResult.Plaintext).toString();
632
+ return [key, value];
633
+ }));
634
+ const env = Object.fromEntries(envEntries);
635
+ return env;
636
+ };
637
+ var handleEncryptedJson = async ({
638
+ encryptedSecretsFile,
639
+ jsonFilter,
640
+ credentialsAndOrigin,
641
+ regionAndOrigin,
642
+ awsKeyAlias
643
+ }) => {
644
+ const encryptedSecrets = await loadEncryptedSecrets({
645
+ encryptedSecretsFile
646
+ });
647
+ const flattened = import_flat2.default.flatten(encryptedSecrets.encryptedParameters, {
648
+ delimiter: "__",
649
+ transformKey: (key) => {
650
+ return (0, import_constant_case.constantCase)(key);
651
+ }
652
+ });
653
+ const kmsClient = new import_client_kms4.KMSClient({
654
+ credentials: credentialsAndOrigin.value,
655
+ region: regionAndOrigin.value
656
+ });
657
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, awsKeyAlias);
658
+ const filterKey = jsonFilter == null ? void 0 : jsonFilter.split(".").map((part) => (0, import_constant_case.constantCase)(part)).join("__");
659
+ const envEntries = await Promise.all(Object.entries(flattened).filter(([key]) => {
660
+ if (filterKey) {
661
+ return key.indexOf(filterKey) === 0;
662
+ }
663
+ return true;
664
+ }).map(async ([key, cipherText]) => {
665
+ const decryptCommand = new import_client_kms4.DecryptCommand({
666
+ KeyId: awsKeyAlias,
667
+ CiphertextBlob: Buffer.from(cipherText, "base64"),
668
+ EncryptionAlgorithm: encryptionAlgorithm
574
669
  });
575
670
  const decryptionResult = await kmsClient.send(decryptCommand);
576
671
  if (!(decryptionResult == null ? void 0 : decryptionResult.Plaintext)) {
@@ -621,12 +716,22 @@ var handler4 = async (argv) => {
621
716
  if (argv.verbose) {
622
717
  console.log({ credentialsAndOrigin, regionAndOrigin });
623
718
  }
624
- env = await handleSec({
625
- secFile: argv.secFile,
626
- credentialsAndOrigin,
627
- regionAndOrigin,
628
- awsKeyAlias: argv.awsKeyAlias
629
- });
719
+ if (argv.encryptedSecretsFile) {
720
+ env = await handleEncryptedJson({
721
+ encryptedSecretsFile: argv.encryptedSecretsFile,
722
+ jsonFilter: argv.jsonFilter,
723
+ credentialsAndOrigin,
724
+ regionAndOrigin,
725
+ awsKeyAlias: argv.awsKeyAlias
726
+ });
727
+ } else {
728
+ env = await handleSec({
729
+ secFile: argv.secFile,
730
+ credentialsAndOrigin,
731
+ regionAndOrigin,
732
+ awsKeyAlias: argv.awsKeyAlias
733
+ });
734
+ }
630
735
  }
631
736
  } catch (e) {
632
737
  if (argv.ignoreMissingEnvFile !== true) {
@@ -654,18 +759,18 @@ __export(encryptEnvCommand_exports, {
654
759
  desc: () => desc5,
655
760
  handler: () => handler5
656
761
  });
657
- var import_client_kms5 = __toModule(require("@aws-sdk/client-kms"));
658
- var import_chalk5 = __toModule(require("chalk"));
659
- var import_dotenv3 = __toModule(require("dotenv"));
660
762
  var import_node_fs4 = __toModule(require("node:fs"));
661
763
  var import_node_path4 = __toModule(require("node:path"));
764
+ var import_client_kms5 = __toModule(require("@aws-sdk/client-kms"));
765
+ var import_chalk6 = __toModule(require("chalk"));
766
+ var import_dotenv3 = __toModule(require("dotenv"));
662
767
  var command5 = "encrypt-env";
663
768
  var desc5 = "Encrypts a dotenv file";
664
769
  var builder5 = {
665
770
  "aws-profile": commonCliOptions.awsProfile,
666
771
  "aws-region": commonCliOptions.awsRegion,
667
772
  "aws-key-alias": commonCliOptions.awsKeyAlias,
668
- "env-file": commonCliOptions.envFile,
773
+ "env-file": __spreadProps(__spreadValues({}, commonCliOptions.envFile), { default: ".env" }),
669
774
  "sec-file": commonCliOptions.secFile,
670
775
  "assume-role-arn": commonCliOptions.awsAssumeRoleArn,
671
776
  verbose: commonCliOptions.verbose
@@ -679,7 +784,7 @@ var handler5 = async (argv) => {
679
784
  });
680
785
  const envSource = import_node_path4.default.resolve(process.cwd(), argv.envFile);
681
786
  if (!await fileExists(envSource)) {
682
- error(`Could not open ${(0, import_chalk5.redBright)(envSource)}`);
787
+ error(`Could not open ${(0, import_chalk6.redBright)(envSource)}`);
683
788
  return;
684
789
  }
685
790
  const parsedEnv = (0, import_dotenv3.parse)(import_node_fs4.default.readFileSync(envSource, { encoding: "utf8" }));
@@ -690,6 +795,7 @@ var handler5 = async (argv) => {
690
795
  },
691
796
  verbose: argv.verbose
692
797
  });
798
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, argv.awsKeyAlias);
693
799
  if (argv.verbose) {
694
800
  info(`Encrypting using key alias ${bold(argv.awsKeyAlias)} in ${bold(await kmsClient.config.region())}`);
695
801
  const describeKeyCommand = new import_client_kms5.DescribeKeyCommand({
@@ -702,7 +808,7 @@ var handler5 = async (argv) => {
702
808
  const encryptCommand = new import_client_kms5.EncryptCommand({
703
809
  KeyId: argv.awsKeyAlias,
704
810
  Plaintext: Buffer.from(value),
705
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
811
+ EncryptionAlgorithm: encryptionAlgorithm
706
812
  });
707
813
  const encryptionResult = await kmsClient.send(encryptCommand);
708
814
  if (!encryptionResult.CiphertextBlob) {
@@ -735,8 +841,8 @@ __export(encryptSecretsJson_exports, {
735
841
  var import_node_fs5 = __toModule(require("node:fs"));
736
842
  var import_node_path5 = __toModule(require("node:path"));
737
843
  var import_client_kms6 = __toModule(require("@aws-sdk/client-kms"));
738
- var import_chalk6 = __toModule(require("chalk"));
739
- var import_flat2 = __toModule(require("flat"));
844
+ var import_chalk7 = __toModule(require("chalk"));
845
+ var import_flat3 = __toModule(require("flat"));
740
846
  var command6 = "encrypt-secrets-json";
741
847
  var desc6 = "Encrypts an unencrypted file";
742
848
  var builder6 = {
@@ -766,14 +872,14 @@ var handler6 = async (argv) => {
766
872
  });
767
873
  const secretsPath = import_node_path5.default.resolve(process.cwd(), argv.secretsFile);
768
874
  if (!await fileExists(secretsPath)) {
769
- error(`Could not open ${(0, import_chalk6.redBright)(secretsPath)}`);
875
+ error(`Could not open ${(0, import_chalk7.redBright)(secretsPath)}`);
770
876
  return;
771
877
  }
772
878
  const secrets = JSON.parse(import_node_fs5.default.readFileSync(secretsPath, { encoding: "utf8" }));
773
879
  if (!secrets.parameters) {
774
880
  throw new Error(`Expected 'parameters' property, but got none`);
775
881
  }
776
- const flatParameters = (0, import_flat2.default)(secrets.parameters, { delimiter: "/" });
882
+ const flatParameters = (0, import_flat3.default)(secrets.parameters, { delimiter: "/" });
777
883
  if (argv.verbose) {
778
884
  console.log(flatParameters);
779
885
  }
@@ -792,11 +898,12 @@ var handler6 = async (argv) => {
792
898
  const describeKeyResult = await kmsClient.send(describeKeyCommand);
793
899
  console.log("describeKeyResult", { describeKeyResult });
794
900
  }
901
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, argv.awsKeyAlias);
795
902
  const encryptedFlatParameters = Object.fromEntries(await Promise.all(Object.entries(flatParameters).map(async ([parameterName, parameter]) => {
796
903
  const encryptCommand = new import_client_kms6.EncryptCommand({
797
904
  KeyId: argv.awsKeyAlias,
798
905
  Plaintext: Buffer.from(parameter),
799
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
906
+ EncryptionAlgorithm: encryptionAlgorithm
800
907
  });
801
908
  const encryptionResult = await kmsClient.send(encryptCommand);
802
909
  if (!encryptionResult.CiphertextBlob) {
@@ -812,7 +919,7 @@ var handler6 = async (argv) => {
812
919
  const cipherText = Buffer.from(encryptionResult.CiphertextBlob).toString("base64");
813
920
  return [parameterName, cipherText];
814
921
  })));
815
- const encryptedParameters = import_flat2.default.unflatten(encryptedFlatParameters, { delimiter: "/" });
922
+ const encryptedParameters = import_flat3.default.unflatten(encryptedFlatParameters, { delimiter: "/" });
816
923
  const encryptedSecrets = {
817
924
  config: secrets.config,
818
925
  encryptedParameters
@@ -838,12 +945,12 @@ __export(offloadToSSMCommand_exports, {
838
945
  desc: () => desc7,
839
946
  handler: () => handler7
840
947
  });
841
- var import_client_kms7 = __toModule(require("@aws-sdk/client-kms"));
842
- var import_client_ssm3 = __toModule(require("@aws-sdk/client-ssm"));
843
- var import_chalk7 = __toModule(require("chalk"));
844
- var import_flat3 = __toModule(require("flat"));
845
948
  var import_node_fs6 = __toModule(require("node:fs"));
846
949
  var import_node_path6 = __toModule(require("node:path"));
950
+ var import_client_kms7 = __toModule(require("@aws-sdk/client-kms"));
951
+ var import_client_ssm3 = __toModule(require("@aws-sdk/client-ssm"));
952
+ var import_chalk8 = __toModule(require("chalk"));
953
+ var import_flat4 = __toModule(require("flat"));
847
954
  var command7 = "offload-secrets-json-to-ssm";
848
955
  var desc7 = "Sends decrypted values of secrets.encrypted.json file to SSM parameter store";
849
956
  var builder7 = {
@@ -868,14 +975,14 @@ var handler7 = async (argv) => {
868
975
  });
869
976
  const encryptedSecretsPath = import_node_path6.default.resolve(process.cwd(), argv.encryptedSecretsFile);
870
977
  if (!await fileExists(encryptedSecretsPath)) {
871
- error(`Could not open ${(0, import_chalk7.redBright)(encryptedSecretsPath)}`);
978
+ error(`Could not open ${(0, import_chalk8.redBright)(encryptedSecretsPath)}`);
872
979
  return;
873
980
  }
874
981
  const encryptedSecrets = JSON.parse(import_node_fs6.default.readFileSync(encryptedSecretsPath, { encoding: "utf8" }));
875
982
  if (!encryptedSecrets.encryptedParameters) {
876
983
  throw new Error(`Expected 'encryptedParameters' property, but got none`);
877
984
  }
878
- const flatEncryptedParameters = (0, import_flat3.default)(encryptedSecrets.encryptedParameters, { delimiter: "/" });
985
+ const flatEncryptedParameters = (0, import_flat4.default)(encryptedSecrets.encryptedParameters, { delimiter: "/" });
879
986
  const kmsClient = getKMSClient({
880
987
  configuration: {
881
988
  credentials: credentialsAndOrigin.value,
@@ -885,17 +992,13 @@ var handler7 = async (argv) => {
885
992
  });
886
993
  if (argv.verbose) {
887
994
  info(`Encrypting using key alias ${bold(argv.awsKeyAlias)} in ${bold(await kmsClient.config.region())}`);
888
- const describeKeyCommand = new import_client_kms7.DescribeKeyCommand({
889
- KeyId: argv.awsKeyAlias
890
- });
891
- const describeKeyResult = await kmsClient.send(describeKeyCommand);
892
- console.log("describeKeyResult", { describeKeyResult });
893
995
  }
996
+ const encryptionAlgorithm = await getEncryptionAlgorithm(kmsClient, argv.awsKeyAlias);
894
997
  const flatParameters = Object.fromEntries(await Promise.all(Object.entries(flatEncryptedParameters).map(async ([parameterName, encryptedParameter]) => {
895
998
  const decryptCommand = new import_client_kms7.DecryptCommand({
896
999
  KeyId: argv.awsKeyAlias,
897
1000
  CiphertextBlob: Buffer.from(encryptedParameter, "base64"),
898
- EncryptionAlgorithm: "RSAES_OAEP_SHA_256"
1001
+ EncryptionAlgorithm: encryptionAlgorithm
899
1002
  });
900
1003
  const decryptionResult = await kmsClient.send(decryptCommand);
901
1004
  if (!decryptionResult.Plaintext) {