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/LICENSE +21 -0
- package/README.md +172 -2
- package/dist/chunk-OIVBYFTS.js +1665 -0
- package/dist/cli.cjs +1782 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +110 -0
- package/dist/index.cjs +1711 -0
- package/dist/index.d.cts +272 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +26 -0
- package/package.json +61 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes this package returns.
|
|
3
|
+
*
|
|
4
|
+
* The one idea worth understanding before reading any of it: a result always
|
|
5
|
+
* says HOW it was reached and HOW MUCH the provider actually committed to.
|
|
6
|
+
* Every other library in this space returns a host and a port as though the
|
|
7
|
+
* two were equally certain whether they came from a provider's own
|
|
8
|
+
* documentation or from a guess about its MX records. They are not, and the
|
|
9
|
+
* difference is the whole reason this exists.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* How the transport is protected. `null` means nobody has stated it.
|
|
13
|
+
*
|
|
14
|
+
* Lowercase, because the emails.help dataset is the source of truth here and
|
|
15
|
+
* that is how it spells them. Thunderbird's XML format uses `SSL` and
|
|
16
|
+
* `STARTTLS`; those are normalised on the way in, so a caller never has to
|
|
17
|
+
* branch on which lookup the answer came from.
|
|
18
|
+
*/
|
|
19
|
+
type Security = 'ssl' | 'starttls' | 'none' | null;
|
|
20
|
+
/** Where an answer came from, in the order the resolver tries them. */
|
|
21
|
+
type Method =
|
|
22
|
+
/** The bundled emails.help dataset — values read off provider documentation. */
|
|
23
|
+
'dataset'
|
|
24
|
+
/** The domain's own autoconfig host, as Thunderbird would look it up. */
|
|
25
|
+
| 'autoconfig'
|
|
26
|
+
/** The domain's own `/.well-known/autoconfig/...` file. */
|
|
27
|
+
| 'well-known'
|
|
28
|
+
/** Mozilla's ISPDB. */
|
|
29
|
+
| 'ispdb'
|
|
30
|
+
/** Microsoft-style autodiscover. */
|
|
31
|
+
| 'autodiscover'
|
|
32
|
+
/** The domain's MX records matched against a known mail host. */
|
|
33
|
+
| 'mx';
|
|
34
|
+
/**
|
|
35
|
+
* How much weight the answer carries.
|
|
36
|
+
*
|
|
37
|
+
* - `documented` the provider states these values itself
|
|
38
|
+
* - `undocumented` the provider publishes the server but not every detail
|
|
39
|
+
* of it (see `undocumented` for which fields), so something is genuinely
|
|
40
|
+
* unstated rather than merely unknown to us
|
|
41
|
+
* - `inferred` nobody stated this for this domain; it was derived, and
|
|
42
|
+
* it may be wrong
|
|
43
|
+
*/
|
|
44
|
+
type Confidence = 'documented' | 'undocumented' | 'inferred';
|
|
45
|
+
interface Server {
|
|
46
|
+
host: string;
|
|
47
|
+
port: number | null;
|
|
48
|
+
security: Security;
|
|
49
|
+
/**
|
|
50
|
+
* False when the provider publishes the server but never resolves its
|
|
51
|
+
* encryption. Spectrum is the case that forced this flag into existence:
|
|
52
|
+
* it documents "SSL: On" against outgoing port 587 and never says whether
|
|
53
|
+
* that means STARTTLS or implicit TLS. Printing either one would be a
|
|
54
|
+
* guess a reader could not tell from a fact.
|
|
55
|
+
*/
|
|
56
|
+
securityDocumented: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface SmtpServer extends Server {
|
|
59
|
+
/** A second port the provider publishes, where it publishes one. */
|
|
60
|
+
alternative?: {
|
|
61
|
+
port: number | null;
|
|
62
|
+
security: Security;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
interface Resolution {
|
|
66
|
+
/** Exactly what was passed in. */
|
|
67
|
+
input: string;
|
|
68
|
+
/** The domain it was reduced to. */
|
|
69
|
+
domain: string;
|
|
70
|
+
found: boolean;
|
|
71
|
+
method: Method | null;
|
|
72
|
+
confidence: Confidence | null;
|
|
73
|
+
/** The provider's name, where the answer came from a source that names one. */
|
|
74
|
+
provider: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* False for providers that offer no IMAP or SMTP at all — Tuta, for one.
|
|
77
|
+
* When this is false the absence of servers below is the answer, not a
|
|
78
|
+
* hole in the data, and a client should stop rather than fall through to
|
|
79
|
+
* guessing.
|
|
80
|
+
*/
|
|
81
|
+
clientAccess: boolean;
|
|
82
|
+
imap: Server | null;
|
|
83
|
+
pop3: Server | null;
|
|
84
|
+
smtp: SmtpServer | null;
|
|
85
|
+
/** What to put in the username field, as the provider words it. */
|
|
86
|
+
username: string | null;
|
|
87
|
+
authentication: string | null;
|
|
88
|
+
/** Field names the provider publishes a server for but never specifies. */
|
|
89
|
+
undocumented: string[];
|
|
90
|
+
notes: string[];
|
|
91
|
+
/** First-party pages each value was read from. */
|
|
92
|
+
sources: string[];
|
|
93
|
+
/** A human-readable guide, where one exists. */
|
|
94
|
+
guide: string | null;
|
|
95
|
+
/** The date the values were last checked against their sources. */
|
|
96
|
+
verified: string | null;
|
|
97
|
+
/** When this resolution ran. */
|
|
98
|
+
checkedAt: string;
|
|
99
|
+
/** Every method tried, in order, with what it returned. Useful in a bug report. */
|
|
100
|
+
trail: Array<{
|
|
101
|
+
method: Method;
|
|
102
|
+
outcome: 'hit' | 'miss' | 'error';
|
|
103
|
+
detail?: string;
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
interface ResolveOptions {
|
|
107
|
+
/**
|
|
108
|
+
* Which methods to try, in order. Defaults to every method.
|
|
109
|
+
*
|
|
110
|
+
* Pass `['dataset']` for a fully offline lookup that makes no network
|
|
111
|
+
* calls at all. Drop `'mx'` if you would rather have no answer than an
|
|
112
|
+
* inferred one.
|
|
113
|
+
*/
|
|
114
|
+
methods?: Method[];
|
|
115
|
+
/** Per-request timeout in milliseconds. Default 5000. */
|
|
116
|
+
timeout?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Fetch the dataset from emails.help instead of using the copy bundled
|
|
119
|
+
* with this version. Off by default: a bundled copy cannot fail, and a
|
|
120
|
+
* package that silently depends on someone's uptime is a bad package.
|
|
121
|
+
*/
|
|
122
|
+
live?: boolean;
|
|
123
|
+
/** Override the dataset endpoint. Mostly for tests. */
|
|
124
|
+
endpoint?: string;
|
|
125
|
+
/** Inject a fetch implementation. Mostly for tests. */
|
|
126
|
+
fetch?: typeof globalThis.fetch;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Reduce an address or a URL-ish string to a bare domain. */
|
|
130
|
+
declare function toDomain(input: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Resolve the mail settings for an address or a domain.
|
|
133
|
+
*
|
|
134
|
+
* Methods are tried in order and the first hit wins. The order is not
|
|
135
|
+
* arbitrary: a value the provider documents beats a value a third party
|
|
136
|
+
* holds, which beats a value nothing states at all. The last method, `mx`,
|
|
137
|
+
* returns `confidence: 'inferred'` — it has matched the domain's mail host
|
|
138
|
+
* to a known provider and is handing back that provider's settings, which
|
|
139
|
+
* is usually right and is never stated.
|
|
140
|
+
*/
|
|
141
|
+
declare function resolve(input: string, options?: ResolveOptions): Promise<Resolution>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The emails.help dataset: one row per mail service, every value traceable
|
|
145
|
+
* to the provider's own documentation.
|
|
146
|
+
*
|
|
147
|
+
* A copy is bundled with each release. `npm run sync` refreshes it before
|
|
148
|
+
* publishing. Consumers who want the newest rows without waiting for a
|
|
149
|
+
* release can pass `{ live: true }`, but the bundled copy is the default
|
|
150
|
+
* because an offline lookup that cannot fail is worth more than a few weeks
|
|
151
|
+
* of freshness.
|
|
152
|
+
*/
|
|
153
|
+
interface DatasetServer {
|
|
154
|
+
host: string;
|
|
155
|
+
port: number | null;
|
|
156
|
+
security: Security;
|
|
157
|
+
security_documented: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface DatasetRow {
|
|
160
|
+
slug: string;
|
|
161
|
+
name: string;
|
|
162
|
+
domains: string[];
|
|
163
|
+
mx_patterns: string[];
|
|
164
|
+
client_access: boolean;
|
|
165
|
+
incoming?: {
|
|
166
|
+
imap?: DatasetServer;
|
|
167
|
+
pop3?: DatasetServer;
|
|
168
|
+
};
|
|
169
|
+
outgoing?: {
|
|
170
|
+
smtp?: DatasetServer & {
|
|
171
|
+
alternative?: {
|
|
172
|
+
port: number | null;
|
|
173
|
+
security: Security;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
username?: string | null;
|
|
178
|
+
authentication?: string | null;
|
|
179
|
+
notes: string[];
|
|
180
|
+
undocumented: string[];
|
|
181
|
+
sources: string[];
|
|
182
|
+
guide: string | null;
|
|
183
|
+
verified: string | null;
|
|
184
|
+
}
|
|
185
|
+
interface Dataset {
|
|
186
|
+
version: number;
|
|
187
|
+
generated_at: string;
|
|
188
|
+
source: string;
|
|
189
|
+
/** The dataset's own statement of what a null in it means. */
|
|
190
|
+
about?: string;
|
|
191
|
+
licence: string;
|
|
192
|
+
count: number;
|
|
193
|
+
providers: DatasetRow[];
|
|
194
|
+
/**
|
|
195
|
+
* The envelope accepts fields this package does not know about, so a new
|
|
196
|
+
* key on the published dataset cannot break anyone's build. Rows are
|
|
197
|
+
* deliberately NOT forgiving in the same way: a field appearing or
|
|
198
|
+
* changing shape inside a provider row is exactly the drift the weekly
|
|
199
|
+
* CI sync is there to catch.
|
|
200
|
+
*/
|
|
201
|
+
[key: string]: unknown;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The copy shipped inside this package.
|
|
205
|
+
*
|
|
206
|
+
* It is compiled in as a module rather than read off disk. That costs a
|
|
207
|
+
* little bundle size and buys three things: the package works unchanged in
|
|
208
|
+
* a browser, a Worker or any edge runtime with no filesystem; there is no
|
|
209
|
+
* path resolution to break between the ESM and CJS builds; and an offline
|
|
210
|
+
* lookup has no failure mode at all.
|
|
211
|
+
*/
|
|
212
|
+
declare function bundledDataset(): Dataset;
|
|
213
|
+
declare function liveDataset(endpoint?: string, fetchImpl?: typeof globalThis.fetch, timeout?: number): Promise<Dataset>;
|
|
214
|
+
/**
|
|
215
|
+
* Find the row for a domain.
|
|
216
|
+
*
|
|
217
|
+
* Two ways in. An exact match on an address domain is the common one. The
|
|
218
|
+
* MX-suffix match is what makes a custom domain resolvable: a business on
|
|
219
|
+
* Google Workspace has its own domain and Google's MX records, and the
|
|
220
|
+
* second rule catches it where the first cannot.
|
|
221
|
+
*/
|
|
222
|
+
declare function rowForDomain(dataset: Dataset, domain: string): DatasetRow | null;
|
|
223
|
+
/** Find the row whose MX patterns match any of these MX hostnames. */
|
|
224
|
+
declare function rowForMx(dataset: Dataset, mxHosts: string[]): DatasetRow | null;
|
|
225
|
+
/** Turn a dataset row into a resolution. */
|
|
226
|
+
declare function fromRow(row: DatasetRow): Omit<Resolution, 'input' | 'domain' | 'method' | 'checkedAt' | 'trail'>;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Thunderbird's client configuration format, and the places it is published.
|
|
230
|
+
*
|
|
231
|
+
* No XML dependency. The format is small, fixed and machine-generated, and
|
|
232
|
+
* pulling a parser in to read six elements would be the only runtime
|
|
233
|
+
* dependency in this package. The reader below is deliberately narrow: it
|
|
234
|
+
* finds server blocks and the fields inside them, and ignores everything
|
|
235
|
+
* else in the document.
|
|
236
|
+
*/
|
|
237
|
+
interface ParsedConfig {
|
|
238
|
+
provider: string | null;
|
|
239
|
+
imap: Server | null;
|
|
240
|
+
pop3: Server | null;
|
|
241
|
+
smtp: SmtpServer | null;
|
|
242
|
+
username: string | null;
|
|
243
|
+
}
|
|
244
|
+
/** The URLs a mail client tries, in the order Thunderbird tries them. */
|
|
245
|
+
declare function autoconfigUrls(domain: string): Array<{
|
|
246
|
+
method: 'autoconfig' | 'well-known';
|
|
247
|
+
url: string;
|
|
248
|
+
}>;
|
|
249
|
+
declare function ispdbUrl(domain: string): string;
|
|
250
|
+
/**
|
|
251
|
+
* Read a clientConfig document.
|
|
252
|
+
*
|
|
253
|
+
* Where a provider lists several servers of one type, the first is taken:
|
|
254
|
+
* the format treats order as preference and Thunderbird does the same.
|
|
255
|
+
*/
|
|
256
|
+
declare function parseClientConfig(xml: string): ParsedConfig | null;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* MX lookup.
|
|
260
|
+
*
|
|
261
|
+
* The contract matters more than the code: `null` means the lookup failed
|
|
262
|
+
* and we do not know, `[]` means the domain genuinely publishes no MX
|
|
263
|
+
* records. A caller that collapses the two will tell someone their domain
|
|
264
|
+
* cannot receive mail because a resolver timed out.
|
|
265
|
+
*
|
|
266
|
+
* `node:dns` is imported dynamically so that the rest of the package stays
|
|
267
|
+
* usable in a browser or an edge runtime, where there is no resolver and
|
|
268
|
+
* this one method simply reports that it could not look.
|
|
269
|
+
*/
|
|
270
|
+
declare function mxHosts(domain: string, timeout: number): Promise<string[] | null>;
|
|
271
|
+
|
|
272
|
+
export { type Confidence, type Dataset, type DatasetRow, type DatasetServer, type Method, type ParsedConfig, type Resolution, type ResolveOptions, type Security, type Server, type SmtpServer, autoconfigUrls, bundledDataset, fromRow, ispdbUrl, liveDataset, mxHosts, parseClientConfig, resolve, rowForDomain, rowForMx, toDomain };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes this package returns.
|
|
3
|
+
*
|
|
4
|
+
* The one idea worth understanding before reading any of it: a result always
|
|
5
|
+
* says HOW it was reached and HOW MUCH the provider actually committed to.
|
|
6
|
+
* Every other library in this space returns a host and a port as though the
|
|
7
|
+
* two were equally certain whether they came from a provider's own
|
|
8
|
+
* documentation or from a guess about its MX records. They are not, and the
|
|
9
|
+
* difference is the whole reason this exists.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* How the transport is protected. `null` means nobody has stated it.
|
|
13
|
+
*
|
|
14
|
+
* Lowercase, because the emails.help dataset is the source of truth here and
|
|
15
|
+
* that is how it spells them. Thunderbird's XML format uses `SSL` and
|
|
16
|
+
* `STARTTLS`; those are normalised on the way in, so a caller never has to
|
|
17
|
+
* branch on which lookup the answer came from.
|
|
18
|
+
*/
|
|
19
|
+
type Security = 'ssl' | 'starttls' | 'none' | null;
|
|
20
|
+
/** Where an answer came from, in the order the resolver tries them. */
|
|
21
|
+
type Method =
|
|
22
|
+
/** The bundled emails.help dataset — values read off provider documentation. */
|
|
23
|
+
'dataset'
|
|
24
|
+
/** The domain's own autoconfig host, as Thunderbird would look it up. */
|
|
25
|
+
| 'autoconfig'
|
|
26
|
+
/** The domain's own `/.well-known/autoconfig/...` file. */
|
|
27
|
+
| 'well-known'
|
|
28
|
+
/** Mozilla's ISPDB. */
|
|
29
|
+
| 'ispdb'
|
|
30
|
+
/** Microsoft-style autodiscover. */
|
|
31
|
+
| 'autodiscover'
|
|
32
|
+
/** The domain's MX records matched against a known mail host. */
|
|
33
|
+
| 'mx';
|
|
34
|
+
/**
|
|
35
|
+
* How much weight the answer carries.
|
|
36
|
+
*
|
|
37
|
+
* - `documented` the provider states these values itself
|
|
38
|
+
* - `undocumented` the provider publishes the server but not every detail
|
|
39
|
+
* of it (see `undocumented` for which fields), so something is genuinely
|
|
40
|
+
* unstated rather than merely unknown to us
|
|
41
|
+
* - `inferred` nobody stated this for this domain; it was derived, and
|
|
42
|
+
* it may be wrong
|
|
43
|
+
*/
|
|
44
|
+
type Confidence = 'documented' | 'undocumented' | 'inferred';
|
|
45
|
+
interface Server {
|
|
46
|
+
host: string;
|
|
47
|
+
port: number | null;
|
|
48
|
+
security: Security;
|
|
49
|
+
/**
|
|
50
|
+
* False when the provider publishes the server but never resolves its
|
|
51
|
+
* encryption. Spectrum is the case that forced this flag into existence:
|
|
52
|
+
* it documents "SSL: On" against outgoing port 587 and never says whether
|
|
53
|
+
* that means STARTTLS or implicit TLS. Printing either one would be a
|
|
54
|
+
* guess a reader could not tell from a fact.
|
|
55
|
+
*/
|
|
56
|
+
securityDocumented: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface SmtpServer extends Server {
|
|
59
|
+
/** A second port the provider publishes, where it publishes one. */
|
|
60
|
+
alternative?: {
|
|
61
|
+
port: number | null;
|
|
62
|
+
security: Security;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
interface Resolution {
|
|
66
|
+
/** Exactly what was passed in. */
|
|
67
|
+
input: string;
|
|
68
|
+
/** The domain it was reduced to. */
|
|
69
|
+
domain: string;
|
|
70
|
+
found: boolean;
|
|
71
|
+
method: Method | null;
|
|
72
|
+
confidence: Confidence | null;
|
|
73
|
+
/** The provider's name, where the answer came from a source that names one. */
|
|
74
|
+
provider: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* False for providers that offer no IMAP or SMTP at all — Tuta, for one.
|
|
77
|
+
* When this is false the absence of servers below is the answer, not a
|
|
78
|
+
* hole in the data, and a client should stop rather than fall through to
|
|
79
|
+
* guessing.
|
|
80
|
+
*/
|
|
81
|
+
clientAccess: boolean;
|
|
82
|
+
imap: Server | null;
|
|
83
|
+
pop3: Server | null;
|
|
84
|
+
smtp: SmtpServer | null;
|
|
85
|
+
/** What to put in the username field, as the provider words it. */
|
|
86
|
+
username: string | null;
|
|
87
|
+
authentication: string | null;
|
|
88
|
+
/** Field names the provider publishes a server for but never specifies. */
|
|
89
|
+
undocumented: string[];
|
|
90
|
+
notes: string[];
|
|
91
|
+
/** First-party pages each value was read from. */
|
|
92
|
+
sources: string[];
|
|
93
|
+
/** A human-readable guide, where one exists. */
|
|
94
|
+
guide: string | null;
|
|
95
|
+
/** The date the values were last checked against their sources. */
|
|
96
|
+
verified: string | null;
|
|
97
|
+
/** When this resolution ran. */
|
|
98
|
+
checkedAt: string;
|
|
99
|
+
/** Every method tried, in order, with what it returned. Useful in a bug report. */
|
|
100
|
+
trail: Array<{
|
|
101
|
+
method: Method;
|
|
102
|
+
outcome: 'hit' | 'miss' | 'error';
|
|
103
|
+
detail?: string;
|
|
104
|
+
}>;
|
|
105
|
+
}
|
|
106
|
+
interface ResolveOptions {
|
|
107
|
+
/**
|
|
108
|
+
* Which methods to try, in order. Defaults to every method.
|
|
109
|
+
*
|
|
110
|
+
* Pass `['dataset']` for a fully offline lookup that makes no network
|
|
111
|
+
* calls at all. Drop `'mx'` if you would rather have no answer than an
|
|
112
|
+
* inferred one.
|
|
113
|
+
*/
|
|
114
|
+
methods?: Method[];
|
|
115
|
+
/** Per-request timeout in milliseconds. Default 5000. */
|
|
116
|
+
timeout?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Fetch the dataset from emails.help instead of using the copy bundled
|
|
119
|
+
* with this version. Off by default: a bundled copy cannot fail, and a
|
|
120
|
+
* package that silently depends on someone's uptime is a bad package.
|
|
121
|
+
*/
|
|
122
|
+
live?: boolean;
|
|
123
|
+
/** Override the dataset endpoint. Mostly for tests. */
|
|
124
|
+
endpoint?: string;
|
|
125
|
+
/** Inject a fetch implementation. Mostly for tests. */
|
|
126
|
+
fetch?: typeof globalThis.fetch;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Reduce an address or a URL-ish string to a bare domain. */
|
|
130
|
+
declare function toDomain(input: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Resolve the mail settings for an address or a domain.
|
|
133
|
+
*
|
|
134
|
+
* Methods are tried in order and the first hit wins. The order is not
|
|
135
|
+
* arbitrary: a value the provider documents beats a value a third party
|
|
136
|
+
* holds, which beats a value nothing states at all. The last method, `mx`,
|
|
137
|
+
* returns `confidence: 'inferred'` — it has matched the domain's mail host
|
|
138
|
+
* to a known provider and is handing back that provider's settings, which
|
|
139
|
+
* is usually right and is never stated.
|
|
140
|
+
*/
|
|
141
|
+
declare function resolve(input: string, options?: ResolveOptions): Promise<Resolution>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The emails.help dataset: one row per mail service, every value traceable
|
|
145
|
+
* to the provider's own documentation.
|
|
146
|
+
*
|
|
147
|
+
* A copy is bundled with each release. `npm run sync` refreshes it before
|
|
148
|
+
* publishing. Consumers who want the newest rows without waiting for a
|
|
149
|
+
* release can pass `{ live: true }`, but the bundled copy is the default
|
|
150
|
+
* because an offline lookup that cannot fail is worth more than a few weeks
|
|
151
|
+
* of freshness.
|
|
152
|
+
*/
|
|
153
|
+
interface DatasetServer {
|
|
154
|
+
host: string;
|
|
155
|
+
port: number | null;
|
|
156
|
+
security: Security;
|
|
157
|
+
security_documented: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface DatasetRow {
|
|
160
|
+
slug: string;
|
|
161
|
+
name: string;
|
|
162
|
+
domains: string[];
|
|
163
|
+
mx_patterns: string[];
|
|
164
|
+
client_access: boolean;
|
|
165
|
+
incoming?: {
|
|
166
|
+
imap?: DatasetServer;
|
|
167
|
+
pop3?: DatasetServer;
|
|
168
|
+
};
|
|
169
|
+
outgoing?: {
|
|
170
|
+
smtp?: DatasetServer & {
|
|
171
|
+
alternative?: {
|
|
172
|
+
port: number | null;
|
|
173
|
+
security: Security;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
username?: string | null;
|
|
178
|
+
authentication?: string | null;
|
|
179
|
+
notes: string[];
|
|
180
|
+
undocumented: string[];
|
|
181
|
+
sources: string[];
|
|
182
|
+
guide: string | null;
|
|
183
|
+
verified: string | null;
|
|
184
|
+
}
|
|
185
|
+
interface Dataset {
|
|
186
|
+
version: number;
|
|
187
|
+
generated_at: string;
|
|
188
|
+
source: string;
|
|
189
|
+
/** The dataset's own statement of what a null in it means. */
|
|
190
|
+
about?: string;
|
|
191
|
+
licence: string;
|
|
192
|
+
count: number;
|
|
193
|
+
providers: DatasetRow[];
|
|
194
|
+
/**
|
|
195
|
+
* The envelope accepts fields this package does not know about, so a new
|
|
196
|
+
* key on the published dataset cannot break anyone's build. Rows are
|
|
197
|
+
* deliberately NOT forgiving in the same way: a field appearing or
|
|
198
|
+
* changing shape inside a provider row is exactly the drift the weekly
|
|
199
|
+
* CI sync is there to catch.
|
|
200
|
+
*/
|
|
201
|
+
[key: string]: unknown;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The copy shipped inside this package.
|
|
205
|
+
*
|
|
206
|
+
* It is compiled in as a module rather than read off disk. That costs a
|
|
207
|
+
* little bundle size and buys three things: the package works unchanged in
|
|
208
|
+
* a browser, a Worker or any edge runtime with no filesystem; there is no
|
|
209
|
+
* path resolution to break between the ESM and CJS builds; and an offline
|
|
210
|
+
* lookup has no failure mode at all.
|
|
211
|
+
*/
|
|
212
|
+
declare function bundledDataset(): Dataset;
|
|
213
|
+
declare function liveDataset(endpoint?: string, fetchImpl?: typeof globalThis.fetch, timeout?: number): Promise<Dataset>;
|
|
214
|
+
/**
|
|
215
|
+
* Find the row for a domain.
|
|
216
|
+
*
|
|
217
|
+
* Two ways in. An exact match on an address domain is the common one. The
|
|
218
|
+
* MX-suffix match is what makes a custom domain resolvable: a business on
|
|
219
|
+
* Google Workspace has its own domain and Google's MX records, and the
|
|
220
|
+
* second rule catches it where the first cannot.
|
|
221
|
+
*/
|
|
222
|
+
declare function rowForDomain(dataset: Dataset, domain: string): DatasetRow | null;
|
|
223
|
+
/** Find the row whose MX patterns match any of these MX hostnames. */
|
|
224
|
+
declare function rowForMx(dataset: Dataset, mxHosts: string[]): DatasetRow | null;
|
|
225
|
+
/** Turn a dataset row into a resolution. */
|
|
226
|
+
declare function fromRow(row: DatasetRow): Omit<Resolution, 'input' | 'domain' | 'method' | 'checkedAt' | 'trail'>;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Thunderbird's client configuration format, and the places it is published.
|
|
230
|
+
*
|
|
231
|
+
* No XML dependency. The format is small, fixed and machine-generated, and
|
|
232
|
+
* pulling a parser in to read six elements would be the only runtime
|
|
233
|
+
* dependency in this package. The reader below is deliberately narrow: it
|
|
234
|
+
* finds server blocks and the fields inside them, and ignores everything
|
|
235
|
+
* else in the document.
|
|
236
|
+
*/
|
|
237
|
+
interface ParsedConfig {
|
|
238
|
+
provider: string | null;
|
|
239
|
+
imap: Server | null;
|
|
240
|
+
pop3: Server | null;
|
|
241
|
+
smtp: SmtpServer | null;
|
|
242
|
+
username: string | null;
|
|
243
|
+
}
|
|
244
|
+
/** The URLs a mail client tries, in the order Thunderbird tries them. */
|
|
245
|
+
declare function autoconfigUrls(domain: string): Array<{
|
|
246
|
+
method: 'autoconfig' | 'well-known';
|
|
247
|
+
url: string;
|
|
248
|
+
}>;
|
|
249
|
+
declare function ispdbUrl(domain: string): string;
|
|
250
|
+
/**
|
|
251
|
+
* Read a clientConfig document.
|
|
252
|
+
*
|
|
253
|
+
* Where a provider lists several servers of one type, the first is taken:
|
|
254
|
+
* the format treats order as preference and Thunderbird does the same.
|
|
255
|
+
*/
|
|
256
|
+
declare function parseClientConfig(xml: string): ParsedConfig | null;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* MX lookup.
|
|
260
|
+
*
|
|
261
|
+
* The contract matters more than the code: `null` means the lookup failed
|
|
262
|
+
* and we do not know, `[]` means the domain genuinely publishes no MX
|
|
263
|
+
* records. A caller that collapses the two will tell someone their domain
|
|
264
|
+
* cannot receive mail because a resolver timed out.
|
|
265
|
+
*
|
|
266
|
+
* `node:dns` is imported dynamically so that the rest of the package stays
|
|
267
|
+
* usable in a browser or an edge runtime, where there is no resolver and
|
|
268
|
+
* this one method simply reports that it could not look.
|
|
269
|
+
*/
|
|
270
|
+
declare function mxHosts(domain: string, timeout: number): Promise<string[] | null>;
|
|
271
|
+
|
|
272
|
+
export { type Confidence, type Dataset, type DatasetRow, type DatasetServer, type Method, type ParsedConfig, type Resolution, type ResolveOptions, type Security, type Server, type SmtpServer, autoconfigUrls, bundledDataset, fromRow, ispdbUrl, liveDataset, mxHosts, parseClientConfig, resolve, rowForDomain, rowForMx, toDomain };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
autoconfigUrls,
|
|
3
|
+
bundledDataset,
|
|
4
|
+
fromRow,
|
|
5
|
+
ispdbUrl,
|
|
6
|
+
liveDataset,
|
|
7
|
+
mxHosts,
|
|
8
|
+
parseClientConfig,
|
|
9
|
+
resolve,
|
|
10
|
+
rowForDomain,
|
|
11
|
+
rowForMx,
|
|
12
|
+
toDomain
|
|
13
|
+
} from "./chunk-OIVBYFTS.js";
|
|
14
|
+
export {
|
|
15
|
+
autoconfigUrls,
|
|
16
|
+
bundledDataset,
|
|
17
|
+
fromRow,
|
|
18
|
+
ispdbUrl,
|
|
19
|
+
liveDataset,
|
|
20
|
+
mxHosts,
|
|
21
|
+
parseClientConfig,
|
|
22
|
+
resolve,
|
|
23
|
+
rowForDomain,
|
|
24
|
+
rowForMx,
|
|
25
|
+
toDomain
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emails-help",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Resolve IMAP and SMTP settings for any email address or domain — and find out how certain the answer actually is. Zero runtime dependencies.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"email",
|
|
7
|
+
"imap",
|
|
8
|
+
"smtp",
|
|
9
|
+
"pop3",
|
|
10
|
+
"autoconfig",
|
|
11
|
+
"autodiscover",
|
|
12
|
+
"ispdb",
|
|
13
|
+
"thunderbird",
|
|
14
|
+
"mail-settings",
|
|
15
|
+
"email-settings",
|
|
16
|
+
"mx"
|
|
17
|
+
],
|
|
18
|
+
"author": "emails.help (https://emails.help)",
|
|
19
|
+
"homepage": "https://emails.help",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/404notpentested/emails-help-js.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/404notpentested/emails-help-js/issues"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"type": "module",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"bin": {
|
|
44
|
+
"emails-help": "./dist/cli.js"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"README.md",
|
|
49
|
+
"LICENSE"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"sync": "node scripts/sync.mjs",
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
56
|
+
"prepublishOnly": "npm run sync && npm run typecheck && npm test"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.10.2",
|
|
60
|
+
"tsup": "^8.3.5",
|
|
61
|
+
"typescript": "^5.7.2"
|
|
62
|
+
}
|
|
63
|
+
}
|