support for 202507 endpoints (#37)

* [auth][api] accept the 20250424.01 client

Version check now answers "current" for a set of builds rather than one:
SUPPORTED_GAME_VERSIONS carries 20230414 and 20250424.01. GAME_VERSION is
unchanged and still what the server reports for itself (presence, rn.ver).

Adds GET /api/versioncheck/islandedversions, always [] — we never island a
build off into its own matchmaking pool.

The 2025 build POSTs /cachedlogin/forplatformid/:platform/:id with a
deviceId/platformAuth/time form body where the 2023 build GETs it, so that
route now takes both methods. The body is accepted and ignored for now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* [2025] unstable

* 20250718.0

* correct one this time

* stubs

* more stubs

* more stubs

* [lists] add worker

* [ai] route stubs

* [api] player photo setting

* [econ] add roomEconConfig route

* [infra] update worker generators

* [worker] add cards/moderation/platformnotification workers

* [lists] updates to some endpoints

* [clubs] stub out announcement endpoint, for now

* [econ] stub out season endpoints for now

* [chat] apps/chat stub out party endpoint not sure the shape yet

* [api] stub out statsig and lockeditems

* [doc] new services

* [lists] stub the bulk endpoint

* [datacollection] add placeholder service until we can kill it

* [api] set gifting to lvl5

* update lock

* [cdn] enable cache

* [match] matchmake v2

* [lists] stub some lists

* [ai] stubs

* [rooms] new subroom save endpoint

* [econ] add bulk purchase endpoint

* [discovery] update featured creator to 1 for fun

* [api] add photo settings flag

* [chat] fixup chat permissions (sorta)

* [auth] restrictions endpoint

* [rooms] contributed endpoint

* [api] fix outfit endpoint

* [discovery] attempt to fix store

* [chat] privacy endpoints

* [api] cheered images

* [rooms] add xp endpoint (disbaled)

* [rooms] add xp endpoint (disabled)

* update images-db for cheers

* [rooms] add autocomplete endpoint

* [cdn/img] increase cache ttl for statics

* [api] bulk route for images

* [accounts] add banner image

* [api] add misc missing endpoints

* [discovery] remove AI tab

* [platformnotifications] stub some endpoints

* [lists] add some more lists

* [rooms] additional endpoints

* [chat] stub a few privacy endpoints

* [econ] stub some endpoints

* misc db fixes

* [api] tweak shape for images v6

* [rooms] dont show trending RROs

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
devin
2026-08-18 23:07:24 -04:00
committed by GitHub
parent 66c09806f9
commit 34171417e3
162 changed files with 114930 additions and 469 deletions
+107 -5
View File
@@ -1,5 +1,5 @@
import { Hono } from 'hono'
import { describeRoute, openAPIRouteHandler } from 'hono-openapi'
import { describeRoute, openAPIRouteHandler, resolver } from 'hono-openapi'
import { useWorkersLogger } from 'workers-tagged-logger'
import {
@@ -15,6 +15,7 @@ import {
assetResponses,
CONDITIONAL_HEADERS,
json,
JsonValue,
keyParam,
LoadingScreenTip,
ServiceStatus,
@@ -71,7 +72,7 @@ async function serveAsset(c: Context<App>, key: string) {
headers.set('etag', object.httpEtag)
headers.set('content-type', 'application/octet-stream')
headers.set('accept-ranges', 'bytes')
headers.set('cache-control', 'public, max-age=3600')
headers.set('cache-control', CACHE_CONTROL)
// Precondition matched (If-None-Match) → R2 returns no body.
if (!('body' in object)) return new Response(null, { status: 304, headers })
@@ -88,6 +89,64 @@ async function serveAsset(c: Context<App>, key: string) {
return new Response(object.body, { headers })
}
/**
* Cache-Control on every file this worker serves — 30 days (86400 × 30). These are big,
* rarely-changing blobs fetched by key: a room scene, an invention, a signature blob. The
* keys are content-addressed or date-foldered UUIDs, so a changed asset arrives under a
* NEW key rather than replacing one that is already cached.
*
* Not `immutable`, unlike `img`: the same rule covers `/config/`, whose files ARE
* republished under their existing names, and telling a browser never to revalidate those
* would pin a stale config for the whole window.
*/
const CACHE_CONTROL = `public, max-age=${86400 * 30}`
/**
* What may reach the ASSETS binding as a config filename: one path segment, no slashes,
* and `..` rejected outright below. A traversal is then a 404 from this worker rather than
* a request the asset server has to be trusted to refuse.
*/
const CONFIG_NAME = /^[A-Za-z0-9._-]+$/
/**
* Serve a file from `static/config/` through the ASSETS binding, by its own filename —
* whatever is in that directory, not just the JSON (a config may be an opaque binary blob
* named by GUID). `null` when nothing is published under that name.
*
* A name carrying no extension also resolves against `<name>.json`, because the same file
* is asked for both ways: the game configs that point at these carry the extension
* (`Econ.MakerAI.DayPass.Config` is `"SkuConfig_v1.json"`) while the client's older config
* calls leave it off. The exact name is tried first, so an extension-less FILE always wins
* over the `.json` guess.
*
* The asset response is handed back whole rather than parsed and re-serialized: it already
* carries a content type and an etag (so `If-None-Match` gets its 304 for free), and these
* files go out BYTE-FOR-BYTE — `RRPlusConfig_v3.json` opens with a UTF-8 BOM, which is what
* the real CDN served and what the client's parser expects.
*/
async function serveConfig(c: Context<App>, name: string): Promise<Response | null> {
if (!CONFIG_NAME.test(name) || name.includes('..')) return null
const candidates = name.includes('.') ? [name] : [name, `${name}.json`]
for (const candidate of candidates) {
// Forwarding the original request keeps its conditional headers; only the URL is
// rewritten to the asset's path.
const res = await c.env.ASSETS.fetch(
new Request(new URL(`/config/${candidate}`, c.req.url), c.req.raw)
)
// Rebuilt rather than returned as-is, only to stamp our own Cache-Control over the
// asset server's: everything else — the body, the status, the content type, the etag
// a conditional GET matched on — is carried across untouched. A 304 has no body to
// carry, and `Response` refuses one for that status.
if (res.ok || res.status === 304) {
const headers = new Headers(res.headers)
headers.set('cache-control', CACHE_CONTROL)
return new Response(res.status === 304 ? null : res.body, { status: res.status, headers })
}
}
return null
}
const app = new Hono<App>()
.use(
'*',
@@ -137,7 +196,50 @@ const app = new Hono<App>()
].join(' '),
responses: { 200: json(LoadingScreenTip.array(), 'The bundled tips') },
}),
(c) => c.json(loadingScreenTipData)
(c) => c.json(loadingScreenTipData, 200, { 'Cache-Control': CACHE_CONTROL })
)
// Everything else under `/config/`, served from `static/config/` by filename — JSON and
// opaque blobs alike. Declared AFTER the tip-data route above, which would otherwise be
// shadowed by this one: its file is named differently from its path, so it stays a
// route of its own.
.get(
'/config/:name',
describeRoute({
tags: ['Config'],
summary: 'Serve a config file',
description: [
'Serves a file out of `static/config/` verbatim — `RRPlusConfig_v3.json` (the Rec Room',
'Plus benefit lists), `SkuConfig_v1.json` (the Maker AI day-pass store copy) and a',
'GUID-named binary blob today. `{name}` IS the filename, so publishing a config is',
'dropping a file in that directory; nothing in the worker enumerates them, and not',
'everything there is JSON.',
'',
'A name with no extension also resolves against `<name>.json`, because the same file',
'is asked for both ways — the game configs that point at these carry the extension',
'(`Econ.MakerAI.DayPass.Config` is `"SkuConfig_v1.json"`), the clients older config',
'calls leave it off. An extension-less file wins over the `.json` guess.',
'',
'These are byte-for-byte copies of what the real CDN served, BOM included, and are',
'not rewritten or re-serialized on the way out.',
].join(' '),
parameters: [
keyParam('name', 'The configs filename. The `.json` may be left off.', false),
...CONDITIONAL_HEADERS.filter((h) => h.name === 'If-None-Match'),
],
responses: {
200: {
description: 'The config file, as stored',
content: {
'application/json': { schema: resolver(JsonValue) },
'application/octet-stream': { schema: { type: 'string', format: 'binary' } },
},
},
304: { description: '`If-None-Match` matched the files etag (no body)' },
404: { description: 'No config is published under that name' },
},
}),
async (c) => (await serveConfig(c, c.req.param('name'))) ?? c.notFound()
)
// Signature blobs by name. Streamed from R2 under the `sigs/` key prefix;
@@ -242,8 +344,8 @@ app.get(
'Binary asset delivery for recflare, a private-server reimplementation of the Rec',
'Room backend. Streams the blobs the client downloads while playing — anti-cheat',
'signatures, saved room scenes, invention data and generic client uploads — out of',
'the shared `recflare-cdn` R2 bucket, plus the one bundled config file the loading',
'screen reads.',
'the shared `recflare-cdn` R2 bucket, plus the JSON config files the client reads',
'from `/config/`.',
'',
'Everything is keyed by prefix (`sigs/`, `room/`, `invention/`, `data/`) and served as',
'`application/octet-stream`; the worker never interprets what it hands back. Reads',
+5
View File
@@ -9,6 +9,11 @@ export type Env = SharedHonoEnv & {
// R2 bucket holding CDN binaries: signature blobs under `sigs/<name>` and
// room build data under `room/<name>`.
CDN_ASSETS: R2Bucket
// Static-asset fetcher for the JSON configs in `static/config/` (see wrangler.jsonc
// `assets`). Fetched by filename so `/config/:name` serves whatever is published;
// the binding is the only way in, since `run_worker_first` keeps the runtime from
// serving the files directly.
ASSETS: Fetcher
}
/** Variables can be extended */
+7
View File
@@ -86,6 +86,13 @@ export function keyParam(
// ---- Response schemas ------------------------------------------------------
/**
* An opaque JSON document — the config files under `static/config/` are served verbatim
* and nothing here interprets them, so modelling their fields would be noise that goes
* stale the moment a file is replaced.
*/
export const JsonValue = z.record(z.string(), z.unknown())
/** `GET /` — the liveness probe body. */
export const ServiceStatus = z.object({
service: z.literal('cdn'),
+104
View File
@@ -28,6 +28,75 @@ describe('cdn endpoints', () => {
expect(body[0]).toHaveProperty('Title')
})
// The config directory is served by filename through the ASSETS binding, so a file
// dropped into `static/config/` is reachable without touching the worker.
test.each(['RRPlusConfig_v3', 'SkuConfig_v1'])(
'GET /config/%s serves the file from static/config',
async (name) => {
const res = await exports.default.fetch(`${ORIGIN}/config/${name}`)
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('application/json')
expect((await res.text()).length).toBeGreaterThan(0)
}
)
// Not everything in the directory is JSON: a config may be an opaque blob named by
// GUID, which is served as-is under its own name.
test('GET /config/:name serves an extension-less binary config', async () => {
const res = await exports.default.fetch(`${ORIGIN}/config/1b057e6e-979d-4f30-8856-a386f77c90da`)
expect(res.status).toBe(200)
expect((await res.arrayBuffer()).byteLength).toBeGreaterThan(0)
})
// The game configs name these files WITH the extension (`Econ.MakerAI.DayPass.Config`
// is `"SkuConfig_v1.json"`), so both spellings have to land on the same file.
test('GET /config/:name accepts the .json suffix', async () => {
const bare = await exports.default.fetch(`${ORIGIN}/config/SkuConfig_v1`)
const suffixed = await exports.default.fetch(`${ORIGIN}/config/SkuConfig_v1.json`)
expect(suffixed.status).toBe(200)
expect(await suffixed.text()).toBe(await bare.text())
})
// Byte-for-byte: RRPlusConfig_v3.json opens with a UTF-8 BOM, as the real CDN served
// it. Re-serializing the file (or parsing and re-emitting it) would strip those bytes.
test('GET /config/RRPlusConfig_v3 keeps the files bytes, BOM included', async () => {
const res = await exports.default.fetch(`${ORIGIN}/config/RRPlusConfig_v3`)
const bytes = new Uint8Array(await res.arrayBuffer())
expect(Array.from(bytes.slice(0, 3))).toEqual([0xef, 0xbb, 0xbf])
// `text()` decodes the BOM away, so the remainder still parses as the config.
expect(JSON.parse(new TextDecoder().decode(bytes))).toHaveProperty('BenefitLists')
})
test('GET /config/:name 404s a config that is not published', async () => {
const res = await exports.default.fetch(`${ORIGIN}/config/NoSuchConfig`)
expect(res.status).toBe(404)
})
// The name reaches the binding as a filename, so anything that could climb out of
// `static/config/` is refused before it gets there. (A bare `..` never arrives: the
// URL is normalized to `/` before routing, which is the liveness probe.)
test.each(['%2e%2e%2floading-screen-tip-data.json', 'sub%2Fdir', '.hidden', 'Sku.Config'])(
'GET /config/%s 404s rather than reaching the asset server',
async (name) => {
const res = await exports.default.fetch(`${ORIGIN}/config/${name}`)
expect(res.status).toBe(404)
}
)
// `run_worker_first` keeps the asset server from answering ahead of the Worker: the
// tip data is an asset too (`static/loading-screen-tip-data.json`), and it must stay
// unreachable at that path — its route is `/config/LoadingScreenTipData`.
test('assets are not served at their own paths', async () => {
const res = await exports.default.fetch(`${ORIGIN}/loading-screen-tip-data.json`)
expect(res.status).toBe(404)
})
test('GET /config/LoadingScreenTipData still wins over the wildcard', async () => {
const res = await exports.default.fetch(`${ORIGIN}/config/LoadingScreenTipData`)
expect(res.status).toBe(200)
expect(Array.isArray(await res.json())).toBe(true)
})
test('GET /sigs/:sigName 404s when the blob is absent', async () => {
const res = await exports.default.fetch(`${ORIGIN}/sigs/does-not-exist`)
expect(res.status).toBe(404)
@@ -41,6 +110,40 @@ describe('cdn endpoints', () => {
expect(new Uint8Array(await res.arrayBuffer())).toEqual(new Uint8Array([1, 2, 3, 4]))
})
// Every file this worker hands back carries the same 30-day Cache-Control — the R2
// blobs, the configs served through the ASSETS binding, and the bundled tip data.
test('every served file carries the 30-day Cache-Control', async () => {
const CACHE_CONTROL = `public, max-age=${86400 * 30}`
await env.CDN_ASSETS.put('room/2026-02-03/cached', new Uint8Array([1, 2, 3]))
for (const path of [
'/room/2026-02-03/cached',
'/config/RRPlusConfig_v3.json',
'/config/LoadingScreenTipData',
]) {
const res = await exports.default.fetch(`${ORIGIN}${path}`)
expect(res.status, path).toBe(200)
expect(res.headers.get('cache-control'), path).toBe(CACHE_CONTROL)
}
// A ranged read is still a served file, and a 304 has to carry it too — otherwise a
// revalidation would answer "no change" with no instruction on how long that holds.
const ranged = await exports.default.fetch(`${ORIGIN}/room/2026-02-03/cached`, {
headers: { Range: 'bytes=0-1' },
})
expect(ranged.status).toBe(206)
expect(ranged.headers.get('cache-control')).toBe(CACHE_CONTROL)
const etag = (await exports.default.fetch(`${ORIGIN}/room/2026-02-03/cached`)).headers.get(
'etag'
)
const revalidated = await exports.default.fetch(`${ORIGIN}/room/2026-02-03/cached`, {
headers: { 'If-None-Match': etag ?? '' },
})
expect(revalidated.status).toBe(304)
expect(revalidated.headers.get('cache-control')).toBe(CACHE_CONTROL)
})
test('GET /sigs/:sigName honors a Range request with 206', async () => {
await env.CDN_ASSETS.put('sigs/ranged', new Uint8Array([10, 11, 12, 13, 14, 15]))
const res = await exports.default.fetch(`${ORIGIN}/sigs/ranged`, {
@@ -191,6 +294,7 @@ describe('cdn endpoints', () => {
expect([...documented].sort()).toEqual([
'GET /',
'GET /config/LoadingScreenTipData',
'GET /config/{name}',
'GET /data/{id}',
'GET /invention/{dataBlob}',
'GET /room/{dataBlob}',