Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Email validation with more than 10K disposable/temporary email domains
Email Validation is a library that validates email addresses and checks againts more than 10K domains used for disposable emails
If you want to block disposable email addresses at signup, or if you are a B2B company and want only professional email adresses, this is the solution for you :)
This library does multiple verifications:
Email Validation has 0 dependency, 100% coverage, and is fully configurable.
Install using npm
:
npm install emailvalid
or Yarn yarn
:
yarn add emailvalid
Email Validation is initialized with a list of default domains
const EmailValidation = require('emailvalid')
const ev = new EmailValidation()
// This email will be invalid because it is a free email
const result = ev.check('random@gmail.com')
console.log(`${result.email} validity: ${result.valid}`)
// This email will be invalid because it is a disposable email
const result2 = ev.check('iamadisposableemail@yopmail.com')
console.log(`${result2.email} validity: ${result2.valid}`)
// You can also check for possible typos
const result3 = ev.check('john@gmil.com')
if (result3.typo) console.log(`Did you mean ${result3.typo}?`)
The output will be an object with some information on the validity (see result section)
Email Validation can be configured with more advanced options as an object:
whitelist
(Array) Add some email domains you want to whitelist (default is [])blacklist
(Array) Add some email domains you want to blacklist (default is [])allowFreemail
(Boolean) Allow free emails such as @gmail.com, ... (default is false)allowDisposable
(Boolean) Allow disposable emails such as @trashmail.com, ... (default is false)You can for example choose to allow freemails, and add a domain baddomain.com in addition to the preconfigured list
const EmailValidation = require('emailvalid')
const ev = new EmailValidation({ allowFreemail: true, blacklist: ['baddomain.com'] })
// This one should have result.valid = true because we allowed free mails such as gmail.com
ev.check('random@gmail.com')
// But this one is blacklisted now
ev.check('paul@baddomain.com')
Or if you want to disallow all free mails, except gmail.com :
const ev = new EmailValidation({ whitelist: ['gmail.com'] })
You can check some examples in example.js
In case you need to update options after initialization, you can do it on the fly with different methods:
whitelist
(Function) Add a new domain to the whitelistblacklist
(Function) Add a new domain to the blacklistsetOptions
(Function) Changes the optionsconst EmailValidation = require('emailvalid')
const ev = new EmailValidation()
// This adds a new domain as invalid
ev.blacklist('baddomain.com')
// This marks a domain as valid
ev.whitelist('gooddomain.com')
// This changes options to allow freemails
ev.setOptions({ allowFreemail: true })
Email Validation will output an object with the following information:
email
(String) Email in a standardized format (trimed and lowercased)domain
(String) Domain from the emailvalid
(Boolean) Is the email address valid?errors
(Array) List of errors if anytypo
(String) Is there any possible typo in the email?Errors contains strings and can be one of :
invalid
Email is not present of format is invaliddisposable
Email is disposable (and not whitelisted or allowed in parameters)freemail
Email is a free mail (and not whitelisted or allowed in parameters)blacklisted
Email is blacklisted in parametersconst EmailValidation = require('emailvalid')
const ev = new EmailValidation()
const result = ev.check('RANDOM@gmail.com')
console.log(result)
// This will return :
// {
// email: 'random@gmail.com',
// domain: 'gmail.com'
// valid: false,
// errors: ['freemail'],
// typo: null
// {
If you need a simple way to add domains to the list, just run yarn add-domain [DOMAIN] [CATEGORY]
For example yarn add-domain freemail gmail.com
Then feel free to create Pull Requests :)
FAQs
Email validation with more than 10K disposable/temporary email domains
The npm package emailvalid receives a total of 2,815 weekly downloads. As such, emailvalid popularity was classified as popular.
We found that emailvalid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.