1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-09 12:12:35 +01:00
This commit is contained in:
Flam3rboy 2021-01-01 22:26:20 +01:00
parent bb9a76a2a1
commit e5f35fbdf9
9 changed files with 3035 additions and 1273 deletions

BIN
.DS_Store vendored

Binary file not shown.

2
.gitignore vendored
View File

@ -102,3 +102,5 @@ dist
# TernJS port file
.tern-port
.DS_STORE

4178
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,33 @@
{
"name": "discord-server-opensource",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Trenite/discord-server-opensource.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Trenite/discord-server-opensource/issues"
},
"homepage": "https://github.com/Trenite/discord-server-opensource#readme",
"devDependencies": {
"@types/node": "^14.14.10",
"typescript": "^4.1.2"
},
"dependencies": {
"@types/express": "^4.17.9",
"@types/node-fetch": "^2.5.7",
"express": "^4.17.1",
"express-cache-middleware": "^1.0.1",
"node-fetch": "^2.6.1"
}
"name": "discord-server-opensource",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Trenite/discord-server-opensource.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Trenite/discord-server-opensource/issues"
},
"homepage": "https://github.com/Trenite/discord-server-opensource#readme",
"dependencies": {
"@types/express": "^4.17.9",
"@types/node-fetch": "^2.5.7",
"express": "^4.17.1",
"express-cache-middleware": "^1.0.1",
"lambert-db": "^1.0.3",
"missing-native-js-functions": "^1.0.8",
"node-fetch": "^2.6.1"
},
"devDependencies": {
"@types/node": "^14.14.10",
"typescript": "^4.1.2"
}
}

View File

@ -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}`));
}
}

View File

@ -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;

52
src/exampleFetch.ts Normal file
View File

@ -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"}
*/

View File

View File