disposable-email-blocker
v1.3.0
Published
Detect and Block if new account registrations are using disposable email services with javascript.
Downloads
24
Maintainers
Readme
🛡️ Disposable email blocker
Detect and Block if new account registrations are using disposable email services with javascript.
The Disposable email blocker provide :
- 🛡️ Protects all HTML forms.
- 🛡️ Detects invalid email addresses and domains
- 🛡️ Blocks disposable email services
- 🛡️ Blocks webmail email services
- 🛡️ Custom error messages
- 🛡️ Disposable data daily updates to stay ahead of fake users
How to use
Use in browser
To use via a CDN include this in your HTML.
Using jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/disposable-email-blocker/disposable-email-blocker.min.js"></script>
<script>
new Disposable.Blocker();
</script>
or
<script
src="https://cdn.jsdelivr.net/npm/disposable-email-blocker/disposable-email-blocker.min.js"
block
></script>
Using unpkg CDN:
<script src="https://unpkg.com/disposable-email-blocker/disposable-email-blocker.min.js"></script>
<script>
new Disposable.Blocker();
</script>
or
<script
src="https://cdn.jsdelivr.net/npm/disposable-email-blocker/disposable-email-blocker.min.js"
block
></script>
Customizing Blocker
The Blocker constructor parameter.
Simple options
const defaults = {
apiUrl: 'string',
data: 'TombaStatusResponse[]',
disposable: {
message: 'string',
},
webmail: {
message: 'string',
block: false,
},
emailError: {
className: 'string',
style: `string`,
},
};
new Disposable.Blocker(defaults);
apiUrl
API URL.data
Data structure.disposable.message
disposable error message.webmail.message
webmail error message.webmail.block
block webmail emails.emailError.className
HTML tag class .emailError.style
css style.
Custom disposable message
To disposable message:
const defaults = {
disposable: {
message:
'Abuses, strongly encourage you to stop using disposable email',
},
};
new Disposable.Blocker(defaults);
Custom webmail message
To webmail message:
const defaults = {
webmail: {
message:
'Warning, You can create an account with this email address, but we strongly encourage you to use a professional email address',
},
};
new Disposable.Blocker(defaults);
Custom API URL
const defaults = {
apiUrl: 'string',
};
new Disposable.Blocker(defaults);
Custom DATA
This will stop API call
const defaults = {
data: [
{
domain: 'coronafleet.com',
webmail: true,
disposable: false,
},
],
};
new Disposable.Blocker(defaults);
Block webmail emails
const defaults = {
webmail: {
block: true,
},
};
new Disposable.Blocker(defaults);
Event
use the on()
API method.
Available Event name done
the Content is revealed on onInput
const blocker = new Blocker();
blocker.on('done', (e: any) => {
if (e.detail.disposable) {
alert(blocker.options.disposable.message);
}
});
Development
For development
Setup
- Clone this repository into it:
git clone https://github.com/tomba-io/disposable-email-blocker.git
cd disposable-email-blocker
yarn
Develop & debug
To start debugging session run:
yarn start
Note that while changes to experiments.ts
are hot-reloaded, changes to template.html
are not.
Note You can set breakpoints in your code and run a debugging session in vsc and other editors.
Build
yarn build
The output is in the /dist
.
Contributing
- Fork it (https://github.com/tomba-io/disposable-email-blocker/fork)
- Create your feature branch (
git checkout -b my-new-email
) - Commit your changes (
git commit -am 'Add new email'
) - Push to the branch (
git push origin my-new-email
) - Create a new Pull Request
Contributors
- Mohamed Ben - creator and maintainer