@sapphire/phisherman 1.4.2-next.76e4efd.0 β 1.4.2-next.77f33a8.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 +11 -60
- package/dist/index.d.ts +86 -3
- package/dist/index.js +78 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- package/dist/lib/Phisherman.d.ts +0 -41
- package/dist/lib/PhishermanTypes.d.ts +0 -49
package/README.md
CHANGED
|
@@ -76,63 +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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
</tr>
|
|
131
|
-
</table>
|
|
132
|
-
|
|
133
|
-
<!-- markdownlint-restore -->
|
|
134
|
-
<!-- prettier-ignore-end -->
|
|
135
|
-
|
|
136
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
137
|
-
|
|
138
|
-
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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,51 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
var
|
|
37
|
-
var
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
@@ -54,43 +32,55 @@ async function checkDomain(domain, apiKey = storedApiKey) {
|
|
|
54
32
|
__name(checkDomain, "checkDomain");
|
|
55
33
|
function reportDomain(domain, apiKey = storedApiKey) {
|
|
56
34
|
validateUrl(domain);
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
})
|
|
63
47
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})
|
|
67
|
-
}, import_fetch.FetchResultTypes.JSON);
|
|
48
|
+
fetch.FetchResultTypes.JSON
|
|
49
|
+
);
|
|
68
50
|
}
|
|
69
51
|
__name(reportDomain, "reportDomain");
|
|
70
52
|
async function getDomainInfo(domain, apiKey = storedApiKey) {
|
|
71
53
|
validateUrl(domain);
|
|
72
|
-
const result = await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
);
|
|
79
65
|
return result[domain];
|
|
80
66
|
}
|
|
81
67
|
__name(getDomainInfo, "getDomainInfo");
|
|
82
68
|
function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") {
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
+
})
|
|
89
81
|
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
}, import_fetch.FetchResultTypes.JSON);
|
|
82
|
+
fetch.FetchResultTypes.JSON
|
|
83
|
+
);
|
|
94
84
|
}
|
|
95
85
|
__name(reportCaughtPhish, "reportCaughtPhish");
|
|
96
86
|
async function setApiKey(key) {
|
|
@@ -100,13 +90,17 @@ async function setApiKey(key) {
|
|
|
100
90
|
__name(setApiKey, "setApiKey");
|
|
101
91
|
async function checkApiKey(apiKey) {
|
|
102
92
|
try {
|
|
103
|
-
await
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
);
|
|
110
104
|
} catch (error) {
|
|
111
105
|
const typedError = error;
|
|
112
106
|
if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") {
|
|
@@ -122,12 +116,11 @@ function validateUrl(domain) {
|
|
|
122
116
|
throw new Error("[SapphirePhisherman]: Invalid domain provided");
|
|
123
117
|
}
|
|
124
118
|
__name(validateUrl, "validateUrl");
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
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
|
|
133
126
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/lib/Phisherman.ts"],"names":[],"mappings":";;;;AAAA,SAAS,OAAO,cAAc,wBAAoC;AAElE,OAAO,QAAQ;AAEf,IAAM,QAAQ,0CAA0C,GAAG,SAAS,KAAK,GAAG,QAAQ;AAIpF,IAAI;AAQJ,eAAsB,YAAY,QAAgB,SAAiB,cAAc;AAChF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM;AAAA,IACpB,8CAA8C;AAAA,IAC9C;AAAA,MACC,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,IACD;AAAA,IACA,iBAAiB;AAAA,EAClB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAQ,OAAO,mBAAmB,UAAU,OAAO,mBAAmB,YAAY,QAAQ;AAAA,EAC3F;AACD;AAlBsB;AA0Bf,SAAS,aAAa,QAAgB,SAAiB,cAAc;AAC3E,cAAY,MAAM;AAClB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQ,aAAa;AAAA,MACrB,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACpB,KAAK;AAAA,MACN,CAAC;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,EAClB;AACD;AAjBgB;AAyBhB,eAAsB,cAAc,QAAgB,SAAiB,cAAc;AAClF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM;AAAA,IACpB,6CAA6C;AAAA,IAC7C;AAAA,MACC,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,IACD;AAAA,IACA,iBAAiB;AAAA,EAClB;AACA,SAAO,OAAO,MAAM;AACrB;AAdsB;AAuBf,SAAS,kBAAkB,QAAgB,SAAiB,cAAc,UAA2B,IAAI;AAC/G,SAAO;AAAA,IACN,6CAA6C;AAAA,IAC7C;AAAA,MACC,QAAQ,aAAa;AAAA,MACrB,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;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;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,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(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
package/dist/index.mjs.map
CHANGED
|
@@ -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"]
|
|
1
|
+
{"version":3,"sources":["../src/lib/Phisherman.ts"],"names":[],"mappings":";;;;AAAA,SAAS,OAAO,cAAc,wBAAoC;AAElE,OAAO,QAAQ;AAEf,IAAM,QAAQ,0CAA0C,GAAG,SAAS,KAAK,GAAG,QAAQ;AAIpF,IAAI;AAQJ,eAAsB,YAAY,QAAgB,SAAiB,cAAc;AAChF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM;AAAA,IACpB,8CAA8C;AAAA,IAC9C;AAAA,MACC,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,IACD;AAAA,IACA,iBAAiB;AAAA,EAClB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAQ,OAAO,mBAAmB,UAAU,OAAO,mBAAmB,YAAY,QAAQ;AAAA,EAC3F;AACD;AAlBsB;AA0Bf,SAAS,aAAa,QAAgB,SAAiB,cAAc;AAC3E,cAAY,MAAM;AAClB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQ,aAAa;AAAA,MACrB,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACpB,KAAK;AAAA,MACN,CAAC;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,EAClB;AACD;AAjBgB;AAyBhB,eAAsB,cAAc,QAAgB,SAAiB,cAAc;AAClF,cAAY,MAAM;AAClB,QAAM,SAAS,MAAM;AAAA,IACpB,6CAA6C;AAAA,IAC7C;AAAA,MACC,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;AAAA,IACD;AAAA,IACA,iBAAiB;AAAA,EAClB;AACA,SAAO,OAAO,MAAM;AACrB;AAdsB;AAuBf,SAAS,kBAAkB,QAAgB,SAAiB,cAAc,UAA2B,IAAI;AAC/G,SAAO;AAAA,IACN,6CAA6C;AAAA,IAC7C;AAAA,MACC,QAAQ,aAAa;AAAA,MACrB,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,eAAe,UAAU;AAAA,MAC1B;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;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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/phisherman",
|
|
3
|
-
"version": "1.4.2-next.
|
|
3
|
+
"version": "1.4.2-next.77f33a8.0",
|
|
4
4
|
"description": "Wrapper around phisherman to easily check and report domains",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
"homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/phisherman",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint src --ext ts --fix",
|
|
18
|
-
"build": "tsup
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"docs": "typedoc-json-parser",
|
|
19
20
|
"prepack": "yarn build",
|
|
20
21
|
"bump": "cliff-jumper",
|
|
21
22
|
"check-update": "cliff-jumper --dry-run"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@sapphire/fetch": "^2.
|
|
25
|
+
"@sapphire/fetch": "^2.4.2-next.77f33a8.0"
|
|
25
26
|
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
@@ -56,7 +57,10 @@
|
|
|
56
57
|
"access": "public"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
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"
|
|
61
65
|
}
|
|
62
66
|
}
|
package/dist/lib/Phisherman.d.ts
DELETED
|
@@ -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
|