fix(web): let a malformed _meta.ui stop the carrier lookup

uiMeta returned undefined for both "this bag declares no ui" and "its ui
is unusable", so a content item declaring `ui: null` fell through and was
granted whatever a BROADER carrier asked for — wrong precedence, wrong
direction to fail in. It now distinguishes the two: no `ui` key means
keep looking, a declared-but-malformed one decides for "no hints".

Also pin the full three-way precedence with a case carrying all three
carriers at once (no prior case would have caught the first two operands
being swapped), and state why a permission's object value need not be
empty: `{}` is the spec's extension point, so rejecting a populated one
would drop grants from servers written against a newer spec.

Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-23 22:05:23 -04:00
commit 53943c2ef8

View file

@ -107,6 +107,15 @@ describe("approveSandboxPermissions", () => {
warn.mockRestore();
});
it("accepts a non-empty object, since `{}` is the spec's extension point", () => {
// The key's presence is the request; a field the host doesn't know can't
// narrow it, and rejecting it would drop grants from servers written
// against a newer spec. The value is normalized to `{}` on the way out.
expect(approveSandboxPermissions({ camera: { enabled: false } })).toEqual({
camera: {},
});
});
it("drops `false` without warning, and ignores unknown keys", () => {
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
expect(