diff --git a/fosscord-server.code-workspace b/fosscord-server.code-workspace index e618b7f0..cd060713 100644 --- a/fosscord-server.code-workspace +++ b/fosscord-server.code-workspace @@ -23,7 +23,12 @@ }, { "path": "webrtc" + }, + { + "path": "slowcord" } ], - "settings": {} + "settings": { + "typescript.tsdk": "util\\node_modules\\typescript\\lib" + } } diff --git a/slowcord/.env.template b/slowcord/.env.template new file mode 100644 index 00000000..34f6abeb --- /dev/null +++ b/slowcord/.env.template @@ -0,0 +1,5 @@ +DATABASE=../bundle/database.db +PORT=3010 +DISCORD_CLIENT_ID= +DISCORD_SECRET= +DISCORD_REDIRECT= \ No newline at end of file diff --git a/slowcord/.vscode/launch.json b/slowcord/.vscode/launch.json new file mode 100644 index 00000000..0467baec --- /dev/null +++ b/slowcord/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + "configurations": [ + { + "name": "Launch Program", + "program": "${workspaceFolder}/build/index.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "node", + "preLaunchTask": "tsc: build - tsconfig.json" + } + ] +} \ No newline at end of file diff --git a/slowcord/.vscode/tasks.json b/slowcord/.vscode/tasks.json new file mode 100644 index 00000000..356126d8 --- /dev/null +++ b/slowcord/.vscode/tasks.json @@ -0,0 +1,13 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build", + "group": "build", + "problemMatcher": [], + "label": "npm: build", + "detail": "tsc -b" + } + ] +} \ No newline at end of file diff --git a/slowcord/README.md b/slowcord/README.md new file mode 100644 index 00000000..629e7724 --- /dev/null +++ b/slowcord/README.md @@ -0,0 +1 @@ +Additional resources/services for [Slowcord](slowcord.maddy.k.vu) \ No newline at end of file diff --git a/slowcord/build/index.js b/slowcord/build/index.js new file mode 100644 index 00000000..484113ed --- /dev/null +++ b/slowcord/build/index.js @@ -0,0 +1,102 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var _a; +import "dotenv/config"; +import express from "express"; +import cookieParser from "cookie-parser"; +import { initDatabase, generateToken, User, Config } from "@fosscord/util"; +import path from "path"; +import fetch from "node-fetch"; +const app = express(); +app.use(cookieParser()); +const port = process.env.PORT; +class Discord { +} +_a = Discord; +Discord.getAccessToken = (req, res) => __awaiter(void 0, void 0, void 0, function* () { + const { code } = req.query; + const body = new URLSearchParams(Object.entries({ + client_id: process.env.DISCORD_CLIENT_ID, + client_secret: process.env.DISCORD_SECRET, + redirect_uri: process.env.DISCORD_REDIRECT, + code: code, + grant_type: "authorization_code", + })).toString(); + const resp = yield fetch("https://discord.com/api/oauth2/token", { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: body + }); + const json = yield resp.json(); + if (json.error) + return null; + return { + access_token: json.access_token, + token_type: json.token_type, + expires_in: json.expires_in, + refresh_token: json.refresh_token, + scope: json.scope, + }; +}); +Discord.getUserDetails = (token) => __awaiter(void 0, void 0, void 0, function* () { + const resp = yield fetch("https://discord.com/api/users/@me", { + headers: { + "Authorization": `Bearer ${token}`, + } + }); + const json = yield resp.json(); + if (!json.username || !json.email) + return null; // eh, deal with bad code later + return { + email: json.email, + username: json.username, + }; +}); +const handlers = { + "discord": Discord, +}; +app.get("/oauth/:type", (req, res) => __awaiter(void 0, void 0, void 0, function* () { + const { type } = req.params; + if (!type) + return res.sendStatus(400); + const handler = handlers[type]; + if (!handler) + return res.sendStatus(400); + const data = yield handler.getAccessToken(req, res); + if (!data) + return res.sendStatus(500); + const details = yield handler.getUserDetails(data.access_token); + if (!details) + return res.sendStatus(500); + let user = yield User.findOne({ where: { email: details.email } }); + if (!user) { + user = yield User.register({ + email: details.email, + username: details.username, + req + }); + } + const token = yield generateToken(user.id); + res.cookie("token", token); + res.sendFile(path.join(__dirname, "../public/login.html")); +})); +app.get("*", (req, res) => { + res.sendFile(path.join(__dirname, "../public/login.html")); +}); +(() => __awaiter(void 0, void 0, void 0, function* () { + yield initDatabase(); + yield Config.init(); + app.listen(port, () => { + console.log(`Listening on port ${port}`); + }); +}))(); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/slowcord/build/index.js.map b/slowcord/build/index.js.map new file mode 100644 index 00000000..ca656f86 --- /dev/null +++ b/slowcord/build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,OAA8B,MAAM,SAAS,CAAC;AACrD,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;AACxB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AAE9B,MAAM,OAAO;;;AACL,sBAAc,GAAG,CAAO,GAAY,EAAE,GAAa,EAAE,EAAE;IAC7D,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE3B,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAA2B;QAClD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,cAAwB;QACnD,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA0B;QACpD,I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AAE;IACzB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,CAAC,GAAS,EAAE;IACX,MAAM,YAAY,EAAE,CAAC;IACrB,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAEpB,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAA,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/slowcord/package-lock.json b/slowcord/package-lock.json new file mode 100644 index 00000000..7ec24a87 Binary files /dev/null and b/slowcord/package-lock.json differ diff --git a/slowcord/package.json b/slowcord/package.json new file mode 100644 index 00000000..9a64c2b3 --- /dev/null +++ b/slowcord/package.json @@ -0,0 +1,33 @@ +{ + "name": "slowcord", + "version": "1.0.0", + "description": "Slowcord additional services", + "main": "build/index.js", + "scripts": { + "build": "tsc -b", + "run": "node build/index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/maddyunderstars/fosscord-server.git" + }, + "author": "", + "license": "AGPL-3.0-only", + "bugs": { + "url": "https://github.com/maddyunderstars/fosscord-server/issues" + }, + "homepage": "https://github.com/maddyunderstars/fosscord-server#readme", + "dependencies": { + "@fosscord/util": "file:../util", + "cookie-parser": "^1.4.6", + "dotenv": "^16.0.1", + "express": "^4.18.1", + "node-fetch": "^3.2.6" + }, + "devDependencies": { + "@types/cookie-parser": "^1.4.3", + "@types/express": "^4.17.13", + "@types/node": "^18.0.0" + }, + "type": "module" +} diff --git a/slowcord/public/login.html b/slowcord/public/login.html new file mode 100644 index 00000000..a695e597 --- /dev/null +++ b/slowcord/public/login.html @@ -0,0 +1,65 @@ + + + + + + + Slowcord + + + +
+
+ + + + + + Login with Discord + +
+
+ + + + + \ No newline at end of file diff --git a/slowcord/src/index.ts b/slowcord/src/index.ts new file mode 100644 index 00000000..3d397aaf --- /dev/null +++ b/slowcord/src/index.ts @@ -0,0 +1,104 @@ +import "dotenv/config"; +import express, { Request, Response } from "express"; +import cookieParser from "cookie-parser"; +import { initDatabase, generateToken, User, Config } from "@fosscord/util"; +import path from "path"; +import fetch from "node-fetch"; + +const app = express(); +app.use(cookieParser()); +const port = process.env.PORT; + +class Discord { + static getAccessToken = async (req: Request, res: Response) => { + const { code } = req.query; + + const body = new URLSearchParams(Object.entries({ + client_id: process.env.DISCORD_CLIENT_ID as string, + client_secret: process.env.DISCORD_SECRET as string, + redirect_uri: process.env.DISCORD_REDIRECT as string, + code: code as string, + grant_type: "authorization_code", + })).toString(); + + const resp = await fetch("https://discord.com/api/oauth2/token", { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: body + }); + + const json = await resp.json() as any; + if (json.error) return null; + + return { + access_token: json.access_token, + token_type: json.token_type, + expires_in: json.expires_in, + refresh_token: json.refresh_token, + scope: json.scope, + }; + }; + + static getUserDetails = async (token: string) => { + const resp = await fetch("https://discord.com/api/users/@me", { + headers: { + "Authorization": `Bearer ${token}`, + } + }); + + const json = await resp.json() as any; + if (!json.username || !json.email) return null; // eh, deal with bad code later + + return { + email: json.email, + username: json.username, + }; + }; +} + +const handlers: { [key: string]: any; } = { + "discord": Discord, +}; + +app.get("/oauth/:type", async (req, res) => { + const { type } = req.params; + if (!type) return res.sendStatus(400); + const handler = handlers[type]; + if (!handler) return res.sendStatus(400); + + const data = await handler.getAccessToken(req, res); + if (!data) return res.sendStatus(500); + + const details = await handler.getUserDetails(data.access_token); + if (!details) return res.sendStatus(500); + + let user = await User.findOne({ where: { email: details.email } }); + if (!user) { + user = await User.register({ + email: details.email, + username: details.username, + req + }); + } + + const token = await generateToken(user.id); + + res.cookie("token", token); + + res.sendFile(path.join(__dirname, "../public/login.html")); +}); + +app.get("*", (req, res) => { + res.sendFile(path.join(__dirname, "../public/login.html")); +}); + +(async () => { + await initDatabase(); + await Config.init(); + + app.listen(port, () => { + console.log(`Listening on port ${port}`); + }); +})(); \ No newline at end of file diff --git a/slowcord/tsconfig.json b/slowcord/tsconfig.json new file mode 100644 index 00000000..b8a5965d --- /dev/null +++ b/slowcord/tsconfig.json @@ -0,0 +1,99 @@ +{ + "exclude": [ + "node_modules" + ], + "include": [ + "src/**/*.ts" + ], + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "lib": ["ES2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + /* Modules */ + "module": "ES2020", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ + "types": ["node"], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./build", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + "strictPropertyInitialization": false, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} \ No newline at end of file diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index f3c40c83..c2c6fbbc 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -245,6 +245,7 @@ export class Channel extends BaseClass { static async createDMChannel(recipients: string[], creator_user_id: string, name?: string) { recipients = recipients.unique().filter((x) => x !== creator_user_id); + //@ts-ignore some typeorm typescript issue const otherRecipientsUsers = await User.find({ where: recipients.map((x) => ({ id: x })) }); // TODO: check config for max number of recipients diff --git a/util/src/util/Event.ts b/util/src/util/Event.ts index bb624051..20a638a0 100644 --- a/util/src/util/Event.ts +++ b/util/src/util/Event.ts @@ -62,6 +62,7 @@ export async function listenEvent(event: string, callback: (event: EventOpts) => msg.type === "event" && msg.id === event && callback({ ...msg.event, cancel }); }; + //@ts-ignore apparently theres no function addListener with this signature process.addListener("message", listener); process.setMaxListeners(process.getMaxListeners() + 1);