import { crypto, toHashString } from "@std/crypto/mod.ts"; export interface Location { country: string; region: string; } interface InternalLocation { status: string; country: string; countryCode: string; region: string; regionName: string; city: string; zip: string; lat: number; lon: number; timezone: string; isp: string; org: string; as: string; query: string; } /** deviously lick (an ip's geolocation) */ export async function deviousLick(ip: string): Promise { const res = await fetch(`http://ip-api.com/json/${ip}`); const data: InternalLocation = await res.json(); return { country: data.country, region: data.regionName, } as Location; } export async function hash(str: string): Promise { const digest = await crypto.subtle.digest( "SHA3-256", new TextEncoder().encode(str), ); return toHashString(digest, "hex"); }