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

+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;