Git Product home page Git Product logo

dkimpy's Introduction

dkimpy

build status code coverage code style styled with prettier made with lass license npm downloads

Node.js wrapper around the Python pip package dkimpy exposing DKIM and ARC signing and verification functions

Table of Contents

Requirements

  1. Ensure that you have a Python version of >= 3.5 installed per dkimpy requirements (note that Python v3 is required because of a bug with DNS recursive CNAME lookups on v2.7):

    python3 --version
  2. Install the package dkimpy and authres (authres is optional and used for ARC):

    pip3 install dkimpy authres

Install

npm:

npm install dkimpy

yarn:

yarn add dkimpy

Usage

dkimVerify

const fs = require('fs');

const { dkimVerify } = require('dkimpy');

const message = fs.readFileSync('/path/to/example.eml');

// then/catch usage
dkimVerify(message)
  .then(console.log)
  .catch(console.error);

// async/await usage
(async () => {
  try {
    const result = await dkimVerify(message)
    console.log(result);
  } catch (err) {
    console.error(err);
  }
})();

The value of result is a Boolean which indicates if DKIM verification was successful for the first DKIM-Signature header found on the email.

You can pass a second argument of index (defaults to 0, which means it looks for the first DKIM-Signature found).

arcVerify

const fs = require('fs');

const { arcVerify } = require('dkimpy');

const message = fs.readFileSync('/path/to/example.eml');

// then/catch usage
arcVerify(message)
  .then(console.log)
  .catch(console.error);

// async/await usage
(async () => {
  try {
    const result = await arcVerify(message)
    console.log(result);
  } catch (err) {
    console.error(err);
  }
})();

The value of result is an enumerable String which is one of:

  • "none" indicates it does not have an ARC signature
  • "pass" indicates its ARC signature was verified successfully
  • "fail" indicates it had an ARC signature and it failed verification

arcSign

const fs = require('fs');

const { arcSign } = require('dkimpy');

const message = fs.readFileSync('/path/to/example.eml');
const selector = 'default'; // default._domainkey
const domain = 'example.com';
const srvId = 'mx.example.com';
const privateKeyFile = '/path/to/private.key';

// then/catch usage
arcSign(message, selector, domain, privateKeyFile, srvId)
  .then(console.log)
  .catch(console.error);

// async/await usage
(async () => {
  try {
    const result = await arcSign(message, selector, domain, privateKeyFile, srvId)
    console.log(result);
  } catch (err) {
    console.error(err);
  }
})();

The value of result is a String with the new ARC headers to add to the top of the message (if any).

Contributors

Name Website
Nick Baugh http://niftylettuce.com/

License

MIT © Nick Baugh

dkimpy's People

Contributors

niftylettuce avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.