Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 63 additions & 8 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion core/src/app_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
41 changes: 35 additions & 6 deletions core/tests/private/app_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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"));
Expand Down
23 changes: 15 additions & 8 deletions core/tests/private/app_ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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": []}),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
}
Expand All @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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(
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions web/src/config/app-requirements.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
15 changes: 12 additions & 3 deletions web/src/features/AppUi/AppUiFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,14 @@ function OpenedAppFrame({
const theme = ui?.theme ?? 'light'
const iframe = useRef<HTMLIFrameElement>(null)
const bridge = useRef<ReturnType<typeof bindAppUiFrame> | 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) => {
Expand Down Expand Up @@ -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 (
<iframe
Expand Down
3 changes: 3 additions & 0 deletions web/src/lib/AppUi/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ export type AppUiSummary = {
appId: string
installationId: string
generation: number
/** The UI bridge version this generation negotiated, 1.0.0 for one stored without it. */
uiBridgeVersion: string
name: string
slots: AppUiSlot[]
routes: string[]
dialogs: string[]
events: string[]
/** The manifest keys the user holds, without the app ID, unique and in ASCII order. */
permissionKeys: string[]
native?: true
}
Expand Down
Loading