feat(federation): shared epoch types + getInstanceId()
This commit is contained in:
@@ -53,9 +53,11 @@ beforeEach(async () => {
|
||||
|
||||
// Seed the singleton instance_settings row mirroring ensureDefaults() —
|
||||
// tests don't run the boot-time helper, so we insert manually with the
|
||||
// schema-default values for the new federatedRegistrationOpen column.
|
||||
// schema-default values for the new federatedRegistrationOpen column plus
|
||||
// the persistent epoch (instanceId) that ensureDefaults mints on boot.
|
||||
testDb.insert(schema.instanceSettings).values({
|
||||
id: 1,
|
||||
instanceId: '123e4567-e89b-12d3-a456-426614174000',
|
||||
updatedAt: Date.now(),
|
||||
}).run();
|
||||
|
||||
@@ -94,5 +96,8 @@ describe('GET /api/instance/info', () => {
|
||||
expect(typeof body.sourceCodeUrl).toBe('string');
|
||||
expect(body.sourceCodeUrl).toMatch(/^https?:\/\//);
|
||||
expect(body.commit === null || typeof body.commit === 'string').toBe(true);
|
||||
// Persistent per-instance epoch (incarnation UUID) is always advertised.
|
||||
expect(typeof body.instanceId).toBe('string');
|
||||
expect(body.instanceId).toMatch(/^[0-9a-f-]{36}$/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { FastifyInstance } from 'fastify';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { getDb, schema } from '../db/index.js';
|
||||
import { config } from '../config.js';
|
||||
import { getInstanceId } from '../utils/federationEpoch.js';
|
||||
import type { InstanceInfoResponse } from '@backspace/shared';
|
||||
|
||||
const BACKSPACE_VERSION = '1.0.0';
|
||||
@@ -23,6 +24,7 @@ export async function instanceRoutes(app: FastifyInstance): Promise<void> {
|
||||
version: BACKSPACE_VERSION,
|
||||
registrationOpen,
|
||||
federatedRegistrationOpen: settings?.federatedRegistrationOpen === 1,
|
||||
instanceId: getInstanceId(),
|
||||
// AGPL-3.0 § 13: advertise the source of the running version to every
|
||||
// network user (and federated peer) — public/unauthenticated by design.
|
||||
sourceCodeUrl: config.sourceCodeUrl,
|
||||
|
||||
Reference in New Issue
Block a user