mailauth 5.0.3 → 7.0.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +23 -0
- package/README.md +117 -41
- package/bin/mailauth.js +14 -6
- package/cli.md +8 -3
- package/docs/arc.md +126 -43
- package/docs/bimi.md +54 -37
- package/docs/dkim.md +79 -40
- package/docs/dmarc.md +82 -31
- package/docs/mta-sts.md +140 -42
- package/docs/spf.md +69 -4
- package/index.d.ts +499 -45
- package/lib/arc/index.d.ts +10 -8
- package/lib/arc/index.js +505 -124
- package/lib/bimi/index.js +162 -81
- package/lib/commands/report.js +2 -1
- package/lib/commands/seal.js +35 -5
- package/lib/commands/sign.js +8 -1
- package/lib/commands/spf.js +8 -0
- package/lib/dkim/body/relaxed.js +6 -5
- package/lib/dkim/body/simple.js +1 -3
- package/lib/dkim/dkim-signer.js +219 -33
- package/lib/dkim/dkim-verifier.js +574 -231
- package/lib/dkim/header/relaxed.js +6 -43
- package/lib/dkim/header/signature-opts.js +87 -0
- package/lib/dkim/header/simple.js +6 -43
- package/lib/dkim/message-parser.js +18 -4
- package/lib/dkim/sign.d.ts +13 -7
- package/lib/dkim/sign.js +18 -2
- package/lib/dkim/syntax.js +31 -0
- package/lib/dkim/verify.js +1 -0
- package/lib/dmarc/author-domain.js +181 -0
- package/lib/dmarc/get-dmarc-record.js +267 -53
- package/lib/dmarc/index.d.ts +29 -2
- package/lib/dmarc/index.js +2 -1
- package/lib/dmarc/verify.js +205 -53
- package/lib/mailauth.js +86 -40
- package/lib/mta-sts.d.ts +77 -11
- package/lib/mta-sts.js +497 -182
- package/lib/parse-dkim-headers.js +376 -191
- package/lib/parse-received.js +104 -32
- package/lib/spf/index.d.ts +37 -1
- package/lib/spf/index.js +260 -28
- package/lib/spf/macro.js +50 -13
- package/lib/spf/spf-verify.js +440 -204
- package/lib/spf/syntax.js +366 -0
- package/lib/tools.js +524 -118
- package/package.json +12 -12
package/lib/mta-sts.d.ts
CHANGED
|
@@ -2,23 +2,86 @@
|
|
|
2
2
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
|
|
5
|
-
import { MTASTSOptions, MTASTSPolicy, MTASTSPolicyResult, MTASTSValidationResult } from '../index';
|
|
5
|
+
import { MTASTSOptions as BaseMTASTSOptions, MTASTSPolicy, MTASTSPolicyResult as BaseMTASTSPolicyResult, MTASTSValidationResult } from '../index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* MTA-STS options
|
|
9
|
+
*/
|
|
10
|
+
export interface MTASTSOptions extends BaseMTASTSOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Apply the RFC 8461 rules exactly (default false).
|
|
13
|
+
*
|
|
14
|
+
* - The TXT record must match the RFC 8461 3.1 ABNF (case-sensitive `v=STSv1`, `id` of 1 to 32 letters and digits)
|
|
15
|
+
* - Only HTTP 200 is accepted and the Content-Type must be `text/plain`
|
|
16
|
+
* - Policy field names and the `mode` value are case-sensitive, `max_age` must be 1 to 10 digits and `mx` must be `["*."] Domain`
|
|
17
|
+
* - The Policy Host certificate must match through a DNS-ID subjectAltName, without CN fallback or partial-label wildcards
|
|
18
|
+
* - An expired cached policy is not applied when a fetch fails
|
|
19
|
+
*
|
|
20
|
+
* In the default lax mode these are accepted and reported in the `warnings` array of the `getPolicy` result.
|
|
21
|
+
*/
|
|
22
|
+
strict?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Overall time limit for the HTTPS policy request in milliseconds (default 60000).
|
|
26
|
+
* The socket idle timeout is 15 seconds or this value, whichever is smaller.
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Maximum size of the policy file in bytes (default 65536). Larger responses fail with the `policy_too_large` error code.
|
|
32
|
+
*/
|
|
33
|
+
maxPolicySize?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Markers for input that the default lax mode accepted but `strict: true` would reject
|
|
38
|
+
*
|
|
39
|
+
* - `txt-syntax`: the TXT record does not match the RFC 8461 3.1 syntax
|
|
40
|
+
* - `http-status`: the policy was served with a 2xx status other than 200
|
|
41
|
+
* - `content-type`: the policy was not served as `text/plain`
|
|
42
|
+
* - `policy-syntax`: the policy file does not match the RFC 8461 3.2 syntax (field name or mode case, max_age format, mx pattern)
|
|
43
|
+
* - `cert-identity`: the Policy Host certificate matched only through the CN or a partial-label wildcard
|
|
44
|
+
* - `expired-cache`: an expired cached policy was returned because the policy could not be fetched
|
|
45
|
+
*/
|
|
46
|
+
export type MTASTSWarning = 'txt-syntax' | 'http-status' | 'content-type' | 'policy-syntax' | 'cert-identity' | 'expired-cache';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* MTA-STS policy fetch result
|
|
50
|
+
*/
|
|
51
|
+
export interface MTASTSPolicyResult extends BaseMTASTSPolicyResult {
|
|
52
|
+
/**
|
|
53
|
+
* Lax acceptance markers, only present when the default lax mode accepted something strict mode would reject
|
|
54
|
+
*/
|
|
55
|
+
warnings?: MTASTSWarning[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* MTA-STS MX validation options
|
|
60
|
+
*/
|
|
61
|
+
export interface MTASTSValidateOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Accepted for API consistency. The matching rules are the same in both modes.
|
|
64
|
+
*/
|
|
65
|
+
strict?: boolean;
|
|
66
|
+
}
|
|
6
67
|
|
|
7
68
|
/**
|
|
8
69
|
* Resolves MTA-STS policy ID from DNS
|
|
9
70
|
*
|
|
10
71
|
* @param address - Email address or domain name
|
|
11
72
|
* @param opts - MTA-STS options
|
|
12
|
-
* @returns Policy ID or false if not found
|
|
73
|
+
* @returns Policy ID or false if not found or not usable
|
|
74
|
+
* @throws Error on DNS errors other than NXDOMAIN/NODATA, or with code `multi_sts_records` for multiple records
|
|
13
75
|
*/
|
|
14
76
|
export function resolvePolicy(address: string, opts?: MTASTSOptions): Promise<string | false>;
|
|
15
77
|
|
|
16
78
|
/**
|
|
17
79
|
* Fetches and parses MTA-STS policy file from HTTPS
|
|
18
80
|
*
|
|
19
|
-
* @param domain - Domain name
|
|
81
|
+
* @param domain - Domain name or email address
|
|
20
82
|
* @param opts - MTA-STS options
|
|
21
|
-
* @returns Parsed policy or false if
|
|
83
|
+
* @returns Parsed policy or false if the policy host has no address records
|
|
84
|
+
* @throws Error if the policy can not be fetched or is invalid
|
|
22
85
|
*/
|
|
23
86
|
export function fetchPolicy(domain: string, opts?: MTASTSOptions): Promise<MTASTSPolicy | false>;
|
|
24
87
|
|
|
@@ -26,27 +89,30 @@ export function fetchPolicy(domain: string, opts?: MTASTSOptions): Promise<MTAST
|
|
|
26
89
|
* Parses MTA-STS policy file content
|
|
27
90
|
*
|
|
28
91
|
* @param file - Policy file content
|
|
92
|
+
* @param opts - Only `strict` is used
|
|
29
93
|
* @returns Parsed policy
|
|
30
94
|
* @throws Error if policy is invalid
|
|
31
95
|
*/
|
|
32
|
-
export function parsePolicy(file: Buffer | string): MTASTSPolicy;
|
|
96
|
+
export function parsePolicy(file: Buffer | string, opts?: Pick<MTASTSOptions, 'strict'>): MTASTSPolicy;
|
|
33
97
|
|
|
34
98
|
/**
|
|
35
|
-
* Validates MX hostname against MTA-STS policy
|
|
99
|
+
* Validates MX hostname against MTA-STS policy.
|
|
100
|
+
* This does not look at `policy.expires`, use `getPolicy` to refresh the policy.
|
|
36
101
|
*
|
|
37
102
|
* @param mx - MX hostname to validate
|
|
38
103
|
* @param policy - MTA-STS policy
|
|
104
|
+
* @param opts - Validation options
|
|
39
105
|
* @returns Validation result
|
|
40
106
|
*/
|
|
41
|
-
export function validateMx(mx: string, policy: MTASTSPolicy): MTASTSValidationResult;
|
|
107
|
+
export function validateMx(mx: string, policy: MTASTSPolicy, opts?: MTASTSValidateOptions): MTASTSValidationResult;
|
|
42
108
|
|
|
43
109
|
/**
|
|
44
110
|
* Gets complete MTA-STS policy for a domain
|
|
45
111
|
* Resolves DNS, fetches policy file, and handles caching
|
|
46
112
|
*
|
|
47
|
-
* @param domain - Domain name
|
|
48
|
-
* @param knownPolicy - Currently cached policy
|
|
113
|
+
* @param domain - Domain name or email address
|
|
114
|
+
* @param knownPolicy - Currently cached policy, the `policy` value of an earlier result
|
|
49
115
|
* @param opts - MTA-STS options
|
|
50
|
-
* @returns Policy fetch result
|
|
116
|
+
* @returns Policy fetch result, store its `policy` value as the new cached policy
|
|
51
117
|
*/
|
|
52
|
-
export function getPolicy(domain: string, knownPolicy?: MTASTSPolicy, opts?: MTASTSOptions): Promise<MTASTSPolicyResult>;
|
|
118
|
+
export function getPolicy(domain: string, knownPolicy?: MTASTSPolicy | null, opts?: MTASTSOptions): Promise<MTASTSPolicyResult>;
|