emails-help 0.0.0-stage → 0.1.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.d.cts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolve
4
+ } from "./chunk-OIVBYFTS.js";
5
+
6
+ // src/cli.ts
7
+ var USAGE = `
8
+ emails-help \u2014 look up IMAP and SMTP settings for an address or domain
9
+
10
+ npx emails-help <address|domain> [options]
11
+
12
+ Options
13
+ --json Print the full result as JSON
14
+ --offline Use only the bundled dataset; make no network calls
15
+ --live Fetch the newest dataset from emails.help
16
+ --no-infer Never fall back to MX-based inference
17
+ --timeout <ms> Per-request timeout (default 5000)
18
+ -h, --help Show this
19
+
20
+ Examples
21
+ npx emails-help posteo.de
22
+ npx emails-help me@fastmail.com --json
23
+ npx emails-help mycompany.com # resolves custom domains via MX
24
+ `;
25
+ function flag(argv, name) {
26
+ return argv.includes(name);
27
+ }
28
+ function value(argv, name) {
29
+ const at = argv.indexOf(name);
30
+ return at === -1 ? void 0 : argv[at + 1];
31
+ }
32
+ function line(label, server) {
33
+ if (server === null) return ` ${label.padEnd(6)} \u2014`;
34
+ const security = server.security ?? "not stated";
35
+ const caveat = server.securityDocumented ? "" : " (encryption not documented by the provider)";
36
+ return ` ${label.padEnd(6)} ${server.host}:${server.port ?? "?"} ${security}${caveat}`;
37
+ }
38
+ function print(result) {
39
+ if (!result.found) {
40
+ console.log(`
41
+ No settings found for ${result.domain}.
42
+ `);
43
+ console.log("Tried:");
44
+ for (const step of result.trail) {
45
+ console.log(` ${step.method.padEnd(12)} ${step.outcome}${step.detail ? ` \u2014 ${step.detail}` : ""}`);
46
+ }
47
+ console.log("");
48
+ return;
49
+ }
50
+ console.log(`
51
+ ${result.provider ?? result.domain}`);
52
+ console.log(` found via ${result.method} \xB7 confidence: ${result.confidence}`);
53
+ if (!result.clientAccess) {
54
+ console.log("\n This provider offers no IMAP or SMTP access at all.");
55
+ console.log(" That is the answer, not missing data \u2014 use its own app or bridge.\n");
56
+ return;
57
+ }
58
+ console.log("");
59
+ console.log(line("IMAP", result.imap));
60
+ if (result.pop3 !== null) console.log(line("POP3", result.pop3));
61
+ console.log(line("SMTP", result.smtp));
62
+ if (result.smtp?.alternative !== void 0) {
63
+ const alt = result.smtp.alternative;
64
+ console.log(` ${"".padEnd(6)} alternative port ${alt.port ?? "?"} ${alt.security ?? "not stated"}`);
65
+ }
66
+ if (result.username !== null) console.log(`
67
+ username ${result.username}`);
68
+ if (result.authentication !== null) console.log(` auth ${result.authentication}`);
69
+ if (result.undocumented.length > 0) {
70
+ console.log(`
71
+ Not documented by the provider: ${result.undocumented.join(", ")}`);
72
+ }
73
+ for (const note of result.notes) console.log(`
74
+ Note: ${note}`);
75
+ if (result.sources.length > 0) {
76
+ console.log("\n Sources:");
77
+ for (const source of result.sources) console.log(` ${source}`);
78
+ }
79
+ if (result.guide !== null) console.log(`
80
+ Guide: ${result.guide}`);
81
+ if (result.verified !== null) console.log(` Last checked: ${result.verified}`);
82
+ console.log("");
83
+ }
84
+ async function main() {
85
+ const argv = process.argv.slice(2);
86
+ const target = argv.find((arg) => !arg.startsWith("-") && argv[argv.indexOf(arg) - 1] !== "--timeout");
87
+ if (target === void 0 || flag(argv, "-h") || flag(argv, "--help")) {
88
+ console.log(USAGE);
89
+ process.exit(target === void 0 ? 1 : 0);
90
+ }
91
+ let methods;
92
+ if (flag(argv, "--offline")) methods = ["dataset"];
93
+ else if (flag(argv, "--no-infer")) methods = ["dataset", "autoconfig", "well-known", "ispdb"];
94
+ const timeoutRaw = value(argv, "--timeout");
95
+ const result = await resolve(target, {
96
+ methods,
97
+ live: flag(argv, "--live"),
98
+ timeout: timeoutRaw === void 0 ? void 0 : Number.parseInt(timeoutRaw, 10)
99
+ });
100
+ if (flag(argv, "--json")) {
101
+ console.log(JSON.stringify(result, null, 2));
102
+ } else {
103
+ print(result);
104
+ }
105
+ process.exit(result.found ? 0 : 2);
106
+ }
107
+ main().catch((error) => {
108
+ console.error(`emails-help: ${error.message}`);
109
+ process.exit(1);
110
+ });