@sapphire/phisherman 1.4.2-next.701df4d.0 → 1.4.2-next.716b60cf.0

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- ![Sapphire Logo](https://cdn.skyra.pw/gh-assets/sapphire-banner.png)
3
+ ![Sapphire Logo](https://raw.githubusercontent.com/sapphiredev/assets/main/banners/SapphireCommunity.png)
4
4
 
5
5
  # @sapphire/phisherman
6
6
 
@@ -76,67 +76,14 @@ We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub S
76
76
  | Patreon | [Click Here](https://sapphirejs.dev/patreon) |
77
77
  | PayPal | [Click Here](https://sapphirejs.dev/paypal) |
78
78
 
79
- ## Contributors
80
-
81
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
82
-
83
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
84
- <!-- prettier-ignore-start -->
85
- <!-- markdownlint-disable -->
86
- <table>
87
- <tr>
88
- <td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Code">💻</a> <a href="#infra-favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-favna" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Documentation">📖</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Tests">⚠️</a></td>
89
- <td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio Román</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Code">💻</a> <a href="#projectManagement-kyranet" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Akyranet" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Tests">⚠️</a></td>
90
- <td align="center"><a href="https://github.com/PyroTechniac"><img src="https://avatars2.githubusercontent.com/u/39341355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gryffon Bellish</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3APyroTechniac" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Tests">⚠️</a></td>
91
- <td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3Avladfrangu" title="Bug reports">🐛</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">👀</a> <a href="#userTesting-vladfrangu" title="User Testing">📓</a> <a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Tests">⚠️</a></td>
92
- <td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Code">💻</a> <a href="#projectManagement-Stitch07" title="Project Management">📆</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Tests">⚠️</a></td>
93
- <td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
94
- <td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
95
- </tr>
96
- <tr>
97
- <td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Nytelife26" title="Documentation">📖</a></td>
98
- <td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Alcremie" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AAlcremie" title="Bug reports">🐛</a></td>
99
- <td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">💻</a></td>
100
- <td align="center"><a href="https://github.com/Vetlix"><img src="https://avatars.githubusercontent.com/u/31412314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vetlix</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Vetlix" title="Code">💻</a></td>
101
- <td align="center"><a href="https://github.com/ethamitc"><img src="https://avatars.githubusercontent.com/u/27776796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ethan Mitchell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ethamitc" title="Documentation">📖</a></td>
102
- <td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=noftaly" title="Code">💻</a></td>
103
- <td align="center"><a href="https://jurien.dev"><img src="https://avatars.githubusercontent.com/u/5418114?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jurien Hamaker</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=jurienhamaker" title="Code">💻</a></td>
104
- </tr>
105
- <tr>
106
- <td align="center"><a href="https://fanoulis.dev/"><img src="https://avatars.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=cfanoulis" title="Documentation">📖</a></td>
107
- <td align="center"><a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dependabot[bot]</b></sub></a><br /><a href="#maintenance-dependabot[bot]" title="Maintenance">🚧</a></td>
108
- <td align="center"><a href="https://kaname.netlify.app/"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kaname-png" title="Code">💻</a></td>
109
- <td align="center"><a href="https://github.com/nandhagk"><img src="https://avatars.githubusercontent.com/u/62976649?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nandhagk</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/issues?q=author%3Anandhagk" title="Bug reports">🐛</a></td>
110
- <td align="center"><a href="https://megatank58.me/"><img src="https://avatars.githubusercontent.com/u/51410502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>megatank58</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=megatank58" title="Code">💻</a></td>
111
- <td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=UndiedGamer" title="Code">💻</a></td>
112
- <td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Documentation">📖</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Code">💻</a></td>
113
- </tr>
114
- <tr>
115
- <td align="center"><a href="https://gitlab.com/DavidPH/"><img src="https://avatars.githubusercontent.com/u/44669930?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=DavidPHH" title="Code">💻</a></td>
116
- <td align="center"><a href="https://github.com/apps/renovate"><img src="https://avatars.githubusercontent.com/in/2740?v=4?s=100" width="100px;" alt=""/><br /><sub><b>renovate[bot]</b></sub></a><br /><a href="#maintenance-renovate[bot]" title="Maintenance">🚧</a></td>
117
- <td align="center"><a href="https://renovate.whitesourcesoftware.com/"><img src="https://avatars.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">🚧</a></td>
118
- <td align="center"><a href="https://fc5570.me/"><img src="https://avatars.githubusercontent.com/u/68158483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>FC</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=FC5570" title="Code">💻</a></td>
119
- <td align="center"><a href="https://github.com/Tokipudi"><img src="https://avatars.githubusercontent.com/u/29551076?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jérémy de Saint Denis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Tokipudi" title="Code">💻</a></td>
120
- <td align="center"><a href="https://github.com/ItsMrCube"><img src="https://avatars.githubusercontent.com/u/25201357?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MrCube</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ItsMrCube" title="Code">💻</a></td>
121
- <td align="center"><a href="https://github.com/bitomic"><img src="https://avatars.githubusercontent.com/u/35199700?v=4?s=100" width="100px;" alt=""/><br /><sub><b>bitomic</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=bitomic" title="Code">💻</a></td>
122
- </tr>
123
- <tr>
124
- <td align="center"><a href="https://c43721.dev/"><img src="https://avatars.githubusercontent.com/u/55610086?v=4?s=100" width="100px;" alt=""/><br /><sub><b>c43721</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=c43721" title="Code">💻</a></td>
125
- <td align="center"><a href="https://commandtechno.com/"><img src="https://avatars.githubusercontent.com/u/68407783?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Commandtechno</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Commandtechno" title="Code">💻</a></td>
126
- <td align="center"><a href="https://github.com/dhruv-kaushikk"><img src="https://avatars.githubusercontent.com/u/73697546?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=dhruv-kaushikk" title="Code">💻</a></td>
127
- <td align="center"><a href="https://axis.moe/"><img src="https://avatars.githubusercontent.com/u/54381371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=axisiscool" title="Code">💻</a></td>
128
- <td align="center"><a href="https://github.com/imranbarbhuiya"><img src="https://avatars.githubusercontent.com/u/74945038?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Parbez</b></sub></a><br /><a href="#maintenance-imranbarbhuiya" title="Maintenance">🚧</a></td>
129
- <td align="center"><a href="https://github.com/NotKaskus"><img src="https://avatars.githubusercontent.com/u/75168528?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Andrew</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=NotKaskus" title="Documentation">📖</a></td>
130
- <td align="center"><a href="https://linktr.ee/mzato0001"><img src="https://avatars.githubusercontent.com/u/62367547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mzato</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Mzato0001" title="Code">💻</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AMzato0001" title="Bug reports">🐛</a></td>
131
- </tr>
132
- <tr>
133
- <td align="center"><a href="https://github.com/MajesticString"><img src="https://avatars.githubusercontent.com/u/66224939?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harry Allen</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=MajesticString" title="Documentation">📖</a></td>
134
- </tr>
135
- </table>
136
-
137
- <!-- markdownlint-restore -->
138
- <!-- prettier-ignore-end -->
139
-
140
- <!-- ALL-CONTRIBUTORS-LIST:END -->
141
-
142
- This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
79
+ ## Contributors
80
+
81
+ Please make sure to read the [Contributing Guide][contributing] before making a pull request.
82
+
83
+ Thank you to all the people who already contributed to Sapphire!
84
+
85
+ <a href="https://github.com/sapphiredev/utilities/graphs/contributors">
86
+ <img src="https://contrib.rocks/image?repo=sapphiredev/utilities" />
87
+ </a>
88
+
89
+ [contributing]: https://github.com/sapphiredev/.github/blob/main/.github/CONTRIBUTING.md
@@ -0,0 +1,126 @@
1
+ 'use strict';
2
+
3
+ var fetch = require('@sapphire/fetch');
4
+ var os = require('os');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var os__default = /*#__PURE__*/_interopDefault(os);
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
+ var agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os__default.default.platform()}/${os__default.default.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;
13
+ var storedApiKey;
14
+ async function checkDomain(domain, apiKey = storedApiKey) {
15
+ validateUrl(domain);
16
+ const result = await fetch.fetch(
17
+ `https://api.phisherman.gg/v2/domains/check/${domain}`,
18
+ {
19
+ headers: {
20
+ "Content-Type": "application/json",
21
+ "User-Agent": agent,
22
+ Authorization: `Bearer ${apiKey}`
23
+ }
24
+ },
25
+ fetch.FetchResultTypes.JSON
26
+ );
27
+ return {
28
+ ...result,
29
+ isScam: result.classification === "safe" || result.classification === "unknown" ? false : true
30
+ };
31
+ }
32
+ __name(checkDomain, "checkDomain");
33
+ function reportDomain(domain, apiKey = storedApiKey) {
34
+ validateUrl(domain);
35
+ return fetch.fetch(
36
+ `https://api.phisherman.gg/v2/phish/report`,
37
+ {
38
+ method: fetch.FetchMethods.Put,
39
+ headers: {
40
+ "Content-Type": "application/json",
41
+ "User-Agent": agent,
42
+ Authorization: `Bearer ${apiKey}`
43
+ },
44
+ body: JSON.stringify({
45
+ url: domain
46
+ })
47
+ },
48
+ fetch.FetchResultTypes.JSON
49
+ );
50
+ }
51
+ __name(reportDomain, "reportDomain");
52
+ async function getDomainInfo(domain, apiKey = storedApiKey) {
53
+ validateUrl(domain);
54
+ const result = await fetch.fetch(
55
+ `https://api.phisherman.gg/v2/domains/info/${domain}`,
56
+ {
57
+ headers: {
58
+ "Content-Type": "application/json",
59
+ "User-Agent": agent,
60
+ Authorization: `Bearer ${apiKey}`
61
+ }
62
+ },
63
+ fetch.FetchResultTypes.JSON
64
+ );
65
+ return result[domain];
66
+ }
67
+ __name(getDomainInfo, "getDomainInfo");
68
+ function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
69
+ return fetch.fetch(
70
+ `https://api.phisherman.gg/v2/phish/caught/${domain}`,
71
+ {
72
+ method: fetch.FetchMethods.Post,
73
+ headers: {
74
+ "Content-Type": "application/json",
75
+ "User-Agent": agent,
76
+ Authorization: `Bearer ${apiKey}`
77
+ },
78
+ body: JSON.stringify({
79
+ guild: Number(guildId)
80
+ })
81
+ },
82
+ fetch.FetchResultTypes.JSON
83
+ );
84
+ }
85
+ __name(reportCaughtPhish, "reportCaughtPhish");
86
+ async function setApiKey(key) {
87
+ await checkApiKey(key);
88
+ storedApiKey = key;
89
+ }
90
+ __name(setApiKey, "setApiKey");
91
+ async function checkApiKey(apiKey) {
92
+ try {
93
+ await fetch.fetch(
94
+ `https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,
95
+ {
96
+ headers: {
97
+ "Content-Type": "application/json",
98
+ "User-Agent": agent,
99
+ Authorization: `Bearer ${apiKey}`
100
+ }
101
+ },
102
+ fetch.FetchResultTypes.JSON
103
+ );
104
+ } catch (error) {
105
+ const typedError = error;
106
+ if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
107
+ throw new Error("[SapphirePhisherman]: Invalid API key provided");
108
+ }
109
+ throw error;
110
+ }
111
+ }
112
+ __name(checkApiKey, "checkApiKey");
113
+ function validateUrl(domain) {
114
+ const regexp = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
115
+ if (!domain.match(regexp))
116
+ throw new Error("[SapphirePhisherman]: Invalid domain provided");
117
+ }
118
+ __name(validateUrl, "validateUrl");
119
+
120
+ exports.checkDomain = checkDomain;
121
+ exports.getDomainInfo = getDomainInfo;
122
+ exports.reportCaughtPhish = reportCaughtPhish;
123
+ exports.reportDomain = reportDomain;
124
+ exports.setApiKey = setApiKey;
125
+ //# sourceMappingURL=out.js.map
126
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/Phisherman.ts"],"names":[],"mappings":";;;;AAAA,SAAS,OAAO,cAAc,wBAAoC;AAElE,OAAO,QAAQ;AAEf,IAAM,QAAQ,0CAA0C,GAAG,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC;AAIrF,IAAI;AAQJ,eAAsB,YAAY,QAAgB,SAAiB,cAAc;AAChF,cAAY,MAAM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AAO;AAAA,MACtB,CAAC;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,EAClB;AACD;AAhBgB;AAuBhB,eAAsB,UAAU,KAAa;AAC5C,QAAM,YAAY,GAAG;AACrB,iBAAe;AAChB;AAHsB;AAKtB,eAAe,YAAY,QAAgB;AAC1C,MAAI;AACH,UAAM;AAAA,MACL;AAAA,MACA;AAAA,QACC,SAAS;AAAA,UACR,gBAAgB;AAAA,UAChB,cAAc;AAAA,UACd,eAAe,UAAU,MAAM;AAAA,QAChC;AAAA,MACD;AAAA,MACA,iBAAiB;AAAA,IAClB;AAAA,EACD,SAAS,OAAO;AACf,UAAM,aAAa;AAEnB,QAAI,WAAW,SAAS,OAAO,WAAW,OAAO,EAAE,YAAY,0CAA0C;AACxG,YAAM,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,UAAM;AAAA,EACP;AACD;AAtBe;AAwBf,SAAS,YAAY,QAAgB;AACpC,QAAM,SAAS;AACf,MAAI,CAAC,OAAO,MAAM,MAAM;AAAG,UAAM,IAAI,MAAM,+CAA+C;AAC3F;AAHS","sourcesContent":["import { fetch, FetchMethods, FetchResultTypes, QueryError } from '@sapphire/fetch';\nimport type { PhishermanInfoType, PhishermanReportType, PhishermanReturnType } from './PhishermanTypes';\nimport os from 'node:os';\n\nconst agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;\n/**\n * The cached apiKey which was created using {@link setApiKey}\n */\nlet storedApiKey: string;\n\n/**\n * Checks if a link is detected as a scam or phishing link by phisherman.\n * @param domain The domain to check.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport async function checkDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanReturnType>(\n\t\t`https://api.phisherman.gg/v2/domains/check/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\n\treturn {\n\t\t...result,\n\t\tisScam: result.classification === 'safe' || result.classification === 'unknown' ? false : true\n\t};\n}\n\n/**\n * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.\n * @param domain The domain to report.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport function reportDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/report`,\n\t\t{\n\t\t\tmethod: FetchMethods.Put,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\turl: domain\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Returns information for a domain.\n * @param domain The domain to get info about.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.1.0\n */\nexport async function getDomainInfo(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanInfoType>(\n\t\t`https://api.phisherman.gg/v2/domains/info/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\treturn result[domain];\n}\n\n/**\n * Report a caught phish back to phisherman to improve their analytics.\n * @param domain The domain which was caught.\n * @param apiKey @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @param guildId The id of the guild in which the domain was caught.\n * @since 1.1.0\n */\nexport function reportCaughtPhish(domain: string, apiKey: string = storedApiKey, guildId: string | number = '') {\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/caught/${domain}`,\n\t\t{\n\t\t\tmethod: FetchMethods.Post,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tguild: Number(guildId)\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Set the phisherman's API key.\n * @param key The API key to access the phisherman API and cache within the code of the wrapper.\n * @since 1.0.0\n */\nexport async function setApiKey(key: string) {\n\tawait checkApiKey(key);\n\tstoredApiKey = key;\n}\n\nasync function checkApiKey(apiKey: string) {\n\ttry {\n\t\tawait fetch<{ message: string; success: false }>(\n\t\t\t`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'User-Agent': agent,\n\t\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t\t}\n\t\t\t},\n\t\t\tFetchResultTypes.JSON\n\t\t);\n\t} catch (error) {\n\t\tconst typedError = error as QueryError;\n\n\t\tif (typedError.code === 401 && typedError.toJSON().message === 'missing permissions or invalid API key') {\n\t\t\tthrow new Error('[SapphirePhisherman]: Invalid API key provided');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction validateUrl(domain: string) {\n\tconst regexp = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/gi;\n\tif (!domain.match(regexp)) throw new Error('[SapphirePhisherman]: Invalid domain provided');\n}\n"]}
@@ -1,11 +1,55 @@
1
- import type { PhishermanReportType } from './PhishermanTypes';
1
+ interface PhishermanOptions {
2
+ apiKey: string;
3
+ }
4
+ interface PhishermanReturnType {
5
+ verifiedPhish: boolean;
6
+ classification: 'malicious' | 'suspicious' | 'safe' | 'unknown';
7
+ }
8
+ type CheckReturnType = PhishermanReturnType & {
9
+ isScam: boolean;
10
+ };
11
+ interface PhishermanReportType {
12
+ success: boolean;
13
+ message: string;
14
+ }
15
+ interface PhishermanInfo {
16
+ status: string;
17
+ created: string;
18
+ lastChecked: string;
19
+ verifiedPhish: boolean;
20
+ classification: string;
21
+ firstSeen: string;
22
+ lastSeen: string;
23
+ targetedBrand: string;
24
+ phishCaught: number;
25
+ details: Details;
26
+ }
27
+ interface Details {
28
+ phishTankId: string;
29
+ urlScanId: string;
30
+ websiteScreenshot: string;
31
+ ip_address: string;
32
+ asn: Asn;
33
+ registry: string;
34
+ country: Country;
35
+ }
36
+ interface Asn {
37
+ asn: string;
38
+ asn_name: string;
39
+ route: string;
40
+ }
41
+ interface Country {
42
+ code: string;
43
+ name: string;
44
+ }
45
+
2
46
  /**
3
47
  * Checks if a link is detected as a scam or phishing link by phisherman.
4
48
  * @param domain The domain to check.
5
49
  * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
6
50
  * @since 1.0.0
7
51
  */
8
- export declare function checkDomain(domain: string, apiKey?: string): Promise<{
52
+ declare function checkDomain(domain: string, apiKey?: string): Promise<{
9
53
  isScam: boolean;
10
54
  verifiedPhish: boolean;
11
55
  classification: "malicious" | "suspicious" | "safe" | "unknown";
@@ -16,14 +60,14 @@ export declare function checkDomain(domain: string, apiKey?: string): Promise<{
16
60
  * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
17
61
  * @since 1.0.0
18
62
  */
19
- export declare function reportDomain(domain: string, apiKey?: string): Promise<PhishermanReportType>;
63
+ declare function reportDomain(domain: string, apiKey?: string): Promise<PhishermanReportType>;
20
64
  /**
21
65
  * Returns information for a domain.
22
66
  * @param domain The domain to get info about.
23
67
  * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
24
68
  * @since 1.1.0
25
69
  */
26
- export declare function getDomainInfo(domain: string, apiKey?: string): Promise<import("./PhishermanTypes").PhishermanInfo>;
70
+ declare function getDomainInfo(domain: string, apiKey?: string): Promise<PhishermanInfo>;
27
71
  /**
28
72
  * Report a caught phish back to phisherman to improve their analytics.
29
73
  * @param domain The domain which was caught.
@@ -31,11 +75,12 @@ export declare function getDomainInfo(domain: string, apiKey?: string): Promise<
31
75
  * @param guildId The id of the guild in which the domain was caught.
32
76
  * @since 1.1.0
33
77
  */
34
- export declare function reportCaughtPhish(domain: string, apiKey?: string, guildId?: string | number): Promise<PhishermanReportType>;
78
+ declare function reportCaughtPhish(domain: string, apiKey?: string, guildId?: string | number): Promise<PhishermanReportType>;
35
79
  /**
36
80
  * Set the phisherman's API key.
37
81
  * @param key The API key to access the phisherman API and cache within the code of the wrapper.
38
82
  * @since 1.0.0
39
83
  */
40
- export declare function setApiKey(key: string): Promise<void>;
41
- //# sourceMappingURL=Phisherman.d.ts.map
84
+ declare function setApiKey(key: string): Promise<void>;
85
+
86
+ export { type CheckReturnType, type PhishermanOptions, type PhishermanReportType, type PhishermanReturnType, checkDomain, getDomainInfo, reportCaughtPhish, reportDomain, setApiKey };
@@ -0,0 +1,86 @@
1
+ interface PhishermanOptions {
2
+ apiKey: string;
3
+ }
4
+ interface PhishermanReturnType {
5
+ verifiedPhish: boolean;
6
+ classification: 'malicious' | 'suspicious' | 'safe' | 'unknown';
7
+ }
8
+ type CheckReturnType = PhishermanReturnType & {
9
+ isScam: boolean;
10
+ };
11
+ interface PhishermanReportType {
12
+ success: boolean;
13
+ message: string;
14
+ }
15
+ interface PhishermanInfo {
16
+ status: string;
17
+ created: string;
18
+ lastChecked: string;
19
+ verifiedPhish: boolean;
20
+ classification: string;
21
+ firstSeen: string;
22
+ lastSeen: string;
23
+ targetedBrand: string;
24
+ phishCaught: number;
25
+ details: Details;
26
+ }
27
+ interface Details {
28
+ phishTankId: string;
29
+ urlScanId: string;
30
+ websiteScreenshot: string;
31
+ ip_address: string;
32
+ asn: Asn;
33
+ registry: string;
34
+ country: Country;
35
+ }
36
+ interface Asn {
37
+ asn: string;
38
+ asn_name: string;
39
+ route: string;
40
+ }
41
+ interface Country {
42
+ code: string;
43
+ name: string;
44
+ }
45
+
46
+ /**
47
+ * Checks if a link is detected as a scam or phishing link by phisherman.
48
+ * @param domain The domain to check.
49
+ * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
50
+ * @since 1.0.0
51
+ */
52
+ declare function checkDomain(domain: string, apiKey?: string): Promise<{
53
+ isScam: boolean;
54
+ verifiedPhish: boolean;
55
+ classification: "malicious" | "suspicious" | "safe" | "unknown";
56
+ }>;
57
+ /**
58
+ * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.
59
+ * @param domain The domain to report.
60
+ * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
61
+ * @since 1.0.0
62
+ */
63
+ declare function reportDomain(domain: string, apiKey?: string): Promise<PhishermanReportType>;
64
+ /**
65
+ * Returns information for a domain.
66
+ * @param domain The domain to get info about.
67
+ * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
68
+ * @since 1.1.0
69
+ */
70
+ declare function getDomainInfo(domain: string, apiKey?: string): Promise<PhishermanInfo>;
71
+ /**
72
+ * Report a caught phish back to phisherman to improve their analytics.
73
+ * @param domain The domain which was caught.
74
+ * @param apiKey @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.
75
+ * @param guildId The id of the guild in which the domain was caught.
76
+ * @since 1.1.0
77
+ */
78
+ declare function reportCaughtPhish(domain: string, apiKey?: string, guildId?: string | number): Promise<PhishermanReportType>;
79
+ /**
80
+ * Set the phisherman's API key.
81
+ * @param key The API key to access the phisherman API and cache within the code of the wrapper.
82
+ * @since 1.0.0
83
+ */
84
+ declare function setApiKey(key: string): Promise<void>;
85
+
86
+ export { type CheckReturnType, type PhishermanOptions, type PhishermanReportType, type PhishermanReturnType, checkDomain, getDomainInfo, reportCaughtPhish, reportDomain, setApiKey };
@@ -1,20 +1,23 @@
1
+ import { fetch, FetchResultTypes, FetchMethods } from '@sapphire/fetch';
2
+ import os from 'node:os';
3
+
1
4
  var __defProp = Object.defineProperty;
2
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // src/lib/Phisherman.ts
5
- import { fetch, FetchMethods, FetchResultTypes } from "@sapphire/fetch";
6
- import os from "node:os";
7
6
  var agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;
8
7
  var storedApiKey;
9
8
  async function checkDomain(domain, apiKey = storedApiKey) {
10
9
  validateUrl(domain);
11
- const result = await fetch(`https://api.phisherman.gg/v2/domains/check/${domain}`, {
12
- headers: {
13
- "Content-Type": "application/json",
14
- "User-Agent": agent,
15
- Authorization: `Bearer ${apiKey}`
16
- }
17
- }, FetchResultTypes.JSON);
10
+ const result = await fetch(
11
+ `https://api.phisherman.gg/v2/domains/check/${domain}`,
12
+ {
13
+ headers: {
14
+ "Content-Type": "application/json",
15
+ "User-Agent": agent,
16
+ Authorization: `Bearer ${apiKey}`
17
+ }
18
+ },
19
+ FetchResultTypes.JSON
20
+ );
18
21
  return {
19
22
  ...result,
20
23
  isScam: result.classification === "safe" || result.classification === "unknown" ? false : true
@@ -23,43 +26,55 @@ async function checkDomain(domain, apiKey = storedApiKey) {
23
26
  __name(checkDomain, "checkDomain");
24
27
  function reportDomain(domain, apiKey = storedApiKey) {
25
28
  validateUrl(domain);
26
- return fetch(`https://api.phisherman.gg/v2/phish/report`, {
27
- method: FetchMethods.Put,
28
- headers: {
29
- "Content-Type": "application/json",
30
- "User-Agent": agent,
31
- Authorization: `Bearer ${apiKey}`
29
+ return fetch(
30
+ `https://api.phisherman.gg/v2/phish/report`,
31
+ {
32
+ method: FetchMethods.Put,
33
+ headers: {
34
+ "Content-Type": "application/json",
35
+ "User-Agent": agent,
36
+ Authorization: `Bearer ${apiKey}`
37
+ },
38
+ body: JSON.stringify({
39
+ url: domain
40
+ })
32
41
  },
33
- body: JSON.stringify({
34
- url: domain
35
- })
36
- }, FetchResultTypes.JSON);
42
+ FetchResultTypes.JSON
43
+ );
37
44
  }
38
45
  __name(reportDomain, "reportDomain");
39
46
  async function getDomainInfo(domain, apiKey = storedApiKey) {
40
47
  validateUrl(domain);
41
- const result = await fetch(`https://api.phisherman.gg/v2/domains/info/${domain}`, {
42
- headers: {
43
- "Content-Type": "application/json",
44
- "User-Agent": agent,
45
- Authorization: `Bearer ${apiKey}`
46
- }
47
- }, FetchResultTypes.JSON);
48
+ const result = await fetch(
49
+ `https://api.phisherman.gg/v2/domains/info/${domain}`,
50
+ {
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ "User-Agent": agent,
54
+ Authorization: `Bearer ${apiKey}`
55
+ }
56
+ },
57
+ FetchResultTypes.JSON
58
+ );
48
59
  return result[domain];
49
60
  }
50
61
  __name(getDomainInfo, "getDomainInfo");
51
62
  function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
52
- return fetch(`https://api.phisherman.gg/v2/phish/caught/${domain}`, {
53
- method: FetchMethods.Post,
54
- headers: {
55
- "Content-Type": "application/json",
56
- "User-Agent": agent,
57
- Authorization: `Bearer ${apiKey}`
63
+ return fetch(
64
+ `https://api.phisherman.gg/v2/phish/caught/${domain}`,
65
+ {
66
+ method: FetchMethods.Post,
67
+ headers: {
68
+ "Content-Type": "application/json",
69
+ "User-Agent": agent,
70
+ Authorization: `Bearer ${apiKey}`
71
+ },
72
+ body: JSON.stringify({
73
+ guild: Number(guildId)
74
+ })
58
75
  },
59
- body: JSON.stringify({
60
- guild: Number(guildId)
61
- })
62
- }, FetchResultTypes.JSON);
76
+ FetchResultTypes.JSON
77
+ );
63
78
  }
64
79
  __name(reportCaughtPhish, "reportCaughtPhish");
65
80
  async function setApiKey(key) {
@@ -69,13 +84,17 @@ async function setApiKey(key) {
69
84
  __name(setApiKey, "setApiKey");
70
85
  async function checkApiKey(apiKey) {
71
86
  try {
72
- await fetch(`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`, {
73
- headers: {
74
- "Content-Type": "application/json",
75
- "User-Agent": agent,
76
- Authorization: `Bearer ${apiKey}`
77
- }
78
- }, FetchResultTypes.JSON);
87
+ await fetch(
88
+ `https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,
89
+ {
90
+ headers: {
91
+ "Content-Type": "application/json",
92
+ "User-Agent": agent,
93
+ Authorization: `Bearer ${apiKey}`
94
+ }
95
+ },
96
+ FetchResultTypes.JSON
97
+ );
79
98
  } catch (error) {
80
99
  const typedError = error;
81
100
  if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
@@ -91,11 +110,7 @@ function validateUrl(domain) {
91
110
  throw new Error("[SapphirePhisherman]: Invalid domain provided");
92
111
  }
93
112
  __name(validateUrl, "validateUrl");
94
- export {
95
- checkDomain,
96
- getDomainInfo,
97
- reportCaughtPhish,
98
- reportDomain,
99
- setApiKey
100
- };
113
+
114
+ export { checkDomain, getDomainInfo, reportCaughtPhish, reportDomain, setApiKey };
115
+ //# sourceMappingURL=out.js.map
101
116
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/Phisherman.ts"],"names":[],"mappings":";;;;AAAA,SAAS,OAAO,cAAc,wBAAoC;AAElE,OAAO,QAAQ;AAEf,IAAM,QAAQ,0CAA0C,GAAG,SAAS,CAAC,IAAI,GAAG,Q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AAe,UAAU,MAAM;AAAA,MAChC;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACpB,OAAO,OAAO,OAAO;AAAA,MACtB,CAAC;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,EAClB;AACD;AAhBgB;AAuBhB,eAAsB,UAAU,KAAa;AAC5C,QAAM,YAAY,GAAG;AACrB,iBAAe;AAChB;AAHsB;AAKtB,eAAe,YAAY,QAAgB;AAC1C,MAAI;AACH,UAAM;AAAA,MACL;AAAA,MACA;AAAA,QACC,SAAS;AAAA,UACR,gBAAgB;AAAA,UAChB,cAAc;AAAA,UACd,eAAe,UAAU,MAAM;AAAA,QAChC;AAAA,MACD;AAAA,MACA,iBAAiB;AAAA,IAClB;AAAA,EACD,SAAS,OAAO;AACf,UAAM,aAAa;AAEnB,QAAI,WAAW,SAAS,OAAO,WAAW,OAAO,EAAE,YAAY,0CAA0C;AACxG,YAAM,IAAI,MAAM,gDAAgD;AAAA,IACjE;AAEA,UAAM;AAAA,EACP;AACD;AAtBe;AAwBf,SAAS,YAAY,QAAgB;AACpC,QAAM,SAAS;AACf,MAAI,CAAC,OAAO,MAAM,MAAM;AAAG,UAAM,IAAI,MAAM,+CAA+C;AAC3F;AAHS","sourcesContent":["import { fetch, FetchMethods, FetchResultTypes, QueryError } from '@sapphire/fetch';\nimport type { PhishermanInfoType, PhishermanReportType, PhishermanReturnType } from './PhishermanTypes';\nimport os from 'node:os';\n\nconst agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;\n/**\n * The cached apiKey which was created using {@link setApiKey}\n */\nlet storedApiKey: string;\n\n/**\n * Checks if a link is detected as a scam or phishing link by phisherman.\n * @param domain The domain to check.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport async function checkDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanReturnType>(\n\t\t`https://api.phisherman.gg/v2/domains/check/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\n\treturn {\n\t\t...result,\n\t\tisScam: result.classification === 'safe' || result.classification === 'unknown' ? false : true\n\t};\n}\n\n/**\n * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.\n * @param domain The domain to report.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport function reportDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/report`,\n\t\t{\n\t\t\tmethod: FetchMethods.Put,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\turl: domain\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Returns information for a domain.\n * @param domain The domain to get info about.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.1.0\n */\nexport async function getDomainInfo(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanInfoType>(\n\t\t`https://api.phisherman.gg/v2/domains/info/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\treturn result[domain];\n}\n\n/**\n * Report a caught phish back to phisherman to improve their analytics.\n * @param domain The domain which was caught.\n * @param apiKey @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @param guildId The id of the guild in which the domain was caught.\n * @since 1.1.0\n */\nexport function reportCaughtPhish(domain: string, apiKey: string = storedApiKey, guildId: string | number = '') {\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/caught/${domain}`,\n\t\t{\n\t\t\tmethod: FetchMethods.Post,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tguild: Number(guildId)\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Set the phisherman's API key.\n * @param key The API key to access the phisherman API and cache within the code of the wrapper.\n * @since 1.0.0\n */\nexport async function setApiKey(key: string) {\n\tawait checkApiKey(key);\n\tstoredApiKey = key;\n}\n\nasync function checkApiKey(apiKey: string) {\n\ttry {\n\t\tawait fetch<{ message: string; success: false }>(\n\t\t\t`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'User-Agent': agent,\n\t\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t\t}\n\t\t\t},\n\t\t\tFetchResultTypes.JSON\n\t\t);\n\t} catch (error) {\n\t\tconst typedError = error as QueryError;\n\n\t\tif (typedError.code === 401 && typedError.toJSON().message === 'missing permissions or invalid API key') {\n\t\t\tthrow new Error('[SapphirePhisherman]: Invalid API key provided');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction validateUrl(domain: string) {\n\tconst regexp = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/gi;\n\tif (!domain.match(regexp)) throw new Error('[SapphirePhisherman]: Invalid domain provided');\n}\n"]}
package/package.json CHANGED
@@ -1,27 +1,33 @@
1
1
  {
2
2
  "name": "@sapphire/phisherman",
3
- "version": "1.4.2-next.701df4d.0",
3
+ "version": "1.4.2-next.716b60cf.0",
4
4
  "description": "Wrapper around phisherman to easily check and report domains",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/esm/index.mjs",
9
+ "types": "dist/cjs/index.d.ts",
10
10
  "exports": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
11
+ "import": {
12
+ "types": "./dist/esm/index.d.mts",
13
+ "default": "./dist/esm/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/cjs/index.d.ts",
17
+ "default": "./dist/cjs/index.cjs"
18
+ }
14
19
  },
15
20
  "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/phisherman",
16
21
  "scripts": {
17
22
  "lint": "eslint src --ext ts --fix",
18
- "build": "tsup && tsc -b src",
23
+ "build": "tsup",
24
+ "docs": "typedoc-json-parser",
19
25
  "prepack": "yarn build",
20
26
  "bump": "cliff-jumper",
21
27
  "check-update": "cliff-jumper --dry-run"
22
28
  },
23
29
  "dependencies": {
24
- "@sapphire/fetch": "^2.3.2-next.701df4d.0"
30
+ "@sapphire/fetch": "^2.4.1"
25
31
  },
26
32
  "repository": {
27
33
  "type": "git",
@@ -29,9 +35,7 @@
29
35
  "directory": "packages/phisherman"
30
36
  },
31
37
  "files": [
32
- "dist/**/*.js*",
33
- "dist/**/*.mjs*",
34
- "dist/**/*.d*"
38
+ "dist/"
35
39
  ],
36
40
  "engines": {
37
41
  "node": ">=16.6.0",
@@ -56,7 +60,10 @@
56
60
  "access": "public"
57
61
  },
58
62
  "devDependencies": {
59
- "tsup": "^6.0.1",
60
- "typescript": "^4.7.2"
63
+ "@favware/cliff-jumper": "^2.2.3",
64
+ "tsup": "^8.0.1",
65
+ "typedoc": "^0.25.4",
66
+ "typedoc-json-parser": "^9.0.1",
67
+ "typescript": "^5.3.2"
61
68
  }
62
69
  }
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './lib/Phisherman';
2
- export type { CheckReturnType, PhishermanOptions, PhishermanReportType, PhishermanReturnType } from './lib/PhishermanTypes';
3
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js DELETED
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
22
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
-
24
- // src/index.ts
25
- var src_exports = {};
26
- __export(src_exports, {
27
- checkDomain: () => checkDomain,
28
- getDomainInfo: () => getDomainInfo,
29
- reportCaughtPhish: () => reportCaughtPhish,
30
- reportDomain: () => reportDomain,
31
- setApiKey: () => setApiKey
32
- });
33
- module.exports = __toCommonJS(src_exports);
34
-
35
- // src/lib/Phisherman.ts
36
- var import_fetch = require("@sapphire/fetch");
37
- var import_node_os = __toESM(require("os"));
38
- var agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${import_node_os.default.platform()}/${import_node_os.default.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;
39
- var storedApiKey;
40
- async function checkDomain(domain, apiKey = storedApiKey) {
41
- validateUrl(domain);
42
- const result = await (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/domains/check/${domain}`, {
43
- headers: {
44
- "Content-Type": "application/json",
45
- "User-Agent": agent,
46
- Authorization: `Bearer ${apiKey}`
47
- }
48
- }, import_fetch.FetchResultTypes.JSON);
49
- return {
50
- ...result,
51
- isScam: result.classification === "safe" || result.classification === "unknown" ? false : true
52
- };
53
- }
54
- __name(checkDomain, "checkDomain");
55
- function reportDomain(domain, apiKey = storedApiKey) {
56
- validateUrl(domain);
57
- return (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/phish/report`, {
58
- method: import_fetch.FetchMethods.Put,
59
- headers: {
60
- "Content-Type": "application/json",
61
- "User-Agent": agent,
62
- Authorization: `Bearer ${apiKey}`
63
- },
64
- body: JSON.stringify({
65
- url: domain
66
- })
67
- }, import_fetch.FetchResultTypes.JSON);
68
- }
69
- __name(reportDomain, "reportDomain");
70
- async function getDomainInfo(domain, apiKey = storedApiKey) {
71
- validateUrl(domain);
72
- const result = await (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/domains/info/${domain}`, {
73
- headers: {
74
- "Content-Type": "application/json",
75
- "User-Agent": agent,
76
- Authorization: `Bearer ${apiKey}`
77
- }
78
- }, import_fetch.FetchResultTypes.JSON);
79
- return result[domain];
80
- }
81
- __name(getDomainInfo, "getDomainInfo");
82
- function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
83
- return (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/phish/caught/${domain}`, {
84
- method: import_fetch.FetchMethods.Post,
85
- headers: {
86
- "Content-Type": "application/json",
87
- "User-Agent": agent,
88
- Authorization: `Bearer ${apiKey}`
89
- },
90
- body: JSON.stringify({
91
- guild: Number(guildId)
92
- })
93
- }, import_fetch.FetchResultTypes.JSON);
94
- }
95
- __name(reportCaughtPhish, "reportCaughtPhish");
96
- async function setApiKey(key) {
97
- await checkApiKey(key);
98
- storedApiKey = key;
99
- }
100
- __name(setApiKey, "setApiKey");
101
- async function checkApiKey(apiKey) {
102
- try {
103
- await (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`, {
104
- headers: {
105
- "Content-Type": "application/json",
106
- "User-Agent": agent,
107
- Authorization: `Bearer ${apiKey}`
108
- }
109
- }, import_fetch.FetchResultTypes.JSON);
110
- } catch (error) {
111
- const typedError = error;
112
- if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
113
- throw new Error("[SapphirePhisherman]: Invalid API key provided");
114
- }
115
- throw error;
116
- }
117
- }
118
- __name(checkApiKey, "checkApiKey");
119
- function validateUrl(domain) {
120
- const regexp = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
121
- if (!domain.match(regexp))
122
- throw new Error("[SapphirePhisherman]: Invalid domain provided");
123
- }
124
- __name(validateUrl, "validateUrl");
125
- // Annotate the CommonJS export names for ESM import in node:
126
- 0 && (module.exports = {
127
- checkDomain,
128
- getDomainInfo,
129
- reportCaughtPhish,
130
- reportDomain,
131
- setApiKey
132
- });
133
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/Phisherman.ts"],"sourcesContent":["export * from './lib/Phisherman';\nexport type { CheckReturnType, PhishermanOptions, PhishermanReportType, PhishermanReturnType } from './lib/PhishermanTypes';\n","import { fetch, FetchMethods, FetchResultTypes, QueryError } from '@sapphire/fetch';\nimport type { PhishermanInfoType, PhishermanReportType, PhishermanReturnType } from './PhishermanTypes';\nimport os from 'node:os';\n\nconst agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;\n/**\n * The cached apiKey which was created using {@link setApiKey}\n */\nlet storedApiKey: string;\n\n/**\n * Checks if a link is detected as a scam or phishing link by phisherman.\n * @param domain The domain to check.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport async function checkDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanReturnType>(\n\t\t`https://api.phisherman.gg/v2/domains/check/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\n\treturn {\n\t\t...result,\n\t\tisScam: result.classification === 'safe' || result.classification === 'unknown' ? false : true\n\t};\n}\n\n/**\n * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.\n * @param domain The domain to report.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport function reportDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/report`,\n\t\t{\n\t\t\tmethod: FetchMethods.Put,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\turl: domain\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Returns information for a domain.\n * @param domain The domain to get info about.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.1.0\n */\nexport async function getDomainInfo(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanInfoType>(\n\t\t`https://api.phisherman.gg/v2/domains/info/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\treturn result[domain];\n}\n\n/**\n * Report a caught phish back to phisherman to improve their analytics.\n * @param domain The domain which was caught.\n * @param apiKey @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @param guildId The id of the guild in which the domain was caught.\n * @since 1.1.0\n */\nexport function reportCaughtPhish(domain: string, apiKey: string = storedApiKey, guildId: string | number = '') {\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/caught/${domain}`,\n\t\t{\n\t\t\tmethod: FetchMethods.Post,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tguild: Number(guildId)\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Set the phisherman's API key.\n * @param key The API key to access the phisherman API and cache within the code of the wrapper.\n * @since 1.0.0\n */\nexport async function setApiKey(key: string) {\n\tawait checkApiKey(key);\n\tstoredApiKey = key;\n}\n\nasync function checkApiKey(apiKey: string) {\n\ttry {\n\t\tawait fetch<{ message: string; success: false }>(\n\t\t\t`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'User-Agent': agent,\n\t\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t\t}\n\t\t\t},\n\t\t\tFetchResultTypes.JSON\n\t\t);\n\t} catch (error) {\n\t\tconst typedError = error as QueryError;\n\n\t\tif (typedError.code === 401 && typedError.toJSON().message === 'missing permissions or invalid API key') {\n\t\t\tthrow new Error('[SapphirePhisherman]: Invalid API key provided');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction validateUrl(domain: string) {\n\tconst regexp = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/gi;\n\tif (!domain.match(regexp)) throw new Error('[SapphirePhisherman]: Invalid domain provided');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkE;AAElE,qBAAe;AAEf,IAAM,QAAQ,0CAA0C,uBAAG,SAAS,KAAK,uBAAG,QAAQ;AAIpF,IAAI;AAQJ,2BAAkC,QAAgB,SAAiB,cAAc;AAChF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM,wBACpB,8CAA8C,UAC9C;AAAA,IACC,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,eAAe,UAAU;AAAA,IAC1B;AAAA,EACD,GACA,8BAAiB,IAClB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAQ,OAAO,mBAAmB,UAAU,OAAO,mBAAmB,YAAY,QAAQ;AAAA,EAC3F;AACD;AAlBsB;AA0Bf,sBAAsB,QAAgB,SAAiB,cAAc;AAC3E,cAAY,MAAM;AAClB,SAAO,wBACN,6CACA;AAAA,IACC,QAAQ,0BAAa;AAAA,IACrB,SAAS;AA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,MAAI,CAAC,OAAO,MAAM,MAAM;AAAG,UAAM,IAAI,MAAM,+CAA+C;AAC3F;AAHS;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/Phisherman.ts"],"sourcesContent":["import { fetch, FetchMethods, FetchResultTypes, QueryError } from '@sapphire/fetch';\nimport type { PhishermanInfoType, PhishermanReportType, PhishermanReturnType } from './PhishermanTypes';\nimport os from 'node:os';\n\nconst agent = `Sapphire Phisherman/1.0.0 (node-fetch) ${os.platform()}/${os.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`;\n/**\n * The cached apiKey which was created using {@link setApiKey}\n */\nlet storedApiKey: string;\n\n/**\n * Checks if a link is detected as a scam or phishing link by phisherman.\n * @param domain The domain to check.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport async function checkDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanReturnType>(\n\t\t`https://api.phisherman.gg/v2/domains/check/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\n\treturn {\n\t\t...result,\n\t\tisScam: result.classification === 'safe' || result.classification === 'unknown' ? false : true\n\t};\n}\n\n/**\n * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.\n * @param domain The domain to report.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.0.0\n */\nexport function reportDomain(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/report`,\n\t\t{\n\t\t\tmethod: FetchMethods.Put,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\turl: domain\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Returns information for a domain.\n * @param domain The domain to get info about.\n * @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @since 1.1.0\n */\nexport async function getDomainInfo(domain: string, apiKey: string = storedApiKey) {\n\tvalidateUrl(domain);\n\tconst result = await fetch<PhishermanInfoType>(\n\t\t`https://api.phisherman.gg/v2/domains/info/${domain}`,\n\t\t{\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t}\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n\treturn result[domain];\n}\n\n/**\n * Report a caught phish back to phisherman to improve their analytics.\n * @param domain The domain which was caught.\n * @param apiKey @param apiKey optionally pass a Phiserman API key for making this request. This will default to {@link storedApiKey}, which can be configured through {@link setApiKey}.\n * @param guildId The id of the guild in which the domain was caught.\n * @since 1.1.0\n */\nexport function reportCaughtPhish(domain: string, apiKey: string = storedApiKey, guildId: string | number = '') {\n\treturn fetch<PhishermanReportType>(\n\t\t`https://api.phisherman.gg/v2/phish/caught/${domain}`,\n\t\t{\n\t\t\tmethod: FetchMethods.Post,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t'User-Agent': agent,\n\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tguild: Number(guildId)\n\t\t\t})\n\t\t},\n\t\tFetchResultTypes.JSON\n\t);\n}\n\n/**\n * Set the phisherman's API key.\n * @param key The API key to access the phisherman API and cache within the code of the wrapper.\n * @since 1.0.0\n */\nexport async function setApiKey(key: string) {\n\tawait checkApiKey(key);\n\tstoredApiKey = key;\n}\n\nasync function checkApiKey(apiKey: string) {\n\ttry {\n\t\tawait fetch<{ message: string; success: false }>(\n\t\t\t`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'User-Agent': agent,\n\t\t\t\t\tAuthorization: `Bearer ${apiKey}`\n\t\t\t\t}\n\t\t\t},\n\t\t\tFetchResultTypes.JSON\n\t\t);\n\t} catch (error) {\n\t\tconst typedError = error as QueryError;\n\n\t\tif (typedError.code === 401 && typedError.toJSON().message === 'missing permissions or invalid API key') {\n\t\t\tthrow new Error('[SapphirePhisherman]: Invalid API key provided');\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction validateUrl(domain: string) {\n\tconst regexp = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/gi;\n\tif (!domain.match(regexp)) throw new Error('[SapphirePhisherman]: Invalid domain provided');\n}\n"],"mappings":";;;;AAAA;AAEA;AAEA,IAAM,QAAQ,0CAA0C,GAAG,SAAS,KAAK,GAAG,QAAQ;AAIpF,IAAI;AAQJ,2BAAkC,QAAgB,SAAiB,cAAc;AAChF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM,MACpB,8CAA8C,UAC9C;AAAA,IACC,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,eAAe,UAAU;AAAA,IAC1B;AAAA,EACD,GACA,iBAAiB,IAClB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAQ,OAAO,mBAAmB,UAAU,OAAO,mBAAmB,YAAY,QAAQ;AAAA,EAC3F;AACD;AAlBsB;AA0Bf,sBAAsB,QAAgB,SAAiB,cAAc;AAC3E,cAAY,MAAM;AAClB,SAAO,MACN,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;AAwBf,qBAAqB,QAAgB;AACpC,QAAM,SAAS;AACf,MAAI,CAAC,OAAO,MAAM,MAAM;AAAG,UAAM,IAAI,MAAM,+CAA+C;AAC3F;AAHS;","names":[]}
@@ -1,49 +0,0 @@
1
- export interface PhishermanOptions {
2
- apiKey: string;
3
- }
4
- export interface PhishermanReturnType {
5
- verifiedPhish: boolean;
6
- classification: 'malicious' | 'suspicious' | 'safe' | 'unknown';
7
- }
8
- export declare type CheckReturnType = PhishermanReturnType & {
9
- isScam: boolean;
10
- };
11
- export interface PhishermanReportType {
12
- success: boolean;
13
- message: string;
14
- }
15
- export interface PhishermanInfo {
16
- status: string;
17
- created: string;
18
- lastChecked: string;
19
- verifiedPhish: boolean;
20
- classification: string;
21
- firstSeen: string;
22
- lastSeen: string;
23
- targetedBrand: string;
24
- phishCaught: number;
25
- details: Details;
26
- }
27
- export interface PhishermanInfoType {
28
- [key: string]: PhishermanInfo;
29
- }
30
- interface Details {
31
- phishTankId: string;
32
- urlScanId: string;
33
- websiteScreenshot: string;
34
- ip_address: string;
35
- asn: Asn;
36
- registry: string;
37
- country: Country;
38
- }
39
- interface Asn {
40
- asn: string;
41
- asn_name: string;
42
- route: string;
43
- }
44
- interface Country {
45
- code: string;
46
- name: string;
47
- }
48
- export {};
49
- //# sourceMappingURL=PhishermanTypes.d.ts.map