From 3a89c2748dd546ce5258028289ad03ce356d3afe Mon Sep 17 00:00:00 2001 From: Tasso Date: Sat, 2 Nov 2024 00:16:49 -0300 Subject: [PATCH] Remove unused exports --- .../app/lib/server/functions/checkUrlForSsrf.ts | 12 ++++++------ .../lib/server/functions/saveUser/sendUserEmail.ts | 2 +- apps/meteor/app/lib/server/functions/setUsername.ts | 9 --------- .../app/lib/server/lib/deprecationWarningLogger.ts | 2 +- apps/meteor/app/lib/server/lib/index.ts | 1 - apps/meteor/app/lib/server/lib/notifyListener.ts | 2 +- .../app/lib/server/startup/settingsOnLoadSiteUrl.ts | 3 --- 7 files changed, 9 insertions(+), 22 deletions(-) diff --git a/apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts b/apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts index 7ec3272ffe4c..de72235fd4e6 100644 --- a/apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts +++ b/apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts @@ -21,7 +21,7 @@ const ranges: string[] = [ '100.100.100.200/32', ]; -export const nslookup = async (hostname: string): Promise => { +const nslookup = async (hostname: string): Promise => { return new Promise((resolve, reject) => { lookup(hostname, (error, address) => { if (error) { @@ -33,11 +33,11 @@ export const nslookup = async (hostname: string): Promise => { }); }; -export const ipToLong = (ip: string): number => { +const ipToLong = (ip: string): number => { return ip.split('.').reduce((acc, octet) => (acc << 8) + parseInt(octet, 10), 0) >>> 0; }; -export const isIpInRange = (ip: string, range: string): boolean => { +const isIpInRange = (ip: string, range: string): boolean => { const [rangeIp, subnet] = range.split('/'); const ipLong = ipToLong(ip); const rangeIpLong = ipToLong(rangeIp); @@ -45,9 +45,9 @@ export const isIpInRange = (ip: string, range: string): boolean => { return (ipLong & mask) === (rangeIpLong & mask); }; -export const isIpInAnyRange = (ip: string): boolean => ranges.some((range) => isIpInRange(ip, range)); +const isIpInAnyRange = (ip: string): boolean => ranges.some((range) => isIpInRange(ip, range)); -export const isValidIPv4 = (ip: string): boolean => { +const isValidIPv4 = (ip: string): boolean => { const octets = ip.split('.'); if (octets.length !== 4) return false; return octets.every((octet) => { @@ -56,7 +56,7 @@ export const isValidIPv4 = (ip: string): boolean => { }); }; -export const isValidDomain = (domain: string): boolean => { +const isValidDomain = (domain: string): boolean => { const domainPattern = /^(?!-)(?!.*--)[A-Za-z0-9-]{1,63}(? { }); }); -export async function sendUserEmail(subject: string, html: string, userData: SaveUserData): Promise { +async function sendUserEmail(subject: string, html: string, userData: SaveUserData): Promise { if (!userData.email) { return; } diff --git a/apps/meteor/app/lib/server/functions/setUsername.ts b/apps/meteor/app/lib/server/functions/setUsername.ts index c4d2c47c6d9d..7aadec17bf40 100644 --- a/apps/meteor/app/lib/server/functions/setUsername.ts +++ b/apps/meteor/app/lib/server/functions/setUsername.ts @@ -7,9 +7,7 @@ import _ from 'underscore'; import { callbacks } from '../../../../lib/callbacks'; import { SystemLogger } from '../../../../server/lib/logger/system'; -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; import { settings } from '../../../settings/server'; -import { RateLimiter } from '../lib'; import { notifyOnUserChange } from '../lib/notifyListener'; import { addUserToRoom } from './addUserToRoom'; import { checkUsernameAvailability } from './checkUsernameAvailability'; @@ -137,10 +135,3 @@ export const _setUsername = async function (userId: string, u: string, fullUser: return user; }; - -export const setUsername = RateLimiter.limitFunction(_setUsername, 1, 60000, { - async 0() { - const userId = Meteor.userId(); - return !userId || !(await hasPermissionAsync(userId, 'edit-other-user-info')); - }, -}); diff --git a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts index 6ca8e3edfbb9..74c176c6bd76 100644 --- a/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts +++ b/apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts @@ -129,4 +129,4 @@ export const methodDeprecationLogger = ((logger) => { }; })(deprecationLogger.section('METHOD')); -export const streamDeprecationLogger = deprecationLogger.section('STREAM'); +// export const streamDeprecationLogger = deprecationLogger.section('STREAM'); diff --git a/apps/meteor/app/lib/server/lib/index.ts b/apps/meteor/app/lib/server/lib/index.ts index fd5c14c56d95..9a5ee594a5a1 100644 --- a/apps/meteor/app/lib/server/lib/index.ts +++ b/apps/meteor/app/lib/server/lib/index.ts @@ -9,7 +9,6 @@ import './notifyUsersOnMessage'; import './meteorFixes'; export { sendNotification } from './sendNotificationsOnMessage'; -export { hostname } from '../startup/settingsOnLoadSiteUrl'; export { passwordPolicy } from './passwordPolicy'; export { validateEmailDomain } from './validateEmailDomain'; export { RateLimiterClass as RateLimiter } from './RateLimiter'; diff --git a/apps/meteor/app/lib/server/lib/notifyListener.ts b/apps/meteor/app/lib/server/lib/notifyListener.ts index 778fe89dbbf4..4703ff9fcf4f 100644 --- a/apps/meteor/app/lib/server/lib/notifyListener.ts +++ b/apps/meteor/app/lib/server/lib/notifyListener.ts @@ -96,7 +96,7 @@ export const notifyOnRoomChangedByUserDM = withDbWatcherCheck( }, ); -export const notifyOnPermissionChanged = withDbWatcherCheck( +const notifyOnPermissionChanged = withDbWatcherCheck( async (permission: IPermission, clientAction: ClientAction = 'updated'): Promise => { void api.broadcast('permission.changed', { clientAction, data: permission }); diff --git a/apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts b/apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts index 231e41cd4a10..48567c1b8a2a 100644 --- a/apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts +++ b/apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts @@ -3,8 +3,6 @@ import { WebAppInternals } from 'meteor/webapp'; import { settings } from '../../../settings/server'; -export let hostname: string; - settings.watch( 'Site_Url', // Needed as WebAppInternals.generateBoilerplate needs to be called in a fiber @@ -25,7 +23,6 @@ settings.watch( Meteor.absoluteUrl.defaultOptions.rootUrl = value; } - hostname = host.replace(/^https?:\/\//, ''); process.env.MOBILE_ROOT_URL = host; process.env.MOBILE_DDP_URL = host; if (typeof WebAppInternals !== 'undefined' && WebAppInternals.generateBoilerplate) {