diff --git a/src/auth.ts b/src/auth.ts index eb4000b..8b1b392 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -6,7 +6,7 @@ import fs from 'fs-extra'; import { nanoid } from 'nanoid'; import { Request } from 'express'; import bcrypt from 'bcrypt'; -import { log, path, arrayEquals } from './utils'; +import { log, path } from './utils'; import { data } from './data'; import { User, Users, OldUsers } from './types/auth'; import { FileData } from './types/definitions'; @@ -238,17 +238,3 @@ export const verifyCliKey = (req: Request) => { const cliKey: string = fs.readJsonSync(path('auth.json')).cliKey; return req.headers.authorization != null && req.headers.authorization === cliKey; }; - -// todo: move inside of onStart (currently broken) -// Monitor auth.json for changes (triggered by running 'npm run new-token') -/* fs.watch(path('auth.json'), { persistent: false }, - (eventType: String) => eventType === 'change' && fs.readJson(path('auth.json')) - .then((json: { users: JSON[] }) => { - if (!(arrayEquals(Object.keys(users), Object.keys(json.users)))) { - // @ts-ignore - Object.keys(json.users).forEach((token) => (!Object.prototype.hasOwnProperty.call(users, token)) && (users[token] = json.users[token])); - log.info('New token added', Object.keys(users)[Object.keys(users).length - 1] || 'No new token'); - } - }) - .catch(console.error)); - */ \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 934f828..abdb81a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -68,10 +68,6 @@ export function replaceholder(data: string, size: number, timestamp: number, tim .replace(/×tamp/g, formatTimestamp(timestamp, timeoffset)); } -export function arrayEquals(arr1: any[], arr2: any[]) { - return arr1.length === arr2.length && arr1.slice().sort().every((value: string, index: number) => value === arr2.slice().sort()[index]) -} - const idModes = { zws: 'zws', // Zero-width spaces (see: https://zws.im/) og: 'original', // Use original uploaded filename @@ -116,7 +112,6 @@ module.exports = { }), generateToken: () => token(), generateId, - arrayEquals, downloadTempS3: (file: FileData) => new Promise((resolve: Function, reject) => fetch(getS3url(file.randomId, file.ext)) .then((f2) => f2.body!.pipe(fs.createWriteStream(Path.join(__dirname, diskFilePath, sanitize(file.originalname))).on('close', () => resolve())))