# @types/spf-parse

> TypeScript definitions for spf-parse

Latest version **1.0.0** (published 2025-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/spf-parse
pnpm add @types/spf-parse
yarn add @types/spf-parse
bun add @types/spf-parse
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-11-16 |
| First published | 2025-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51348 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/spf-parse
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spf-parse
- npm.io page: https://npm.io/package/@types/spf-parse

## Recent versions

- 1.0.0 (latest) — 2025-11-16

## README

# Installation
> `npm install --save @types/spf-parse`

# Summary
This package contains type definitions for spf-parse (https://github.com/softvu/spf-parse#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spf-parse.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/spf-parse/index.d.ts)
````ts
export = spfParse;

declare namespace spfParse {
    /** Qualifer prefix characters */
    type Prefix = "+" | "-" | "~" | "?" | "v";

    /** Prefix descriptions */
    interface PrefixDescriptions {
        "+": "Pass";
        "-": "Fail";
        "~": "SoftFail";
        "?": "Neutral";
        v?: string;
    }

    /** A single parsed SPF mechanism */
    interface Mechanism {
        /** Mechanism type, e.g. 'ip4', 'mx', 'all' */
        type: string;

        /** Optional value associated with the mechanism (domain, IP, etc.) */
        value?: string;

        /** The qualifier prefix */
        prefix: Prefix;

        /** Human-readable description of the prefix */
        prefixdesc?: string;

        /** Human-readable description of the mechanism */
        description?: string;
    }

    /** Parse message (warning or error) */
    interface ParseMessage {
        /** Text of the message */
        message: string;

        /** Message type: error or warning */
        type: "error" | "warning";
    }

    /** Result of parsing a single SPF record */
    interface ParseResult {
        /** Parsed mechanisms */
        mechanisms: Mechanism[];

        /** Validation messages */
        messages?: ParseMessage[];

        /** True if record parsed successfully */
        valid: boolean;
    }

    /** Error thrown by mechanism validators */
    class MechanismError extends Error {
        /** Error type */
        type: "warning" | "error";
        constructor(message: string, type?: "warning" | "error");
    }

    /**
     * Parse a single SPF term (e.g. "+ip4:192.0.2.0/24")
     * @param term SPF term string
     * @param messages Message array to push validation errors/warnings into
     * @returns Parsed mechanism record
     */
    function parseTerm(term: string, messages: ParseMessage[]): Mechanism;
}

/**
 * Parse a full SPF record string (e.g. "v=spf1 include:some.sender.org -all")
 * @param record SPF record string
 * @returns Structured parse result
 */
declare function spfParse(record: string): spfParse.ParseResult;

````

### Additional Details
 * Last updated: Sun, 16 Nov 2025 00:47:04 GMT
 * Dependencies: none

# Credits
These definitions were written by [ultraslayyy](https://github.com/ultraslayyy).

---
_Source: https://npm.io/package/@types/spf-parse · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
