Skip to content

Latest commit

 

History

History
172 lines (129 loc) · 5.52 KB

readme.md

File metadata and controls

172 lines (129 loc) · 5.52 KB

NPM

Codefresh build status

node-opendkim

node.js native language binding to libopendkim

Install/Test Locally (from source)

git clone git@github.com:godsflaw/node-opendkim.git
cd node-opendkim
npm install
npm test -- --verbose

Install Locally (npm)

npm install --save node-opendkim

Install Globally (npm)

npm install --global node-opendkim

Compile (Development)

node-gyp rebuild


Usage

Verify (async/await)

const OpenDKIM = require('node-opendkim');

async function verify(message) {
  var opendkim = new OpenDKIM();

  try {
    await opendkim.verify({id: undefined});
    await opendkim.chunk({
      message: message,
      length: message.length
    });
    await opendkim.chunk_end();
  } catch (err) {
    console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
    console.log(err);
  }
}

Verify (sync)

const OpenDKIM = require('node-opendkim');

function verify_sync(message) {
  var opendkim = new OpenDKIM();

  try {
    opendkim.verify_sync({id: undefined});
    opendkim.chunk_sync({
      message: message,
      length: message.length
    });
    opendkim.chunk_end_sync();
  } catch (err) {
    console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
    console.log(err);
  }
}

Verify (errback)

const OpenDKIM = require('node-opendkim');

function verify(opendkim, message, callback) {
  opendkim.verify({id: undefined}, function (err, result) {
    if (err) {
      return callback(err, result);
    }

    var options = {
      message: message,
      length: message.length
    };

    opendkim.chunk(options, function (err, result) {
      if (err) {
        return callback(err, result);
      }

      opendkim.chunk_end(function (err, result) {
        if (err) {
          return callback(err, result);
        }

        return callback(err, result);
      });
    });
  });
}

var opendkim = new OpenDKIM();

verify(opendkim, message, function (err, result) {
  if (err) {
    return console.log(opendkim.sig_geterrorstr(opendkim.sig_geterror()));
  }

  // success
});

API Administration

API Processing

API Signing

API Utility

API Verifying


License

MIT © Christopher Mooney