Files
browser/db/schema.ts
T
pastilhasandClaude Opus 5 52934f52dc browser, extracted from the platform — extension, relay and all
Your own Chrome, driven from Officer. Not a headless one: it attaches to the browser you are already
signed into, which is the whole difference from /scrape, and /scrape stays behind in the platform.

The relay is a sidecar now, and that is the point. It was a second Bun.serve inside the platform
process on its own port, which is exactly why it was switched off on 2026-08-13 — "the platform serves
one port". A sidecar is a process allowed its own listeners, so the objection stops applying instead of
being argued with.

The boundary across it is deliberately small: two questions, who is connected and what tabs they have,
because only those live in memory on the relay side. Screenshots, evaluation and navigation still go
straight down cdp.ts's own WebSocket to the relay's /cdp endpoint, exactly as before — routing page
bytes through the platform would be work for nothing.

Three normally-breaking changes taken now because now they are free, each already recommended in a
comment by whoever switched the relay off. Its own signing key instead of borrowing getKey('jwt'). Its
own table instead of the platform's user_integrations. And the port kept at 18792 on purpose, because
the port is an input to the token HMAC as well as an address — moving it fails every pairing silently,
and the extension blames the address. user_integrations held zero browser-relay rows, checked in
Postgres rather than assumed, so there was nothing to unpair.

The screen became panels. BrowserScreen.tsx rendered TabList and TabPreview through appType: null
placeholders; both components were already self-contained and took no props, so the screen had nothing
to pass and simply went.

Not tested end to end — no browser has been paired since the move, and that needs a Chrome and a
person. BLOCKERS.md says so rather than the commit implying otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 01:04:09 +00:00

31 lines
1.6 KiB
TypeScript

import { pgTable, serial, integer, text, timestamp, uniqueIndex } from 'drizzle-orm/pg-core';
import { users } from 'officerdb/schema';
// One row per paired browser: the salt its token is derived from, and nothing else.
//
// ── Why this is not `user_integrations` ──
//
// It was, under provider `browser-relay`. That put a plugin's data in a platform table, which is the same
// coupling the extraction removes everywhere else — and it meant the platform's schema carried a row
// shape whose meaning lived in code it does not own.
//
// Moving it is normally a breaking change, because the salt IS the pairing: lose it and every browser
// re-pairs. It is free right now and only right now — the relay has been switched off since 2026-08-13
// and `user_integrations` holds zero `browser-relay` rows, checked before this table was written. Doing
// it later would cost somebody their paired browsers.
export const browserPairings = pgTable(
'browser_pairings',
{
id: serial('id').primaryKey(),
userId: integer('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
/** Random per pairing. The token is HMAC(key, `…:${port}:${userId}:${salt}`) — see sidecar/relay-auth.ts. */
salt: text('salt').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
},
// One pairing per account. Regenerating replaces the salt rather than adding a second row, which is
// what makes "regenerate" actually revoke the old token instead of leaving two valid.
(table) => [uniqueIndex('uq_browser_pairings_user').on(table.userId)],
);