Build verified checkpoint containers for TrueNAS

This commit is contained in:
Quintine committed 2026-09-21 17:48:25 +10:00
1 parent c5508b727a
commit 64e8299aeb
27 files changed
+536 -16

No files matched your search

+4 -3
View File
@@ -1,3 +1,4 @@
import { requestOrigin } from '@/lib/request-origin';
import {
authenticate,
createSeatHandover,
@@ -14,12 +15,12 @@ import {
import { RuleError } from '@/game/engine';
import { validSeatAiDelegateRequest } from '@/lib/seat-ai-delegation';
import { resumeRoom } from '@/db/room-continuation';
import { waitUntil } from 'cloudflare:workers';
import { env, waitUntil } from 'cloudflare:workers';
const noStore = { 'Cache-Control': 'no-store' };
export async function POST(req: Request) {
try {
const url = new URL(req.url);
if (req.headers.get('origin') && req.headers.get('origin') !== url.origin)
if (req.headers.get('origin') && req.headers.get('origin') !== requestOrigin(req, env.DUNE_PUBLIC_ORIGIN))
throw new SeatControlError(
'Invalid request origin.',
'INVALID_ORIGIN',
@@ -158,7 +159,7 @@ export async function POST(req: Request) {
{
headers: {
...noStore,
'Set-Cookie': `dune_${code}=${result.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${code}; Max-Age=2592000${url.protocol === 'https:' ? '; Secure' : ''}`,
'Set-Cookie': `dune_${code}=${result.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${code}; Max-Age=2592000${requestOrigin(req, env.DUNE_PUBLIC_ORIGIN).startsWith('https:') ? '; Secure' : ''}`,
},
},
);
+3 -1
View File
@@ -1,3 +1,5 @@
import { env } from 'cloudflare:workers';
import { requestOrigin } from '@/lib/request-origin';
import { authenticate } from '@/db/rooms';
import { readTableTalk, sendTableTalk, TableTalkError } from '@/db/table-talk';
import { RuleError } from '@/game/engine';
@@ -8,7 +10,7 @@ async function handle(req: Request, write: boolean) {
if (
write &&
req.headers.get('origin') &&
req.headers.get('origin') !== url.origin
req.headers.get('origin') !== requestOrigin(req, env.DUNE_PUBLIC_ORIGIN)
)
throw new TableTalkError('Invalid request origin.', 403);
const code = url.pathname.split('/').at(-2)!.toUpperCase();
+4 -3
View File
@@ -1,3 +1,4 @@
import { requestOrigin } from '@/lib/request-origin';
import {
readSeatView,
authenticate,
@@ -9,7 +10,7 @@ import {
} from '@/db/rooms';
import { RuleError } from '@/game/engine';
import type { FactionId } from '@/game/catalog';
import { waitUntil } from 'cloudflare:workers';
import { env, waitUntil } from 'cloudflare:workers';
import { resumeRoom } from '@/db/room-continuation';
const codeOf = (req: Request) => {
@@ -68,7 +69,7 @@ export async function POST(req: Request) {
try {
if (
req.headers.get('origin') &&
req.headers.get('origin') !== new URL(req.url).origin
req.headers.get('origin') !== requestOrigin(req, env.DUNE_PUBLIC_ORIGIN)
)
return Response.json(
{ error: 'Invalid request origin.' },
@@ -115,7 +116,7 @@ export async function POST(req: Request) {
headers: {
...(r.token
? {
'Set-Cookie': `dune_${code}=${r.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${code}; Max-Age=2592000${new URL(req.url).protocol === 'https:' ? '; Secure' : ''}`,
'Set-Cookie': `dune_${code}=${r.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${code}; Max-Age=2592000${requestOrigin(req, env.DUNE_PUBLIC_ORIGIN).startsWith('https:') ? '; Secure' : ''}`,
}
: {}),
'Cache-Control': 'no-store',
+4 -2
View File
@@ -1,3 +1,5 @@
import { env } from 'cloudflare:workers';
import { requestOrigin } from '@/lib/request-origin';
import { createRoom, RoomEntryError } from '@/db/rooms';
import { RuleError } from '@/game/engine';
import type { FactionId } from '@/game/catalog';
@@ -5,7 +7,7 @@ export async function POST(req: Request) {
try {
if (
req.headers.get('origin') &&
req.headers.get('origin') !== new URL(req.url).origin
req.headers.get('origin') !== requestOrigin(req, env.DUNE_PUBLIC_ORIGIN)
)
return Response.json(
{ error: 'Invalid request origin.' },
@@ -40,7 +42,7 @@ export async function POST(req: Request) {
{
status: 201,
headers: {
'Set-Cookie': `dune_${result.view.code}=${result.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${result.view.code}; Max-Age=2592000${new URL(req.url).protocol === 'https:' ? '; Secure' : ''}`,
'Set-Cookie': `dune_${result.view.code}=${result.token}; HttpOnly; SameSite=Strict; Path=/api/rooms/${result.view.code}; Max-Age=2592000${requestOrigin(req, env.DUNE_PUBLIC_ORIGIN).startsWith('https:') ? '; Secure' : ''}`,
'Cache-Control': 'no-store',
},
},