feat: panel-hosted Reality keys (keyStore, payload keyMaterial, backfill, cleanup)

This commit is contained in:
aaaamoooo
2026-10-20 07:20:42 +00:00
parent 1b77c610f4
commit 483b891306
6 changed files with 343 additions and 6 deletions
+6 -1
View File
@@ -20,7 +20,10 @@ function emptyData() {
completedJobRetentionDays: 7
},
users: [], servers: [], agents: [], enrollmentTokens: [], customers: [],
nodes: [], nodeClients: [], jobs: [], activity: [], observations: [], subscriptionAccess: [], subscriptionClients: []
nodes: [], nodeClients: [], jobs: [], activity: [], observations: [], subscriptionAccess: [], subscriptionClients: [],
// Panel-hosted Reality keypairs: { "reality-<nodeId>": { privateKey, publicKey, updatedAt } }.
// An object (not a collection), so it is not part of COLLECTIONS validation.
keyStore: {}
};
}
@@ -40,6 +43,7 @@ class Store {
this.data = JSON.parse(raw);
this.data.subscriptionAccess ||= [];
this.data.subscriptionClients ||= [];
this.data.keyStore ||= {};
this.#validate(this.data);
} catch (error) {
if (error.code !== 'ENOENT') throw error;
@@ -81,6 +85,7 @@ class Store {
const copy = structuredClone(next);
copy.subscriptionAccess ||= [];
copy.subscriptionClients ||= [];
copy.keyStore ||= {};
this.#validate(copy);
for (const key of Object.keys(draft)) delete draft[key];
Object.assign(draft, copy);