Merge pull request #147 from DiegoMagdaleno/master
New way to do config no more hardcoded localhost
This commit is contained in:
		
						commit
						e1f0eb3c2a
					
				
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -105,3 +105,7 @@ dist | ||||
| 
 | ||||
| .DS_STORE | ||||
| src/ready.json | ||||
| 
 | ||||
| # Docker | ||||
| .docker/config/* | ||||
| !.docker/config/.keep | ||||
							
								
								
									
										316
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										316
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -7,14 +7,20 @@ | ||||
| 		"": { | ||||
| 			"name": "@fosscord/api", | ||||
| 			"version": "1.0.0", | ||||
| 			"hasInstallScript": true, | ||||
| 			"license": "ISC", | ||||
| 			"dependencies": { | ||||
| 				"@fosscord/server-util": "^1.2.6", | ||||
| 				"@fosscord/server-util": "^1.3.1", | ||||
| 				"@types/jest": "^26.0.22", | ||||
| 				"@types/json-schema": "^7.0.7", | ||||
| 				"ajv": "^8.4.0", | ||||
| 				"ajv-formats": "^2.1.0", | ||||
| 				"assert": "^1.5.0", | ||||
| 				"atomically": "^1.7.0", | ||||
| 				"bcrypt": "^5.0.1", | ||||
| 				"body-parser": "^1.19.0", | ||||
| 				"dot-prop": "^6.0.1", | ||||
| 				"dotenv": "^8.2.0", | ||||
| 				"env-paths": "^2.2.1", | ||||
| 				"express": "^4.17.1", | ||||
| 				"express-validator": "^6.9.2", | ||||
| 				"i18next": "^19.8.5", | ||||
| @ -492,14 +498,17 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/@fosscord/server-util": { | ||||
| 			"version": "1.2.6", | ||||
| 			"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.2.6.tgz", | ||||
| 			"integrity": "sha512-HFa/DX+4Ze9e8j/tT/Je6at2UEygAH4xsHYay/SObFQKC1Oo+G5aIYvak0kwyzO12lg91i0FBRUEHuMviwNe8A==", | ||||
| 			"version": "1.3.1", | ||||
| 			"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.1.tgz", | ||||
| 			"integrity": "sha512-NmrJ8HcZmOHyIUDMoQ+UnjoeMMi/HSbN2p/EMt1penTDSBvWcD8YS5m2NljuH0QxSmhuA2yLgSEpV1ydvJmOIw==", | ||||
| 			"dependencies": { | ||||
| 				"@types/jsonwebtoken": "^8.5.0", | ||||
| 				"@types/mongoose-autopopulate": "^0.10.1", | ||||
| 				"@types/mongoose-lean-virtuals": "^0.5.1", | ||||
| 				"@types/node": "^14.14.25", | ||||
| 				"ajv": "^8.5.0", | ||||
| 				"dot-prop": "^6.0.1", | ||||
| 				"env-paths": "^2.2.1", | ||||
| 				"jsonwebtoken": "^8.5.1", | ||||
| 				"missing-native-js-functions": "^1.2.2", | ||||
| 				"mongodb": "^3.6.6", | ||||
| @ -1513,6 +1522,11 @@ | ||||
| 				"pretty-format": "^26.0.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/@types/json-schema": { | ||||
| 			"version": "7.0.7", | ||||
| 			"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", | ||||
| 			"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==" | ||||
| 		}, | ||||
| 		"node_modules/@types/jsonwebtoken": { | ||||
| 			"version": "8.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.0.tgz", | ||||
| @ -1710,6 +1724,40 @@ | ||||
| 				"node": ">=8.5.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/0x/node_modules/ajv": { | ||||
| 			"version": "6.12.6", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 			"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"fast-deep-equal": "^3.1.1", | ||||
| 				"fast-json-stable-stringify": "^2.0.0", | ||||
| 				"json-schema-traverse": "^0.4.1", | ||||
| 				"uri-js": "^4.2.2" | ||||
| 			}, | ||||
| 			"funding": { | ||||
| 				"type": "github", | ||||
| 				"url": "https://github.com/sponsors/epoberezkin" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/0x/node_modules/debug": { | ||||
| 			"version": "4.3.1", | ||||
| 			"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", | ||||
| 			"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"ms": "2.1.2" | ||||
| 			}, | ||||
| 			"engines": { | ||||
| 				"node": ">=6.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/0x/node_modules/json-schema-traverse": { | ||||
| 			"version": "0.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 			"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"node_modules/0x/node_modules/make-dir": { | ||||
| 			"version": "1.3.0", | ||||
| 			"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", | ||||
| @ -1811,15 +1859,34 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/ajv": { | ||||
| 			"version": "6.12.6", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 			"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 			"dev": true, | ||||
| 			"version": "8.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.5.0.tgz", | ||||
| 			"integrity": "sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ==", | ||||
| 			"dependencies": { | ||||
| 				"fast-deep-equal": "^3.1.1", | ||||
| 				"fast-json-stable-stringify": "^2.0.0", | ||||
| 				"json-schema-traverse": "^0.4.1", | ||||
| 				"json-schema-traverse": "^1.0.0", | ||||
| 				"require-from-string": "^2.0.2", | ||||
| 				"uri-js": "^4.2.2" | ||||
| 			}, | ||||
| 			"funding": { | ||||
| 				"type": "github", | ||||
| 				"url": "https://github.com/sponsors/epoberezkin" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/ajv-formats": { | ||||
| 			"version": "2.1.0", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz", | ||||
| 			"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==", | ||||
| 			"dependencies": { | ||||
| 				"ajv": "^8.0.0" | ||||
| 			}, | ||||
| 			"peerDependencies": { | ||||
| 				"ajv": "^8.0.0" | ||||
| 			}, | ||||
| 			"peerDependenciesMeta": { | ||||
| 				"ajv": { | ||||
| 					"optional": true | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/ansi-escapes": { | ||||
| @ -1987,7 +2054,6 @@ | ||||
| 			"version": "1.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", | ||||
| 			"integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"object-assign": "^4.1.1", | ||||
| 				"util": "0.10.3" | ||||
| @ -2005,14 +2071,12 @@ | ||||
| 		"node_modules/assert/node_modules/inherits": { | ||||
| 			"version": "2.0.1", | ||||
| 			"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", | ||||
| 			"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", | ||||
| 			"dev": true | ||||
| 			"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" | ||||
| 		}, | ||||
| 		"node_modules/assert/node_modules/util": { | ||||
| 			"version": "0.10.3", | ||||
| 			"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", | ||||
| 			"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"inherits": "2.0.1" | ||||
| 			} | ||||
| @ -2044,6 +2108,14 @@ | ||||
| 				"node": ">= 4.5.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/atomically": { | ||||
| 			"version": "1.7.0", | ||||
| 			"resolved": "https://registry.npmjs.org/atomically/-/atomically-1.7.0.tgz", | ||||
| 			"integrity": "sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==", | ||||
| 			"engines": { | ||||
| 				"node": ">=10.12.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/aws-sign2": { | ||||
| 			"version": "0.7.0", | ||||
| 			"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", | ||||
| @ -3871,6 +3943,20 @@ | ||||
| 				"node": ">=8" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/dot-prop": { | ||||
| 			"version": "6.0.1", | ||||
| 			"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", | ||||
| 			"integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", | ||||
| 			"dependencies": { | ||||
| 				"is-obj": "^2.0.0" | ||||
| 			}, | ||||
| 			"engines": { | ||||
| 				"node": ">=10" | ||||
| 			}, | ||||
| 			"funding": { | ||||
| 				"url": "https://github.com/sponsors/sindresorhus" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/dotenv": { | ||||
| 			"version": "8.2.0", | ||||
| 			"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", | ||||
| @ -3991,6 +4077,14 @@ | ||||
| 				"once": "^1.4.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/env-paths": { | ||||
| 			"version": "2.2.1", | ||||
| 			"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", | ||||
| 			"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", | ||||
| 			"engines": { | ||||
| 				"node": ">=6" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/env-string": { | ||||
| 			"version": "1.0.1", | ||||
| 			"resolved": "https://registry.npmjs.org/env-string/-/env-string-1.0.1.tgz", | ||||
| @ -4493,8 +4587,7 @@ | ||||
| 		"node_modules/fast-deep-equal": { | ||||
| 			"version": "3.1.3", | ||||
| 			"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", | ||||
| 			"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", | ||||
| 			"dev": true | ||||
| 			"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" | ||||
| 		}, | ||||
| 		"node_modules/fast-json-stable-stringify": { | ||||
| 			"version": "2.1.0", | ||||
| @ -4856,6 +4949,28 @@ | ||||
| 				"node": ">=6" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/har-validator/node_modules/ajv": { | ||||
| 			"version": "6.12.6", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 			"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"fast-deep-equal": "^3.1.1", | ||||
| 				"fast-json-stable-stringify": "^2.0.0", | ||||
| 				"json-schema-traverse": "^0.4.1", | ||||
| 				"uri-js": "^4.2.2" | ||||
| 			}, | ||||
| 			"funding": { | ||||
| 				"type": "github", | ||||
| 				"url": "https://github.com/sponsors/epoberezkin" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/har-validator/node_modules/json-schema-traverse": { | ||||
| 			"version": "0.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 			"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"node_modules/has": { | ||||
| 			"version": "1.0.3", | ||||
| 			"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", | ||||
| @ -5443,6 +5558,14 @@ | ||||
| 				"node": ">=0.10.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/is-obj": { | ||||
| 			"version": "2.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", | ||||
| 			"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", | ||||
| 			"engines": { | ||||
| 				"node": ">=8" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/is-plain-object": { | ||||
| 			"version": "2.0.4", | ||||
| 			"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", | ||||
| @ -7422,10 +7545,9 @@ | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"node_modules/json-schema-traverse": { | ||||
| 			"version": "0.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 			"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 			"dev": true | ||||
| 			"version": "1.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", | ||||
| 			"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" | ||||
| 		}, | ||||
| 		"node_modules/json-stable-stringify": { | ||||
| 			"version": "0.0.1", | ||||
| @ -9777,6 +9899,14 @@ | ||||
| 				"node": ">=0.10.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/require-from-string": { | ||||
| 			"version": "2.0.2", | ||||
| 			"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", | ||||
| 			"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", | ||||
| 			"engines": { | ||||
| 				"node": ">=0.10.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/require-main-filename": { | ||||
| 			"version": "2.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", | ||||
| @ -10626,6 +10756,11 @@ | ||||
| 				"safer-buffer": "^2.0.2", | ||||
| 				"tweetnacl": "~0.14.0" | ||||
| 			}, | ||||
| 			"bin": { | ||||
| 				"sshpk-conv": "bin/sshpk-conv", | ||||
| 				"sshpk-sign": "bin/sshpk-sign", | ||||
| 				"sshpk-verify": "bin/sshpk-verify" | ||||
| 			}, | ||||
| 			"engines": { | ||||
| 				"node": ">=0.10.0" | ||||
| 			} | ||||
| @ -11454,9 +11589,9 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"node_modules/typescript": { | ||||
| 			"version": "4.1.3", | ||||
| 			"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", | ||||
| 			"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", | ||||
| 			"version": "4.2.4", | ||||
| 			"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", | ||||
| 			"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", | ||||
| 			"bin": { | ||||
| 				"tsc": "bin/tsc", | ||||
| 				"tsserver": "bin/tsserver" | ||||
| @ -11589,7 +11724,6 @@ | ||||
| 			"version": "4.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", | ||||
| 			"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", | ||||
| 			"dev": true, | ||||
| 			"dependencies": { | ||||
| 				"punycode": "^2.1.0" | ||||
| 			} | ||||
| @ -11598,7 +11732,6 @@ | ||||
| 			"version": "2.1.1", | ||||
| 			"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", | ||||
| 			"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", | ||||
| 			"dev": true, | ||||
| 			"engines": { | ||||
| 				"node": ">=6" | ||||
| 			} | ||||
| @ -12531,14 +12664,17 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"@fosscord/server-util": { | ||||
| 			"version": "1.2.6", | ||||
| 			"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.2.6.tgz", | ||||
| 			"integrity": "sha512-HFa/DX+4Ze9e8j/tT/Je6at2UEygAH4xsHYay/SObFQKC1Oo+G5aIYvak0kwyzO12lg91i0FBRUEHuMviwNe8A==", | ||||
| 			"version": "1.3.1", | ||||
| 			"resolved": "https://registry.npmjs.org/@fosscord/server-util/-/server-util-1.3.1.tgz", | ||||
| 			"integrity": "sha512-NmrJ8HcZmOHyIUDMoQ+UnjoeMMi/HSbN2p/EMt1penTDSBvWcD8YS5m2NljuH0QxSmhuA2yLgSEpV1ydvJmOIw==", | ||||
| 			"requires": { | ||||
| 				"@types/jsonwebtoken": "^8.5.0", | ||||
| 				"@types/mongoose-autopopulate": "^0.10.1", | ||||
| 				"@types/mongoose-lean-virtuals": "^0.5.1", | ||||
| 				"@types/node": "^14.14.25", | ||||
| 				"ajv": "^8.5.0", | ||||
| 				"dot-prop": "^6.0.1", | ||||
| 				"env-paths": "^2.2.1", | ||||
| 				"jsonwebtoken": "^8.5.1", | ||||
| 				"missing-native-js-functions": "^1.2.2", | ||||
| 				"mongodb": "^3.6.6", | ||||
| @ -13375,6 +13511,11 @@ | ||||
| 				"pretty-format": "^26.0.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"@types/json-schema": { | ||||
| 			"version": "7.0.7", | ||||
| 			"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", | ||||
| 			"integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==" | ||||
| 		}, | ||||
| 		"@types/jsonwebtoken": { | ||||
| 			"version": "8.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.0.tgz", | ||||
| @ -13566,6 +13707,33 @@ | ||||
| 				"which": "^1.2.4" | ||||
| 			}, | ||||
| 			"dependencies": { | ||||
| 				"ajv": { | ||||
| 					"version": "6.12.6", | ||||
| 					"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 					"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 					"dev": true, | ||||
| 					"requires": { | ||||
| 						"fast-deep-equal": "^3.1.1", | ||||
| 						"fast-json-stable-stringify": "^2.0.0", | ||||
| 						"json-schema-traverse": "^0.4.1", | ||||
| 						"uri-js": "^4.2.2" | ||||
| 					} | ||||
| 				}, | ||||
| 				"debug": { | ||||
| 					"version": "4.3.1", | ||||
| 					"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", | ||||
| 					"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", | ||||
| 					"dev": true, | ||||
| 					"requires": { | ||||
| 						"ms": "2.1.2" | ||||
| 					} | ||||
| 				}, | ||||
| 				"json-schema-traverse": { | ||||
| 					"version": "0.4.1", | ||||
| 					"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 					"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 					"dev": true | ||||
| 				}, | ||||
| 				"make-dir": { | ||||
| 					"version": "1.3.0", | ||||
| 					"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", | ||||
| @ -13648,17 +13816,22 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"ajv": { | ||||
| 			"version": "6.12.6", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 			"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 			"dev": true, | ||||
| 			"version": "8.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.5.0.tgz", | ||||
| 			"integrity": "sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ==", | ||||
| 			"requires": { | ||||
| 				"fast-deep-equal": "^3.1.1", | ||||
| 				"fast-json-stable-stringify": "^2.0.0", | ||||
| 				"json-schema-traverse": "^0.4.1", | ||||
| 				"json-schema-traverse": "^1.0.0", | ||||
| 				"require-from-string": "^2.0.2", | ||||
| 				"uri-js": "^4.2.2" | ||||
| 			} | ||||
| 		}, | ||||
| 		"ajv-formats": { | ||||
| 			"version": "2.1.0", | ||||
| 			"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.0.tgz", | ||||
| 			"integrity": "sha512-USH2jBb+C/hIpwD2iRjp0pe0k+MvzG0mlSn/FIdCgQhUb9ALPRjt2KIQdfZDS9r0ZIeUAg7gOu9KL0PFqGqr5Q==", | ||||
| 			"requires": {} | ||||
| 		}, | ||||
| 		"ansi-escapes": { | ||||
| 			"version": "4.3.2", | ||||
| 			"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", | ||||
| @ -13799,7 +13972,6 @@ | ||||
| 			"version": "1.5.0", | ||||
| 			"resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", | ||||
| 			"integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", | ||||
| 			"dev": true, | ||||
| 			"requires": { | ||||
| 				"object-assign": "^4.1.1", | ||||
| 				"util": "0.10.3" | ||||
| @ -13808,14 +13980,12 @@ | ||||
| 				"inherits": { | ||||
| 					"version": "2.0.1", | ||||
| 					"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", | ||||
| 					"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", | ||||
| 					"dev": true | ||||
| 					"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" | ||||
| 				}, | ||||
| 				"util": { | ||||
| 					"version": "0.10.3", | ||||
| 					"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", | ||||
| 					"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", | ||||
| 					"dev": true, | ||||
| 					"requires": { | ||||
| 						"inherits": "2.0.1" | ||||
| 					} | ||||
| @ -13846,6 +14016,11 @@ | ||||
| 			"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"atomically": { | ||||
| 			"version": "1.7.0", | ||||
| 			"resolved": "https://registry.npmjs.org/atomically/-/atomically-1.7.0.tgz", | ||||
| 			"integrity": "sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==" | ||||
| 		}, | ||||
| 		"aws-sign2": { | ||||
| 			"version": "0.7.0", | ||||
| 			"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", | ||||
| @ -15431,6 +15606,14 @@ | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"dot-prop": { | ||||
| 			"version": "6.0.1", | ||||
| 			"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", | ||||
| 			"integrity": "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA==", | ||||
| 			"requires": { | ||||
| 				"is-obj": "^2.0.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"dotenv": { | ||||
| 			"version": "8.2.0", | ||||
| 			"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", | ||||
| @ -15544,6 +15727,11 @@ | ||||
| 				"once": "^1.4.0" | ||||
| 			} | ||||
| 		}, | ||||
| 		"env-paths": { | ||||
| 			"version": "2.2.1", | ||||
| 			"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", | ||||
| 			"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==" | ||||
| 		}, | ||||
| 		"env-string": { | ||||
| 			"version": "1.0.1", | ||||
| 			"resolved": "https://registry.npmjs.org/env-string/-/env-string-1.0.1.tgz", | ||||
| @ -15957,8 +16145,7 @@ | ||||
| 		"fast-deep-equal": { | ||||
| 			"version": "3.1.3", | ||||
| 			"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", | ||||
| 			"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", | ||||
| 			"dev": true | ||||
| 			"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" | ||||
| 		}, | ||||
| 		"fast-json-stable-stringify": { | ||||
| 			"version": "2.1.0", | ||||
| @ -16247,6 +16434,26 @@ | ||||
| 			"requires": { | ||||
| 				"ajv": "^6.12.3", | ||||
| 				"har-schema": "^2.0.0" | ||||
| 			}, | ||||
| 			"dependencies": { | ||||
| 				"ajv": { | ||||
| 					"version": "6.12.6", | ||||
| 					"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", | ||||
| 					"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||||
| 					"dev": true, | ||||
| 					"requires": { | ||||
| 						"fast-deep-equal": "^3.1.1", | ||||
| 						"fast-json-stable-stringify": "^2.0.0", | ||||
| 						"json-schema-traverse": "^0.4.1", | ||||
| 						"uri-js": "^4.2.2" | ||||
| 					} | ||||
| 				}, | ||||
| 				"json-schema-traverse": { | ||||
| 					"version": "0.4.1", | ||||
| 					"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 					"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 					"dev": true | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"has": { | ||||
| @ -16731,6 +16938,11 @@ | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
| 		"is-obj": { | ||||
| 			"version": "2.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", | ||||
| 			"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==" | ||||
| 		}, | ||||
| 		"is-plain-object": { | ||||
| 			"version": "2.0.4", | ||||
| 			"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", | ||||
| @ -18305,10 +18517,9 @@ | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"json-schema-traverse": { | ||||
| 			"version": "0.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", | ||||
| 			"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||||
| 			"dev": true | ||||
| 			"version": "1.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", | ||||
| 			"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" | ||||
| 		}, | ||||
| 		"json-stable-stringify": { | ||||
| 			"version": "0.0.1", | ||||
| @ -20266,6 +20477,11 @@ | ||||
| 			"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", | ||||
| 			"dev": true | ||||
| 		}, | ||||
| 		"require-from-string": { | ||||
| 			"version": "2.0.2", | ||||
| 			"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", | ||||
| 			"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" | ||||
| 		}, | ||||
| 		"require-main-filename": { | ||||
| 			"version": "2.0.0", | ||||
| 			"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", | ||||
| @ -21662,9 +21878,9 @@ | ||||
| 			} | ||||
| 		}, | ||||
| 		"typescript": { | ||||
| 			"version": "4.1.3", | ||||
| 			"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", | ||||
| 			"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==" | ||||
| 			"version": "4.2.4", | ||||
| 			"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", | ||||
| 			"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==" | ||||
| 		}, | ||||
| 		"umd": { | ||||
| 			"version": "3.0.3", | ||||
| @ -21766,7 +21982,6 @@ | ||||
| 			"version": "4.4.1", | ||||
| 			"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", | ||||
| 			"integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", | ||||
| 			"dev": true, | ||||
| 			"requires": { | ||||
| 				"punycode": "^2.1.0" | ||||
| 			}, | ||||
| @ -21774,8 +21989,7 @@ | ||||
| 				"punycode": { | ||||
| 					"version": "2.1.1", | ||||
| 					"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", | ||||
| 					"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", | ||||
| 					"dev": true | ||||
| 					"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" | ||||
| 				} | ||||
| 			} | ||||
| 		}, | ||||
|  | ||||
| @ -29,11 +29,18 @@ | ||||
| 	}, | ||||
| 	"homepage": "https://github.com/fosscord/fosscord-api#readme", | ||||
| 	"dependencies": { | ||||
| 		"@fosscord/server-util": "^1.2.6", | ||||
| 		"@fosscord/server-util": "^1.3.1", | ||||
| 		"@types/jest": "^26.0.22", | ||||
| 		"@types/json-schema": "^7.0.7", | ||||
| 		"ajv": "^8.4.0", | ||||
| 		"ajv-formats": "^2.1.0", | ||||
| 		"assert": "^1.5.0", | ||||
| 		"atomically": "^1.7.0", | ||||
| 		"bcrypt": "^5.0.1", | ||||
| 		"body-parser": "^1.19.0", | ||||
| 		"dot-prop": "^6.0.1", | ||||
| 		"dotenv": "^8.2.0", | ||||
| 		"env-paths": "^2.2.1", | ||||
| 		"express": "^4.17.1", | ||||
| 		"express-validator": "^6.9.2", | ||||
| 		"i18next": "^19.8.5", | ||||
|  | ||||
							
								
								
									
										93
									
								
								scripts/config_generator.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								scripts/config_generator.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,93 @@ | ||||
| const { Snowflake } = require("@fosscord/server-util"); | ||||
| const crypto = require('crypto'); | ||||
| const fs = require('fs'); | ||||
| 
 | ||||
| 
 | ||||
| const defaultConfig = { | ||||
|     // TODO: Get the network interfaces dinamically
 | ||||
|     gateway: "ws://localhost", | ||||
|     general: { | ||||
|         instance_id: Snowflake.generate(), | ||||
|     }, | ||||
|     permissions: { | ||||
|         user: { | ||||
|             createGuilds: true, | ||||
|         } | ||||
|     }, | ||||
|     limits: { | ||||
|         user: { | ||||
|             maxGuilds: 100, | ||||
|             maxUsername: 32, | ||||
|             maxFriends: 1000, | ||||
|         }, | ||||
|         guild: { | ||||
|             maxRoles: 250, | ||||
|             maxMembers: 250000, | ||||
|             maxChannels: 500, | ||||
|             maxChannelsInCategory: 50, | ||||
|             hideOfflineMember: 1000, | ||||
|         }, | ||||
|         message: { | ||||
| 			characters: 2000, | ||||
| 			ttsCharacters: 200, | ||||
| 			maxReactions: 20, | ||||
| 			maxAttachmentSize: 8388608, | ||||
| 			maxBulkDelete: 100, | ||||
| 		}, | ||||
| 		channel: { | ||||
| 			maxPins: 50, | ||||
| 			maxTopic: 1024, | ||||
| 		}, | ||||
| 		rate: { | ||||
| 			ip: { | ||||
| 				enabled: true, | ||||
| 				count: 1000, | ||||
| 				timespan: 1000 * 60 * 10, | ||||
| 			}, | ||||
| 			routes: {}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	security: { | ||||
| 		jwtSecret: crypto.randomBytes(256).toString("base64"), | ||||
| 		forwadedFor: null, | ||||
| 		// forwadedFor: "X-Forwarded-For" // nginx/reverse proxy
 | ||||
| 		// forwadedFor: "CF-Connecting-IP" // cloudflare:
 | ||||
| 		captcha: { | ||||
| 			enabled: false, | ||||
| 			service: null, | ||||
| 			sitekey: null, | ||||
| 			secret: null, | ||||
| 		}, | ||||
| 	}, | ||||
| 	login: { | ||||
| 		requireCaptcha: false, | ||||
| 	}, | ||||
| 	register: { | ||||
| 		email: { | ||||
| 			necessary: true, | ||||
| 			allowlist: false, | ||||
| 			blocklist: true, | ||||
| 			domains: [], // TODO: efficiently save domain blocklist in database
 | ||||
| 			// domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"),
 | ||||
| 		}, | ||||
| 		dateOfBirth: { | ||||
| 			necessary: true, | ||||
| 			minimum: 13, | ||||
| 		}, | ||||
| 		requireInvite: false, | ||||
| 		requireCaptcha: true, | ||||
| 		allowNewRegistration: true, | ||||
| 		allowMultipleAccounts: true, | ||||
| 		password: { | ||||
| 			minLength: 8, | ||||
| 			minNumbers: 2, | ||||
| 			minUpperCase: 2, | ||||
| 			minSymbols: 0, | ||||
| 			blockInsecureCommonPasswords: false, | ||||
| 		}, | ||||
|     }, | ||||
| } | ||||
| 
 | ||||
| let data = JSON.stringify(defaultConfig); | ||||
| fs.writeFileSync('./.docker/config/api.json', data); | ||||
| 
 | ||||
| @ -3,7 +3,7 @@ import fs from "fs/promises"; | ||||
| import { Connection } from "mongoose"; | ||||
| import { Server, ServerOptions } from "lambert-server"; | ||||
| import { Authentication, CORS, GlobalRateLimit } from "./middlewares/"; | ||||
| import Config from "./util/Config"; | ||||
| import * as Config from "./util/Config"; | ||||
| import { db } from "@fosscord/server-util"; | ||||
| import i18next from "i18next"; | ||||
| import i18nextMiddleware, { I18next } from "i18next-http-middleware"; | ||||
| @ -55,7 +55,7 @@ export class FosscordServer extends Server { | ||||
| 		await (db as Promise<Connection>); | ||||
| 		await this.setupSchema(); | ||||
| 		console.log("[DB] connected"); | ||||
| 		await Promise.all([Config.init()]); | ||||
| 		//await Promise.all([Config.init()]);
 | ||||
| 
 | ||||
| 		this.app.use(GlobalRateLimit); | ||||
| 		this.app.use(Authentication); | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| import { NextFunction, Request, Response } from "express"; | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import { checkToken } from "@fosscord/server-util"; | ||||
| import * as Config from "../util/Config" | ||||
| 
 | ||||
| export const NO_AUTHORIZATION_ROUTES = [ | ||||
| 	"/api/v8/auth/login", | ||||
| @ -27,7 +28,10 @@ export async function Authentication(req: Request, res: Response, next: NextFunc | ||||
| 	// TODO: check if user is banned/token expired
 | ||||
| 
 | ||||
| 	try { | ||||
| 		const decoded: any = await checkToken(req.headers.authorization); | ||||
| 
 | ||||
| 		const { jwtSecret } = Config.apiConfig.getAll().security; | ||||
| 
 | ||||
| 		const decoded: any = await checkToken(req.headers.authorization, jwtSecret); | ||||
| 
 | ||||
| 		req.token = decoded; | ||||
| 		req.user_id = decoded.id; | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| import { NextFunction, Request, Response } from "express"; | ||||
| import Config from "../util/Config"; | ||||
| import * as Config from '../util/Config' | ||||
| import crypto from "crypto"; | ||||
| 
 | ||||
| // TODO: use mongodb ttl index
 | ||||
| // TODO: increment count on serverside
 | ||||
| @ -43,7 +44,7 @@ export async function GlobalRateLimit(req: Request, res: Response, next: NextFun | ||||
| } | ||||
| 
 | ||||
| export function getIpAdress(req: Request): string { | ||||
| 	const { forwadedFor } = Config.get().security; | ||||
| 	const { forwadedFor } = Config.apiConfig.getAll().security; | ||||
| 	const ip = forwadedFor ? <string>req.headers[forwadedFor] : req.ip; | ||||
| 	return ip.replaceAll(".", "_").replaceAll(":", "_"); | ||||
| } | ||||
|  | ||||
| @ -3,7 +3,7 @@ import { check, FieldErrors, Length } from "../../util/instanceOf"; | ||||
| import bcrypt from "bcrypt"; | ||||
| import jwt from "jsonwebtoken"; | ||||
| import { UserModel } from "@fosscord/server-util"; | ||||
| import Config from "../../util/Config"; | ||||
| import * as Config from "../../util/Config"; | ||||
| import { adjustEmail } from "./register"; | ||||
| 
 | ||||
| const router: Router = Router(); | ||||
| @ -25,7 +25,9 @@ router.post( | ||||
| 		const query: any[] = [{ phone: login }]; | ||||
| 		if (email) query.push({ email }); | ||||
| 
 | ||||
| 		const config = Config.get(); | ||||
| 		// TODO: Rewrite this to have the proper config syntax on the new method 
 | ||||
|   | ||||
| 		const config = Config.apiConfig.getAll(); | ||||
| 
 | ||||
| 		if (config.login.requireCaptcha && config.security.captcha.enabled) { | ||||
| 			if (!captcha_key) { | ||||
| @ -69,7 +71,7 @@ export async function generateToken(id: string) { | ||||
| 	return new Promise((res, rej) => { | ||||
| 		jwt.sign( | ||||
| 			{ id: id, iat }, | ||||
| 			Config.get().security.jwtSecret, | ||||
| 			Config.apiConfig.getAll().security.jwtSecret, | ||||
| 			{ | ||||
| 				algorithm, | ||||
| 			}, | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| import { Request, Response, Router } from "express"; | ||||
| import Config from "../../util/Config"; | ||||
| import * as Config from "../../util/Config"; | ||||
| import { trimSpecial, User, Snowflake, UserModel } from "@fosscord/server-util"; | ||||
| import bcrypt from "bcrypt"; | ||||
| import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf"; | ||||
| @ -40,7 +40,7 @@ router.post( | ||||
| 		// TODO: check password strength
 | ||||
| 
 | ||||
| 		// adjusted_email will be slightly modified version of the user supplied email -> e.g. protection against GMail Trick
 | ||||
| 		let adjusted_email: string | undefined = adjustEmail(email); | ||||
| 		let adjusted_email: string | null = adjustEmail(email); | ||||
| 
 | ||||
| 		// adjusted_password will be the hash of the password
 | ||||
| 		let adjusted_password: string = ""; | ||||
| @ -52,7 +52,7 @@ router.post( | ||||
| 		let discriminator = ""; | ||||
| 
 | ||||
| 		// get register Config
 | ||||
| 		const { register, security } = Config.get(); | ||||
| 		const { register, security } = Config.apiConfig.getAll(); | ||||
| 
 | ||||
| 		// check if registration is allowed
 | ||||
| 		if (!register.allowNewRegistration) { | ||||
| @ -90,13 +90,13 @@ router.post( | ||||
| 					}, | ||||
| 				}); | ||||
| 			} | ||||
| 		} else if (register.email.required) { | ||||
| 		} else if (register.email.necessary) { | ||||
| 			throw FieldErrors({ | ||||
| 				email: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") }, | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
| 		if (register.dateOfBirth.required && !date_of_birth) { | ||||
| 		if (register.dateOfBirth.necessary && !date_of_birth) { | ||||
| 			throw FieldErrors({ | ||||
| 				date_of_birth: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") }, | ||||
| 			}); | ||||
| @ -181,7 +181,7 @@ router.post( | ||||
| 			mobile: false, | ||||
| 			premium: false, | ||||
| 			premium_type: 0, | ||||
| 			phone: undefined, | ||||
| 			phone: null, | ||||
| 			mfa_enabled: false, | ||||
| 			verified: false, | ||||
| 			presence: { | ||||
| @ -253,7 +253,7 @@ router.post( | ||||
| 	} | ||||
| ); | ||||
| 
 | ||||
| export function adjustEmail(email: string): string | undefined { | ||||
| export function adjustEmail(email: string): string | null { | ||||
| 	// body parser already checked if it is a valid email
 | ||||
| 	const parts = <RegExpMatchArray>email.match(EMAIL_REGEX); | ||||
| 	// @ts-ignore
 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import { Router } from "express"; | ||||
| import { ChannelModel, getPermission, MessageDeleteBulkEvent, MessageModel } from "@fosscord/server-util"; | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import Config from "../../../../util/Config"; | ||||
| import * as Config from "../../../../util/Config"; | ||||
| import { emitEvent } from "../../../../util/Event"; | ||||
| import { check } from "../../../../util/instanceOf"; | ||||
| 
 | ||||
| @ -20,7 +20,7 @@ router.post("/", check({ messages: [String] }), async (req, res) => { | ||||
| 	const permission = await getPermission(req.user_id, channel?.guild_id, channel_id, { channel }); | ||||
| 	permission.hasThrow("MANAGE_MESSAGES"); | ||||
| 
 | ||||
| 	const { maxBulkDelete } = Config.get().limits.message; | ||||
| 	const { maxBulkDelete } =  Config.apiConfig.getAll().limits.message; | ||||
| 
 | ||||
| 	const { messages } = req.body as { messages: string[] }; | ||||
| 	if (messages.length < 2) throw new HTTPError("You must at least specify 2 messages to bulk delete"); | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import { ChannelModel, ChannelPinsUpdateEvent, getPermission, MessageModel, MessageUpdateEvent, toObject } from "@fosscord/server-util"; | ||||
| import { Router, Request, Response } from "express"; | ||||
| import Config from "../../../util/Config"; | ||||
| import * as Config from "../../../util/Config"; | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import { emitEvent } from "../../../util/Event"; | ||||
| 
 | ||||
| @ -18,7 +18,7 @@ router.put("/:message_id", async (req: Request, res: Response) => { | ||||
| 	if (channel.guild_id) permission.hasThrow("MANAGE_MESSAGES"); | ||||
| 
 | ||||
| 	const pinned_count = await MessageModel.count({ channel_id, pinned: true }).exec(); | ||||
| 	const { maxPins } = Config.get().limits.channel; | ||||
| 	const { maxPins } = Config.apiConfig.getAll().limits.channel; | ||||
| 	if (pinned_count >= maxPins) throw new HTTPError("Max pin count reached: " + maxPins); | ||||
| 
 | ||||
| 	await MessageModel.updateOne({ id: message_id }, { pinned: true }).exec(); | ||||
|  | ||||
| @ -1,12 +1,11 @@ | ||||
| import { Router } from "express"; | ||||
| import Config from "../util/Config"; | ||||
| import * as Config from "../util/Config" | ||||
| 
 | ||||
| const router = Router(); | ||||
| 
 | ||||
| router.get("/", (req, res) => { | ||||
| 	const endpoint = Config.getAll()?.gateway?.endpoint; | ||||
| 
 | ||||
| 	res.send({ url: endpoint || "ws://localhost:3002" }); | ||||
| 	const { gateway } = Config.apiConfig.getAll(); | ||||
| 	res.send({ url: gateway || "ws://localhost:3002" }); | ||||
| }); | ||||
| 
 | ||||
| export default router; | ||||
|  | ||||
| @ -3,7 +3,7 @@ import { RoleModel, GuildModel, Snowflake, Guild, RoleDocument } from "@fosscord | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import { check } from "./../../util/instanceOf"; | ||||
| import { GuildCreateSchema } from "../../schema/Guild"; | ||||
| import Config from "../../util/Config"; | ||||
| import * as Config from "../../util/Config"; | ||||
| import { getPublicUser } from "../../util/User"; | ||||
| import { addMember } from "../../util/Member"; | ||||
| import { createChannel } from "../../util/Channel"; | ||||
| @ -15,7 +15,7 @@ const router: Router = Router(); | ||||
| router.post("/", check(GuildCreateSchema), async (req: Request, res: Response) => { | ||||
| 	const body = req.body as GuildCreateSchema; | ||||
| 
 | ||||
| 	const { maxGuilds } = Config.get().limits.user; | ||||
| 	const { maxGuilds } = Config.apiConfig.getAll().limits.user; | ||||
| 	const user = await getPublicUser(req.user_id, { guilds: true }); | ||||
| 
 | ||||
| 	if (user.guilds.length >= maxGuilds) { | ||||
|  | ||||
| @ -5,7 +5,7 @@ import { HTTPError } from "lambert-server"; | ||||
| import { GuildTemplateCreateSchema } from "../../../schema/Guild"; | ||||
| import { getPublicUser } from "../../../util/User"; | ||||
| import { check } from "../../../util/instanceOf"; | ||||
| import Config from "../../../util/Config"; | ||||
| import * as Config from "../../../util/Config"; | ||||
| import { addMember } from "../../../util/Member"; | ||||
| 
 | ||||
| router.get("/:code", async (req: Request, res: Response) => { | ||||
| @ -21,7 +21,7 @@ router.post("/:code", check(GuildTemplateCreateSchema), async (req: Request, res | ||||
| 	const { code } = req.params; | ||||
| 	const body = req.body as GuildTemplateCreateSchema; | ||||
| 
 | ||||
| 	const { maxGuilds } = Config.get().limits.user; | ||||
| 	const { maxGuilds } =  Config.apiConfig.getAll().limits.user; | ||||
| 	const user = await getPublicUser(req.user_id, { guilds: true }); | ||||
| 
 | ||||
| 	if (user.guilds.length >= maxGuilds) { | ||||
|  | ||||
| @ -1,19 +1,6 @@ | ||||
| import { Config, Snowflake } from "@fosscord/server-util"; | ||||
| import crypto from "crypto"; | ||||
| 
 | ||||
| export default { | ||||
| 	init() { | ||||
| 		return Config.init({ api: DefaultOptions }); | ||||
| 	}, | ||||
| 	get(): DefaultOptions { | ||||
| 		return Config.getAll().api; | ||||
| 	}, | ||||
| 	set(val: any) { | ||||
| 		return Config.setAll({ api: val }); | ||||
| 	}, | ||||
| 	getAll: Config.getAll, | ||||
| 	setAll: Config.setAll, | ||||
| }; | ||||
| import Ajv, { JSONSchemaType } from "ajv" | ||||
| import { getConfigPathForFile } from "@fosscord/server-util/dist/util/Config"; | ||||
| import {Config} from "@fosscord/server-util" | ||||
| 
 | ||||
| export interface RateLimitOptions { | ||||
| 	count: number; | ||||
| @ -21,6 +8,7 @@ export interface RateLimitOptions { | ||||
| } | ||||
| 
 | ||||
| export interface DefaultOptions { | ||||
| 	gateway: string; | ||||
| 	general: { | ||||
| 		instance_id: string; | ||||
| 	}; | ||||
| @ -64,7 +52,7 @@ export interface DefaultOptions { | ||||
| 					login?: RateLimitOptions; | ||||
| 					register?: RateLimitOptions; | ||||
| 				}; | ||||
| 				channel?: {}; | ||||
| 				channel?: string; | ||||
| 				// TODO: rate limit configuration for all routes
 | ||||
| 			}; | ||||
| 		}; | ||||
| @ -84,13 +72,13 @@ export interface DefaultOptions { | ||||
| 	}; | ||||
| 	register: { | ||||
| 		email: { | ||||
| 			required: boolean; | ||||
| 			necessary: boolean; | ||||
| 			allowlist: boolean; | ||||
| 			blocklist: boolean; | ||||
| 			domains: string[]; | ||||
| 		}; | ||||
| 		dateOfBirth: { | ||||
| 			required: boolean; | ||||
| 			necessary: boolean; | ||||
| 			minimum: number; // in years
 | ||||
| 		}; | ||||
| 		requireCaptcha: boolean; | ||||
| @ -107,85 +95,271 @@ export interface DefaultOptions { | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| export const DefaultOptions: DefaultOptions = { | ||||
| 	general: { | ||||
| 		instance_id: Snowflake.generate(), | ||||
| 	}, | ||||
| 	permissions: { | ||||
| 		user: { | ||||
| 			createGuilds: true, | ||||
| 		}, | ||||
| 	}, | ||||
| 	limits: { | ||||
| 		user: { | ||||
| 			maxGuilds: 100, | ||||
| 			maxUsername: 32, | ||||
| 			maxFriends: 1000, | ||||
| 		}, | ||||
| 		guild: { | ||||
| 			maxRoles: 250, | ||||
| 			maxMembers: 250000, | ||||
| 			maxChannels: 500, | ||||
| 			maxChannelsInCategory: 50, | ||||
| 			hideOfflineMember: 1000, | ||||
| 		}, | ||||
| 		message: { | ||||
| 			characters: 2000, | ||||
| 			ttsCharacters: 200, | ||||
| 			maxReactions: 20, | ||||
| 			maxAttachmentSize: 8388608, | ||||
| 			maxBulkDelete: 100, | ||||
| 		}, | ||||
| 		channel: { | ||||
| 			maxPins: 50, | ||||
| 			maxTopic: 1024, | ||||
| 		}, | ||||
| 		rate: { | ||||
| 			ip: { | ||||
| 				enabled: true, | ||||
| 				count: 1000, | ||||
| 				timespan: 1000 * 60 * 10, | ||||
| 
 | ||||
| const schema: JSONSchemaType<DefaultOptions> & { | ||||
| 	definitions: { | ||||
| 		rateLimitOptions: JSONSchemaType<RateLimitOptions> | ||||
| 	} | ||||
| } = { | ||||
| 	type: "object", | ||||
| 	definitions: { | ||||
| 		rateLimitOptions: { | ||||
| 			type: "object", | ||||
| 			properties: { | ||||
| 				count: { type: "number" }, | ||||
| 				timespan: { type: "number" }, | ||||
| 			}, | ||||
| 			routes: {}, | ||||
| 			required: ["count", "timespan"], | ||||
| 		}, | ||||
| 	}, | ||||
| 	security: { | ||||
| 		jwtSecret: crypto.randomBytes(256).toString("base64"), | ||||
| 		forwadedFor: null, | ||||
| 		// forwadedFor: "X-Forwarded-For" // nginx/reverse proxy
 | ||||
| 		// forwadedFor: "CF-Connecting-IP" // cloudflare:
 | ||||
| 		captcha: { | ||||
| 			enabled: false, | ||||
| 			service: null, | ||||
| 			sitekey: null, | ||||
| 			secret: null, | ||||
| 	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 | ||||
| 		}, | ||||
| 	}, | ||||
| 	login: { | ||||
| 		requireCaptcha: false, | ||||
| 	}, | ||||
| 	register: { | ||||
| 		email: { | ||||
| 			required: true, | ||||
| 			allowlist: false, | ||||
| 			blocklist: true, | ||||
| 			domains: [], // TODO: efficiently save domain blocklist in database
 | ||||
| 			// domains: fs.readFileSync(__dirname + "/blockedEmailDomains.txt", { encoding: "utf8" }).split("\n"),
 | ||||
| 		}, | ||||
| 		dateOfBirth: { | ||||
| 			required: true, | ||||
| 			minimum: 13, | ||||
| 		}, | ||||
| 		requireInvite: false, | ||||
| 		requireCaptcha: true, | ||||
| 		allowNewRegistration: true, | ||||
| 		allowMultipleAccounts: true, | ||||
| 		password: { | ||||
| 			minLength: 8, | ||||
| 			minNumbers: 2, | ||||
| 			minUpperCase: 2, | ||||
| 			minSymbols: 0, | ||||
| 			blockInsecureCommonPasswords: 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}); | ||||
| @ -14,7 +14,7 @@ import { | ||||
| } from "@fosscord/server-util"; | ||||
| 
 | ||||
| import { HTTPError } from "lambert-server"; | ||||
| import Config from "./Config"; | ||||
| import * as Config from "./Config"; | ||||
| import { emitEvent } from "./Event"; | ||||
| import { getPublicUser } from "./User"; | ||||
| 
 | ||||
| @ -39,7 +39,7 @@ export async function isMember(user_id: string, guild_id: string) { | ||||
| export async function addMember(user_id: string, guild_id: string, cache?: { guild?: GuildDocument }) { | ||||
| 	const user = await getPublicUser(user_id, { guilds: true }); | ||||
| 
 | ||||
| 	const { maxGuilds } = Config.get().limits.user; | ||||
| 	const { maxGuilds } = Config.apiConfig.getAll().limits.user; | ||||
| 	if (user.guilds.length >= maxGuilds) { | ||||
| 		throw new HTTPError(`You are at the ${maxGuilds} server limit.`, 403); | ||||
| 	} | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| import "missing-native-js-functions"; | ||||
| import Config from "./Config"; | ||||
| import * as Config from "./Config"; | ||||
| 
 | ||||
| const reNUMBER = /[0-9]/g; | ||||
| const reUPPERCASELETTER = /[A-Z]/g; | ||||
| @ -23,7 +23,7 @@ export function check(password: string): number { | ||||
| 		minUpperCase, | ||||
| 		minSymbols, | ||||
| 		blockInsecureCommonPasswords, | ||||
| 	} = Config.get().register.password; | ||||
| 	} = Config.apiConfig.getAll().register.password; | ||||
| 	var strength = 0; | ||||
| 
 | ||||
| 	// checks for total password len
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Flam3rboy
						Flam3rboy