fluxy-bot 0.11.4 → 0.11.5
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/bin/cli.js +37 -0
- package/cli/index.ts +0 -2
- package/package.json +1 -1
- package/cli/commands/password-reset.ts +0 -44
package/bin/cli.js
CHANGED
|
@@ -1735,6 +1735,42 @@ async function tunnel(sub) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
1737
|
|
|
1738
|
+
// ── Password Reset ──
|
|
1739
|
+
|
|
1740
|
+
async function passwordReset() {
|
|
1741
|
+
const DB_PATH = path.join(DATA_DIR, 'memory.db');
|
|
1742
|
+
|
|
1743
|
+
if (!fs.existsSync(DB_PATH)) {
|
|
1744
|
+
console.log(`\n ${c.red}✗${c.reset} No database found. Run ${c.pink}fluxy init${c.reset} and complete setup first.\n`);
|
|
1745
|
+
process.exit(1);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
const Database = (await import('better-sqlite3')).default;
|
|
1749
|
+
const db = new Database(DB_PATH);
|
|
1750
|
+
|
|
1751
|
+
// Clear password and TOTP credentials
|
|
1752
|
+
db.prepare("DELETE FROM settings WHERE key IN ('portal_pass', 'totp_enabled', 'totp_secret', 'totp_recovery_codes')").run();
|
|
1753
|
+
|
|
1754
|
+
// Reset onboard flag so the wizard appears on next visit
|
|
1755
|
+
db.prepare("INSERT INTO settings (key, value) VALUES ('onboard_complete', 'false') ON CONFLICT(key) DO UPDATE SET value = 'false', updated_at = CURRENT_TIMESTAMP").run();
|
|
1756
|
+
|
|
1757
|
+
// Invalidate all active sessions and trusted devices
|
|
1758
|
+
db.prepare('DELETE FROM sessions').run();
|
|
1759
|
+
db.prepare('DELETE FROM trusted_devices').run();
|
|
1760
|
+
|
|
1761
|
+
db.close();
|
|
1762
|
+
|
|
1763
|
+
console.log(`\n ${c.blue}✔${c.reset} Password reset successful.\n`);
|
|
1764
|
+
console.log(` ${c.dim}The onboard wizard will appear on your next visit`);
|
|
1765
|
+
console.log(` so you can create a new password.${c.reset}\n`);
|
|
1766
|
+
|
|
1767
|
+
// Auto-restart daemon if it's running
|
|
1768
|
+
if (isDaemonInstalled() && isDaemonActive()) {
|
|
1769
|
+
console.log(` ${c.dim}Restarting Fluxy daemon...${c.reset}`);
|
|
1770
|
+
daemon('restart');
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1738
1774
|
// ── Route ──
|
|
1739
1775
|
|
|
1740
1776
|
switch (command) {
|
|
@@ -1746,6 +1782,7 @@ switch (command) {
|
|
|
1746
1782
|
case 'update': update(); break;
|
|
1747
1783
|
case 'daemon': daemon(subcommand); break;
|
|
1748
1784
|
case 'tunnel': tunnel(subcommand); break;
|
|
1785
|
+
case 'password-reset': passwordReset(); break;
|
|
1749
1786
|
default:
|
|
1750
1787
|
fs.existsSync(CONFIG_PATH) ? start() : init();
|
|
1751
1788
|
}
|
package/cli/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { registerStartCommand } from './commands/start.js';
|
|
|
9
9
|
import { registerTunnelCommand } from './commands/tunnel.js';
|
|
10
10
|
import { registerUpdateCommand } from './commands/update.js';
|
|
11
11
|
import { registerInitCommand } from './commands/init.js';
|
|
12
|
-
import { registerPasswordResetCommand } from './commands/password-reset.js';
|
|
13
12
|
|
|
14
13
|
const program = new Command();
|
|
15
14
|
|
|
@@ -23,7 +22,6 @@ registerDaemonCommand(program);
|
|
|
23
22
|
registerTunnelCommand(program);
|
|
24
23
|
registerUpdateCommand(program);
|
|
25
24
|
registerInitCommand(program);
|
|
26
|
-
registerPasswordResetCommand(program);
|
|
27
25
|
|
|
28
26
|
// Aliases for convenience matching the old CLI
|
|
29
27
|
program
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import pc from 'picocolors';
|
|
5
|
-
import Database from 'better-sqlite3';
|
|
6
|
-
|
|
7
|
-
import { DATA_DIR } from '../core/config.js';
|
|
8
|
-
|
|
9
|
-
const DB_PATH = path.join(DATA_DIR, 'memory.db');
|
|
10
|
-
|
|
11
|
-
export function registerPasswordResetCommand(program: Command) {
|
|
12
|
-
program
|
|
13
|
-
.command('password-reset')
|
|
14
|
-
.description('Reset your portal password via the onboard wizard')
|
|
15
|
-
.action(() => {
|
|
16
|
-
if (!fs.existsSync(DB_PATH)) {
|
|
17
|
-
console.log(pc.red('✗ No database found. Run ' + pc.magenta('fluxy init') + ' first.'));
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const db = new Database(DB_PATH);
|
|
22
|
-
|
|
23
|
-
// Clear password and TOTP credentials
|
|
24
|
-
db.prepare("DELETE FROM settings WHERE key IN ('portal_pass', 'totp_enabled', 'totp_secret', 'totp_recovery_codes')").run();
|
|
25
|
-
|
|
26
|
-
// Reset onboard flag so the wizard appears on next visit
|
|
27
|
-
db.prepare("INSERT INTO settings (key, value) VALUES ('onboard_complete', 'false') ON CONFLICT(key) DO UPDATE SET value = 'false', updated_at = CURRENT_TIMESTAMP").run();
|
|
28
|
-
|
|
29
|
-
// Invalidate all active sessions
|
|
30
|
-
db.prepare('DELETE FROM sessions').run();
|
|
31
|
-
db.prepare('DELETE FROM trusted_devices').run();
|
|
32
|
-
|
|
33
|
-
db.close();
|
|
34
|
-
|
|
35
|
-
console.log();
|
|
36
|
-
console.log(pc.green('✓ Password reset successful.'));
|
|
37
|
-
console.log();
|
|
38
|
-
console.log(pc.dim(' The onboard wizard will appear on your next visit'));
|
|
39
|
-
console.log(pc.dim(' so you can create a new password.'));
|
|
40
|
-
console.log();
|
|
41
|
-
console.log(pc.dim(' Restart Fluxy if it\'s running: ') + pc.magenta('fluxy stop && fluxy start'));
|
|
42
|
-
console.log();
|
|
43
|
-
});
|
|
44
|
-
}
|