groundmail-cli 0.37.2 → 0.38.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 +104 -3
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2106,7 +2106,7 @@ function trimUrl(value) {
|
|
|
2106
2106
|
}
|
|
2107
2107
|
|
|
2108
2108
|
// package.json
|
|
2109
|
-
var version = "0.
|
|
2109
|
+
var version = "0.38.0";
|
|
2110
2110
|
|
|
2111
2111
|
// src/user-agent.ts
|
|
2112
2112
|
function buildUserAgent(own) {
|
|
@@ -4605,6 +4605,101 @@ async function runMigrateCommand(provider, args, env = process.env) {
|
|
|
4605
4605
|
}
|
|
4606
4606
|
}
|
|
4607
4607
|
|
|
4608
|
+
// src/commands/burrowguard.ts
|
|
4609
|
+
var MISSING_KEY4 = "Missing API key. Set GROUNDMAIL_API_KEY, pass --api-key, or run `groundmail login`.";
|
|
4610
|
+
var USAGE = [
|
|
4611
|
+
"Usage: groundmail burrowguard sites [list]",
|
|
4612
|
+
' groundmail burrowguard sites create --name "Sign-up form" --hostname app.example.com [--hostname localhost] [--block-free-webmail] [--allow-data-center-ips]',
|
|
4613
|
+
' groundmail burrowguard sites create --name "Contact form" --email-checks-only',
|
|
4614
|
+
" groundmail burrowguard sites delete <id> --yes",
|
|
4615
|
+
" groundmail burrowguard sites roll-secret <id> --yes",
|
|
4616
|
+
" groundmail burrowguard checks [--site <id>] [--result passed|blocked|no_token] [--range 24h|7d|30d] [--limit 25]"
|
|
4617
|
+
].join("\n");
|
|
4618
|
+
function readAll(args, flag) {
|
|
4619
|
+
return args.flatMap((arg, index) => arg === flag && args[index + 1] ? [args[index + 1]] : []);
|
|
4620
|
+
}
|
|
4621
|
+
async function withClient4(args, env, run) {
|
|
4622
|
+
const options = parseSuppressionsCommonArgs(args);
|
|
4623
|
+
const apiKey = resolveApiKey7(options, env);
|
|
4624
|
+
if (!apiKey) return { exitCode: 1, error: MISSING_KEY4 };
|
|
4625
|
+
try {
|
|
4626
|
+
const client2 = await createSuppressionsClient(apiKey, options.baseUrl);
|
|
4627
|
+
const output = await run(client2);
|
|
4628
|
+
if (output !== void 0) console.log(JSON.stringify(output));
|
|
4629
|
+
return { exitCode: 0 };
|
|
4630
|
+
} catch (error) {
|
|
4631
|
+
return { exitCode: 1, error: error instanceof Error ? error.message : String(error) };
|
|
4632
|
+
}
|
|
4633
|
+
}
|
|
4634
|
+
async function runSites(action, rest, env) {
|
|
4635
|
+
if (!action || action === "list" || action.startsWith("--")) {
|
|
4636
|
+
return withClient4(action ? [action, ...rest] : rest, env, (client2) => client2.burrowguard.sites.list());
|
|
4637
|
+
}
|
|
4638
|
+
if (action === "create") {
|
|
4639
|
+
const name = readFlag19(rest, "--name");
|
|
4640
|
+
const hostnames = readAll(rest, "--hostname");
|
|
4641
|
+
const emailOnly = rest.includes("--email-checks-only");
|
|
4642
|
+
if (!name || hostnames.length === 0 && !emailOnly) return { exitCode: 1, error: `Required: --name and --hostname.
|
|
4643
|
+
${USAGE}` };
|
|
4644
|
+
return withClient4(
|
|
4645
|
+
rest,
|
|
4646
|
+
env,
|
|
4647
|
+
(client2) => client2.burrowguard.sites.create({
|
|
4648
|
+
name,
|
|
4649
|
+
...hostnames.length > 0 ? { allowed_hostnames: hostnames } : {},
|
|
4650
|
+
...emailOnly ? { email_checks_only: true } : {},
|
|
4651
|
+
...rest.includes("--block-free-webmail") ? { block_free_webmail: true } : {},
|
|
4652
|
+
...rest.includes("--allow-data-center-ips") ? { allow_data_center_ips: true } : {}
|
|
4653
|
+
})
|
|
4654
|
+
);
|
|
4655
|
+
}
|
|
4656
|
+
if (action === "delete" || action === "roll-secret") {
|
|
4657
|
+
const id = rest[0] && !rest[0].startsWith("--") ? rest[0] : void 0;
|
|
4658
|
+
if (!id) return { exitCode: 1, error: `Missing site id.
|
|
4659
|
+
${USAGE}` };
|
|
4660
|
+
if (!rest.includes("--yes")) {
|
|
4661
|
+
const effect = action === "delete" ? "deletes the site and its checks" : "stops the current secret working at once";
|
|
4662
|
+
return { exitCode: 1, error: `This ${effect}. Pass --yes to go ahead.` };
|
|
4663
|
+
}
|
|
4664
|
+
return withClient4(rest, env, async (client2) => {
|
|
4665
|
+
if (action === "delete") {
|
|
4666
|
+
await client2.burrowguard.sites.remove(id);
|
|
4667
|
+
return { deleted: true, id };
|
|
4668
|
+
}
|
|
4669
|
+
return client2.burrowguard.sites.rollSecret(id);
|
|
4670
|
+
});
|
|
4671
|
+
}
|
|
4672
|
+
return { exitCode: 1, error: `Unknown command: burrowguard sites ${action}
|
|
4673
|
+
${USAGE}` };
|
|
4674
|
+
}
|
|
4675
|
+
function runChecks(args, env) {
|
|
4676
|
+
const result = readFlag19(args, "--result");
|
|
4677
|
+
if (result && !["passed", "blocked", "no_token"].includes(result)) {
|
|
4678
|
+
return Promise.resolve({ exitCode: 1, error: "--result must be passed, blocked or no_token" });
|
|
4679
|
+
}
|
|
4680
|
+
const range = readFlag19(args, "--range");
|
|
4681
|
+
if (range && !["24h", "7d", "30d"].includes(range)) {
|
|
4682
|
+
return Promise.resolve({ exitCode: 1, error: "--range must be 24h, 7d or 30d" });
|
|
4683
|
+
}
|
|
4684
|
+
const limit = readFlag19(args, "--limit");
|
|
4685
|
+
return withClient4(
|
|
4686
|
+
args,
|
|
4687
|
+
env,
|
|
4688
|
+
(client2) => client2.burrowguard.checks.list({
|
|
4689
|
+
...readFlag19(args, "--site") ? { site: readFlag19(args, "--site") } : {},
|
|
4690
|
+
...result ? { result } : {},
|
|
4691
|
+
...range ? { range } : {},
|
|
4692
|
+
...limit ? { limit: Number(limit) } : {},
|
|
4693
|
+
...readFlag19(args, "--cursor") ? { cursor: readFlag19(args, "--cursor") } : {}
|
|
4694
|
+
})
|
|
4695
|
+
);
|
|
4696
|
+
}
|
|
4697
|
+
async function runBurrowGuardCommand(subcommand, args, env = process.env) {
|
|
4698
|
+
if (subcommand === "sites") return runSites(args[0], args.slice(1), env);
|
|
4699
|
+
if (subcommand === "checks") return runChecks(args, env);
|
|
4700
|
+
return { exitCode: 1, error: USAGE };
|
|
4701
|
+
}
|
|
4702
|
+
|
|
4608
4703
|
// src/commands/validate.ts
|
|
4609
4704
|
async function runValidateCommand(args, env = process.env) {
|
|
4610
4705
|
const options = parseSuppressionsCommonArgs(args);
|
|
@@ -4757,9 +4852,9 @@ function formatTestEmail(email) {
|
|
|
4757
4852
|
lines.push(`Id: ${email.id}`);
|
|
4758
4853
|
return lines.join("\n");
|
|
4759
4854
|
}
|
|
4760
|
-
var
|
|
4855
|
+
var USAGE2 = "Usage: groundmail test-inbox address [--prefix signup] | wait --to <address> [--timeout 30] [--since <iso>] [--json] | list [--to <address>] [--json]";
|
|
4761
4856
|
async function runTestInboxCommand(subcommand, args, env = process.env) {
|
|
4762
|
-
if (!subcommand || !["address", "wait", "list"].includes(subcommand)) return { exitCode: 1, error:
|
|
4857
|
+
if (!subcommand || !["address", "wait", "list"].includes(subcommand)) return { exitCode: 1, error: USAGE2 };
|
|
4763
4858
|
const apiKey = readFlag26(args, "--api-key") || env.GROUNDMAIL_API_KEY;
|
|
4764
4859
|
if (!apiKey) return { exitCode: 1, error: "Missing API key. Run groundmail login, set GROUNDMAIL_API_KEY or pass --api-key." };
|
|
4765
4860
|
const json = args.includes("--json");
|
|
@@ -4861,6 +4956,11 @@ var USAGE_LINES = [
|
|
|
4861
4956
|
" groundmail webhooks deliveries get --webhook <webhook-id> --id <delivery-id>",
|
|
4862
4957
|
" groundmail webhooks deliveries resend --webhook <webhook-id> --id <delivery-id>",
|
|
4863
4958
|
" groundmail validate user@example.com Groundmail validation: verdict, reasons, typo suggestion (exit 2 when invalid)",
|
|
4959
|
+
" groundmail burrowguard sites the forms BurrowGuard protects",
|
|
4960
|
+
' groundmail burrowguard sites create --name "Sign-up form" --hostname app.example.com [--hostname localhost] [--block-free-webmail] [--allow-data-center-ips] [--email-checks-only] prints the secret once',
|
|
4961
|
+
" groundmail burrowguard sites roll-secret <id> --yes the old secret stops working at once",
|
|
4962
|
+
" groundmail burrowguard sites delete <id> --yes",
|
|
4963
|
+
" groundmail burrowguard checks [--site <id>] [--result passed|blocked|no_token] [--range 24h|7d|30d] [--limit 25]",
|
|
4864
4964
|
" groundmail suppressions list [--tenant <tenant>]",
|
|
4865
4965
|
" groundmail suppressions add --email user@example.com [--reason \u2026] [--tenant <tenant>]",
|
|
4866
4966
|
" groundmail suppressions remove --id <id> | --email user@example.com [--tenant <tenant>]",
|
|
@@ -5005,6 +5105,7 @@ async function main() {
|
|
|
5005
5105
|
const rest = session.argv;
|
|
5006
5106
|
if (command === "migrate") await finish(await runMigrateCommand(subcommand, rest));
|
|
5007
5107
|
if (command === "validate") await finish(await runValidateCommand([...subcommand ? [subcommand] : [], ...rest]));
|
|
5108
|
+
if (command === "burrowguard") await finish(await runBurrowGuardCommand(subcommand, rest));
|
|
5008
5109
|
if (command === "dmarc") await finish(await runDmarcCommand(subcommand, rest));
|
|
5009
5110
|
if (command === "test-inbox") await finish(await runTestInboxCommand(subcommand, rest));
|
|
5010
5111
|
if (command === "domains") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groundmail-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Groundmail CLI — send transactional email from the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"groundmail": "0.
|
|
41
|
+
"groundmail": "0.41.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^8.5.0",
|