summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Server.ts5
-rw-r--r--src/Utils.ts11
-rw-r--r--src/exampleFetch.ts52
-rw-r--r--src/routes/api/v8/auth/login.ts0
-rw-r--r--src/routes/api/v8/auth/register.ts0
5 files changed, 55 insertions, 13 deletions
diff --git a/src/Server.ts b/src/Server.ts

index ca03e0d2..92c73a35 100644 --- a/src/Server.ts +++ b/src/Server.ts
@@ -1,7 +1,6 @@ import express, { Application, Router } from "express"; import { traverseDirectory } from "./Utils"; import { Server as HTTPServer } from "http"; -import fetch from "node-fetch"; import fs from "fs/promises"; export type ServerOptions = { @@ -56,13 +55,13 @@ export class Server { var router = require(file); if (router.router) router = router.router; if (router.default) router = router.default; - if (!router || router.prototype.constructor.name !== "router") + if (!router || router?.prototype?.constructor?.name !== "router") throw `File doesn't export any default router`; this.app.use(path, <Router>router); console.log(`[Server] Route ${path} registerd`); return router; } catch (error) { - console.error(new Error(`[Server] Failed to register route ${file}: ${error}`)); + console.error(new Error(`[Server] Failed to register route ${path}: ${error}`)); } } diff --git a/src/Utils.ts b/src/Utils.ts
index 09d8e8c6..291372c1 100644 --- a/src/Utils.ts +++ b/src/Utils.ts
@@ -1,14 +1,5 @@ import fs from "fs/promises"; - -declare global { - interface Array<T> { - flat(): T; - } -} - -Array.prototype.flat = function () { - return this.reduce((acc, val) => (Array.isArray(val) ? acc.concat(val.flat()) : acc.concat(val)), []); -}; +import "missing-native-js-functions"; export interface traverseDirectoryOptions { dirname: string; diff --git a/src/exampleFetch.ts b/src/exampleFetch.ts new file mode 100644
index 00000000..9c433e4b --- /dev/null +++ b/src/exampleFetch.ts
@@ -0,0 +1,52 @@ +import fetch from "node-fetch"; + +fetch("https://discord.com/api/v8/auth/login", { + headers: { + authorization: "undefined", + "content-type": "application/json", + "x-fingerprint": "782364413927751692.ex9RorNkBsGynrJCe5Brxtc3Ytc", + "x-super-properties": + "eyJvcyI6Ik1hYyBPUyBYIiwiYnJvd3NlciI6IkNocm9tZSIsImRldmljZSI6IiIsImJyb3dzZXJfdXNlcl9hZ2VudCI6Ik1vemlsbGEvNS4wIChNYWNpbnRvc2g7IEludGVsIE1hYyBPUyBYIDEwXzE1XzcpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS84Ny4wLjQyODAuNjcgU2FmYXJpLzUzNy4zNiIsImJyb3dzZXJfdmVyc2lvbiI6Ijg3LjAuNDI4MC42NyIsIm9zX3ZlcnNpb24iOiIxMC4xNS43IiwicmVmZXJyZXIiOiIiLCJyZWZlcnJpbmdfZG9tYWluIjoiIiwicmVmZXJyZXJfY3VycmVudCI6IiIsInJlZmVycmluZ19kb21haW5fY3VycmVudCI6IiIsInJlbGVhc2VfY2hhbm5lbCI6InN0YWJsZSIsImNsaWVudF9idWlsZF9udW1iZXIiOjcyMzc2LCJjbGllbnRfZXZlbnRfc291cmNlIjpudWxsfQ==", + }, + body: JSON.stringify({ + login: "email@gmail.com", + password: "cleartextpassword", + undelete: false, + captcha_key: null, + login_source: null, + gift_code_sku_id: null, + }), + method: "POST", +}); +/** + * @returns {"token": null, "mfa": true, "sms": true, "ticket": "WzMxMTEyOTM1NzM2MjEzNTA0MSwibG9naW4iXQ.X8LHqg.vTwtZBaLu5W_XMMSvKad1OAaEoA"} + */ + +fetch("https://discord.com/api/v8/auth/mfa/totp", { + headers: { + authorization: "undefined", + "content-type": "application/json", + }, + body: JSON.stringify({ + code: "722608", + ticket: "WzMxMTEyOTM1NzM2MjEzNTA0MSwibG9naW4iXQ.X8LHqg.vTwtZBaLu5W_XMMSvKad1OAaEoA", + login_source: null, + gift_code_sku_id: null, + }), + method: "POST", +}); +/** + * @returns {"token": "mfa.-Rg2AwyP06YdTPmIDt0sqA92T8fBVITLTcXjP7zO_Uhgkg1FA0WERGjJXJyN_dyVDeBnxIWr0w3XiXW8YxVw", "user_settings": {"locale": "en-GB", "theme": "dark"}} + */ + +// token: mfa.-Rg2AwyP06YdTPmIDt0sqA92T8fBVITLTcXjP7zO_Uhgkg1FA0WERGjJXJyN_dyVDeBnxIWr0w3XiXW8YxVw + +fetch("https://discord.com/api/v8/gateway", { + headers: { + authorization: "token", + }, + method: "GET", +}); +/** + * @returns {"url": "wss://gateway.discord.gg"} + */ diff --git a/src/routes/api/v8/auth/login.ts b/src/routes/api/v8/auth/login.ts new file mode 100644
index 00000000..e69de29b --- /dev/null +++ b/src/routes/api/v8/auth/login.ts
diff --git a/src/routes/api/v8/auth/register.ts b/src/routes/api/v8/auth/register.ts new file mode 100644
index 00000000..e69de29b --- /dev/null +++ b/src/routes/api/v8/auth/register.ts