diff --git a/channels/0/.gitkeep b/channels/0/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/1/.gitkeep b/channels/1/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/2/.gitkeep b/channels/2/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/3/.gitkeep b/channels/3/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/4/.gitkeep b/channels/4/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/5/.gitkeep b/channels/5/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/6/.gitkeep b/channels/6/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/7/.gitkeep b/channels/7/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/8/.gitkeep b/channels/8/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/9/.gitkeep b/channels/9/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/a/.gitkeep b/channels/a/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/b/.gitkeep b/channels/b/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/c/.gitkeep b/channels/c/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/d/.gitkeep b/channels/d/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/e/.gitkeep b/channels/e/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/channels/f/.gitkeep b/channels/f/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/commands/admin/addmod.js b/commands/admin/addmod.js index a1631de..547f994 100644 --- a/commands/admin/addmod.js +++ b/commands/admin/addmod.js @@ -15,7 +15,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/admin/listusers.js b/commands/admin/listusers.js index 7a02c43..9a5ad73 100644 --- a/commands/admin/listusers.js +++ b/commands/admin/listusers.js @@ -16,7 +16,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/admin/reload.js b/commands/admin/reload.js index 5f39733..a5f3aa7 100644 --- a/commands/admin/reload.js +++ b/commands/admin/reload.js @@ -13,7 +13,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/admin/removemod.js b/commands/admin/removemod.js index e8ddacf..b2e820c 100644 --- a/commands/admin/removemod.js +++ b/commands/admin/removemod.js @@ -15,7 +15,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/admin/saveconfig.js b/commands/admin/saveconfig.js index 90072b8..9c8ea3b 100644 --- a/commands/admin/saveconfig.js +++ b/commands/admin/saveconfig.js @@ -13,7 +13,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/admin/shout.js b/commands/admin/shout.js index a68a156..0c958fd 100644 --- a/commands/admin/shout.js +++ b/commands/admin/shout.js @@ -12,7 +12,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/channels/claimchannel.js b/commands/channels/claimchannel.js new file mode 100644 index 0000000..cab7e19 --- /dev/null +++ b/commands/channels/claimchannel.js @@ -0,0 +1,187 @@ +/** + * @author Marzavec + * @summary Take channel ownership + * @version 1.0.0 + * @description Claim an unowned channel, enabling user management options + * @module claimchannel + */ + +import captcha from 'ascii-captcha'; +import { + isModerator, + getUserDetails, + levels, +} from '../utility/_UAC.js'; +import { + // Errors, + ClaimExpirationDays, +} from '../utility/_Constants.js'; +import { + getChannelSettings, + updateChannelSettings, +} from '../utility/_Channels.js'; + +/** + * Executes when invoked by a remote client + * @param {Object} env - Environment object with references to core, server, socket & payload + * @public + * @return {void} + */ +export async function run({ + core, server, socket, payload, +}) { + // must be in a channel to run this command + if (typeof socket.channel === 'undefined') { + return server.police.frisk(socket, 10); + } + + if (!socket.trip) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to take ownership: Invalid trip. Refer to `/help claimchannel` for instructions on how to use this command.', + channel: socket.channel, // @todo Multichannel + }, socket); + } + + if (isModerator(socket.level)) { + return server.reply({ + cmd: 'info', // @todo Add numeric error code as `id` + text: "You're already a global moderator; it's free real estate. . .", + channel: socket.channel, // @todo Multichannel + }, socket); + } + + const channelSettings = getChannelSettings(core.appConfig.data, socket.channel); + + if (channelSettings.owned) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: `This channel is already owned by the trip "${channelSettings.ownerTrip}", until ${channelSettings.claimExpires}`, + channel: socket.channel, // @todo Multichannel + }, socket); + } + + socket.claimCaptcha = { + solution: captcha.generateRandomText(7), + }; + + server.reply({ + cmd: 'warn', + text: 'Enter the following to take ownership (case-sensitive):', + channel: payload.channel, // @todo Multichannel + }, socket); + + server.reply({ + cmd: 'captcha', + text: captcha.word2Transformedstr(socket.claimCaptcha.solution), + channel: payload.channel, // @todo Multichannel + }, socket); + + return true; +} + +/** + * Automatically executes once after server is ready to register this modules hooks + * @param {Object} server - Reference to server environment object + * @public + * @return {void} + */ +export function initHooks(server) { + server.registerHook('in', 'chat', this.chatHook.bind(this), 26); +} + +/** + * Executes every time an incoming chat command is invoked + * @param {Object} env - Environment object with references to core, server, socket & payload + * @public + * @return {{Object|boolean|string}} Object = same/new payload, false = suppress, string = error + */ +export function chatHook({ + core, server, socket, payload, +}) { + if (typeof payload.text !== 'string') { + return false; + } + + if (typeof socket.claimCaptcha !== 'undefined') { + if (payload.text === socket.claimCaptcha.solution) { + socket.claimCaptcha = undefined; + + const channelSettings = getChannelSettings(core.appConfig.data, socket.channel); + + if (channelSettings.owned) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: `This channel is already owned by the trip "${channelSettings.ownerTrip}", until ${channelSettings.claimExpires}`, + channel: socket.channel, // @todo Multichannel + }, socket); + } + + const expirationDate = new Date(); + expirationDate.setDate(expirationDate.getDate() + ClaimExpirationDays); + channelSettings.claimExpires = expirationDate; + channelSettings.owned = true; + channelSettings.ownerTrip = socket.trip; + + updateChannelSettings(core.appConfig.data, socket.channel, channelSettings); + + server.broadcast({ + cmd: 'info', + text: `Channel now owned by "${socket.trip}", until ${channelSettings.claimExpires}`, + channel: socket.channel, + }, { channel: socket.channel }); + + socket.level = levels.channelOwner; + + const updateNotice = { + ...getUserDetails(socket), + ...{ + cmd: 'updateUser', + channel: socket.channel, + }, + }; + + server.broadcast(updateNotice, { channel: socket.channel }); + + return false; + } + + server.police.frisk(socket, 7); + socket.terminate(); + + return false; + } + + if (payload.text.startsWith('/claimchannel')) { + this.run({ + core, + server, + socket, + payload: { + cmd: 'claimchannel', + }, + }); + + return false; + } + + return payload; +} + +/** + * Module meta information + * @public + * @typedef {Object} claimchannel/info + * @property {string} name - Module command name + * @property {string} category - Module category name + * @property {string} description - Information about module + * @property {string} usage - Information about module usage + */ +export const info = { + name: 'claimchannel', + category: 'channels', + description: 'Claim an unowned channel, enabling user management options. You must have a trip code to run this command.', + usage: ` + API: { cmd: 'claimchannel' } + Text: /claimchannel`, +}; diff --git a/commands/channels/setlevel.js b/commands/channels/setlevel.js new file mode 100644 index 0000000..9b12057 --- /dev/null +++ b/commands/channels/setlevel.js @@ -0,0 +1,203 @@ +/** + * @author Marzavec ( https://github.com/marzavec ) + * @summary Change user level + * @version 1.0.0 + * @description Alter the permission level a trip is allowed within current channel + * @module setlevel + */ + +import { + levels, + isChannelModerator, + getUserDetails, +} from '../utility/_UAC.js'; +import { + setChannelTripLevel, +} from '../utility/_Channels.js'; + +/** + * Automatically executes once after server is ready + * @param {Object} core - Reference to core environment object + * @public + * @return {void} + */ +export async function init(core) { + core.levelLabels = Object.keys(levels); +} + +/** + * Executes when invoked by a remote client + * @param {Object} env - Environment object with references to core, server, socket & payload + * @public + * @return {void} + */ +export async function run({ + core, server, socket, payload, +}) { + // increase rate limit chance and ignore if not channel mod or better + if (!isChannelModerator(socket.level)) { + return server.police.frisk(socket, 10); + } + + if (typeof payload.trip !== 'string' || payload.trip.length !== 6) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to set level: Invalid trip. Refer to `/help setlevel` for instructions on how to use this command.', + channel: socket.channel, // @todo Multichannel + }, socket); + } + + if (typeof payload.level !== 'string') { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to set level: Invalid level label. Refer to `/help setlevel` for instructions on how to use this command.', + channel: socket.channel, // @todo Multichannel + }, socket); + } + + if (core.levelLabels.indexOf(payload.level) === -1) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: `Failed to set level: Invalid level label; choices are case sensitive: ${core.levelLabels.join(', ')}`, + channel: socket.channel, // @todo Multichannel + }, socket); + } + + const newLevel = levels[payload.level]; + + if (newLevel >= socket.level) { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to set level: New level may not be the same or greater than your own.', + channel: socket.channel, // @todo Multichannel + }, socket); + } + + const setError = setChannelTripLevel(core.appConfig.data, socket.channel, payload.trip, newLevel); + + if (setError !== '') { + return server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: `Failed to set level: ${setError}`, + channel: socket.channel, // @todo Multichannel + }, socket); + } + + const targetClients = server.findSockets({ + channel: socket.channel, + trip: payload.trip, + }); + + for (let i = 0, j = targetClients.length; i < j; i += 1) { + targetClients[i].level = newLevel; + + server.broadcast({ + ...getUserDetails(targetClients[i]), + ...{ + cmd: 'updateUser', + channel: socket.channel, + }, + }, { channel: socket.channel }); + } + + server.broadcast({ + cmd: 'info', // @todo Add numeric error code as `id` + text: `Changed permission level of "${payload.trip}" to "${payload.level}"`, + channel: socket.channel, // @todo Multichannel + }, { channel: socket.channel }); + + return true; +} + +/** + * Automatically executes once after server is ready to register this modules hooks + * @param {Object} server - Reference to server environment object + * @public + * @return {void} + */ +export function initHooks(server) { + server.registerHook('in', 'chat', this.setlevelCheck.bind(this), 29); +} + +/** + * Executes every time an incoming chat command is invoked + * @param {Object} env - Environment object with references to core, server, socket & payload + * @public + * @return {(Object|boolean|string)} Object = same/altered payload, + * false = suppress action, + * string = error + */ +export function setlevelCheck({ + core, server, socket, payload, +}) { + if (typeof payload.text !== 'string') { + return false; + } + + if (payload.text.startsWith('/setlevel')) { + const input = payload.text.split(' '); + + // If there is no trip parameter + if (!input[1]) { + server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to set level: Invalid trip. Refer to `/help setlevel` for instructions on how to use this command.', + channel: socket.channel, // @todo Multichannel + }, socket); + + return false; + } + + // If there is no level parameter + if (!input[2]) { + server.reply({ + cmd: 'warn', // @todo Add numeric error code as `id` + text: 'Failed to set level: Invalid level label. Refer to `/help setlevel` for instructions on how to use this command.', + channel: socket.channel, // @todo Multichannel + }, socket); + + return false; + } + + this.run({ + core, + server, + socket, + payload: { + cmd: 'setlevel', + trip: input[1], + level: input[2], + }, + }); + + return false; + } + + return payload; +} + +/** + * The following payload properties are required to invoke this module: + * "trip", "level" + * @public + * @typedef {Array} setlevel/requiredData + */ +export const requiredData = ['trip', 'level']; + +/** + * Module meta information + * @public + * @typedef {Object} setlevel/info + * @property {string} name - Module command name + * @property {string} category - Module category name + * @property {string} description - Information about module + * @property {string} usage - Information about module usage + */ +export const info = { + name: 'setlevel', + category: 'channels', + description: 'Alter the permission level a trip is allowed within current channel', + usage: ` + API: { cmd: 'setlevel', trip: '[target trip]', level: '[level label]' } + Text: /setlevel `, +}; diff --git a/commands/core/changecolor.js b/commands/core/changecolor.js index bb75a14..3099a44 100644 --- a/commands/core/changecolor.js +++ b/commands/core/changecolor.js @@ -21,7 +21,7 @@ const verifyColor = (color) => /(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(color); /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -77,7 +77,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -87,7 +87,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/changenick.js b/commands/core/changenick.js index ceda5df..6932b3e 100644 --- a/commands/core/changenick.js +++ b/commands/core/changenick.js @@ -15,7 +15,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -131,7 +131,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -141,7 +141,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/chat.js b/commands/core/chat.js index 958ccbc..4ed9b8d 100644 --- a/commands/core/chat.js +++ b/commands/core/chat.js @@ -76,7 +76,7 @@ export function addActiveMessage(customId, userid) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -147,7 +147,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -159,7 +159,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * checks for miscellaneous '/' based commands - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -186,7 +186,7 @@ export function commandCheckIn({ server, socket, payload }) { /** * Executes every time an incoming chat command is invoked; * assumes a failed chat command invocation and will reject with notice - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/emote.js b/commands/core/emote.js index 3adfbbd..5f4d214 100644 --- a/commands/core/emote.js +++ b/commands/core/emote.js @@ -31,7 +31,7 @@ const parseText = (text) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -78,7 +78,7 @@ export async function run({ server, socket, payload }) { /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -89,7 +89,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /me - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/help.js b/commands/core/help.js index 7431217..64de931 100644 --- a/commands/core/help.js +++ b/commands/core/help.js @@ -6,9 +6,13 @@ * @module help */ +import { + CodebaseVersion, +} from '../utility/_Constants.js'; + /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -43,6 +47,7 @@ export async function run({ } reply += '---\nFor specific help on certain commands, use either:\nText: `/help `\nAPI: `{cmd: \'help\', command: \'\'}`'; + reply += `\n\nHackChat ${CodebaseVersion}`; } else { const command = core.commands.get(payload.command); @@ -73,7 +78,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -84,7 +89,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /help - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/invite.js b/commands/core/invite.js index 2121157..8c19cdb 100644 --- a/commands/core/invite.js +++ b/commands/core/invite.js @@ -32,7 +32,7 @@ export function getChannel(channel = undefined) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/core/join.js b/commands/core/join.js index e6a56e9..0e56575 100644 --- a/commands/core/join.js +++ b/commands/core/join.js @@ -32,7 +32,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/core/morestats.js b/commands/core/morestats.js index c2f4cfa..28bd7bc 100644 --- a/commands/core/morestats.js +++ b/commands/core/morestats.js @@ -29,7 +29,7 @@ const formatTime = (time) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -105,7 +105,7 @@ server-uptime: ${uptime}`, /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -116,7 +116,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /stats - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/core/session.js b/commands/core/session.js index 58e965b..d7d6c6d 100644 --- a/commands/core/session.js +++ b/commands/core/session.js @@ -8,9 +8,10 @@ * @module session */ -import fs from 'fs'; +import { + readFileSync, +} from 'node:fs'; import jsonwebtoken from 'jsonwebtoken'; - import { isModerator, verifyNickname, @@ -66,7 +67,7 @@ function notifyFailure(server, socket) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -171,14 +172,14 @@ export async function run({ /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ export function init(core) { // load the encryption key if required if (typeof core.sessionKey === 'undefined') { - core.sessionKey = fs.readFileSync(SessionLocation); + core.sessionKey = readFileSync(SessionLocation); } } diff --git a/commands/core/stats.js b/commands/core/stats.js index 69f5a07..ec1cfe5 100644 --- a/commands/core/stats.js +++ b/commands/core/stats.js @@ -8,7 +8,7 @@ /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/core/updateMessage.js b/commands/core/updateMessage.js index 8459bfc..8e8f2d6 100644 --- a/commands/core/updateMessage.js +++ b/commands/core/updateMessage.js @@ -20,7 +20,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/core/whisper.js b/commands/core/whisper.js index 3a96338..9f80a39 100644 --- a/commands/core/whisper.js +++ b/commands/core/whisper.js @@ -44,7 +44,7 @@ const parseText = (text) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -111,7 +111,7 @@ export async function run({ server, socket, payload }) { /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -122,7 +122,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /whisper - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/internal/disconnect.js b/commands/internal/disconnect.js index 292c0c3..3a829ca 100644 --- a/commands/internal/disconnect.js +++ b/commands/internal/disconnect.js @@ -12,7 +12,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/internal/socketreply.js b/commands/internal/socketreply.js index 6042937..1a03ec9 100644 --- a/commands/internal/socketreply.js +++ b/commands/internal/socketreply.js @@ -9,7 +9,7 @@ /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/mod/ban.js b/commands/mod/ban.js index abd41ec..d43593b 100644 --- a/commands/mod/ban.js +++ b/commands/mod/ban.js @@ -9,7 +9,6 @@ import { isModerator, getUserDetails, - levels, } from '../utility/_UAC.js'; import { Errors, @@ -20,7 +19,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -76,7 +75,7 @@ export async function run({ text: `Banned ${targetNick}`, user: getUserDetails(targetUser), channel: socket.channel, // @todo Multichannel - }, { channel: socket.channel, level: (level) => level < levels.moderator }); + }, { channel: socket.channel, level: (level) => isModerator(level) }); // notify mods server.broadcast({ diff --git a/commands/mod/disablecaptcha.js b/commands/mod/disablecaptcha.js index 61eab0b..bc60e43 100644 --- a/commands/mod/disablecaptcha.js +++ b/commands/mod/disablecaptcha.js @@ -13,7 +13,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -25,7 +25,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/mod/dumb.js b/commands/mod/dumb.js index d36cc7c..fbcb328 100644 --- a/commands/mod/dumb.js +++ b/commands/mod/dumb.js @@ -61,7 +61,7 @@ const parseText = (text) => { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -73,7 +73,7 @@ export function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -140,7 +140,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -153,7 +153,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, shadow-prevent chat if they are muzzled - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -216,7 +216,7 @@ export function chatCheck({ /** * Executes every time an incoming chat command is invoked; * shadow-prevent all invites from muzzled users - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -288,7 +288,7 @@ export function inviteCheck({ /** * Executes every time an incoming chat command is invoked; * shadow-prevent all whispers from muzzled users - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/mod/enablecaptcha.js b/commands/mod/enablecaptcha.js index 06bba46..84f8ecd 100644 --- a/commands/mod/enablecaptcha.js +++ b/commands/mod/enablecaptcha.js @@ -30,7 +30,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -42,7 +42,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -87,7 +87,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -99,7 +99,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, check if they are answering a captcha - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -154,7 +154,7 @@ export function chatCheck({ /** * Executes every time an incoming join command is invoked; * hook incoming join commands, check if they are joining a captcha protected channel - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/mod/forcecolor.js b/commands/mod/forcecolor.js index 0f6bd23..d2d70dd 100644 --- a/commands/mod/forcecolor.js +++ b/commands/mod/forcecolor.js @@ -28,7 +28,7 @@ const verifyColor = (color) => /(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(color); /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -105,7 +105,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -116,7 +116,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /forcecolor - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/mod/kick.js b/commands/mod/kick.js index 09506c4..17e459b 100644 --- a/commands/mod/kick.js +++ b/commands/mod/kick.js @@ -8,7 +8,6 @@ import { isModerator, - levels, getUserDetails, } from '../utility/_UAC.js'; import { @@ -20,7 +19,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -126,7 +125,7 @@ export async function run({ cmd: 'info', text: `Kicked ${kicked.map((k) => k.nick).join(', ')}`, channel: socket.channel, // @todo Multichannel - }, { channel: socket.channel, level: (level) => level < levels.moderator }); + }, { channel: socket.channel, level: (level) => isModerator(level) }); // stats are fun core.stats.increment('users-kicked', kicked.length); diff --git a/commands/mod/lockroom.js b/commands/mod/lockroom.js index 9c28333..4421e84 100644 --- a/commands/mod/lockroom.js +++ b/commands/mod/lockroom.js @@ -50,7 +50,7 @@ const danteQuotes = [ /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -62,7 +62,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -109,7 +109,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -124,7 +124,7 @@ export function initHooks(server) { /** * Executes every time an incoming changenick command is invoked; * hook incoming changenick commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -143,7 +143,7 @@ export function changeNickCheck({ /** * Executes every time an incoming whisper command is invoked; * hook incoming whisper commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -162,7 +162,7 @@ export function whisperCheck({ /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -185,7 +185,7 @@ export function chatCheck({ /** * Executes every time an incoming invite command is invoked; * hook incoming invite commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -204,7 +204,7 @@ export function inviteCheck({ /** * Executes every time an incoming join command is invoked; * hook incoming join commands, shunt them to purgatory if needed - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/commands/mod/speak.js b/commands/mod/speak.js index ded8802..392ebc4 100644 --- a/commands/mod/speak.js +++ b/commands/mod/speak.js @@ -14,7 +14,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -26,7 +26,7 @@ export function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/mod/unban.js b/commands/mod/unban.js index 16405b2..2256cfa 100644 --- a/commands/mod/unban.js +++ b/commands/mod/unban.js @@ -12,7 +12,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/mod/unbanall.js b/commands/mod/unbanall.js index 93133d2..d18537e 100644 --- a/commands/mod/unbanall.js +++ b/commands/mod/unbanall.js @@ -12,7 +12,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/mod/unlockroom.js b/commands/mod/unlockroom.js index fc217d0..387a8bb 100644 --- a/commands/mod/unlockroom.js +++ b/commands/mod/unlockroom.js @@ -14,7 +14,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -26,7 +26,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/commands/utility/_Channels.js b/commands/utility/_Channels.js index bf8074a..d85919c 100644 --- a/commands/utility/_Channels.js +++ b/commands/utility/_Channels.js @@ -1,3 +1,5 @@ +/* eslint import/no-cycle: [0, { ignoreExternal: true }] */ + /** * @author Marzavec ( https://github.com/marzavec ) * @summary Channel helper @@ -6,8 +8,21 @@ * @module Channels */ +import { + existsSync, + readFileSync, + writeFile, +} from 'node:fs'; +import { + createHash, +} from 'node:crypto'; +import { + levels, +} from './_UAC.js'; import { Errors, + DefaultChannelSettings, + MaxChannelTrips, } from './_Constants.js'; /** @@ -28,6 +43,55 @@ export function canJoinChannel(channel, socket) { return true; } +/** + * Returns the target channel's hash + * @public + * @param {string} channel Target channel + * @return {string} + */ +export function getChannelHash(channel) { + return createHash('sha256').update(channel, 'utf8').digest('hex'); +} + +/** + * Caches the target channel settings to storage + * @public + * @param {string} config Server config object + * @param {string} channel Target channel + * @return {boolean} + */ +export function storeChannelSettings(config, channel) { + const channelHash = getChannelHash(channel); + const configPath = `../../channels/${channelHash[0]}/${channelHash}.json`; + + delete config.permissions[channelHash].channelHash; + + writeFile(configPath, JSON.stringify(config.permissions[channelHash] || DefaultChannelSettings)); + + return true; +} + +/** + * Applies new settings into the specified channel settings + * @public + * @param {string} config Server config object + * @param {string} channel Target channel + * @param {string} newSettings Updated channel settings + * @return {object} + */ +export function updateChannelSettings(config, channel, newSettings) { + const channelHash = getChannelHash(channel); + const updatedSettings = { + ...newSettings, + ...config.permissions[channelHash], + }; + + config.permissions[channelHash] = updatedSettings; + config.permissions[channelHash].lastAccessed = new Date(); + + return updatedSettings; +} + /** * Returns an object containing info about the specified channel, * including if it is owned, mods, permissions @@ -37,15 +101,70 @@ export function canJoinChannel(channel, socket) { * @return {object} */ export function getChannelSettings(config, channel) { - if (typeof config.permissions !== 'undefined') { - if (typeof config.permissions[channel] !== 'undefined') { - return config.permissions[channel]; + const channelHash = getChannelHash(channel); + + if (typeof config.permissions[channelHash] === 'undefined') { + const configPath = `../../channels/${channelHash[0]}/${channelHash}.json`; + + if (!existsSync(configPath)) { + return DefaultChannelSettings; } + + let configData; + try { + configData = JSON.parse(readFileSync(configPath, 'utf8')); + } catch (e) { + console.log(`Corrupted channel config: ${configPath}`); + + return DefaultChannelSettings; + } + + // Check last access date here, if too old; delete file and return DefaultChannelSettings + + config.permissions[channelHash] = configData; } - return { - owned: false, - }; + config.permissions[channelHash].lastAccessed = new Date(); + config.permissions[channelHash].channelHash = channelHash; + + return config.permissions[channelHash]; +} + +/** + * Apply a new permission level to the provided trip, within the provided channel + * @public + * @param {string} config Server config object + * @param {string} channel Target channel name + * @param {string} trip Target trip + * @param {number} level New level + * @return {(string)} + */ +export function setChannelTripLevel(config, channel, trip, level) { + const channelSettings = getChannelSettings(config, channel); + + if (!channelSettings.owned) { + return 'This channel has no owner.'; + } + + const currentTrips = Object.keys(config.permissions[channelSettings.channelHash].tripLevels); + + if (currentTrips.length >= MaxChannelTrips) { + if (level !== levels.default) { + return 'Too many trips used. Remove trips by setting their level to default level.'; + } + + if (currentTrips.indexOf(trip) === -1) { + return 'Invalid trip'; + } + + delete config.permissions[channelSettings.channelHash].tripLevels[trip]; + + return ''; + } + + config.permissions[channelSettings.channelHash].tripLevels[trip] = level; + + return ''; } /** diff --git a/commands/utility/_Constants.js b/commands/utility/_Constants.js index 7f567ef..ed7ae94 100644 --- a/commands/utility/_Constants.js +++ b/commands/utility/_Constants.js @@ -1,11 +1,17 @@ /** * @author Marzavec ( https://github.com/marzavec ) - * @summary Error ID list + * @summary App settings * @version 1.0.0 - * @description Exports an object that hold common global error IDs + * @description Exports an object that hold common constants * @module Constants */ +/** + * Internal version, used mainly for debugging + * @typedef {object} CodebaseVersion + */ +export const CodebaseVersion = '2.2.21b'; + /* Base error ranges */ const GlobalErrors = 10; const JoinErrors = 20; @@ -46,4 +52,30 @@ export const Errors = { }, }; +/** + * The settings structure of a default, unowned channel + * @typedef {object} DefaultChannelSettings + */ +export const DefaultChannelSettings = { + owned: false, + ownerTrip: '', + lastAccessed: new Date(), + claimExpires: new Date(), + motd: '', + lockLevel: 0, + tripLevels: {}, +}; + +/** + * Maximum number of specialized trip levels, per channel + * @typedef {number} MaxChannelTrips + */ +export const MaxChannelTrips = 250; + +/** + * How many days until a claim will expire + * @typedef {number} ClaimExpirationDays + */ +export const ClaimExpirationDays = 7; + export default Errors; diff --git a/commands/utility/_UAC.js b/commands/utility/_UAC.js index 320392e..f5e9ff9 100644 --- a/commands/utility/_UAC.js +++ b/commands/utility/_UAC.js @@ -1,3 +1,5 @@ +/* eslint import/no-cycle: [0, { ignoreExternal: true }] */ + /** * User Account Control information containing level constants * and simple helper functions related to users @@ -7,14 +9,13 @@ * @module UAC */ +import { + createHash, +} from 'node:crypto'; import { getChannelSettings, } from './_Channels.js'; -const { - createHash, -} = await import('crypto'); - /** * Object defining labels for default permission ranges * @typedef {Object} levels @@ -148,9 +149,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 = createHash('sha256').update(pass + salt, 'utf8').digest('base64').substr(0, 6); // check if user is global admin if (trip === config.adminTrip) { @@ -171,19 +170,13 @@ export function getUserPerms(pass, salt, config, channel) { const channelSettings = getChannelSettings(config, channel); if (channelSettings.owned) { - // check if user is channel owner - // @todo channel ownership patch - - // check if user is channel mod - // @todo channel ownership patch - - // check if user is channel trusted - // @todo channel ownership patch + if (channelSettings.ownerTrip === trip) { + level = levels.channelOwner; + } else if (typeof channelSettings.tripLevels[trip] !== 'undefined') { + level = channelSettings.tripLevels[trip]; + } } - // check if user is global trusted - // @todo channel ownership patch - return { trip, level, diff --git a/documentation/DEPLOY.md b/documentation/DEPLOY.md index b1eed6f..39c7af6 100644 --- a/documentation/DEPLOY.md +++ b/documentation/DEPLOY.md @@ -1,4 +1,4 @@ -# Development Enviroment +# Development Environment 1. [Clone](https://help.github.com/articles/cloning-a-repository/) the repository. * Terminal Command: `git clone https://github.com/hack-chat/main.git hackchat` diff --git a/documentation/admin_addmod.js.html b/documentation/admin_addmod.js.html index 8f440eb..abe0347 100644 --- a/documentation/admin_addmod.js.html +++ b/documentation/admin_addmod.js.html @@ -43,7 +43,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/admin_listusers.js.html b/documentation/admin_listusers.js.html index 4d052f1..80e3e59 100644 --- a/documentation/admin_listusers.js.html +++ b/documentation/admin_listusers.js.html @@ -44,7 +44,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/admin_reload.js.html b/documentation/admin_reload.js.html index 3294c48..a0a3048 100644 --- a/documentation/admin_reload.js.html +++ b/documentation/admin_reload.js.html @@ -41,7 +41,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/admin_removemod.js.html b/documentation/admin_removemod.js.html index cab6c34..37c5f4e 100644 --- a/documentation/admin_removemod.js.html +++ b/documentation/admin_removemod.js.html @@ -43,7 +43,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/admin_saveconfig.js.html b/documentation/admin_saveconfig.js.html index 2856e3e..56f5d48 100644 --- a/documentation/admin_saveconfig.js.html +++ b/documentation/admin_saveconfig.js.html @@ -41,7 +41,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/admin_shout.js.html b/documentation/admin_shout.js.html index e5cd885..a485608 100644 --- a/documentation/admin_shout.js.html +++ b/documentation/admin_shout.js.html @@ -40,7 +40,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/core_changecolor.js.html b/documentation/core_changecolor.js.html index 76804dd..7beb200 100644 --- a/documentation/core_changecolor.js.html +++ b/documentation/core_changecolor.js.html @@ -49,7 +49,7 @@ const verifyColor = (color) => /(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(color); /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -105,7 +105,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -115,7 +115,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_changenick.js.html b/documentation/core_changenick.js.html index e70e4b2..1f083a1 100644 --- a/documentation/core_changenick.js.html +++ b/documentation/core_changenick.js.html @@ -43,7 +43,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -159,7 +159,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -169,7 +169,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_chat.js.html b/documentation/core_chat.js.html index 5c8594a..6466666 100644 --- a/documentation/core_chat.js.html +++ b/documentation/core_chat.js.html @@ -104,7 +104,7 @@ export function addActiveMessage(customId, userid) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -175,7 +175,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -187,7 +187,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * checks for miscellaneous '/' based commands - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -214,7 +214,7 @@ export function commandCheckIn({ server, socket, payload }) { /** * Executes every time an incoming chat command is invoked; * assumes a failed chat command invocation and will reject with notice - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_emote.js.html b/documentation/core_emote.js.html index 9779ad6..e9ddba2 100644 --- a/documentation/core_emote.js.html +++ b/documentation/core_emote.js.html @@ -59,7 +59,7 @@ const parseText = (text) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -106,7 +106,7 @@ export async function run({ server, socket, payload }) { /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -117,7 +117,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /me - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_help.js.html b/documentation/core_help.js.html index dd69be4..42c401e 100644 --- a/documentation/core_help.js.html +++ b/documentation/core_help.js.html @@ -36,7 +36,7 @@ /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -101,7 +101,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -112,7 +112,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /help - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_invite.js.html b/documentation/core_invite.js.html index 51e7b23..ac67eae 100644 --- a/documentation/core_invite.js.html +++ b/documentation/core_invite.js.html @@ -60,7 +60,7 @@ export function getChannel(channel = undefined) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/core_join.js.html b/documentation/core_join.js.html index bbb2f07..7854e66 100644 --- a/documentation/core_join.js.html +++ b/documentation/core_join.js.html @@ -60,7 +60,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/core_morestats.js.html b/documentation/core_morestats.js.html index 58e2351..7b9d2de 100644 --- a/documentation/core_morestats.js.html +++ b/documentation/core_morestats.js.html @@ -57,7 +57,7 @@ const formatTime = (time) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -133,7 +133,7 @@ server-uptime: ${uptime}`, /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -144,7 +144,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /stats - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/core_session.js.html b/documentation/core_session.js.html index 3d04283..fc6a9e9 100644 --- a/documentation/core_session.js.html +++ b/documentation/core_session.js.html @@ -94,7 +94,7 @@ function notifyFailure(server, socket) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -199,7 +199,7 @@ export async function run({ /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ diff --git a/documentation/core_stats.js.html b/documentation/core_stats.js.html index e25eb13..2fca5ce 100644 --- a/documentation/core_stats.js.html +++ b/documentation/core_stats.js.html @@ -36,7 +36,7 @@ /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/core_updateMessage.js.html b/documentation/core_updateMessage.js.html index 3b19b89..944b50f 100644 --- a/documentation/core_updateMessage.js.html +++ b/documentation/core_updateMessage.js.html @@ -48,7 +48,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/core_whisper.js.html b/documentation/core_whisper.js.html index bf1f995..87f750a 100644 --- a/documentation/core_whisper.js.html +++ b/documentation/core_whisper.js.html @@ -72,7 +72,7 @@ const parseText = (text) => { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -139,7 +139,7 @@ export async function run({ server, socket, payload }) { /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -150,7 +150,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /whisper - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/internal_disconnect.js.html b/documentation/internal_disconnect.js.html index 5ac0c97..f27322b 100644 --- a/documentation/internal_disconnect.js.html +++ b/documentation/internal_disconnect.js.html @@ -40,7 +40,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/internal_socketreply.js.html b/documentation/internal_socketreply.js.html index 6ac2255..274e07e 100644 --- a/documentation/internal_socketreply.js.html +++ b/documentation/internal_socketreply.js.html @@ -37,7 +37,7 @@ /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_ban.js.html b/documentation/mod_ban.js.html index 2dbe6da..d1101cb 100644 --- a/documentation/mod_ban.js.html +++ b/documentation/mod_ban.js.html @@ -48,7 +48,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_disablecaptcha.js.html b/documentation/mod_disablecaptcha.js.html index 46eba22..14446fa 100644 --- a/documentation/mod_disablecaptcha.js.html +++ b/documentation/mod_disablecaptcha.js.html @@ -41,7 +41,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -53,7 +53,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_dumb.js.html b/documentation/mod_dumb.js.html index 76e943d..9834dc3 100644 --- a/documentation/mod_dumb.js.html +++ b/documentation/mod_dumb.js.html @@ -89,7 +89,7 @@ const parseText = (text) => { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -101,7 +101,7 @@ export function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -168,7 +168,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -181,7 +181,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, shadow-prevent chat if they are muzzled - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -244,7 +244,7 @@ export function chatCheck({ /** * Executes every time an incoming chat command is invoked; * shadow-prevent all invites from muzzled users - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -316,7 +316,7 @@ export function inviteCheck({ /** * Executes every time an incoming chat command is invoked; * shadow-prevent all whispers from muzzled users - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/mod_enablecaptcha.js.html b/documentation/mod_enablecaptcha.js.html index 19b4f59..e454eff 100644 --- a/documentation/mod_enablecaptcha.js.html +++ b/documentation/mod_enablecaptcha.js.html @@ -58,7 +58,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -70,7 +70,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -115,7 +115,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -127,7 +127,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, check if they are answering a captcha - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -182,7 +182,7 @@ export function chatCheck({ /** * Executes every time an incoming join command is invoked; * hook incoming join commands, check if they are joining a captcha protected channel - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/mod_forcecolor.js.html b/documentation/mod_forcecolor.js.html index c92a4d6..6277c75 100644 --- a/documentation/mod_forcecolor.js.html +++ b/documentation/mod_forcecolor.js.html @@ -56,7 +56,7 @@ const verifyColor = (color) => /(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(color); /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -133,7 +133,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -144,7 +144,7 @@ export function initHooks(server) { /** * Executes every time an incoming chat command is invoked; * hooks chat commands checking for /forcecolor - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/mod_kick.js.html b/documentation/mod_kick.js.html index daddd47..48e943d 100644 --- a/documentation/mod_kick.js.html +++ b/documentation/mod_kick.js.html @@ -48,7 +48,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_lockroom.js.html b/documentation/mod_lockroom.js.html index dc97d7b..bfd282c 100644 --- a/documentation/mod_lockroom.js.html +++ b/documentation/mod_lockroom.js.html @@ -78,7 +78,7 @@ const danteQuotes = [ /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -90,7 +90,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ @@ -137,7 +137,7 @@ export async function run({ /** * Automatically executes once after server is ready to register this modules hooks - * @param {Object} server - Reference to server enviroment object + * @param {Object} server - Reference to server environment object * @public * @return {void} */ @@ -152,7 +152,7 @@ export function initHooks(server) { /** * Executes every time an incoming changenick command is invoked; * hook incoming changenick commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -171,7 +171,7 @@ export function changeNickCheck({ /** * Executes every time an incoming whisper command is invoked; * hook incoming whisper commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -190,7 +190,7 @@ export function whisperCheck({ /** * Executes every time an incoming chat command is invoked; * hook incoming chat commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -213,7 +213,7 @@ export function chatCheck({ /** * Executes every time an incoming invite command is invoked; * hook incoming invite commands, reject them if the channel is 'purgatory' - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, @@ -232,7 +232,7 @@ export function inviteCheck({ /** * Executes every time an incoming join command is invoked; * hook incoming join commands, shunt them to purgatory if needed - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {(Object|boolean|string)} Object = same/altered payload, * false = suppress action, diff --git a/documentation/mod_speak.js.html b/documentation/mod_speak.js.html index 1dc51d8..8655c71 100644 --- a/documentation/mod_speak.js.html +++ b/documentation/mod_speak.js.html @@ -42,7 +42,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -54,7 +54,7 @@ export function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_unban.js.html b/documentation/mod_unban.js.html index 269bd23..4d5a3d1 100644 --- a/documentation/mod_unban.js.html +++ b/documentation/mod_unban.js.html @@ -40,7 +40,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_unbanall.js.html b/documentation/mod_unbanall.js.html index 76bcf94..a9ed1a2 100644 --- a/documentation/mod_unbanall.js.html +++ b/documentation/mod_unbanall.js.html @@ -40,7 +40,7 @@ import { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/mod_unlockroom.js.html b/documentation/mod_unlockroom.js.html index f6e1894..aa2ace5 100644 --- a/documentation/mod_unlockroom.js.html +++ b/documentation/mod_unlockroom.js.html @@ -42,7 +42,7 @@ import { /** * Automatically executes once after server is ready - * @param {Object} core - Reference to core enviroment object + * @param {Object} core - Reference to core environment object * @public * @return {void} */ @@ -54,7 +54,7 @@ export async function init(core) { /** * Executes when invoked by a remote client - * @param {Object} env - Enviroment object with references to core, server, socket & payload + * @param {Object} env - Environment object with references to core, server, socket & payload * @public * @return {void} */ diff --git a/documentation/module-addmod.html b/documentation/module-addmod.html index 510321b..2eab838 100644 --- a/documentation/module-addmod.html +++ b/documentation/module-addmod.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-ban.html b/documentation/module-ban.html index e4a3413..62f1a56 100644 --- a/documentation/module-ban.html +++ b/documentation/module-ban.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-changecolor.html b/documentation/module-changecolor.html index 348bc0a..9a76772 100644 --- a/documentation/module-changecolor.html +++ b/documentation/module-changecolor.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -381,7 +381,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -536,7 +536,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-changenick.html b/documentation/module-changenick.html index 5d5e65c..601da31 100644 --- a/documentation/module-changenick.html +++ b/documentation/module-changenick.html @@ -214,7 +214,7 @@ - Reference to server enviroment object + Reference to server environment object @@ -369,7 +369,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -536,7 +536,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-chat.html b/documentation/module-chat.html index f068e08..00077e0 100644 --- a/documentation/module-chat.html +++ b/documentation/module-chat.html @@ -792,7 +792,7 @@ checks for miscellaneous '/' based commands - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -960,7 +960,7 @@ assumes a failed chat command invocation and will reject with notice - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -1127,7 +1127,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -1282,7 +1282,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-disablecaptcha.html b/documentation/module-disablecaptcha.html index 2cabf56..f65ca41 100644 --- a/documentation/module-disablecaptcha.html +++ b/documentation/module-disablecaptcha.html @@ -215,7 +215,7 @@ - Reference to core enviroment object + Reference to core environment object @@ -370,7 +370,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-disconnect.html b/documentation/module-disconnect.html index cf82807..7c65d4a 100644 --- a/documentation/module-disconnect.html +++ b/documentation/module-disconnect.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-dumb.html b/documentation/module-dumb.html index a4e1909..ed1d6cd 100644 --- a/documentation/module-dumb.html +++ b/documentation/module-dumb.html @@ -215,7 +215,7 @@ hook incoming chat commands, shadow-prevent chat if they are muzzled - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -382,7 +382,7 @@ string = error - Reference to core enviroment object + Reference to core environment object @@ -537,7 +537,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -693,7 +693,7 @@ shadow-prevent all invites from muzzled users - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -860,7 +860,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -1016,7 +1016,7 @@ shadow-prevent all whispers from muzzled users - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-emote.html b/documentation/module-emote.html index b753cfc..9f13fd8 100644 --- a/documentation/module-emote.html +++ b/documentation/module-emote.html @@ -215,7 +215,7 @@ hooks chat commands checking for /me - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -382,7 +382,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -537,7 +537,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-enablecaptcha.html b/documentation/module-enablecaptcha.html index 97de3d9..474c7a3 100644 --- a/documentation/module-enablecaptcha.html +++ b/documentation/module-enablecaptcha.html @@ -216,7 +216,7 @@ hook incoming chat commands, check if they are answering a captcha - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -383,7 +383,7 @@ string = error - Reference to core enviroment object + Reference to core environment object @@ -538,7 +538,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -694,7 +694,7 @@ hook incoming join commands, check if they are joining a captcha protected chann - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -861,7 +861,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-forcecolor.html b/documentation/module-forcecolor.html index 02efa9d..254f1a0 100644 --- a/documentation/module-forcecolor.html +++ b/documentation/module-forcecolor.html @@ -215,7 +215,7 @@ hooks chat commands checking for /forcecolor - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -382,7 +382,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -537,7 +537,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-help.html b/documentation/module-help.html index 8f61eef..357a4e8 100644 --- a/documentation/module-help.html +++ b/documentation/module-help.html @@ -215,7 +215,7 @@ hooks chat commands checking for /help - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -382,7 +382,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -537,7 +537,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-invite.html b/documentation/module-invite.html index d862e7a..439e9bc 100644 --- a/documentation/module-invite.html +++ b/documentation/module-invite.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-join.html b/documentation/module-join.html index 74a9c99..efa71c8 100644 --- a/documentation/module-join.html +++ b/documentation/module-join.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-kick.html b/documentation/module-kick.html index c7b82c3..4f1fb8f 100644 --- a/documentation/module-kick.html +++ b/documentation/module-kick.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-listusers.html b/documentation/module-listusers.html index d5caf86..a3d33b6 100644 --- a/documentation/module-listusers.html +++ b/documentation/module-listusers.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-lockroom.html b/documentation/module-lockroom.html index 0ff495a..27dbe73 100644 --- a/documentation/module-lockroom.html +++ b/documentation/module-lockroom.html @@ -215,7 +215,7 @@ hook incoming changenick commands, reject them if the channel is 'purgatory' - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -383,7 +383,7 @@ hook incoming chat commands, reject them if the channel is 'purgatory' - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -550,7 +550,7 @@ string = error - Reference to core enviroment object + Reference to core environment object @@ -705,7 +705,7 @@ string = error - Reference to server enviroment object + Reference to server environment object @@ -861,7 +861,7 @@ hook incoming invite commands, reject them if the channel is 'purgatory' - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -1029,7 +1029,7 @@ hook incoming join commands, shunt them to purgatory if needed - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -1196,7 +1196,7 @@ string = error - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -1352,7 +1352,7 @@ hook incoming whisper commands, reject them if the channel is 'purgatory' - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-morestats.html b/documentation/module-morestats.html index 192146b..8ac5cdd 100644 --- a/documentation/module-morestats.html +++ b/documentation/module-morestats.html @@ -214,7 +214,7 @@ - Reference to server enviroment object + Reference to server environment object @@ -369,7 +369,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -525,7 +525,7 @@ hooks chat commands checking for /stats - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-reload.html b/documentation/module-reload.html index 56fa67b..c91a338 100644 --- a/documentation/module-reload.html +++ b/documentation/module-reload.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-removemod.html b/documentation/module-removemod.html index 1fd4f85..be97676 100644 --- a/documentation/module-removemod.html +++ b/documentation/module-removemod.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-saveconfig.html b/documentation/module-saveconfig.html index eda4496..08c5520 100644 --- a/documentation/module-saveconfig.html +++ b/documentation/module-saveconfig.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-session.html b/documentation/module-session.html index be1c462..5a9ea4e 100644 --- a/documentation/module-session.html +++ b/documentation/module-session.html @@ -392,7 +392,7 @@ - Reference to core enviroment object + Reference to core environment object @@ -547,7 +547,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-shout.html b/documentation/module-shout.html index 61ad2a9..2d62aa4 100644 --- a/documentation/module-shout.html +++ b/documentation/module-shout.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-socketreply.html b/documentation/module-socketreply.html index 55fc9f4..512fdac 100644 --- a/documentation/module-socketreply.html +++ b/documentation/module-socketreply.html @@ -215,7 +215,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-speak.html b/documentation/module-speak.html index 833b986..52f9545 100644 --- a/documentation/module-speak.html +++ b/documentation/module-speak.html @@ -214,7 +214,7 @@ - Reference to core enviroment object + Reference to core environment object @@ -369,7 +369,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-stats.html b/documentation/module-stats.html index 209eded..b831fbd 100644 --- a/documentation/module-stats.html +++ b/documentation/module-stats.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-unban.html b/documentation/module-unban.html index ce37d42..ba546c6 100644 --- a/documentation/module-unban.html +++ b/documentation/module-unban.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-unbanall.html b/documentation/module-unbanall.html index fface1a..589dc75 100644 --- a/documentation/module-unbanall.html +++ b/documentation/module-unbanall.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-unlockroom.html b/documentation/module-unlockroom.html index 508ba70..db41943 100644 --- a/documentation/module-unlockroom.html +++ b/documentation/module-unlockroom.html @@ -214,7 +214,7 @@ - Reference to core enviroment object + Reference to core environment object @@ -369,7 +369,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-updateMessage.html b/documentation/module-updateMessage.html index 6d87c8e..8db47a1 100644 --- a/documentation/module-updateMessage.html +++ b/documentation/module-updateMessage.html @@ -214,7 +214,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/documentation/module-whisper.html b/documentation/module-whisper.html index 3da3aa1..609eb4c 100644 --- a/documentation/module-whisper.html +++ b/documentation/module-whisper.html @@ -222,7 +222,7 @@ - Reference to server enviroment object + Reference to server environment object @@ -377,7 +377,7 @@ - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload @@ -533,7 +533,7 @@ hooks chat commands checking for /whisper - Enviroment object with references to core, server, socket & payload + Environment object with references to core, server, socket & payload diff --git a/main.mjs b/main.mjs index 285f160..5f2246e 100644 --- a/main.mjs +++ b/main.mjs @@ -1,8 +1,14 @@ -import fs from 'fs'; -import { join, dirname } from 'path'; -import { Low, JSONFile } from 'lowdb'; -import { fileURLToPath } from 'url'; -import { CoreApp } from 'hackchat-server'; +import { + existsSync, + readFileSync, +} from 'node:fs'; +import { + Low, + JSONFile, +} from 'lowdb'; +import { + CoreApp, +} from 'hackchat-server'; // required file paths const SessionLocation = './session.key'; @@ -10,15 +16,15 @@ const SaltLocation = './salt.key'; const AppConfigLocation = './config.json'; // verify required files exist -if (fs.existsSync(SessionLocation) === false) { +if (existsSync(SessionLocation) === false) { throw Error('Missing session key, you may need to run: npm run config'); } -if (fs.existsSync(SaltLocation) === false) { +if (existsSync(SaltLocation) === false) { throw Error('Missing salt key, you may need to run: npm run config'); } -if (fs.existsSync(AppConfigLocation) === false) { +if (existsSync(AppConfigLocation) === false) { throw Error('Missing config, you may need to run: npm run config'); } @@ -30,10 +36,10 @@ const server = new CoreApp({ }); // load sessoin key data -server.sessionKey = fs.readFileSync(SessionLocation); +server.sessionKey = readFileSync(SessionLocation); // load salt key data -server.saltKey = fs.readFileSync(SaltLocation); +server.saltKey = readFileSync(SaltLocation); // load the configuration data const adapter = new JSONFile(AppConfigLocation); diff --git a/scripts/config.js b/scripts/config.js index 89d3d80..a5ad4d1 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -1,8 +1,19 @@ /* eslint-disable no-await-in-loop */ /* eslint import/no-unresolved: 0 */ -import fs from 'fs'; -import { Low, JSONFile } from 'lowdb'; +import { + existsSync, + readFileSync, + writeFile, + writeFileSync, +} from 'node:fs'; +import { + createHash, +} from 'node:crypto'; +import { + Low, + JSONFile, +} from 'lowdb'; import crypto from 'crypto'; import enquirerPkg from 'enquirer'; @@ -45,7 +56,7 @@ const config = new Low(adapter); // check for missing cert, generate if needed const checkCert = async () => { - if (fs.existsSync(SessionLocation) === false) { + if (existsSync(SessionLocation) === false) { const prompt = new Confirm({ name: 'certDialogue', message: 'Missing session key, create new?', @@ -54,7 +65,7 @@ const checkCert = async () => { if (await prompt.run() !== false) { const data = crypto.randomBytes(4096); - fs.writeFile(SessionLocation, data, (err) => { + writeFile(SessionLocation, data, (err) => { if (err) throw err; }); } @@ -75,7 +86,7 @@ const checkConfig = async () => { // check for missing or uninitialized salt const checkTripSalt = async () => { - if (fs.existsSync(SaltLocation) === false) { + if (existsSync(SaltLocation) === false) { const prompt = new Confirm({ name: 'overwrite', message: 'Missing trip salt, create new?', @@ -84,7 +95,7 @@ const checkTripSalt = async () => { if (await prompt.run() !== false) { const data = crypto.randomBytes(4096); - fs.writeFileSync(SaltLocation, data); + writeFileSync(SaltLocation, data); } } else { console.log('Found existing trip salt.'); @@ -94,7 +105,7 @@ const checkTripSalt = async () => { // verify config has an admin account const checkPermissions = async () => { if (typeof config.data.adminTrip === 'undefined' || config.data.adminTrip === '') { - const salt = fs.readFileSync(SaltLocation); + const salt = readFileSync(SaltLocation); const prompt = new Password({ name: 'adminPassword', @@ -103,9 +114,7 @@ const checkPermissions = async () => { const password = await prompt.run(); - const sha = crypto.createHash('sha256'); - sha.update(password + salt); - config.data.adminTrip = sha.digest('base64').substr(0, 6); + config.data.adminTrip = createHash('sha256').update(password + salt, 'utf8').digest('base64').substr(0, 6); await config.write(); } else {