@sapphire/phisherman 1.4.1 β†’ 1.4.2-next.009d3d2.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/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.4.1](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.4.0...@sapphire/phisherman@1.4.1) (2022-04-01)
6
+
7
+ **Note:** Version bump only for package @sapphire/phisherman
8
+
9
+ # [1.4.0](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.3.1...@sapphire/phisherman@1.4.0) (2022-03-06)
10
+
11
+ ### Features
12
+
13
+ - allow module: NodeNext ([#306](https://github.com/sapphiredev/utilities/issues/306)) ([9dc6dd6](https://github.com/sapphiredev/utilities/commit/9dc6dd619efab879bb2b0b3c9e64304e10a67ed6))
14
+
15
+ ## [1.3.1](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.3.0...@sapphire/phisherman@1.3.1) (2022-03-01)
16
+
17
+ **Note:** Version bump only for package @sapphire/phisherman
18
+
19
+ # [1.3.0](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.2.0...@sapphire/phisherman@1.3.0) (2022-02-15)
20
+
21
+ ### Features
22
+
23
+ - **phisherman:** add url validation ([#294](https://github.com/sapphiredev/utilities/issues/294)) ([b039d4a](https://github.com/sapphiredev/utilities/commit/b039d4a621b4b0be7b87af578868a37145087846))
24
+ - **ts-config:** add multi-config structure ([#281](https://github.com/sapphiredev/utilities/issues/281)) ([b5191d7](https://github.com/sapphiredev/utilities/commit/b5191d7f2416dc5838590c4ff221454925553e37))
25
+
26
+ # [1.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.1.0...@sapphire/phisherman@1.2.0) (2022-01-28)
27
+
28
+ ### Features
29
+
30
+ - change build system to tsup ([#270](https://github.com/sapphiredev/utilities/issues/270)) ([365a53a](https://github.com/sapphiredev/utilities/commit/365a53a5517a01a0926cf28a83c96b63f32ed9f8))
31
+
32
+ # [1.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.0.1...@sapphire/phisherman@1.1.0) (2022-01-22)
33
+
34
+ ### Features
35
+
36
+ - **phisherman:** add more methods ([#265](https://github.com/sapphiredev/utilities/issues/265)) ([524f311](https://github.com/sapphiredev/utilities/commit/524f3116fe5e1fd2f8186ef1e635dcf750503555))
37
+
38
+ ## [1.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/phisherman@1.0.0...@sapphire/phisherman@1.0.1) (2022-01-16)
39
+
40
+ **Note:** Version bump only for package @sapphire/phisherman
41
+
42
+ # 1.0.0 (2022-01-12)
43
+
44
+ ### Features
45
+
46
+ - add phisherman ([#255](https://github.com/sapphiredev/utilities/issues/255)) ([68fba03](https://github.com/sapphiredev/utilities/commit/68fba03bcbd3af14e66b25357d1eafd0cc315f0f))
package/README.md CHANGED
@@ -76,58 +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
- </tr>
126
- </table>
127
-
128
- <!-- markdownlint-restore -->
129
- <!-- prettier-ignore-end -->
130
-
131
- <!-- ALL-CONTRIBUTORS-LIST:END -->
132
-
133
- 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
package/dist/index.d.ts CHANGED
@@ -1,3 +1,86 @@
1
- export * from './lib/Phisherman';
2
- export type { CheckReturnType, PhishermanOptions, PhishermanReportType, PhishermanReturnType } from './lib/PhishermanTypes';
3
- //# sourceMappingURL=index.d.ts.map
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 { CheckReturnType, PhishermanOptions, PhishermanReportType, PhishermanReturnType, checkDomain, getDomainInfo, reportCaughtPhish, reportDomain, setApiKey };
package/dist/index.js CHANGED
@@ -1,107 +1,106 @@
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);
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 }; }
23
7
 
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);
8
+ var os__default = /*#__PURE__*/_interopDefault(os);
34
9
 
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)`;
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)`;
39
13
  var storedApiKey;
40
14
  async function checkDomain(domain, apiKey = storedApiKey) {
41
15
  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);
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
+ );
49
27
  return {
50
28
  ...result,
51
29
  isScam: result.classification === "safe" || result.classification === "unknown" ? false : true
52
30
  };
53
31
  }
32
+ __name(checkDomain, "checkDomain");
54
33
  function reportDomain(domain, apiKey = storedApiKey) {
55
34
  validateUrl(domain);
56
- return (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/phish/report`, {
57
- method: import_fetch.FetchMethods.Put,
58
- headers: {
59
- "Content-Type": "application/json",
60
- "User-Agent": agent,
61
- Authorization: `Bearer ${apiKey}`
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
+ })
62
47
  },
63
- body: JSON.stringify({
64
- url: domain
65
- })
66
- }, import_fetch.FetchResultTypes.JSON);
48
+ fetch.FetchResultTypes.JSON
49
+ );
67
50
  }
51
+ __name(reportDomain, "reportDomain");
68
52
  async function getDomainInfo(domain, apiKey = storedApiKey) {
69
53
  validateUrl(domain);
70
- const result = await (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/domains/info/${domain}`, {
71
- headers: {
72
- "Content-Type": "application/json",
73
- "User-Agent": agent,
74
- Authorization: `Bearer ${apiKey}`
75
- }
76
- }, import_fetch.FetchResultTypes.JSON);
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
+ );
77
65
  return result[domain];
78
66
  }
67
+ __name(getDomainInfo, "getDomainInfo");
79
68
  function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
80
- return (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/phish/caught/${domain}`, {
81
- method: import_fetch.FetchMethods.Post,
82
- headers: {
83
- "Content-Type": "application/json",
84
- "User-Agent": agent,
85
- Authorization: `Bearer ${apiKey}`
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
+ })
86
81
  },
87
- body: JSON.stringify({
88
- guild: Number(guildId)
89
- })
90
- }, import_fetch.FetchResultTypes.JSON);
82
+ fetch.FetchResultTypes.JSON
83
+ );
91
84
  }
85
+ __name(reportCaughtPhish, "reportCaughtPhish");
92
86
  async function setApiKey(key) {
93
87
  await checkApiKey(key);
94
88
  storedApiKey = key;
95
89
  }
90
+ __name(setApiKey, "setApiKey");
96
91
  async function checkApiKey(apiKey) {
97
92
  try {
98
- await (0, import_fetch.fetch)(`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`, {
99
- headers: {
100
- "Content-Type": "application/json",
101
- "User-Agent": agent,
102
- Authorization: `Bearer ${apiKey}`
103
- }
104
- }, import_fetch.FetchResultTypes.JSON);
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
+ );
105
104
  } catch (error) {
106
105
  const typedError = error;
107
106
  if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
@@ -110,17 +109,18 @@ async function checkApiKey(apiKey) {
110
109
  throw error;
111
110
  }
112
111
  }
112
+ __name(checkApiKey, "checkApiKey");
113
113
  function validateUrl(domain) {
114
114
  const regexp = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
115
115
  if (!domain.match(regexp))
116
116
  throw new Error("[SapphirePhisherman]: Invalid domain provided");
117
117
  }
118
- // Annotate the CommonJS export names for ESM import in node:
119
- 0 && (module.exports = {
120
- checkDomain,
121
- getDomainInfo,
122
- reportCaughtPhish,
123
- reportDomain,
124
- setApiKey
125
- });
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
126
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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 regex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AAY,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;AAAA,QAC1B;AAAA,MACD;AAAA,MACA,iBAAiB;AAAA,IAClB;AAAA,EACD,SAAS,OAAP;AACD,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/dist/index.mjs CHANGED
@@ -1,76 +1,100 @@
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
21
24
  };
22
25
  }
26
+ __name(checkDomain, "checkDomain");
23
27
  function reportDomain(domain, apiKey = storedApiKey) {
24
28
  validateUrl(domain);
25
- return fetch(`https://api.phisherman.gg/v2/phish/report`, {
26
- method: FetchMethods.Put,
27
- headers: {
28
- "Content-Type": "application/json",
29
- "User-Agent": agent,
30
- 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
+ })
31
41
  },
32
- body: JSON.stringify({
33
- url: domain
34
- })
35
- }, FetchResultTypes.JSON);
42
+ FetchResultTypes.JSON
43
+ );
36
44
  }
45
+ __name(reportDomain, "reportDomain");
37
46
  async function getDomainInfo(domain, apiKey = storedApiKey) {
38
47
  validateUrl(domain);
39
- const result = await fetch(`https://api.phisherman.gg/v2/domains/info/${domain}`, {
40
- headers: {
41
- "Content-Type": "application/json",
42
- "User-Agent": agent,
43
- Authorization: `Bearer ${apiKey}`
44
- }
45
- }, 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
+ );
46
59
  return result[domain];
47
60
  }
61
+ __name(getDomainInfo, "getDomainInfo");
48
62
  function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
49
- return fetch(`https://api.phisherman.gg/v2/phish/caught/${domain}`, {
50
- method: FetchMethods.Post,
51
- headers: {
52
- "Content-Type": "application/json",
53
- "User-Agent": agent,
54
- 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
+ })
55
75
  },
56
- body: JSON.stringify({
57
- guild: Number(guildId)
58
- })
59
- }, FetchResultTypes.JSON);
76
+ FetchResultTypes.JSON
77
+ );
60
78
  }
79
+ __name(reportCaughtPhish, "reportCaughtPhish");
61
80
  async function setApiKey(key) {
62
81
  await checkApiKey(key);
63
82
  storedApiKey = key;
64
83
  }
84
+ __name(setApiKey, "setApiKey");
65
85
  async function checkApiKey(apiKey) {
66
86
  try {
67
- await fetch(`https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`, {
68
- headers: {
69
- "Content-Type": "application/json",
70
- "User-Agent": agent,
71
- Authorization: `Bearer ${apiKey}`
72
- }
73
- }, 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
+ );
74
98
  } catch (error) {
75
99
  const typedError = error;
76
100
  if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
@@ -79,16 +103,14 @@ async function checkApiKey(apiKey) {
79
103
  throw error;
80
104
  }
81
105
  }
106
+ __name(checkApiKey, "checkApiKey");
82
107
  function validateUrl(domain) {
83
108
  const regexp = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
84
109
  if (!domain.match(regexp))
85
110
  throw new Error("[SapphirePhisherman]: Invalid domain provided");
86
111
  }
87
- export {
88
- checkDomain,
89
- getDomainInfo,
90
- reportCaughtPhish,
91
- reportDomain,
92
- setApiKey
93
- };
112
+ __name(validateUrl, "validateUrl");
113
+
114
+ export { checkDomain, getDomainInfo, reportCaughtPhish, reportDomain, setApiKey };
115
+ //# sourceMappingURL=out.js.map
94
116
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
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,OACH;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,6CACA;AAAA,IACC,QAAQ,aAAa;AAAA,IACrB,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,eAAe,UAAU;AAAA,IAC1B;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACpB,KAAK;AAAA,IACN,CAAC;AAAA,EACF,GACA,iBAAiB,IAClB;AACD;AAjBgB,AAyBhB,6BAAoC,QAAgB,SAAiB,cAAc;AAClF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM,MACpB,6CAA6C,UAC7C;AAAA,IACC,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,eAAe,UAAU;AAAA,IAC1B;AAAA,EACD,GACA,iBAAiB,IAClB;AACA,SAAO,OAAO;AACf;AAdsB,AAu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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;AAAA,QAC1B;AAAA,MACD;AAAA,MACA,iBAAiB;AAAA,IAClB;AAAA,EACD,SAAS,OAAP;AACD,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,57 +1,66 @@
1
1
  {
2
- "name": "@sapphire/phisherman",
3
- "version": "1.4.1",
4
- "description": "Wrapper around phisherman to easily check and report domains",
5
- "author": "@sapphire",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
10
- "typedocMain": "src/index.ts",
11
- "exports": {
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js",
14
- "types": "./dist/index.d.ts"
15
- },
16
- "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/phisherman",
17
- "scripts": {
18
- "lint": "eslint src --ext ts --fix",
19
- "build": "tsup && tsc -b src",
20
- "prepublishOnly": "yarn build"
21
- },
22
- "dependencies": {
23
- "@sapphire/fetch": "^2.3.1"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/sapphiredev/utilities.git",
28
- "directory": "packages/phisherman"
29
- },
30
- "files": [
31
- "dist",
32
- "!dist/*.tsbuildinfo"
33
- ],
34
- "engines": {
35
- "node": ">=16.6.0",
36
- "npm": ">=7.0.0"
37
- },
38
- "keywords": [
39
- "sapphiredev",
40
- "bot",
41
- "typescript",
42
- "ts",
43
- "yarn",
44
- "discord",
45
- "sapphire",
46
- "phisherman",
47
- "scam",
48
- "detection"
49
- ],
50
- "bugs": {
51
- "url": "https://github.com/sapphiredev/utilities/issues"
52
- },
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "gitHead": "bf5ac56e547bfdbfac38e020882004e0f136546e"
57
- }
2
+ "name": "@sapphire/phisherman",
3
+ "version": "1.4.2-next.009d3d2.0",
4
+ "description": "Wrapper around phisherman to easily check and report domains",
5
+ "author": "@sapphire",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/phisherman",
16
+ "scripts": {
17
+ "lint": "eslint src --ext ts --fix",
18
+ "build": "tsup",
19
+ "docs": "typedoc-json-parser",
20
+ "prepack": "yarn build",
21
+ "bump": "cliff-jumper",
22
+ "check-update": "cliff-jumper --dry-run"
23
+ },
24
+ "dependencies": {
25
+ "@sapphire/fetch": "^2.4.2-next.009d3d2.0"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/sapphiredev/utilities.git",
30
+ "directory": "packages/phisherman"
31
+ },
32
+ "files": [
33
+ "dist/**/*.js*",
34
+ "dist/**/*.mjs*",
35
+ "dist/**/*.d*"
36
+ ],
37
+ "engines": {
38
+ "node": ">=16.6.0",
39
+ "npm": ">=7.0.0"
40
+ },
41
+ "keywords": [
42
+ "sapphiredev",
43
+ "bot",
44
+ "typescript",
45
+ "ts",
46
+ "yarn",
47
+ "discord",
48
+ "sapphire",
49
+ "phisherman",
50
+ "scam",
51
+ "detection"
52
+ ],
53
+ "bugs": {
54
+ "url": "https://github.com/sapphiredev/utilities/issues"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "devDependencies": {
60
+ "@favware/cliff-jumper": "^2.0.0",
61
+ "tsup": "^6.6.3",
62
+ "typedoc": "^0.23.26",
63
+ "typedoc-json-parser": "^7.2.0",
64
+ "typescript": "^4.9.5"
65
+ }
66
+ }
package/LICENSE.md DELETED
@@ -1,24 +0,0 @@
1
- # The MIT License (MIT)
2
-
3
- Copyright Β© `2020` `The Sapphire Community and its contributors`
4
-
5
- Permission is hereby granted, free of charge, to any person
6
- obtaining a copy of this software and associated documentation
7
- files (the β€œSoftware”), to deal in the Software without
8
- restriction, including without limitation the rights to use,
9
- copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the
11
- Software is furnished to do so, subject to the following
12
- conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,41 +0,0 @@
1
- import type { PhishermanReportType } from './PhishermanTypes';
2
- /**
3
- * Checks if a link is detected as a scam or phishing link by phisherman.
4
- * @param domain The domain to check.
5
- * @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
- * @since 1.0.0
7
- */
8
- export declare function checkDomain(domain: string, apiKey?: string): Promise<{
9
- isScam: boolean;
10
- verifiedPhish: boolean;
11
- classification: "malicious" | "suspicious" | "safe" | "unknown";
12
- }>;
13
- /**
14
- * Report a domain that is confirmed to be a scam or phishing domain to phisherman, to enhance their API.
15
- * @param domain The domain to report.
16
- * @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
- * @since 1.0.0
18
- */
19
- export declare function reportDomain(domain: string, apiKey?: string): Promise<PhishermanReportType>;
20
- /**
21
- * Returns information for a domain.
22
- * @param domain The domain to get info about.
23
- * @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
- * @since 1.1.0
25
- */
26
- export declare function getDomainInfo(domain: string, apiKey?: string): Promise<import("./PhishermanTypes").PhishermanInfo>;
27
- /**
28
- * Report a caught phish back to phisherman to improve their analytics.
29
- * @param domain The domain which was caught.
30
- * @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}.
31
- * @param guildId The id of the guild in which the domain was caught.
32
- * @since 1.1.0
33
- */
34
- export declare function reportCaughtPhish(domain: string, apiKey?: string, guildId?: string | number): Promise<PhishermanReportType>;
35
- /**
36
- * Set the phisherman's API key.
37
- * @param key The API key to access the phisherman API and cache within the code of the wrapper.
38
- * @since 1.0.0
39
- */
40
- export declare function setApiKey(key: string): Promise<void>;
41
- //# sourceMappingURL=Phisherman.d.ts.map
@@ -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