Socket
Socket
Sign inDemoInstall

legit

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 1.0.0

src/index.js

16

example/check_email.js

@@ -1,10 +0,8 @@

const legit = require('../index.js');
const legit = require("../src/index.js");
legit('martyn@martyndavies.me', function(err, validation, addresses) {
if (validation == true) {
console.log('This is a real email that can accept emails!');
console.log(JSON.stringify(addresses));
} else {
console.log('This domain cannot accept emails, you might want to remove it.');
}
});
legit("martyn@martyndavies.me")
.then(result => {
console.log("This is a real email that can accept emails!");
console.log(JSON.stringify(result));
})
.catch(err => console.log("This domain cannot accept emails."));
{
"name": "legit",
"version": "0.0.7",
"version": "1.0.0",
"description": "Check that email addresses are really able to accept emails by pinging the DNS and checking for active MX records.",
"main": "index.js",
"main": "./src/index.js",
"respository": "https://github.com/martyndavies/legit",
"devDependencies":{
"devDependencies": {
"should": "*",

@@ -9,0 +9,0 @@ "mocha": "*"

@@ -15,17 +15,17 @@ # Legit

```javascript
const legit = require('legit');
const legit = require("../src/index.js");
legit('martyn@martyndavies.me', function(err, validation, addresses) {
if (validation == true) {
console.log('This is a real email that can accept emails!')
console.log(JSON.stringify(addresses))
} else {
console.log('Error: '+ err)
}
});
legit("martyn@martyndavies.me")
.then(result => {
console.log("This is a real email that can accept emails!");
console.log(JSON.stringify(result));
})
.catch(err => console.log("This domain cannot accept emails."));
```
If an email addresses domain is legit then the `validation` will be true and an array of MX records will be returned as well. If the domain has no MX or cannot resolve any MX then it will return false and the `addresses` will be `null`.
If an email addresses domain is legit then the object returned will include an `isValid` key that will be set to `true` as well as an `mxArray` key with all the MX record information for the valid domain.
If the domain has no MX or cannot resolve any MX then it will return `isValid`, along with `errors`.
## License

@@ -35,3 +35,3 @@

Copyright (c) 2015-2017 Martyn Davies, and contributors.
Copyright (c) 2015-2018 Martyn Davies, and contributors.

@@ -38,0 +38,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@@ -1,24 +0,21 @@

const assert = require('assert');
const should = require('should');
const legit = require('../');
const assert = require("assert");
const should = require("should");
const legit = require("../src");
describe('Testing Emails', function(){
describe('Email is legit', function(){
it('should return true when email is legit', function(){
legit('martyn@martyndavies.me', function(err, validation, addresses){
validation.should.be.true;
should.exist(addresses);
});
});
});
describe("Testing Emails", function() {
describe("Email is legit", function() {
it("should return true when email is legit", function() {
legit("martyn@martyndavies.me").then(
result => result.isValid.should.be.true && should.exist(result.mxArray)
);
});
});
describe('Email is not legit', function(){
it('should return false when email is not legit', function(){
legit('nosir@neverwouldibuythisdomainladdyohno.com', function(err, validation, addresses){
validation.should.be.false;
should.not.exist(addresses);
should.exist(err);
});
});
});
describe("Email is not legit", function() {
it("should return false when email is not legit", function() {
legit("nosir@neverwouldibuythisdomainladdyohno.com")
.then(result => result.isValid.should.not.exist)
.catch(err => should.exist(err.errors));
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc