mailauth 4.11.0 → 4.12.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 +12 -0
- package/README.md +3 -0
- package/cli.md +3 -0
- package/eslint.config.js +7 -4
- package/index.d.ts +1354 -0
- package/lib/arc/index.d.ts +47 -0
- package/lib/bimi/index.d.ts +20 -0
- package/lib/dkim/sign.d.ts +33 -0
- package/lib/dkim/verify.d.ts +12 -0
- package/lib/dmarc/index.d.ts +11 -0
- package/lib/mailauth.js +13 -3
- package/lib/mta-sts.d.ts +52 -0
- package/lib/mta-sts.js +1 -1
- package/lib/spf/index.d.ts +11 -0
- package/package.json +11 -10
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/arc
|
|
2
|
+
|
|
3
|
+
import { MessageInput, ARCData, ARCOptions, ARCResult, ARCSealOptions, ARCChainEntry } from '../../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Verifies ARC chain in a message
|
|
7
|
+
*
|
|
8
|
+
* @param data - ARC chain data
|
|
9
|
+
* @param opts - ARC verification options
|
|
10
|
+
* @returns ARC verification result
|
|
11
|
+
*/
|
|
12
|
+
export function arc(data: ARCData, opts?: ARCOptions): Promise<ARCResult>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Seals a message with ARC headers
|
|
16
|
+
*
|
|
17
|
+
* @param input - RFC822 formatted message (stream, buffer, or string)
|
|
18
|
+
* @param seal - ARC sealing options
|
|
19
|
+
* @returns ARC headers to prepend
|
|
20
|
+
*/
|
|
21
|
+
export function sealMessage(input: MessageInput, seal: ARCSealOptions): Promise<Buffer>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gets ARC chain from parsed headers
|
|
25
|
+
*
|
|
26
|
+
* @param headers - Parsed message headers
|
|
27
|
+
* @returns ARC chain or false if no chain found
|
|
28
|
+
*/
|
|
29
|
+
export function getARChain(headers: any): ARCChainEntry[] | false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Verifies ARC seal chain
|
|
33
|
+
*
|
|
34
|
+
* @param data - ARC chain data
|
|
35
|
+
* @param opts - ARC verification options
|
|
36
|
+
* @returns true if chain is valid
|
|
37
|
+
*/
|
|
38
|
+
export function verifyASChain(data: ARCData, opts: ARCOptions): Promise<boolean>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates ARC seal headers
|
|
42
|
+
*
|
|
43
|
+
* @param input - RFC822 formatted message or false for pre-calculated data
|
|
44
|
+
* @param data - Seal creation data
|
|
45
|
+
* @returns Seal headers
|
|
46
|
+
*/
|
|
47
|
+
export function createSeal(input: MessageInput | false, data: any): Promise<{ headers: string[] }>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/bimi
|
|
2
|
+
|
|
3
|
+
import { BIMIOptions, BIMIResult, BIMIData, VMCValidationOptions, VMCValidationResult } from '../../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves BIMI record and logo location for a domain
|
|
7
|
+
*
|
|
8
|
+
* @param opts - BIMI lookup options
|
|
9
|
+
* @returns BIMI verification result
|
|
10
|
+
*/
|
|
11
|
+
export function bimi(opts: BIMIOptions): Promise<BIMIResult | false>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validates BIMI VMC (Verified Mark Certificate) and logo file
|
|
15
|
+
*
|
|
16
|
+
* @param bimiData - BIMI data including location and authority URLs
|
|
17
|
+
* @param opts - VMC validation options
|
|
18
|
+
* @returns VMC validation result
|
|
19
|
+
*/
|
|
20
|
+
export function validateVMC(bimiData: BIMIData | null, opts?: VMCValidationOptions): Promise<VMCValidationResult | false>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/dkim/sign
|
|
2
|
+
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
|
|
5
|
+
import { Transform } from 'stream';
|
|
6
|
+
import { MessageInput, DKIMSignOptions, DKIMSignResult } from '../../index';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Signs an email message with DKIM signature(s)
|
|
10
|
+
*
|
|
11
|
+
* @param input - RFC822 formatted message (stream, buffer, or string)
|
|
12
|
+
* @param options - DKIM signing options
|
|
13
|
+
* @returns DKIM signature header(s) and any errors
|
|
14
|
+
*/
|
|
15
|
+
export function dkimSign(input: MessageInput, options: DKIMSignOptions): Promise<DKIMSignResult>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transform stream for DKIM signing
|
|
19
|
+
* Prepends DKIM-Signature header to the message stream
|
|
20
|
+
*/
|
|
21
|
+
export class DkimSignStream extends Transform {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a DKIM signing stream
|
|
24
|
+
*
|
|
25
|
+
* @param options - DKIM signing options
|
|
26
|
+
*/
|
|
27
|
+
constructor(options: DKIMSignOptions);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Any errors encountered during signing
|
|
31
|
+
*/
|
|
32
|
+
errors: Error[] | null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/dkim/verify
|
|
2
|
+
|
|
3
|
+
import { MessageInput, DKIMVerifyOptions, DKIMVerifyResult } from '../../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Verifies DKIM signatures in an email message
|
|
7
|
+
*
|
|
8
|
+
* @param input - RFC822 formatted message (stream, buffer, or string)
|
|
9
|
+
* @param options - DKIM verification options
|
|
10
|
+
* @returns DKIM verification results
|
|
11
|
+
*/
|
|
12
|
+
export function dkimVerify(input: MessageInput, options?: DKIMVerifyOptions): Promise<DKIMVerifyResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/dmarc
|
|
2
|
+
|
|
3
|
+
import { DMARCOptions, DMARCResult } from '../../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Verifies DMARC policy for a message
|
|
7
|
+
*
|
|
8
|
+
* @param opts - DMARC verification options
|
|
9
|
+
* @returns DMARC verification result
|
|
10
|
+
*/
|
|
11
|
+
export function dmarc(opts: DMARCOptions): Promise<DMARCResult | false>;
|
package/lib/mailauth.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { dkimSign, DkimSignStream } = require('./dkim/sign');
|
|
3
4
|
const { dkimVerify } = require('./dkim/verify');
|
|
4
5
|
const { spf } = require('./spf');
|
|
5
6
|
const { dmarc } = require('./dmarc');
|
|
6
|
-
const { arc, createSeal } = require('./arc');
|
|
7
|
+
const { arc, createSeal, sealMessage, getARChain, verifyASChain } = require('./arc');
|
|
7
8
|
const { bimi, validateVMC: validateBimiVmc } = require('./bimi');
|
|
8
9
|
const { validateSvg: validateBimiSvg } = require('./bimi/validate-svg');
|
|
9
10
|
const { parseReceived } = require('./parse-received');
|
|
10
|
-
const { sealMessage } = require('./arc');
|
|
11
11
|
const libmime = require('libmime');
|
|
12
12
|
const os = require('node:os');
|
|
13
13
|
const { isIP } = require('net');
|
|
@@ -30,7 +30,7 @@ const { isIP } = require('net');
|
|
|
30
30
|
* @param {Boolean} [opts.disableArc=false] If true then do not perform ARC validation and sealing
|
|
31
31
|
* @param {Boolean} [opts.disableDmarc=false] If true then do not perform DMARC check
|
|
32
32
|
* @param {Boolean} [opts.disableBimi=false] If true then do not perform BIMI check
|
|
33
|
-
* @returns
|
|
33
|
+
* @returns Authentication result
|
|
34
34
|
*/
|
|
35
35
|
const authenticate = async (input, opts) => {
|
|
36
36
|
opts = Object.assign({}, opts); // copy keys
|
|
@@ -191,7 +191,17 @@ const authenticate = async (input, opts) => {
|
|
|
191
191
|
|
|
192
192
|
module.exports = {
|
|
193
193
|
authenticate,
|
|
194
|
+
dkimSign,
|
|
195
|
+
DkimSignStream,
|
|
196
|
+
dkimVerify,
|
|
197
|
+
spf,
|
|
198
|
+
dmarc,
|
|
199
|
+
arc,
|
|
194
200
|
sealMessage,
|
|
201
|
+
getARChain,
|
|
202
|
+
verifyASChain,
|
|
203
|
+
createSeal,
|
|
204
|
+
bimi,
|
|
195
205
|
validateBimiVmc,
|
|
196
206
|
validateBimiSvg
|
|
197
207
|
};
|
package/lib/mta-sts.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/mta-sts
|
|
2
|
+
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
|
|
5
|
+
import { MTASTSOptions, MTASTSPolicy, MTASTSPolicyResult, MTASTSValidationResult } from '../index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolves MTA-STS policy ID from DNS
|
|
9
|
+
*
|
|
10
|
+
* @param address - Email address or domain name
|
|
11
|
+
* @param opts - MTA-STS options
|
|
12
|
+
* @returns Policy ID or false if not found
|
|
13
|
+
*/
|
|
14
|
+
export function resolvePolicy(address: string, opts?: MTASTSOptions): Promise<string | false>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Fetches and parses MTA-STS policy file from HTTPS
|
|
18
|
+
*
|
|
19
|
+
* @param domain - Domain name
|
|
20
|
+
* @param opts - MTA-STS options
|
|
21
|
+
* @returns Parsed policy or false if not found
|
|
22
|
+
*/
|
|
23
|
+
export function fetchPolicy(domain: string, opts?: MTASTSOptions): Promise<MTASTSPolicy | false>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parses MTA-STS policy file content
|
|
27
|
+
*
|
|
28
|
+
* @param file - Policy file content
|
|
29
|
+
* @returns Parsed policy
|
|
30
|
+
* @throws Error if policy is invalid
|
|
31
|
+
*/
|
|
32
|
+
export function parsePolicy(file: Buffer | string): MTASTSPolicy;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validates MX hostname against MTA-STS policy
|
|
36
|
+
*
|
|
37
|
+
* @param mx - MX hostname to validate
|
|
38
|
+
* @param policy - MTA-STS policy
|
|
39
|
+
* @returns Validation result
|
|
40
|
+
*/
|
|
41
|
+
export function validateMx(mx: string, policy: MTASTSPolicy): MTASTSValidationResult;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Gets complete MTA-STS policy for a domain
|
|
45
|
+
* Resolves DNS, fetches policy file, and handles caching
|
|
46
|
+
*
|
|
47
|
+
* @param domain - Domain name
|
|
48
|
+
* @param knownPolicy - Currently cached policy
|
|
49
|
+
* @param opts - MTA-STS options
|
|
50
|
+
* @returns Policy fetch result
|
|
51
|
+
*/
|
|
52
|
+
export function getPolicy(domain: string, knownPolicy?: MTASTSPolicy, opts?: MTASTSOptions): Promise<MTASTSPolicyResult>;
|
package/lib/mta-sts.js
CHANGED
|
@@ -22,7 +22,7 @@ const resolvePolicy = async (address, opts) => {
|
|
|
22
22
|
|
|
23
23
|
address = (address || '').toString();
|
|
24
24
|
let atPos = address.indexOf('@');
|
|
25
|
-
let domain = atPos < 0 ? address :
|
|
25
|
+
let domain = atPos < 0 ? address : address.substr(atPos + 1);
|
|
26
26
|
if (/[\x7e-\xff]/.test(domain)) {
|
|
27
27
|
// high bytes, probably U-label
|
|
28
28
|
try {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Type definitions for mailauth/lib/spf
|
|
2
|
+
|
|
3
|
+
import { SPFOptions, SPFResult } from '../../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Verifies SPF for a sender
|
|
7
|
+
*
|
|
8
|
+
* @param opts - SPF verification options
|
|
9
|
+
* @returns SPF verification result
|
|
10
|
+
*/
|
|
11
|
+
export function spf(opts: SPFOptions): Promise<SPFResult>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailauth",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Email authentication library for Node.js",
|
|
5
5
|
"main": "lib/mailauth.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "eslint \"lib/**/*.js\" \"test/**/*.js\" && mocha --recursive \"./test/**/*.js\" --reporter spec",
|
|
8
9
|
"format": "prettier --write .",
|
|
@@ -34,25 +35,25 @@
|
|
|
34
35
|
"homepage": "https://github.com/postalsys/mailauth",
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"chai": "4.4.1",
|
|
37
|
-
"eslint": "9.
|
|
38
|
+
"eslint": "9.39.2",
|
|
38
39
|
"eslint-config-nodemailer": "1.2.0",
|
|
39
40
|
"eslint-config-prettier": "10.1.8",
|
|
40
|
-
"js-yaml": "4.1.
|
|
41
|
+
"js-yaml": "4.1.1",
|
|
41
42
|
"license-report": "6.8.1",
|
|
42
43
|
"mbox-reader": "1.2.0",
|
|
43
|
-
"mocha": "11.7.
|
|
44
|
-
"prettier": "
|
|
45
|
-
"resedit": "
|
|
44
|
+
"mocha": "11.7.5",
|
|
45
|
+
"prettier": "3.7.4",
|
|
46
|
+
"resedit": "3.0.1"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@postalsys/vmc": "1.1.2",
|
|
49
50
|
"fast-xml-parser": "4.5.2",
|
|
50
|
-
"ipaddr.js": "2.
|
|
51
|
-
"joi": "18.0.
|
|
51
|
+
"ipaddr.js": "2.3.0",
|
|
52
|
+
"joi": "18.0.2",
|
|
52
53
|
"libmime": "5.3.7",
|
|
53
|
-
"nodemailer": "7.0.
|
|
54
|
+
"nodemailer": "7.0.11",
|
|
54
55
|
"punycode.js": "2.3.1",
|
|
55
|
-
"tldts": "7.0.
|
|
56
|
+
"tldts": "7.0.19",
|
|
56
57
|
"undici": "7.16.0",
|
|
57
58
|
"yargs": "17.7.2"
|
|
58
59
|
},
|