From aff02c5b9a97a8c8620baa499769aa8aaa45a3c5 Mon Sep 17 00:00:00 2001 From: "HomePC\\Kevin" Date: Sun, 29 Nov 2026 01:17:29 +0100 Subject: [PATCH 1/2] feat(apps): offer protocol 1.2.0 and send the user's permission keys to app UIs Raise the SDK crates to 1.5.0 and offer protocol 1.2.0 in the core and the release requirements. Apps negotiate the lower bound of each requires range, so apps that require >=1.0.0 or >=1.1.0 keep exactly that version. The UI bridge context now carries permissionKeys for apps whose negotiated uiBridge is 1.2.0 or newer, and never for older bridges, whose strict validators reject unknown members: - The app UI summary reports the bridge version of its generation, read from the same generation row as the user's keys (NULL counts as 1.0.0), and its permission keys unqualified, unique and in ASCII order. - The frame session compares versions numerically and always includes the keys for 1.2.0 bridges, an empty array when the user holds none. - An open frame sends the context again when the inventory poll returns other keys. bridgeVersion in runtime:bootstrap stays 1.0.0, native UIs are unchanged and x-rentnerproxy-access stays authoritative. Co-Authored-By: Claude Opus 5.5 --- core/Cargo.lock | 71 ++++++++++++-- core/Cargo.toml | 8 +- core/src/app_install.rs | 2 +- core/tests/private/app_install.rs | 41 ++++++-- core/tests/private/app_ipc.rs | 23 +++-- web/src/config/app-requirements.config.ts | 6 +- web/src/features/AppUi/AppUiFrame.tsx | 15 ++- web/src/lib/AppUi/contract.ts | 3 + web/src/lib/AppUi/session.ts | 38 +++++++- web/src/server/AppRuntime/authority.server.ts | 6 +- web/src/server/AppRuntime/ui/access.server.ts | 12 ++- .../AppCatalog/catalog-install-ui.test.tsx | 1 + .../features/AppUi/app-ui-frame.test.tsx | 33 ++++++- .../features/AppUi/native-app-ui.test.tsx | 1 + .../app-runtime-reference/greeting-host.ts | 4 +- .../application-shell.test.tsx | 1 + web/src/tests/lib/AppUi/bridge.test.ts | 77 ++++++++++++++- .../server/AppRuntime/authority.db.test.ts | 19 ++++ .../server/AppRuntime/ui-summaries.test.ts | 94 +++++++++++++++++++ 19 files changed, 411 insertions(+), 44 deletions(-) create mode 100644 web/src/tests/server/AppRuntime/ui-summaries.test.ts diff --git a/core/Cargo.lock b/core/Cargo.lock index d353aa0af..8ac85f6f1 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -1980,9 +1980,9 @@ checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" [[package]] name = "rentnerproxy-app-catalog" -version = "1.0.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756fd9cf38bf0ebf3cf7d0e1dc6aab719c100d4f49cf03fbcb5929c8317f4a48" +checksum = "00092ccb0bc16ad28b34714e77476a77e7afb2c6affd2e518de3bd077b0e7665" dependencies = [ "ed25519-dalek", "hex", @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "rentnerproxy-app-contracts" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992fefcd901855c854b488cddce81a06bcb6ad2242b55dc426572608135cadc5" +checksum = "24dc56e57368d31eb9c93a3f157ceb642617703dfc7acf803b091a1f012e4bb4" dependencies = [ "jsonschema", "serde_json", @@ -2008,9 +2008,9 @@ dependencies = [ [[package]] name = "rentnerproxy-app-pipeline" -version = "1.0.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62d6ace1e02c1fbdab07eaa4500236bf93d8f50e1407910f3ef51e9d0e49f4d0" +checksum = "9f9858a891bc32008f5996b9b4a255073b2bd2cbccb485dc13cb77abaa546449" dependencies = [ "getrandom 0.4.3", "hex", @@ -2024,6 +2024,7 @@ dependencies = [ "serde_json", "tempfile", "time", + "toml", "uuid", "windows-sys 0.61.2", "zstd", @@ -2031,9 +2032,9 @@ dependencies = [ [[package]] name = "rentnerproxy-artifacts" -version = "1.0.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167798416e6596a85c1b3d1e72d9ad48243b229ac509927827bad8cfbebcdfca" +checksum = "a420b8e3d200e1895ace29c69e936e70d136deddfa263531789b2ca682f3be1e" dependencies = [ "cap-fs-ext", "cap-std", @@ -2391,6 +2392,15 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_spanned" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2746,6 +2756,45 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "1.2.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.7+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.2.0+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" + [[package]] name = "tower" version = "0.5.3" @@ -3212,6 +3261,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" + [[package]] name = "winx" version = "0.36.4" diff --git a/core/Cargo.toml b/core/Cargo.toml index 8863f05f3..0e2ce6f01 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -6,10 +6,10 @@ rust-version = "1.99.1" license = "MIT" [dependencies] -rentnerproxy-app-catalog = "1.0.0" -rentnerproxy-app-contracts = "1.4.1" -rentnerproxy-app-pipeline = "1.0.0" -rentnerproxy-artifacts = "1.0.0" +rentnerproxy-app-catalog = "1.5.0" +rentnerproxy-app-contracts = "1.5.0" +rentnerproxy-app-pipeline = "1.5.0" +rentnerproxy-artifacts = "1.5.0" aws-lc-rs = "1.19.0" axum = { version = "0.8.9", default-features = false, features = [ "json", diff --git a/core/src/app_install.rs b/core/src/app_install.rs index 4828a7838..7290ec564 100644 --- a/core/src/app_install.rs +++ b/core/src/app_install.rs @@ -83,7 +83,7 @@ pub(crate) use transport::{Source, unreachable_source}; /// same values (`web/src/config/app-requirements.config.ts`), so an older platform can check /// installed apps against a newer release before its image changes. pub(crate) const RUNTIME_PROFILE: &str = "rentnerproxy-linux-v1"; -pub(crate) const PROTOCOL_VERSION: &str = "1.1.0"; +pub(crate) const PROTOCOL_VERSION: &str = "1.2.0"; #[derive(Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/core/tests/private/app_install.rs b/core/tests/private/app_install.rs index afe38f1f0..0e4bb3b9a 100644 --- a/core/tests/private/app_install.rs +++ b/core/tests/private/app_install.rs @@ -513,8 +513,8 @@ fn target_check_reads_installed_manifests_from_the_accepted_catalog() { } #[test] -fn install_advertises_protocol_1_1_0_to_apps_that_require_it() { - assert_eq!(super::PROTOCOL_VERSION, "1.1.0"); +fn install_advertises_protocol_1_2_0_to_apps_that_require_it() { + assert_eq!(super::PROTOCOL_VERSION, "1.2.0"); // The web release config and this constant mirror the protocol of the contracts crate. assert_eq!( super::PROTOCOL_VERSION, @@ -525,11 +525,12 @@ fn install_advertises_protocol_1_1_0_to_apps_that_require_it() { for (platform_api, app_protocol, compatible) in [ (">=1.0.0 <2.0.0", ">=1.0.0 <2.0.0", true), (">=1.1.0 <2.0.0", ">=1.1.0 <2.0.0", true), - (">=1.2.0 <2.0.0", ">=1.0.0 <2.0.0", false), - (">=1.0.0 <2.0.0", ">=1.2.0 <2.0.0", false), + (">=1.2.0 <2.0.0", ">=1.2.0 <2.0.0", true), + (">=1.3.0 <2.0.0", ">=1.0.0 <2.0.0", false), + (">=1.0.0 <2.0.0", ">=1.3.0 <2.0.0", false), // A capped range ends below the advertised version, yet the app negotiates 1.0.0. (">=1.0.0 <1.1.0", ">=1.0.0 <1.1.0", true), - (">=1.0.0 <1.1.0", ">=1.2.0 <2.0.0", false), + (">=1.0.0 <1.1.0", ">=1.3.0 <2.0.0", false), ] { let mut manifest = manifest(); manifest["requires"]["platformApi"] = json!(platform_api); @@ -554,8 +555,9 @@ fn apps_negotiate_the_lower_bound_of_each_manifest_range() { for (range, negotiated) in [ (">=1.0.0 <2.0.0", Some("1.0.0")), (">=1.1.0 <2.0.0", Some("1.1.0")), + (">=1.2.0 <2.0.0", Some("1.2.0")), (">=1.0.0 <1.1.0", Some("1.0.0")), - (">=1.2.0 <2.0.0", None), + (">=1.3.0 <2.0.0", None), ] { let mut manifest = manifest(); manifest["requires"]["platformApi"] = json!(range); @@ -573,6 +575,33 @@ fn apps_negotiate_the_lower_bound_of_each_manifest_range() { } } +#[test] +fn ui_apps_negotiate_the_lower_bound_of_their_bridge_range() { + // Only a 1.2.0 bridge receives the user's permission keys in the UI context, so apps that + // require an older bridge must keep negotiating exactly that version. + for (range, negotiated) in [ + (">=1.0.0 <2.0.0", Some("1.0.0")), + (">=1.1.0 <2.0.0", Some("1.1.0")), + (">=1.2.0 <2.0.0", Some("1.2.0")), + (">=1.0.0 <1.2.0", Some("1.0.0")), + (">=1.3.0 <2.0.0", None), + ] { + let mut manifest = manifest(); + manifest["ui"] = json!({"entrypoint":"ui/index.html", "slots":["navigation"]}); + manifest["requires"]["uiBridge"] = json!(range); + let result = super::negotiate_manifest_versions(&manifest); + match negotiated { + Some(version) => { + let versions = result.unwrap(); + assert_eq!(versions.ui_bridge.as_deref(), Some(version), "{range}"); + assert_eq!(versions.app_protocol, "1.0.0"); + assert_eq!(versions.platform_api, "1.0.0"); + } + None => assert!(result.is_err(), "{range}"), + } + } +} + #[test] fn engine_providers_require_the_engine_capability_that_applies_them() { let installer = manager(Path::new("unused")); diff --git a/core/tests/private/app_ipc.rs b/core/tests/private/app_ipc.rs index 77c39f21a..c535bc392 100644 --- a/core/tests/private/app_ipc.rs +++ b/core/tests/private/app_ipc.rs @@ -1648,7 +1648,7 @@ async fn an_app_that_is_not_ready_keeps_retrying_without_registration() { for ready in [ json!({"ready": false, "protocolVersion": VERSION, "providers": []}), json!({"ready": true, "protocolVersion": "9.9.9", "providers": []}), - json!({"ready": true, "protocolVersion": "1.2.0", "providers": []}), + json!({"ready": true, "protocolVersion": "1.3.0", "providers": []}), json!({"ready": true, "protocolVersion": "2.0.0", "providers": []}), json!({"ready": true, "protocolVersion": "1.1", "providers": []}), json!({"ready": true, "protocolVersion": "1.01.0", "providers": []}), @@ -1878,7 +1878,7 @@ async fn privileged_controller_validates_launch_pipe_and_bootstrap_paths() { .contains("Invalid manager launch request") ); let mut incompatible = launch.clone(); - incompatible["uiBridge"] = json!(">=1.2.0 <2.0.0"); + incompatible["uiBridge"] = json!(">=1.3.0 <2.0.0"); assert!( send(format!("{incompatible}\n")) .await @@ -2161,8 +2161,8 @@ async fn restricted_child_fixture() { } #[test] -fn the_platform_advertises_protocol_1_1_0_and_keeps_provider_registrations_at_1_0_0() { - assert_eq!(VERSION, "1.1.0"); +fn the_platform_advertises_protocol_1_2_0_and_keeps_provider_registrations_at_1_0_0() { + assert_eq!(VERSION, "1.2.0"); assert_eq!(VERSION, rentnerproxy_app_contracts::PROTOCOL_VERSION); assert_eq!(PROVIDER_VERSION, "1.0.0"); } @@ -2172,9 +2172,11 @@ fn launch_ranges_admit_apps_that_require_the_advertised_protocol() { for (range, supported) in [ (">=1.0.0 <2.0.0", true), (">=1.1.0 <2.0.0", true), + (">=1.2.0 <2.0.0", true), (">=1.0.0 <1.1.0", true), - (">=1.1.1 <2.0.0", false), - (">=1.2.0 <2.0.0", false), + (">=1.1.1 <2.0.0", true), + (">=1.2.1 <2.0.0", false), + (">=1.3.0 <2.0.0", false), (">=2.0.0 <3.0.0", false), (">=1.1.0 <1.1.0", false), (">=1.0.0 <3.0.0", false), @@ -2193,8 +2195,11 @@ fn launch_validation_admits_only_negotiated_versions_inside_the_manifest_ranges( ("1.0.0", ">=1.0.0 <2.0.0", true), ("1.1.0", ">=1.0.0 <2.0.0", true), ("1.1.0", ">=1.1.0 <2.0.0", true), + ("1.2.0", ">=1.0.0 <2.0.0", true), + ("1.2.0", ">=1.2.0 <2.0.0", true), ("1.0.0", ">=1.1.0 <2.0.0", false), - ("1.2.0", ">=1.0.0 <2.0.0", false), + ("1.1.0", ">=1.2.0 <2.0.0", false), + ("1.3.0", ">=1.0.0 <2.0.0", false), ("2.0.0", ">=1.0.0 <3.0.0", false), ("1.1.0", ">=1.0.0 <1.1.0", false), ("1.1", ">=1.0.0 <2.0.0", false), @@ -2242,10 +2247,12 @@ async fn readiness_expects_exactly_the_negotiated_protocol() { for (negotiated, reported, accepted) in [ ("1.0.0", "1.0.0", true), ("1.1.0", "1.1.0", true), + ("1.2.0", "1.2.0", true), // An app negotiated 1.0.0 must not claim more, nor an app of 1.1.0 less. ("1.0.0", "1.1.0", false), ("1.1.0", "1.0.0", false), ("1.1.0", "1.2.0", false), + ("1.2.0", "1.1.0", false), ("1.1.0", "2.0.0", false), ] { let outcome = exercise_readiness_in( @@ -2266,7 +2273,7 @@ async fn readiness_expects_exactly_the_negotiated_protocol() { } #[tokio::test] -async fn provider_registrations_stay_at_provider_version_1_0_0_on_a_1_1_0_platform() { +async fn provider_registrations_stay_at_provider_version_1_0_0_on_a_1_2_0_platform() { let mut registrations = registration("monitor", "monitoring"); registrations["version"] = json!(VERSION); let outcome = readiness(json!([registrations]), &["monitoring"], &[204]).await; diff --git a/web/src/config/app-requirements.config.ts b/web/src/config/app-requirements.config.ts index 97a016661..8e5ef149f 100644 --- a/web/src/config/app-requirements.config.ts +++ b/web/src/config/app-requirements.config.ts @@ -14,9 +14,9 @@ export const APP_REQUIREMENTS_MAX_BYTES = 16_384 */ export const APP_RUNTIME_ENVIRONMENT = { runtimeProfile: 'rentnerproxy-linux-v1', - platformApi: '1.1.0', - appProtocol: '1.1.0', - uiBridge: '1.1.0', + platformApi: '1.2.0', + appProtocol: '1.2.0', + uiBridge: '1.2.0', } as const export const BUNDLED_INSTALLER_CONFIG = 'docker/production/apps/catalog/installer.json' diff --git a/web/src/features/AppUi/AppUiFrame.tsx b/web/src/features/AppUi/AppUiFrame.tsx index 53a9bb737..12708f90d 100644 --- a/web/src/features/AppUi/AppUiFrame.tsx +++ b/web/src/features/AppUi/AppUiFrame.tsx @@ -161,7 +161,14 @@ function OpenedAppFrame({ const theme = ui?.theme ?? 'light' const iframe = useRef(null) const bridge = useRef | null>(null) - const currentContext = useEffectEvent(() => ({ theme, locale, route })) + const currentContext = useEffectEvent(() => ({ + theme, + locale, + route, + permissionKeys: app.permissionKeys, + })) + // Keys match the manifest pattern, so the joined list changes exactly when the keys do. + const permissionScope = app.permissionKeys.join(' ') const navigate = useEffectEvent(onNavigate) const dialog = useEffectEvent( (request: AppUiDialogRequest, settle: (outcome: 'confirmed' | 'cancelled') => void) => { @@ -211,9 +218,11 @@ function OpenedAppFrame({ } }, []) + // The inventory poll updates the user's keys while the frame stays open. useEffect(() => { - bridge.current?.sendContext({ theme, locale, route }) - }, [locale, route, theme]) + const permissionKeys = permissionScope === '' ? [] : permissionScope.split(' ') + bridge.current?.sendContext({ theme, locale, route, permissionKeys }) + }, [locale, permissionScope, route, theme]) return (