Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

988 B
Raw Blame
// Only the __Host- prefixed session cookie is honoured. The legacy unprefixed
// `sid` cookie can be planted by any sibling subdomain (Domain=three.ws), so
// accepting it would allow session fixation.

import { describe, it, expect, vi } from 'vitest';

vi.mock('../api/_lib/db.js', () => ({ sql: vi.fn(async () => []) }));

const { hasSessionCookie, sessionCookie } = await import('../api/_lib/auth.js');

const req = (cookie) => ({ headers: { cookie } });

describe('session cookie reading', () => {
	it('accepts the __Host-sid cookie', () => {
		expect(hasSessionCookie(req('a=1; __Host-sid=token'))).toBe(true);
	});

	it('ignores the legacy unprefixed sid cookie', () => {
		expect(hasSessionCookie(req('sid=planted-by-sibling-subdomain'))).toBe(false);
		expect(hasSessionCookie(req('x=1; sid=planted'))).toBe(false);
	});

	it('still clears the legacy cookie on logout', () => {
		expect(sessionCookie('', { clear: true }).some((c) => c.startsWith('sid='))).toBe(true);
	});
});