flotilla/e2e/harness/zooid/config.ts

49 lines
2 KiB
TypeScript
Raw Normal View History

2026-08-06 15:43:57 +00:00
/**
* The virtual relays the container serves, and the only place their names are written down.
*
2026-09-10 03:28:02 +00:00
* zooid binds a config to a Host header and serves any number of them from one process, so another
* relay costs a toml in docker/config and nothing else. The names are a union rather than a string
* so that a scenario naming a relay that has no config fails to compile instead of hanging on a 404
* from the dispatcher.
2026-08-06 15:43:57 +00:00
*
* Each host resolves nowhere, and `.test` is reserved by rfc 2606, so a url that escapes this
* process fails to connect rather than reaching a host. transport.ts covers why the container is
* told to call itself this rather than its loopback address.
2026-08-06 15:43:57 +00:00
*/
2026-09-10 03:28:02 +00:00
// The relays a space is seeded on: members-only, with nip-29 groups on, which is what a Flotilla
// space is.
export const spaceTenants = {
2026-08-06 15:43:57 +00:00
space: "space.test",
other: "other.test",
// Policy space.toml cannot express at the same time. `closed` refuses a join without an invite,
// `unsigned` serves events with their signatures stripped, `delegated` gives every member one
// management method.
2026-08-20 20:33:20 +00:00
closed: "closed.test",
unsigned: "unsigned.test",
delegated: "delegated.test",
2026-08-06 15:43:57 +00:00
} as const
2026-09-10 03:28:02 +00:00
// Public relays with no groups, which is where anything outside a space lives: `indexer` is what a
// pubkey's own lists are resolved from, `outbox` is a followed pubkey's write relay. See
// ARCHITECTURE.md, "The follow graph".
export const openTenants = {
indexer: "indexer.test",
outbox: "outbox.test",
} as const
export const tenants = {...spaceTenants, ...openTenants} as const
export type SpaceName = keyof typeof spaceTenants
export type OpenRelayName = keyof typeof openTenants
2026-08-06 15:43:57 +00:00
export type TenantName = keyof typeof tenants
export const tenantUrl = (name: TenantName) => `wss://${tenants[name]}/`
export const tenantNames = Object.keys(tenants) as TenantName[]
// Which tenant a url belongs to, for the transport's Host header.
2026-08-06 15:43:57 +00:00
export const tenantByUrl = new Map(tenantNames.map(name => [tenantUrl(name), tenants[name]]))