'use strict'; var fetch = require('@sapphire/fetch'); var os = require('os'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var os__default = /*#__PURE__*/_interopDefault(os); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var packageVersion = "2.0.1"; var agent = `Sapphire Phisherman/${packageVersion} (undici) ${os__default.default.platform()}/${os__default.default.release()} (https://github.com/sapphiredev/utilities/tree/main/packages/phisherman)`; var storedApiKey; async function checkDomain(domain, apiKey = storedApiKey) { validateUrl(domain); const result = await fetch.fetch( `https://api.phisherman.gg/v2/domains/check/${domain}`, { headers: { "Content-Type": "application/json", "User-Agent": agent, Authorization: `Bearer ${apiKey}` } }, fetch.FetchResultTypes.JSON ); return { ...result, isScam: result.classification === "safe" || result.classification === "unknown" ? false : true }; } __name(checkDomain, "checkDomain"); function reportDomain(domain, apiKey = storedApiKey) { validateUrl(domain); return fetch.fetch( `https://api.phisherman.gg/v2/phish/report`, { method: fetch.FetchMethods.Put, headers: { "Content-Type": "application/json", "User-Agent": agent, Authorization: `Bearer ${apiKey}` }, body: JSON.stringify({ url: domain }) }, fetch.FetchResultTypes.JSON ); } __name(reportDomain, "reportDomain"); async function getDomainInfo(domain, apiKey = storedApiKey) { validateUrl(domain); const result = await fetch.fetch( `https://api.phisherman.gg/v2/domains/info/${domain}`, { headers: { "Content-Type": "application/json", "User-Agent": agent, Authorization: `Bearer ${apiKey}` } }, fetch.FetchResultTypes.JSON ); return result[domain]; } __name(getDomainInfo, "getDomainInfo"); function reportCaughtPhish(domain, apiKey = storedApiKey, guildId = "") { return fetch.fetch( `https://api.phisherman.gg/v2/phish/caught/${domain}`, { method: fetch.FetchMethods.Post, headers: { "Content-Type": "application/json", "User-Agent": agent, Authorization: `Bearer ${apiKey}` }, body: JSON.stringify({ guild: Number(guildId) }) }, fetch.FetchResultTypes.JSON ); } __name(reportCaughtPhish, "reportCaughtPhish"); async function setApiKey(key) { await checkApiKey(key); storedApiKey = key; } __name(setApiKey, "setApiKey"); async function checkApiKey(apiKey) { try { await fetch.fetch( `https://api.phisherman.gg/v2/domains/check/verified.test.phisherman.gg`, { headers: { "Content-Type": "application/json", "User-Agent": agent, Authorization: `Bearer ${apiKey}` } }, fetch.FetchResultTypes.JSON ); } catch (error) { const typedError = error; if (typedError.code === 401 && typedError.toJSON().message === "missing permissions or invalid API key") { throw new Error("[SapphirePhisherman]: Invalid API key provided"); } throw error; } } __name(checkApiKey, "checkApiKey"); function validateUrl(domain) { const regexp = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi; if (!domain.match(regexp)) throw new Error("[SapphirePhisherman]: Invalid domain provided"); } __name(validateUrl, "validateUrl"); exports.checkDomain = checkDomain; exports.getDomainInfo = getDomainInfo; exports.reportCaughtPhish = reportCaughtPhish; exports.reportDomain = reportDomain; exports.setApiKey = setApiKey; //# sourceMappingURL=out.js.map //# sourceMappingURL=index.cjs.map