vanitizer
v0.0.8
Published
create organization centric vanity urls from email addresses
Downloads
2
Maintainers
Readme
Vanity URL generator from email
Vanity urls are a way to segment your users in your web application, usually by organization or community, for the purposes of allowing group discovery and personalization.
These generally work utilizing wildcard records allowing organization names to be placed before the websites fully qualified domain name. These generally follow the format:
{testing}.mydomain.com
for example:
- coke.koan.co
- newrelic.koan.co
Vanitizer is a simple library of tools to support the creation of organization style vanity urls based on email address. Vaniztizer also has some small support for organization detection for Google App's SSO.
Install
vanitizer is available using npm:
npm install --save vanitizer
Usage
const {
isGoogleEmail,
isDisposableEmail,
isFreeEmail,
isWorkEmail,
getDomains,
} = require('vanitizer');
// Returns domains based on email
const opts = {
logger, // uses DEBUG lib by defaul
wordWhitelist, // json object format: ({ "candidate_name": true })
wordBlacklist, // json object format: ({ "candidate_name2": true })
domainBlacklist, // json object format: ({ "candidate.com": true })
domainWhitelist, // json object format: ({ "candidate2.com": true })
}; // can be undefined
getDomains(opts)('[email protected]'); // returns { domains: [ 'koan', 'koan-co' ], status: true, err: null }
getDomains(opts)('[email protected]'); // { domains: [ 'koan', 'koan-co' ], status: true, err: null }
getDomains('[email protected]'); // returns { domains: [ 'koan', 'koan-co-uk' ], status: true, err: null }
getDomains('koan.co'); //
// Is a work email address
isWorkEmail('[email protected]'); // returns { status: true, error: null }
isWorkEmail('[email protected]'); // returns { status: false, error: null }
isWorkEmail('asdf@koan'); // returns { status: false, error: 'invalid_email' }
// Is a free email address
isFreeEmail('[email protected]'); // returns { status: false, error: null }
isFreeEmail('[email protected]'); // returns { status: true, error: null }
// Is a disposable email address
isDisposableEmail('[email protected]'); // returns { status: false, error: null }
isDisposableEmail('[email protected]'); // returns { status: true, error: null }
// Is a ISP provided email address
isIspEmail('[email protected]'); // returns { status: true, error: null }
isIspEmail('[email protected]'); // returns { status: false, error: null }
// Is a google email address
isGoogleEmail('[email protected]'); // returns { status: true, error: null }
isGoogleEmail('[email protected]'); // returns { status: true, error: null }
Credits & Content
- https://github.com/FGRibreau/mailchecker
- https://github.com/andreis/disposable-email-domains
- https://gist.github.com/gitaarik/5974153
- https://gist.github.com/michenriksen/8710649
- https://github.com/ivolo/disposable-email-domains
- https://github.com/wesbos/burner-email-providers
- https://gist.github.com/tbrianjones/5992856