1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-25 03:33:33 +01:00
This commit is contained in:
TheArcaneBrony 2022-09-04 10:44:33 +02:00
parent 8c92b197e4
commit 3a3417cded
No known key found for this signature in database
GPG Key ID: 32FC5AAADAD75A22
24 changed files with 1447 additions and 1645 deletions

View File

@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---
**Describe the bug**
@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
@ -24,18 +24,20 @@ A clear and concise description of what you expected to happen.
If applicable, add console logs to help give more information about your problem.
**System Information (please complete the following information):**
- OS: [e.g. Debian Linux, Arch Linux etc.]
- Version (If not applicable skip): [e.g Ubuntu 22.04 LTS/Windows Server 2022]
- Node Version: [e.g Node v18.7.0]
- Python 3 Version: [e.g Python 3.10.6]
- OS: [e.g. Debian Linux, Arch Linux etc.]
- Version (If not applicable skip): [e.g Ubuntu 22.04 LTS/Windows Server 2022]
- Node Version: [e.g Node v18.7.0]
- Python 3 Version: [e.g Python 3.10.6]
**Env and Software info**
- Release: [e.g. 0.1.0]
- Branch (if release is not applicable): [e.g Staging]
- Commit Hash (if release is not applicable): [e.g 401eda069a3ced17f1c43294d19765663cb8dcb7]
- Database: [e.g Postgres 14]
- Reverse Proxy: [e.g ngnix]
- Thread Count: [e.g 1]
- Release: [e.g. 0.1.0]
- Branch (if release is not applicable): [e.g Staging]
- Commit Hash (if release is not applicable): [e.g 401eda069a3ced17f1c43294d19765663cb8dcb7]
- Database: [e.g Postgres 14]
- Reverse Proxy: [e.g ngnix]
- Thread Count: [e.g 1]
**Additional context**
Add any other context about the problem here.

View File

@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an feature for Fosscord Server
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---
**Is your feature request related to a problem? Please describe.**

View File

@ -72,7 +72,7 @@
localStorage.setItem("UserSettingsStore", JSON.stringify(settings));
}
</script>
<script src="/assets/checkLocale.js"></script>
<script src="/assets/2f2e0c25e45eb2f5a6f1.js"></script>
<script src="/assets/006e72c08a4c69cb66fc.js"></script>

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ async function main() {
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
}
server.listen(port);
await Promise.all([api.start(), cdn.start(), gateway.start()]);

View File

@ -45,8 +45,8 @@ export default function TestClient(app: Application) {
res.set(name, value);
});
} else {
if(req.params.file.endsWith(".map")) {
return res.status(404).send("Not found");
if (req.params.file.endsWith(".map")) {
return res.status(404).send("Not found");
}
console.log(`[TestClient] Downloading file not yet cached! Asset file: ${req.params.file}`);
response = await fetch(`https://discord.com/assets/${req.params.file}`, {

View File

@ -1,5 +1,5 @@
import { route } from "@fosscord/api";
import { Application, Config, FieldErrors, generateToken, handleFile, OrmUtils, trimSpecial, User, HTTPError } from "@fosscord/util";
import { Application, Config, FieldErrors, generateToken, handleFile, HTTPError, OrmUtils, trimSpecial, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
import { verifyToken } from "node-2fa";

View File

@ -1,7 +1,7 @@
import { Request, Response, Router } from "express";
import { route, getIpAdress, verifyCaptcha } from "@fosscord/api";
import { Config, User, generateToken, adjustEmail, FieldErrors, LoginSchema } from "@fosscord/util";
import { getIpAdress, route, verifyCaptcha } from "@fosscord/api";
import { adjustEmail, Config, FieldErrors, generateToken, LoginSchema, User } from "@fosscord/util";
import crypto from "crypto";
import { Request, Response, Router } from "express";
let bcrypt: any;
try {
@ -38,7 +38,7 @@ router.post("/", route({ body: "LoginSchema" }), async (req: Request, res: Respo
captcha_key: verify["error-codes"],
captcha_sitekey: sitekey,
captcha_service: service
})
});
}
}

View File

@ -1,5 +1,5 @@
import { route } from "@fosscord/api";
import { BackupCode, generateToken, TotpSchema, User, HTTPError } from "@fosscord/util";
import { BackupCode, generateToken, HTTPError, TotpSchema, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
import { verifyToken } from "node-2fa";
const router = Router();

View File

@ -1,6 +1,6 @@
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { FieldErrors, User, BackupCodesChallengeSchema } from "@fosscord/util";
import { BackupCodesChallengeSchema, FieldErrors, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
let bcrypt: any;
try {
@ -17,13 +17,13 @@ router.post("/", route({ body: "BackupCodesChallengeSchema" }), async (req: Requ
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] });
if (!await bcrypt.compare(password, user.data.hash || "")) {
if (!(await bcrypt.compare(password, user.data.hash || ""))) {
throw FieldErrors({ password: { message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } });
}
return res.json({
nonce: "NoncePlaceholder",
regenerate_nonce: "RegenNoncePlaceholder",
regenerate_nonce: "RegenNoncePlaceholder"
});
});

View File

@ -1,8 +1,8 @@
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { Request, Response, Router } from "express";
const router = Router();
router.get("/",route({}), async (req: Request, res: Response) => {
router.get("/", route({}), async (req: Request, res: Response) => {
// TODO: member verification
res.status(404).json({

View File

@ -134,159 +134,159 @@ const skus = new Map([
price: 0,
price_tier: null
}
],
]
],
[
"978380684370378762",
[
[
{
"id": "978380692553465866",
"name": "Premium Tier 0 Monthly",
"interval": 1,
"interval_count": 1,
"tax_inclusive": true,
"sku_id": "978380684370378762",
"currency": "usd",
"price": 299,
"price_tier": null,
"prices": {
id: "978380692553465866",
name: "Premium Tier 0 Monthly",
interval: 1,
interval_count: 1,
tax_inclusive: true,
sku_id: "978380684370378762",
currency: "usd",
price: 299,
price_tier: null,
prices: {
"0": {
"country_prices": {
"country_code": "US",
"prices": [
country_prices: {
country_code: "US",
prices: [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
},
"payment_source_prices": {
payment_source_prices: {
"775487223059316758": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"736345864146255982": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"683074999590060249": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
}
},
"3": {
"country_prices": {
"country_code": "US",
"prices": [
country_prices: {
country_code: "US",
prices: [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
},
"payment_source_prices": {
payment_source_prices: {
"775487223059316758": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"736345864146255982": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"683074999590060249": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
}
},
"4": {
"country_prices": {
"country_code": "US",
"prices": [
country_prices: {
country_code: "US",
prices: [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
},
"payment_source_prices": {
payment_source_prices: {
"775487223059316758": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"736345864146255982": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"683074999590060249": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
}
},
"1": {
"country_prices": {
"country_code": "US",
"prices": [
country_prices: {
country_code: "US",
prices: [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
},
"payment_source_prices": {
payment_source_prices: {
"775487223059316758": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"736345864146255982": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
],
"683074999590060249": [
{
"currency": "usd",
"amount": 0,
"exponent": 2
currency: "usd",
amount: 0,
exponent: 2
}
]
}

View File

@ -1,6 +1,6 @@
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
import { BackupCode, generateMfaBackupCodes, User, CodesVerificationSchema } from "@fosscord/util";
import { BackupCode, CodesVerificationSchema, generateMfaBackupCodes, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
const router = Router();
@ -14,27 +14,23 @@ router.post("/", route({ body: "CodesVerificationSchema" }), async (req: Request
var codes: BackupCode[];
if (regenerate) {
await BackupCode.update(
{ user: { id: req.user_id } },
{ expired: true }
);
await BackupCode.update({ user: { id: req.user_id } }, { expired: true });
codes = generateMfaBackupCodes(req.user_id);
await Promise.all(codes.map(x => x.save()));
}
else {
await Promise.all(codes.map((x) => x.save()));
} else {
codes = await BackupCode.find({
where: {
user: {
id: req.user_id,
id: req.user_id
},
expired: false,
expired: false
}
});
}
return res.json({
backup_codes: codes.map(x => ({ ...x, expired: undefined })),
backup_codes: codes.map((x) => ({ ...x, expired: undefined }))
});
});

View File

@ -1,5 +1,5 @@
import { route } from "@fosscord/api";
import { BackupCode, generateToken, TotpDisableSchema, User, HTTPError } from "@fosscord/util";
import { BackupCode, generateToken, HTTPError, TotpDisableSchema, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
import { verifyToken } from "node-2fa";

View File

@ -1,5 +1,5 @@
import { route } from "@fosscord/api";
import { BackupCode, Config, generateMfaBackupCodes, generateToken, TotpEnableSchema, User, HTTPError } from "@fosscord/util";
import { BackupCode, Config, generateMfaBackupCodes, generateToken, HTTPError, TotpEnableSchema, User } from "@fosscord/util";
import { Request, Response, Router } from "express";
import { verifyToken } from "node-2fa";

View File

@ -3,8 +3,8 @@ export * from "./handlers/Message";
export * from "./handlers/route";
export * from "./handlers/Voice";
export * from "./utility/Base64";
export * from "./utility/captcha";
export * from "./utility/ipAddress";
export * from "./utility/passwordStrength";
export * from "./utility/RandomInviteID";
export * from "./utility/String";
export * from "./utility/captcha";

View File

@ -7,8 +7,8 @@ export interface hcaptchaResponse {
hostname: string;
credit: boolean;
"error-codes": string[];
score: number; // enterprise only
score_reason: string[]; // enterprise only
score: number; // enterprise only
score_reason: string[]; // enterprise only
}
export interface recaptchaResponse {
@ -22,8 +22,8 @@ export interface recaptchaResponse {
const verifyEndpoints = {
hcaptcha: "https://hcaptcha.com/siteverify",
recaptcha: "https://www.google.com/recaptcha/api/siteverify",
}
recaptcha: "https://www.google.com/recaptcha/api/siteverify"
};
export async function verifyCaptcha(response: string, ip?: string) {
const { security } = Config.get();
@ -34,13 +34,14 @@ export async function verifyCaptcha(response: string, ip?: string) {
const res = await fetch(verifyEndpoints[service], {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Type": "application/x-www-form-urlencoded"
},
body: `response=${encodeURIComponent(response)}`
+ `&secret=${encodeURIComponent(secret!)}`
+ `&sitekey=${encodeURIComponent(sitekey!)}`
+ (ip ? `&remoteip=${encodeURIComponent(ip!)}` : ""),
body:
`response=${encodeURIComponent(response)}` +
`&secret=${encodeURIComponent(secret!)}` +
`&sitekey=${encodeURIComponent(sitekey!)}` +
(ip ? `&remoteip=${encodeURIComponent(ip!)}` : "")
});
return await res.json() as hcaptchaResponse | recaptchaResponse;
}
return (await res.json()) as hcaptchaResponse | recaptchaResponse;
}

View File

@ -1,6 +1,13 @@
import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn, RelationId } from "typeorm";
import { Ban, PublicGuildRelations, Message } from ".";
import { GuildCreateEvent, GuildDeleteEvent, GuildMemberAddEvent, GuildMemberRemoveEvent, GuildMemberUpdateEvent, MessageCreateEvent } from "../interfaces";
import { Ban, Message, PublicGuildRelations } from ".";
import {
GuildCreateEvent,
GuildDeleteEvent,
GuildMemberAddEvent,
GuildMemberRemoveEvent,
GuildMemberUpdateEvent,
MessageCreateEvent
} from "../interfaces";
import { Config, emitEvent } from "../util";
import { DiscordApiErrors } from "../util/Constants";
import { HTTPError } from "../util/imports/HTTPError";
@ -301,7 +308,7 @@ export class Member extends BaseClassWithoutId {
presences: [],
stage_instances: [],
threads: [],
embedded_activities: [],
embedded_activities: []
},
user_id
} as GuildCreateEvent)
@ -320,7 +327,7 @@ export class Member extends BaseClassWithoutId {
attachments: [],
embeds: [],
sticker_items: [],
edited_timestamp: undefined,
edited_timestamp: undefined
});
await Promise.all([
message.save(),

View File

@ -1,40 +1,39 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class guildMemberProfiles1661885910534 implements MigrationInterface {
name = 'guildMemberProfiles1661885910534'
name = "guildMemberProfiles1661885910534";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`members\`
ADD \`avatar\` varchar(255) NULL
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\`
ADD \`banner\` varchar(255) NULL
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\`
ADD \`bio\` varchar(255) NOT NULL
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\`
ADD \`communication_disabled_until\` datetime NULL
`);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE \`members\` DROP COLUMN \`communication_disabled_until\`
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\` DROP COLUMN \`bio\`
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\` DROP COLUMN \`banner\`
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE \`members\` DROP COLUMN \`avatar\`
`);
}
}
}

View File

@ -1,40 +1,39 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class guildMemberProfiles1661885830688 implements MigrationInterface {
name = 'guildMemberProfiles1661885830688'
name = "guildMemberProfiles1661885830688";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "members"
ADD "avatar" character varying
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members"
ADD "banner" character varying
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members"
ADD "bio" character varying NOT NULL default ''
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members"
ADD "communication_disabled_until" TIMESTAMP
`);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "members" DROP COLUMN "communication_disabled_until"
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members" DROP COLUMN "bio"
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members" DROP COLUMN "banner"
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members" DROP COLUMN "avatar"
`);
}
}
}

View File

@ -1,13 +1,13 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class guildMemberProfiles1661885742207 implements MigrationInterface {
name = 'guildMemberProfiles1661885742207'
name = "guildMemberProfiles1661885742207";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
`);
await queryRunner.query(`
await queryRunner.query(`
CREATE TABLE "temporary_members" (
"index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"id" varchar NOT NULL,
@ -29,7 +29,7 @@ export class guildMemberProfiles1661885742207 implements MigrationInterface {
CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
)
`);
await queryRunner.query(`
await queryRunner.query(`
INSERT INTO "temporary_members"(
"index",
"id",
@ -58,27 +58,27 @@ export class guildMemberProfiles1661885742207 implements MigrationInterface {
"joined_by"
FROM "members"
`);
await queryRunner.query(`
await queryRunner.query(`
DROP TABLE "members"
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "temporary_members"
RENAME TO "members"
`);
await queryRunner.query(`
await queryRunner.query(`
CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
`);
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3"
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE "members"
RENAME TO "temporary_members"
`);
await queryRunner.query(`
await queryRunner.query(`
CREATE TABLE "members" (
"index" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
"id" varchar NOT NULL,
@ -96,7 +96,7 @@ export class guildMemberProfiles1661885742207 implements MigrationInterface {
CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION
)
`);
await queryRunner.query(`
await queryRunner.query(`
INSERT INTO "members"(
"index",
"id",
@ -125,12 +125,11 @@ export class guildMemberProfiles1661885742207 implements MigrationInterface {
"joined_by"
FROM "temporary_members"
`);
await queryRunner.query(`
await queryRunner.query(`
DROP TABLE "temporary_members"
`);
await queryRunner.query(`
await queryRunner.query(`
CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id")
`);
}
}
}

View File

@ -1,3 +1,3 @@
export interface BackupCodesChallengeSchema {
password: string;
}
}

View File

@ -2,4 +2,4 @@ export interface CodesVerificationSchema {
key: string;
nonce: string;
regenerate?: boolean;
}
}

View File

@ -44,4 +44,4 @@ export * from "./UserSettingsSchema";
export * from "./VanityUrlSchema";
export * from "./VoiceStateUpdateSchema";
export * from "./WebhookCreateSchema";
export * from "./WidgetModifySchema";
export * from "./WidgetModifySchema";