@songsid/agend 2.3.5-alpha.8 → 2.3.5-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts-profiles.d.ts +6 -0
- package/dist/accounts-profiles.js +16 -0
- package/dist/accounts-profiles.js.map +1 -1
- package/dist/agent-cli-instructions.md +1 -1
- package/dist/agent-cli.js +5 -2
- package/dist/agent-cli.js.map +1 -1
- package/dist/agent-whats-new.js +5 -0
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/authority/company-join.d.ts +16 -0
- package/dist/authority/company-join.js +37 -0
- package/dist/authority/company-join.js.map +1 -0
- package/dist/authority/hub-initialization.d.ts +13 -0
- package/dist/authority/hub-initialization.js +30 -0
- package/dist/authority/hub-initialization.js.map +1 -0
- package/dist/backend/claude-code.d.ts +1 -0
- package/dist/backend/claude-code.js +13 -0
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/types.d.ts +4 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +2 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-model-minimum.d.ts +7 -0
- package/dist/claude-model-minimum.js +16 -0
- package/dist/claude-model-minimum.js.map +1 -0
- package/dist/daemon.d.ts +43 -1
- package/dist/daemon.js +176 -27
- package/dist/daemon.js.map +1 -1
- package/dist/decision-list.d.ts +2 -0
- package/dist/decision-list.js +1 -1
- package/dist/decision-list.js.map +1 -1
- package/dist/fleet-manager.d.ts +50 -1
- package/dist/fleet-manager.js +306 -32
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +14 -3
- package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
- package/dist/hub/client.js +2 -0
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.js +1 -1
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +48 -1
- package/dist/hub/compose/server.js +30 -5
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +2 -0
- package/dist/hub/directory/directory.js +49 -4
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +2 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/enrollment-budget.d.ts +6 -0
- package/dist/hub/enrollment-budget.js +24 -0
- package/dist/hub/enrollment-budget.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +5 -0
- package/dist/hub/group-policy/authorization.js +24 -1
- package/dist/hub/group-policy/authorization.js.map +1 -1
- package/dist/hub/http/compose.js +62 -8
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +2 -0
- package/dist/hub/http/core.js +10 -1
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +3 -0
- package/dist/hub/http/schema.js +4 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/browser-certificate.d.ts +6 -1
- package/dist/hub/init/browser-certificate.js +22 -1
- package/dist/hub/init/browser-certificate.js.map +1 -1
- package/dist/hub/init/initializer.d.ts +11 -1
- package/dist/hub/init/initializer.js +202 -83
- package/dist/hub/init/initializer.js.map +1 -1
- package/dist/hub/init/layout.js +1 -1
- package/dist/hub/init/layout.js.map +1 -1
- package/dist/hub/init/text.js +2 -2
- package/dist/hub/init/text.js.map +1 -1
- package/dist/hub/init/types.d.ts +32 -4
- package/dist/hub/init/types.js.map +1 -1
- package/dist/hub/init/web-audit-import.d.ts +12 -0
- package/dist/hub/init/web-audit-import.js +39 -0
- package/dist/hub/init/web-audit-import.js.map +1 -0
- package/dist/hub/init/web-audit.d.ts +30 -0
- package/dist/hub/init/web-audit.js +42 -0
- package/dist/hub/init/web-audit.js.map +1 -0
- package/dist/hub/init/web-error.d.ts +6 -0
- package/dist/hub/init/web-error.js +8 -0
- package/dist/hub/init/web-error.js.map +1 -0
- package/dist/hub/init/web-http.d.ts +9 -0
- package/dist/hub/init/web-http.js +103 -0
- package/dist/hub/init/web-http.js.map +1 -0
- package/dist/hub/init/web.d.ts +118 -0
- package/dist/hub/init/web.js +428 -0
- package/dist/hub/init/web.js.map +1 -0
- package/dist/hub/init/wizard.js +1 -3
- package/dist/hub/init/wizard.js.map +1 -1
- package/dist/hub/join/client.d.ts +35 -0
- package/dist/hub/join/client.js +112 -0
- package/dist/hub/join/client.js.map +1 -0
- package/dist/hub/join/descriptor.d.ts +45 -0
- package/dist/hub/join/descriptor.js +52 -0
- package/dist/hub/join/descriptor.js.map +1 -0
- package/dist/hub/join/fleet-authority.d.ts +2 -0
- package/dist/hub/join/fleet-authority.js +3 -0
- package/dist/hub/join/fleet-authority.js.map +1 -0
- package/dist/hub/join/http.d.ts +8 -0
- package/dist/hub/join/http.js +112 -0
- package/dist/hub/join/http.js.map +1 -0
- package/dist/hub/join/invitation.d.ts +28 -0
- package/dist/hub/join/invitation.js +28 -0
- package/dist/hub/join/invitation.js.map +1 -0
- package/dist/hub/join/local-journal.d.ts +84 -0
- package/dist/hub/join/local-journal.js +65 -0
- package/dist/hub/join/local-journal.js.map +1 -0
- package/dist/hub/join/local.d.ts +116 -0
- package/dist/hub/join/local.js +419 -0
- package/dist/hub/join/local.js.map +1 -0
- package/dist/hub/join/private.d.ts +3 -0
- package/dist/hub/join/private.js +46 -0
- package/dist/hub/join/private.js.map +1 -0
- package/dist/hub/join/protocol.d.ts +69 -0
- package/dist/hub/join/protocol.js +96 -0
- package/dist/hub/join/protocol.js.map +1 -0
- package/dist/hub/join/receipt.d.ts +42 -0
- package/dist/hub/join/receipt.js +75 -0
- package/dist/hub/join/receipt.js.map +1 -0
- package/dist/hub/join/service.d.ts +177 -0
- package/dist/hub/join/service.js +564 -0
- package/dist/hub/join/service.js.map +1 -0
- package/dist/hub/join/store.d.ts +97 -0
- package/dist/hub/join/store.js +87 -0
- package/dist/hub/join/store.js.map +1 -0
- package/dist/hub/join/trust.d.ts +13 -0
- package/dist/hub/join/trust.js +68 -0
- package/dist/hub/join/trust.js.map +1 -0
- package/dist/hub/member/pairing-api.js +6 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/pairing-notices.js +6 -4
- package/dist/hub/member/pairing-notices.js.map +1 -1
- package/dist/hub/pairing-notices.d.ts +3 -3
- package/dist/hub/pairing-notices.js +13 -8
- package/dist/hub/pairing-notices.js.map +1 -1
- package/dist/hub/pairing.d.ts +6 -0
- package/dist/hub/pairing.js +6 -6
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +29 -0
- package/dist/hub/protocol.js +3 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-read-pacer.d.ts +14 -0
- package/dist/hub/room-read-pacer.js +51 -0
- package/dist/hub/room-read-pacer.js.map +1 -0
- package/dist/hub/rooms.d.ts +7 -1
- package/dist/hub/rooms.js +25 -13
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +4 -0
- package/dist/hub/runtime.js +2 -0
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +3 -0
- package/dist/hub/server.js +14 -0
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/session-directory-transition.d.ts +48 -0
- package/dist/hub/session-directory-transition.js +118 -0
- package/dist/hub/session-directory-transition.js.map +1 -0
- package/dist/hub/session-epoch.d.ts +16 -0
- package/dist/hub/session-epoch.js +50 -0
- package/dist/hub/session-epoch.js.map +1 -0
- package/dist/hub/sessions.d.ts +13 -0
- package/dist/hub/sessions.js +36 -16
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-api.d.ts +50 -0
- package/dist/hub/settings-api.js +92 -0
- package/dist/hub/settings-api.js.map +1 -0
- package/dist/hub/settings-commit.d.ts +95 -0
- package/dist/hub/settings-commit.js +490 -0
- package/dist/hub/settings-commit.js.map +1 -0
- package/dist/hub/settings-directory-decision.d.ts +433 -0
- package/dist/hub/settings-directory-decision.js +236 -0
- package/dist/hub/settings-directory-decision.js.map +1 -0
- package/dist/hub/settings-directory-proof.d.ts +77 -0
- package/dist/hub/settings-directory-proof.js +303 -0
- package/dist/hub/settings-directory-proof.js.map +1 -0
- package/dist/hub/store.d.ts +2 -1
- package/dist/hub/store.js +2 -1
- package/dist/hub/store.js.map +1 -1
- package/dist/hub/types.d.ts +4 -2
- package/dist/hub-host-settings.d.ts +48 -0
- package/dist/hub-host-settings.js +85 -0
- package/dist/hub-host-settings.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +3 -0
- package/dist/instance-lifecycle.js +4 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +32 -14
- package/dist/locale.js.map +1 -1
- package/dist/outbound-schemas.d.ts +2 -0
- package/dist/outbound-schemas.js +4 -2
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/pane-port.d.ts +1 -1
- package/dist/profile-signins.d.ts +107 -0
- package/dist/profile-signins.js +249 -0
- package/dist/profile-signins.js.map +1 -0
- package/dist/scheduler/db.d.ts +10 -0
- package/dist/scheduler/db.js +38 -11
- package/dist/scheduler/db.js.map +1 -1
- package/dist/scheduler/types.d.ts +6 -1
- package/dist/settings-api.d.ts +7 -0
- package/dist/settings-api.js +197 -2
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-confirmation.d.ts +1 -1
- package/dist/settings-confirmation.js +1 -1
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.js +58 -0
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +3 -0
- package/dist/settings-http-confirmation.js +8 -5
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/settings-request-capability.d.ts +5 -0
- package/dist/settings-request-capability.js +6 -1
- package/dist/settings-request-capability.js.map +1 -1
- package/dist/structured-signin-transport.d.ts +20 -2
- package/dist/structured-signin-transport.js +57 -6
- package/dist/structured-signin-transport.js.map +1 -1
- package/dist/team-membership.d.ts +7 -0
- package/dist/team-membership.js +10 -0
- package/dist/team-membership.js.map +1 -0
- package/dist/tmux-manager.d.ts +1 -1
- package/dist/tmux-manager.js +4 -1
- package/dist/tmux-manager.js.map +1 -1
- package/dist/topic-commands.js +1 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/ui/backend-signin.js +51 -15
- package/dist/ui/hub-attachments.js +3 -3
- package/dist/ui/hub-chat-strings.js +2 -0
- package/dist/ui/hub-client.js +9 -3
- package/dist/ui/hub-company-join-strings.js +74 -0
- package/dist/ui/hub-company-join.js +119 -0
- package/dist/ui/hub-group-policy.js +7 -2
- package/dist/ui/hub-owner-strings.js +8 -8
- package/dist/ui/hub-quick-pairing.js +15 -8
- package/dist/ui/hub-quick-strings.js +3 -3
- package/dist/ui/hub-this-hub.js +112 -0
- package/dist/ui/hub-welcome.js +8 -5
- package/dist/ui/panel-hub.js +178 -26
- package/dist/ui/panel-needs.js +1 -1
- package/dist/ui/settings-hub-company-join.js +90 -0
- package/dist/ui/settings-hub-membership.js +2 -1
- package/dist/ui/settings-hub-preview.js +74 -0
- package/dist/ui/settings-hub-run.js +60 -0
- package/dist/ui/settings-hub-section.js +4 -2
- package/dist/ui/settings-registry.js +2 -0
- package/dist/ui/shared/app-i18n.js +1 -1
- package/dist/ui/shared/app-shell.js +21 -17
- package/dist/ui/shared/app.css +9 -8
- package/dist/ui/shared/chat-strings.js +13 -13
- package/dist/ui/shared/hub-chat.css +12 -0
- package/dist/ui/shared/hub-groups.css +2 -0
- package/dist/ui/shared/hub-owner.css +19 -1
- package/dist/ui/shared/hub.css +7 -1
- package/dist/ui/structured-signin.js +24 -6
- package/dist/update-dispatch.d.ts +32 -4
- package/dist/update-dispatch.js +146 -16
- package/dist/update-dispatch.js.map +1 -1
- package/dist/update-launch.d.ts +1 -1
- package/dist/update-launch.js +2 -2
- package/dist/update-launch.js.map +1 -1
- package/dist/view-api.d.ts +2 -8
- package/dist/view-api.js +3 -9
- package/dist/view-api.js.map +1 -1
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +66 -9
- package/dist/web-api.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3425 directory-v2 SQL decision for settings-commit.ts, not another file writer or an HTTP authority.
|
|
3
|
+
* The shared writer stages/fsyncs the exact images first. One root IMMEDIATE transaction then authorizes
|
|
4
|
+
* those images together with binding, floor/version, browser epoch, audit and FULL old-recipient notices.
|
|
5
|
+
* File journals/signatures cannot substitute for this row. No production caller is composed yet.
|
|
6
|
+
*/
|
|
7
|
+
import { type HubDirectorySessionRotation } from "./session-directory-transition.js";
|
|
8
|
+
import type Database from "better-sqlite3";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import type { HubMigration } from "./db.js";
|
|
11
|
+
import type { HubTransportStore } from "./store.js";
|
|
12
|
+
declare const imageSchema: z.ZodObject<{
|
|
13
|
+
configDigest: z.ZodString;
|
|
14
|
+
configSha: z.ZodString;
|
|
15
|
+
directorySha: z.ZodString;
|
|
16
|
+
manifestSha: z.ZodString;
|
|
17
|
+
bindSecretSha: z.ZodString;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export type HubDirectorySettingsImage = z.infer<typeof imageSchema>;
|
|
20
|
+
declare const requestSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
expected: z.ZodObject<{
|
|
23
|
+
operationId: z.ZodNullable<z.ZodString>;
|
|
24
|
+
directoryEpoch: z.ZodNumber;
|
|
25
|
+
transportRevision: z.ZodNumber;
|
|
26
|
+
authorizationVersion: z.ZodNumber;
|
|
27
|
+
policySha: z.ZodString;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
before: z.ZodObject<{
|
|
30
|
+
configDigest: z.ZodString;
|
|
31
|
+
configSha: z.ZodString;
|
|
32
|
+
directorySha: z.ZodString;
|
|
33
|
+
manifestSha: z.ZodString;
|
|
34
|
+
bindSecretSha: z.ZodString;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
after: z.ZodObject<{
|
|
37
|
+
configDigest: z.ZodString;
|
|
38
|
+
configSha: z.ZodString;
|
|
39
|
+
directorySha: z.ZodString;
|
|
40
|
+
manifestSha: z.ZodString;
|
|
41
|
+
bindSecretSha: z.ZodString;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
generation: z.ZodString;
|
|
44
|
+
receiptSha: z.ZodString;
|
|
45
|
+
actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
kind: z.ZodLiteral<"hub-administrator">;
|
|
47
|
+
person: z.ZodObject<{
|
|
48
|
+
realm: z.ZodString;
|
|
49
|
+
objectId: z.ZodString;
|
|
50
|
+
}, z.core.$strict>;
|
|
51
|
+
sessionId: z.ZodString;
|
|
52
|
+
requestId: z.ZodString;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
kind: z.ZodLiteral<"host-owner">;
|
|
55
|
+
sessionId: z.ZodString;
|
|
56
|
+
requestId: z.ZodString;
|
|
57
|
+
}, z.core.$strict>], "kind">;
|
|
58
|
+
at: z.ZodNumber;
|
|
59
|
+
changes: z.ZodArray<z.ZodEnum<{
|
|
60
|
+
ca: "ca";
|
|
61
|
+
query: "query";
|
|
62
|
+
search: "search";
|
|
63
|
+
secret: "secret";
|
|
64
|
+
server: "server";
|
|
65
|
+
"service-account": "service-account";
|
|
66
|
+
}>>;
|
|
67
|
+
recipients: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
68
|
+
kind: z.ZodLiteral<"host">;
|
|
69
|
+
sink: z.ZodString;
|
|
70
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
71
|
+
kind: z.ZodLiteral<"person">;
|
|
72
|
+
person: z.ZodObject<{
|
|
73
|
+
realm: z.ZodString;
|
|
74
|
+
objectId: z.ZodString;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
}, z.core.$strict>], "kind">>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
export type HubDirectoryDecisionRequest = z.infer<typeof requestSchema>;
|
|
79
|
+
export declare function parseHubDirectoryDecisionMetadata(raw: unknown): {
|
|
80
|
+
actor: {
|
|
81
|
+
kind: "hub-administrator";
|
|
82
|
+
person: {
|
|
83
|
+
realm: string;
|
|
84
|
+
objectId: string;
|
|
85
|
+
};
|
|
86
|
+
sessionId: string;
|
|
87
|
+
requestId: string;
|
|
88
|
+
} | {
|
|
89
|
+
kind: "host-owner";
|
|
90
|
+
sessionId: string;
|
|
91
|
+
requestId: string;
|
|
92
|
+
};
|
|
93
|
+
changes: ("ca" | "query" | "search" | "secret" | "server" | "service-account")[];
|
|
94
|
+
recipients: ({
|
|
95
|
+
kind: "host";
|
|
96
|
+
sink: string;
|
|
97
|
+
} | {
|
|
98
|
+
kind: "person";
|
|
99
|
+
person: {
|
|
100
|
+
realm: string;
|
|
101
|
+
objectId: string;
|
|
102
|
+
};
|
|
103
|
+
})[];
|
|
104
|
+
};
|
|
105
|
+
declare const operationSchema: z.ZodObject<{
|
|
106
|
+
id: z.ZodString;
|
|
107
|
+
expected: z.ZodObject<{
|
|
108
|
+
operationId: z.ZodNullable<z.ZodString>;
|
|
109
|
+
directoryEpoch: z.ZodNumber;
|
|
110
|
+
transportRevision: z.ZodNumber;
|
|
111
|
+
authorizationVersion: z.ZodNumber;
|
|
112
|
+
policySha: z.ZodString;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
before: z.ZodObject<{
|
|
115
|
+
configDigest: z.ZodString;
|
|
116
|
+
configSha: z.ZodString;
|
|
117
|
+
directorySha: z.ZodString;
|
|
118
|
+
manifestSha: z.ZodString;
|
|
119
|
+
bindSecretSha: z.ZodString;
|
|
120
|
+
}, z.core.$strict>;
|
|
121
|
+
after: z.ZodObject<{
|
|
122
|
+
configDigest: z.ZodString;
|
|
123
|
+
configSha: z.ZodString;
|
|
124
|
+
directorySha: z.ZodString;
|
|
125
|
+
manifestSha: z.ZodString;
|
|
126
|
+
bindSecretSha: z.ZodString;
|
|
127
|
+
}, z.core.$strict>;
|
|
128
|
+
generation: z.ZodString;
|
|
129
|
+
receiptSha: z.ZodString;
|
|
130
|
+
actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
131
|
+
kind: z.ZodLiteral<"hub-administrator">;
|
|
132
|
+
person: z.ZodObject<{
|
|
133
|
+
realm: z.ZodString;
|
|
134
|
+
objectId: z.ZodString;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
sessionId: z.ZodString;
|
|
137
|
+
requestId: z.ZodString;
|
|
138
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
139
|
+
kind: z.ZodLiteral<"host-owner">;
|
|
140
|
+
sessionId: z.ZodString;
|
|
141
|
+
requestId: z.ZodString;
|
|
142
|
+
}, z.core.$strict>], "kind">;
|
|
143
|
+
at: z.ZodNumber;
|
|
144
|
+
changes: z.ZodArray<z.ZodEnum<{
|
|
145
|
+
ca: "ca";
|
|
146
|
+
query: "query";
|
|
147
|
+
search: "search";
|
|
148
|
+
secret: "secret";
|
|
149
|
+
server: "server";
|
|
150
|
+
"service-account": "service-account";
|
|
151
|
+
}>>;
|
|
152
|
+
recipients: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
153
|
+
kind: z.ZodLiteral<"host">;
|
|
154
|
+
sink: z.ZodString;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
kind: z.ZodLiteral<"person">;
|
|
157
|
+
person: z.ZodObject<{
|
|
158
|
+
realm: z.ZodString;
|
|
159
|
+
objectId: z.ZodString;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
}, z.core.$strict>], "kind">>;
|
|
162
|
+
kind: z.ZodEnum<{
|
|
163
|
+
directory: "directory";
|
|
164
|
+
"directory-compensation": "directory-compensation";
|
|
165
|
+
}>;
|
|
166
|
+
compensates: z.ZodNullable<z.ZodString>;
|
|
167
|
+
browserSession: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
v: z.ZodLiteral<1>;
|
|
169
|
+
previousSessionId: z.ZodString;
|
|
170
|
+
sessionId: z.ZodString;
|
|
171
|
+
}, z.core.$strict>>;
|
|
172
|
+
previousGeneration: z.ZodString;
|
|
173
|
+
directoryEpoch: z.ZodNumber;
|
|
174
|
+
authorizationVersion: z.ZodNumber;
|
|
175
|
+
}, z.core.$strict>;
|
|
176
|
+
export type HubDirectorySettingsOperation = z.infer<typeof operationSchema>;
|
|
177
|
+
declare const noticeSchema: z.ZodObject<{
|
|
178
|
+
v: z.ZodLiteral<1>;
|
|
179
|
+
id: z.ZodString;
|
|
180
|
+
operationId: z.ZodString;
|
|
181
|
+
kind: z.ZodEnum<{
|
|
182
|
+
directory: "directory";
|
|
183
|
+
"directory-compensation": "directory-compensation";
|
|
184
|
+
}>;
|
|
185
|
+
phase: z.ZodLiteral<"applying">;
|
|
186
|
+
actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
187
|
+
kind: z.ZodLiteral<"hub-administrator">;
|
|
188
|
+
person: z.ZodObject<{
|
|
189
|
+
realm: z.ZodString;
|
|
190
|
+
objectId: z.ZodString;
|
|
191
|
+
}, z.core.$strict>;
|
|
192
|
+
sessionId: z.ZodString;
|
|
193
|
+
requestId: z.ZodString;
|
|
194
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
195
|
+
kind: z.ZodLiteral<"host-owner">;
|
|
196
|
+
sessionId: z.ZodString;
|
|
197
|
+
requestId: z.ZodString;
|
|
198
|
+
}, z.core.$strict>], "kind">;
|
|
199
|
+
at: z.ZodNumber;
|
|
200
|
+
changes: z.ZodArray<z.ZodEnum<{
|
|
201
|
+
ca: "ca";
|
|
202
|
+
query: "query";
|
|
203
|
+
search: "search";
|
|
204
|
+
secret: "secret";
|
|
205
|
+
server: "server";
|
|
206
|
+
"service-account": "service-account";
|
|
207
|
+
}>>;
|
|
208
|
+
recipients: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
209
|
+
kind: z.ZodLiteral<"host">;
|
|
210
|
+
sink: z.ZodString;
|
|
211
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
212
|
+
kind: z.ZodLiteral<"person">;
|
|
213
|
+
person: z.ZodObject<{
|
|
214
|
+
realm: z.ZodString;
|
|
215
|
+
objectId: z.ZodString;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
}, z.core.$strict>], "kind">>;
|
|
218
|
+
}, z.core.$strict>;
|
|
219
|
+
export type HubDirectorySecurityNotice = z.infer<typeof noticeSchema>;
|
|
220
|
+
export declare const HUB_DIRECTORY_SETTINGS_MIGRATION: HubMigration;
|
|
221
|
+
/** Durable head only. A mounted server must separately prove its exact installed image matches head.after. */
|
|
222
|
+
export declare function readHubDirectorySettingsHead(db: Database.Database): {
|
|
223
|
+
operationId: string | null;
|
|
224
|
+
directoryEpoch: number;
|
|
225
|
+
};
|
|
226
|
+
export interface HubDirectoryDecisionDeps {
|
|
227
|
+
db: Database.Database;
|
|
228
|
+
transport: HubTransportStore;
|
|
229
|
+
/** Exact Hub binding, never accepted from a browser body. */
|
|
230
|
+
hubId: string;
|
|
231
|
+
}
|
|
232
|
+
export type HubDirectorySettingsDecision = ReturnType<typeof createHubDirectorySettingsDecision>;
|
|
233
|
+
/** Internal library, no I/O on construction. The shared writer owns all file installation and proof acquisition. */
|
|
234
|
+
export declare function createHubDirectorySettingsDecision(deps: HubDirectoryDecisionDeps): {
|
|
235
|
+
hubId: string;
|
|
236
|
+
inspect: () => {
|
|
237
|
+
operationId: string | null;
|
|
238
|
+
directoryEpoch: number;
|
|
239
|
+
transportRevision: number;
|
|
240
|
+
authorizationVersion: number;
|
|
241
|
+
policySha: string;
|
|
242
|
+
};
|
|
243
|
+
decide(raw: HubDirectoryDecisionRequest, assertProof: () => void | number, rotation?: HubDirectorySessionRotation): {
|
|
244
|
+
id: string;
|
|
245
|
+
expected: {
|
|
246
|
+
operationId: string | null;
|
|
247
|
+
directoryEpoch: number;
|
|
248
|
+
transportRevision: number;
|
|
249
|
+
authorizationVersion: number;
|
|
250
|
+
policySha: string;
|
|
251
|
+
};
|
|
252
|
+
before: {
|
|
253
|
+
configDigest: string;
|
|
254
|
+
configSha: string;
|
|
255
|
+
directorySha: string;
|
|
256
|
+
manifestSha: string;
|
|
257
|
+
bindSecretSha: string;
|
|
258
|
+
};
|
|
259
|
+
after: {
|
|
260
|
+
configDigest: string;
|
|
261
|
+
configSha: string;
|
|
262
|
+
directorySha: string;
|
|
263
|
+
manifestSha: string;
|
|
264
|
+
bindSecretSha: string;
|
|
265
|
+
};
|
|
266
|
+
generation: string;
|
|
267
|
+
receiptSha: string;
|
|
268
|
+
actor: {
|
|
269
|
+
kind: "hub-administrator";
|
|
270
|
+
person: {
|
|
271
|
+
realm: string;
|
|
272
|
+
objectId: string;
|
|
273
|
+
};
|
|
274
|
+
sessionId: string;
|
|
275
|
+
requestId: string;
|
|
276
|
+
} | {
|
|
277
|
+
kind: "host-owner";
|
|
278
|
+
sessionId: string;
|
|
279
|
+
requestId: string;
|
|
280
|
+
};
|
|
281
|
+
at: number;
|
|
282
|
+
changes: ("ca" | "query" | "search" | "secret" | "server" | "service-account")[];
|
|
283
|
+
recipients: ({
|
|
284
|
+
kind: "host";
|
|
285
|
+
sink: string;
|
|
286
|
+
} | {
|
|
287
|
+
kind: "person";
|
|
288
|
+
person: {
|
|
289
|
+
realm: string;
|
|
290
|
+
objectId: string;
|
|
291
|
+
};
|
|
292
|
+
})[];
|
|
293
|
+
kind: "directory" | "directory-compensation";
|
|
294
|
+
compensates: string | null;
|
|
295
|
+
browserSession?: {
|
|
296
|
+
v: 1;
|
|
297
|
+
previousSessionId: string;
|
|
298
|
+
sessionId: string;
|
|
299
|
+
} | undefined;
|
|
300
|
+
previousGeneration: string;
|
|
301
|
+
directoryEpoch: number;
|
|
302
|
+
authorizationVersion: number;
|
|
303
|
+
};
|
|
304
|
+
/** A new operation restoring ONLY original content; current policy/denies/revokes/provenance are never rewound. */
|
|
305
|
+
compensate(originalId: string, raw: HubDirectoryDecisionRequest, assertPreauthorizedIntent: () => void): {
|
|
306
|
+
id: string;
|
|
307
|
+
expected: {
|
|
308
|
+
operationId: string | null;
|
|
309
|
+
directoryEpoch: number;
|
|
310
|
+
transportRevision: number;
|
|
311
|
+
authorizationVersion: number;
|
|
312
|
+
policySha: string;
|
|
313
|
+
};
|
|
314
|
+
before: {
|
|
315
|
+
configDigest: string;
|
|
316
|
+
configSha: string;
|
|
317
|
+
directorySha: string;
|
|
318
|
+
manifestSha: string;
|
|
319
|
+
bindSecretSha: string;
|
|
320
|
+
};
|
|
321
|
+
after: {
|
|
322
|
+
configDigest: string;
|
|
323
|
+
configSha: string;
|
|
324
|
+
directorySha: string;
|
|
325
|
+
manifestSha: string;
|
|
326
|
+
bindSecretSha: string;
|
|
327
|
+
};
|
|
328
|
+
generation: string;
|
|
329
|
+
receiptSha: string;
|
|
330
|
+
actor: {
|
|
331
|
+
kind: "hub-administrator";
|
|
332
|
+
person: {
|
|
333
|
+
realm: string;
|
|
334
|
+
objectId: string;
|
|
335
|
+
};
|
|
336
|
+
sessionId: string;
|
|
337
|
+
requestId: string;
|
|
338
|
+
} | {
|
|
339
|
+
kind: "host-owner";
|
|
340
|
+
sessionId: string;
|
|
341
|
+
requestId: string;
|
|
342
|
+
};
|
|
343
|
+
at: number;
|
|
344
|
+
changes: ("ca" | "query" | "search" | "secret" | "server" | "service-account")[];
|
|
345
|
+
recipients: ({
|
|
346
|
+
kind: "host";
|
|
347
|
+
sink: string;
|
|
348
|
+
} | {
|
|
349
|
+
kind: "person";
|
|
350
|
+
person: {
|
|
351
|
+
realm: string;
|
|
352
|
+
objectId: string;
|
|
353
|
+
};
|
|
354
|
+
})[];
|
|
355
|
+
kind: "directory" | "directory-compensation";
|
|
356
|
+
compensates: string | null;
|
|
357
|
+
browserSession?: {
|
|
358
|
+
v: 1;
|
|
359
|
+
previousSessionId: string;
|
|
360
|
+
sessionId: string;
|
|
361
|
+
} | undefined;
|
|
362
|
+
previousGeneration: string;
|
|
363
|
+
directoryEpoch: number;
|
|
364
|
+
authorizationVersion: number;
|
|
365
|
+
};
|
|
366
|
+
operation(id: string): {
|
|
367
|
+
id: string;
|
|
368
|
+
expected: {
|
|
369
|
+
operationId: string | null;
|
|
370
|
+
directoryEpoch: number;
|
|
371
|
+
transportRevision: number;
|
|
372
|
+
authorizationVersion: number;
|
|
373
|
+
policySha: string;
|
|
374
|
+
};
|
|
375
|
+
before: {
|
|
376
|
+
configDigest: string;
|
|
377
|
+
configSha: string;
|
|
378
|
+
directorySha: string;
|
|
379
|
+
manifestSha: string;
|
|
380
|
+
bindSecretSha: string;
|
|
381
|
+
};
|
|
382
|
+
after: {
|
|
383
|
+
configDigest: string;
|
|
384
|
+
configSha: string;
|
|
385
|
+
directorySha: string;
|
|
386
|
+
manifestSha: string;
|
|
387
|
+
bindSecretSha: string;
|
|
388
|
+
};
|
|
389
|
+
generation: string;
|
|
390
|
+
receiptSha: string;
|
|
391
|
+
actor: {
|
|
392
|
+
kind: "hub-administrator";
|
|
393
|
+
person: {
|
|
394
|
+
realm: string;
|
|
395
|
+
objectId: string;
|
|
396
|
+
};
|
|
397
|
+
sessionId: string;
|
|
398
|
+
requestId: string;
|
|
399
|
+
} | {
|
|
400
|
+
kind: "host-owner";
|
|
401
|
+
sessionId: string;
|
|
402
|
+
requestId: string;
|
|
403
|
+
};
|
|
404
|
+
at: number;
|
|
405
|
+
changes: ("ca" | "query" | "search" | "secret" | "server" | "service-account")[];
|
|
406
|
+
recipients: ({
|
|
407
|
+
kind: "host";
|
|
408
|
+
sink: string;
|
|
409
|
+
} | {
|
|
410
|
+
kind: "person";
|
|
411
|
+
person: {
|
|
412
|
+
realm: string;
|
|
413
|
+
objectId: string;
|
|
414
|
+
};
|
|
415
|
+
})[];
|
|
416
|
+
kind: "directory" | "directory-compensation";
|
|
417
|
+
compensates: string | null;
|
|
418
|
+
browserSession?: {
|
|
419
|
+
v: 1;
|
|
420
|
+
previousSessionId: string;
|
|
421
|
+
sessionId: string;
|
|
422
|
+
} | undefined;
|
|
423
|
+
previousGeneration: string;
|
|
424
|
+
directoryEpoch: number;
|
|
425
|
+
authorizationVersion: number;
|
|
426
|
+
};
|
|
427
|
+
/** Absence is meaningful only while floor/head authority is readable; uncertainty is never treated as no decision. */
|
|
428
|
+
lookup(id: string): HubDirectorySettingsOperation | null;
|
|
429
|
+
/** Own startup/remount verifies files/seal first, then checks this barrier before admitting any effect. */
|
|
430
|
+
imageCurrent(raw: HubDirectorySettingsImage): boolean;
|
|
431
|
+
notices(): HubDirectorySecurityNotice[];
|
|
432
|
+
};
|
|
433
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #3425 directory-v2 SQL decision for settings-commit.ts, not another file writer or an HTTP authority.
|
|
3
|
+
* The shared writer stages/fsyncs the exact images first. One root IMMEDIATE transaction then authorizes
|
|
4
|
+
* those images together with binding, floor/version, browser epoch, audit and FULL old-recipient notices.
|
|
5
|
+
* File journals/signatures cannot substitute for this row. No production caller is composed yet.
|
|
6
|
+
*/
|
|
7
|
+
import { takeHubDirectorySessionRotation } from "./session-directory-transition.js";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { advanceHubSessionEpoch, readHubSessionEpoch } from "./session-epoch.js";
|
|
11
|
+
import { canonicalArguments, sha256 } from "./identity.js";
|
|
12
|
+
import { parseGroupPolicy } from "./group-policy/model.js";
|
|
13
|
+
import { epoch, hash, identifier, person, uuid, validated, parseStrictJson, HubProtocolError } from "./validation.js";
|
|
14
|
+
const imageSchema = z.strictObject({ configDigest: hash, configSha: hash, directorySha: hash, manifestSha: hash, bindSecretSha: hash });
|
|
15
|
+
const actorSchema = z.discriminatedUnion("kind", [
|
|
16
|
+
z.strictObject({ kind: z.literal("hub-administrator"), person, sessionId: identifier, requestId: identifier }),
|
|
17
|
+
z.strictObject({ kind: z.literal("host-owner"), sessionId: identifier, requestId: identifier }),
|
|
18
|
+
]);
|
|
19
|
+
const recipientSchema = z.discriminatedUnion("kind", [
|
|
20
|
+
z.strictObject({ kind: z.literal("host"), sink: identifier }),
|
|
21
|
+
z.strictObject({ kind: z.literal("person"), person }),
|
|
22
|
+
]);
|
|
23
|
+
const recipientsSchema = z.array(recipientSchema).min(1).max(32).refine(rows => rows.some(r => r.kind === "host")
|
|
24
|
+
&& new Set(rows.map(r => canonicalArguments(r))).size === rows.length);
|
|
25
|
+
const changesSchema = z.array(z.enum(["server", "ca", "search", "service-account", "secret", "query"])).min(1).max(6)
|
|
26
|
+
.refine(xs => new Set(xs).size === xs.length);
|
|
27
|
+
const expectationSchema = z.strictObject({ operationId: uuid.nullable(), directoryEpoch: epoch,
|
|
28
|
+
transportRevision: epoch, authorizationVersion: epoch, policySha: hash });
|
|
29
|
+
const requestSchema = z.strictObject({ id: uuid, expected: expectationSchema, before: imageSchema, after: imageSchema,
|
|
30
|
+
generation: identifier, receiptSha: hash, actor: actorSchema, at: epoch,
|
|
31
|
+
changes: changesSchema, recipients: recipientsSchema });
|
|
32
|
+
export function parseHubDirectoryDecisionMetadata(raw) {
|
|
33
|
+
return validated(z.strictObject({ actor: actorSchema, changes: changesSchema, recipients: recipientsSchema }), raw);
|
|
34
|
+
}
|
|
35
|
+
const operationSchema = requestSchema.extend({ kind: z.enum(["directory", "directory-compensation"]),
|
|
36
|
+
compensates: uuid.nullable(), browserSession: z.strictObject({ v: z.literal(1), previousSessionId: identifier, sessionId: identifier }).optional(), previousGeneration: identifier, directoryEpoch: epoch, authorizationVersion: epoch });
|
|
37
|
+
const noticeSchema = z.strictObject({ v: z.literal(1), id: uuid, operationId: uuid,
|
|
38
|
+
kind: z.enum(["directory", "directory-compensation"]), phase: z.literal("applying"),
|
|
39
|
+
actor: actorSchema, at: epoch, changes: changesSchema, recipients: recipientsSchema });
|
|
40
|
+
export const HUB_DIRECTORY_SETTINGS_MIGRATION = Object.freeze({ component: "s5-directory-settings", version: 1, up(db) {
|
|
41
|
+
const tables = ["hub_settings_head", "hub_settings_operations", "hub_settings_security_notices", "hub_settings_security_targets"];
|
|
42
|
+
const present = tables.map(name => !!db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(name));
|
|
43
|
+
if (present.some(Boolean) && !present.every(Boolean))
|
|
44
|
+
throw new HubProtocolError("uncertain");
|
|
45
|
+
if (!present[0]) {
|
|
46
|
+
// An existing authority must never be reconstructed from a missing operation log.
|
|
47
|
+
if (readHubSessionEpoch(db) !== 0)
|
|
48
|
+
throw new HubProtocolError("uncertain");
|
|
49
|
+
db.exec(`CREATE TABLE hub_settings_head(singleton INTEGER PRIMARY KEY CHECK(singleton=1), operation_id TEXT, directory_epoch INTEGER NOT NULL);
|
|
50
|
+
INSERT INTO hub_settings_head VALUES(1,NULL,0);
|
|
51
|
+
CREATE TABLE hub_settings_operations(id TEXT PRIMARY KEY, body TEXT NOT NULL);
|
|
52
|
+
CREATE TABLE hub_settings_security_notices(id TEXT PRIMARY KEY, operation_id TEXT NOT NULL REFERENCES hub_settings_operations(id), body TEXT NOT NULL);
|
|
53
|
+
CREATE TABLE hub_settings_security_targets(notice_id TEXT NOT NULL REFERENCES hub_settings_security_notices(id),
|
|
54
|
+
kind TEXT NOT NULL CHECK(kind IN ('host','person')), target TEXT NOT NULL, state TEXT NOT NULL CHECK(state IN ('queued','delivered')),
|
|
55
|
+
PRIMARY KEY(notice_id,kind,target));`);
|
|
56
|
+
}
|
|
57
|
+
readHubDirectorySettingsHead(db);
|
|
58
|
+
} });
|
|
59
|
+
function operation(db, id) {
|
|
60
|
+
const row = db.prepare("SELECT body FROM hub_settings_operations WHERE id=?").get(id);
|
|
61
|
+
if (!row)
|
|
62
|
+
throw new HubProtocolError("uncertain");
|
|
63
|
+
const result = validated(operationSchema, parseStrictJson(row.body));
|
|
64
|
+
if (result.id !== id)
|
|
65
|
+
throw new HubProtocolError("uncertain");
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/** Durable head only. A mounted server must separately prove its exact installed image matches head.after. */
|
|
69
|
+
export function readHubDirectorySettingsHead(db) {
|
|
70
|
+
try {
|
|
71
|
+
const row = db.prepare("SELECT operation_id, directory_epoch FROM hub_settings_head WHERE singleton=1").get();
|
|
72
|
+
if (!row || !Number.isSafeInteger(row.directory_epoch) || row.directory_epoch !== readHubSessionEpoch(db)
|
|
73
|
+
|| (row.operation_id === null ? row.directory_epoch !== 0 : !uuid.safeParse(row.operation_id).success))
|
|
74
|
+
throw new HubProtocolError("uncertain");
|
|
75
|
+
if (row.operation_id !== null && operation(db, row.operation_id).directoryEpoch !== row.directory_epoch)
|
|
76
|
+
throw new HubProtocolError("uncertain");
|
|
77
|
+
return { operationId: row.operation_id, directoryEpoch: row.directory_epoch };
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
throw new HubProtocolError("uncertain");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function policyRow(db) {
|
|
84
|
+
const row = db.prepare("SELECT hub_id,body FROM hub_group_policy WHERE singleton=1").get();
|
|
85
|
+
if (!row)
|
|
86
|
+
throw new HubProtocolError("uncertain");
|
|
87
|
+
return { ...row, policy: parseGroupPolicy(parseStrictJson(row.body)), sha: sha256(row.body) };
|
|
88
|
+
}
|
|
89
|
+
const same = (a, b) => canonicalArguments(a) === canonicalArguments(b);
|
|
90
|
+
const content = ({ manifestSha: _manifest, ...rest }) => rest;
|
|
91
|
+
const directoryBoundary = ({ directorySha, bindSecretSha }) => ({ directorySha, bindSecretSha });
|
|
92
|
+
const targetRows = (recipients) => recipients.map(r => ({ kind: r.kind,
|
|
93
|
+
target: r.kind === "host" ? r.sink : `${r.person.realm}/${r.person.objectId}`, state: "queued" })).sort((a, b) => canonicalArguments(a).localeCompare(canonicalArguments(b)));
|
|
94
|
+
function synchronous(value) {
|
|
95
|
+
if (value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function") {
|
|
96
|
+
try {
|
|
97
|
+
value.then(undefined, () => undefined);
|
|
98
|
+
}
|
|
99
|
+
catch { /* refused below */ }
|
|
100
|
+
throw new HubProtocolError("invalid");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Internal library, no I/O on construction. The shared writer owns all file installation and proof acquisition. */
|
|
104
|
+
export function createHubDirectorySettingsDecision(deps) {
|
|
105
|
+
const { db, transport } = deps, hubId = validated(identifier, deps.hubId);
|
|
106
|
+
function inspect() {
|
|
107
|
+
const head = readHubDirectorySettingsHead(db), state = transport.read(), p = policyRow(db);
|
|
108
|
+
if (p.hub_id !== hubId)
|
|
109
|
+
throw new HubProtocolError("uncertain");
|
|
110
|
+
return { ...head, transportRevision: state.revision, authorizationVersion: state.revocationVersion, policySha: p.sha };
|
|
111
|
+
}
|
|
112
|
+
function assertExpected(expected) {
|
|
113
|
+
if (!same(inspect(), expected))
|
|
114
|
+
throw new HubProtocolError("conflict");
|
|
115
|
+
}
|
|
116
|
+
function decide(raw, assertProof, compensation, rotation) {
|
|
117
|
+
// Parse clones nested inputs before invoking any caller/audit callback. No mutable request may be published later.
|
|
118
|
+
const input = validated(requestSchema, raw);
|
|
119
|
+
if (db.inTransaction)
|
|
120
|
+
throw new HubProtocolError("invalid"); // this must be the durable root decision, never a savepoint
|
|
121
|
+
const transition = rotation ? takeHubDirectorySessionRotation(rotation, db, hubId, input.actor, input.expected.directoryEpoch) : undefined;
|
|
122
|
+
if (compensation && transition)
|
|
123
|
+
throw new HubProtocolError("invalid");
|
|
124
|
+
const result = db.transaction(() => {
|
|
125
|
+
synchronous(assertProof());
|
|
126
|
+
assertExpected(input.expected);
|
|
127
|
+
transition?.validate(transition.clock());
|
|
128
|
+
const previous = policyRow(db), policy = previous.policy;
|
|
129
|
+
if (previous.hub_id !== hubId || (input.actor.kind === "hub-administrator" && input.actor.person.realm !== policy.realm))
|
|
130
|
+
throw new HubProtocolError("denied");
|
|
131
|
+
// Cosmetic rename v1 may have resealed the full Hub since the last directory decision. Its directory/secret
|
|
132
|
+
// authority is unchanged; the shared writer separately verifies and CASes the exact current complete pair.
|
|
133
|
+
if (input.expected.operationId !== null && !same(directoryBoundary(operation(db, input.expected.operationId).after), directoryBoundary(input.before)))
|
|
134
|
+
throw new HubProtocolError("conflict");
|
|
135
|
+
if (same(input.before, input.after) || policy.revision === Number.MAX_SAFE_INTEGER)
|
|
136
|
+
throw new HubProtocolError("invalid");
|
|
137
|
+
if (compensation && (compensation.kind !== "directory" || input.expected.operationId !== compensation.id
|
|
138
|
+
|| !same(input.before, compensation.after)
|
|
139
|
+
|| !same(content(input.after), content(compensation.before)) || input.generation !== compensation.previousGeneration
|
|
140
|
+
|| !same(input.recipients, compensation.recipients) || !same(input.actor, compensation.actor)
|
|
141
|
+
|| !same(input.changes, compensation.changes)))
|
|
142
|
+
throw new HubProtocolError("conflict");
|
|
143
|
+
const nextPolicy = { ...policy, generation: input.generation, revision: policy.revision + 1 };
|
|
144
|
+
const nextEpoch = input.expected.directoryEpoch + 1, nextVersion = input.expected.authorizationVersion + 1;
|
|
145
|
+
if (!Number.isSafeInteger(nextEpoch) || !Number.isSafeInteger(nextVersion))
|
|
146
|
+
throw new HubProtocolError("unavailable");
|
|
147
|
+
const saved = validated(operationSchema, { ...input, kind: compensation ? "directory-compensation" : "directory",
|
|
148
|
+
compensates: compensation?.id ?? null, ...(transition ? { browserSession: transition.declaration } : {}), previousGeneration: policy.generation, directoryEpoch: nextEpoch, authorizationVersion: nextVersion });
|
|
149
|
+
const notice = validated(noticeSchema, { v: 1, id: randomUUID(), operationId: input.id, kind: saved.kind, phase: "applying",
|
|
150
|
+
actor: input.actor, at: input.at, changes: input.changes, recipients: input.recipients });
|
|
151
|
+
transport.mutate({ at: input.at, requestId: input.actor.requestId,
|
|
152
|
+
actor: input.actor.kind === "host-owner" ? { kind: "local-host" } : { kind: "person", person: input.actor.person },
|
|
153
|
+
action: `settings.${saved.kind}-committed`, result: "completed", reasonCode: input.receiptSha }, (state, owningDb) => {
|
|
154
|
+
if (owningDb !== db || !db.inTransaction)
|
|
155
|
+
throw new HubProtocolError("invalid");
|
|
156
|
+
assertExpected(input.expected);
|
|
157
|
+
state.revocationVersion = nextVersion;
|
|
158
|
+
// Cancel unfinished self-service reservations; never restore work or alter retained credential/provenance rows.
|
|
159
|
+
for (const pairing of state.pairings)
|
|
160
|
+
if (pairing.automatic && ["offered", "pending"].includes(pairing.state)) {
|
|
161
|
+
pairing.state = "revoked";
|
|
162
|
+
pairing.codeHash = null;
|
|
163
|
+
pairing.claimHash = null;
|
|
164
|
+
}
|
|
165
|
+
db.prepare("UPDATE hub_group_policy SET body=? WHERE singleton=1 AND hub_id=? AND body=?")
|
|
166
|
+
.run(JSON.stringify(parseGroupPolicy(nextPolicy)), hubId, previous.body);
|
|
167
|
+
db.prepare("INSERT INTO hub_settings_operations VALUES(?,?)").run(input.id, JSON.stringify(saved));
|
|
168
|
+
db.prepare("INSERT INTO hub_settings_security_notices VALUES(?,?,?)").run(notice.id, input.id, JSON.stringify(notice));
|
|
169
|
+
for (const target of targetRows(notice.recipients))
|
|
170
|
+
db.prepare("INSERT INTO hub_settings_security_targets VALUES(?,?,?,'queued')").run(notice.id, target.kind, target.target);
|
|
171
|
+
}); // existing floor-before-audit and same-DB write; any later rollback leaves a raised floor uncertain
|
|
172
|
+
const finalProof = assertProof();
|
|
173
|
+
synchronous(finalProof);
|
|
174
|
+
// The shared writer returns its last clock sample, avoiding another callback after its final material/time check.
|
|
175
|
+
const transitionTime = typeof finalProof === "number" ? finalProof : transition?.clock();
|
|
176
|
+
// Audit/proof callbacks may reenter. Recheck every authority image before the final callback-free transition.
|
|
177
|
+
const state = transport.read(), latestPolicy = policyRow(db);
|
|
178
|
+
const storedNotice = db.prepare("SELECT body FROM hub_settings_security_notices WHERE id=? AND operation_id=?")
|
|
179
|
+
.get(notice.id, input.id);
|
|
180
|
+
if (state.revision !== input.expected.transportRevision + 1 || state.revocationVersion !== nextVersion
|
|
181
|
+
|| !same(latestPolicy.policy, nextPolicy) || latestPolicy.hub_id !== hubId
|
|
182
|
+
|| !same(readHubDirectorySettingsHead(db), { operationId: input.expected.operationId, directoryEpoch: input.expected.directoryEpoch })
|
|
183
|
+
|| !same(operation(db, input.id), saved) || !storedNotice
|
|
184
|
+
|| !same(validated(noticeSchema, parseStrictJson(storedNotice.body)), notice)
|
|
185
|
+
|| !same(db.prepare("SELECT kind,target,state FROM hub_settings_security_targets WHERE notice_id=?").all(notice.id)
|
|
186
|
+
.sort((a, b) => canonicalArguments(a).localeCompare(canonicalArguments(b))), targetRows(notice.recipients)))
|
|
187
|
+
throw new HubProtocolError("conflict");
|
|
188
|
+
const successor = transition?.validate(transitionTime);
|
|
189
|
+
if (advanceHubSessionEpoch(db, input.expected.directoryEpoch) !== nextEpoch)
|
|
190
|
+
throw new HubProtocolError("uncertain");
|
|
191
|
+
if (successor)
|
|
192
|
+
db.prepare("INSERT INTO hub_sessions(token_hash,id,person,created_at,seen_at,expires_at,state,directory_epoch) VALUES(?,?,?,?,?,?,'active',?)")
|
|
193
|
+
.run(successor.tokenHash, successor.id, successor.person, successor.at, successor.at, successor.expiresAt, nextEpoch);
|
|
194
|
+
const changed = db.prepare("UPDATE hub_settings_head SET operation_id=?,directory_epoch=? WHERE singleton=1 AND directory_epoch=? AND operation_id IS ?")
|
|
195
|
+
.run(input.id, nextEpoch, input.expected.directoryEpoch, input.expected.operationId);
|
|
196
|
+
if (changed.changes !== 1)
|
|
197
|
+
throw new HubProtocolError("conflict");
|
|
198
|
+
return saved;
|
|
199
|
+
}).immediate();
|
|
200
|
+
transition?.committed(result);
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
hubId,
|
|
205
|
+
inspect,
|
|
206
|
+
decide(raw, assertProof, rotation) { return decide(raw, assertProof, undefined, rotation); },
|
|
207
|
+
/** A new operation restoring ONLY original content; current policy/denies/revokes/provenance are never rewound. */
|
|
208
|
+
compensate(originalId, raw, assertPreauthorizedIntent) {
|
|
209
|
+
const original = operation(db, validated(uuid, originalId));
|
|
210
|
+
return decide(raw, assertPreauthorizedIntent, original);
|
|
211
|
+
},
|
|
212
|
+
operation(id) { return operation(db, validated(uuid, id)); },
|
|
213
|
+
/** Absence is meaningful only while floor/head authority is readable; uncertainty is never treated as no decision. */
|
|
214
|
+
lookup(id) {
|
|
215
|
+
validated(uuid, id);
|
|
216
|
+
inspect();
|
|
217
|
+
return db.prepare("SELECT 1 FROM hub_settings_operations WHERE id=?").get(id) ? operation(db, id) : null;
|
|
218
|
+
},
|
|
219
|
+
/** Own startup/remount verifies files/seal first, then checks this barrier before admitting any effect. */
|
|
220
|
+
imageCurrent(raw) {
|
|
221
|
+
const image = validated(imageSchema, raw), head = inspect();
|
|
222
|
+
return head.operationId === null || same(directoryBoundary(operation(db, head.operationId).after), directoryBoundary(image));
|
|
223
|
+
},
|
|
224
|
+
notices() {
|
|
225
|
+
inspect();
|
|
226
|
+
return db.prepare("SELECT id,operation_id,body FROM hub_settings_security_notices ORDER BY rowid").all()
|
|
227
|
+
.map(row => {
|
|
228
|
+
const notice = validated(noticeSchema, parseStrictJson(row.body));
|
|
229
|
+
if (notice.id !== row.id || notice.operationId !== row.operation_id)
|
|
230
|
+
throw new HubProtocolError("uncertain");
|
|
231
|
+
return notice;
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=settings-directory-decision.js.map
|