@mtndev/cli 1.1.0 → 2.0.1
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/CHANGELOG.md +91 -0
- package/cjs/__chunks/VH7oDXx4.cjs +28 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -0
- package/cjs/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/cjs/commands/aws/iam/admin-group.cjs +111 -0
- package/cjs/commands/aws/iam/admin-group.d.ts +55 -0
- package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -0
- package/cjs/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/cjs/commands/aws/iam/break-glass/index.cjs +7 -0
- package/cjs/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -0
- package/cjs/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -0
- package/cjs/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/check-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -0
- package/cjs/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -0
- package/cjs/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -0
- package/cjs/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -0
- package/cjs/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -0
- package/cjs/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -0
- package/cjs/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -0
- package/cjs/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/cjs/commands/aws/iam/users/handler.cjs +59 -0
- package/cjs/commands/aws/iam/users/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/users/index.cjs +18 -0
- package/cjs/commands/aws/iam/users/index.d.ts +3 -0
- package/cjs/commands/aws/iam/users/schema.cjs +17 -0
- package/cjs/commands/aws/iam/users/schema.d.ts +18 -0
- package/cjs/commands/aws/iam/users/utils.cjs +454 -0
- package/cjs/commands/aws/iam/users/utils.d.ts +119 -0
- package/cjs/commands/aws/index.cjs +223 -0
- package/cjs/commands/aws/index.d.ts +14 -0
- package/cjs/commands/aws/route53/add-record/handler.cjs +264 -0
- package/cjs/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/cjs/commands/aws/route53/add-record/index.cjs +26 -0
- package/cjs/commands/aws/route53/add-record/index.d.ts +3 -0
- package/cjs/commands/aws/route53/add-record/schema.cjs +43 -0
- package/cjs/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/cjs/commands/aws/route53/add-record/utils.cjs +404 -0
- package/cjs/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -0
- package/cjs/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/cjs/commands/aws/route53/remove-record/index.cjs +5 -0
- package/cjs/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -0
- package/cjs/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/cjs/commands/aws/schema.cjs +19 -0
- package/cjs/commands/aws/schema.d.ts +13 -0
- package/cjs/commands/aws/ses/send-email/handler.cjs +73 -0
- package/cjs/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/cjs/commands/aws/ses/send-email/index.cjs +9 -0
- package/cjs/commands/aws/ses/send-email/index.d.ts +3 -0
- package/cjs/commands/aws/ses/send-email/schema.cjs +24 -0
- package/cjs/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/cjs/commands/aws/ses/send-email/utils.cjs +87 -0
- package/cjs/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/cjs/commands/aws/ses/smtp-password.cjs +72 -0
- package/cjs/commands/aws/ses/smtp-password.d.ts +21 -0
- package/cjs/commands/aws/utils/exec-aws.cjs +145 -0
- package/cjs/commands/aws/utils/exec-aws.d.ts +79 -0
- package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -0
- package/cjs/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/cjs/commands/aws/utils/resolve-profile.cjs +93 -0
- package/cjs/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/cjs/commands/aws/utils/tty.cjs +54 -0
- package/cjs/commands/aws/utils/tty.d.ts +24 -0
- package/cjs/commands/db/create-readonly-user/handler.cjs +254 -0
- package/cjs/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/cjs/commands/db/create-readonly-user/index.cjs +18 -0
- package/cjs/commands/db/create-readonly-user/index.d.ts +3 -0
- package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -0
- package/cjs/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -0
- package/cjs/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/cjs/commands/db/create-readonly-user/schema.cjs +39 -0
- package/cjs/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/cjs/commands/db/create-readonly-user/utils.cjs +160 -0
- package/cjs/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/cjs/commands/db/index.cjs +46 -0
- package/cjs/commands/db/index.d.ts +6 -0
- package/cjs/commands/doppler/handler.cjs +95 -9
- package/cjs/commands/doppler/index.cjs +33 -41
- package/cjs/commands/doppler/index.d.ts +1 -0
- package/cjs/commands/doppler/schema.cjs +130 -6
- package/cjs/commands/doppler/schema.d.ts +233 -17
- package/cjs/commands/doppler/set-secret.cjs +378 -0
- package/cjs/commands/doppler/set-secret.d.ts +113 -0
- package/cjs/commands/doppler/utils/exec.cjs +106 -12
- package/cjs/commands/doppler/utils.cjs +412 -30
- package/cjs/commands/doppler/utils.d.ts +32 -8
- package/cjs/commands/icons/handler.cjs +82 -8
- package/cjs/commands/icons/index.cjs +15 -31
- package/cjs/commands/icons/schema.cjs +101 -13
- package/cjs/commands/icons/schema.d.ts +1 -1
- package/cjs/commands/icons/utils.cjs +131 -13
- package/cjs/commands/index.cjs +54 -82
- package/cjs/commands/schema.cjs +25 -8
- package/cjs/index.cjs +3 -4
- package/esm/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/esm/commands/aws/ec2/allow-ip/handler.js +258 -0
- package/esm/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/esm/commands/aws/ec2/allow-ip/index.js +4 -0
- package/esm/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/esm/commands/aws/ec2/allow-ip/schema.js +29 -0
- package/esm/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/esm/commands/aws/ec2/allow-ip/utils.js +363 -0
- package/esm/commands/aws/iam/admin-group.d.ts +55 -0
- package/esm/commands/aws/iam/admin-group.js +104 -0
- package/esm/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/esm/commands/aws/iam/break-glass/handler.js +124 -0
- package/esm/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/esm/commands/aws/iam/break-glass/index.js +4 -0
- package/esm/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/esm/commands/aws/iam/break-glass/schema.js +19 -0
- package/esm/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/esm/commands/aws/iam/check-admin/handler.js +86 -0
- package/esm/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/check-admin/index.js +4 -0
- package/esm/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/esm/commands/aws/iam/check-admin/schema.js +17 -0
- package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/esm/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/esm/commands/aws/iam/remove-admin/handler.js +117 -0
- package/esm/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/remove-admin/index.js +4 -0
- package/esm/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/esm/commands/aws/iam/remove-admin/schema.js +20 -0
- package/esm/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/esm/commands/aws/iam/setup-acl/handler.js +224 -0
- package/esm/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/esm/commands/aws/iam/setup-acl/index.js +4 -0
- package/esm/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/esm/commands/aws/iam/setup-acl/schema.js +18 -0
- package/esm/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/esm/commands/aws/iam/setup-acl/utils.js +298 -0
- package/esm/commands/aws/iam/users/handler.d.ts +5 -0
- package/esm/commands/aws/iam/users/handler.js +56 -0
- package/esm/commands/aws/iam/users/index.d.ts +3 -0
- package/esm/commands/aws/iam/users/index.js +4 -0
- package/esm/commands/aws/iam/users/schema.d.ts +18 -0
- package/esm/commands/aws/iam/users/schema.js +16 -0
- package/esm/commands/aws/iam/users/utils.d.ts +119 -0
- package/esm/commands/aws/iam/users/utils.js +440 -0
- package/esm/commands/aws/index.d.ts +14 -0
- package/esm/commands/aws/index.js +142 -0
- package/esm/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/esm/commands/aws/route53/add-record/handler.js +258 -0
- package/esm/commands/aws/route53/add-record/index.d.ts +3 -0
- package/esm/commands/aws/route53/add-record/index.js +4 -0
- package/esm/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/esm/commands/aws/route53/add-record/schema.js +40 -0
- package/esm/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/esm/commands/aws/route53/add-record/utils.js +389 -0
- package/esm/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/esm/commands/aws/route53/remove-record/handler.js +111 -0
- package/esm/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/esm/commands/aws/route53/remove-record/index.js +3 -0
- package/esm/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/esm/commands/aws/route53/remove-record/schema.js +21 -0
- package/esm/commands/aws/schema.d.ts +13 -0
- package/esm/commands/aws/schema.js +16 -0
- package/esm/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/esm/commands/aws/ses/send-email/handler.js +70 -0
- package/esm/commands/aws/ses/send-email/index.d.ts +3 -0
- package/esm/commands/aws/ses/send-email/index.js +4 -0
- package/esm/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/esm/commands/aws/ses/send-email/schema.js +23 -0
- package/esm/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/esm/commands/aws/ses/send-email/utils.js +84 -0
- package/esm/commands/aws/ses/smtp-password.d.ts +21 -0
- package/esm/commands/aws/ses/smtp-password.js +69 -0
- package/esm/commands/aws/utils/exec-aws.d.ts +79 -0
- package/esm/commands/aws/utils/exec-aws.js +137 -0
- package/esm/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/esm/commands/aws/utils/resolve-policy-path.js +14 -0
- package/esm/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/esm/commands/aws/utils/resolve-profile.js +88 -0
- package/esm/commands/aws/utils/tty.d.ts +24 -0
- package/esm/commands/aws/utils/tty.js +51 -0
- package/esm/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/esm/commands/db/create-readonly-user/handler.js +251 -0
- package/esm/commands/db/create-readonly-user/index.d.ts +3 -0
- package/esm/commands/db/create-readonly-user/index.js +4 -0
- package/esm/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/esm/commands/db/create-readonly-user/mysql.js +98 -0
- package/esm/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/esm/commands/db/create-readonly-user/postgres.js +205 -0
- package/esm/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/esm/commands/db/create-readonly-user/schema.js +35 -0
- package/esm/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/esm/commands/db/create-readonly-user/utils.js +151 -0
- package/esm/commands/db/index.d.ts +6 -0
- package/esm/commands/db/index.js +31 -0
- package/esm/commands/doppler/handler.js +92 -9
- package/esm/commands/doppler/index.d.ts +1 -0
- package/esm/commands/doppler/index.js +6 -41
- package/esm/commands/doppler/schema.d.ts +233 -17
- package/esm/commands/doppler/schema.js +125 -7
- package/esm/commands/doppler/set-secret.d.ts +113 -0
- package/esm/commands/doppler/set-secret.js +370 -0
- package/esm/commands/doppler/utils/exec.js +100 -12
- package/esm/commands/doppler/utils.d.ts +32 -8
- package/esm/commands/doppler/utils.js +396 -30
- package/esm/commands/icons/handler.js +79 -8
- package/esm/commands/icons/index.js +4 -31
- package/esm/commands/icons/schema.d.ts +1 -1
- package/esm/commands/icons/schema.js +97 -15
- package/esm/commands/icons/utils.js +125 -13
- package/esm/commands/index.js +49 -78
- package/esm/commands/schema.js +22 -7
- package/esm/index.js +3 -4
- package/package.json +12 -2
- package/vitest.config.ts +11 -0
- package/cjs/__chunks/4GFJUCSP.cjs +0 -52
- package/cjs/__chunks/4SFWHCB3.cjs +0 -133
- package/cjs/__chunks/B2KFW7T7.cjs +0 -1
- package/cjs/__chunks/EMMC33QA.cjs +0 -401
- package/cjs/__chunks/INFOPAHN.cjs +0 -117
- package/cjs/__chunks/J36P6UNE.cjs +0 -75
- package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
- package/cjs/__chunks/NSRFG4DF.cjs +0 -100
- package/cjs/__chunks/WNJ3ZYLI.cjs +0 -1
- package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
- package/esm/__chunks/46HGXFME.js +0 -0
- package/esm/__chunks/6G4PXXKF.js +0 -75
- package/esm/__chunks/6L5RNR7G.js +0 -100
- package/esm/__chunks/FL7AILGH.js +0 -133
- package/esm/__chunks/HJSXC6HP.js +0 -117
- package/esm/__chunks/O262GK4B.js +0 -401
- package/esm/__chunks/O3CCA76Q.js +0 -22
- package/esm/__chunks/SJXQJ7RS.js +0 -92
- package/esm/__chunks/SNCKIAOR.js +0 -0
- package/esm/__chunks/X3R5PSWH.js +0 -52
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../../../../__chunks/VH7oDXx4.cjs");
|
|
3
|
+
const require_commands_aws_utils_tty = require("../../utils/tty.cjs");
|
|
4
|
+
const require_commands_aws_utils_exec_aws = require("../../utils/exec-aws.cjs");
|
|
5
|
+
const require_commands_aws_utils_resolve_profile = require("../../utils/resolve-profile.cjs");
|
|
6
|
+
const require_commands_aws_route53_add_record_utils = require("../add-record/utils.cjs");
|
|
7
|
+
const require_commands_aws_route53_add_record_handler = require("../add-record/handler.cjs");
|
|
8
|
+
const require_commands_aws_route53_remove_record_schema = require("./schema.cjs");
|
|
9
|
+
let chalk = require("chalk");
|
|
10
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
11
|
+
let zod = require("zod");
|
|
12
|
+
//#region src/commands/aws/route53/remove-record/handler.js
|
|
13
|
+
/**
|
|
14
|
+
* `aws route53 remove-record` handler: interactively (or via flags) delete a
|
|
15
|
+
* Route53 resource record set, showing the record before it is removed.
|
|
16
|
+
* @param {unknown} options
|
|
17
|
+
*/
|
|
18
|
+
async function removeRecordCommand(options) {
|
|
19
|
+
try {
|
|
20
|
+
const { profile: profileOption, zone: zoneOption, type: typeOption, name: nameOption, yes, dryRun, verbose } = require_commands_aws_route53_remove_record_schema.removeRecordOptionsSchema.parse(options);
|
|
21
|
+
const profile = await require_commands_aws_utils_resolve_profile.resolveProfile({ profile: profileOption });
|
|
22
|
+
if (!profile) {
|
|
23
|
+
console.error(chalk.default.red("Error: pass --profile or set AWS_PROFILE."));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
require_commands_aws_utils_exec_aws.requireCommands(["aws"]);
|
|
27
|
+
const identity = require_commands_aws_utils_exec_aws.getCallerIdentity({
|
|
28
|
+
profile,
|
|
29
|
+
verbose
|
|
30
|
+
});
|
|
31
|
+
console.log("Caller:");
|
|
32
|
+
console.log(` Account: ${identity.Account}`);
|
|
33
|
+
console.log(` Arn: ${identity.Arn}`);
|
|
34
|
+
console.log("");
|
|
35
|
+
const zone = await require_commands_aws_route53_add_record_handler.resolveHostedZone({
|
|
36
|
+
profile,
|
|
37
|
+
zoneOption,
|
|
38
|
+
verbose
|
|
39
|
+
});
|
|
40
|
+
console.log(`Hosted zone: ${require_commands_aws_route53_add_record_utils.hostedZoneLabel(zone)}`);
|
|
41
|
+
console.log("");
|
|
42
|
+
const type = await require_commands_aws_route53_add_record_handler.resolveRecordType(typeOption);
|
|
43
|
+
const name = await require_commands_aws_route53_add_record_handler.resolveName({
|
|
44
|
+
nameOption,
|
|
45
|
+
zoneName: zone.name
|
|
46
|
+
});
|
|
47
|
+
const existing = require_commands_aws_route53_add_record_utils.getResourceRecordSet({
|
|
48
|
+
profile,
|
|
49
|
+
hostedZoneId: zone.id,
|
|
50
|
+
name,
|
|
51
|
+
type,
|
|
52
|
+
verbose
|
|
53
|
+
});
|
|
54
|
+
if (!existing) {
|
|
55
|
+
console.log(chalk.default.yellow(`No ${type} record at ${require_commands_aws_route53_add_record_utils.withoutTrailingDot(name)}. Nothing to remove.`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
console.log("Record to remove:");
|
|
59
|
+
console.log(` Name: ${require_commands_aws_route53_add_record_utils.withoutTrailingDot(name)}`);
|
|
60
|
+
console.log(` Type: ${type}`);
|
|
61
|
+
if (existing.isAlias) console.log(` Alias: ${require_commands_aws_route53_add_record_utils.withoutTrailingDot(String(existing.aliasTarget?.DNSName ?? ""))}`);
|
|
62
|
+
else {
|
|
63
|
+
if (existing.ttl !== void 0) console.log(` TTL: ${existing.ttl}`);
|
|
64
|
+
console.log(` Value:${require_commands_aws_route53_add_record_utils.formatValues(existing.values)}`);
|
|
65
|
+
}
|
|
66
|
+
console.log("");
|
|
67
|
+
if (dryRun) {
|
|
68
|
+
console.log(chalk.default.cyan("Dry run — no changes made."));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!yes) {
|
|
72
|
+
if (!await require_commands_aws_utils_tty.promptYesNo({
|
|
73
|
+
message: `Delete this ${type} record?`,
|
|
74
|
+
defaultYes: false
|
|
75
|
+
})) {
|
|
76
|
+
console.log("Aborted.");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const changeInfo = require_commands_aws_route53_add_record_utils.deleteResourceRecordSet({
|
|
81
|
+
profile,
|
|
82
|
+
hostedZoneId: zone.id,
|
|
83
|
+
record: existing,
|
|
84
|
+
verbose
|
|
85
|
+
});
|
|
86
|
+
console.log("");
|
|
87
|
+
console.log(chalk.default.green(`Done. Deleted ${type} ${require_commands_aws_route53_add_record_utils.withoutTrailingDot(name)}.`));
|
|
88
|
+
if (changeInfo?.Id) {
|
|
89
|
+
console.log(` Change ID: ${changeInfo.Id}`);
|
|
90
|
+
console.log(` Status: ${changeInfo.Status ?? "PENDING"}`);
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (error instanceof zod.ZodError) {
|
|
94
|
+
console.error(chalk.default.red("\n❌ Invalid command options:"));
|
|
95
|
+
error.errors.forEach((err) => {
|
|
96
|
+
console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
|
|
97
|
+
});
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
const verbose = options?.verbose || false;
|
|
101
|
+
console.error(chalk.default.red("\n❌ remove-record failed:"));
|
|
102
|
+
if (error instanceof require_commands_aws_utils_exec_aws.AwsCliError || error instanceof Error) {
|
|
103
|
+
console.error(chalk.default.red(` ${error.message}`));
|
|
104
|
+
if (verbose && error.stack) {
|
|
105
|
+
console.error(chalk.default.gray("\nStack trace:"));
|
|
106
|
+
console.error(chalk.default.gray(error.stack));
|
|
107
|
+
}
|
|
108
|
+
} else console.error(chalk.default.red(` ${String(error)}`));
|
|
109
|
+
console.error(chalk.default.yellow("\n💡 Use --verbose for detailed error information\n"));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
exports.removeRecordCommand = removeRecordCommand;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_route53_remove_record_schema = require("./schema.cjs");
|
|
3
|
+
const require_commands_aws_route53_remove_record_handler = require("./handler.cjs");
|
|
4
|
+
exports.removeRecordCommand = require_commands_aws_route53_remove_record_handler.removeRecordCommand;
|
|
5
|
+
exports.removeRecordOptionsSchema = require_commands_aws_route53_remove_record_schema.removeRecordOptionsSchema;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_schema = require("../../schema.cjs");
|
|
3
|
+
const require_commands_aws_route53_add_record_schema = require("../add-record/schema.cjs");
|
|
4
|
+
let zod = require("zod");
|
|
5
|
+
//#region src/commands/aws/route53/remove-record/schema.js
|
|
6
|
+
/**
|
|
7
|
+
* Zod schema for `aws route53 remove-record` options.
|
|
8
|
+
*/
|
|
9
|
+
const removeRecordOptionsSchema = zod.z.object({
|
|
10
|
+
profile: require_commands_aws_schema.profileField,
|
|
11
|
+
zone: zod.z.string().optional().describe("Hosted zone name or ID (e.g. mountaindev.com or Z123…). Skips the zone picker when set."),
|
|
12
|
+
type: zod.z.string().optional().transform((value) => value === void 0 ? void 0 : value.toUpperCase()).refine((value) => value === void 0 || typeof value === "string" && require_commands_aws_route53_add_record_schema.RECORD_TYPES.includes(value), { message: `Record type must be one of: ${require_commands_aws_route53_add_record_schema.RECORD_TYPES.join(", ")}` }).describe(`DNS record type (${require_commands_aws_route53_add_record_schema.RECORD_TYPES.join(", ")})`),
|
|
13
|
+
name: zod.z.string().optional().describe("Record name relative to the zone (e.g. \"redline\") or a fully-qualified name"),
|
|
14
|
+
yes: zod.z.boolean().optional().default(false).describe("Skip the confirmation prompt"),
|
|
15
|
+
dryRun: zod.z.boolean().optional().default(false).describe("Preview the deletion without calling Route53"),
|
|
16
|
+
verbose: require_commands_aws_schema.verboseField
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {z.infer<typeof removeRecordOptionsSchema>} RemoveRecordOptions
|
|
20
|
+
*/
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.removeRecordOptionsSchema = removeRecordOptionsSchema;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for `aws route53 remove-record` options.
|
|
3
|
+
*/
|
|
4
|
+
export const removeRecordOptionsSchema: z.ZodObject<{
|
|
5
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
6
|
+
zone: z.ZodOptional<z.ZodString>;
|
|
7
|
+
type: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>, string | undefined, string | undefined>;
|
|
8
|
+
name: z.ZodOptional<z.ZodString>;
|
|
9
|
+
yes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
+
dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
11
|
+
verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
verbose: boolean;
|
|
14
|
+
yes: boolean;
|
|
15
|
+
dryRun: boolean;
|
|
16
|
+
profile?: string | undefined;
|
|
17
|
+
type?: string | undefined;
|
|
18
|
+
name?: string | undefined;
|
|
19
|
+
zone?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
profile?: string | undefined;
|
|
22
|
+
verbose?: boolean | undefined;
|
|
23
|
+
yes?: boolean | undefined;
|
|
24
|
+
type?: string | undefined;
|
|
25
|
+
dryRun?: boolean | undefined;
|
|
26
|
+
name?: string | undefined;
|
|
27
|
+
zone?: string | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type RemoveRecordOptions = z.infer<typeof removeRecordOptionsSchema>;
|
|
30
|
+
import { z } from "zod";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/commands/aws/schema.js
|
|
4
|
+
/**
|
|
5
|
+
* Shared Zod field for the AWS profile option.
|
|
6
|
+
*/
|
|
7
|
+
const profileField = zod.z.string().optional().describe("AWS profile (defaults to the AWS_PROFILE environment variable)");
|
|
8
|
+
/**
|
|
9
|
+
* Shared Zod field for the AWS region option.
|
|
10
|
+
*/
|
|
11
|
+
const regionField = zod.z.string().optional().describe("AWS region");
|
|
12
|
+
/**
|
|
13
|
+
* Shared Zod field for verbose logging.
|
|
14
|
+
*/
|
|
15
|
+
const verboseField = zod.z.boolean().optional().default(false).describe("Enable verbose logging for detailed output and error traces");
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.profileField = profileField;
|
|
18
|
+
exports.regionField = regionField;
|
|
19
|
+
exports.verboseField = verboseField;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Zod field for the AWS profile option.
|
|
3
|
+
*/
|
|
4
|
+
export const profileField: z.ZodOptional<z.ZodString>;
|
|
5
|
+
/**
|
|
6
|
+
* Shared Zod field for the AWS region option.
|
|
7
|
+
*/
|
|
8
|
+
export const regionField: z.ZodOptional<z.ZodString>;
|
|
9
|
+
/**
|
|
10
|
+
* Shared Zod field for verbose logging.
|
|
11
|
+
*/
|
|
12
|
+
export const verboseField: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
13
|
+
import { z } from "zod";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../../../../__chunks/VH7oDXx4.cjs");
|
|
3
|
+
const require_commands_aws_utils_resolve_profile = require("../../utils/resolve-profile.cjs");
|
|
4
|
+
const require_commands_aws_ses_send_email_schema = require("./schema.cjs");
|
|
5
|
+
const require_commands_aws_ses_send_email_utils = require("./utils.cjs");
|
|
6
|
+
let chalk = require("chalk");
|
|
7
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
8
|
+
let zod = require("zod");
|
|
9
|
+
//#region src/commands/aws/ses/send-email/handler.js
|
|
10
|
+
/**
|
|
11
|
+
* `aws ses send-email` handler: send a single test email via the SES API or SMTP.
|
|
12
|
+
* @param {unknown} options
|
|
13
|
+
*/
|
|
14
|
+
async function sendEmailCommand(options) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = require_commands_aws_ses_send_email_schema.sendEmailOptionsSchema.parse(options);
|
|
17
|
+
const { to, from, subject, transport, region, profile: profileOption, accessKeyId, dryRun, verbose } = parsed;
|
|
18
|
+
const body = parsed.body ?? require_commands_aws_ses_send_email_utils.defaultBody();
|
|
19
|
+
const profile = transport === "api" ? await require_commands_aws_utils_resolve_profile.resolveProfile({ profile: profileOption }) : profileOption;
|
|
20
|
+
console.log(chalk.default.blue("\n📧 SES send-email"));
|
|
21
|
+
console.log(chalk.default.gray(` transport: ${transport}`));
|
|
22
|
+
console.log(chalk.default.gray(` region: ${region}`));
|
|
23
|
+
console.log(chalk.default.gray(` from: ${from}`));
|
|
24
|
+
console.log(chalk.default.gray(` to: ${to}`));
|
|
25
|
+
console.log(chalk.default.gray(` subject: ${subject}`));
|
|
26
|
+
if (verbose) console.log(chalk.default.gray(` body: ${body}`));
|
|
27
|
+
if (dryRun) {
|
|
28
|
+
console.log(chalk.default.yellow("\n[dry-run] No email sent."));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const messageId = transport === "api" ? await require_commands_aws_ses_send_email_utils.sendViaApi({
|
|
32
|
+
to,
|
|
33
|
+
from,
|
|
34
|
+
subject,
|
|
35
|
+
body,
|
|
36
|
+
region,
|
|
37
|
+
profile
|
|
38
|
+
}) : await require_commands_aws_ses_send_email_utils.sendViaSmtp({
|
|
39
|
+
to,
|
|
40
|
+
from,
|
|
41
|
+
subject,
|
|
42
|
+
body,
|
|
43
|
+
region,
|
|
44
|
+
accessKeyId
|
|
45
|
+
});
|
|
46
|
+
console.log(chalk.default.green(`\n✅ Email sent${messageId ? ` (messageId: ${messageId})` : ""}.`));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof zod.ZodError) {
|
|
49
|
+
console.error(chalk.default.red("\n❌ Invalid command options:"));
|
|
50
|
+
error.errors.forEach((err) => {
|
|
51
|
+
console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
|
|
52
|
+
});
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const verbose = options?.verbose || false;
|
|
56
|
+
console.error(chalk.default.red("\n❌ send-email failed:"));
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
console.error(chalk.default.red(` ${error.message}`));
|
|
59
|
+
if (verbose && error.stack) {
|
|
60
|
+
console.error(chalk.default.gray("\nStack trace:"));
|
|
61
|
+
console.error(chalk.default.gray(error.stack));
|
|
62
|
+
}
|
|
63
|
+
} else console.error(chalk.default.red(` ${String(error)}`));
|
|
64
|
+
console.error(chalk.default.yellow("\n💡 Troubleshooting tips:"));
|
|
65
|
+
console.error(chalk.default.yellow(" • The sender address must be verified in SES"));
|
|
66
|
+
console.error(chalk.default.yellow(" • New SES accounts are sandboxed — recipients must also be verified"));
|
|
67
|
+
console.error(chalk.default.yellow(" • For smtp transport, set SES_SMTP_USER and SES_SMTP_PASSWORD"));
|
|
68
|
+
console.error(chalk.default.yellow(" • Use --verbose for detailed error information\n"));
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.sendEmailCommand = sendEmailCommand;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_ses_send_email_schema = require("./schema.cjs");
|
|
3
|
+
const require_commands_aws_ses_send_email_utils = require("./utils.cjs");
|
|
4
|
+
const require_commands_aws_ses_send_email_handler = require("./handler.cjs");
|
|
5
|
+
exports.defaultBody = require_commands_aws_ses_send_email_utils.defaultBody;
|
|
6
|
+
exports.sendEmailCommand = require_commands_aws_ses_send_email_handler.sendEmailCommand;
|
|
7
|
+
exports.sendEmailOptionsSchema = require_commands_aws_ses_send_email_schema.sendEmailOptionsSchema;
|
|
8
|
+
exports.sendViaApi = require_commands_aws_ses_send_email_utils.sendViaApi;
|
|
9
|
+
exports.sendViaSmtp = require_commands_aws_ses_send_email_utils.sendViaSmtp;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_schema = require("../../schema.cjs");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region src/commands/aws/ses/send-email/schema.js
|
|
5
|
+
/**
|
|
6
|
+
* Zod schema for `aws ses send-email` options.
|
|
7
|
+
*/
|
|
8
|
+
const sendEmailOptionsSchema = zod.z.object({
|
|
9
|
+
to: zod.z.string({ required_error: "--to <address> is required" }).describe("Recipient email address"),
|
|
10
|
+
from: zod.z.string({ required_error: "--from <address> is required" }).describe("Verified SES sender email address"),
|
|
11
|
+
subject: zod.z.string().optional().default("MTN CLI test email").describe("Email subject line"),
|
|
12
|
+
body: zod.z.string().optional().describe("Email body (defaults to a timestamp and random token)"),
|
|
13
|
+
transport: zod.z.enum(["api", "smtp"]).optional().default("api").describe("Send via the SES API (default) or SES SMTP"),
|
|
14
|
+
region: zod.z.string().optional().default("us-east-1").describe("AWS region for the SES endpoint"),
|
|
15
|
+
profile: require_commands_aws_schema.profileField,
|
|
16
|
+
accessKeyId: zod.z.string().optional().describe("IAM access key ID used as the SMTP username (smtp transport only)"),
|
|
17
|
+
dryRun: zod.z.boolean().optional().default(false).describe("Print the email payload without sending"),
|
|
18
|
+
verbose: require_commands_aws_schema.verboseField
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {z.infer<typeof sendEmailOptionsSchema>} SendEmailOptions
|
|
22
|
+
*/
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.sendEmailOptionsSchema = sendEmailOptionsSchema;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for `aws ses send-email` options.
|
|
3
|
+
*/
|
|
4
|
+
export const sendEmailOptionsSchema: z.ZodObject<{
|
|
5
|
+
to: z.ZodString;
|
|
6
|
+
from: z.ZodString;
|
|
7
|
+
subject: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
body: z.ZodOptional<z.ZodString>;
|
|
9
|
+
transport: z.ZodDefault<z.ZodOptional<z.ZodEnum<["api", "smtp"]>>>;
|
|
10
|
+
region: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
12
|
+
accessKeyId: z.ZodOptional<z.ZodString>;
|
|
13
|
+
dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
14
|
+
verbose: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
region: string;
|
|
17
|
+
verbose: boolean;
|
|
18
|
+
dryRun: boolean;
|
|
19
|
+
to: string;
|
|
20
|
+
from: string;
|
|
21
|
+
subject: string;
|
|
22
|
+
transport: "api" | "smtp";
|
|
23
|
+
profile?: string | undefined;
|
|
24
|
+
accessKeyId?: string | undefined;
|
|
25
|
+
body?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
to: string;
|
|
28
|
+
from: string;
|
|
29
|
+
profile?: string | undefined;
|
|
30
|
+
region?: string | undefined;
|
|
31
|
+
verbose?: boolean | undefined;
|
|
32
|
+
dryRun?: boolean | undefined;
|
|
33
|
+
accessKeyId?: string | undefined;
|
|
34
|
+
subject?: string | undefined;
|
|
35
|
+
body?: string | undefined;
|
|
36
|
+
transport?: "api" | "smtp" | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export type SendEmailOptions = z.infer<typeof sendEmailOptionsSchema>;
|
|
39
|
+
import { z } from "zod";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_aws_ses_smtp_password = require("../smtp-password.cjs");
|
|
3
|
+
let crypto = require("crypto");
|
|
4
|
+
//#region src/commands/aws/ses/send-email/utils.js
|
|
5
|
+
/**
|
|
6
|
+
* Build a default test-email body with a timestamp and random token.
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
function defaultBody() {
|
|
10
|
+
return `MTN CLI test email — random token: ${(0, crypto.randomBytes)(16).toString("hex")} — sent at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Send an email through the SES API using the AWS SDK.
|
|
14
|
+
* @param {{
|
|
15
|
+
* to: string;
|
|
16
|
+
* from: string;
|
|
17
|
+
* subject: string;
|
|
18
|
+
* body: string;
|
|
19
|
+
* region: string;
|
|
20
|
+
* profile?: string;
|
|
21
|
+
* }} params
|
|
22
|
+
* @returns {Promise<string | undefined>} The SES message id
|
|
23
|
+
*/
|
|
24
|
+
async function sendViaApi(params) {
|
|
25
|
+
const { to, from, subject, body, region, profile } = params;
|
|
26
|
+
const { SESClient, SendEmailCommand } = await import("@aws-sdk/client-ses");
|
|
27
|
+
const { fromNodeProviderChain } = await import("@aws-sdk/credential-providers");
|
|
28
|
+
const client = new SESClient({
|
|
29
|
+
region,
|
|
30
|
+
credentials: fromNodeProviderChain(profile ? { profile } : {})
|
|
31
|
+
});
|
|
32
|
+
const command = new SendEmailCommand({
|
|
33
|
+
Source: from,
|
|
34
|
+
Destination: { ToAddresses: [to] },
|
|
35
|
+
Message: {
|
|
36
|
+
Subject: { Data: subject },
|
|
37
|
+
Body: { Text: { Data: body } }
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return (await client.send(command)).MessageId;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Send an email through the SES SMTP endpoint using nodemailer.
|
|
44
|
+
* Credentials come from SES_SMTP_USER/SES_SMTP_PASSWORD, or the password is
|
|
45
|
+
* derived from AWS_SECRET_ACCESS_KEY when only that is available.
|
|
46
|
+
* @param {{
|
|
47
|
+
* to: string;
|
|
48
|
+
* from: string;
|
|
49
|
+
* subject: string;
|
|
50
|
+
* body: string;
|
|
51
|
+
* region: string;
|
|
52
|
+
* accessKeyId?: string;
|
|
53
|
+
* }} params
|
|
54
|
+
* @returns {Promise<string | undefined>} The SMTP message id
|
|
55
|
+
*/
|
|
56
|
+
async function sendViaSmtp(params) {
|
|
57
|
+
const { to, from, subject, body, region, accessKeyId } = params;
|
|
58
|
+
const user = process.env.SES_SMTP_USER ?? accessKeyId;
|
|
59
|
+
let pass = process.env.SES_SMTP_PASSWORD;
|
|
60
|
+
if (!pass) {
|
|
61
|
+
const secret = process.env.AWS_SECRET_ACCESS_KEY;
|
|
62
|
+
if (secret) pass = require_commands_aws_ses_smtp_password.calculateSmtpPassword({
|
|
63
|
+
secretAccessKey: secret,
|
|
64
|
+
region
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!user || !pass) throw new Error("SMTP transport requires SES_SMTP_USER and SES_SMTP_PASSWORD, or AWS_SECRET_ACCESS_KEY (plus --access-key-id) to derive the SMTP password.");
|
|
68
|
+
const nodemailerModule = await import("nodemailer");
|
|
69
|
+
return (await (nodemailerModule.default ?? nodemailerModule).createTransport({
|
|
70
|
+
host: require_commands_aws_ses_smtp_password.smtpEndpoint(region),
|
|
71
|
+
port: 587,
|
|
72
|
+
secure: false,
|
|
73
|
+
auth: {
|
|
74
|
+
user,
|
|
75
|
+
pass
|
|
76
|
+
}
|
|
77
|
+
}).sendMail({
|
|
78
|
+
from,
|
|
79
|
+
to,
|
|
80
|
+
subject,
|
|
81
|
+
text: body
|
|
82
|
+
})).messageId;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.defaultBody = defaultBody;
|
|
86
|
+
exports.sendViaApi = sendViaApi;
|
|
87
|
+
exports.sendViaSmtp = sendViaSmtp;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a default test-email body with a timestamp and random token.
|
|
3
|
+
* @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export function defaultBody(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Send an email through the SES API using the AWS SDK.
|
|
8
|
+
* @param {{
|
|
9
|
+
* to: string;
|
|
10
|
+
* from: string;
|
|
11
|
+
* subject: string;
|
|
12
|
+
* body: string;
|
|
13
|
+
* region: string;
|
|
14
|
+
* profile?: string;
|
|
15
|
+
* }} params
|
|
16
|
+
* @returns {Promise<string | undefined>} The SES message id
|
|
17
|
+
*/
|
|
18
|
+
export function sendViaApi(params: {
|
|
19
|
+
to: string;
|
|
20
|
+
from: string;
|
|
21
|
+
subject: string;
|
|
22
|
+
body: string;
|
|
23
|
+
region: string;
|
|
24
|
+
profile?: string;
|
|
25
|
+
}): Promise<string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Send an email through the SES SMTP endpoint using nodemailer.
|
|
28
|
+
* Credentials come from SES_SMTP_USER/SES_SMTP_PASSWORD, or the password is
|
|
29
|
+
* derived from AWS_SECRET_ACCESS_KEY when only that is available.
|
|
30
|
+
* @param {{
|
|
31
|
+
* to: string;
|
|
32
|
+
* from: string;
|
|
33
|
+
* subject: string;
|
|
34
|
+
* body: string;
|
|
35
|
+
* region: string;
|
|
36
|
+
* accessKeyId?: string;
|
|
37
|
+
* }} params
|
|
38
|
+
* @returns {Promise<string | undefined>} The SMTP message id
|
|
39
|
+
*/
|
|
40
|
+
export function sendViaSmtp(params: {
|
|
41
|
+
to: string;
|
|
42
|
+
from: string;
|
|
43
|
+
subject: string;
|
|
44
|
+
body: string;
|
|
45
|
+
region: string;
|
|
46
|
+
accessKeyId?: string;
|
|
47
|
+
}): Promise<string | undefined>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let crypto = require("crypto");
|
|
3
|
+
//#region src/commands/aws/ses/smtp-password.js
|
|
4
|
+
/**
|
|
5
|
+
* AWS regions that expose an SES SMTP endpoint.
|
|
6
|
+
*/
|
|
7
|
+
const SMTP_REGIONS = /* @__PURE__ */ new Set([
|
|
8
|
+
"us-east-2",
|
|
9
|
+
"us-east-1",
|
|
10
|
+
"us-west-1",
|
|
11
|
+
"us-west-2",
|
|
12
|
+
"ap-south-1",
|
|
13
|
+
"ap-northeast-2",
|
|
14
|
+
"ap-southeast-1",
|
|
15
|
+
"ap-southeast-2",
|
|
16
|
+
"ap-northeast-1",
|
|
17
|
+
"ca-central-1",
|
|
18
|
+
"eu-central-1",
|
|
19
|
+
"eu-west-1",
|
|
20
|
+
"eu-west-2",
|
|
21
|
+
"eu-west-3",
|
|
22
|
+
"eu-south-1",
|
|
23
|
+
"eu-north-1",
|
|
24
|
+
"sa-east-1",
|
|
25
|
+
"us-gov-west-1",
|
|
26
|
+
"us-gov-east-1",
|
|
27
|
+
"me-south-1",
|
|
28
|
+
"af-south-1",
|
|
29
|
+
"il-central-1"
|
|
30
|
+
]);
|
|
31
|
+
const DATE = "11111111";
|
|
32
|
+
const SERVICE = "ses";
|
|
33
|
+
const MESSAGE = "SendRawEmail";
|
|
34
|
+
const TERMINAL = "aws4_request";
|
|
35
|
+
const VERSION = 4;
|
|
36
|
+
/**
|
|
37
|
+
* @param {Buffer} key
|
|
38
|
+
* @param {string} message
|
|
39
|
+
* @returns {Buffer}
|
|
40
|
+
*/
|
|
41
|
+
function sign(key, message) {
|
|
42
|
+
return (0, crypto.createHmac)("sha256", key).update(message, "utf8").digest();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Derive an SES SMTP password from an IAM secret access key, following the
|
|
46
|
+
* AWS Signature V4 algorithm with SES-specific constants.
|
|
47
|
+
* @see https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html#smtp-credentials-convert
|
|
48
|
+
* @param {{ secretAccessKey: string; region: string }} params
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
function calculateSmtpPassword(params) {
|
|
52
|
+
const { secretAccessKey, region } = params;
|
|
53
|
+
if (!SMTP_REGIONS.has(region)) throw new Error(`calculateSmtpPassword: region "${region}" has no SES SMTP endpoint`);
|
|
54
|
+
let signature = sign(Buffer.from(`AWS4${secretAccessKey}`, "utf8"), DATE);
|
|
55
|
+
signature = sign(signature, region);
|
|
56
|
+
signature = sign(signature, SERVICE);
|
|
57
|
+
signature = sign(signature, TERMINAL);
|
|
58
|
+
signature = sign(signature, MESSAGE);
|
|
59
|
+
return Buffer.concat([Buffer.from([VERSION]), signature]).toString("base64");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* SES SMTP endpoint host for a region.
|
|
63
|
+
* @param {string} region
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
function smtpEndpoint(region) {
|
|
67
|
+
return `email-smtp.${region}.amazonaws.com`;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.SMTP_REGIONS = SMTP_REGIONS;
|
|
71
|
+
exports.calculateSmtpPassword = calculateSmtpPassword;
|
|
72
|
+
exports.smtpEndpoint = smtpEndpoint;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive an SES SMTP password from an IAM secret access key, following the
|
|
3
|
+
* AWS Signature V4 algorithm with SES-specific constants.
|
|
4
|
+
* @see https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html#smtp-credentials-convert
|
|
5
|
+
* @param {{ secretAccessKey: string; region: string }} params
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function calculateSmtpPassword(params: {
|
|
9
|
+
secretAccessKey: string;
|
|
10
|
+
region: string;
|
|
11
|
+
}): string;
|
|
12
|
+
/**
|
|
13
|
+
* SES SMTP endpoint host for a region.
|
|
14
|
+
* @param {string} region
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
export function smtpEndpoint(region: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* AWS regions that expose an SES SMTP endpoint.
|
|
20
|
+
*/
|
|
21
|
+
export const SMTP_REGIONS: Set<string>;
|