//native
type Greip = {
apiKey: string;
};
/**
* Retrieve threat intelligence information for a given IP address
* Access comprehensive threat intelligence data linked to a specific IP address. This endpoint provides insights into malicious activity, reputation scoring, and potential security risks associated with the IP address.
*/
export async function main(
auth: Greip,
ip: string,
format: string | undefined,
userID: string | undefined,
mode: string | undefined,
callback: string | undefined,
) {
const url = new URL(`https://greipapi.com/lookup/ip/threats`);
for (const [k, v] of [
["ip", ip],
["format", format],
["userID", userID],
["mode", mode],
["callback", callback],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago