@inflatable-cookie/longhorn 0.5.0 → 0.7.0
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/README.md +2 -2
- package/package.json +1 -7
- package/src/agent-control/generated/protocol.ts +228 -0
- package/src/agent-control/index.ts +1 -5
- package/src/agent-control/inject.ts +4 -1
- package/src/agent-control/selection.ts +42 -25
- package/src/agent-control/shim.ts +428 -198
- package/src/bridge/direct.ts +1 -1
- package/src/bridge/generated/fields.ts +4 -3
- package/src/bridge/generated/protocol.ts +62 -7
- package/src/bridge/generated/variant-fields.ts +1 -1
- package/src/bridge/job.ts +49 -12
- package/src/bridge/loopback.ts +7 -25
- package/src/bridge/operation.ts +13 -43
- package/src/bridge/router.ts +10 -23
- package/src/bridge/runtime/connection.ts +78 -109
- package/src/bridge/runtime/policy.ts +8 -28
- package/src/bridge/runtime/retry.ts +6 -18
- package/src/bridge/session.ts +4 -14
- package/src/bridge/stream/connection.ts +24 -55
- package/src/bridge/stream/source.ts +2 -6
- package/src/bridge/stream/tracker.ts +12 -12
- package/src/bridge/supervision.ts +104 -97
- package/src/bridge/validation/base.ts +21 -63
- package/src/bridge/validation/jobs.ts +11 -25
- package/src/bridge/validation/negotiation.ts +28 -43
- package/src/bridge/validation/operations.ts +29 -65
- package/src/bridge/validation/streams.ts +3 -10
- package/src/commands/client.ts +37 -28
- package/src/commands/controller.ts +119 -96
- package/src/commands/generated/fields.ts +7 -6
- package/src/commands/generated/protocol.ts +28 -1
- package/src/commands/generated/variant-fields.ts +1 -1
- package/src/commands/keyboard.ts +94 -100
- package/src/commands/physical-code.ts +11 -0
- package/src/commands/ports.ts +8 -13
- package/src/commands/projectors.ts +100 -75
- package/src/commands/validation.ts +434 -241
- package/src/config/client.ts +9 -22
- package/src/config/generated/base.ts +22 -6
- package/src/config/generated/fields.ts +4 -3
- package/src/config/generated/label-template.ts +1 -1
- package/src/config/generated/labels.ts +1 -1
- package/src/config/generated/protocol.ts +1 -1
- package/src/config/generated/restore.ts +35 -12
- package/src/config/generated/variant-fields.ts +1 -1
- package/src/config/names.ts +6 -12
- package/src/config/validation/commands.ts +11 -25
- package/src/config/validation/outcomes.ts +163 -70
- package/src/config/validation/primitives.ts +35 -80
- package/src/config/validation/projection.ts +100 -128
- package/src/core/connection.ts +187 -83
- package/src/core/controller-lifecycle.ts +144 -0
- package/src/core/generated/identifiers.ts +4 -0
- package/src/core/identifiers.ts +40 -0
- package/src/core/index.ts +10 -1
- package/src/core/json-value.ts +58 -0
- package/src/core/listeners.ts +35 -0
- package/src/core/record.ts +80 -0
- package/src/core/transport.ts +9 -11
- package/src/core/wire-copy.ts +7 -0
- package/src/history/client.ts +11 -13
- package/src/history/controller.ts +106 -108
- package/src/history/direct.ts +1 -3
- package/src/history/generated/fields.ts +4 -3
- package/src/history/generated/protocol.ts +8 -5
- package/src/history/generated/variant-fields.ts +1 -1
- package/src/history/ports.ts +7 -4
- package/src/history/serialized.ts +9 -13
- package/src/history/validation.ts +69 -75
- package/src/history-tree/client.ts +89 -11
- package/src/history-tree/controller.ts +380 -96
- package/src/history-tree/direct.ts +3 -1
- package/src/history-tree/generated/fields.ts +5 -3
- package/src/history-tree/generated/protocol.ts +43 -7
- package/src/history-tree/generated/variant-fields.ts +7 -1
- package/src/history-tree/ports.ts +12 -5
- package/src/history-tree/serialized.ts +39 -11
- package/src/history-tree/validation.ts +286 -78
- package/src/layout/generated/protocol.ts +4 -3
- package/src/layout/generated/variant-fields.ts +47 -0
- package/src/layout/index.ts +1 -1
- package/src/layout/ratio.ts +10 -9
- package/src/layout/validation.ts +98 -32
- package/src/layout/visibility.ts +1 -2
- package/src/licence/client.ts +48 -7
- package/src/licence/controller.ts +127 -70
- package/src/licence/direct.ts +3 -1
- package/src/licence/generated/fields.ts +4 -3
- package/src/licence/generated/key-conformance.json +28 -0
- package/src/licence/generated/protocol.ts +9 -5
- package/src/licence/generated/variant-fields.ts +1 -1
- package/src/licence/key.ts +42 -18
- package/src/licence/ports.ts +10 -3
- package/src/licence/serialized.ts +32 -9
- package/src/licence/validation.ts +134 -43
- package/src/native-content/client.ts +207 -234
- package/src/native-content/generated/fields.ts +6 -6
- package/src/native-content/generated/protocol.ts +16 -5
- package/src/native-content/generated/variant-fields.ts +1 -1
- package/src/native-content/ports.ts +11 -16
- package/src/native-content/serialized.ts +12 -19
- package/src/native-content/validation/base.ts +57 -80
- package/src/native-content/validation/messages.ts +24 -35
- package/src/native-content/validation/state.ts +31 -33
- package/src/notifications/client.ts +85 -51
- package/src/notifications/controller.ts +400 -145
- package/src/notifications/direct.ts +3 -1
- package/src/notifications/generated/fields.ts +4 -3
- package/src/notifications/generated/labels.ts +1 -1
- package/src/notifications/generated/protocol.ts +5 -1
- package/src/notifications/generated/variant-fields.ts +1 -1
- package/src/notifications/ports.ts +9 -4
- package/src/notifications/serialized.ts +11 -9
- package/src/notifications/tone.ts +1 -1
- package/src/notifications/validation.ts +165 -71
- package/src/operation/bridge.ts +187 -60
- package/src/operation/client.ts +48 -62
- package/src/operation/controller.ts +67 -97
- package/src/operation/direct.ts +1 -3
- package/src/operation/generated/fields.ts +4 -3
- package/src/operation/generated/labels.ts +1 -1
- package/src/operation/generated/protocol.ts +5 -1
- package/src/operation/generated/variant-fields.ts +1 -1
- package/src/operation/ports.ts +12 -10
- package/src/operation/serialized.ts +8 -9
- package/src/operation/validation.ts +189 -104
- package/src/settings/client.ts +11 -44
- package/src/settings/connection.ts +35 -53
- package/src/settings/generated/fields.ts +5 -4
- package/src/settings/generated/protocol.ts +14 -5
- package/src/settings/generated/variant-fields.ts +1 -1
- package/src/settings/names.ts +2 -4
- package/src/settings/registry.ts +23 -25
- package/src/settings/validation/authority.ts +21 -19
- package/src/settings/validation/command.ts +22 -41
- package/src/settings/validation/error.ts +2 -8
- package/src/settings/validation/primitives.ts +46 -97
- package/src/settings/validation/projection.ts +8 -24
- package/src/settings/validation/registry.ts +33 -79
- package/src/surface-transfer/client.ts +6 -18
- package/src/surface-transfer/generated/fields.ts +3 -3
- package/src/surface-transfer/generated/protocol.ts +3 -3
- package/src/surface-transfer/generated/variant-fields.ts +1 -1
- package/src/surface-transfer/validation.ts +91 -86
- package/src/surfaces/client.ts +33 -55
- package/src/surfaces/generated/fields.ts +3 -3
- package/src/surfaces/generated/protocol.ts +1 -1
- package/src/surfaces/generated/variant-fields.ts +1 -1
- package/src/surfaces/validation.ts +227 -99
- package/src/transfer/client.ts +26 -60
- package/src/transfer/connection.ts +29 -51
- package/src/transfer/generated/fields.ts +7 -6
- package/src/transfer/generated/protocol.ts +13 -5
- package/src/transfer/generated/variant-fields.ts +1 -1
- package/src/transfer/index.ts +8 -1
- package/src/transfer/payload.ts +20 -35
- package/src/transfer/validation.ts +169 -119
- package/src/update/client.ts +86 -9
- package/src/update/controller.ts +264 -116
- package/src/update/direct.ts +3 -1
- package/src/update/generated/fields.ts +5 -4
- package/src/update/generated/protocol.ts +25 -9
- package/src/update/generated/variant-fields.ts +4 -2
- package/src/update/ports.ts +14 -6
- package/src/update/serialized.ts +36 -10
- package/src/update/validation.ts +118 -48
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { isOpaqueId } from "../../core/identifiers.ts";
|
|
2
|
+
import {
|
|
3
|
+
checkWireFields,
|
|
4
|
+
hasHole,
|
|
5
|
+
readWireRecord,
|
|
6
|
+
signed32,
|
|
7
|
+
unsigned32,
|
|
8
|
+
wireVariantFields,
|
|
9
|
+
} from "../../core/record.ts";
|
|
1
10
|
import {
|
|
2
11
|
SETTINGS_VARIANT_FIELDS,
|
|
3
12
|
SETTINGS_VARIANT_FIELDS_DISCRIMINANTS,
|
|
@@ -6,21 +15,10 @@ import { SETTINGS_FIELDS } from "../generated/fields.ts";
|
|
|
6
15
|
import {
|
|
7
16
|
SETTINGS_HARD_MAXIMUM_OPAQUE_VALUE_BYTES,
|
|
8
17
|
SETTINGS_PROTOCOL_VERSION,
|
|
9
|
-
type SettingsOpaqueValue,
|
|
10
18
|
} from "../generated/protocol.ts";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./error.ts";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Kept under its original name so the twenty call sites do not churn, but the
|
|
18
|
-
* value is now the Rust `SettingsLimits::HARD_MAXIMUM_OPAQUE_VALUE_BYTES`
|
|
19
|
-
* rather than a literal that happened to match it.
|
|
20
|
-
*/
|
|
21
|
-
export const HARD_MAXIMUM_OPAQUE_VALUE_BYTES: number =
|
|
22
|
-
SETTINGS_HARD_MAXIMUM_OPAQUE_VALUE_BYTES;
|
|
23
|
-
const OPAQUE_ID = /^[a-z0-9][a-z0-9._:/-]{0,254}$/;
|
|
19
|
+
import type { SettingsOpaqueValue } from "../generated/protocol.ts";
|
|
20
|
+
import { incompatible } from "./error.ts";
|
|
21
|
+
import type { SettingsProtocolValidationCode } from "./error.ts";
|
|
24
22
|
|
|
25
23
|
export function authority(value: unknown): void {
|
|
26
24
|
const valueRecord = record(value, SETTINGS_FIELDS.SettingsAuthorityExpectation);
|
|
@@ -35,12 +33,11 @@ export function optionalOpaque(value: unknown, maximum: number): void {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
export function opaque(
|
|
39
|
-
value: unknown,
|
|
40
|
-
maximum: number,
|
|
41
|
-
): asserts value is SettingsOpaqueValue {
|
|
36
|
+
export function opaque(value: unknown, maximum: number): asserts value is SettingsOpaqueValue {
|
|
42
37
|
const envelope = record(value, SETTINGS_FIELDS.SettingsOpaqueValue);
|
|
43
|
-
|
|
38
|
+
if (!unsigned32(envelope.codecVersion) || envelope.codecVersion === 0) {
|
|
39
|
+
incompatible("invalid_opaque_value", envelope.codecVersion);
|
|
40
|
+
}
|
|
44
41
|
let encoded: string | undefined;
|
|
45
42
|
try {
|
|
46
43
|
encoded = JSON.stringify(envelope);
|
|
@@ -51,23 +48,23 @@ export function opaque(
|
|
|
51
48
|
incompatible("invalid_opaque_value", value);
|
|
52
49
|
}
|
|
53
50
|
const bytes = new TextEncoder().encode(encoded).byteLength;
|
|
54
|
-
if (bytes > maximum || bytes >
|
|
51
|
+
if (bytes > maximum || bytes > SETTINGS_HARD_MAXIMUM_OPAQUE_VALUE_BYTES) {
|
|
55
52
|
incompatible("opaque_value_too_large", bytes);
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
export function definition(value: unknown): void {
|
|
60
|
-
const valueRecord = record(value);
|
|
56
|
+
export function definition(value: unknown, allowed: ReadonlyArray<string>): void {
|
|
57
|
+
const valueRecord = record(value, allowed);
|
|
61
58
|
identity(valueRecord.id);
|
|
62
59
|
identity(valueRecord.moduleId);
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
export function arraysOfIdentities(...values: unknown
|
|
62
|
+
export function arraysOfIdentities(...values: Array<unknown>): void {
|
|
66
63
|
values.forEach((value) => array(value).forEach(identity));
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
export function identity(value: unknown):
|
|
70
|
-
if (
|
|
66
|
+
export function identity(value: unknown): asserts value is string {
|
|
67
|
+
if (!isOpaqueId(value)) {
|
|
71
68
|
incompatible("invalid_identity", value);
|
|
72
69
|
}
|
|
73
70
|
}
|
|
@@ -78,7 +75,7 @@ export function protocolVersion(value: unknown): void {
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
export function known(value: unknown, choices:
|
|
78
|
+
export function known(value: unknown, choices: ReadonlyArray<string>): void {
|
|
82
79
|
if (typeof value !== "string" || !choices.includes(value)) {
|
|
83
80
|
incompatible("unknown_discriminant", value);
|
|
84
81
|
}
|
|
@@ -100,31 +97,21 @@ export function boolean(value: unknown): void {
|
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
99
|
|
|
103
|
-
export function
|
|
104
|
-
if (
|
|
100
|
+
export function order(value: unknown): void {
|
|
101
|
+
if (!signed32(value)) {
|
|
105
102
|
incompatible("invalid_shape", value);
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
export function positive(
|
|
110
|
-
value: unknown,
|
|
111
|
-
code: SettingsProtocolValidationCode,
|
|
112
|
-
): void {
|
|
106
|
+
export function positive(value: unknown, code: SettingsProtocolValidationCode): void {
|
|
113
107
|
unsigned(value, code);
|
|
114
108
|
if (value === 0) {
|
|
115
109
|
incompatible(code, value);
|
|
116
110
|
}
|
|
117
111
|
}
|
|
118
112
|
|
|
119
|
-
export function unsigned(
|
|
120
|
-
value
|
|
121
|
-
code: SettingsProtocolValidationCode,
|
|
122
|
-
): void {
|
|
123
|
-
if (
|
|
124
|
-
typeof value !== "number" ||
|
|
125
|
-
!Number.isSafeInteger(value) ||
|
|
126
|
-
value < 0
|
|
127
|
-
) {
|
|
113
|
+
export function unsigned(value: unknown, code: SettingsProtocolValidationCode): void {
|
|
114
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
128
115
|
incompatible(code, value);
|
|
129
116
|
}
|
|
130
117
|
}
|
|
@@ -133,71 +120,33 @@ export function boundedArray(
|
|
|
133
120
|
value: unknown,
|
|
134
121
|
maximum: number,
|
|
135
122
|
code: SettingsProtocolValidationCode,
|
|
136
|
-
): unknown
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
incompatible(code,
|
|
123
|
+
): Array<unknown> {
|
|
124
|
+
// Bounds land before work: an oversized list is refused unread.
|
|
125
|
+
if (Array.isArray(value) && value.length > maximum) {
|
|
126
|
+
incompatible(code, value.length);
|
|
140
127
|
}
|
|
141
|
-
return
|
|
128
|
+
return array(value);
|
|
142
129
|
}
|
|
143
130
|
|
|
144
|
-
export function array(value: unknown): unknown
|
|
145
|
-
if (!Array.isArray(value)) {
|
|
131
|
+
export function array(value: unknown): Array<unknown> {
|
|
132
|
+
if (!Array.isArray(value) || hasHole(value)) {
|
|
146
133
|
incompatible("invalid_shape", value);
|
|
147
134
|
}
|
|
148
135
|
return value;
|
|
149
136
|
}
|
|
150
137
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* `allowed` comes from the generated field map, so the keys accepted are the
|
|
155
|
-
* Rust struct's and nothing else — contract 010's Boundary Validation Target.
|
|
156
|
-
* Called without a list, this keeps shape-only behaviour, which is correct
|
|
157
|
-
* for a tagged union and a gap anywhere else.
|
|
158
|
-
*/
|
|
159
|
-
export function record(
|
|
160
|
-
value: unknown,
|
|
161
|
-
allowed?: readonly string[],
|
|
162
|
-
): Record<string, unknown> {
|
|
163
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
164
|
-
incompatible("invalid_shape", value);
|
|
165
|
-
}
|
|
166
|
-
const result = value as Record<string, unknown>;
|
|
167
|
-
if (allowed === undefined) return result;
|
|
168
|
-
|
|
169
|
-
const permitted = new Set(allowed);
|
|
170
|
-
for (const key of Object.keys(result)) {
|
|
171
|
-
if (!permitted.has(key)) {
|
|
172
|
-
incompatible("unknown_field", { key, value });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
for (const key of allowed) {
|
|
176
|
-
if (!(key in result)) {
|
|
177
|
-
incompatible("missing_field", { key, value });
|
|
178
|
-
}
|
|
179
|
-
}
|
|
138
|
+
export function record(value: unknown, allowed?: ReadonlyArray<string>): Record<string, unknown> {
|
|
139
|
+
const result = readWireRecord(value, () => incompatible("invalid_shape", value));
|
|
140
|
+
checkWireFields(result, allowed, (code, key) => incompatible(code, { key, value }));
|
|
180
141
|
return result;
|
|
181
142
|
}
|
|
182
143
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* A missing entry means the generator failed to read the union, not that a
|
|
192
|
-
* caller sent something odd — every caller checks the discriminant with
|
|
193
|
-
* `known()` above this call.
|
|
194
|
-
*/
|
|
195
|
-
export function variantKeys(
|
|
196
|
-
type: string,
|
|
197
|
-
value: Record<string, unknown>,
|
|
198
|
-
): readonly string[] {
|
|
199
|
-
const discriminant = value[SETTINGS_VARIANT_FIELDS_DISCRIMINANTS[type] ?? "kind"];
|
|
200
|
-
const keys = SETTINGS_VARIANT_FIELDS[type]?.[discriminant as string];
|
|
201
|
-
if (keys === undefined) incompatible("unknown_field", { type, discriminant });
|
|
202
|
-
return keys;
|
|
144
|
+
export function variantKeys(type: string, value: Record<string, unknown>): ReadonlyArray<string> {
|
|
145
|
+
return wireVariantFields(
|
|
146
|
+
SETTINGS_VARIANT_FIELDS,
|
|
147
|
+
SETTINGS_VARIANT_FIELDS_DISCRIMINANTS,
|
|
148
|
+
type,
|
|
149
|
+
value,
|
|
150
|
+
(discriminant) => incompatible("unknown_field", { type, discriminant }),
|
|
151
|
+
);
|
|
203
152
|
}
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { SETTINGS_FIELDS } from "../generated/fields.ts";
|
|
2
|
-
import {
|
|
3
|
-
array,
|
|
4
|
-
identity,
|
|
5
|
-
known,
|
|
6
|
-
optionalOpaque,
|
|
7
|
-
record,
|
|
8
|
-
} from "./primitives.ts";
|
|
2
|
+
import { array, identity, known, optionalOpaque, record } from "./primitives.ts";
|
|
9
3
|
|
|
10
|
-
export function
|
|
4
|
+
export function hasPolicyOverride(
|
|
11
5
|
value: unknown,
|
|
12
6
|
maximum: number,
|
|
13
|
-
effects:
|
|
14
|
-
):
|
|
7
|
+
effects: ReadonlyArray<string>,
|
|
8
|
+
): boolean {
|
|
15
9
|
const valueRecord = record(value, SETTINGS_FIELDS.SettingsPolicyProjection);
|
|
16
10
|
identity(valueRecord.sourceId);
|
|
17
11
|
known(valueRecord.effect, effects);
|
|
18
12
|
optionalOpaque(valueRecord.constraints, maximum);
|
|
13
|
+
return valueRecord.effect === "override";
|
|
19
14
|
}
|
|
20
15
|
|
|
21
|
-
export function recovery(
|
|
22
|
-
value: unknown,
|
|
23
|
-
maximum: number,
|
|
24
|
-
codes: readonly string[],
|
|
25
|
-
): void {
|
|
16
|
+
export function recovery(value: unknown, maximum: number, codes: ReadonlyArray<string>): void {
|
|
26
17
|
const valueRecord = record(value, SETTINGS_FIELDS.SettingsRecoveryState);
|
|
27
18
|
known(valueRecord.code, codes);
|
|
28
19
|
optionalOpaque(valueRecord.diagnostic, maximum);
|
|
29
20
|
}
|
|
30
21
|
|
|
31
|
-
export function activation(
|
|
32
|
-
value: unknown,
|
|
33
|
-
states: readonly string[],
|
|
34
|
-
): void {
|
|
22
|
+
export function activation(value: unknown, states: ReadonlyArray<string>): void {
|
|
35
23
|
array(value).forEach((value) => {
|
|
36
24
|
const requirement = record(value, SETTINGS_FIELDS.SettingsActivationRequirement);
|
|
37
25
|
identity(requirement.targetId);
|
|
@@ -39,11 +27,7 @@ export function activation(
|
|
|
39
27
|
});
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
export function rejection(
|
|
43
|
-
value: unknown,
|
|
44
|
-
maximum: number,
|
|
45
|
-
codes: readonly string[],
|
|
46
|
-
): void {
|
|
30
|
+
export function rejection(value: unknown, maximum: number, codes: ReadonlyArray<string>): void {
|
|
47
31
|
const valueRecord = record(value, SETTINGS_FIELDS.SettingsRejection);
|
|
48
32
|
known(valueRecord.code, codes);
|
|
49
33
|
optionalOpaque(valueRecord.diagnostic, maximum);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SETTINGS_FIELDS } from "../generated/fields.ts";
|
|
2
2
|
import {
|
|
3
|
+
SETTINGS_HARD_MAXIMUM_OPAQUE_VALUE_BYTES,
|
|
3
4
|
SETTINGS_MUTATION_TIMINGS,
|
|
4
|
-
type SettingsRegistrySnapshot,
|
|
5
5
|
} from "../generated/protocol.ts";
|
|
6
|
+
import type { SettingsRegistrySnapshot, SettingsLimits } from "../generated/protocol.ts";
|
|
6
7
|
import { incompatible } from "./error.ts";
|
|
7
8
|
import {
|
|
8
9
|
arraysOfIdentities,
|
|
@@ -10,14 +11,13 @@ import {
|
|
|
10
11
|
boundedArray,
|
|
11
12
|
definition,
|
|
12
13
|
identity,
|
|
13
|
-
|
|
14
|
+
order,
|
|
14
15
|
known,
|
|
15
16
|
positive,
|
|
16
17
|
protocolVersion,
|
|
17
18
|
record,
|
|
18
19
|
text,
|
|
19
20
|
unsigned,
|
|
20
|
-
HARD_MAXIMUM_OPAQUE_VALUE_BYTES,
|
|
21
21
|
} from "./primitives.ts";
|
|
22
22
|
|
|
23
23
|
const DIGEST = /^[a-f0-9]{64}$/;
|
|
@@ -32,31 +32,11 @@ export function assertValidSettingsRegistrySnapshot(
|
|
|
32
32
|
incompatible("invalid_registry", registry.digest);
|
|
33
33
|
}
|
|
34
34
|
const limits = settingsLimits(registry.limits);
|
|
35
|
-
const modules = boundedArray(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
const sections = boundedArray(
|
|
41
|
-
registry.sections,
|
|
42
|
-
limits.maximumSections,
|
|
43
|
-
"invalid_registry",
|
|
44
|
-
);
|
|
45
|
-
const pages = boundedArray(
|
|
46
|
-
registry.pages,
|
|
47
|
-
limits.maximumPages,
|
|
48
|
-
"invalid_registry",
|
|
49
|
-
);
|
|
50
|
-
const renderers = boundedArray(
|
|
51
|
-
registry.renderers,
|
|
52
|
-
limits.maximumRenderers,
|
|
53
|
-
"invalid_registry",
|
|
54
|
-
);
|
|
55
|
-
const scopes = boundedArray(
|
|
56
|
-
registry.scopes,
|
|
57
|
-
limits.maximumScopes,
|
|
58
|
-
"invalid_registry",
|
|
59
|
-
);
|
|
35
|
+
const modules = boundedArray(registry.modules, limits.maximumModules, "invalid_registry");
|
|
36
|
+
const sections = boundedArray(registry.sections, limits.maximumSections, "invalid_registry");
|
|
37
|
+
const pages = boundedArray(registry.pages, limits.maximumPages, "invalid_registry");
|
|
38
|
+
const renderers = boundedArray(registry.renderers, limits.maximumRenderers, "invalid_registry");
|
|
39
|
+
const scopes = boundedArray(registry.scopes, limits.maximumScopes, "invalid_registry");
|
|
60
40
|
const applyUnits = boundedArray(
|
|
61
41
|
registry.applyUnits,
|
|
62
42
|
limits.maximumApplyUnits,
|
|
@@ -77,18 +57,18 @@ export function assertValidSettingsRegistrySnapshot(
|
|
|
77
57
|
const module = record(value, SETTINGS_FIELDS.SettingsModuleDefinition);
|
|
78
58
|
identity(module.id);
|
|
79
59
|
text(module.label, limits.maximumLabelBytes);
|
|
80
|
-
|
|
60
|
+
order(module.order);
|
|
81
61
|
});
|
|
82
62
|
sections.forEach((value) => {
|
|
83
63
|
const section = record(value, SETTINGS_FIELDS.SettingsSectionDefinition);
|
|
84
64
|
identity(section.id);
|
|
85
65
|
identity(section.moduleId);
|
|
86
66
|
text(section.label, limits.maximumLabelBytes);
|
|
87
|
-
|
|
67
|
+
order(section.order);
|
|
88
68
|
});
|
|
89
|
-
renderers.forEach(definition);
|
|
90
|
-
scopes.forEach(definition);
|
|
91
|
-
capabilities.forEach(definition);
|
|
69
|
+
renderers.forEach((value) => definition(value, SETTINGS_FIELDS.SettingsRendererDefinition));
|
|
70
|
+
scopes.forEach((value) => definition(value, SETTINGS_FIELDS.SettingsScopeDefinition));
|
|
71
|
+
capabilities.forEach((value) => definition(value, SETTINGS_FIELDS.SettingsCapabilityDefinition));
|
|
92
72
|
applyUnits.forEach((value) => {
|
|
93
73
|
const unit = record(value, SETTINGS_FIELDS.SettingsApplyUnitDefinition);
|
|
94
74
|
identity(unit.id);
|
|
@@ -100,39 +80,26 @@ export function assertValidSettingsRegistrySnapshot(
|
|
|
100
80
|
pages.forEach((value) => validatePage(value, limits));
|
|
101
81
|
}
|
|
102
82
|
|
|
103
|
-
function validatePage(
|
|
104
|
-
value: unknown,
|
|
105
|
-
limits: Record<string, number>,
|
|
106
|
-
): void {
|
|
83
|
+
function validatePage(value: unknown, limits: SettingsLimits): void {
|
|
107
84
|
const page = record(value, SETTINGS_FIELDS.SettingsPageDefinition);
|
|
108
85
|
identity(page.id);
|
|
109
86
|
identity(page.moduleId);
|
|
110
87
|
identity(page.sectionId);
|
|
111
88
|
identity(page.rendererId);
|
|
112
|
-
text(page.label, limits.maximumLabelBytes
|
|
113
|
-
|
|
114
|
-
boundedArray(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
).forEach((keyword) => text(keyword, limits.maximumKeywordBytes!));
|
|
119
|
-
boundedArray(
|
|
120
|
-
page.anchors,
|
|
121
|
-
limits.maximumAnchorsPerPage!,
|
|
122
|
-
"invalid_registry",
|
|
123
|
-
).forEach((value) => {
|
|
89
|
+
text(page.label, limits.maximumLabelBytes);
|
|
90
|
+
order(page.order);
|
|
91
|
+
boundedArray(page.keywords, limits.maximumKeywordsPerPage, "invalid_registry").forEach(
|
|
92
|
+
(keyword) => text(keyword, limits.maximumKeywordBytes),
|
|
93
|
+
);
|
|
94
|
+
boundedArray(page.anchors, limits.maximumAnchorsPerPage, "invalid_registry").forEach((value) => {
|
|
124
95
|
const anchor = record(value, SETTINGS_FIELDS.SettingsAnchorDefinition);
|
|
125
96
|
identity(anchor.id);
|
|
126
97
|
if (anchor.label !== null) {
|
|
127
|
-
text(anchor.label, limits.maximumLabelBytes
|
|
98
|
+
text(anchor.label, limits.maximumLabelBytes);
|
|
128
99
|
}
|
|
129
|
-
|
|
100
|
+
order(anchor.order);
|
|
130
101
|
});
|
|
131
|
-
arraysOfIdentities(
|
|
132
|
-
page.requiredCapabilities,
|
|
133
|
-
page.readableScopeIds,
|
|
134
|
-
page.writableApplyUnitIds,
|
|
135
|
-
);
|
|
102
|
+
arraysOfIdentities(page.requiredCapabilities, page.readableScopeIds, page.writableApplyUnitIds);
|
|
136
103
|
const features = record(page.features, SETTINGS_FIELDS.SettingsPageFeatures);
|
|
137
104
|
boolean(features.reset);
|
|
138
105
|
boolean(features.import);
|
|
@@ -141,30 +108,17 @@ function validatePage(
|
|
|
141
108
|
boolean(features.confirmation);
|
|
142
109
|
}
|
|
143
110
|
|
|
144
|
-
function settingsLimits(value: unknown):
|
|
111
|
+
function settingsLimits(value: unknown): SettingsLimits {
|
|
145
112
|
const limits = record(value, SETTINGS_FIELDS.SettingsLimits);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"maximumSections",
|
|
149
|
-
"maximumPages",
|
|
150
|
-
"maximumRenderers",
|
|
151
|
-
"maximumScopes",
|
|
152
|
-
"maximumApplyUnits",
|
|
153
|
-
"maximumCapabilities",
|
|
154
|
-
"maximumAnchorsPerPage",
|
|
155
|
-
"maximumKeywordsPerPage",
|
|
156
|
-
"maximumLabelBytes",
|
|
157
|
-
"maximumKeywordBytes",
|
|
158
|
-
"maximumOpaqueValueBytes",
|
|
159
|
-
] as const;
|
|
160
|
-
for (const name of names) {
|
|
161
|
-
positive(limits[name], "invalid_registry");
|
|
162
|
-
}
|
|
163
|
-
if (
|
|
164
|
-
(limits.maximumOpaqueValueBytes as number) >
|
|
165
|
-
HARD_MAXIMUM_OPAQUE_VALUE_BYTES
|
|
166
|
-
) {
|
|
113
|
+
assertPositiveLimits(limits);
|
|
114
|
+
if (limits.maximumOpaqueValueBytes > SETTINGS_HARD_MAXIMUM_OPAQUE_VALUE_BYTES) {
|
|
167
115
|
incompatible("invalid_registry", limits.maximumOpaqueValueBytes);
|
|
168
116
|
}
|
|
169
|
-
return limits
|
|
117
|
+
return limits;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function assertPositiveLimits(limits: Record<string, unknown>): asserts limits is SettingsLimits {
|
|
121
|
+
for (const name of SETTINGS_FIELDS.SettingsLimits) {
|
|
122
|
+
positive(limits[name], "invalid_registry");
|
|
123
|
+
}
|
|
170
124
|
}
|
|
@@ -15,10 +15,8 @@ import {
|
|
|
15
15
|
assertValidSurfaceTransferResponse,
|
|
16
16
|
} from "./validation.ts";
|
|
17
17
|
|
|
18
|
-
export const TRANSFER_START_SURFACE_COMMAND =
|
|
19
|
-
|
|
20
|
-
export const TRANSFER_COMMIT_SURFACE_COMMAND =
|
|
21
|
-
"longhorn_transfer_commit_surface";
|
|
18
|
+
export const TRANSFER_START_SURFACE_COMMAND = "longhorn_transfer_start_surface";
|
|
19
|
+
export const TRANSFER_COMMIT_SURFACE_COMMAND = "longhorn_transfer_commit_surface";
|
|
22
20
|
|
|
23
21
|
export class SurfaceTransferClient {
|
|
24
22
|
readonly #transport: InvokeTransport;
|
|
@@ -27,27 +25,17 @@ export class SurfaceTransferClient {
|
|
|
27
25
|
this.#transport = transport;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
async start(
|
|
31
|
-
request: SurfaceSessionStartRequest,
|
|
32
|
-
): Promise<SurfaceSessionResponse> {
|
|
28
|
+
async start(request: SurfaceSessionStartRequest): Promise<SurfaceSessionResponse> {
|
|
33
29
|
assertTransferProtocolVersion(request.protocol_version);
|
|
34
|
-
const value = await this.#transport.invoke(
|
|
35
|
-
TRANSFER_START_SURFACE_COMMAND,
|
|
36
|
-
{ request },
|
|
37
|
-
);
|
|
30
|
+
const value = await this.#transport.invoke(TRANSFER_START_SURFACE_COMMAND, { request });
|
|
38
31
|
assertValidSurfaceSessionResponse(value);
|
|
39
32
|
return value;
|
|
40
33
|
}
|
|
41
34
|
|
|
42
|
-
async commit(
|
|
43
|
-
request: SurfaceTransferCommand,
|
|
44
|
-
): Promise<SurfaceTransferResponse> {
|
|
35
|
+
async commit(request: SurfaceTransferCommand): Promise<SurfaceTransferResponse> {
|
|
45
36
|
assertTransferProtocolVersion(request.protocol_version);
|
|
46
37
|
assertValidTransferCommitSelector(request.selector);
|
|
47
|
-
const value = await this.#transport.invoke(
|
|
48
|
-
TRANSFER_COMMIT_SURFACE_COMMAND,
|
|
49
|
-
{ request },
|
|
50
|
-
);
|
|
38
|
+
const value = await this.#transport.invoke(TRANSFER_COMMIT_SURFACE_COMMAND, { request });
|
|
51
39
|
assertValidSurfaceTransferResponse(value);
|
|
52
40
|
return value;
|
|
53
41
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Allowed field names per protocol type, from the Rust structs.
|
|
3
3
|
// A `record()` given one of these rejects unknown and missing keys —
|
|
4
4
|
// contract 010's Boundary Validation Target.
|
|
5
5
|
|
|
6
|
-
export const SURFACE_TRANSFER_FIELDS
|
|
6
|
+
export const SURFACE_TRANSFER_FIELDS = {
|
|
7
7
|
"SurfaceSessionStartRequest": ["protocol_version", "request_id", "surface_id"],
|
|
8
8
|
"SurfaceTransferCommand": ["protocol_version", "request_id", "session_id", "selector"],
|
|
9
9
|
"SurfaceProvisioningCompletion": ["window_id", "host_binding_id", "display_id"],
|
|
10
10
|
"SurfaceTransferCompletion": ["protocol_version", "request_id", "session_id", "source_host_binding_id", "target_host_binding_id", "previous_revision", "committed_revision", "authoritative_document", "target"],
|
|
11
11
|
"SurfaceTransferAbort": ["protocol_version", "request_id", "source", "surface_code", "message", "retryable", "session_consumed", "reconciliation_required"],
|
|
12
|
-
};
|
|
12
|
+
} as const;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Rust serde types are the wire authority.
|
|
3
3
|
|
|
4
4
|
import type { SurfaceDocument, SurfaceId, SurfaceMutationRejectionCode, SurfaceRevision } from "@inflatable-cookie/longhorn/surfaces";
|
|
@@ -8,11 +8,11 @@ export const SURFACE_TRANSFER_TARGET_KINDS = ["existing","provisioned"] as const
|
|
|
8
8
|
export const SURFACE_TRANSFER_ABORT_DOMAINS = ["transfer","surface_transfer"] as const;
|
|
9
9
|
export const SURFACE_SESSION_RESPONSE_STATUSES = ["started","aborted"] as const;
|
|
10
10
|
export const SURFACE_TRANSFER_RESPONSE_STATUSES = ["committed","aborted"] as const;
|
|
11
|
-
export const SURFACE_TRANSFER_ERROR_CODES = ["invalid_binding_snapshot","unknown_host_binding","stale_host_binding","surface_load_failed","surface_unavailable","unknown_surface","source_changed","unsupported_source","unsupported_target","cross_document","stale_surface_revision","ineligible_target","target_changed","invalid_insertion_position","empty_display_disabled","no_empty_display_target","
|
|
11
|
+
export const SURFACE_TRANSFER_ERROR_CODES = ["invalid_binding_snapshot","unknown_host_binding","stale_host_binding","surface_load_failed","surface_unavailable","unknown_surface","source_changed","unsupported_source","unsupported_target","cross_document","stale_surface_revision","ineligible_target","target_changed","invalid_insertion_position","empty_display_disabled","no_empty_display_target","provision_failed","provision_receipt_mismatch","surface_mutation_rejected","publication_failed","host_reconciliation_required","transfer_rejected"] as const;
|
|
12
12
|
|
|
13
13
|
export type DisplayId = string;
|
|
14
14
|
|
|
15
|
-
export type SurfaceTransferErrorCode = "invalid_binding_snapshot" | "unknown_host_binding" | "stale_host_binding" | "surface_load_failed" | "surface_unavailable" | "unknown_surface" | "source_changed" | "unsupported_source" | "unsupported_target" | "cross_document" | "stale_surface_revision" | "ineligible_target" | "target_changed" | "invalid_insertion_position" | "empty_display_disabled" | "no_empty_display_target" | "
|
|
15
|
+
export type SurfaceTransferErrorCode = "invalid_binding_snapshot" | "unknown_host_binding" | "stale_host_binding" | "surface_load_failed" | "surface_unavailable" | "unknown_surface" | "source_changed" | "unsupported_source" | "unsupported_target" | "cross_document" | "stale_surface_revision" | "ineligible_target" | "target_changed" | "invalid_insertion_position" | "empty_display_disabled" | "no_empty_display_target" | "provision_failed" | "provision_receipt_mismatch" | "surface_mutation_rejected" | "publication_failed" | "host_reconciliation_required" | "transfer_rejected";
|
|
16
16
|
|
|
17
17
|
export type SurfaceSessionStartRequest = { protocol_version: TransferProtocolVersion, request_id: TransferRequestId, surface_id: SurfaceId, };
|
|
18
18
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Allowed field names per tagged-union variant, from the Rust enums.
|
|
3
3
|
// Keyed by type, then by discriminant. The discriminant itself is in
|
|
4
4
|
// each list, because `exact()` compares every key.
|