fakefilter 1.1.13 → 1.1.1582

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.
Files changed (276) hide show
  1. package/LICENSE.md +29 -0
  2. package/README.md +66 -16
  3. package/dist/domainLookup.d.ts +7 -0
  4. package/dist/domainLookup.js +46 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +213 -0
  7. package/dist/json/data.json +1 -0
  8. package/dist/types.d.ts +16 -0
  9. package/dist/types.js +3 -0
  10. package/package.json +37 -42
  11. package/apiserver/api/ext_result.js +0 -51
  12. package/apiserver/api/ext_tasks.js +0 -151
  13. package/apiserver/api/is_fakedomain.js +0 -39
  14. package/apiserver/api/is_fakeemail.js +0 -17
  15. package/apiserver/api/ping.js +0 -12
  16. package/apiserver/docs/README.md +0 -41
  17. package/apiserver/docs/babel.config.js +0 -3
  18. package/apiserver/docs/blog/2019-05-28-first-blog-post.md +0 -12
  19. package/apiserver/docs/blog/2019-05-29-long-blog-post.md +0 -44
  20. package/apiserver/docs/blog/2021-08-01-mdx-blog-post.mdx +0 -20
  21. package/apiserver/docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
  22. package/apiserver/docs/blog/2021-08-26-welcome/index.md +0 -25
  23. package/apiserver/docs/blog/authors.yml +0 -17
  24. package/apiserver/docs/docs/intro.md +0 -16
  25. package/apiserver/docs/docs/nodejs/_category_.json +0 -4
  26. package/apiserver/docs/docs/nodejs/index.md +0 -30
  27. package/apiserver/docs/docs/restful/_category_.json +0 -4
  28. package/apiserver/docs/docs/restful/index.md +0 -59
  29. package/apiserver/docs/docusaurus.config.js +0 -118
  30. package/apiserver/docs/package.json +0 -37
  31. package/apiserver/docs/sidebars.js +0 -31
  32. package/apiserver/docs/src/components/HomepageFeatures/index.js +0 -64
  33. package/apiserver/docs/src/components/HomepageFeatures/styles.module.css +0 -11
  34. package/apiserver/docs/src/css/custom.css +0 -39
  35. package/apiserver/docs/src/pages/index.js +0 -45
  36. package/apiserver/docs/src/pages/index.module.css +0 -23
  37. package/apiserver/docs/src/pages/markdown-page.md +0 -7
  38. package/apiserver/docs/src/theme/IconArrow/index.js +0 -10
  39. package/apiserver/docs/static/.nojekyll +0 -0
  40. package/apiserver/docs/static/img/docusaurus.png +0 -0
  41. package/apiserver/docs/static/img/favicon.ico +0 -0
  42. package/apiserver/docs/static/img/logo.svg +0 -1
  43. package/apiserver/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
  44. package/apiserver/docs/static/img/tutorial/localeDropdown.png +0 -0
  45. package/apiserver/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
  46. package/apiserver/docs/static/img/undraw_docusaurus_react.svg +0 -170
  47. package/apiserver/docs/static/img/undraw_docusaurus_tree.svg +0 -40
  48. package/apiserver/inc/middleware_client.js +0 -37
  49. package/apiserver/inc/middleware_logging.js +0 -17
  50. package/apiserver/inc/shared.js +0 -47
  51. package/apiserver/inc/worker_fakefilter.js +0 -53
  52. package/apiserver/index.js +0 -62
  53. package/apiserver/public/10minemail.com.js +0 -27
  54. package/apiserver/public/10minuteemails.com.js +0 -46
  55. package/apiserver/public/10minutemail.com.js +0 -29
  56. package/apiserver/public/crazymailing.com.js +0 -27
  57. package/apiserver/public/gettempmail.com.js +0 -39
  58. package/apiserver/public/img/dynamic/README.md +0 -0
  59. package/apiserver/public/img/test.html +0 -48
  60. package/apiserver/public/onetempmail.com.js +0 -35
  61. package/apiserver/public/shared.js +0 -54
  62. package/apiserver/public/temp-mail.org.js +0 -28
  63. package/apiserver/public/tempmail.com.tr.js +0 -36
  64. package/apiserver/public/tempmail.net.js +0 -28
  65. package/apiserver/public/tempmailid.com.js +0 -40
  66. package/apiserver/public/tempmailo.org.js +0 -36
  67. package/apiserver/public/throwawaymail.com.js +0 -27
  68. package/burner/README.md +0 -1
  69. package/burner/burner-check.js +0 -57
  70. package/burner/emails.txt +0 -57106
  71. package/chart-update.js +0 -261
  72. package/cleanup.js +0 -58
  73. package/config.js +0 -126
  74. package/demos/visitor0/index.js +0 -41
  75. package/demos/visitor0/renderedDOM.html +0 -8
  76. package/elements/demo.js +0 -78
  77. package/elements/renderedDOM.html +0 -6459
  78. package/elements/screenshots/afterclick.png +0 -0
  79. package/elements/screenshots/goto.png +0 -0
  80. package/events.js +0 -59
  81. package/fetch.js +0 -180
  82. package/models/events.js +0 -37
  83. package/models/harvested.js +0 -45
  84. package/models/harvested_clone.js +0 -44
  85. package/providers/10-minute-mail.com.js +0 -39
  86. package/providers/10-minuten-mail.de.js +0 -39
  87. package/providers/10mails.net.js +0 -41
  88. package/providers/10minut.com.pl.js +0 -39
  89. package/providers/10minut.xyz.js +0 -40
  90. package/providers/10minuteemails.com.js +0 -39
  91. package/providers/10minutemail.co.za.js +0 -39
  92. package/providers/10minutemail.com.js +0 -39
  93. package/providers/10minutemail.info.js +0 -38
  94. package/providers/10minutemail.net.js +0 -38
  95. package/providers/10minutemail.org.js +0 -38
  96. package/providers/10minutesemail.net.js +0 -36
  97. package/providers/10minutesmail.us.js +0 -39
  98. package/providers/1secmail.com.js +0 -39
  99. package/providers/20minutemail.com.js +0 -36
  100. package/providers/22.do.js +0 -25
  101. package/providers/24hour.email.js +0 -37
  102. package/providers/___emailondeck.com.js +0 -76
  103. package/providers/abandonmail.com.js +0 -39
  104. package/providers/airmailbox.website.js +0 -38
  105. package/providers/akmail.in.js +0 -37
  106. package/providers/altaddress.org.js +0 -50
  107. package/providers/altmails.com.js +0 -37
  108. package/providers/anonbox.net.js +0 -42
  109. package/providers/anonmails.de.js +0 -25
  110. package/providers/anonymmail.net.js +0 -47
  111. package/providers/another-temp-mail.com.js +0 -40
  112. package/providers/awgarstone.com.js +0 -15
  113. package/providers/brodilla.email.js +0 -45
  114. package/providers/byom.de.js +0 -42
  115. package/providers/chacuo.net.js +0 -38
  116. package/providers/cryptogmail.com.js +0 -40
  117. package/providers/default.tmail.thehp.in.js +0 -41
  118. package/providers/developermail.com.js +0 -39
  119. package/providers/dispemail.com.js +0 -38
  120. package/providers/disposableemail.co.js +0 -37
  121. package/providers/disposableemail.us.js +0 -37
  122. package/providers/disposablemail.com.js +0 -38
  123. package/providers/disposeamail.com.js +0 -43
  124. package/providers/dispostable.com.js +0 -39
  125. package/providers/dodsi.com.js +0 -38
  126. package/providers/dropmail.me.js +0 -37
  127. package/providers/easytrashmail.com.js +0 -33
  128. package/providers/edumail.icu.js +0 -36
  129. package/providers/email-fake.com.js +0 -35
  130. package/providers/emailfake.com.js +0 -35
  131. package/providers/emailnator.com.js +0 -37
  132. package/providers/etempmail.com.js +0 -36
  133. package/providers/etempmail.net.js +0 -37
  134. package/providers/eyepaste.com.js +0 -39
  135. package/providers/fakemail.io.js +0 -36
  136. package/providers/fakemail.net.js +0 -35
  137. package/providers/fakemailgenerator.com.js +0 -35
  138. package/providers/fakermail.com.js +0 -37
  139. package/providers/faxmail.co.js +0 -47
  140. package/providers/fex.plus.js +0 -38
  141. package/providers/findtempmail.com.js +0 -39
  142. package/providers/foxiomail.com.js +0 -42
  143. package/providers/fyii.de.js +0 -42
  144. package/providers/gecicimail.co.js +0 -14
  145. package/providers/gecicimail.com.tr.js +0 -15
  146. package/providers/generator.email.js +0 -37
  147. package/providers/getnada.cc.js +0 -37
  148. package/providers/getnada.com.js +0 -37
  149. package/providers/gmailcity.com.js +0 -37
  150. package/providers/gpa.lu.js +0 -37
  151. package/providers/guerrillamail.com.js +0 -38
  152. package/providers/harakirimail.com.js +0 -38
  153. package/providers/haribu.net.js +0 -39
  154. package/providers/hizli.email.js +0 -40
  155. package/providers/hottempmail.com.js +0 -52
  156. package/providers/instant-email.org.js +0 -39
  157. package/providers/instantemailaddress.com.js +0 -40
  158. package/providers/internxt.com.js +0 -47
  159. package/providers/jooko.info.js +0 -37
  160. package/providers/kopeechka.store.js +0 -43
  161. package/providers/kuku.lu.js +0 -37
  162. package/providers/linshi-email.com.js +0 -38
  163. package/providers/linshiyou.com.js +0 -25
  164. package/providers/linshiyouxiang.net.js +0 -36
  165. package/providers/lroid.com.js +0 -35
  166. package/providers/luxusmail.org.js +0 -39
  167. package/providers/mail-temp.com.js +0 -37
  168. package/providers/mail-tester.com.js +0 -37
  169. package/providers/mail.gen.tr.js +0 -14
  170. package/providers/mail.gw.js +0 -35
  171. package/providers/mail.td.js +0 -42
  172. package/providers/mail.tm.js +0 -35
  173. package/providers/mail1.js +0 -44
  174. package/providers/mail1a.de.js +0 -42
  175. package/providers/mail4qa.com.js +0 -37
  176. package/providers/mail7.io.js +0 -41
  177. package/providers/mailcatch.com.js +0 -38
  178. package/providers/maildim.com.js +0 -38
  179. package/providers/maildrop.cc.js +0 -38
  180. package/providers/mailinator.com.js +0 -27
  181. package/providers/mailnesia.com.js +0 -41
  182. package/providers/mailpoof.com.js +0 -71
  183. package/providers/mailsac.com.js +0 -27
  184. package/providers/mailswipe.net.js +0 -37
  185. package/providers/minimail.eu.org.js +0 -27
  186. package/providers/mintemail.com.js +0 -49
  187. package/providers/minuteinbox.com.js +0 -35
  188. package/providers/moakt.com.js +0 -37
  189. package/providers/mohmal.com.js +0 -39
  190. package/providers/muellmail.com.js +0 -40
  191. package/providers/mytemp.email.js +0 -35
  192. package/providers/mytrashmailer.com.js +0 -38
  193. package/providers/niepodam.pl.js +0 -53
  194. package/providers/nolog.email.js +0 -38
  195. package/providers/onetempmail.com.js +0 -37
  196. package/providers/open.js +0 -41
  197. package/providers/oxyemail.com.js +0 -38
  198. package/providers/phaantm.de.js +0 -42
  199. package/providers/poo.email.js +0 -27
  200. package/providers/sandvpn.com.js +0 -49
  201. package/providers/shitmail.me.js +0 -38
  202. package/providers/shitmail.org.js +0 -38
  203. package/providers/snapmail.cc.js +0 -42
  204. package/providers/spamdecoy.net.js +0 -38
  205. package/providers/spamgourmet.com.js +0 -29
  206. package/providers/spoofmail.de.js +0 -47
  207. package/providers/static.js +0 -32
  208. package/providers/t-mail.org.js +0 -42
  209. package/providers/temp-email.info.js +0 -39
  210. package/providers/temp-inbox.com.js +0 -38
  211. package/providers/temp-inbox.me.js +0 -47
  212. package/providers/temp-mail.io.js +0 -36
  213. package/providers/temp-mail.org.2.js +0 -60
  214. package/providers/temp-mail.org.js +0 -36
  215. package/providers/temp-mailbox.com.js +0 -35
  216. package/providers/temp-mails.com.js +0 -45
  217. package/providers/temp.cab.js +0 -39
  218. package/providers/tempail.com.js +0 -36
  219. package/providers/tempinbox.xyz.js +0 -38
  220. package/providers/tempmail.adguard.com.js +0 -31
  221. package/providers/tempmail.altmails.com.js +0 -37
  222. package/providers/tempmail.cn.js +0 -38
  223. package/providers/tempmail.co.js +0 -38
  224. package/providers/tempmail.dev.js +0 -35
  225. package/providers/tempmail.io.js +0 -38
  226. package/providers/tempmail.ninja.js +0 -35
  227. package/providers/tempmail.plus.js +0 -47
  228. package/providers/tempmail.quest.js +0 -45
  229. package/providers/tempmail.run.js +0 -37
  230. package/providers/tempmail.tel.js +0 -38
  231. package/providers/tempmailed.com.js +0 -43
  232. package/providers/tempmailo.com.js +0 -35
  233. package/providers/tempo-email.com.js +0 -38
  234. package/providers/tempo-mail.xyz.js +0 -40
  235. package/providers/temporary-email.com.js +0 -35
  236. package/providers/temporary-email.org.js +0 -36
  237. package/providers/temporary-mail.net.js +0 -42
  238. package/providers/temporarymail.com.js +0 -39
  239. package/providers/tempos.email.js +0 -38
  240. package/providers/tempr.email.js +0 -45
  241. package/providers/temprmail.com.js +0 -38
  242. package/providers/tenmail.org.js +0 -40
  243. package/providers/thnen.com.js +0 -25
  244. package/providers/throwaway.io.js +0 -39
  245. package/providers/tmail.gg.js +0 -36
  246. package/providers/tmail.mmomekong.com.js +0 -38
  247. package/providers/tmailor.com.js +0 -37
  248. package/providers/tmailweb.com.js +0 -39
  249. package/providers/trash-mail.com.js +0 -42
  250. package/providers/trashmail.com.js +0 -39
  251. package/providers/trashmail.de.js +0 -36
  252. package/providers/trashmail.live.js +0 -36
  253. package/providers/trashmail.org.js +0 -39
  254. package/providers/trashmail.ws.js +0 -42
  255. package/providers/trashmails.com.js +0 -38
  256. package/providers/tuamaeaquelaursa.com.js +0 -25
  257. package/providers/txen.de.js +0 -48
  258. package/providers/wegwerfemailadresse.com.js +0 -43
  259. package/providers/yopmail.com.js +0 -37
  260. package/providers/yopmail.fr.js +0 -37
  261. package/providers/yopmail.net.js +0 -37
  262. package/providers/yourmail.online.js +0 -39
  263. package/providers/youxiang.dev.js +0 -25
  264. package/release.sh +0 -26
  265. package/repo-update.js +0 -134
  266. package/shared.js +0 -736
  267. package/test/doRequest.js +0 -47
  268. package/test/is_domain_banned.js +0 -53
  269. package/test/is_fakedomain.js +0 -136
  270. package/test/is_fakeemail.js +0 -136
  271. package/test/psl.js +0 -58
  272. package/test/repo_json_v1.js +0 -30
  273. package/test/repo_json_v2.js +0 -41
  274. package/test1.js +0 -36
  275. package/update-repo.sh +0 -37
  276. package/vars.js +0 -16
package/LICENSE.md ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, 7c
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,27 +1,77 @@
1
- # Fakefilter Service
1
+ # FakeFilter
2
+ The intention of this project is to sweep temporary and fake email addresses from registrations. We collect fake email providers and their domains and want to publish them here in different formats. We want that site owners use this repo as reliable source to find out all fake/temp provider registration attempts.
2
3
 
3
- this project will harvest domains of fake/temp-email providers and store them in mysql table. This project stores everything to mysql database. The `repo/` folder is mapped to `https://github.com/7c/fakefilter` repo which is supposed to be the distribution repo
4
+ # Why FakeFilter
5
+ There are other lists like https://gist.github.com/adamloving/4401361 , https://disify.com/ , https://github.com/wesbos/burner-email-providers , https://github.com/disposable-email-domains/disposable-email-domains , https://github.com/elliotjreed/disposable-emails-filter-php , https://github.com/Propaganistas/Laravel-Disposable-Email , https://github.com/disposable/disposable - they do work with submissions. This is greatly appreciated service for the community. We want to thank to them. FakeFilter has different approach: we do actively monitor all known providers and get their domains almost realtime and distribute daily. All our system is automated. Your help is still required; if you submit us new providers, we will write services to watch those providers REALTIME. Users do have rights to fake their emails, but also service providers do have the right to know about this fact. We have nothing against free/fake services, this service aims to be automated and reliable.
4
6
 
5
- ## Testing specific provider for Development
6
- You may want to start every provider seperatly (for development reasons for example) just by calling `node providers/<name>.js`, this would open the puppeteer in non-headless mode. This will allow you to debug
7
+ # Stats
8
+ ## Daily Coverage
9
+ Amount of coverage, actions against all known Disposable Email Providers per Day
10
+ ![Monthly Coverage](https://fakefilter.net/public/img/dynamic/chart1.png)
7
11
 
8
- ## Fetching specific provider
9
- `node fetch.js <providerName> [<providerName> <providerName>]`
12
+ ## Monthly Unique Disposable Domains
13
+ Number of unique known validated Disposable Domains in Total at given Month
14
+ ![Monthly Disposable Domains](https://fakefilter.net/public/img/dynamic/chart3.png)
10
15
 
11
- ## Repo/ folder
12
- this is seperate [github](https://github.com/7c/fakefilter) repo. Use `repo-update.js` from crontab to populate it.
13
16
 
14
- ## repo-update.sh
17
+ ## Success Rate Charts
18
+ We monitor every disposable email provider we know about and make charts about success rate in % per day. You can access provider based success rate charts at [here](CHARTS.md)
19
+
20
+ ## Adding new Providers
21
+ Please help us to add new Providers to this list, simply create an issue with the title as providers main sitedomain, this way we can group them by domain. Your help is appreciated.
22
+
23
+ ## Online Formats
24
+ We have implemented a RESTful API, you can check the API at [fakefilter.net](https://fakefilter.net/static/docs/restful/). This database is aimed to serve realtime, so once we detect a new domain, this API will have it. We recommend using the Offline format as backup since we cannot guarantee the uptime.
25
+
26
+ ## Offline Formats
27
+ You may use one of these formats to have access to the information flow in your favorite programming language:
28
+
29
+ [Markdown](markdown/README.md)
30
+
31
+ [Json](json/data.json)
32
+ This format supports firstseen,lastseen,randomSubdomain properties
33
+
34
+ [Json v2](json/data_version2.json)
35
+ A fakedomain might belong to multiple providers, in this format we list their PSL (Public Suffix List) based domain and all known hostnames belonging to this PSL domain. Ths version also supports IDN domains, all domains are punycode.
36
+
37
+ [Txt](txt/data.txt)
38
+
39
+ ## Expired Domains
40
+ Our service removes domains from fakefilter (json/api/markdown/txt) after a year of inactivity. If these domains reappear, they are reinstated in our database for a minimum of 365 days. You can find the list of expired domains per provider [here](markdown/EXPIRED.md)
41
+
42
+ ## Whitelist
43
+ We whitelist major well-known providers from being blocked from fakefilter, just to make sure we do not add them automatically from our system. Some providers offer @gmail<dot>com emails, adding such domains would be painful for the community.
44
+
45
+ ## Javascript Interface
46
+ We have implemented npm/javascript interface for Javascript Developers as demonstration
47
+
48
+ `npm i --save fakefilter`
49
+
50
+ You have to make sure that this npm package is always up2date in order this static implementation to work as designed.
51
+
52
+ Offline Lookup:
15
53
  ```
16
- --dry will not write to files
54
+ const { isFakeDomain, isFakeEmail } = require('fakefilter')
55
+
56
+ console.log(isFakeDomain('domain.com'))
57
+ console.log(isFakeEmail('user@domain.com'))
58
+ ```
59
+
60
+
61
+ Online Lookup:
62
+
63
+ this version does not throw at all. You either get null (which indicates any error) or false or the object as reply
17
64
  ```
65
+ ## also see examples/online.js
66
+ const { isFakeDomainOnline, isFakeEmailOnline } = require('fakefilter')
18
67
 
19
- ## chart-update.sh
20
- this is responsible to draw charts using external module
68
+ console.log(await isFakeDomainOnline('domain.com'))
69
+ console.log(await isFakeEmailOnline('user@domain.com'))
21
70
 
71
+ ```
22
72
 
23
- ## Docs
24
- docs/website are/is made with Docusaurus, the source is inside apiserver/docs/. You can use `npm run serve` to develop and `npm run build` to build. This docs page serves as the main entry point for https://fakefilter.net
25
73
 
26
- ## events.js
27
- use this tool to pull events for specific provider from mysql
74
+ Test:
75
+ ```
76
+ node index.js
77
+ ```
@@ -0,0 +1,7 @@
1
+ import { FakeFilterDataset } from './types';
2
+ export declare class DomainLookup {
3
+ private readonly domains;
4
+ constructor(dataset: FakeFilterDataset);
5
+ match(domain: string): string | false;
6
+ }
7
+ export declare function getLookup(dataset: FakeFilterDataset): DomainLookup;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DomainLookup = void 0;
4
+ exports.getLookup = getLookup;
5
+ //#endregion
6
+ // Immutable lookup structure built once per dataset. Keys are normalized to
7
+ // lowercase so membership and suffix checks are case-insensitive and the input
8
+ // only needs to be normalized a single time.
9
+ class DomainLookup {
10
+ constructor(dataset) {
11
+ this.domains = new Set();
12
+ for (const key of Object.keys(dataset.domains)) {
13
+ this.domains.add(key.toLowerCase().trim());
14
+ }
15
+ }
16
+ // Returns the matched fake domain (exact host or registrable suffix) or false.
17
+ // A Set is used instead of direct property access so reserved keys such as
18
+ // `constructor` or `toString` cannot produce prototype-chain false positives.
19
+ match(domain) {
20
+ const normalized = domain.toLowerCase().trim();
21
+ // exact match
22
+ if (this.domains.has(normalized))
23
+ return normalized;
24
+ // suffix match on dot boundaries: a.b.fake.com -> fake.com
25
+ const parts = normalized.split('.');
26
+ for (let i = 1; i < parts.length; i++) {
27
+ const suffix = parts.slice(i).join('.');
28
+ if (this.domains.has(suffix))
29
+ return suffix;
30
+ }
31
+ return false;
32
+ }
33
+ }
34
+ exports.DomainLookup = DomainLookup;
35
+ // Datasets are cached by identity so repeated lookups reuse the same Set.
36
+ // The bundled default dataset is a stable singleton object, so it is cached on
37
+ // first use just like any caller-provided dataset.
38
+ const cache = new WeakMap();
39
+ function getLookup(dataset) {
40
+ let lookup = cache.get(dataset);
41
+ if (!lookup) {
42
+ lookup = new DomainLookup(dataset);
43
+ cache.set(dataset, lookup);
44
+ }
45
+ return lookup;
46
+ }
@@ -0,0 +1,9 @@
1
+ import { FakeDomainResponse, FakeFilterDataset } from './types';
2
+ export type { DomainDetails, FakeDomainResponse } from './types';
3
+ export declare function hostnameFromEmailAddress(email: any): string | null;
4
+ export declare function isFakeDomain(domain: string, json?: boolean | FakeFilterDataset): string | false;
5
+ export declare function fetch(url: string, timeout?: number, json?: boolean): Promise<any>;
6
+ export declare function isFakeEmail(email: string, json?: boolean | FakeFilterDataset): string | false;
7
+ export declare function isFakeEmailOnline(email: string, timeout?: number): Promise<FakeDomainResponse | null>;
8
+ export declare function isFakeDomainOnline(domain: string | null, timeout?: number): Promise<FakeDomainResponse | null>;
9
+ export declare function runTests(): Promise<void>;
package/dist/index.js ADDED
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.hostnameFromEmailAddress = hostnameFromEmailAddress;
40
+ exports.isFakeDomain = isFakeDomain;
41
+ exports.fetch = fetch;
42
+ exports.isFakeEmail = isFakeEmail;
43
+ exports.isFakeEmailOnline = isFakeEmailOnline;
44
+ exports.isFakeDomainOnline = isFakeDomainOnline;
45
+ exports.runTests = runTests;
46
+ /*
47
+
48
+ Basic Typescript Interface to lookup by Email or Domain
49
+
50
+ Important: you need to auto update npm package daily to make continious feed
51
+
52
+ */
53
+ //#region imports
54
+ const assert_1 = __importDefault(require("assert"));
55
+ const https = __importStar(require("https"));
56
+ const http = __importStar(require("http"));
57
+ const data_json_1 = __importDefault(require("./json/data.json"));
58
+ const domainLookup_1 = require("./domainLookup");
59
+ const apiserver = 'https://fakefilter.net';
60
+ // const apiserver = "http://127.0.0.1:5520" -- local tests
61
+ const scheme = apiserver.search(/^https/) === 0 ? 'https' : 'http';
62
+ function hostnameFromEmailAddress(email) {
63
+ if (email && typeof email === 'string' && email.search(/@/) > 0)
64
+ return email.split(/@/)[1];
65
+ return null;
66
+ }
67
+ function isFakeDomain(domain, json = false) {
68
+ const dataset = typeof json === 'boolean' ? data_json_1.default : json;
69
+ return (0, domainLookup_1.getLookup)(dataset).match(domain);
70
+ }
71
+ function fetch(url, timeout = 5000, json = true) {
72
+ return new Promise((resolve, reject) => {
73
+ try {
74
+ //#region response handler
75
+ const handler = (res) => {
76
+ if (res.statusCode !== 200) {
77
+ res.resume();
78
+ return reject('STATUSCODE');
79
+ }
80
+ let data = '';
81
+ res.on('data', (chunk) => { data += chunk; });
82
+ res.on('close', () => {
83
+ if (json) {
84
+ try {
85
+ return resolve(JSON.parse(data));
86
+ }
87
+ catch (err) {
88
+ return resolve(false);
89
+ }
90
+ }
91
+ return resolve(data);
92
+ });
93
+ };
94
+ //#endregion
95
+ const request = apiserver.search(/^https/) === 0 ? https.get(url, handler) : http.get(url, handler);
96
+ request.setTimeout(timeout, () => {
97
+ request.destroy();
98
+ return reject('TIMEOUT');
99
+ });
100
+ request.end();
101
+ request.on('error', (err) => {
102
+ return reject(err);
103
+ });
104
+ }
105
+ catch (err3) {
106
+ // errors like ERR_INVALID_PROTOCOL is thrown here
107
+ reject(err3);
108
+ }
109
+ });
110
+ }
111
+ function isFakeEmail(email, json = false) {
112
+ // a null hostname is intentionally forwarded so invalid input throws, matching the original behaviour
113
+ return isFakeDomain(hostnameFromEmailAddress(email), json);
114
+ }
115
+ function isFakeEmailOnline(email, timeout = 5000) {
116
+ return isFakeDomainOnline(hostnameFromEmailAddress(email), timeout);
117
+ }
118
+ async function isFakeDomainOnline(domain, timeout = 5000) {
119
+ // we intentionally do not reject because we do not want to hold
120
+ // the process too long, null indicates error
121
+ try {
122
+ const answer = await fetch(`${apiserver}/api/is/fakedomain/${domain}`, timeout, true);
123
+ if (answer && answer.hasOwnProperty('retcode') && answer.retcode === 200)
124
+ return answer;
125
+ }
126
+ catch (err) {
127
+ // error returns null
128
+ return null;
129
+ }
130
+ // preserve original behaviour: stay pending when the lookup is not a positive hit
131
+ return new Promise(() => { });
132
+ }
133
+ async function runTests() {
134
+ //#region fetch tests
135
+ // not existing domain
136
+ try {
137
+ await fetch(`${scheme}://nonexisting${Date.now()}.com`);
138
+ assert_1.default.equal(false, true); // we should never reach this position
139
+ }
140
+ catch (err) {
141
+ assert_1.default.equal(err.code, 'ENOTFOUND');
142
+ }
143
+ // not existing url on existing domain
144
+ try {
145
+ await fetch(`${apiserver}/notexisting`);
146
+ assert_1.default.equal(false, true); // we should never reach this position
147
+ }
148
+ catch (err) {
149
+ assert_1.default.equal(err, 'STATUSCODE');
150
+ }
151
+ // invalid protocoll
152
+ try {
153
+ await fetch(`htps://fakefilter.net/notexisting`);
154
+ assert_1.default.equal(false, true); // we should never reach this position
155
+ }
156
+ catch (err) {
157
+ assert_1.default.equal(err.code, 'ERR_INVALID_PROTOCOL');
158
+ }
159
+ // invalid url
160
+ try {
161
+ await fetch(`://fakefilter.net/notexisting`);
162
+ assert_1.default.equal(false, true); // we should never reach this position
163
+ }
164
+ catch (err) {
165
+ assert_1.default.equal(err.code, 'ERR_INVALID_URL');
166
+ }
167
+ // 404
168
+ try {
169
+ await fetch(`${apiserver}/api/is/fakedomain/`);
170
+ assert_1.default.equal(false, true); // we should never reach this position
171
+ }
172
+ catch (err) {
173
+ assert_1.default.equal(err, 'STATUSCODE');
174
+ }
175
+ // non FakeDomain
176
+ assert_1.default.equal((await fetch(`${apiserver}/api/is/fakedomain/fakefilter.net`)).retcode, 200);
177
+ // FakeDomain
178
+ assert_1.default.equal((await fetch(`${apiserver}/api/is/fakedomain/fakefilte r.net`)).retcode, -50);
179
+ //#endregion
180
+ const json = data_json_1.default;
181
+ console.log(`Running tests`);
182
+ const all_domains = Object.keys(json.domains);
183
+ //#region offline + online assertions for every known domain
184
+ // all domains we know must be detected as FakeDomain
185
+ for (const domain of all_domains) {
186
+ // if (domain!=='www.barryogorman.com') continue
187
+ // console.log((domain),isFakeDomain(domain)===domain.toLowerCase())
188
+ // exact match
189
+ // console.log(`>> ${domain}`)
190
+ assert_1.default.notEqual(isFakeDomain(domain), false);
191
+ // subdomain match for example any@sub.test.com should match if test.com is part of the filter
192
+ assert_1.default.notEqual(isFakeDomain(`sub.${domain}`), false);
193
+ assert_1.default.notEqual(isFakeDomain(`sub.sub.${domain}`), false);
194
+ assert_1.default.notEqual(isFakeDomain(`another.sub.sub.${domain}`), false);
195
+ // sub$hostname should not be detected as fakedomain - if we have test.com in the filter, subtest.com should not be detected as fake
196
+ if (domain.search(/^[^.]+\.[^.]+$/) == 0) {
197
+ assert_1.default.equal(isFakeEmail(`any@sub${domain}`), false);
198
+ assert_1.default.equal(isFakeDomain(`sub${domain}`), false);
199
+ }
200
+ assert_1.default.notEqual(isFakeEmail(`any@${domain}`), false);
201
+ assert_1.default.notEqual(isFakeEmail(`any@sub.${domain}`), false);
202
+ // RESTFul API query (responses are guaranteed present for these mocked/online lookups)
203
+ assert_1.default.equal((await isFakeDomainOnline(domain)).isFakeDomain, domain);
204
+ assert_1.default.equal((await isFakeEmailOnline(`any@${domain}`)).isFakeDomain, domain);
205
+ assert_1.default.equal((await isFakeEmailOnline(`any@sub.${domain}`)).isFakeDomain, 'sub.' + domain);
206
+ }
207
+ //#endregion
208
+ console.log(`OK`);
209
+ process.exit(0);
210
+ }
211
+ // basic tests
212
+ if (require.main === module)
213
+ runTests();