From 4350ce931bff7ea94eb7568f1743966cf748c324 Mon Sep 17 00:00:00 2001 From: doqedev Date: Thu, 9 Oct 2025 22:01:11 -0700 Subject: [PATCH] added scanning functionality --- src/class.ts | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 2 ++ src/types.ts | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 src/class.ts create mode 100644 src/index.ts create mode 100644 src/types.ts diff --git a/src/class.ts b/src/class.ts new file mode 100644 index 0000000..3a99b39 --- /dev/null +++ b/src/class.ts @@ -0,0 +1,64 @@ +import fetch from "cross-fetch"; +import { CheckResult } from "./types"; + +const TASEApi = `https://tase-staging.thegoober.xyz` + +export class TASEClient { + private token: string; + + constructor(APIToken: string){ + this.token = APIToken + } + + async checkUser(UserID: string): Promise { + if(UserID.length < 16 || UserID.length > 20) throw new Error("A UserID must be between 16-20 characters.") + + const Response = await fetch(TASEApi + `/api/v1/check/${UserID}`, { + headers: { + authorization: `Bearer ${this.token}` + }, + method: "GET" + }) + + if(!Response.ok){ + switch(Response.status){ + case 401: + throw new Error("Invalid API Key.") + case 403: + throw new Error("Your API key has been blacklisted.") + default: + throw new Error(`Unknown API error (code ${Response.status}: ${Response.statusText})`) + } + } + + return Response.json() + } + + async checkUsers(UserIDs: string[]): Promise> { + if(UserIDs.find((Value) => Value.length < 16 || Value.length > 20)) throw new Error("All UserIDs must be between 16-20 characters.") + if(UserIDs.length > 10000) throw new Error("The amount of UserIDs must be less than 10,000.") + if(UserIDs.length < 1) throw new Error("The amount of UserIDs must be atleast 1 character.") + + const Response = await fetch(TASEApi + `/api/v1/mass-check`, { + headers: { + authorization: `Bearer ${this.token}`, + "content-type": "application/json" + }, + body: JSON.stringify(UserIDs), + method: "POST" + }) + + if(!Response.ok){ + switch(Response.status){ + case 401: + throw new Error("Invalid API Key.") + case 403: + throw new Error("Your API key has been blacklisted.") + default: + throw new Error(`Unknown API error (code ${Response.status}: ${Response.statusText})`) + } + } + + return Response.json() + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..349452e --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export * from "./class" +export * from "./types" \ No newline at end of file diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..82b8964 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,61 @@ +export interface CheckGuild { + /** + * What is the Guild ID of the server? + */ + id: string + /** + * What is this server's name? + */ + name: string, + /** + * What type of server is this? + */ + type: string, + /** + * What versions was this user detected with? + */ + detectedWith: Array + /** + * When was the user last seen inside the condo server? + */ + lastSeen: Date | undefined, + /** + * When was the user first seen inside the condo server? + */ + firstSeen: Date | undefined, + /** + * Has the user boosted this server before? + */ + isBooster: boolean, + /** + * Does the user have certain roles? + */ + isStaff: boolean + /** + * A number calculated on how much a user has interacted with this guild. + */ + score: number +} + +export interface CheckResult { + /** + * What is the ID of the user? + */ + userId: string, + /** + * When did this user appeal? (if they have appealed.) + */ + appealDate?: Date + /** + * The summed up score of all the `guilds`. + */ + scoreSum: number, + /** + * When was the user last seen? + */ + lastSeen: Date | undefined, + /** + * An array of guilds the user has been detected in, with certain properties. + */ + guilds: Array +}