Update dependencies and replace deprecated packages

This commit is contained in:
Terncode committed 2026-11-25 20:52:34 +01:00
1 parent ecb1b76891
commit e74cc2c3a5
15 files changed
+5475 -13841

No files matched your search

-124
View File
@@ -1,124 +0,0 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12
},
plugins: [
'@typescript-eslint'
],
rules: {
indent: [
'warn',
'tab',
{
SwitchCase: 1,
ignoredNodes: ['ConditionalExpression'],
},
],
quotes: [
'warn',
'single',
{ allowTemplateLiterals: true, avoidEscape: true },
],
'linebreak-style': [
'warn',
'unix'
],
'max-len': ['warn', { 'code': 200 }],
semi: [
'warn',
'always'
],
radix: [
'error',
],
'@typescript-eslint/no-empty-interface': [
'warn',
{
'allowSingleExtends': true
}
],
'camelcase': 'warn',
'no-trailing-spaces': 'warn',
'no-unused-labels': 'error',
'keyword-spacing': ['warn', { 'before': true, 'after': true }],
'no-new-wrappers': 'error',
'no-debugger': 'error',
'no-eval': 'error',
'no-redeclare': 'off',
'no-underscore-dangle': 'off',
'no-multiple-empty-lines': [
'warn',
{
'max': 2
}
],
'no-caller': 'error',
'no-console': [
'error',
{
'allow': [
'log',
'warn',
'dir',
'timeLog',
'assert',
'clear',
'count',
'countReset',
'group',
'groupEnd',
'table',
'dirxml',
'error',
'groupCollapsed',
'Console',
'profile',
'profileEnd',
'timeStamp',
'context'
]
}
],
'curly': ['warn', 'all'],
'brace-style': ['warn', 'stroustrup'],
'eol-last': 'error',
'eqeqeq': [
'error',
'smart'
],
'guard-for-in': 'error',
'no-case-declarations': 'off',
'no-sparse-arrays': 'off',
'no-empty-pattern': 'off',
'no-cond-assign': 'off',
'no-unused-vars': 'off',
'prefer-const': 'off',
'id-denylist': 'off',
'id-match': 'off',
'no-empty': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types' : 'off',
'no-mixed-spaces-and-tabs' : 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_' }
],
}
};
+3 -1
View File
@@ -144,7 +144,7 @@ const minifyOptions = {
ecma: 5,
compress: { ecma: 5, arrows: false },
mangle: {
props: { regex: '^__', reserved: ['__default'] },
props: { regex: '^__', reserved: ['__default', '__symbol__'] },
},
format: { comments: false },
extractComments: 'some',
@@ -310,6 +310,7 @@ function createJitOptions(defines, banner) {
},
banner: { js: banner },
logLevel: 'warning',
inject: [fileURLToPath(import.meta.resolve('@angular/compiler'))],
plugins: [lodashPlugin, jit.plugin],
};
@@ -445,6 +446,7 @@ else {
try {
await Promise.all(selectBundles().map(buildProd));
console.log(`[client] done in ${((Date.now() - start) / 1000).toFixed(1)}s`);
process.exit(0);
}
catch (e) {
if (!e.errors) {
+88
View File
@@ -0,0 +1,88 @@
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin';
import globals from 'globals';
export default tseslint.config(
js.configs.recommended,
tseslint.configs.recommended,
{
files: ['**/*.ts'],
plugins: {
'@stylistic': stylistic,
},
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
rules: {
'@stylistic/indent': [
'warn',
'tab',
{
SwitchCase: 1,
ignoredNodes: ['ConditionalExpression'],
},
],
'@stylistic/quotes': [
'warn',
'single',
{ allowTemplateLiterals: 'always', avoidEscape: true },
],
'@stylistic/linebreak-style': ['warn', 'unix'],
'@stylistic/max-len': ['warn', { code: 200 }],
'@stylistic/semi': ['warn', 'always'],
'@stylistic/keyword-spacing': ['warn', { before: true, after: true }],
'@stylistic/no-trailing-spaces': 'warn',
'@stylistic/no-multiple-empty-lines': ['warn', { max: 2 }],
'@stylistic/brace-style': ['warn', 'stroustrup'],
'@stylistic/eol-last': 'error',
radix: ['error'],
'@typescript-eslint/no-empty-object-type': ['warn', { allowInterfaces: 'with-single-extends' }],
camelcase: 'warn',
'no-unused-labels': 'error',
'no-new-wrappers': 'error',
'no-debugger': 'error',
'no-eval': 'error',
'no-redeclare': 'off',
'no-underscore-dangle': 'off',
'no-caller': 'error',
'no-console': [
'error',
{
allow: [
'log', 'warn', 'dir', 'timeLog', 'assert', 'clear', 'count', 'countReset', 'group', 'groupEnd',
'table', 'dirxml', 'error', 'groupCollapsed', 'Console', 'profile', 'profileEnd', 'timeStamp', 'context',
],
},
],
curly: ['warn', 'all'],
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'no-case-declarations': 'off',
'no-sparse-arrays': 'off',
'no-empty-pattern': 'off',
'no-cond-assign': 'off',
'no-unused-vars': 'off',
'prefer-const': 'off',
'id-denylist': 'off',
'id-match': 'off',
'no-empty': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
},
},
);
+67 -33
View File
@@ -9,13 +9,11 @@ import gulpif from 'gulp-if';
import rev from 'gulp-rev';
import gulpSass from 'gulp-sass';
import * as sassEmbedded from 'sass-embedded';
import shell from 'gulp-shell';
import cssnano from 'gulp-cssnano';
import postcss from 'gulp-postcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import imagemin, { mozjpeg, optipng, gifsicle, svgo } from 'gulp-imagemin';
import autoprefixer from 'gulp-autoprefixer';
import liveServer from 'gulp-live-server';
import sizereport from 'gulp-sizereport';
import markdownTree from 'markdown-tree';
import { spawn } from 'child_process';
@@ -143,15 +141,35 @@ const sprites = () => Promise.resolve() // del(['tools/output/images/*'])
.pipe(gulpif(!argv.fast, imagemin()))
.pipe(gulp.dest('assets/images')));
function parseChangelog(markdown) {
const versions = [];
for (const line of markdown.split(/\r?\n/)) {
const heading = /^#+\s+(.*)$/.exec(line);
const item = /^\s*[-*+]\s+(.*)$/.exec(line);
const current = versions[versions.length - 1];
if (heading) {
versions.push({ version: heading[1].trim(), changes: [] });
}
else if (!current || !line.trim()) {
continue;
}
else if (item || !current.changes.length) {
current.changes.push((item ? item[1] : line).trim());
}
else {
current.changes[current.changes.length - 1] += `\n${line.trim()}`;
}
}
return versions;
}
const changelog = cb => {
const changelog = readFile('CHANGELOG.md');
const tree = markdownTree(changelog);
const object = config.nochangelog ? [] : tree.children.map(c => ({
version: c.text,
changes: c.tokens
.map(t => t.text)
.filter(x => x)
.map(x => x.replace(/^\[test\]/, '<span class="badge badge-secondary">test</span>')),
const object = config.nochangelog ? [] : parseChangelog(readFile('CHANGELOG.md')).map(({ version, changes }) => ({
version,
changes: changes.map(x => x.replace(/^\[test\]/, '<span class="badge badge-secondary">test</span>')),
}));
const type = `{ version: string; changes: string[]; }[]`;
const code = `/* eslint-disable */\n\nexport const CHANGELOG: ${type} = ${JSON.stringify(object, null, 2)};\n`;
@@ -253,8 +271,12 @@ function buildSass(name, src, dest) {
quietDeps: true,
silenceDeprecations: ['import', 'global-builtin', 'color-functions', 'if-function', 'slash-div'],
}).on('error', sass.logError))
.pipe(autoprefixer('last 2 versions'))
.pipe(gulpif(!development, cssnano({ discardComments: { removeAll: true } })))
.pipe(postcss(() => ({
plugins: [
autoprefixer({ overrideBrowserslist: ['last 2 versions'] }),
...(development ? [] : [cssnano({ preset: ['default', { discardComments: { removeAll: true } }] })]),
],
})))
.pipe(gulpif(!development, rev()))
.pipe(gulp.dest(dest));
result.displayName = `sass (${name})`;
@@ -300,33 +322,45 @@ const size = () => gulp.src([
'dist/browser/assets-admin/styles/*.css',
]).pipe(sizereport({ gzip: true, total: true }));
const music = () => gulp.src(path.join(config.assetsPath, 'assets/music/*.wav'), { read: false })
.pipe(shell([
'ffmpeg -y -i "<%= file.path %>" -acodec libmp3lame "<%= out(file.path, ".mp3") %>"',
'ffmpeg -y -i "<%= file.path %>" -acodec libvorbis "<%= out(file.path, ".webm") %>"',
], {
templateData: {
out: (file, ext) => path.join('assets', 'music', path.basename(file, '.wav') + ext),
}
}));
const music = async () => {
const dir = path.join(config.assetsPath, 'assets', 'music');
const files = fs.readdirSync(dir).filter(file => file.endsWith('.wav'));
for (const file of files) {
const out = ext => path.join('assets', 'music', path.basename(file, '.wav') + ext);
await runAsync('ffmpeg', ['-y', '-i', path.join(dir, file), '-acodec', 'libmp3lame', out('.mp3')]);
await runAsync('ffmpeg', ['-y', '-i', path.join(dir, file), '-acodec', 'libvorbis', out('.webm')]);
}
};
const serverDev = cb => {
if (!argv.noserver) {
const serverPath = path.join('dist', 'node', 'server', 'server.js');
const options = { env: { NODE_OPTIONS: '--inspect' } };
const commonArgs = [serverPath, '--inspect', '--color', '--beta', '--admin'];
const server = argv.adm ?
liveServer([...commonArgs, '--adm'], options) :
liveServer([...commonArgs, '--login', '--game', '--tools'], options);
server.start();
const args = argv.adm ? [...commonArgs, '--adm'] : [...commonArgs, '--login', '--game', '--tools'];
let server;
const restart = cb => {
server.start();
cb();
const start = () => {
server = spawn(process.execPath, args, { stdio: 'inherit', env: { ...process.env, ...options.env } });
};
gulp.watch(['dist/browser/**/*.css']).on('change', path => server.notify({ path }));
gulp.watch(['dist/browser/**/*.js']).on('change', path => server.notify({ path }));
const restart = cb => {
if (server && server.exitCode === null && server.signalCode === null) {
server.once('exit', () => {
start();
cb();
});
server.kill();
}
else {
start();
cb();
}
};
start();
process.on('exit', () => server && server.kill());
gulp.watch([
'config.json',
'src/maps/*.json',
+5074 -13567
View File
File diff suppressed because it is too large. Load diff
+74 -97
View File
@@ -40,158 +40,135 @@
"test-ts-watch": "npm run test -- --watch --watch-extensions ts",
"check-code": "node ./dist/node/experiments/checkCode.js",
"test-inspect": "node --inspect ./node_modules/mocha/bin/mocha.js \"dist/node/tests/**/*.spec.js\" -R progress --exit --watch",
"update-angular": "npm update @angular/common @angular/compiler @angular/core @angular/forms @angular/platform-browser @angular/platform-browser-dynamic @angular/router @angular/animations @angular/compiler-cli @angular/platform-server @angular/cdk --save",
"latest-angular": "npm i @angular/common@latest @angular/compiler@latest @angular/core@latest @angular/forms@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/router@latest @angular/animations@latest @angular/compiler-cli@latest @angular/platform-server@latest @angular/cdk@latest --save",
"update-angular": "npm update @angular/common @angular/compiler @angular/core @angular/forms @angular/platform-browser @angular/router @angular/compiler-cli @angular/build @angular/cdk --save",
"latest-angular": "npm i @angular/common@latest @angular/compiler@latest @angular/core@latest @angular/forms@latest @angular/platform-browser@latest @angular/router@latest @angular/compiler-cli@latest @angular/build@latest @angular/cdk@latest --save",
"update-fontawesome": "npm update @fortawesome/fontawesome-svg-core @fortawesome/free-brands-svg-icons @fortawesome/free-solid-svg-icons @fortawesome/angular-fontawesome --save"
},
"devDependencies": {
"@angular/animations": "22.1.0",
"@angular/build": "22.1.2",
"@angular/common": "22.1.0",
"@angular/compiler": "22.1.0",
"@angular/compiler-cli": "22.1.0",
"@angular/core": "22.1.0",
"@angular/forms": "22.1.0",
"@angular/platform-browser": "22.1.0",
"@angular/platform-browser-dynamic": "22.1.0",
"@angular/platform-server": "22.1.0",
"@angular/router": "22.1.0",
"@angular/build": "22.3.0",
"@angular/common": "22.3.2",
"@angular/compiler": "22.3.2",
"@angular/compiler-cli": "22.3.2",
"@angular/core": "22.3.2",
"@angular/forms": "22.3.2",
"@angular/platform-browser": "22.3.2",
"@angular/router": "22.3.2",
"@babel/core": "7.29.16",
"@eslint/js": "10.0.1",
"@fortawesome/angular-fontawesome": "5.1.0",
"@fortawesome/fontawesome-svg-core": "6.7.2",
"@fortawesome/free-brands-svg-icons": "6.7.2",
"@fortawesome/free-solid-svg-icons": "6.7.2",
"@fortawesome/fontawesome-svg-core": "7.3.1",
"@fortawesome/free-brands-svg-icons": "7.3.1",
"@fortawesome/free-solid-svg-icons": "7.3.1",
"@jridgewell/remapping": "2.3.5",
"@rollup/plugin-babel": "6.1.0",
"@swc/core": "^1.15.47",
"@stylistic/eslint-plugin": "6.0.1",
"@swc/core": "^1.16.22",
"@types/bluebird": "3.5.42",
"@types/body-parser": "1.19.6",
"@types/body-parser": "2.2.0",
"@types/chai": "5.2.3",
"@types/chai-as-promised": "8.0.2",
"@types/cookie-parser": "1.4.10",
"@types/del": "4.0.3",
"@types/delta-e": "0.0.2",
"@types/express": "5.0.6",
"@types/express-session": "1.18.2",
"@types/express-session": "1.19.0",
"@types/file-saver": "2.0.7",
"@types/fs-extra": "11.0.4",
"@types/gl-matrix": "2.4.5",
"@types/glob": "8.1.0",
"@types/google.analytics": "0.0.46",
"@types/howler": "2.2.12",
"@types/lodash": "4.17.24",
"@types/howler": "2.2.13",
"@types/lodash": "4.17.28",
"@types/mocha": "10.0.10",
"@types/morgan": "1.9.10",
"@types/node": "25.5.0",
"@types/node-ipc": "9.2.3",
"@types/node": "26.6.11",
"@types/passport": "1.0.17",
"@types/passport-discord": "0.1.15",
"@types/passport-local": "1.0.38",
"@types/passport-oauth2": "1.8.0",
"@types/pug": "2.0.10",
"@types/serve-favicon": "2.5.7",
"@types/sinon": "21.0.0",
"@types/sinon": "22.0.2",
"@types/ua-parser-js": "0.7.39",
"@types/uws": "0.13.7",
"@types/webgl2": "0.0.12",
"@types/yargs": "17.0.35",
"@typescript-eslint/eslint-plugin": "8.57.1",
"@typescript-eslint/parser": "8.57.1",
"autoprefixer": "10.7.1",
"c8": "^12.0.0",
"chai": "6.2.2",
"chai": "6.3.0",
"chai-as-promised": "8.0.2",
"chalk": "5.6.2",
"del": "8.0.1",
"esbuild": "^0.28.1",
"eslint": "8.57.1",
"eslint-config-google": "0.14.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"focus-visible": "5.0.2",
"chalk": "6.0.1",
"cssnano": "9.9.0",
"del": "9.0.1",
"esbuild": "^0.28.2",
"eslint": "10.16.0",
"focus-visible": "5.2.1",
"globals": "17.15.0",
"gulp": "5.0.1",
"gulp-autoprefixer": "10.0.0",
"gulp-cssnano": "2.1.3",
"gulp-if": "3.0.0",
"gulp-imagemin": "9.2.0",
"gulp-live-server": "0.0.31",
"gulp-plumber": "1.2.1",
"gulp-postcss": "10.0.0",
"gulp-rev": "12.0.0",
"gulp-sass": "6.0.1",
"gulp-shell": "0.8.0",
"gulp-sizereport": "1.2.1",
"gulp-sourcemaps": "3.0.0",
"howler": "2.1.2",
"html-loader": "5.1.0",
"html5-gamepad": "1.1.0",
"merge2": "1.2.4",
"mocha": "11.8.0",
"howler": "2.2.4",
"mocha": "12.0.3",
"postcss": "8.5.34",
"reflect-metadata": "0.2.2",
"rxjs": "7.8.2",
"sass-embedded": "1.108.2",
"sinon": "21.0.3",
"sinon": "22.1.0",
"ts-node": "10.9.2",
"tslib": "2.8.1",
"tsutils": "3.17.1",
"tslib": "2.9.1",
"typescript": "6.0.3",
"typescript-7": "npm:[email protected]",
"workbox-cli": "7.4.0",
"zone.js": "0.15.1"
"typescript-eslint": "8.74.0",
"workbox-cli": "7.4.1",
"zone.js": "0.16.3"
},
"dependencies": {
"@angular/cdk": "22.1.0",
"@encharm/cws": "4.5.3",
"@angular/cdk": "22.3.2",
"@encharm/cws": "4.17.5",
"@passport-next/passport-facebook": "^3.1.3",
"@passport-next/passport-google-oauth2": "^1.0.0",
"ag-psd": "30.1.0",
"ag-sockets": "14.0.2",
"ag-psd": "34.2.3",
"ag-sockets": "14.0.5",
"base64-js": "^1.5.1",
"bluebird": "3.5.5",
"body-parser": "2.2.2",
"bootstrap": "5.3.8",
"canvas": "3.2.1",
"bluebird": "3.7.2",
"body-parser": "2.4.0",
"bootstrap": "5.3.9",
"canvas": "3.2.3",
"canvas-toBlob": "1.0.0",
"color-convert": "3.1.3",
"connect-mongo": "6.0.0",
"cookie-parser": "1.4.4",
"core-js": "3.2.1",
"date-fns": "^4.1.0",
"cookie-parser": "1.4.7",
"core-js": "3.51.0",
"date-fns": "^4.4.0",
"delta-e": "0.0.8",
"errorhandler": "1.5.1",
"express": "5.2.1",
"express-rate-limit": "8.3.1",
"errorhandler": "1.5.2",
"express": "5.3.0",
"express-rate-limit": "8.7.5",
"express-session": "1.19.0",
"file-saver": "2.0.2",
"font-awesome": "4.7.0",
"file-saver": "2.0.5",
"frameguard": "4.0.0",
"fs-extra": "11.3.4",
"gif.js": "0.2.0",
"hsts": "2.2.0",
"fs-extra": "11.4.1",
"hsts": "3.0.0",
"ipware": "2.0.0",
"lodash": "4.17.15",
"markdown-tree": "0.0.0",
"mongoose": "9.3.2",
"morgan": "1.9.1",
"ngx-bootstrap": "21.2.2",
"lodash": "4.18.1",
"mongoose": "9.13.1",
"morgan": "1.12.1",
"ngx-bootstrap": "22.0.0",
"passport": "0.7.0",
"passport-deviantart": "0.0.5",
"passport-discord": "0.1.3",
"passport-github2": "0.1.11",
"passport-github2": "0.1.12",
"passport-local": "1.0.0",
"passport-patreon": "1.0.1",
"passport-tumblr": "0.1.2",
"passport-twitter": "1.0.4",
"passport-vkontakte": "0.3.2",
"passport-oauth1": "1.3.0",
"passport-oauth2": "1.8.0",
"passport-vkontakte": "0.5.0",
"pug": "3.0.4",
"pug-plugin-ng": "0.0.3",
"rollbar": "2.12.2",
"serve-favicon": "2.5.0",
"source-map-support": "0.5.13",
"rollbar": "4.2.1",
"serve-favicon": "2.5.1",
"source-map-support": "0.5.21",
"timsort": "0.3.0",
"tracer": "1.0.1",
"transliteration": "2.6.1",
"ua-parser-js": "2.0.9",
"tracer": "1.3.0",
"transliteration": "2.7.0",
"ua-parser-js": "2.0.10",
"util": "^0.12.5",
"webgl-debug": "2.0.1",
"yargs": "18.0.0"
"yargs": "18.2.0"
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import './bootstrap-common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';
import { AdminAppModule } from './components/admin/admin.module';
platformBrowserDynamic().bootstrapModule(AdminAppModule, { preserveWhitespaces: true });
platformBrowser().bootstrapModule(AdminAppModule, { preserveWhitespaces: true });
+2 -2
View File
@@ -1,8 +1,8 @@
import './bootstrap-common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './components/app/app.module';
import { host, local } from './client/data';
if (DEVELOPMENT || local || host === `${location.protocol}//${location.host}/`) {
platformBrowserDynamic().bootstrapModule(AppModule, { preserveWhitespaces: true });
platformBrowser().bootstrapModule(AppModule, { preserveWhitespaces: true });
}
+2 -2
View File
@@ -1,5 +1,5 @@
import './bootstrap-common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';
import { ToolsAppModule } from './components/tools/tools.module';
platformBrowserDynamic().bootstrapModule(ToolsAppModule, { preserveWhitespaces: true });
platformBrowser().bootstrapModule(ToolsAppModule, { preserveWhitespaces: true });
+2 -2
View File
@@ -1,5 +1,5 @@
import './bootstrap-common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './components/app/app.module';
import { host, local } from './client/data';
@@ -9,5 +9,5 @@ if (DEVELOPMENT || local || host === `${location.protocol}//${location.host}/`)
window.opener.postMessage({ type: 'loaded-page', path }, '*');
}
platformBrowserDynamic().bootstrapModule(AppModule, { preserveWhitespaces: true });
platformBrowser().bootstrapModule(AppModule, { preserveWhitespaces: true });
}
+3 -1
View File
@@ -1,7 +1,9 @@
import { escapeRegExp } from 'lodash';
import { LogArgument } from 'rollbar';
import type Rollbar from 'rollbar';
import { CHARACTER_LIMIT_ERROR } from './errors';
type LogArgument = Rollbar.LogArgument;
const IGNORE = new RegExp([
// adware / extensions
'plantsandplay', 'anyplacetrivial', 'surfbuyermac', 'hotshoppymac', 'GM_getValue', '__gCrWeb.autofill',
+2 -3
View File
@@ -1,9 +1,8 @@
import { NgModule, provideZoneChangeDetection } from '@angular/core';
import { ANIMATION_MODULE_TYPE, NgModule, provideZoneChangeDetection } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
@@ -66,7 +65,6 @@ export const routes: Routes = [
ButtonsModule,
RouterModule.forRoot(routes),
FontAwesomeModule,
NoopAnimationsModule,
],
declarations: [
ToolsRange,
@@ -92,6 +90,7 @@ export const routes: Routes = [
],
providers: [
provideZoneChangeDetection(),
{ provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' },
ErrorReporter,
],
bootstrap: [ToolsApp],
+1 -3
View File
@@ -3,13 +3,11 @@
import { Request } from 'express';
import { isString } from 'lodash';
import { Strategy as GoogleStrategy } from '@passport-next/passport-google-oauth2';
import { Strategy as TwitterStrategy } from 'passport-twitter';
import { Strategy as FacebookStrategy } from '@passport-next/passport-facebook';
import { Strategy as GithubStrategy } from 'passport-github2';
import { Strategy as VKontakteStrategy } from 'passport-vkontakte';
import { Strategy as PatreonStrategy } from 'passport-patreon';
import { Strategy as DiscordStrategy } from 'passport-discord';
import { Profile } from '../common/interfaces';
import { DiscordStrategy, PatreonStrategy, TwitterStrategy } from './oauthStrategies';
import { PATREON_COLOR } from '../common/colors';
import { colorToCSS } from '../common/color';
import { config } from './config';
+143
View File
@@ -0,0 +1,143 @@
import OAuth2Strategy, { InternalOAuthError, StrategyOptionsWithRequest, VerifyFunctionWithRequest } from 'passport-oauth2';
import { Strategy as OAuth1Strategy, InternalOAuthError as InternalOAuth1Error } from 'passport-oauth1';
type Options = Omit<StrategyOptionsWithRequest, 'authorizationURL' | 'tokenURL'>;
function parseJson(body: string | Buffer | undefined, error: string) {
try {
return JSON.parse(String(body));
}
catch {
throw new Error(error);
}
}
export class DiscordStrategy extends OAuth2Strategy {
constructor(options: Options, verify: VerifyFunctionWithRequest) {
super({
authorizationURL: 'https://discord.com/api/oauth2/authorize',
tokenURL: 'https://discord.com/api/oauth2/token',
scopeSeparator: ' ',
...options,
}, verify);
this.name = 'discord';
this._oauth2.useAuthorizationHeaderforGET(true);
}
userProfile(accessToken: string, done: (err?: unknown, profile?: any) => void) {
this._oauth2.get('https://discord.com/api/users/@me', accessToken, (err, body) => {
if (err) {
return done(new InternalOAuthError('Failed to fetch the user profile.', err));
}
try {
const profile = parseJson(body, 'Failed to parse the user profile.');
profile.provider = 'discord';
profile.accessToken = accessToken;
profile.fetchedAt = new Date();
done(null, profile);
}
catch (e) {
done(e);
}
});
}
}
export class PatreonStrategy extends OAuth2Strategy {
constructor(options: Options, verify: VerifyFunctionWithRequest) {
super({
authorizationURL: 'https://www.patreon.com/oauth2/authorize',
tokenURL: 'https://api.patreon.com/oauth2/token',
...options,
}, verify);
this.name = 'patreon';
this._oauth2.useAuthorizationHeaderforGET(true);
}
userProfile(accessToken: string, done: (err?: unknown, profile?: any) => void) {
this._oauth2.get('https://api.patreon.com/oauth2/api/current_user', accessToken, (err, body) => {
if (err) {
return done(new InternalOAuthError('failed to fetch user profile', err));
}
try {
const json = parseJson(body, 'Failed to parse the user profile.').data;
done(null, {
provider: 'patreon',
id: json.id,
name: json.attributes.full_name,
avatar: json.attributes.image_url,
_raw: body,
_json: json,
});
}
catch (e) {
done(e);
}
});
}
}
export class TwitterStrategy extends OAuth1Strategy {
private includeEmail: boolean;
constructor(options: any, verify: (...args: any[]) => void) {
super({
requestTokenURL: 'https://api.twitter.com/oauth/request_token',
accessTokenURL: 'https://api.twitter.com/oauth/access_token',
userAuthorizationURL: 'https://api.twitter.com/oauth/authenticate',
sessionKey: 'oauth:twitter',
...options,
}, verify);
this.name = 'twitter';
this.includeEmail = !!options.includeEmail;
}
authenticate(req: any, options?: any) {
if (req.query && req.query.denied) {
return this.fail();
}
super.authenticate(req, options);
}
userProfile(token: string, tokenSecret: string, _params: any, done: (err?: unknown, profile?: any) => void) {
const url = `https://api.twitter.com/1.1/account/verify_credentials.json${this.includeEmail ? '?include_email=true' : ''}`;
this._oauth.get(url, token, tokenSecret, (err: any, body: string, res: any) => {
if (err) {
const json = err.data ? (() => { try { return JSON.parse(err.data); } catch { return undefined; } })() : undefined;
const error = json && json.errors && json.errors[0];
return done(error ? new Error(error.message) : new InternalOAuth1Error('Failed to fetch user profile', err));
}
try {
const json = parseJson(body, 'Failed to parse user profile');
done(null, {
provider: 'twitter',
id: json.id_str || String(json.id),
username: json.screen_name,
displayName: json.name,
emails: json.email ? [{ value: json.email }] : undefined,
photos: [{ value: json.profile_image_url_https }],
_raw: body,
_json: json,
_accessLevel: res && res.headers['x-access-level'],
});
}
catch (e) {
done(e);
}
});
}
parseErrorResponse(body: string) {
try {
const json = JSON.parse(body);
if (Array.isArray(json.errors) && json.errors.length > 0) {
return new Error(json.errors[0].message);
}
}
catch {
return new Error(body);
}
return undefined;
}
}
+12 -4
View File
@@ -34,17 +34,25 @@ declare module 'connect-mongo';
declare module 'zone.js/plugins/long-stack-trace-zone';
declare module 'passport-google-oauth20' { export const Strategy: any; }
declare module 'passport-twitter' { export const Strategy: any; }
declare module 'passport-facebook' { export const Strategy: any; }
declare module '@passport-next/passport-google-oauth2' { export const Strategy: any; }
declare module '@passport-next/passport-facebook' { export const Strategy: any; }
declare module 'passport-github2' { export const Strategy: any; }
declare module 'passport-vkontakte' { export const Strategy: any; }
declare module 'passport-yahoo-oauth' { export const Strategy: any; }
declare module 'passport-tumblr' { export const Strategy: any; }
declare module 'passport-deviantart' { export const Strategy: any; }
declare module 'passport-steam' { export const Strategy: any; }
declare module 'passport-patreon' { export const Strategy: any; }
declare module 'passport-oauth1' {
export class Strategy {
constructor(options: any, verify: (...args: any[]) => void);
name: string;
protected _oauth: any;
authenticate(req: any, options?: any): void;
fail(...args: any[]): void;
}
export class InternalOAuthError extends Error {
constructor(message: string, err: any);
}
}
declare module 'timsort' {
export function sort<T>(array: T[], compare: (a: T, b: T) => number): void;