move devDependencies to dependencies
because bundle installs api/gateway/cdn as npm dep. and the dev packages don't get automatically installed
This commit is contained in:
Generated
+36
-5
@@ -19,7 +19,6 @@
|
||||
"atomically": "^1.7.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"canvas": "^2.8.0",
|
||||
"cheerio": "^1.0.0-rc.9",
|
||||
"dot-prop": "^6.0.1",
|
||||
"dotenv": "^8.2.0",
|
||||
@@ -2703,7 +2702,10 @@
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.8.0.tgz",
|
||||
"integrity": "sha512-gLTi17X8WY9Cf5GZ2Yns8T5lfBOcGgFehDFb+JQwDqdOoBOcECS9ZWMEAqMSVcMYwXD659J8NyzjRY/2aE+C2Q==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.0",
|
||||
"nan": "^2.14.0",
|
||||
@@ -3686,6 +3688,9 @@
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
|
||||
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"mimic-response": "^2.0.0"
|
||||
},
|
||||
@@ -7184,6 +7189,9 @@
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
|
||||
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
@@ -7515,7 +7523,10 @@
|
||||
"node_modules/nan": {
|
||||
"version": "2.15.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
|
||||
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
|
||||
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/nanoassert": {
|
||||
"version": "1.1.0",
|
||||
@@ -9528,6 +9539,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -9547,6 +9559,9 @@
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
|
||||
"integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"decompress-response": "^4.2.0",
|
||||
"once": "^1.3.1",
|
||||
@@ -13762,6 +13777,9 @@
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.8.0.tgz",
|
||||
"integrity": "sha512-gLTi17X8WY9Cf5GZ2Yns8T5lfBOcGgFehDFb+JQwDqdOoBOcECS9ZWMEAqMSVcMYwXD659J8NyzjRY/2aE+C2Q==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.0",
|
||||
"nan": "^2.14.0",
|
||||
@@ -14609,6 +14627,9 @@
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
|
||||
"integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"mimic-response": "^2.0.0"
|
||||
}
|
||||
@@ -17420,7 +17441,10 @@
|
||||
"mimic-response": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
|
||||
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA=="
|
||||
"integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"minimalistic-assert": {
|
||||
"version": "1.0.1",
|
||||
@@ -17682,7 +17706,10 @@
|
||||
"nan": {
|
||||
"version": "2.15.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
|
||||
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
|
||||
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"nanoassert": {
|
||||
"version": "1.1.0",
|
||||
@@ -19304,12 +19331,16 @@
|
||||
"simple-concat": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
|
||||
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"simple-get": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
|
||||
"integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"decompress-response": "^4.2.0",
|
||||
"once": "^1.3.1",
|
||||
|
||||
+1
-9
@@ -41,7 +41,6 @@
|
||||
"atomically": "^1.7.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"canvas": "^2.8.0",
|
||||
"cheerio": "^1.0.0-rc.9",
|
||||
"dot-prop": "^6.0.1",
|
||||
"dotenv": "^8.2.0",
|
||||
@@ -61,10 +60,7 @@
|
||||
"mongoose-long": "^0.3.2",
|
||||
"multer": "^1.4.2",
|
||||
"node-fetch": "^2.6.1",
|
||||
"require_optional": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"0x": "^4.10.2",
|
||||
"require_optional": "^1.0.1",
|
||||
"@types/amqplib": "^0.8.1",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/express": "^4.17.9",
|
||||
@@ -74,10 +70,6 @@
|
||||
"@types/node": "^14.17.9",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
"caxa": "^2.1.0",
|
||||
"jest": "^26.6.3",
|
||||
"saslprep": "^1.0.3",
|
||||
"ts-node": "^9.1.1",
|
||||
"ts-node-dev": "^1.1.6",
|
||||
"typescript": "^4.1.2"
|
||||
}
|
||||
|
||||
@@ -1,372 +0,0 @@
|
||||
// @ts-nocheck
|
||||
import Ajv, { JSONSchemaType } from "ajv";
|
||||
import { getConfigPathForFile } from "@fosscord/util/dist/util/Config";
|
||||
import { Config } from "@fosscord/util";
|
||||
|
||||
export interface RateLimitOptions {
|
||||
count: number;
|
||||
timespan: number;
|
||||
}
|
||||
|
||||
export interface DefaultOptions {
|
||||
gateway: string;
|
||||
general: {
|
||||
instance_id: string;
|
||||
};
|
||||
permissions: {
|
||||
user: {
|
||||
createGuilds: boolean;
|
||||
};
|
||||
};
|
||||
limits: {
|
||||
user: {
|
||||
maxGuilds: number;
|
||||
maxUsername: number;
|
||||
maxFriends: number;
|
||||
};
|
||||
guild: {
|
||||
maxRoles: number;
|
||||
maxMembers: number;
|
||||
maxChannels: number;
|
||||
maxChannelsInCategory: number;
|
||||
hideOfflineMember: number;
|
||||
};
|
||||
message: {
|
||||
characters: number;
|
||||
ttsCharacters: number;
|
||||
maxReactions: number;
|
||||
maxAttachmentSize: number;
|
||||
maxBulkDelete: number;
|
||||
};
|
||||
channel: {
|
||||
maxPins: number;
|
||||
maxTopic: number;
|
||||
};
|
||||
rate: {
|
||||
ip: {
|
||||
enabled: boolean;
|
||||
count: number;
|
||||
timespan: number;
|
||||
};
|
||||
routes: {
|
||||
auth?: {
|
||||
login?: RateLimitOptions;
|
||||
register?: RateLimitOptions;
|
||||
};
|
||||
channel?: string;
|
||||
// TODO: rate limit configuration for all routes
|
||||
};
|
||||
};
|
||||
};
|
||||
security: {
|
||||
jwtSecret: string;
|
||||
forwadedFor: string | null;
|
||||
captcha: {
|
||||
enabled: boolean;
|
||||
service: "recaptcha" | "hcaptcha" | null; // TODO: hcaptcha, custom
|
||||
sitekey: string | null;
|
||||
secret: string | null;
|
||||
};
|
||||
};
|
||||
login: {
|
||||
requireCaptcha: boolean;
|
||||
};
|
||||
register: {
|
||||
email: {
|
||||
necessary: boolean;
|
||||
allowlist: boolean;
|
||||
blocklist: boolean;
|
||||
domains: string[];
|
||||
};
|
||||
dateOfBirth: {
|
||||
necessary: boolean;
|
||||
minimum: number; // in years
|
||||
};
|
||||
requireCaptcha: boolean;
|
||||
requireInvite: boolean;
|
||||
allowNewRegistration: boolean;
|
||||
allowMultipleAccounts: boolean;
|
||||
password: {
|
||||
minLength: number;
|
||||
minNumbers: number;
|
||||
minUpperCase: number;
|
||||
minSymbols: number;
|
||||
blockInsecureCommonPasswords: boolean; // TODO: efficiently save password blocklist in database
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const schema: JSONSchemaType<DefaultOptions> & {
|
||||
definitions: {
|
||||
rateLimitOptions: JSONSchemaType<RateLimitOptions>;
|
||||
};
|
||||
} = {
|
||||
type: "object",
|
||||
definitions: {
|
||||
rateLimitOptions: {
|
||||
type: "object",
|
||||
properties: {
|
||||
count: { type: "number" },
|
||||
timespan: { type: "number" }
|
||||
},
|
||||
required: ["count", "timespan"]
|
||||
}
|
||||
},
|
||||
properties: {
|
||||
gateway: {
|
||||
type: "string"
|
||||
},
|
||||
general: {
|
||||
type: "object",
|
||||
properties: {
|
||||
instance_id: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
required: ["instance_id"],
|
||||
additionalProperties: false
|
||||
},
|
||||
permissions: {
|
||||
type: "object",
|
||||
properties: {
|
||||
user: {
|
||||
type: "object",
|
||||
properties: {
|
||||
createGuilds: {
|
||||
type: "boolean"
|
||||
}
|
||||
},
|
||||
required: ["createGuilds"],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: ["user"],
|
||||
additionalProperties: false
|
||||
},
|
||||
limits: {
|
||||
type: "object",
|
||||
properties: {
|
||||
user: {
|
||||
type: "object",
|
||||
properties: {
|
||||
maxFriends: {
|
||||
type: "number"
|
||||
},
|
||||
maxGuilds: {
|
||||
type: "number"
|
||||
},
|
||||
maxUsername: {
|
||||
type: "number"
|
||||
}
|
||||
},
|
||||
required: ["maxFriends", "maxGuilds", "maxUsername"],
|
||||
additionalProperties: false
|
||||
},
|
||||
guild: {
|
||||
type: "object",
|
||||
properties: {
|
||||
maxRoles: {
|
||||
type: "number"
|
||||
},
|
||||
maxMembers: {
|
||||
type: "number"
|
||||
},
|
||||
maxChannels: {
|
||||
type: "number"
|
||||
},
|
||||
maxChannelsInCategory: {
|
||||
type: "number"
|
||||
},
|
||||
hideOfflineMember: {
|
||||
type: "number"
|
||||
}
|
||||
},
|
||||
required: ["maxRoles", "maxMembers", "maxChannels", "maxChannelsInCategory", "hideOfflineMember"],
|
||||
additionalProperties: false
|
||||
},
|
||||
message: {
|
||||
type: "object",
|
||||
properties: {
|
||||
characters: {
|
||||
type: "number"
|
||||
},
|
||||
ttsCharacters: {
|
||||
type: "number"
|
||||
},
|
||||
maxReactions: {
|
||||
type: "number"
|
||||
},
|
||||
maxAttachmentSize: {
|
||||
type: "number"
|
||||
},
|
||||
maxBulkDelete: {
|
||||
type: "number"
|
||||
}
|
||||
},
|
||||
required: ["characters", "ttsCharacters", "maxReactions", "maxAttachmentSize", "maxBulkDelete"],
|
||||
additionalProperties: false
|
||||
},
|
||||
channel: {
|
||||
type: "object",
|
||||
properties: {
|
||||
maxPins: {
|
||||
type: "number"
|
||||
},
|
||||
maxTopic: {
|
||||
type: "number"
|
||||
}
|
||||
},
|
||||
required: ["maxPins", "maxTopic"],
|
||||
additionalProperties: false
|
||||
},
|
||||
rate: {
|
||||
type: "object",
|
||||
properties: {
|
||||
ip: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enabled: { type: "boolean" },
|
||||
count: { type: "number" },
|
||||
timespan: { type: "number" }
|
||||
},
|
||||
required: ["enabled", "count", "timespan"],
|
||||
additionalProperties: false
|
||||
},
|
||||
routes: {
|
||||
type: "object",
|
||||
properties: {
|
||||
auth: {
|
||||
type: "object",
|
||||
properties: {
|
||||
login: { $ref: "#/definitions/rateLimitOptions" },
|
||||
register: { $ref: "#/definitions/rateLimitOptions" }
|
||||
},
|
||||
nullable: true,
|
||||
required: [],
|
||||
additionalProperties: false
|
||||
},
|
||||
channel: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: [],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: ["ip", "routes"]
|
||||
}
|
||||
},
|
||||
required: ["channel", "guild", "message", "rate", "user"],
|
||||
additionalProperties: false
|
||||
},
|
||||
security: {
|
||||
type: "object",
|
||||
properties: {
|
||||
jwtSecret: {
|
||||
type: "string"
|
||||
},
|
||||
forwadedFor: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
},
|
||||
captcha: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enabled: { type: "boolean" },
|
||||
service: {
|
||||
type: "string",
|
||||
enum: ["hcaptcha", "recaptcha", null],
|
||||
nullable: true
|
||||
},
|
||||
sitekey: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
},
|
||||
secret: {
|
||||
type: "string",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: ["enabled", "secret", "service", "sitekey"],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: ["captcha", "forwadedFor", "jwtSecret"],
|
||||
additionalProperties: false
|
||||
},
|
||||
login: {
|
||||
type: "object",
|
||||
properties: {
|
||||
requireCaptcha: { type: "boolean" }
|
||||
},
|
||||
required: ["requireCaptcha"],
|
||||
additionalProperties: false
|
||||
},
|
||||
register: {
|
||||
type: "object",
|
||||
properties: {
|
||||
email: {
|
||||
type: "object",
|
||||
properties: {
|
||||
necessary: { type: "boolean" },
|
||||
allowlist: { type: "boolean" },
|
||||
blocklist: { type: "boolean" },
|
||||
domains: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ["allowlist", "blocklist", "domains", "necessary"],
|
||||
additionalProperties: false
|
||||
},
|
||||
dateOfBirth: {
|
||||
type: "object",
|
||||
properties: {
|
||||
necessary: { type: "boolean" },
|
||||
minimum: { type: "number" }
|
||||
},
|
||||
required: ["minimum", "necessary"],
|
||||
additionalProperties: false
|
||||
},
|
||||
requireCaptcha: { type: "boolean" },
|
||||
requireInvite: { type: "boolean" },
|
||||
allowNewRegistration: { type: "boolean" },
|
||||
allowMultipleAccounts: { type: "boolean" },
|
||||
password: {
|
||||
type: "object",
|
||||
properties: {
|
||||
minLength: { type: "number" },
|
||||
minNumbers: { type: "number" },
|
||||
minUpperCase: { type: "number" },
|
||||
minSymbols: { type: "number" },
|
||||
blockInsecureCommonPasswords: { type: "boolean" }
|
||||
},
|
||||
required: ["minLength", "minNumbers", "minUpperCase", "minSymbols", "blockInsecureCommonPasswords"],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"allowMultipleAccounts",
|
||||
"allowNewRegistration",
|
||||
"dateOfBirth",
|
||||
"email",
|
||||
"password",
|
||||
"requireCaptcha",
|
||||
"requireInvite"
|
||||
],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
required: ["gateway", "general", "limits", "login", "permissions", "register", "security"],
|
||||
additionalProperties: false
|
||||
};
|
||||
|
||||
const ajv = new Ajv();
|
||||
const validator = ajv.compile(schema);
|
||||
|
||||
const configPath = getConfigPathForFile("fosscord", "api", ".json");
|
||||
|
||||
export const apiConfig = new Config<DefaultOptions>({ path: configPath, schemaValidator: validator, schema: schema });
|
||||
Reference in New Issue
Block a user