@the_binod/disposable-email-check
v1.0.3
Published
Detect disposable/temporary email addresses
Maintainers
Readme
Disposable Email Check
Detect disposable/temporary email addresses with a simple utility function.
Features
- Fast lookup using a Map of blocked domains
- Easy integration in any Node.js or TypeScript project
- Includes a comprehensive list of disposable email domains
Installation
Using pnpm:
pnpm add @the_binod/disposable-email-checkUsing npm:
npm install @the_binod/disposable-email-checkUsing yarn:
yarn add @the_binod/disposable-email-checkUsage
Basic Example
import { isDisposableEmail } from '@the_binod/disposable-email-check';
console.log(isDisposableEmail('[email protected]')); // true
console.log(isDisposableEmail('[email protected]')); // falseAPI Integration Example
import { isDisposableEmail } from '@the_binod/disposable-email-check';
function handleRegistration(email: string) {
if (isDisposableEmail(email)) {
throw new Error('Disposable email addresses are not allowed.');
}
// Proceed with registration...
}Batch Checking Example
import { isDisposableEmail } from '@the_binod/disposable-email-check';
const emails = [
'[email protected]',
'[email protected]',
'[email protected]',
];
const results = emails.map(email => ({
email,
isDisposable: isDisposableEmail(email),
}));
console.table(results);API
isDisposableEmail(email: string): boolean
Checks if the given email address is from a known disposable domain.
- email: The email address to check.
- Returns:
trueif the domain is disposable,falseotherwise.
Blocklist
The blocklist of disposable domains is maintained in src/block_domains.json.
Updating the Blocklist
Edit
src/block_domains.jsonand add or remove domains as needed (one per line, as a JSON array).Rebuild the package:
pnpm run build(Optional) Run tests to ensure everything works:
pnpm exec vitest run
Testing
To run the unit tests:
pnpm install
pnpm exec vitest runContributing
Contributions are welcome! To contribute:
- Fork this repository
- Create a new branch for your feature or fix
- Make your changes (add tests if possible)
- Run tests to verify
- Submit a pull request with a clear description
For major changes, please open an issue first to discuss what you would like to change.
Coding Standards
- Use TypeScript
- Write clear, concise commit messages
- Add or update tests for new features or bug fixes
Changelog
1.0.1
- Initial release with Map-based lookup
- Comprehensive blocklist
- Unit tests with Vitest
Contact & Support
For questions, issues, or feature requests:
- Open an issue on the GitHub repository
- Or contact Binod Shrestha
License
MIT
