disposable-email-domain 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ /** Sorted list of known disposable / temporary email domains. */
2
+ export declare const domains: readonly string[];
3
+ /**
4
+ * Returns true if the email's domain is a known disposable email domain.
5
+ * Accepts a full address ("foo@mailinator.com") or a bare domain
6
+ * ("mailinator.com"). Case-insensitive.
7
+ */
8
+ export declare function isDisposable(email: string): boolean;
9
+ declare const _default: {
10
+ domains: readonly string[];
11
+ isDisposable: typeof isDisposable;
12
+ };
13
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.domains = void 0;
4
+ exports.isDisposable = isDisposable;
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ // domains.json is shipped alongside the package (see package.json "files").
8
+ // At runtime dist/index.js sits in dist/, so the list is one level up.
9
+ const domainsData = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "..", "domains.json"), "utf8"));
10
+ /** Sorted list of known disposable / temporary email domains. */
11
+ exports.domains = domainsData;
12
+ const domainSet = new Set(domainsData);
13
+ /**
14
+ * Returns true if the email's domain is a known disposable email domain.
15
+ * Accepts a full address ("foo@mailinator.com") or a bare domain
16
+ * ("mailinator.com"). Case-insensitive.
17
+ */
18
+ function isDisposable(email) {
19
+ const at = email.lastIndexOf("@");
20
+ const domain = (at === -1 ? email : email.slice(at + 1)).trim().toLowerCase();
21
+ return domainSet.has(domain);
22
+ }
23
+ exports.default = { domains: exports.domains, isDisposable };