Skip to content

Commit

Permalink
Remove unused exports
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Nov 2, 2024
1 parent 65167f1 commit 3a89c27
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
12 changes: 6 additions & 6 deletions apps/meteor/app/lib/server/functions/checkUrlForSsrf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ranges: string[] = [
'100.100.100.200/32',
];

export const nslookup = async (hostname: string): Promise<string> => {
const nslookup = async (hostname: string): Promise<string> => {
return new Promise((resolve, reject) => {
lookup(hostname, (error, address) => {
if (error) {
Expand All @@ -33,21 +33,21 @@ export const nslookup = async (hostname: string): Promise<string> => {
});
};

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);
const mask = ~(2 ** (32 - Number(subnet)) - 1);
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) => {
Expand All @@ -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}(?<!-)\.?([A-Za-z0-9-]{2,63}\.?)*[A-Za-z]{2,63}$/;
if (!domainPattern.test(domain)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Meteor.startup(() => {
});
});

export async function sendUserEmail(subject: string, html: string, userData: SaveUserData): Promise<void> {
async function sendUserEmail(subject: string, html: string, userData: SaveUserData): Promise<void> {
if (!userData.email) {
return;
}
Expand Down
9 changes: 0 additions & 9 deletions apps/meteor/app/lib/server/functions/setUsername.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'));
},
});
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ export const methodDeprecationLogger = ((logger) => {
};
})(deprecationLogger.section('METHOD'));

export const streamDeprecationLogger = deprecationLogger.section('STREAM');
// export const streamDeprecationLogger = deprecationLogger.section('STREAM');
1 change: 0 additions & 1 deletion apps/meteor/app/lib/server/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/lib/notifyListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const notifyOnRoomChangedByUserDM = withDbWatcherCheck(
},
);

export const notifyOnPermissionChanged = withDbWatcherCheck(
const notifyOnPermissionChanged = withDbWatcherCheck(
async (permission: IPermission, clientAction: ClientAction = 'updated'): Promise<void> => {
void api.broadcast('permission.changed', { clientAction, data: permission });

Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { WebAppInternals } from 'meteor/webapp';

import { settings } from '../../../settings/server';

export let hostname: string;

settings.watch<string>(
'Site_Url',
// Needed as WebAppInternals.generateBoilerplate needs to be called in a fiber
Expand All @@ -25,7 +23,6 @@ settings.watch<string>(
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) {
Expand Down

0 comments on commit 3a89c27

Please sign in to comment.