import * as plugins from '../../plugins.js'; import { DcRouterDb } from '../classes.dcrouter-db.js'; import type { IDnsAuthorityZone } from '../../../ts_interfaces/data/dns-authority.js'; const getDb = () => DcRouterDb.getInstance().getDb(); /** * Singleton DNS-authority document. One row per dcrouter instance, keyed on the * fixed `settingsId`, following the `AcmeConfigDoc` / `RemoteIngressHubSettingsDoc` * pattern rather than introducing a third settings shape. * * Holds the zones whose authority was **proven** by an observed public * delegation to our nameservers. This is the authority set — the whole of it. * Deployment configuration contributes nothing: `dnsScopes` used to add an * always-in-effect floor, and duplicating one fact into two places is what let * the two representations drift, which is the bug class this document closes. * * Reading it is therefore load-bearing. `DnsAuthorityManager.start()` treats an * absent document (known-empty: claim nothing) differently from an unreadable * one (unknown: refuse to start), because rendering the second as the first * would turn a database blip into every zone dropping off the air. */ @plugins.smartdata.Collection(() => getDb()) export class DnsAuthorityDoc extends plugins.smartdata.SmartDataDbDoc { @plugins.smartdata.unI() @plugins.smartdata.svDb() public settingsId: string = 'dns-authority-settings'; /** * Delegation-verified zones. Each entry carries the evidence that justified * it, so a later audit can tell what was observed and when. */ @plugins.smartdata.svDb() public verifiedZones: IDnsAuthorityZone[] = []; @plugins.smartdata.svDb() public updatedAt: number = 0; @plugins.smartdata.svDb() public updatedBy: string = ''; constructor() { super(); } public static async load(): Promise { return await DnsAuthorityDoc.getInstance({ settingsId: 'dns-authority-settings' }); } }