mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
feat(server): staff tools, player-made items, picture safety, chat, multiplayer games
Staff and moderation
- Invisible staff (!invisible, "xiv"): hidden from players, half see-through
to other staff, cannot chat while hidden. New permission staff.invisible.
- Summon and goto land on the player's exact spot ("xgt" before the move).
- Custom warnings (!warn PLAYER custom TEXT), shown in the warning popup.
- Mod notes (!note, !notes; lib/modnotes.js), on the player page and the
dashboard.
- Granular permissions: per-role overrides (setting rolePermissions) and
per-account grants and denies, applied live to staff who are playing
(refreshStaff re-sends "xsp").
- Item control (lib/itemcontrol.js): lock items out of the item finder
(!lock, !unlock, !locked), take an item from a player (!take), delete a
custom item from the game and every inventory.
- GET items/find: search any item by name or id, marked locked, for the
dashboards' quick lock.
Player-made items (lib/playeritems.js, "xcm")
- The Item Maker: make, rename, set the worn look, delete. 5 a day, 20 in all;
names go through the name filter.
- Admin switches: Item Maker on/off, new items wait for approval, and a
separate switch (on by default) that holds every player-uploaded picture
for a moderator. Review queue for items.approve (moderator and up).
- Pictures (lib/itemart.js): PNG, JPEG and GIF cleaned of metadata, BMP
converted to PNG; 512px and 300KB at most once cleaned.
- Worn as the maker chooses: a sticker (the picture) or a texture (the
item's shape painted with the picture).
Picture safety
- A picture waiting for approval is never served publicly: /itemart/ 404s it,
and it is only shown through /account|/mod|/admin/api/itemart to its maker
and to staff who review or make items.
- A picture turned away or taken off is remembered by SHA-256 and cannot be
uploaded again.
- Three strikes: three pictures turned away stops a player's uploads until a
moderator lets them again. Staff can stop or allow uploads by hand.
- Accounts under 24 hours old cannot upload pictures (AJ_ITEM_ART_MIN_HOURS);
uploads capped at 10 a day.
- Optional Google Cloud Vision SafeSearch (lib/image-moderation.js) for item
pictures and Art Studio paintings when AJ_GOOGLE_VISION_API_KEY is set;
fails closed when the scanner is unreachable.
Chat
- Emoji: Twemoji pictures served at /emoji/<codepoints>.png and cached in
data/emoji (lib/emoji.js).
- Smart spam filtering before the word filter (lib/chatspam.js): long runs of
one character, repeated words and lines, huge words and emoji floods are
tidied, and repeats within 20 seconds are dropped.
- Typing indicator: "xty" is passed on to everyone in the room who can see
the player, at most every 2 seconds.
Games (lib/minigames.js)
- Room games can be played together: a MULTIPLAYER table gives a game a
waiting list (Single Player / Multiplayer). Players in the same room are
matched, taken into the game together, and each one's moves are relayed to
the others. Gem Breaker is the first: two players, "pos", "shoot" and
"playerLost" relayed.
- Gem Breaker's start message now lists each player's id. Without it no
player counted as local, so even single player could not aim.
Other
- Players stay connected through the client's new 75-minute AFK limit
(idleTimeoutMs 80 minutes).
- Jam-a-Grams carry custom items and colours; Jammer Wall avatar photos are
validated (walls.js photoParam).
- Weak passwords refused (common words, or containing the username).
- Code-scanning fixes: every logged value goes through logText
(lib/logtext.js) against log injection, HSTS, path-only error logs, a
single file read in lib/names.js.
Tests: items (pictures, approval, strikes, re-upload refusal, the hidden
waiting picture, the dashboard search), staff (invisibility, goto and summon
spots, custom warnings, notes), buddygames (two-player Gem Breaker, the
typing relay), and updates for main's verified badge and spawn rooms.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da7eb9af58
commit
e05565787f
50 files changed
+2904
-277
No files matched your search
+28
-24
@@ -28,29 +28,29 @@ const run = async () => {
|
||||
// --- registration: the web form's API, and no accounts made by logging in
|
||||
assert.match(await (await fetch(`${BASE}/register`)).text(), /Create an account/);
|
||||
const registerJson = body => fetch(`${BASE}/api/register`, {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({avatarType: 1, agreed: true, ...body})});
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01"})).status, 401);
|
||||
assert.strictEqual((await registerJson({username: "Alice", password: "Password01"})).status, 200);
|
||||
assert.deepStrictEqual(await (await registerJson({username: "alice", password: "Password01"})).json(), {error: "username_taken"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "a!", password: "Password01"})).json(), {error: "invalid_username"});
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01"})).status, 401);
|
||||
assert.strictEqual((await registerJson({username: "Alice", password: "KettlePass01"})).status, 200);
|
||||
assert.deepStrictEqual(await (await registerJson({username: "alice", password: "KettlePass01"})).json(), {error: "username_taken"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "a!", password: "KettlePass01"})).json(), {error: "invalid_username"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Shorty", password: "pw"})).json(), {error: "invalid_password"});
|
||||
// no default animal: whoever signs up picks one of the nine on the page.
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: undefined})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "Password01", avatarType: 2})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "KettlePass01", avatarType: undefined})).json(), {error: "choose_animal"});
|
||||
assert.deepStrictEqual(await (await registerJson({username: "Noanimal", password: "KettlePass01", avatarType: 2})).json(), {error: "choose_animal"});
|
||||
assert.match(await (await fetch(`${BASE}/register`)).text(), /Choose an animal/);
|
||||
assert.strictEqual((await fetch(`${BASE}/signup/thumb_wolf.svg`)).headers.get("content-type"), "image/svg+xml");
|
||||
assert.strictEqual((await fetch(`${BASE}/signup/..%2Faccount.html`)).status, 404);
|
||||
for (const [username, password] of [["Bob", "Password02"], ["Carol", "Password03"], ["foo", "Password04"]]) {
|
||||
for (const [username, password] of [["Bob", "KettlePass02"], ["Carol", "KettlePass03"], ["foo", "KettlePass04"]]) {
|
||||
assert.strictEqual((await registerJson({username, password})).status, 200);
|
||||
}
|
||||
|
||||
let res = await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", domain: "flash", df: "x"});
|
||||
let res = await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01", domain: "flash", df: "x"});
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.headers.get("access-control-allow-origin"), "null");
|
||||
const alice = await res.json();
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "alice", password: "wrong"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "constructor", password: "Password01"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "constructor", password: "KettlePass01"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: alice.refresh_token})).status, 200);
|
||||
const bob = await (await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).json();
|
||||
const bob = await (await postJson(`${BASE}/authenticate`, {username: "Bob", password: "KettlePass02"})).json();
|
||||
|
||||
res = await fetch(`${BASE}/player?domain=flash&client_version=1830`, {headers: {Authorization: `Bearer ${alice.auth_token}`}});
|
||||
assert.strictEqual((await res.json()).screen_name, "Alice");
|
||||
@@ -83,11 +83,11 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await guest.nextXt("la")).slice(2), ["1"]);
|
||||
const iv = crypto.randomBytes(16);
|
||||
const cipher = crypto.createCipheriv("aes-256-cbc", crypto.createHash("sha256").update(guestKey).digest(), iv);
|
||||
const encrypted = Buffer.concat([iv, cipher.update("DavePass01"), cipher.final()]).toString("base64");
|
||||
const encrypted = Buffer.concat([iv, cipher.update("TulipKettle01"), cipher.final()]).toString("base64");
|
||||
guest.xt("lc", 1, "Dave", encrypted, "2000-01-01", 0, "", 15136, 15224, 15299, 4, 0, "US", 1830);
|
||||
assert.deepStrictEqual((await guest.nextXt("lc")).slice(2, 3), ["1"]);
|
||||
guest.socket.destroy();
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Dave", password: "TulipKettle01"})).status, 200);
|
||||
|
||||
// --- first player: login and world entry
|
||||
const a = new GameClient();
|
||||
@@ -158,6 +158,10 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await b.nextXt("uc")).slice(1), [roomId, String(bobId), "hi & bye", "0"]);
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[7%2]]></txt></body></msg>`); // emote: not echoed
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(3), ["7", "2"]);
|
||||
// Actions are sent to every other player in the room. The sender has
|
||||
// already applied the action locally, so it is not echoed back to them.
|
||||
b.send(`<msg t='sys'><body action='pubMsg' r='${roomId}'><txt><![CDATA[:sitS:%3%m1]]></txt></body></msg>`);
|
||||
assert.deepStrictEqual((await a.nextXt("uc")).slice(3), [":sitS:", "3", "m1"]);
|
||||
|
||||
// --- player cards
|
||||
a.xt("ag", roomId, "bob", 1);
|
||||
@@ -234,7 +238,7 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await a.nextXt("ds")).slice(2), ["0", "0", "1"]);
|
||||
|
||||
// --- shops, clothing, animals and pets (Carol watches from the same den)
|
||||
const carol = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "Password03"})).json();
|
||||
const carol = await (await postJson(`${BASE}/authenticate`, {username: "Carol", password: "KettlePass03"})).json();
|
||||
const c = new GameClient();
|
||||
await c.connect();
|
||||
await c.logIn("Carol", carol.auth_token);
|
||||
@@ -394,7 +398,7 @@ const run = async () => {
|
||||
{
|
||||
const stranger = new GameClient();
|
||||
await stranger.connect();
|
||||
await stranger.logIn("Dave", (await (await postJson(`${BASE}/authenticate`, {username: "Dave", password: "DavePass01"})).json()).auth_token);
|
||||
await stranger.logIn("Dave", (await (await postJson(`${BASE}/authenticate`, {username: "Dave", password: "TulipKettle01"})).json()).auth_token);
|
||||
stranger.xt("dj", 1, "denAlice", 1, -1);
|
||||
assert.strictEqual((await stranger.nextXt("rj"))[2], "0");
|
||||
stranger.socket.destroy();
|
||||
@@ -429,7 +433,7 @@ const run = async () => {
|
||||
assert.deepStrictEqual((await a.nextXt("di")).slice(3, 4), ["1"]);
|
||||
|
||||
// --- no game account has admin powers: "foo" is an ordinary player now
|
||||
const foo = await (await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).json();
|
||||
const foo = await (await postJson(`${BASE}/authenticate`, {username: "foo", password: "KettlePass04"})).json();
|
||||
const f = new GameClient();
|
||||
await f.connect();
|
||||
const fooLogin = await f.logIn("foo", foo.auth_token);
|
||||
@@ -521,14 +525,14 @@ const run = async () => {
|
||||
// names sign-up would refuse are fine from the panel, and can log in.
|
||||
for (const odd of ["x", "~*Bob*~ <3", "Ünïcødé 名前", "a name well past twenty characters"]) {
|
||||
assert.strictEqual((await panel("account", {username: "Bob", action: "rename", newName: odd}, admin)).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: odd, password: "Password02"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: odd, password: "KettlePass02"})).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: odd, action: "rename", newName: "Bob"}, admin)).status, 200);
|
||||
}
|
||||
assert.strictEqual((await registerJson({username: "x", password: "Password09"})).status, 400); // sign-up rules unchanged
|
||||
assert.strictEqual((await registerJson({username: "x", password: "KettlePass09"})).status, 400); // sign-up rules unchanged
|
||||
const renamed = await panel("account", {username: "Bob", action: "rename", newName: "Robert"}, admin);
|
||||
assert.deepStrictEqual([renamed.status, renamed.data.username], [200, "Robert"]);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Bob", password: "Password02"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "robert", password: "Password02"})).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "Bob", password: "KettlePass02"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "robert", password: "KettlePass02"})).status, 200);
|
||||
assert.ok(!(await panel("accounts", undefined, admin)).data.accounts.some(account => account.username === "Bob"));
|
||||
assert.strictEqual((await panel("account", {username: "Robert", action: "rename", newName: "ROBERT"}, admin)).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: "robert", action: "rename", newName: "Bob"}, admin)).status, 200);
|
||||
@@ -536,7 +540,7 @@ const run = async () => {
|
||||
// A new password for a player: the old one and old tokens stop working.
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "short"}, admin)).status, 400);
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "password", password: "New-password-4"}, admin)).status, 200);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "Password04"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "KettlePass04"})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {refresh_token: foo.refresh_token})).status, 401);
|
||||
assert.strictEqual((await postJson(`${BASE}/authenticate`, {username: "foo", password: "New-password-4"})).status, 200);
|
||||
assert.strictEqual((await panel("account", {username: "foo", action: "delete"}, admin)).status, 200);
|
||||
@@ -624,13 +628,13 @@ const run = async () => {
|
||||
assert.strictEqual((await (await fetch(`${BASE}/flashvars`)).json()).loginChoices, true);
|
||||
// (a fresh account: Carol is banned by now, and a banned account's
|
||||
// sign-in is refused with "account_banned", so it gets no token.)
|
||||
assert.strictEqual((await registerJson({username: "Erin", password: "Password05"})).status, 200);
|
||||
const chosen = await (await postJson(`${BASE}/authenticate`, {username: "Erin", password: "Password05",
|
||||
assert.strictEqual((await registerJson({username: "Erin", password: "KettlePass05"})).status, 200);
|
||||
const chosen = await (await postJson(`${BASE}/authenticate`, {username: "Erin", password: "KettlePass05",
|
||||
login_choices: {accountType: 0, isGuide: true, membershipDays: 12, isModerator: "yes"}})).json();
|
||||
assert.strictEqual((await (await fetch(`${BASE}/player`, {headers: {Authorization: `Bearer ${chosen.auth_token}`}})).json()).game_account_type, 0);
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["0", "1"]); // account type, guide
|
||||
await postJson(`${BASE}/authenticate`, {username: "Erin", password: "Password05"}); // and back to normal
|
||||
await postJson(`${BASE}/authenticate`, {username: "Erin", password: "KettlePass05"}); // and back to normal
|
||||
a.xt("ag", denId, "Erin", 0);
|
||||
assert.deepStrictEqual((await a.untilXt("ag")).slice(5, 7), ["2", "0"]);
|
||||
|
||||
@@ -645,7 +649,7 @@ const run = async () => {
|
||||
assert.strictEqual((await a.untilXt("ap"))[2], "1");
|
||||
const late = new GameClient();
|
||||
await late.connect();
|
||||
const dev = await (await postJson(`${BASE}/authenticate`, {username: "Alice", password: "Password01", login_choices: {accountType: 4, membershipDays: 7}})).json();
|
||||
const dev = await (await postJson(`${BASE}/authenticate`, {username: "Alice", password: "KettlePass01", login_choices: {accountType: 4, membershipDays: 7}})).json();
|
||||
const devLogin = await late.logIn("Alice", dev.auth_token);
|
||||
assert.deepStrictEqual([devLogin.params.accountType, devLogin.params.numDaysLeftOnSubscription, devLogin.params.isGuide, devLogin.params.isModerator], [4, 7, false, false]);
|
||||
assert.deepStrictEqual((await late.untilXt("xcc")).slice(2, 4), ["1", String(0xFD000000)]); // the table at login
|
||||
|
||||
Reference in new issue
Block a user