import { readFile } from 'node:fs/promises' import { join } from 'node:path' import { supabaseDir } from './harness' /** * Settings the workspace access rule depends on (V1-1 contract §6.2, §9.1). * private.caller_workspace_ids() requires auth.users.email_confirmed_at, but * with confirmations off GoTrue stamps that column at sign-up; the helpers * live in `private`, which must stay out of the PostgREST schemas. */ async function readSetting( section: string, key: string, ): Promise { const config = await readFile(join(supabaseDir, 'config.toml'), 'utf8') let current = '' for (const line of config.split('\n')) { const header = line.match(/^\[([^\]]+)\]\s*$/) if (header) current = header[1] const setting = line.match(/^(\w+)\s*=\s*(.+?)\s*$/) if (current === section && setting?.[1] === key) return setting[2] } return undefined } describe('config.toml settings the access rules rely on', () => { it('requires email confirmation before any session', async () => { expect(await readSetting('auth.email', 'enable_confirmations')).toBe('true') }) it('keeps anonymous sign-ins off (no account without an email)', async () => { expect(await readSetting('auth', 'enable_anonymous_sign_ins')).toBe('false') }) it('exposes only the public schema through PostgREST', async () => { expect(await readSetting('api', 'schemas')).toBe('["public"]') }) })