@lordbex/thelounge 4.4.3-blowfish → 4.5.0-blowfish-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -7
- package/dist/defaults/config.js +31 -2
- package/dist/package.json +94 -91
- package/dist/server/client.js +188 -194
- package/dist/server/clientManager.js +75 -72
- package/dist/server/command-line/index.js +44 -43
- package/dist/server/command-line/install.js +37 -70
- package/dist/server/command-line/outdated.js +12 -17
- package/dist/server/command-line/start.js +25 -26
- package/dist/server/command-line/storage.js +26 -31
- package/dist/server/command-line/uninstall.js +16 -23
- package/dist/server/command-line/upgrade.js +20 -26
- package/dist/server/command-line/users/add.js +33 -40
- package/dist/server/command-line/users/edit.js +18 -24
- package/dist/server/command-line/users/index.js +12 -16
- package/dist/server/command-line/users/list.js +11 -39
- package/dist/server/command-line/users/remove.js +16 -22
- package/dist/server/command-line/users/reset.js +34 -35
- package/dist/server/command-line/utils.js +231 -87
- package/dist/server/config.js +61 -52
- package/dist/server/helper.js +29 -28
- package/dist/server/identification.js +39 -34
- package/dist/server/index.js +1 -3
- package/dist/server/log.js +19 -16
- package/dist/server/models/chan.js +36 -33
- package/dist/server/models/msg.js +15 -19
- package/dist/server/models/network.js +102 -104
- package/dist/server/models/prefix.js +4 -7
- package/dist/server/models/user.js +5 -10
- package/dist/server/path-helper.js +8 -0
- package/dist/server/plugins/auth/ldap.js +177 -112
- package/dist/server/plugins/auth/local.js +10 -15
- package/dist/server/plugins/auth.js +6 -35
- package/dist/server/plugins/changelog.js +30 -27
- package/dist/server/plugins/clientCertificate.js +33 -37
- package/dist/server/plugins/dev-server.js +15 -21
- package/dist/server/plugins/inputs/action.js +9 -14
- package/dist/server/plugins/inputs/away.js +1 -3
- package/dist/server/plugins/inputs/ban.js +9 -14
- package/dist/server/plugins/inputs/blow.js +9 -14
- package/dist/server/plugins/inputs/connect.js +5 -10
- package/dist/server/plugins/inputs/ctcp.js +7 -12
- package/dist/server/plugins/inputs/disconnect.js +1 -3
- package/dist/server/plugins/inputs/ignore.js +23 -29
- package/dist/server/plugins/inputs/ignorelist.js +12 -18
- package/dist/server/plugins/inputs/index.js +8 -34
- package/dist/server/plugins/inputs/invite.js +7 -12
- package/dist/server/plugins/inputs/kick.js +7 -12
- package/dist/server/plugins/inputs/kill.js +1 -3
- package/dist/server/plugins/inputs/list.js +1 -3
- package/dist/server/plugins/inputs/mode.js +10 -15
- package/dist/server/plugins/inputs/msg.js +13 -18
- package/dist/server/plugins/inputs/mute.js +9 -15
- package/dist/server/plugins/inputs/nick.js +9 -14
- package/dist/server/plugins/inputs/notice.js +5 -7
- package/dist/server/plugins/inputs/part.js +11 -16
- package/dist/server/plugins/inputs/quit.js +7 -13
- package/dist/server/plugins/inputs/rainbow.js +55 -0
- package/dist/server/plugins/inputs/raw.js +1 -3
- package/dist/server/plugins/inputs/rejoin.js +7 -12
- package/dist/server/plugins/inputs/topic.js +7 -12
- package/dist/server/plugins/inputs/whois.js +1 -3
- package/dist/server/plugins/irc-events/away.js +14 -20
- package/dist/server/plugins/irc-events/cap.js +16 -22
- package/dist/server/plugins/irc-events/chghost.js +14 -13
- package/dist/server/plugins/irc-events/connection.js +61 -63
- package/dist/server/plugins/irc-events/ctcp.js +22 -28
- package/dist/server/plugins/irc-events/error.js +20 -26
- package/dist/server/plugins/irc-events/help.js +7 -13
- package/dist/server/plugins/irc-events/info.js +7 -13
- package/dist/server/plugins/irc-events/invite.js +7 -13
- package/dist/server/plugins/irc-events/join.js +30 -27
- package/dist/server/plugins/irc-events/kick.js +21 -17
- package/dist/server/plugins/irc-events/link.js +122 -109
- package/dist/server/plugins/irc-events/list.js +23 -26
- package/dist/server/plugins/irc-events/message.js +46 -52
- package/dist/server/plugins/irc-events/mode.js +66 -63
- package/dist/server/plugins/irc-events/modelist.js +29 -35
- package/dist/server/plugins/irc-events/motd.js +10 -16
- package/dist/server/plugins/irc-events/names.js +3 -6
- package/dist/server/plugins/irc-events/nick.js +26 -23
- package/dist/server/plugins/irc-events/part.js +19 -15
- package/dist/server/plugins/irc-events/quit.js +17 -14
- package/dist/server/plugins/irc-events/sasl.js +9 -15
- package/dist/server/plugins/irc-events/spgroups.js +38 -0
- package/dist/server/plugins/irc-events/spjoin.js +52 -0
- package/dist/server/plugins/irc-events/topic.js +12 -18
- package/dist/server/plugins/irc-events/unhandled.js +12 -12
- package/dist/server/plugins/irc-events/welcome.js +7 -13
- package/dist/server/plugins/irc-events/whois.js +20 -24
- package/dist/server/plugins/massEventAggregator.js +214 -0
- package/dist/server/plugins/messageStorage/sqlite.js +322 -141
- package/dist/server/plugins/messageStorage/text.js +21 -26
- package/dist/server/plugins/packages/index.js +105 -74
- package/dist/server/plugins/packages/publicClient.js +7 -16
- package/dist/server/plugins/packages/themes.js +11 -16
- package/dist/server/plugins/storage.js +28 -33
- package/dist/server/plugins/sts.js +12 -17
- package/dist/server/plugins/uploader.js +40 -43
- package/dist/server/plugins/webpush.js +23 -51
- package/dist/server/server.js +318 -271
- package/dist/server/storageCleaner.js +29 -37
- package/dist/server/utils/fish.js +349 -389
- package/dist/shared/irc.js +3 -6
- package/dist/shared/linkify.js +7 -14
- package/dist/shared/types/chan.js +6 -9
- package/dist/shared/types/changelog.js +1 -2
- package/dist/shared/types/config.js +1 -2
- package/dist/shared/types/mention.js +1 -2
- package/dist/shared/types/msg.js +3 -5
- package/dist/shared/types/network.js +1 -2
- package/dist/shared/types/storage.js +1 -2
- package/dist/shared/types/user.js +1 -2
- package/index.js +14 -10
- package/package.json +94 -91
- package/public/css/style.css +9 -6
- package/public/css/style.css.map +1 -1
- package/public/fonts/font-awesome/fa-brands-400.ttf +0 -0
- package/public/fonts/font-awesome/fa-brands-400.woff2 +0 -0
- package/public/fonts/font-awesome/fa-duotone-900.ttf +0 -0
- package/public/fonts/font-awesome/fa-duotone-900.woff2 +0 -0
- package/public/fonts/font-awesome/fa-light-300.ttf +0 -0
- package/public/fonts/font-awesome/fa-light-300.woff2 +0 -0
- package/public/fonts/font-awesome/fa-regular-400.ttf +0 -0
- package/public/fonts/font-awesome/fa-regular-400.woff2 +0 -0
- package/public/fonts/font-awesome/fa-solid-900.ttf +0 -0
- package/public/fonts/font-awesome/fa-solid-900.woff2 +0 -0
- package/public/fonts/font-awesome/fa-thin-100.ttf +0 -0
- package/public/fonts/font-awesome/fa-thin-100.woff2 +0 -0
- package/public/fonts/font-awesome/fa-v4compatibility.ttf +0 -0
- package/public/fonts/font-awesome/fa-v4compatibility.woff2 +0 -0
- package/public/js/bundle.js +1 -1
- package/public/js/bundle.js.map +1 -1
- package/public/js/bundle.vendor.js +1 -1
- package/public/js/bundle.vendor.js.LICENSE.txt +24 -6
- package/public/js/bundle.vendor.js.map +1 -1
- package/public/js/loading-error-handlers.js +1 -1
- package/public/service-worker.js +1 -1
- package/public/themes/default.css +1 -1
- package/public/themes/morning.css +1 -1
- package/dist/webpack.config.js +0 -224
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const commander_1 = require("commander");
|
|
11
|
-
const config_1 = __importDefault(require("../config"));
|
|
12
|
-
const utils_1 = __importDefault(require("./utils"));
|
|
13
|
-
const program = new commander_1.Command("start");
|
|
1
|
+
import log from "../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import Config from "../config.js";
|
|
7
|
+
import Utils from "./utils.js";
|
|
8
|
+
import { getDirname } from "../path-helper.js";
|
|
9
|
+
const program = new Command("start");
|
|
14
10
|
program
|
|
15
11
|
.description("Start the server")
|
|
16
12
|
.option("--dev", "Development mode with hot module reloading")
|
|
17
|
-
.on("--help",
|
|
18
|
-
.action(function (options) {
|
|
13
|
+
.on("--help", Utils.extraHelp)
|
|
14
|
+
.action(async function (options) {
|
|
19
15
|
initalizeConfig();
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const serverModule = await import("../server.js");
|
|
17
|
+
serverModule.default(options).catch((err) => {
|
|
18
|
+
log.error("Server startup failed:", err);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
24
21
|
});
|
|
25
22
|
function initalizeConfig() {
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
if (!fs.existsSync(Config.getConfigPath())) {
|
|
24
|
+
fs.mkdirSync(Config.getHomePath(), { recursive: true });
|
|
25
|
+
fs.chmodSync(Config.getHomePath(), "0700");
|
|
26
|
+
const __dirname = getDirname(import.meta.url);
|
|
27
|
+
const defaultConfigPath = path.resolve(path.join(__dirname, "..", "..", "defaults", "config.js"));
|
|
28
|
+
fs.copyFileSync(defaultConfigPath, Config.getConfigPath());
|
|
29
|
+
log.info(`Configuration file created at ${colors.green(Config.getConfigPath())}.`);
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
fs.mkdirSync(Config.getUsersPath(), { recursive: true, mode: 0o700 });
|
|
33
32
|
}
|
|
34
|
-
|
|
33
|
+
export default program;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const clientManager_1 = __importDefault(require("../clientManager"));
|
|
9
|
-
const utils_1 = __importDefault(require("./utils"));
|
|
10
|
-
const sqlite_1 = __importDefault(require("../plugins/messageStorage/sqlite"));
|
|
11
|
-
const storageCleaner_1 = require("../storageCleaner");
|
|
12
|
-
const program = new commander_1.Command("storage").description("various utilities related to the message storage");
|
|
1
|
+
import log from "../log.js";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import ClientManager from "../clientManager.js";
|
|
4
|
+
import Utils from "./utils.js";
|
|
5
|
+
import SqliteMessageStorage from "../plugins/messageStorage/sqlite.js";
|
|
6
|
+
import { StorageCleaner } from "../storageCleaner.js";
|
|
7
|
+
const program = new Command("storage").description("various utilities related to the message storage");
|
|
13
8
|
program
|
|
14
9
|
.command("migrate")
|
|
15
10
|
.argument("[username]", "migrate a specific user only, all if not provided")
|
|
16
11
|
.description("Migrate message storage where needed")
|
|
17
|
-
.on("--help",
|
|
12
|
+
.on("--help", Utils.extraHelp)
|
|
18
13
|
.action(function (user) {
|
|
19
14
|
runMigrations(user).catch((err) => {
|
|
20
|
-
|
|
15
|
+
log.error(err.toString());
|
|
21
16
|
process.exit(1);
|
|
22
17
|
});
|
|
23
18
|
});
|
|
@@ -25,15 +20,15 @@ program
|
|
|
25
20
|
.command("clean")
|
|
26
21
|
.argument("[user]", "clean messages for a specific user only, all if not provided")
|
|
27
22
|
.description("Delete messages from the DB based on the storage policy")
|
|
28
|
-
.on("--help",
|
|
23
|
+
.on("--help", Utils.extraHelp)
|
|
29
24
|
.action(function (user) {
|
|
30
25
|
runCleaning(user).catch((err) => {
|
|
31
|
-
|
|
26
|
+
log.error(err.toString());
|
|
32
27
|
process.exit(1);
|
|
33
28
|
});
|
|
34
29
|
});
|
|
35
30
|
async function runMigrations(user) {
|
|
36
|
-
const manager = new
|
|
31
|
+
const manager = new ClientManager();
|
|
37
32
|
const users = manager.getUsers();
|
|
38
33
|
if (user) {
|
|
39
34
|
if (!users.includes(user)) {
|
|
@@ -49,26 +44,26 @@ async function runMigrations(user) {
|
|
|
49
44
|
}
|
|
50
45
|
// runs sqlite migrations for a user, which must exist
|
|
51
46
|
async function migrateUser(manager, user) {
|
|
52
|
-
|
|
47
|
+
log.info("handling user", user);
|
|
53
48
|
if (!isUserLogEnabled(manager, user)) {
|
|
54
|
-
|
|
49
|
+
log.info("logging disabled for user", user, ". Skipping");
|
|
55
50
|
return;
|
|
56
51
|
}
|
|
57
|
-
const sqlite = new
|
|
52
|
+
const sqlite = new SqliteMessageStorage(user);
|
|
58
53
|
await sqlite.enable(); // enable runs migrations
|
|
59
54
|
await sqlite.close();
|
|
60
|
-
|
|
55
|
+
log.info("user", user, "migrated successfully");
|
|
61
56
|
}
|
|
62
57
|
function isUserLogEnabled(manager, user) {
|
|
63
58
|
const conf = manager.readUserConfig(user);
|
|
64
59
|
if (!conf) {
|
|
65
|
-
|
|
60
|
+
log.error("Could not open user configuration of", user);
|
|
66
61
|
return false;
|
|
67
62
|
}
|
|
68
63
|
return conf.log;
|
|
69
64
|
}
|
|
70
65
|
async function runCleaning(user) {
|
|
71
|
-
const manager = new
|
|
66
|
+
const manager = new ClientManager();
|
|
72
67
|
const users = manager.getUsers();
|
|
73
68
|
if (user) {
|
|
74
69
|
if (!users.includes(user)) {
|
|
@@ -83,21 +78,21 @@ async function runCleaning(user) {
|
|
|
83
78
|
}
|
|
84
79
|
}
|
|
85
80
|
async function cleanUser(manager, user) {
|
|
86
|
-
|
|
81
|
+
log.info("handling user", user);
|
|
87
82
|
if (!isUserLogEnabled(manager, user)) {
|
|
88
|
-
|
|
83
|
+
log.info("logging disabled for user", user, ". Skipping");
|
|
89
84
|
return;
|
|
90
85
|
}
|
|
91
|
-
const sqlite = new
|
|
86
|
+
const sqlite = new SqliteMessageStorage(user);
|
|
92
87
|
await sqlite.enable();
|
|
93
|
-
const cleaner = new
|
|
88
|
+
const cleaner = new StorageCleaner(sqlite);
|
|
94
89
|
const num_deleted = await cleaner.runDeletesNoLimit();
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
log.info(`deleted ${num_deleted} messages`);
|
|
91
|
+
log.info("running a vacuum now, this might take a while");
|
|
97
92
|
if (num_deleted > 0) {
|
|
98
93
|
await sqlite.vacuum();
|
|
99
94
|
}
|
|
100
95
|
await sqlite.close();
|
|
101
|
-
|
|
96
|
+
log.info(`cleaning messages for ${user} has been successful`);
|
|
102
97
|
}
|
|
103
|
-
|
|
98
|
+
export default program;
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const config_1 = __importDefault(require("../config"));
|
|
10
|
-
const utils_1 = __importDefault(require("./utils"));
|
|
11
|
-
const program = new commander_1.Command("uninstall");
|
|
1
|
+
import log from "../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import Config from "../config.js";
|
|
5
|
+
import Utils from "./utils.js";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
const program = new Command("uninstall");
|
|
12
9
|
program
|
|
13
10
|
.argument("<package>", "The package to uninstall")
|
|
14
11
|
.description("Uninstall a theme or a package")
|
|
15
|
-
.on("--help",
|
|
12
|
+
.on("--help", Utils.extraHelp)
|
|
16
13
|
.action(async function (packageName) {
|
|
17
|
-
|
|
18
|
-
const fs = require("fs").promises;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
-
const path = require("path");
|
|
21
|
-
const packagesConfig = path.join(config_1.default.getPackagesPath(), "package.json");
|
|
14
|
+
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
|
22
15
|
// const packages = JSON.parse(fs.readFileSync(packagesConfig, "utf-8"));
|
|
23
16
|
const packages = JSON.parse(await fs.readFile(packagesConfig, "utf-8"));
|
|
24
17
|
if (!packages.dependencies ||
|
|
25
18
|
!Object.prototype.hasOwnProperty.call(packages.dependencies, packageName)) {
|
|
26
|
-
|
|
19
|
+
log.warn(`${colors.green(packageName)} is not installed.`);
|
|
27
20
|
process.exit(1);
|
|
28
21
|
}
|
|
29
|
-
|
|
22
|
+
log.info(`Uninstalling ${colors.green(packageName)}...`);
|
|
30
23
|
try {
|
|
31
|
-
await
|
|
32
|
-
|
|
24
|
+
await Utils.executeYarnCommand("remove", packageName);
|
|
25
|
+
log.info(`${colors.green(packageName)} has been successfully uninstalled.`);
|
|
33
26
|
}
|
|
34
27
|
catch (code_1) {
|
|
35
28
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
36
|
-
|
|
29
|
+
log.error(`Failed to uninstall ${colors.green(packageName)}. Exit code: ${code_1}`);
|
|
37
30
|
process.exit(1);
|
|
38
31
|
}
|
|
39
32
|
});
|
|
40
|
-
|
|
33
|
+
export default program;
|
|
@@ -1,50 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const commander_1 = require("commander");
|
|
10
|
-
const config_1 = __importDefault(require("../config"));
|
|
11
|
-
const utils_1 = __importDefault(require("./utils"));
|
|
12
|
-
const program = new commander_1.Command("upgrade");
|
|
1
|
+
import log from "../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import Config from "../config.js";
|
|
5
|
+
import Utils from "./utils.js";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
const program = new Command("upgrade");
|
|
13
9
|
program
|
|
14
10
|
.arguments("[packages...]")
|
|
15
11
|
.description("Upgrade installed themes and packages to their latest versions")
|
|
16
|
-
.on("--help",
|
|
12
|
+
.on("--help", Utils.extraHelp)
|
|
17
13
|
.action(function (packages) {
|
|
18
|
-
const fs = require("fs");
|
|
19
|
-
const path = require("path");
|
|
20
14
|
// Get paths to the location of packages directory
|
|
21
|
-
const packagesConfig = path.join(
|
|
15
|
+
const packagesConfig = path.join(Config.getPackagesPath(), "package.json");
|
|
22
16
|
const packagesList = JSON.parse(fs.readFileSync(packagesConfig, "utf-8")).dependencies;
|
|
23
17
|
const argsList = ["upgrade", "--latest"];
|
|
24
18
|
let count = 0;
|
|
25
19
|
if (!Object.entries(packagesList).length) {
|
|
26
|
-
|
|
20
|
+
log.warn("There are no packages installed.");
|
|
27
21
|
return;
|
|
28
22
|
}
|
|
29
23
|
// If a package names are supplied, check they exist
|
|
30
24
|
if (packages.length) {
|
|
31
|
-
|
|
25
|
+
log.info("Upgrading the following packages:");
|
|
32
26
|
packages.forEach((p) => {
|
|
33
|
-
|
|
27
|
+
log.info(`- ${colors.green(p)}`);
|
|
34
28
|
if (Object.prototype.hasOwnProperty.call(packagesList, p)) {
|
|
35
29
|
argsList.push(p);
|
|
36
30
|
count++;
|
|
37
31
|
}
|
|
38
32
|
else {
|
|
39
|
-
|
|
33
|
+
log.error(`${colors.green(p)} is not installed.`);
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
36
|
}
|
|
43
37
|
else {
|
|
44
|
-
|
|
38
|
+
log.info("Upgrading all packages...");
|
|
45
39
|
}
|
|
46
40
|
if (count === 0 && packages.length) {
|
|
47
|
-
|
|
41
|
+
log.warn("There are not any packages to upgrade.");
|
|
48
42
|
return;
|
|
49
43
|
}
|
|
50
44
|
const command = argsList.shift();
|
|
@@ -52,13 +46,13 @@ program
|
|
|
52
46
|
if (!command) {
|
|
53
47
|
return;
|
|
54
48
|
}
|
|
55
|
-
return
|
|
49
|
+
return Utils.executeYarnCommand(command, ...params)
|
|
56
50
|
.then(() => {
|
|
57
|
-
|
|
51
|
+
log.info("Package(s) have been successfully upgraded.");
|
|
58
52
|
})
|
|
59
53
|
.catch((code) => {
|
|
60
|
-
|
|
54
|
+
log.error(`Failed to upgrade package(s). Exit code ${String(code)}`);
|
|
61
55
|
process.exit(1);
|
|
62
56
|
});
|
|
63
57
|
});
|
|
64
|
-
|
|
58
|
+
export default program;
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const helper_1 = __importDefault(require("../../helper"));
|
|
11
|
-
const config_1 = __importDefault(require("../../config"));
|
|
12
|
-
const utils_1 = __importDefault(require("../utils"));
|
|
13
|
-
const program = new commander_1.Command("add");
|
|
1
|
+
import log from "../../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import Helper from "../../helper.js";
|
|
6
|
+
import Config from "../../config.js";
|
|
7
|
+
import Utils from "../utils.js";
|
|
8
|
+
const program = new Command("add");
|
|
14
9
|
program
|
|
15
10
|
.description("Add a new user")
|
|
16
|
-
.on("--help",
|
|
11
|
+
.on("--help", Utils.extraHelp)
|
|
17
12
|
.option("--password [password]", "new password, will be prompted if not specified")
|
|
18
13
|
.option("--save-logs", "if password is specified, this enables saving logs to disk")
|
|
19
14
|
.argument("<name>", "name of the user")
|
|
20
|
-
.action(function (name, cmdObj) {
|
|
21
|
-
if (!
|
|
22
|
-
|
|
15
|
+
.action(async function (name, cmdObj) {
|
|
16
|
+
if (!fs.existsSync(Config.getUsersPath())) {
|
|
17
|
+
log.error(`${Config.getUsersPath()} does not exist.`);
|
|
23
18
|
return;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
const ClientManager = require("../../clientManager").default;
|
|
20
|
+
const { default: ClientManager } = await import("../../clientManager.js");
|
|
27
21
|
const manager = new ClientManager();
|
|
28
22
|
const users = manager.getUsers();
|
|
29
23
|
if (users === undefined) {
|
|
@@ -31,37 +25,36 @@ program
|
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
33
27
|
if (users.includes(name)) {
|
|
34
|
-
|
|
28
|
+
log.error(`User ${colors.bold(name)} already exists.`);
|
|
35
29
|
return;
|
|
36
30
|
}
|
|
37
31
|
if (cmdObj.password) {
|
|
38
32
|
add(manager, name, cmdObj.password, !!cmdObj.saveLogs);
|
|
39
33
|
return;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
try {
|
|
36
|
+
const password = await log.prompt({
|
|
37
|
+
text: "Enter password:",
|
|
38
|
+
silent: true,
|
|
39
|
+
});
|
|
45
40
|
if (!password) {
|
|
46
|
-
|
|
41
|
+
log.error("Password cannot be empty.");
|
|
47
42
|
return;
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
});
|
|
44
|
+
const enableLog = await log.prompt({
|
|
45
|
+
text: "Save logs to disk?",
|
|
46
|
+
default: "yes",
|
|
47
|
+
});
|
|
48
|
+
add(manager, name, password, enableLog.charAt(0).toLowerCase() === "y");
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
log.error("Error during prompts:", String(err));
|
|
52
|
+
}
|
|
60
53
|
});
|
|
61
54
|
function add(manager, name, password, enableLog) {
|
|
62
|
-
const hash =
|
|
55
|
+
const hash = Helper.password.hash(password);
|
|
63
56
|
manager.addUser(name, hash, enableLog);
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
log.info(`User ${colors.bold(name)} created.`);
|
|
58
|
+
log.info(`User file located at ${colors.green(Config.getUserConfigPath(name))}.`);
|
|
66
59
|
}
|
|
67
|
-
|
|
60
|
+
export default program;
|
|
@@ -1,39 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const config_1 = __importDefault(require("../../config"));
|
|
12
|
-
const utils_1 = __importDefault(require("../utils"));
|
|
13
|
-
const program = new commander_1.Command("edit");
|
|
1
|
+
import log from "../../log.js";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import child from "child_process";
|
|
4
|
+
import colors from "chalk";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import Config from "../../config.js";
|
|
7
|
+
import Utils from "../utils.js";
|
|
8
|
+
const program = new Command("edit");
|
|
14
9
|
program
|
|
15
|
-
.description(`Edit user file located at ${
|
|
10
|
+
.description(`Edit user file located at ${colors.green(Config.getUserConfigPath("<name>"))}`)
|
|
16
11
|
.argument("<name>", "name of the user")
|
|
17
|
-
.on("--help",
|
|
18
|
-
.action(function (name) {
|
|
19
|
-
if (!
|
|
20
|
-
|
|
12
|
+
.on("--help", Utils.extraHelp)
|
|
13
|
+
.action(async function (name) {
|
|
14
|
+
if (!fs.existsSync(Config.getUsersPath())) {
|
|
15
|
+
log.error(`${Config.getUsersPath()} does not exist.`);
|
|
21
16
|
return;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
|
-
const ClientManager = require("../../clientManager").default;
|
|
18
|
+
const ClientManager = (await import("../../clientManager.js")).default;
|
|
25
19
|
const users = new ClientManager().getUsers();
|
|
26
20
|
if (users === undefined) {
|
|
27
21
|
// There was an error, already logged
|
|
28
22
|
return;
|
|
29
23
|
}
|
|
30
24
|
if (!users.includes(name)) {
|
|
31
|
-
|
|
25
|
+
log.error(`User ${colors.bold(name)} does not exist.`);
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
34
|
-
const child_spawn =
|
|
28
|
+
const child_spawn = child.spawn(process.env.EDITOR || "vi", [Config.getUserConfigPath(name)], { stdio: "inherit" });
|
|
35
29
|
child_spawn.on("error", function () {
|
|
36
|
-
|
|
30
|
+
log.error(`Unable to open ${colors.green(Config.getUserConfigPath(name))}. ${colors.bold("$EDITOR")} is not set, and ${colors.bold("vi")} was not found.`);
|
|
37
31
|
});
|
|
38
32
|
});
|
|
39
|
-
|
|
33
|
+
export default program;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
add =
|
|
11
|
-
|
|
12
|
-
reset = require("./reset").default;
|
|
1
|
+
import Config from "../../config.js";
|
|
2
|
+
import list from "./list.js";
|
|
3
|
+
import remove from "./remove.js";
|
|
4
|
+
import edit from "./edit.js";
|
|
5
|
+
let add;
|
|
6
|
+
let reset;
|
|
7
|
+
if (!Config.values.ldap.enable) {
|
|
8
|
+
const addModule = await import("./add.js");
|
|
9
|
+
const resetModule = await import("./reset.js");
|
|
10
|
+
add = addModule.default;
|
|
11
|
+
reset = resetModule.default;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
const remove_1 = __importDefault(require("./remove"));
|
|
16
|
-
const edit_1 = __importDefault(require("./edit"));
|
|
17
|
-
exports.default = [list_1.default, remove_1.default, edit_1.default, add, reset];
|
|
13
|
+
export default [list, remove, edit, add, reset];
|
|
@@ -1,53 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const log_1 = __importDefault(require("../../log"));
|
|
30
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
-
const commander_1 = require("commander");
|
|
32
|
-
const utils_1 = __importDefault(require("../utils"));
|
|
33
|
-
const program = new commander_1.Command("list");
|
|
1
|
+
import log from "../../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import Utils from "../utils.js";
|
|
5
|
+
const program = new Command("list");
|
|
34
6
|
program
|
|
35
7
|
.description("List all users")
|
|
36
|
-
.on("--help",
|
|
8
|
+
.on("--help", Utils.extraHelp)
|
|
37
9
|
.action(async function () {
|
|
38
|
-
const ClientManager = (await
|
|
10
|
+
const ClientManager = (await import("../../clientManager.js")).default;
|
|
39
11
|
const users = new ClientManager().getUsers();
|
|
40
12
|
if (users === undefined) {
|
|
41
13
|
// There was an error, already logged
|
|
42
14
|
return;
|
|
43
15
|
}
|
|
44
16
|
if (users.length === 0) {
|
|
45
|
-
|
|
17
|
+
log.info(`There are currently no users. Create one with ${colors.bold("thelounge add <name>")}.`);
|
|
46
18
|
return;
|
|
47
19
|
}
|
|
48
|
-
|
|
20
|
+
log.info("Users:");
|
|
49
21
|
users.forEach((user, i) => {
|
|
50
|
-
|
|
22
|
+
log.info(`${i + 1}. ${colors.bold(user)}`);
|
|
51
23
|
});
|
|
52
24
|
});
|
|
53
|
-
|
|
25
|
+
export default program;
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const commander_1 = require("commander");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const config_1 = __importDefault(require("../../config"));
|
|
11
|
-
const utils_1 = __importDefault(require("../utils"));
|
|
12
|
-
const program = new commander_1.Command("remove");
|
|
1
|
+
import log from "../../log.js";
|
|
2
|
+
import colors from "chalk";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import Config from "../../config.js";
|
|
6
|
+
import Utils from "../utils.js";
|
|
7
|
+
const program = new Command("remove");
|
|
13
8
|
program
|
|
14
9
|
.description("Remove an existing user")
|
|
15
|
-
.on("--help",
|
|
10
|
+
.on("--help", Utils.extraHelp)
|
|
16
11
|
.argument("<name>", "name of the user")
|
|
17
|
-
.action(function (name) {
|
|
18
|
-
if (!
|
|
19
|
-
|
|
12
|
+
.action(async function (name) {
|
|
13
|
+
if (!fs.existsSync(Config.getUsersPath())) {
|
|
14
|
+
log.error(`${Config.getUsersPath()} does not exist.`);
|
|
20
15
|
return;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
const ClientManager = require("../../clientManager").default;
|
|
17
|
+
const ClientManager = (await import("../../clientManager.js")).default;
|
|
24
18
|
const manager = new ClientManager();
|
|
25
19
|
try {
|
|
26
20
|
if (manager.removeUser(name)) {
|
|
27
|
-
|
|
21
|
+
log.info(`User ${colors.bold(name)} removed.`);
|
|
28
22
|
}
|
|
29
23
|
else {
|
|
30
|
-
|
|
24
|
+
log.error(`User ${colors.bold(name)} does not exist.`);
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
|
-
catch
|
|
27
|
+
catch {
|
|
34
28
|
// There was an error, already logged
|
|
35
29
|
}
|
|
36
30
|
});
|
|
37
|
-
|
|
31
|
+
export default program;
|