Plugin & Theme System: - Add plugin type definitions, permissions (30+), and validation constants - Add IndexedDB storage layer for plugin code, theme CSS, and previews - Add theme CSS sanitization, injection, and safety validation - Add HookBus event system with 130+ hooks across 20 domains - Add plugin ZIP extraction and manifest validation with JS security checks - Add sandboxed PluginAPI factory with scoped storage, logging, and permission gating - Add plugin loader with blob URL dynamic import and auto-disable circuit breaker - Add 3 built-in themes (Nord, Catppuccin, Solarized) - Add Zustand plugin store with install/uninstall/enable/disable lifecycle - Add PluginSlot, PluginSlotRenderer, and PluginErrorBoundary components - Add plugins and themes settings UI panels - Integrate plugin slots into email viewer, composer, navigation rail, sidebar, and context menu - Extend theme store with custom theme installation and activation Admin Dashboard: - Add admin authentication with scrypt password hashing and AES-256-GCM sessions - Add rate-limited login (5 attempts/15min per IP) - Add config manager with admin override > env var > default priority - Add settings policy system with feature gates and per-setting restrictions - Add audit logging with rotation - Add admin API routes (login, logout, config, policy, audit, password change) - Add admin UI pages (login, dashboard, config, policy, audit) - Add policy store for client-side feature gate enforcement - Wire admin password initialization into server instrumentation Tests: - Add 139 tests across 10 test files covering all plugin/theme modules
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { readFileSync } from "fs";
|
|
import { configManager } from "./lib/admin/config-manager";
|
|
import { initAdminPassword } from "./lib/admin/password";
|
|
|
|
const VERSION_CHECK_URL =
|
|
"https://raw.githubusercontent.com/bulwarkmail/webmail/main/VERSION";
|
|
|
|
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
|
|
function compareVersions(current: string, remote: string): number {
|
|
const a = current.split(".").map(Number);
|
|
const b = remote.split(".").map(Number);
|
|
for (let i = 0; i < 3; i++) {
|
|
if ((b[i] ?? 0) > (a[i] ?? 0)) return 1;
|
|
if ((b[i] ?? 0) < (a[i] ?? 0)) return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
const pkg = JSON.parse(
|
|
readFileSync(`${process.cwd()}/package.json`, "utf-8")
|
|
);
|
|
const current: string = pkg.version ?? "0.0.0";
|
|
console.info(`Bulwark Webmail v${current}`);
|
|
|
|
if (process.env.NODE_ENV === "production") {
|
|
fetch(VERSION_CHECK_URL, {
|
|
cache: "no-store",
|
|
signal: AbortSignal.timeout(5000),
|
|
})
|
|
.then((res) => {
|
|
if (!res.ok) return;
|
|
return res.text();
|
|
})
|
|
.then((text) => {
|
|
if (!text) return;
|
|
const remote = text.trim();
|
|
if (!SEMVER_RE.test(remote)) return;
|
|
if (compareVersions(current, remote) > 0) {
|
|
console.info(
|
|
`Update available: v${remote} — https://github.com/bulwarkmail/webmail`
|
|
);
|
|
}
|
|
})
|
|
.catch(() => {});
|
|
}
|
|
|
|
// Initialize admin config and password bootstrap
|
|
configManager.load()
|
|
.then(() => initAdminPassword())
|
|
.then(() => {
|
|
console.info("Admin dashboard initialized");
|
|
})
|
|
.catch((err) => {
|
|
console.warn("Admin dashboard init skipped:", err instanceof Error ? err.message : err);
|
|
});
|