@inflatable-cookie/longhorn 0.6.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/selection.ts +10 -8
- package/src/agent-control/shim.ts +149 -77
- package/src/bridge/generated/fields.ts +1 -1
- package/src/bridge/generated/protocol.ts +55 -4
- package/src/bridge/generated/variant-fields.ts +1 -1
- package/src/bridge/job.ts +49 -2
- package/src/bridge/runtime/connection.ts +11 -14
- package/src/bridge/stream/connection.ts +14 -23
- package/src/bridge/stream/tracker.ts +5 -0
- package/src/bridge/supervision.ts +102 -80
- package/src/bridge/validation/base.ts +7 -27
- package/src/bridge/validation/negotiation.ts +1 -6
- package/src/bridge/validation/operations.ts +2 -14
- package/src/commands/client.ts +16 -2
- package/src/commands/controller.ts +96 -58
- package/src/commands/generated/fields.ts +4 -4
- package/src/commands/generated/protocol.ts +24 -1
- package/src/commands/generated/variant-fields.ts +1 -1
- package/src/commands/keyboard.ts +4 -13
- package/src/commands/physical-code.ts +11 -0
- package/src/commands/ports.ts +2 -1
- package/src/commands/projectors.ts +52 -29
- package/src/commands/validation.ts +408 -188
- package/src/config/client.ts +3 -3
- package/src/config/generated/base.ts +22 -6
- package/src/config/generated/fields.ts +2 -1
- 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/validation/commands.ts +11 -13
- package/src/config/validation/outcomes.ts +147 -46
- package/src/config/validation/primitives.ts +11 -39
- package/src/config/validation/projection.ts +44 -44
- package/src/core/connection.ts +124 -29
- 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 +76 -0
- package/src/core/transport.ts +10 -1
- package/src/core/wire-copy.ts +1 -0
- package/src/history/client.ts +11 -7
- package/src/history/controller.ts +72 -74
- package/src/history/generated/fields.ts +2 -1
- package/src/history/generated/protocol.ts +8 -5
- package/src/history/generated/variant-fields.ts +1 -1
- package/src/history/ports.ts +7 -2
- package/src/history/validation.ts +15 -37
- package/src/history-tree/client.ts +15 -13
- package/src/history-tree/controller.ts +131 -90
- package/src/history-tree/generated/fields.ts +3 -1
- 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 +9 -4
- package/src/history-tree/validation.ts +44 -35
- package/src/layout/generated/protocol.ts +2 -1
- package/src/layout/generated/variant-fields.ts +47 -0
- package/src/layout/index.ts +1 -1
- package/src/layout/ratio.ts +9 -2
- package/src/layout/validation.ts +88 -13
- package/src/licence/client.ts +11 -7
- package/src/licence/controller.ts +64 -43
- package/src/licence/generated/fields.ts +2 -1
- package/src/licence/generated/protocol.ts +8 -4
- package/src/licence/generated/variant-fields.ts +1 -1
- package/src/licence/key.ts +2 -6
- package/src/licence/ports.ts +7 -2
- package/src/licence/validation.ts +27 -20
- package/src/native-content/client.ts +32 -1
- package/src/native-content/generated/fields.ts +4 -4
- 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 +2 -1
- package/src/native-content/validation/base.ts +16 -46
- package/src/native-content/validation/messages.ts +3 -0
- package/src/notifications/client.ts +17 -39
- package/src/notifications/controller.ts +266 -165
- package/src/notifications/generated/fields.ts +2 -1
- 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 +2 -1
- package/src/notifications/tone.ts +1 -1
- package/src/notifications/validation.ts +41 -51
- package/src/operation/bridge.ts +79 -19
- package/src/operation/client.ts +17 -45
- package/src/operation/controller.ts +38 -59
- package/src/operation/generated/fields.ts +2 -1
- 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 +2 -1
- package/src/operation/validation.ts +48 -50
- package/src/settings/connection.ts +10 -14
- package/src/settings/generated/fields.ts +2 -1
- package/src/settings/generated/protocol.ts +5 -1
- package/src/settings/generated/variant-fields.ts +1 -1
- package/src/settings/validation/authority.ts +2 -2
- package/src/settings/validation/command.ts +5 -4
- package/src/settings/validation/primitives.ts +32 -67
- package/src/settings/validation/registry.ts +13 -11
- package/src/surface-transfer/generated/fields.ts +1 -1
- 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 +76 -53
- package/src/surfaces/client.ts +26 -38
- package/src/surfaces/generated/fields.ts +1 -1
- package/src/surfaces/generated/protocol.ts +1 -1
- package/src/surfaces/generated/variant-fields.ts +1 -1
- package/src/surfaces/validation.ts +198 -61
- package/src/transfer/connection.ts +25 -39
- package/src/transfer/generated/fields.ts +2 -1
- package/src/transfer/generated/protocol.ts +9 -1
- package/src/transfer/generated/variant-fields.ts +1 -1
- package/src/transfer/index.ts +8 -1
- package/src/transfer/payload.ts +12 -9
- package/src/transfer/validation.ts +146 -60
- package/src/update/client.ts +43 -16
- package/src/update/controller.ts +187 -104
- package/src/update/generated/fields.ts +2 -1
- package/src/update/generated/protocol.ts +19 -7
- package/src/update/generated/variant-fields.ts +3 -2
- package/src/update/ports.ts +11 -7
- package/src/update/serialized.ts +8 -6
- package/src/update/validation.ts +18 -28
package/src/licence/ports.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ConnectionFailureReporter } from "../core/connection.ts";
|
|
2
|
+
import type { Unlisten } from "../core/transport.ts";
|
|
1
3
|
import type {
|
|
2
4
|
LicenceActivateCommand,
|
|
3
5
|
LicenceChangedEvent,
|
|
@@ -9,7 +11,7 @@ import type {
|
|
|
9
11
|
LicenceSnapshot,
|
|
10
12
|
} from "./generated/protocol.ts";
|
|
11
13
|
|
|
12
|
-
export type LicenceUnlisten =
|
|
14
|
+
export type LicenceUnlisten = Unlisten;
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* The raw seam.
|
|
@@ -37,5 +39,8 @@ export interface CheckedLicencePort {
|
|
|
37
39
|
refresh(command: LicenceRefreshCommand): Promise<LicenceOutcomeProjection>;
|
|
38
40
|
releaseSeat(command: LicenceReleaseSeatCommand): Promise<LicenceOutcomeProjection>;
|
|
39
41
|
renameSeat(command: LicenceRenameSeatCommand): Promise<LicenceOutcomeProjection>;
|
|
40
|
-
listen(
|
|
42
|
+
listen(
|
|
43
|
+
listener: (event: LicenceChangedEvent) => void,
|
|
44
|
+
onFailure?: ConnectionFailureReporter,
|
|
45
|
+
): Promise<LicenceUnlisten>;
|
|
41
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkWireFields, readWireRecord, wireVariantFields } from "../core/record.ts";
|
|
2
2
|
import { LICENCE_FIELDS } from "./generated/fields.ts";
|
|
3
3
|
import {
|
|
4
4
|
LICENCE_CHANGED_KINDS,
|
|
@@ -40,8 +40,7 @@ export function assertLicenceSnapshot(value: unknown): asserts value is LicenceS
|
|
|
40
40
|
exact(root, "$", LICENCE_FIELDS.LicenceSnapshot);
|
|
41
41
|
protocol(root.protocolVersion, "$.protocolVersion");
|
|
42
42
|
positive(root.authorityEpoch, "$.authorityEpoch");
|
|
43
|
-
//
|
|
44
|
-
// licence that cannot be used. Card 193 kept those apart deliberately.
|
|
43
|
+
// A held licence reports its usability even when that usability is blocked.
|
|
45
44
|
if (root.licence !== null) {
|
|
46
45
|
held(root.licence, "$.licence");
|
|
47
46
|
}
|
|
@@ -88,7 +87,7 @@ export function assertLicenceActivateCommand(
|
|
|
88
87
|
nonEmpty(credential.token, "$.credential.token");
|
|
89
88
|
}
|
|
90
89
|
if (credential.kind === "licenceFile") {
|
|
91
|
-
|
|
90
|
+
base64(credential.contentsBase64, "$.credential.contentsBase64");
|
|
92
91
|
}
|
|
93
92
|
// The label a customer gives this machine, asked for at the only moment it
|
|
94
93
|
// can be without inventing a settings screen. Absent is fine.
|
|
@@ -231,20 +230,18 @@ function variantFields(
|
|
|
231
230
|
value: Record<string, unknown>,
|
|
232
231
|
path: string,
|
|
233
232
|
): ReadonlyArray<string> {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
return wireVariantFields(
|
|
234
|
+
LICENCE_VARIANT_FIELDS,
|
|
235
|
+
LICENCE_VARIANT_FIELDS_DISCRIMINANTS,
|
|
236
|
+
type,
|
|
237
|
+
value,
|
|
238
|
+
(discriminant) => fail(path, `no generated fields for ${type}.${String(discriminant)}`),
|
|
239
|
+
);
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
function object(value: unknown, path: string): Record<string, unknown> {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
return value;
|
|
243
|
+
const result = readWireRecord(value, () => fail(path, "expected object"));
|
|
244
|
+
return result;
|
|
248
245
|
}
|
|
249
246
|
function array(value: unknown, path: string): Array<unknown> {
|
|
250
247
|
if (!Array.isArray(value)) {
|
|
@@ -257,11 +254,9 @@ function exact(
|
|
|
257
254
|
path: string,
|
|
258
255
|
expected: ReadonlyArray<string>,
|
|
259
256
|
): void {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
fail(path, `unexpected keys: ${actual.join(",")}`);
|
|
264
|
-
}
|
|
257
|
+
checkWireFields(value, expected, () =>
|
|
258
|
+
fail(path, `unexpected keys: ${Object.keys(value).sort().join(",")}`),
|
|
259
|
+
);
|
|
265
260
|
}
|
|
266
261
|
function protocol(value: unknown, path: string): void {
|
|
267
262
|
if (value !== LICENCE_PROTOCOL_VERSION) {
|
|
@@ -284,6 +279,18 @@ function nonEmpty(value: unknown, path: string): void {
|
|
|
284
279
|
fail(path, "expected a non-empty string");
|
|
285
280
|
}
|
|
286
281
|
}
|
|
282
|
+
function base64(value: unknown, path: string): void {
|
|
283
|
+
string(value, path);
|
|
284
|
+
// Canonical padded standard base64, including zero pad bits.
|
|
285
|
+
if (
|
|
286
|
+
!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value) ||
|
|
287
|
+
value.length === 0 ||
|
|
288
|
+
(value.endsWith("==") && !/[AQgw]==$/.test(value)) ||
|
|
289
|
+
(value.endsWith("=") && !value.endsWith("==") && !/[AEIMQUYcgkosw048]=$/.test(value))
|
|
290
|
+
) {
|
|
291
|
+
fail(path, "expected padded standard base64");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
287
294
|
/** Unix seconds, and negative is a real point in time. */
|
|
288
295
|
function timestamp(value: unknown, path: string): void {
|
|
289
296
|
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
ContentSizeProposal,
|
|
24
24
|
DesiredUpdate,
|
|
25
25
|
NativeContentContentSizeDecisionResult,
|
|
26
|
+
NativeContentCursor,
|
|
26
27
|
NativeContentDesiredUpdateResult,
|
|
27
28
|
NativeContentIslandId,
|
|
28
29
|
NativeContentProtocolRejection,
|
|
@@ -109,7 +110,11 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
109
110
|
this.#connection = new CheckedSnapshotConnection<NativeContentSnapshot>({
|
|
110
111
|
listen: async (receive) => (port.listen === undefined ? () => {} : port.listen(receive)),
|
|
111
112
|
loadSnapshot: () => this.#loadSnapshot(),
|
|
112
|
-
validateSnapshot:
|
|
113
|
+
validateSnapshot: (value) => {
|
|
114
|
+
const snapshot = parseSnapshot(value);
|
|
115
|
+
assertIsland(snapshot.cursor, islandId);
|
|
116
|
+
return snapshot;
|
|
117
|
+
},
|
|
113
118
|
handleEvent: (payload, current) => eventAction(payload, current, islandId),
|
|
114
119
|
isNewer: isNewerSessionSnapshot,
|
|
115
120
|
onSnapshot: listener,
|
|
@@ -140,6 +145,7 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
140
145
|
protocol_version: NATIVE_CONTENT_PROTOCOL_VERSION,
|
|
141
146
|
request_id: requestId,
|
|
142
147
|
island_id: this.#islandId,
|
|
148
|
+
authority_epoch: current.cursor.authority_epoch,
|
|
143
149
|
client_epoch: current.cursor.client_epoch,
|
|
144
150
|
expected_desired_revision: current.cursor.desired_revision,
|
|
145
151
|
update,
|
|
@@ -149,6 +155,8 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
149
155
|
assertValidNativeContentDesiredUpdateResult(value);
|
|
150
156
|
assertCorrelation(value.request_id, requestId);
|
|
151
157
|
if (value.status === "committed") {
|
|
158
|
+
assertIsland(value.event.cursor, this.#islandId);
|
|
159
|
+
assertIsland(value.snapshot.cursor, this.#islandId);
|
|
152
160
|
this.#connection.offer(value.snapshot);
|
|
153
161
|
}
|
|
154
162
|
return value;
|
|
@@ -168,6 +176,7 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
168
176
|
protocol_version: NATIVE_CONTENT_PROTOCOL_VERSION,
|
|
169
177
|
request_id: requestId,
|
|
170
178
|
island_id: this.#islandId,
|
|
179
|
+
authority_epoch: current.cursor.authority_epoch,
|
|
171
180
|
client_epoch: current.cursor.client_epoch,
|
|
172
181
|
proposal,
|
|
173
182
|
decision,
|
|
@@ -177,6 +186,8 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
177
186
|
assertValidNativeContentDecisionResult(value);
|
|
178
187
|
assertCorrelation(value.request_id, requestId);
|
|
179
188
|
if (value.status === "decided") {
|
|
189
|
+
assertIsland(value.event.cursor, this.#islandId);
|
|
190
|
+
assertIsland(value.snapshot.cursor, this.#islandId);
|
|
180
191
|
this.#connection.offer(value.snapshot);
|
|
181
192
|
}
|
|
182
193
|
return value;
|
|
@@ -230,6 +241,7 @@ class CheckedNativeContentConnection implements NativeContentConnection {
|
|
|
230
241
|
protocol_version: NATIVE_CONTENT_PROTOCOL_VERSION,
|
|
231
242
|
request_id: requestId,
|
|
232
243
|
island_id: this.#islandId,
|
|
244
|
+
authority_epoch: current.cursor.authority_epoch,
|
|
233
245
|
client_epoch: current.cursor.client_epoch,
|
|
234
246
|
};
|
|
235
247
|
assertValidNativeContentSnapshotRequest(request);
|
|
@@ -355,6 +367,13 @@ export function isNewerNativeContentSnapshot(
|
|
|
355
367
|
);
|
|
356
368
|
}
|
|
357
369
|
|
|
370
|
+
/** A host reply that carries state is only accepted for the island that asked. */
|
|
371
|
+
function assertIsland(cursor: NativeContentCursor, expected: NativeContentIslandId): void {
|
|
372
|
+
if (cursor.island_id !== expected) {
|
|
373
|
+
throw new NativeContentIslandCorrelationError(expected, cursor.island_id);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
358
377
|
function assertCorrelation(received: string, expected: string): void {
|
|
359
378
|
if (received !== expected) {
|
|
360
379
|
throw new NativeContentResponseCorrelationError(expected, received);
|
|
@@ -373,6 +392,18 @@ export class NativeContentResponseCorrelationError extends Error {
|
|
|
373
392
|
}
|
|
374
393
|
}
|
|
375
394
|
|
|
395
|
+
export class NativeContentIslandCorrelationError extends Error {
|
|
396
|
+
constructor(
|
|
397
|
+
readonly expectedIslandId: NativeContentIslandId,
|
|
398
|
+
readonly receivedIslandId: NativeContentIslandId,
|
|
399
|
+
) {
|
|
400
|
+
super(
|
|
401
|
+
`native-content reply is for another island: expected ${expectedIslandId}; received ${receivedIslandId}`,
|
|
402
|
+
);
|
|
403
|
+
this.name = "NativeContentIslandCorrelationError";
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
376
407
|
export class NativeContentRequestRejectedError extends Error {
|
|
377
408
|
constructor(readonly rejection: NativeContentProtocolRejection) {
|
|
378
409
|
super(rejection.message);
|
|
@@ -1,4 +1,4 @@
|
|
|
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.
|
|
@@ -25,8 +25,8 @@ export const NATIVE_CONTENT_FIELDS = {
|
|
|
25
25
|
"NativeContentCursor": ["authority_epoch", "client_epoch", "island_id", "attach_generation", "desired_revision", "observed_revision"],
|
|
26
26
|
"NativeContentSnapshot": ["protocol_version", "cursor", "desired", "observed", "invalidated_generation"],
|
|
27
27
|
"NativeContentConnectRequest": ["protocol_version", "request_id", "island_id"],
|
|
28
|
-
"NativeContentSnapshotRequest": ["protocol_version", "request_id", "island_id", "client_epoch"],
|
|
29
|
-
"NativeContentDesiredUpdateRequest": ["protocol_version", "request_id", "island_id", "client_epoch", "expected_desired_revision", "update"],
|
|
30
|
-
"NativeContentContentSizeDecisionRequest": ["protocol_version", "request_id", "island_id", "client_epoch", "proposal", "decision"],
|
|
28
|
+
"NativeContentSnapshotRequest": ["protocol_version", "request_id", "island_id", "authority_epoch", "client_epoch"],
|
|
29
|
+
"NativeContentDesiredUpdateRequest": ["protocol_version", "request_id", "island_id", "authority_epoch", "client_epoch", "expected_desired_revision", "update"],
|
|
30
|
+
"NativeContentContentSizeDecisionRequest": ["protocol_version", "request_id", "island_id", "authority_epoch", "client_epoch", "proposal", "decision"],
|
|
31
31
|
"NativeContentChangedEvent": ["protocol_version", "cursor", "change"],
|
|
32
32
|
} as const;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// @generated by `effigy generate:
|
|
1
|
+
// @generated by `effigy generate:bindings`; do not edit.
|
|
2
2
|
// Rust serde types are the wire authority. Browser, plugin, GPU, and product payloads are absent.
|
|
3
3
|
|
|
4
|
-
export const NATIVE_CONTENT_PROTOCOL_VERSION =
|
|
5
|
-
export const NATIVE_CONTENT_MAXIMUM_OPAQUE_ID_BYTES = 128 as const;
|
|
4
|
+
export const NATIVE_CONTENT_PROTOCOL_VERSION = 2 as const;
|
|
6
5
|
export const NATIVE_CONTENT_MECHANISMS = ["child_view","isolated_window","backing_surface"] as const;
|
|
7
6
|
export const NATIVE_CONTENT_DETACH_POLICIES = ["reversible","owner_process_termination","process_lifetime"] as const;
|
|
8
7
|
export const NATIVE_CONTENT_INPUT_ROUTING_MODES = ["native_direct","renderer_forwarded","disabled"] as const;
|
|
@@ -18,7 +17,7 @@ export const NATIVE_CONTENT_OPERATION_KINDS = ["attach","set_child_bounds","set_
|
|
|
18
17
|
export const NATIVE_CONTENT_OPERATION_OUTCOME_KINDS = ["applied","failed","dependency_skipped","not_attempted"] as const;
|
|
19
18
|
export const NATIVE_CONTENT_SIZE_DECISION_KINDS = ["accepted","constrained","rejected"] as const;
|
|
20
19
|
export const NATIVE_CONTENT_HOST_DESTROY_OUTCOMES = ["invalidated","already_invalidated"] as const;
|
|
21
|
-
export const NATIVE_CONTENT_REJECTION_CODES = ["unsupported_protocol_version","island_mismatch","stale_client_epoch","future_client_epoch","client_epoch_exhausted","stale_revision","stale_attach_generation","future_attach_generation","attach_generation_gap","generation_still_attached","host_change_requires_generation","host_binding_mismatch","illegal_lifecycle_transition","terminal_generation","invalidated_generation","lifecycle_busy","geometry_mechanism_mismatch","unsupported_visibility_observation","unsupported_focus_observation","unsupported_input_routing","readiness_without_attachment","absent_with_native_evidence","content_size_requests_unsupported","viewport_conversion","revision_exhausted","attach_generation_exhausted","receipt_island_mismatch","receipt_stale_desired","receipt_stale_observed","receipt_invalid_generation","receipt_unknown_step","receipt_duplicate_step","receipt_blocked_dependency"] as const;
|
|
20
|
+
export const NATIVE_CONTENT_REJECTION_CODES = ["unsupported_protocol_version","island_mismatch","authority_epoch_mismatch","stale_client_epoch","future_client_epoch","client_epoch_exhausted","stale_revision","stale_attach_generation","future_attach_generation","attach_generation_gap","generation_still_attached","host_change_requires_generation","host_binding_mismatch","illegal_lifecycle_transition","terminal_generation","invalidated_generation","lifecycle_busy","geometry_mechanism_mismatch","unsupported_visibility_observation","unsupported_focus_observation","unsupported_input_routing","readiness_without_attachment","absent_with_native_evidence","content_size_requests_unsupported","viewport_conversion","revision_exhausted","attach_generation_exhausted","receipt_island_mismatch","receipt_stale_desired","receipt_stale_observed","receipt_invalid_generation","receipt_unknown_step","receipt_duplicate_step","receipt_blocked_dependency"] as const;
|
|
22
21
|
export const NATIVE_CONTENT_FAILURE_PHASES = ["compatibility","admission","coordination"] as const;
|
|
23
22
|
export const NATIVE_CONTENT_RETRY_CLASSES = ["never","refresh"] as const;
|
|
24
23
|
export const NATIVE_CONTENT_CONNECT_STATUSES = ["connected","rejected"] as const;
|
|
@@ -189,7 +188,7 @@ export type HostDestroyOutcome = "invalidated" | "already_invalidated";
|
|
|
189
188
|
|
|
190
189
|
export type HostDestroyReceipt = { previous_observed_revision: NativeContentRevision, current_observed_revision: NativeContentRevision, generation: AttachGeneration, outcome: HostDestroyOutcome, };
|
|
191
190
|
|
|
192
|
-
export type NativeContentRejectionCode = "unsupported_protocol_version" | "island_mismatch" | "stale_client_epoch" | "future_client_epoch" | "client_epoch_exhausted" | "stale_revision" | "stale_attach_generation" | "future_attach_generation" | "attach_generation_gap" | "generation_still_attached" | "host_change_requires_generation" | "host_binding_mismatch" | "illegal_lifecycle_transition" | "terminal_generation" | "invalidated_generation" | "lifecycle_busy" | "geometry_mechanism_mismatch" | "unsupported_visibility_observation" | "unsupported_focus_observation" | "unsupported_input_routing" | "readiness_without_attachment" | "absent_with_native_evidence" | "content_size_requests_unsupported" | "viewport_conversion" | "revision_exhausted" | "attach_generation_exhausted" | "receipt_island_mismatch" | "receipt_stale_desired" | "receipt_stale_observed" | "receipt_invalid_generation" | "receipt_unknown_step" | "receipt_duplicate_step" | "receipt_blocked_dependency";
|
|
191
|
+
export type NativeContentRejectionCode = "unsupported_protocol_version" | "island_mismatch" | "authority_epoch_mismatch" | "stale_client_epoch" | "future_client_epoch" | "client_epoch_exhausted" | "stale_revision" | "stale_attach_generation" | "future_attach_generation" | "attach_generation_gap" | "generation_still_attached" | "host_change_requires_generation" | "host_binding_mismatch" | "illegal_lifecycle_transition" | "terminal_generation" | "invalidated_generation" | "lifecycle_busy" | "geometry_mechanism_mismatch" | "unsupported_visibility_observation" | "unsupported_focus_observation" | "unsupported_input_routing" | "readiness_without_attachment" | "absent_with_native_evidence" | "content_size_requests_unsupported" | "viewport_conversion" | "revision_exhausted" | "attach_generation_exhausted" | "receipt_island_mismatch" | "receipt_stale_desired" | "receipt_stale_observed" | "receipt_invalid_generation" | "receipt_unknown_step" | "receipt_duplicate_step" | "receipt_blocked_dependency";
|
|
193
192
|
|
|
194
193
|
export type NativeContentFailurePhase = "compatibility" | "admission" | "coordination";
|
|
195
194
|
|
|
@@ -288,6 +287,10 @@ request_id: NativeContentRequestId,
|
|
|
288
287
|
* Canonical island identity.
|
|
289
288
|
*/
|
|
290
289
|
island_id: NativeContentIslandId,
|
|
290
|
+
/**
|
|
291
|
+
* Host authority lifetime recorded by connect.
|
|
292
|
+
*/
|
|
293
|
+
authority_epoch: NativeContentAuthorityEpoch,
|
|
291
294
|
/**
|
|
292
295
|
* Current host-issued renderer session.
|
|
293
296
|
*/
|
|
@@ -306,6 +309,10 @@ request_id: NativeContentRequestId,
|
|
|
306
309
|
* Canonical island identity.
|
|
307
310
|
*/
|
|
308
311
|
island_id: NativeContentIslandId,
|
|
312
|
+
/**
|
|
313
|
+
* Host authority lifetime recorded by connect.
|
|
314
|
+
*/
|
|
315
|
+
authority_epoch: NativeContentAuthorityEpoch,
|
|
309
316
|
/**
|
|
310
317
|
* Current host-issued renderer session.
|
|
311
318
|
*/
|
|
@@ -332,6 +339,10 @@ request_id: NativeContentRequestId,
|
|
|
332
339
|
* Canonical island identity.
|
|
333
340
|
*/
|
|
334
341
|
island_id: NativeContentIslandId,
|
|
342
|
+
/**
|
|
343
|
+
* Host authority lifetime recorded by connect.
|
|
344
|
+
*/
|
|
345
|
+
authority_epoch: NativeContentAuthorityEpoch,
|
|
335
346
|
/**
|
|
336
347
|
* Current host-issued renderer session.
|
|
337
348
|
*/
|
|
@@ -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.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Unlisten } from "../core/transport.ts";
|
|
1
2
|
import type {
|
|
2
3
|
NativeContentChangedEvent,
|
|
3
4
|
NativeContentConnectRequest,
|
|
@@ -11,7 +12,7 @@ import type {
|
|
|
11
12
|
NativeContentSnapshotResult,
|
|
12
13
|
} from "./generated/protocol.ts";
|
|
13
14
|
|
|
14
|
-
export type NativeContentUnlisten =
|
|
15
|
+
export type NativeContentUnlisten = Unlisten;
|
|
15
16
|
|
|
16
17
|
export interface NativeContentPort {
|
|
17
18
|
connect(request: NativeContentConnectRequest): Promise<unknown>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isOpaqueId } from "../../core/identifiers.ts";
|
|
2
|
+
import { checkWireFields, readWireRecord, wireVariantFields } from "../../core/record.ts";
|
|
2
3
|
import {
|
|
3
4
|
NATIVE_CONTENT_VARIANT_FIELDS,
|
|
4
5
|
NATIVE_CONTENT_VARIANT_FIELDS_DISCRIMINANTS,
|
|
5
6
|
} from "../generated/variant-fields.ts";
|
|
6
|
-
import {
|
|
7
|
-
NATIVE_CONTENT_MAXIMUM_OPAQUE_ID_BYTES,
|
|
8
|
-
NATIVE_CONTENT_PROTOCOL_VERSION,
|
|
9
|
-
} from "../generated/protocol.ts";
|
|
7
|
+
import { NATIVE_CONTENT_PROTOCOL_VERSION } from "../generated/protocol.ts";
|
|
10
8
|
|
|
11
9
|
const FORBIDDEN_KEYS = new Set([
|
|
12
10
|
"payload",
|
|
@@ -55,10 +53,8 @@ export function exactObject(
|
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
export function record(value: unknown, path: string): Record<string, unknown> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
return value;
|
|
56
|
+
const result = readWireRecord(value, () => fail(path, "expected object"));
|
|
57
|
+
return result;
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
export function exactKeys(
|
|
@@ -66,17 +62,9 @@ export function exactKeys(
|
|
|
66
62
|
path: string,
|
|
67
63
|
keys: ReadonlyArray<string>,
|
|
68
64
|
): void {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
fail(`${path}.${key}`, "unknown field");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
for (const key of keys) {
|
|
76
|
-
if (!(key in value)) {
|
|
77
|
-
fail(`${path}.${key}`, "missing field");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
65
|
+
checkWireFields(value, keys, (code, key) =>
|
|
66
|
+
fail(`${path}.${key}`, code === "unknown_field" ? "unknown field" : "missing field"),
|
|
67
|
+
);
|
|
80
68
|
}
|
|
81
69
|
|
|
82
70
|
export function member<const Value extends string>(
|
|
@@ -96,12 +84,7 @@ export function text(value: unknown, path: string): asserts value is string {
|
|
|
96
84
|
}
|
|
97
85
|
|
|
98
86
|
export function opaqueId(value: unknown, path: string): asserts value is string {
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
value.length === 0 ||
|
|
102
|
-
value.length > NATIVE_CONTENT_MAXIMUM_OPAQUE_ID_BYTES ||
|
|
103
|
-
!/^[a-z0-9._:-]+$/.test(value)
|
|
104
|
-
) {
|
|
87
|
+
if (!isOpaqueId(value)) {
|
|
105
88
|
fail(path, "invalid bounded opaque id");
|
|
106
89
|
}
|
|
107
90
|
}
|
|
@@ -173,29 +156,16 @@ function visit(value: unknown, path: string, seen: Set<object>): void {
|
|
|
173
156
|
seen.delete(value);
|
|
174
157
|
}
|
|
175
158
|
|
|
176
|
-
/**
|
|
177
|
-
* Allowed keys for one tagged-union variant, from the generated map.
|
|
178
|
-
*
|
|
179
|
-
* The discriminant's *name* comes from the generated map too: this domain
|
|
180
|
-
* uses `kind`, `status` and `state`, and a call site that has to name the
|
|
181
|
-
* right one is a per-site chance to name the wrong one.
|
|
182
|
-
*
|
|
183
|
-
* A missing entry means the generator failed to read the union, not that a
|
|
184
|
-
* caller sent something odd — every switch checks the discriminant above this
|
|
185
|
-
* call. Failing loudly beats a hand-written list, which is what these were.
|
|
186
|
-
*/
|
|
187
159
|
export function variantKeys(
|
|
188
160
|
type: string,
|
|
189
161
|
object: Record<string, unknown>,
|
|
190
162
|
path: string,
|
|
191
163
|
): ReadonlyArray<string> {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
return keys;
|
|
164
|
+
return wireVariantFields(
|
|
165
|
+
NATIVE_CONTENT_VARIANT_FIELDS,
|
|
166
|
+
NATIVE_CONTENT_VARIANT_FIELDS_DISCRIMINANTS,
|
|
167
|
+
type,
|
|
168
|
+
object,
|
|
169
|
+
(discriminant) => fail(path, `no generated fields for ${type}.${String(discriminant)}`),
|
|
170
|
+
);
|
|
201
171
|
}
|
|
@@ -54,6 +54,7 @@ export function assertValidNativeContentSnapshotRequest(
|
|
|
54
54
|
): asserts value is NativeContentSnapshotRequest {
|
|
55
55
|
const object = exactObject(value, "$", NATIVE_CONTENT_FIELDS.NativeContentSnapshotRequest);
|
|
56
56
|
requestEnvelope(object);
|
|
57
|
+
positive(object.authority_epoch, "$.authority_epoch");
|
|
57
58
|
positive(object.client_epoch, "$.client_epoch");
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -63,6 +64,7 @@ export function assertValidNativeContentDesiredUpdateRequest(
|
|
|
63
64
|
assertProductPayloadFree(value);
|
|
64
65
|
const object = exactObject(value, "$", NATIVE_CONTENT_FIELDS.NativeContentDesiredUpdateRequest);
|
|
65
66
|
requestEnvelope(object);
|
|
67
|
+
positive(object.authority_epoch, "$.authority_epoch");
|
|
66
68
|
positive(object.client_epoch, "$.client_epoch");
|
|
67
69
|
natural(object.expected_desired_revision, "$.expected_desired_revision");
|
|
68
70
|
assertValidDesiredUpdate(object.update);
|
|
@@ -78,6 +80,7 @@ export function assertValidNativeContentDecisionRequest(
|
|
|
78
80
|
NATIVE_CONTENT_FIELDS.NativeContentContentSizeDecisionRequest,
|
|
79
81
|
);
|
|
80
82
|
requestEnvelope(object);
|
|
83
|
+
positive(object.authority_epoch, "$.authority_epoch");
|
|
81
84
|
positive(object.client_epoch, "$.client_epoch");
|
|
82
85
|
assertValidContentSizeProposal(object.proposal);
|
|
83
86
|
assertValidContentSizeDecision(object.decision);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckedSnapshotConnection } from "@inflatable-cookie/longhorn/core";
|
|
1
|
+
import { CheckedSnapshotConnection, CheckedSubscription } from "@inflatable-cookie/longhorn/core";
|
|
2
2
|
import type {
|
|
3
3
|
ConnectionFailure,
|
|
4
4
|
ConnectionFailureReporter,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
assertValidNotificationChangedEvent,
|
|
9
9
|
assertValidNotificationMutationCommand,
|
|
10
10
|
assertValidNotificationMutationResult,
|
|
11
|
+
assertValidNotificationSnapshot,
|
|
11
12
|
assertValidNotificationSnapshotResponse,
|
|
12
13
|
} from "./validation.ts";
|
|
13
14
|
import { NOTIFICATION_PROTOCOL_VERSION } from "./generated/protocol.ts";
|
|
@@ -59,7 +60,19 @@ export class NotificationClient {
|
|
|
59
60
|
onFailure?: ConnectionFailureReporter,
|
|
60
61
|
limit = 100,
|
|
61
62
|
): NotificationSubscription {
|
|
62
|
-
|
|
63
|
+
const port = this.port;
|
|
64
|
+
return new CheckedSubscription(
|
|
65
|
+
new CheckedSnapshotConnection({
|
|
66
|
+
listen: async (receive) => (port.listen === undefined ? () => {} : port.listen(receive)),
|
|
67
|
+
loadSnapshot: async () => (await this.snapshot(0, limit)).snapshot,
|
|
68
|
+
validateSnapshot: parseSnapshot,
|
|
69
|
+
handleEvent: notificationEventAction,
|
|
70
|
+
isNewer: isNewerNotificationSnapshot,
|
|
71
|
+
onSnapshot: listener,
|
|
72
|
+
onFailure,
|
|
73
|
+
}),
|
|
74
|
+
() => {},
|
|
75
|
+
);
|
|
63
76
|
}
|
|
64
77
|
}
|
|
65
78
|
|
|
@@ -75,44 +88,9 @@ export class NotificationResponseCorrelationError extends Error {
|
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
|
|
78
|
-
class CheckedNotificationSubscription implements NotificationSubscription {
|
|
79
|
-
readonly ready: Promise<void>;
|
|
80
|
-
readonly connection: CheckedSnapshotConnection<NotificationSnapshot>;
|
|
81
|
-
|
|
82
|
-
constructor(
|
|
83
|
-
client: NotificationClient,
|
|
84
|
-
port: NotificationPort,
|
|
85
|
-
listener: (snapshot: NotificationSnapshot) => void,
|
|
86
|
-
onFailure: ConnectionFailureReporter | undefined,
|
|
87
|
-
limit: number,
|
|
88
|
-
) {
|
|
89
|
-
this.connection = new CheckedSnapshotConnection({
|
|
90
|
-
listen: async (receive) => (port.listen === undefined ? () => {} : port.listen(receive)),
|
|
91
|
-
loadSnapshot: async () => (await client.snapshot(0, limit)).snapshot,
|
|
92
|
-
validateSnapshot: parseSnapshot,
|
|
93
|
-
handleEvent: notificationEventAction,
|
|
94
|
-
isNewer: isNewerNotificationSnapshot,
|
|
95
|
-
onSnapshot: listener,
|
|
96
|
-
onFailure,
|
|
97
|
-
});
|
|
98
|
-
this.ready = this.connection.ready.then(() => undefined);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
current(): NotificationSnapshot | undefined {
|
|
102
|
-
return this.connection.current();
|
|
103
|
-
}
|
|
104
|
-
failures(): ReadonlyArray<ConnectionFailure> {
|
|
105
|
-
return this.connection.failures();
|
|
106
|
-
}
|
|
107
|
-
dispose(): Promise<void> {
|
|
108
|
-
return this.connection.dispose();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
91
|
function parseSnapshot(value: unknown): NotificationSnapshot {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return response.snapshot;
|
|
92
|
+
assertValidNotificationSnapshot(value);
|
|
93
|
+
return value;
|
|
116
94
|
}
|
|
117
95
|
|
|
118
96
|
export function notificationEventAction(
|