diff --git a/ass.js b/ass.js index 9770ab4..d561737 100755 --- a/ass.js +++ b/ass.js @@ -11,11 +11,10 @@ const { host, port, domain, useSsl, resourceIdSize, resourceIdType, isProxied } //#region Imports const fs = require('fs-extra'); -const uuid = require('uuid').v4; const express = require('express'); const useragent = require('express-useragent'); const multer = require('multer'); -const { path, saveData, log, verify, generateId } = require('./utils'); +const { path, saveData, log, verify, generateToken, generateId } = require('./utils'); //#endregion //#region Variables, module setup @@ -37,7 +36,7 @@ function preStartup() { // Make sure auth.json exists and generate the first key if (!fs.existsSync(path('auth.json'))) { - tokens.push(uuid().replace(/-/g, '')); + tokens.push(generateToken()); fs.writeJsonSync(path('auth.json'), { tokens }, { spaces: 4 }); log(`File [auth.json] created\n!! Important: save this token in a secure spot: ${tokens[0]}\n`); } else log('File [auth.json] exists'); diff --git a/utils.js b/utils.js index 53e844f..e4d81ce 100755 --- a/utils.js +++ b/utils.js @@ -1,5 +1,6 @@ const fs = require('fs-extra'); const Path = require('path'); +const token = require('./generators/token'); const zwsGen = require('./generators/zws'); const randomGen = require('./generators/random'); @@ -15,6 +16,7 @@ module.exports = { path: (...paths) => Path.join(__dirname, ...paths), saveData: (data) => fs.writeJsonSync(Path.join(__dirname, 'data.json'), data, { spaces: 4 }), verify: (req, tokens) => req.headers.authorization && tokens.includes(req.headers.authorization), + generateToken: () => token(), generateId: (mode, lenth, originalName) => (mode == idModes.zws) ? zwsGen(lenth) : (mode == idModes.r) ? randomGen(lenth)