feat(dashboard): unify secure staff administration

Provide a single /dashboard entry point for owner and staff tools, with Discord OAuth sign-in for approved owner accounts and active staff. Add owner-managed dashboard access grants, staff server health and update visibility, filtering, moderation improvements, item controls, and per-animal clothing restrictions.

Replace staff-triggered password and 2FA resets with email-verified account recovery. Persist validated recovery addresses, use short-lived hashed recovery tokens, expose recovery flows in registration and account pages, and keep mail delivery disabled until its webhook configuration is present.

Cover dashboard aliases, recovery restrictions, Discord access, monitoring, item locks, wear rules, and staff behavior with regression tests.
This commit is contained in:
Snipzil committed 2026-10-19 10:09:35 -04:00
1 parent 4997315239
commit 7dee29010a
27 files changed
+2303 -346

No files matched your search

+43 -2
View File
@@ -8,6 +8,7 @@ const config = require("../config.js");
const sales = require("./sales.js");
const badges = require("./badges.js");
const extraMusic = require("./extramusic.js");
const wearRules = require("./wearrules.js");
// defPack ids, from loader.DefPacksDefHelper in the client.
const DEF_ITEM = 1000;
@@ -42,6 +43,7 @@ const DEF_PET_TOY = 1063;
const DEF_WORLD_ITEMS = 1064;
const DEF_NPC = 1025;
const DEF_NAMEBAR_BADGE = 1049;
const DEF_EMOTICON = 1036;
const OFFERED_SPECIAL_TYPES = ["0", "4"]; // den items: plain, mannequin
const DEN_ITEM_MASTERPIECE = 2725;
@@ -70,6 +72,32 @@ const LAYER_EYES = "3";
const TYPE_CLOTHING = "1";
const EVERY_AVATAR = "9007199254740991"; // avatarUseFlags with a bit set for each animal type
// ItemXtCommManager checks bit (avatar type - 1). BigInt avoids losing a
// bit in JavaScript's 53-bit Number representation while preserving the
// string form the AMF def pack uses.
const clientAvatarUseFlags = itemId => {
let flags = BigInt(EVERY_AVATAR);
for (const type of wearRules.blockedTypes(itemId)) {
if (type <= 53) {
flags &= ~(1n << BigInt(type - 1));
}
}
return String(flags);
};
// One transform is used for fetched packs and for the live `xdi` definition
// updates sent to games that are already running.
const clientItemRow = def => {
const row = {...def};
if (row.type === TYPE_CLOTHING) {
row.avatarUseFlags = clientAvatarUseFlags(row.id);
}
else if (row.type === "0" && row.layerId === LAYER_EYES) {
row.avatarUseFlags = EVERY_AVATAR;
}
return row;
};
// rooms the official room pack no longer lists but whose files an older
// build on the CDN still has (lib/cdn.js looks there): the Summer Carnival,
// dropped after build 1828.
@@ -317,9 +345,9 @@ const alwaysOnSale = (pack, ids) => {
// the rows put back or added (SHARED_CHANGES).
const CLIENT_PACKS = new Map([
[DEF_ITEM, pack => {
for (const def of Object.values(pack)) {
for (const [key, def] of Object.entries(pack)) {
if (def.type === TYPE_CLOTHING || (def.type === "0" && def.layerId === LAYER_EYES)) {
def.avatarUseFlags = EVERY_AVATAR;
pack[key] = clientItemRow(def);
}
}
sales.stamp("clothing", pack);
@@ -397,6 +425,9 @@ let musicIds = []; // den items that are music tracks
let roomDefsById = new Map();
let badgeIds = []; // name tag badges, ascending
let npcDefs = new Map(); // the characters of the adventures, see lib/disguises.js
// An avatar attachment is named by its emoticon definition id on the wire,
// while AvatarWorldView needs the media id stored by that definition.
let emoticonMediaIds = new Map();
// A pack whose feature can be done without: missing (offline and never
// cached) just leaves that feature empty.
@@ -463,6 +494,7 @@ const init = async () => {
petFoodDefs = await loadOptional(DEF_PET_FOOD);
petToyDefs = await loadOptional(DEF_PET_TOY);
npcDefs = new Map((await loadOptional(DEF_NPC)).map(def => [Number(def.id), def]));
emoticonMediaIds = new Map((await loadOptional(DEF_EMOTICON)).map(def => [Number(def.id), Number(def.mediaRef)]));
partyDefs = new Map((await loadOptional(DEF_PARTY)).map(def => {
const room = roomPathsById.get(Number(def.roomDefId));
return [Number(def.id), {
@@ -544,6 +576,14 @@ module.exports = {
denItemDef: id => denItemDefs.get(Number(id)),
denItemIds: () => denItemIds,
clientPack,
// A changing rule must not leave the cached item pack permissive. The next
// client request remakes it, and current games receive an xdi row too.
invalidateClientItemPack: () => clientPackBodies.delete(DEF_ITEM),
clientItemRow,
clientItemDef: id => {
const def = itemDefs.get(Number(id));
return def ? clientItemRow(def) : null;
},
string: id => (Object.hasOwn(strings, id) ? String(strings[id]) : ""),
stringId: text => {
if (!stringIds) {
@@ -558,6 +598,7 @@ module.exports = {
},
badgeIds: () => badgeIds,
npcDef: id => npcDefs.get(Number(id)),
emoticonMediaId: id => emoticonMediaIds.get(Number(id)) || 0,
oddDenItemIds: () => oddDenItemIds,
// den items that exist to be given by id and are in no shop.
unsoldDenItemIds: () => extraMusic.ids,