diff --git a/commands/utility/_UAC.js b/commands/utility/_UAC.js index f003288..96a9332 100644 --- a/commands/utility/_UAC.js +++ b/commands/utility/_UAC.js @@ -15,6 +15,8 @@ const { createHash, } = await import('crypto'); +const TripLength = 10; + /** * Object defining labels for default permission ranges * @typedef {Object} levels @@ -150,7 +152,7 @@ export function getUserPerms(pass, salt, config, channel) { const sha = createHash('sha256'); sha.update(pass + salt); - const trip = sha.digest('base64').substr(0, 6); + const trip = sha.digest('base64').substr(0, TripLength); // check if user is global admin if (trip === config.adminTrip) { diff --git a/scripts/config.js b/scripts/config.js index 89d3d80..eb8e875 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -18,6 +18,8 @@ const SessionLocation = './session.key'; const SaltLocation = './salt.key'; const AppConfigLocation = './config.json'; +const TripLength = 10; + // default configuration options const defaultConfig = { adminTrip: '', @@ -105,7 +107,7 @@ const checkPermissions = async () => { const sha = crypto.createHash('sha256'); sha.update(password + salt); - config.data.adminTrip = sha.digest('base64').substr(0, 6); + config.data.adminTrip = sha.digest('base64').substr(0, TripLength); await config.write(); } else { diff --git a/test/uac.test.js b/test/uac.test.js index be017e1..f64bada 100644 --- a/test/uac.test.js +++ b/test/uac.test.js @@ -42,7 +42,7 @@ describe('Checking UAC module', () => { it('should return admin level labels', async () => { const newConfig = Object.assign({}, mocks.core.appConfig.data); - newConfig.adminTrip = 'Tt8H7c'; + newConfig.adminTrip = 'Tt8H7clbL9'; const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake'); expect(resp).to.be.an('object'); }); @@ -50,7 +50,7 @@ describe('Checking UAC module', () => { it('should return mod level labels', async () => { const newConfig = Object.assign({}, mocks.core.appConfig.data); newConfig.globalMods = [{ - trip: 'Tt8H7c', + trip: 'Tt8H7clbL9', }]; const resp = importedModule.getUserPerms('test', 'salt', newConfig, 'cake'); expect(resp).to.be.an('object');