From aabde238b826fdf92f3f75b8817f09d79297a36d Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Thu, 25 Sep 2025 09:55:18 -0700 Subject: [PATCH 1/6] Refactor : RPPL-3560 Remove PrivacySettings contracts and processors from Ripple --- .../src/bootstrap/setup_extn_client_step.rs | 8 - .../main/src/firebolt/handlers/privacy_rpc.rs | 137 ++-- .../src/firebolt/handlers/user_grants_rpc.rs | 40 ++ .../store_privacy_settings_processor.rs | 11 + .../processor/store_user_grants_processor.rs | 9 + core/main/src/service/user_grants.rs | 36 +- .../api/distributor/distributor_privacy.rs | 592 ++++++++---------- .../api/distributor/distributor_usergrants.rs | 105 ++-- core/sdk/src/api/storage_property.rs | 4 +- core/sdk/src/api/usergrant_entry.rs | 79 --- core/sdk/src/extn/extn_client_message.rs | 11 +- core/sdk/src/framework/ripple_contract.rs | 2 - .../general/src/distributor_general_ffi.rs | 19 +- 13 files changed, 494 insertions(+), 559 deletions(-) diff --git a/core/main/src/bootstrap/setup_extn_client_step.rs b/core/main/src/bootstrap/setup_extn_client_step.rs index d924fa16f..41bce2fec 100644 --- a/core/main/src/bootstrap/setup_extn_client_step.rs +++ b/core/main/src/bootstrap/setup_extn_client_step.rs @@ -21,10 +21,6 @@ use ripple_sdk::{ use crate::processor::metrics_processor::OpMetricsProcessor; use crate::processor::settings_processor::SettingsProcessor; -use crate::processor::{ - store_privacy_settings_processor::StorePrivacySettingsProcessor, - store_user_grants_processor::StoreUserGrantsProcessor, -}; use crate::{ processor::{ app_events_processor::AppEventsProcessor, @@ -51,10 +47,6 @@ impl Bootstep for SetupExtnClientStep { client.add_request_processor(KeyboardProcessor::new(state.platform_state.clone())); client.add_event_processor(AppEventsProcessor::new(state.platform_state.clone())); client.add_request_processor(StorageManagerProcessor::new(state.platform_state.clone())); - client.add_request_processor(StoreUserGrantsProcessor::new(state.platform_state.clone())); - client.add_request_processor(StorePrivacySettingsProcessor::new( - state.platform_state.clone(), - )); client.add_request_processor(AuthorizedInfoProcessor::new(state.platform_state.clone())); client.add_request_processor(SettingsProcessor::new(state.platform_state.clone())); client.add_request_processor(OpMetricsProcessor::new(state.platform_state.clone())); diff --git a/core/main/src/firebolt/handlers/privacy_rpc.rs b/core/main/src/firebolt/handlers/privacy_rpc.rs index 790d78078..6e7147c76 100644 --- a/core/main/src/firebolt/handlers/privacy_rpc.rs +++ b/core/main/src/firebolt/handlers/privacy_rpc.rs @@ -15,6 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 // +use crate::broker::broker_utils::BrokerUtils; use crate::processor::storage::storage_manager::StorageManager; use crate::service::apps::app_events::AppEventDecorator; use crate::{ @@ -31,8 +32,7 @@ use ripple_sdk::{ api::{ device::device_peristence::SetBoolProperty, distributor::distributor_privacy::{ - ContentListenRequest, GetPropertyParams, PrivacyCloudRequest, PrivacySettings, - PrivacySettingsData, PrivacySettingsStoreRequest, SetPropertyParams, + ContentListenRequest, PrivacySettings, PrivacySettingsData, }, firebolt::{ fb_capabilities::{CapabilityRole, FireboltCap, RoleInfo, CAPABILITY_NOT_AVAILABLE}, @@ -573,24 +573,13 @@ impl PrivacyImpl { match privacy_settings_storage_type { PrivacySettingsStorageType::Local | PrivacySettingsStorageType::Sync => { - let payload = PrivacySettingsStoreRequest::GetPrivacySettings(property); - let response = platform_state.get_client().send_extn_request(payload).await; - if let Ok(extn_msg) = response { - match extn_msg.payload { - ExtnPayload::Response(res) => match res { - ExtnResponse::Boolean(val) => RpcResult::Ok(val), - _ => RpcResult::Err(jsonrpsee::core::Error::Custom( - "Unable to fetch".to_owned(), - )), - }, - _ => RpcResult::Err(jsonrpsee::core::Error::Custom( - "Unexpected response received from Extn".to_owned(), - )), - } - } else { - RpcResult::Err(jsonrpsee::core::Error::Custom( - "Error in getting response from Extn".to_owned(), - )) + // Direct call to StorageManager instead of routing through extension processor + match StorageManager::get_bool(platform_state, property).await { + Ok(val) => RpcResult::Ok(val), + Err(e) => RpcResult::Err(jsonrpsee::core::Error::Custom(format!( + "Unable to fetch privacy setting: {}", + e + ))), } } PrivacySettingsStorageType::Cloud => { @@ -603,18 +592,33 @@ impl PrivacyImpl { )) } }; - let request = PrivacyCloudRequest::GetProperty(GetPropertyParams { - setting, - dist_session, + let request_payload = json!({ + "setting": setting, + "dist_session": dist_session }); - if let Ok(resp) = platform_state.get_client().send_extn_request(request).await { - if let Some(ExtnResponse::Boolean(b)) = resp.payload.extract() { - return Ok(b); + + match BrokerUtils::process_internal_main_request( + platform_state, + "distributor.privacy.getProperty", + Some(request_payload), + ) + .await + { + Ok(response_value) => { + if let Some(boolean_value) = response_value.as_bool() { + return Ok(boolean_value); + } + Err(jsonrpsee::core::Error::Custom(String::from( + "Invalid response format from distributor.privacy.getProperty", + ))) + } + Err(e) => { + error!("Failed to get privacy property from distributor: {:?}", e); + Err(jsonrpsee::core::Error::Custom(String::from( + "PrivacySettingsStorageType::Cloud: Not Available", + ))) } } - Err(jsonrpsee::core::Error::Custom(String::from( - "PrivacySettingsStorageType::Cloud: Not Available", - ))) } else { Err(jsonrpsee::core::Error::Custom(String::from( "Account session is not available", @@ -638,35 +642,31 @@ impl PrivacyImpl { match privacy_settings_storage_type { PrivacySettingsStorageType::Local => { - let payload = PrivacySettingsStoreRequest::SetPrivacySettings(property, value); - let response = platform_state.get_client().send_extn_request(payload).await; - if let Ok(extn_msg) = response { - match extn_msg.payload { - ExtnPayload::Response(res) => match res { - ExtnResponse::None(_) => RpcResult::Ok(()), - _ => RpcResult::Err(jsonrpsee::core::Error::Custom( - "Unable to fetch".to_owned(), - )), - }, - _ => RpcResult::Err(jsonrpsee::core::Error::Custom( - "Unexpected response received from Extn".to_owned(), - )), - } - } else { - RpcResult::Err(jsonrpsee::core::Error::Custom( - "Error in getting response from Extn".to_owned(), - )) + // Direct call to StorageManager instead of routing through extension processor + match StorageManager::set_bool(platform_state, property, value, None).await { + Ok(_) => RpcResult::Ok(()), + Err(e) => RpcResult::Err(jsonrpsee::core::Error::Custom(format!( + "Unable to set privacy setting: {}", + e + ))), } } PrivacySettingsStorageType::Cloud | PrivacySettingsStorageType::Sync => { if let Some(dist_session) = platform_state.session_state.get_account_session() { if let Some(privacy_setting) = property.as_privacy_setting() { - let request = PrivacyCloudRequest::SetProperty(SetPropertyParams { - setting: privacy_setting, - value, - dist_session, + let request_payload = json!({ + "setting": privacy_setting, + "value": value, + "dist_session": dist_session }); - let result = platform_state.get_client().send_extn_request(request).await; + + let result = BrokerUtils::process_internal_main_request( + platform_state, + "distributor.privacy.setProperty", + Some(request_payload), + ) + .await; + if PrivacySettingsStorageType::Sync == privacy_settings_storage_type && result.is_ok() { @@ -1177,15 +1177,34 @@ impl PrivacyServer for PrivacyImpl { } PrivacySettingsStorageType::Cloud => { if let Some(dist_session) = self.state.session_state.get_account_session() { - let request = PrivacyCloudRequest::GetProperties(dist_session); - if let Ok(resp) = self.state.get_client().send_extn_request(request).await { - if let Some(b) = resp.payload.extract() { - return Ok(b); + let request_payload = json!({ + "dist_session": dist_session + }); + + match BrokerUtils::process_internal_main_request( + &self.state, + "distributor.privacy.getProperties", + Some(request_payload), + ) + .await + { + Ok(response_value) => { + if let Ok(privacy_settings) = + serde_json::from_value::(response_value) + { + return Ok(privacy_settings); + } + Err(jsonrpsee::core::Error::Custom(String::from( + "Invalid response format from distributor.privacy.getProperties", + ))) + } + Err(e) => { + error!("Failed to get privacy properties from distributor: {:?}", e); + Err(jsonrpsee::core::Error::Custom(String::from( + "PrivacySettingsStorageType::Cloud: Not Available", + ))) } } - Err(jsonrpsee::core::Error::Custom(String::from( - "PrivacySettingsStorageType::Cloud: Not Available", - ))) } else { Err(jsonrpsee::core::Error::Custom(String::from( "Account session is not available", diff --git a/core/main/src/firebolt/handlers/user_grants_rpc.rs b/core/main/src/firebolt/handlers/user_grants_rpc.rs index f02645967..d29bd328f 100644 --- a/core/main/src/firebolt/handlers/user_grants_rpc.rs +++ b/core/main/src/firebolt/handlers/user_grants_rpc.rs @@ -92,6 +92,13 @@ pub trait UserGrants { ) -> RpcResult<()>; #[method(name = "ripple.syncGrantsMap")] async fn sync_user_grants_map(&self, ctx: CallContext) -> RpcResult<()>; + #[method(name = "ripple.getUserGrants")] + async fn get_user_grants( + &self, + ctx: CallContext, + app_id: String, + permission: FireboltPermission, + ) -> RpcResult>; } #[derive(Debug)] @@ -216,6 +223,39 @@ impl UserGrantsServer for UserGrantsImpl { .await; Ok(()) } + + async fn get_user_grants( + &self, + _ctx: CallContext, + app_id: String, + permission: FireboltPermission, + ) -> RpcResult> { + debug!( + "Getting user grants for app: {} and permission: {:?}", + app_id, permission + ); + + let result = self + .platform_state + .cap_state + .grant_state + .get_grant_status(&app_id, &permission); + + match result { + Some(grant_status) => { + let granted = match grant_status { + ripple_sdk::api::device::device_user_grants_data::GrantStatus::Allowed => true, + ripple_sdk::api::device::device_user_grants_data::GrantStatus::Denied => false, + }; + debug!("Found user grant status: {}", granted); + Ok(Some(granted)) + } + None => { + debug!("No user grant status found"); + Ok(None) + } + } + } async fn clear_user_grants(&self, _ctx: CallContext) -> RpcResult<()> { debug!("Handling clear user grants request"); let _ = self diff --git a/core/main/src/processor/store_privacy_settings_processor.rs b/core/main/src/processor/store_privacy_settings_processor.rs index 024fb1233..4c61b5b03 100644 --- a/core/main/src/processor/store_privacy_settings_processor.rs +++ b/core/main/src/processor/store_privacy_settings_processor.rs @@ -14,6 +14,16 @@ // // SPDX-License-Identifier: Apache-2.0 // + +/* +COMMENTED OUT: This processor is now dead code after migration to RPC handlers +All privacy settings functionality has been migrated to distributor.privacy RPC methods: +- distributor.privacy.getProperty +- distributor.privacy.getProperties +- distributor.privacy.setProperty +- distributor.privacy.getPartnerExclusions +The PrivacySettingsStoreRequest enum is commented out, making this processor non-functional + use crate::processor::storage::storage_manager::StorageManager; use crate::state::platform_state::PlatformState; use ripple_sdk::{ @@ -236,3 +246,4 @@ impl ExtnRequestProcessor for StorePrivacySettingsProcessor { } } } +*/ diff --git a/core/main/src/processor/store_user_grants_processor.rs b/core/main/src/processor/store_user_grants_processor.rs index 58f74b36b..0906b0872 100644 --- a/core/main/src/processor/store_user_grants_processor.rs +++ b/core/main/src/processor/store_user_grants_processor.rs @@ -13,7 +13,15 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 + // +// COMMENTED OUT: This processor is now dead code after migration to RPC handlers +// All user grants functionality has been migrated to distributor.usergrants RPC methods: +// - distributor.usergrants.getCloudUserGrants +// - distributor.usergrants.setCloudUserGrants +// The UserGrantsStoreRequest enum is commented out, making this processor non-functional + +/* use crate::state::platform_state::PlatformState; use ripple_sdk::{ api::{ @@ -193,3 +201,4 @@ impl ExtnRequestProcessor for StoreUserGrantsProcessor { } } } +*/ diff --git a/core/main/src/service/user_grants.rs b/core/main/src/service/user_grants.rs index ff52df3fe..11cff8a8f 100644 --- a/core/main/src/service/user_grants.rs +++ b/core/main/src/service/user_grants.rs @@ -39,9 +39,7 @@ use ripple_sdk::{ PolicyPersistenceType, }, }, - distributor::distributor_usergrants::{ - UserGrantsCloudSetParams, UserGrantsCloudStoreRequest, - }, + distributor::distributor_usergrants::UserGrantsCloudSetParams, firebolt::{ fb_capabilities::{ CapEvent, CapabilityRole, DenyReason, DenyReasonWithCap, FireboltCap, @@ -1179,15 +1177,37 @@ impl GrantPolicyEnforcer { return; } + // Convert to rule-based call using BrokerUtils for distributor let usergrants_cloud_set_params = UserGrantsCloudSetParams { account_session, user_grant_info, }; - let request = - UserGrantsCloudStoreRequest::SetCloudUserGrants(usergrants_cloud_set_params); - let resp = platform_state.get_client().send_extn_request(request).await; - if resp.is_err() { - error!("Unable to sync usergrants to cloud. Unable to send request to extn"); + + // Serialize the parameters for the rule-based call + let params = match serde_json::to_value(&usergrants_cloud_set_params) { + Ok(value) => Some(value), + Err(e) => { + error!( + "Unable to sync usergrants to cloud. Failed to serialize parameters: {}", + e + ); + return; + } + }; + + // Make the rule-based call to distributor using internal broker system + let result = crate::broker::broker_utils::BrokerUtils::process_internal_main_request( + platform_state, + "distributor.usergrants.setCloudUserGrants", + params, + ) + .await; + + if result.is_err() { + error!( + "Unable to sync usergrants to cloud. Rule-based request failed: {:?}", + result + ); } } } diff --git a/core/sdk/src/api/distributor/distributor_privacy.rs b/core/sdk/src/api/distributor/distributor_privacy.rs index 34df486d6..8ab513be1 100644 --- a/core/sdk/src/api/distributor/distributor_privacy.rs +++ b/core/sdk/src/api/distributor/distributor_privacy.rs @@ -19,15 +19,8 @@ use std::str::FromStr; use serde::{Deserialize, Serialize}; +use crate::api::session::AccountSession; use crate::api::usergrant_entry::UserGrantInfo; -use crate::{ - api::{ - session::AccountSession, - storage_property::{StorageAdjective, StorageProperty}, - }, - extn::extn_client_message::{ExtnPayload, ExtnPayloadProvider, ExtnRequest, ExtnResponse}, - framework::ripple_contract::RippleContract, -}; #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] pub enum PrivacySetting { @@ -147,13 +140,6 @@ impl Default for PrivacySettings { } } -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub enum PrivacySettingsStoreRequest { - GetPrivacySettings(StorageProperty), - SetPrivacySettings(StorageProperty, bool), - SetAllPrivacySettings(PrivacySettingsData), -} - #[derive(Default, PartialEq, Debug, Clone, Serialize, Deserialize)] pub struct PrivacySettingsData { pub allow_acr_collection: Option, @@ -209,68 +195,73 @@ impl From for PrivacySettingsData { } } -impl ExtnPayloadProvider for PrivacySettingsStoreRequest { - fn get_from_payload(payload: ExtnPayload) -> Option { - match payload { - ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(storage_request)) => { - Some(storage_request) - } - _ => None, - } - } - - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(self.clone())) - } - - fn contract() -> RippleContract { - RippleContract::Storage(StorageAdjective::PrivacyLocal) - } -} - -impl ExtnPayloadProvider for PrivacySettings { - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { - if let Ok(v) = serde_json::from_value(v) { - return Some(v); - } - } - - None - } - - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Response(ExtnResponse::Value( - serde_json::to_value(self.clone()).unwrap(), - )) - } - - fn contract() -> crate::framework::ripple_contract::RippleContract { - RippleContract::Storage(StorageAdjective::PrivacyCloud) - } -} - -impl ExtnPayloadProvider for PrivacySettingsData { - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( - PrivacySettingsStoreRequest::SetAllPrivacySettings(settings), - )) = payload - { - return Some(settings); - } - None - } +//impl ExtnPayloadProvider for PrivacySettingsStoreRequest { +// fn get_from_payload(payload: ExtnPayload) -> Option { +// match payload { +// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(storage_request)) => { +// Some(storage_request) +// } +// _ => None, +// } +// } +// +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(self.clone())) +// } +// +// fn contract() -> RippleContract { +// RippleContract::Storage(StorageAdjective::PrivacyLocal) +// } +//} - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( - PrivacySettingsStoreRequest::SetAllPrivacySettings(self.clone()), - )) - } +// +// COMMENTED OUT: Extension payload implementations for PrivacySettings +// These create storage contract dependencies. PrivacySettings is now used directly as RPC response types. +// - fn contract() -> crate::framework::ripple_contract::RippleContract { - RippleContract::Storage(StorageAdjective::PrivacyLocal) - } -} +// impl ExtnPayloadProvider for PrivacySettings { +// fn get_from_payload(payload: ExtnPayload) -> Option { +// if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { +// if let Ok(v) = serde_json::from_value(v) { +// return Some(v); +// } +// } +// +// None +// } +// +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Response(ExtnResponse::Value( +// serde_json::to_value(self.clone()).unwrap(), +// )) +// } +// +// fn contract() -> crate::framework::ripple_contract::RippleContract { +// RippleContract::Storage(StorageAdjective::PrivacyCloud) +// } +// } + +//impl ExtnPayloadProvider for PrivacySettingsData { +// fn get_from_payload(payload: ExtnPayload) -> Option { +// if let ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( +// PrivacySettingsStoreRequest::SetAllPrivacySettings(settings), +// )) = payload +// { +// return Some(settings); +// } +// None +// } +// +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( +// PrivacySettingsStoreRequest::SetAllPrivacySettings(self.clone()), +// )) +// } +// +// fn contract() -> crate::framework::ripple_contract::RippleContract { +// RippleContract::Storage(StorageAdjective::PrivacyLocal) +// } +//} #[derive(Debug, Deserialize, Clone)] #[serde(rename_all = "camelCase")] @@ -293,42 +284,43 @@ pub struct SetPropertyParams { pub dist_session: AccountSession, } -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub enum PrivacyCloudRequest { - GetProperty(GetPropertyParams), - GetProperties(AccountSession), - SetProperty(SetPropertyParams), - GetPartnerExclusions(AccountSession), -} - -impl PrivacyCloudRequest { - pub fn get_session(&self) -> AccountSession { - match self { - PrivacyCloudRequest::GetProperty(params) => params.dist_session.clone(), - PrivacyCloudRequest::GetProperties(session) => session.clone(), - PrivacyCloudRequest::SetProperty(params) => params.dist_session.clone(), - PrivacyCloudRequest::GetPartnerExclusions(session) => session.clone(), - } - } -} - -impl ExtnPayloadProvider for PrivacyCloudRequest { - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Request(ExtnRequest::PrivacySettings(p)) = payload { - return Some(p); - } - - None - } - - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Request(ExtnRequest::PrivacySettings(self.clone())) - } - - fn contract() -> crate::framework::ripple_contract::RippleContract { - RippleContract::Storage(StorageAdjective::PrivacyCloud) - } -} +// +//#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] +//pub enum PrivacyCloudRequest { +// GetProperty(GetPropertyParams), +// GetProperties(AccountSession), +// SetProperty(SetPropertyParams), +// GetPartnerExclusions(AccountSession), +//} +// +//impl PrivacyCloudRequest { +// pub fn get_session(&self) -> AccountSession { +// match self { +// PrivacyCloudRequest::GetProperty(params) => params.dist_session.clone(), +// PrivacyCloudRequest::GetProperties(session) => session.clone(), +// PrivacyCloudRequest::SetProperty(params) => params.dist_session.clone(), +// PrivacyCloudRequest::GetPartnerExclusions(session) => session.clone(), +// } +// } +//} +// +//impl ExtnPayloadProvider for PrivacyCloudRequest { +// fn get_from_payload(payload: ExtnPayload) -> Option { +// if let ExtnPayload::Request(ExtnRequest::PrivacySettings(p)) = payload { +// return Some(p); +// } +// +// None +// } +// +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Request(ExtnRequest::PrivacySettings(self.clone())) +// } +// +// fn contract() -> crate::framework::ripple_contract::RippleContract { +// RippleContract::Storage(StorageAdjective::PrivacyCloud) +// } +//} #[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone)] pub struct ExclusionPolicyData { @@ -354,27 +346,32 @@ pub struct ExclusionPolicy { pub watch_history: Option, } -impl ExtnPayloadProvider for ExclusionPolicy { - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { - if let Ok(v) = serde_json::from_value(v) { - return Some(v); - } - } - - None - } - - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Response(ExtnResponse::Value( - serde_json::to_value(self.clone()).unwrap(), - )) - } +// +// COMMENTED OUT: Extension payload implementations for ExclusionPolicy +// These create storage contract dependencies. ExclusionPolicy is now used directly as RPC response types. +// - fn contract() -> crate::framework::ripple_contract::RippleContract { - RippleContract::Storage(StorageAdjective::PrivacyCloud) - } -} +// impl ExtnPayloadProvider for ExclusionPolicy { +// fn get_from_payload(payload: ExtnPayload) -> Option { +// if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { +// if let Ok(v) = serde_json::from_value(v) { +// return Some(v); +// } +// } +// +// None +// } +// +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Response(ExtnResponse::Value( +// serde_json::to_value(self.clone()).unwrap(), +// )) +// } +// +// fn contract() -> crate::framework::ripple_contract::RippleContract { +// RippleContract::Storage(StorageAdjective::PrivacyCloud) +// } +// } #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] pub enum DataEventType { @@ -411,208 +408,133 @@ pub enum PrivacyResponse { #[cfg(test)] mod tests { - use super::*; - use crate::utils::test_utils::test_extn_payload_provider; - - #[test] - fn test_get_session_get_property() { - let params = GetPropertyParams { - setting: PrivacySetting::AppDataCollection("test_app_data_collection".to_string()), - dist_session: AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }, - }; - let request = PrivacyCloudRequest::GetProperty(params.clone()); - let session = request.get_session(); - assert_eq!(session, params.dist_session); - } - - #[test] - fn test_get_session_get_properties() { - let session = AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }; - let request = PrivacyCloudRequest::GetProperties(session.clone()); - let result = request.get_session(); - assert_eq!(result, session); - } - - #[test] - fn test_get_session_set_property() { - let params = SetPropertyParams { - setting: PrivacySetting::AppDataCollection("test_app_data_collection".to_string()), - value: true, - dist_session: AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }, - }; - let request = PrivacyCloudRequest::SetProperty(params.clone()); - let session = request.get_session(); - assert_eq!(session, params.dist_session); - } - - #[test] - fn test_get_session_get_partner_exclusions() { - let session = AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }; - - let request = PrivacyCloudRequest::GetPartnerExclusions(session.clone()); - let result = request.get_session(); - assert_eq!(result, session); - } - - #[test] - fn test_extn_request_privacy_cloud() { - let get_property_params = GetPropertyParams { - setting: PrivacySetting::AppDataCollection("test_app_data_collection".to_string()), - dist_session: AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }, - }; - - let privacy_cloud_request = PrivacyCloudRequest::GetProperty(get_property_params); - let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyCloud); - - test_extn_payload_provider(privacy_cloud_request, contract_type); - } - - #[test] - fn test_extn_payload_provider_for_exclusion_policy() { - let exclusion_policy = ExclusionPolicy { - acr: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched, DataEventType::BusinessIntelligence], - entity_reference: vec![String::from("entity_reference_acr")], - derivative_propagation: true, - }), - app_content_ad_targeting: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_app_content_ad_targeting")], - derivative_propagation: false, - }), - business_analytics: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched, DataEventType::BusinessIntelligence], - entity_reference: vec![String::from("entity_reference_business_analytics")], - derivative_propagation: false, - }), - camera_analytics: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_camera_analytics")], - derivative_propagation: true, - }), - continue_watching: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_continue_watching")], - derivative_propagation: true, - }), - personalization: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_personalization")], - derivative_propagation: true, - }), - primary_browse_ad_targeting: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from( - "entity_reference_primary_browse_ad_targeting", - )], - derivative_propagation: true, - }), - primary_content_ad_targeting: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from( - "entity_reference_primary_content_ad_targeting", - )], - derivative_propagation: true, - }), - product_analytics: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_product_analytics")], - derivative_propagation: true, - }), - remote_diagnostics: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_remote_diagnostics")], - derivative_propagation: true, - }), - unentitled_continue_watching: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from( - "entity_reference_unentitled_continue_watching", - )], - derivative_propagation: true, - }), - unentitled_personalization: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_unentitled_personalization")], - derivative_propagation: true, - }), - watch_history: Some(ExclusionPolicyData { - data_events: vec![DataEventType::Watched], - entity_reference: vec![String::from("entity_reference_watch_history")], - derivative_propagation: true, - }), - }; - - let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyCloud); - test_extn_payload_provider(exclusion_policy, contract_type); - } - - #[test] - fn test_extn_payload_provider_for_privacy_settings() { - let privacy_settings = PrivacySettings { - allow_acr_collection: true, - allow_resume_points: true, - allow_app_content_ad_targeting: true, - allow_business_analytics: true, - allow_camera_analytics: true, - allow_personalization: true, - allow_primary_browse_ad_targeting: true, - allow_primary_content_ad_targeting: true, - allow_product_analytics: true, - allow_remote_diagnostics: true, - allow_unentitled_personalization: true, - allow_unentitled_resume_points: true, - allow_watch_history: true, - }; - - let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyCloud); - test_extn_payload_provider(privacy_settings, contract_type); - } - - #[test] - fn test_extn_payload_provider_for_privacy_settings_data() { - let privacy_settings_data = PrivacySettingsData { - allow_acr_collection: Some(true), - allow_resume_points: Some(true), - allow_app_content_ad_targeting: Some(true), - allow_business_analytics: Some(true), - allow_camera_analytics: Some(true), - allow_personalization: Some(true), - allow_primary_browse_ad_targeting: Some(true), - allow_primary_content_ad_targeting: Some(true), - allow_product_analytics: Some(true), - allow_remote_diagnostics: Some(true), - allow_unentitled_personalization: Some(true), - allow_unentitled_resume_points: Some(true), - allow_watch_history: Some(true), - }; - - let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyLocal); - test_extn_payload_provider(privacy_settings_data, contract_type); - } + // All extension payload tests commented out - using direct RPC calls now + // The core data structures above are tested through RPC integration tests + + // use super::*; + // use crate::utils::test_utils::test_extn_payload_provider; + + // #[test] + // fn test_extn_payload_provider_for_exclusion_policy() { + // let exclusion_policy = ExclusionPolicy { + // acr: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched, DataEventType::BusinessIntelligence], + // entity_reference: vec![String::from("entity_reference_acr")], + // derivative_propagation: true, + // }), + // app_content_ad_targeting: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_app_content_ad_targeting")], + // derivative_propagation: false, + // }), + // business_analytics: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched, DataEventType::BusinessIntelligence], + // entity_reference: vec![String::from("entity_reference_business_analytics")], + // derivative_propagation: false, + // }), + // camera_analytics: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_camera_analytics")], + // derivative_propagation: true, + // }), + // continue_watching: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_continue_watching")], + // derivative_propagation: true, + // }), + // personalization: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_personalization")], + // derivative_propagation: true, + // }), + // primary_browse_ad_targeting: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from( + // "entity_reference_primary_browse_ad_targeting", + // )], + // derivative_propagation: true, + // }), + // primary_content_ad_targeting: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from( + // "entity_reference_primary_content_ad_targeting", + // )], + // derivative_propagation: true, + // }), + // product_analytics: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_product_analytics")], + // derivative_propagation: true, + // }), + // remote_diagnostics: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_remote_diagnostics")], + // derivative_propagation: true, + // }), + // unentitled_continue_watching: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from( + // "entity_reference_unentitled_continue_watching", + // )], + // derivative_propagation: true, + // }), + // unentitled_personalization: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_unentitled_personalization")], + // derivative_propagation: true, + // }), + // watch_history: Some(ExclusionPolicyData { + // data_events: vec![DataEventType::Watched], + // entity_reference: vec![String::from("entity_reference_watch_history")], + // derivative_propagation: true, + // }), + // }; + + // let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyCloud); + // test_extn_payload_provider(exclusion_policy, contract_type); + // } + + // #[test] + // fn test_extn_payload_provider_for_privacy_settings() { + // let privacy_settings = PrivacySettings { + // allow_acr_collection: true, + // allow_resume_points: true, + // allow_app_content_ad_targeting: true, + // allow_business_analytics: true, + // allow_camera_analytics: true, + // allow_personalization: true, + // allow_primary_browse_ad_targeting: true, + // allow_primary_content_ad_targeting: true, + // allow_product_analytics: true, + // allow_remote_diagnostics: true, + // allow_unentitled_personalization: true, + // allow_unentitled_resume_points: true, + // allow_watch_history: true, + // }; + + // let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyCloud); + // test_extn_payload_provider(privacy_settings, contract_type); + // } + + // #[test] + // fn test_extn_payload_provider_for_privacy_settings_data() { + // let privacy_settings_data = PrivacySettingsData { + // allow_acr_collection: Some(true), + // allow_resume_points: Some(true), + // allow_app_content_ad_targeting: Some(true), + // allow_business_analytics: Some(true), + // allow_camera_analytics: Some(true), + // allow_personalization: Some(true), + // allow_primary_browse_ad_targeting: Some(true), + // allow_primary_content_ad_targeting: Some(true), + // allow_product_analytics: Some(true), + // allow_remote_diagnostics: Some(true), + // allow_unentitled_personalization: Some(true), + // allow_unentitled_resume_points: Some(true), + // allow_watch_history: Some(true), + // }; + + // let contract_type: RippleContract = RippleContract::Storage(StorageAdjective::PrivacyLocal); + // test_extn_payload_provider(privacy_settings_data, contract_type); + // } } diff --git a/core/sdk/src/api/distributor/distributor_usergrants.rs b/core/sdk/src/api/distributor/distributor_usergrants.rs index 00208425f..fadd0fc84 100644 --- a/core/sdk/src/api/distributor/distributor_usergrants.rs +++ b/core/sdk/src/api/distributor/distributor_usergrants.rs @@ -19,11 +19,15 @@ use serde::{Deserialize, Serialize}; use crate::{ api::{ - firebolt::fb_capabilities::FireboltPermission, session::AccountSession, - storage_property::StorageAdjective, usergrant_entry::UserGrantInfo, + firebolt::fb_capabilities::FireboltPermission, + session::AccountSession, + // Removed StorageAdjective import - not needed for RPC-only functionality + // storage_property::StorageAdjective, + usergrant_entry::UserGrantInfo, }, - extn::extn_client_message::{ExtnPayload, ExtnPayloadProvider, ExtnRequest}, - framework::ripple_contract::RippleContract, + // Removed extension message imports - using direct RPC calls now + // extn::extn_client_message::{ExtnPayload, ExtnPayloadProvider, ExtnRequest}, + // framework::ripple_contract::RippleContract, }; #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] @@ -37,57 +41,66 @@ pub struct UserGrantsCloudSetParams { pub account_session: AccountSession, pub user_grant_info: UserGrantInfo, } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -pub enum UserGrantsCloudStoreRequest { - GetCloudUserGrants(UserGrantsCloudGetParams), - SetCloudUserGrants(UserGrantsCloudSetParams), -} +// +// OBSOLETE EXTENSION REQUEST INFRASTRUCTURE - REPLACED WITH DIRECT RPC CALLS +// The structs above (UserGrantsCloudGetParams, UserGrantsCloudSetParams) are still used by RPC handlers +// but the extension request processing below has been replaced with direct eos-distributor RPC calls +// -impl ExtnPayloadProvider for UserGrantsCloudStoreRequest { - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(self.clone())) - } +// #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] +// pub enum UserGrantsCloudStoreRequest { +// GetCloudUserGrants(UserGrantsCloudGetParams), +// SetCloudUserGrants(UserGrantsCloudSetParams), +// } - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(r)) = payload { - return Some(r); - } - None - } +// impl ExtnPayloadProvider for UserGrantsCloudStoreRequest { +// fn get_extn_payload(&self) -> ExtnPayload { +// ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(self.clone())) +// } - fn contract() -> RippleContract { - RippleContract::Storage(StorageAdjective::UsergrantCloud) - } -} +// fn get_from_payload(payload: ExtnPayload) -> Option { +// if let ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(r)) = payload { +// return Some(r); +// } +// None +// } + +// fn contract() -> RippleContract { +// RippleContract::Storage(StorageAdjective::UsergrantCloud) +// } +// } pub type UserGrants = Vec; #[cfg(test)] mod tests { - use super::*; - use crate::api::firebolt::fb_capabilities::{CapabilityRole, FireboltCap}; - use crate::utils::test_utils::test_extn_payload_provider; + // Extension payload tests commented out - using direct RPC calls now + // The parameter structs above are tested through RPC integration tests + + // use super::*; + // use crate::api::firebolt::fb_capabilities::{CapabilityRole, FireboltCap}; + // use crate::utils::test_utils::test_extn_payload_provider; - #[test] - fn test_extn_request_user_grants_cloud_store() { - let user_grants_get_params = UserGrantsCloudGetParams { - app_id: "test_app_id".to_string(), - permission: FireboltPermission { - cap: FireboltCap::Short("test_short_cap".to_string()), - role: CapabilityRole::Use, - }, - account_session: AccountSession { - id: "test_session_id".to_string(), - token: "test_token".to_string(), - account_id: "test_account_id".to_string(), - device_id: "test_device_id".to_string(), - }, - }; + // #[test] + // fn test_extn_request_user_grants_cloud_store() { + // let user_grants_get_params = UserGrantsCloudGetParams { + // app_id: "test_app_id".to_string(), + // permission: FireboltPermission { + // cap: FireboltCap::Short("test_short_cap".to_string()), + // role: CapabilityRole::Use, + // }, + // account_session: AccountSession { + // id: "test_session_id".to_string(), + // token: "test_token".to_string(), + // account_id: "test_account_id".to_string(), + // device_id: "test_device_id".to_string(), + // }, + // }; - let user_grants_request = - UserGrantsCloudStoreRequest::GetCloudUserGrants(user_grants_get_params); + // let user_grants_request = + // UserGrantsCloudStoreRequest::GetCloudUserGrants(user_grants_get_params); - let contract_type = RippleContract::Storage(StorageAdjective::UsergrantCloud); - test_extn_payload_provider(user_grants_request, contract_type); - } + // let contract_type = RippleContract::Storage(StorageAdjective::UsergrantCloud); + // test_extn_payload_provider(user_grants_request, contract_type); + // } } diff --git a/core/sdk/src/api/storage_property.rs b/core/sdk/src/api/storage_property.rs index 425849619..b7792db53 100644 --- a/core/sdk/src/api/storage_property.rs +++ b/core/sdk/src/api/storage_property.rs @@ -657,8 +657,8 @@ impl ExtnPayloadProvider for StorageManagerRequest { pub enum StorageAdjective { PrivacyCloud, PrivacyLocal, - UsergrantCloud, - UsergrantLocal, + //UsergrantCloud, + //UsergrantLocal, Local, Manager, Secure, diff --git a/core/sdk/src/api/usergrant_entry.rs b/core/sdk/src/api/usergrant_entry.rs index a3559f99d..0158f79ad 100644 --- a/core/sdk/src/api/usergrant_entry.rs +++ b/core/sdk/src/api/usergrant_entry.rs @@ -28,14 +28,6 @@ use super::device::device_user_grants_data::{GrantLifespan, GrantStatus, PolicyP use super::firebolt::fb_capabilities::FireboltPermission; use super::storage_property::StorageAdjective; -#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] -pub enum UserGrantsStoreRequest { - GetUserGrants(String, FireboltPermission), - SetUserGrants(UserGrantInfo), - SyncGrantMapPerPolicy(), - ClearUserGrants(PolicyPersistenceType), -} - #[derive(Clone, Debug, Deserialize)] pub enum UserGrantsPersistenceType { Account, @@ -51,24 +43,6 @@ impl UserGrantsPersistenceType { } } -impl ExtnPayloadProvider for UserGrantsStoreRequest { - fn get_extn_payload(&self) -> ExtnPayload { - ExtnPayload::Request(ExtnRequest::UserGrantsStore(self.clone())) - } - - fn get_from_payload(payload: ExtnPayload) -> Option { - if let ExtnPayload::Request(ExtnRequest::UserGrantsStore(r)) = payload { - return Some(r); - } - - None - } - - fn contract() -> RippleContract { - RippleContract::Storage(StorageAdjective::UsergrantLocal) - } -} - #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] pub struct UserGrantInfo { pub role: CapabilityRole, @@ -100,21 +74,6 @@ mod tests { use crate::api::firebolt::fb_capabilities::{CapabilityRole, FireboltCap}; use crate::utils::test_utils::test_extn_payload_provider; - #[test] - fn test_extn_request_user_grants_store() { - let user_id = "test_user_id".to_string(); - let firebolt_permission = FireboltPermission { - cap: FireboltCap::Short("test_short_cap".to_string()), - role: CapabilityRole::Use, - }; - - let user_grants_request = - UserGrantsStoreRequest::GetUserGrants(user_id, firebolt_permission); - let contract_type: RippleContract = - RippleContract::Storage(StorageAdjective::UsergrantLocal); - - test_extn_payload_provider(user_grants_request, contract_type); - } #[test] fn test_user_grants_persistence_type_as_string() { assert_eq!(UserGrantsPersistenceType::Account.as_string(), "account"); @@ -132,42 +91,4 @@ mod tests { assert_eq!(default_info.app_name, None); assert_eq!(default_info.lifespan, GrantLifespan::Once); } - - #[test] - fn test_set_user_grants_request() { - let user_grant_info = UserGrantInfo { - role: CapabilityRole::Manage, - capability: "test_capability".to_string(), - status: Some(GrantStatus::Allowed), - last_modified_time: Duration::new(1000, 0), - expiry_time: Some(Duration::new(2000, 0)), - app_name: Some("test_app".to_string()), - lifespan: GrantLifespan::Forever, - }; - - let user_grants_request = UserGrantsStoreRequest::SetUserGrants(user_grant_info.clone()); - let contract_type: RippleContract = - RippleContract::Storage(StorageAdjective::UsergrantLocal); - - test_extn_payload_provider(user_grants_request, contract_type); - } - - #[test] - fn test_sync_grant_map_per_policy_request() { - let user_grants_request = UserGrantsStoreRequest::SyncGrantMapPerPolicy(); - let contract_type: RippleContract = - RippleContract::Storage(StorageAdjective::UsergrantLocal); - - test_extn_payload_provider(user_grants_request, contract_type); - } - - #[test] - fn test_clear_user_grants_request() { - let persistence_type = PolicyPersistenceType::Account; - let user_grants_request = UserGrantsStoreRequest::ClearUserGrants(persistence_type); - let contract_type: RippleContract = - RippleContract::Storage(StorageAdjective::UsergrantLocal); - - test_extn_payload_provider(user_grants_request, contract_type); - } } diff --git a/core/sdk/src/extn/extn_client_message.rs b/core/sdk/src/extn/extn_client_message.rs index 1def4c5e9..ebb2a9685 100644 --- a/core/sdk/src/extn/extn_client_message.rs +++ b/core/sdk/src/extn/extn_client_message.rs @@ -38,11 +38,7 @@ use crate::{ device_peristence::StorageData, device_request::{DeviceRequest, NetworkResponse, TimeZone}, }, - distributor::{ - distributor_permissions::{PermissionRequest, PermissionResponse}, - distributor_privacy::{PrivacyCloudRequest, PrivacySettingsStoreRequest}, - distributor_usergrants::UserGrantsCloudStoreRequest, - }, + distributor::distributor_permissions::{PermissionRequest, PermissionResponse}, firebolt::{ fb_keyboard::{KeyboardSessionRequest, KeyboardSessionResponse}, fb_lifecycle_management::LifecycleManagementRequest, @@ -55,7 +51,6 @@ use crate::{ settings::{SettingValue, SettingsRequest}, status_update::ExtnStatus, storage_property::StorageManagerRequest, - usergrant_entry::UserGrantsStoreRequest, }, framework::ripple_contract::RippleContract, utils::error::RippleError, @@ -454,12 +449,8 @@ pub enum ExtnRequest { Keyboard(KeyboardSessionRequest), Permission(PermissionRequest), AccountSession(AccountSessionRequest), - PrivacySettings(PrivacyCloudRequest), StorageManager(StorageManagerRequest), Settings(SettingsRequest), - UserGrantsCloudStore(UserGrantsCloudStoreRequest), - UserGrantsStore(UserGrantsStoreRequest), - PrivacySettingsStore(PrivacySettingsStoreRequest), AuthorizedInfo(CapsRequest), OperationalMetricsRequest(OperationalMetricRequest), Context(RippleContextUpdateRequest), diff --git a/core/sdk/src/framework/ripple_contract.rs b/core/sdk/src/framework/ripple_contract.rs index 96e9a8793..1563dcb14 100644 --- a/core/sdk/src/framework/ripple_contract.rs +++ b/core/sdk/src/framework/ripple_contract.rs @@ -81,8 +81,6 @@ pub enum RippleContract { AppEvents, /// Device channel specific events which get cascaded across Main and Extensions like Power, HDCP DeviceEvents(EventAdjective), - /// Contract which controls User Privacy Settings will become an Adjective in near future - PrivacySettings, /// Contract to allow Extensions to get and set Settings. Settings, /// Extensions can use this contract to get more information on the firebolt capabilities diff --git a/distributor/general/src/distributor_general_ffi.rs b/distributor/general/src/distributor_general_ffi.rs index 0764803fc..ee1e8504d 100644 --- a/distributor/general/src/distributor_general_ffi.rs +++ b/distributor/general/src/distributor_general_ffi.rs @@ -36,10 +36,7 @@ use ripple_sdk::{ utils::{error::RippleError, extn_utils::ExtnUtils, logger::init_logger}, }; -use crate::{ - general_permission_processor::DistributorPermissionProcessor, - general_privacy_processor::DistributorPrivacyProcessor, -}; +use crate::general_permission_processor::DistributorPermissionProcessor; fn init_library() -> CExtnMetadata { let _ = init_logger("distributor_general".into()); @@ -49,7 +46,6 @@ fn init_library() -> CExtnMetadata { ContractFulfiller::new(vec![ RippleContract::Permissions, RippleContract::Storage(StorageAdjective::Secure), - RippleContract::Storage(StorageAdjective::PrivacyCloud), ]), Version::new(1, 1, 0), ); @@ -73,11 +69,14 @@ fn start_launcher(sender: ExtnSender, receiver: CReceiver) { let client_c = client.clone(); tokio::spawn(async move { if let Ok(response) = client.request(Config::SavedDir).await { - if let Some(ExtnResponse::String(value)) = response.payload.extract() { - client.add_request_processor(DistributorPrivacyProcessor::new( - client.clone(), - value.clone(), - )); + if let Some(ExtnResponse::String(_value)) = response.payload.extract() { + // Stubbed out - DistributorPrivacyProcessor replaced with direct RPC calls + // Privacy operations now handled by distributor RPC API + debug!("Privacy processor stubbed out - using direct RPC calls instead"); + // client.add_request_processor(DistributorPrivacyProcessor::new( + // client.clone(), + // value.clone(), + // )); } } From 80d6ed361f92b5f0162709e0d3b7773e9fc91c0c Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Thu, 25 Sep 2025 10:05:54 -0700 Subject: [PATCH 2/6] Fixed clippy warnings --- core/sdk/src/api/usergrant_entry.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/core/sdk/src/api/usergrant_entry.rs b/core/sdk/src/api/usergrant_entry.rs index 0158f79ad..bc64549ed 100644 --- a/core/sdk/src/api/usergrant_entry.rs +++ b/core/sdk/src/api/usergrant_entry.rs @@ -18,15 +18,10 @@ use std::time::Duration; use crate::api::firebolt::fb_capabilities::CapabilityRole; -use crate::{ - extn::extn_client_message::{ExtnPayload, ExtnPayloadProvider, ExtnRequest}, - framework::ripple_contract::RippleContract, -}; + use serde::{Deserialize, Serialize}; -use super::device::device_user_grants_data::{GrantLifespan, GrantStatus, PolicyPersistenceType}; -use super::firebolt::fb_capabilities::FireboltPermission; -use super::storage_property::StorageAdjective; +use super::device::device_user_grants_data::{GrantLifespan, GrantStatus}; #[derive(Clone, Debug, Deserialize)] pub enum UserGrantsPersistenceType { From ab999f9ee6faa3f68ec3cb920bdf42507b423b60 Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Thu, 25 Sep 2025 13:31:32 -0700 Subject: [PATCH 3/6] Fixed more clippy warnings --- .../main/src/firebolt/handlers/privacy_rpc.rs | 42 +++++++------------ core/sdk/src/api/usergrant_entry.rs | 3 +- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/core/main/src/firebolt/handlers/privacy_rpc.rs b/core/main/src/firebolt/handlers/privacy_rpc.rs index 6e7147c76..08dfef862 100644 --- a/core/main/src/firebolt/handlers/privacy_rpc.rs +++ b/core/main/src/firebolt/handlers/privacy_rpc.rs @@ -38,7 +38,7 @@ use ripple_sdk::{ fb_capabilities::{CapabilityRole, FireboltCap, RoleInfo, CAPABILITY_NOT_AVAILABLE}, fb_general::{ListenRequest, ListenerResponse}, }, - gateway::rpc_gateway_api::{ApiProtocol, CallContext, RpcRequest}, + gateway::rpc_gateway_api::CallContext, storage_property::{ StorageProperty::{ self, AllowAcrCollection, AllowAppContentAdTargeting, AllowBusinessAnalytics, @@ -56,10 +56,8 @@ use ripple_sdk::{ EVENT_ALLOW_UNENTITLED_RESUME_POINTS_CHANGED, EVENT_ALLOW_WATCH_HISTORY_CHANGED, }, }, - extn::extn_client_message::ExtnPayload, - extn::extn_client_message::ExtnResponse, log::{debug, error}, - serde_json::{from_value, json}, + serde_json::json, }; use super::advertising_rpc::ScopeOption; @@ -92,35 +90,25 @@ impl AllowAppContentAdTargetingSettings { platform_state: &mut PlatformState, ctx: &CallContext, ) -> HashMap { - let mut new_ctx = ctx.clone(); - new_ctx.protocol = ApiProtocol::Extn; - platform_state .metrics .add_api_stats(&ctx.request_id, "localization.countryCode"); - let rpc_request = RpcRequest { - ctx: new_ctx.clone(), - method: "localization.countryCode".into(), - params_json: RpcRequest::prepend_ctx(None, &new_ctx), - }; - let resp = platform_state - .get_client() - .get_extn_client() - .main_internal_request(rpc_request.clone()) - .await; - - let country_code = if let Ok(res) = resp.clone() { - if let Some(ExtnResponse::Value(val)) = res.payload.extract::() { - match from_value::(val) { - Ok(v) => v, - Err(_) => "US".to_owned(), + let country_code = match BrokerUtils::process_internal_main_request( + platform_state, + "localization.countryCode", + None, + ) + .await + { + Ok(response_value) => { + if let Ok(country) = serde_json::from_value::(response_value) { + country + } else { + "US".to_owned() } - } else { - "US".to_owned() } - } else { - "US".to_owned() + Err(_) => "US".to_owned(), }; [ diff --git a/core/sdk/src/api/usergrant_entry.rs b/core/sdk/src/api/usergrant_entry.rs index bc64549ed..b85da56bb 100644 --- a/core/sdk/src/api/usergrant_entry.rs +++ b/core/sdk/src/api/usergrant_entry.rs @@ -66,8 +66,7 @@ impl Default for UserGrantInfo { #[cfg(test)] mod tests { use super::*; - use crate::api::firebolt::fb_capabilities::{CapabilityRole, FireboltCap}; - use crate::utils::test_utils::test_extn_payload_provider; + use crate::api::firebolt::fb_capabilities::CapabilityRole; #[test] fn test_user_grants_persistence_type_as_string() { From 29a0bec06249bc1e1c18f48fec7161485c79f13f Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Thu, 23 Oct 2025 13:36:46 -0700 Subject: [PATCH 4/6] Added support for batch update of usergrants --- .../src/firebolt/handlers/user_grants_rpc.rs | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/core/main/src/firebolt/handlers/user_grants_rpc.rs b/core/main/src/firebolt/handlers/user_grants_rpc.rs index d29bd328f..f811644c1 100644 --- a/core/main/src/firebolt/handlers/user_grants_rpc.rs +++ b/core/main/src/firebolt/handlers/user_grants_rpc.rs @@ -85,10 +85,10 @@ pub trait UserGrants { #[method(name = "ripple.clearUserGrants")] async fn clear_user_grants(&self, ctx: CallContext) -> RpcResult<()>; #[method(name = "ripple.setUserGrants")] - async fn set_user_grant( + async fn set_user_grants( &self, ctx: CallContext, - user_grant_info: UserGrantInfo, + user_grant_info: Vec, ) -> RpcResult<()>; #[method(name = "ripple.syncGrantsMap")] async fn sync_user_grants_map(&self, ctx: CallContext) -> RpcResult<()>; @@ -184,35 +184,40 @@ impl UserGrantsImpl { #[async_trait] impl UserGrantsServer for UserGrantsImpl { - async fn set_user_grant( + async fn set_user_grants( &self, _ctx: CallContext, - user_grant_info: UserGrantInfo, + user_grant_info: Vec, ) -> RpcResult<()> { debug!("Handling set user grant request: {:?}", user_grant_info); - let app_id = user_grant_info.app_name.to_owned(); - let grant_entry = GrantEntry { - role: user_grant_info.role, - capability: user_grant_info.capability.to_owned(), - status: user_grant_info.status, - lifespan: match user_grant_info.expiry_time { - Some(_) => Some(GrantLifespan::Seconds), - None => Some(GrantLifespan::Forever), - }, - last_modified_time: user_grant_info.last_modified_time, - lifespan_ttl_in_secs: user_grant_info.expiry_time.map(|epoch_duration| { - epoch_duration - .as_secs() - .saturating_sub(user_grant_info.last_modified_time.as_secs()) - }), - }; - let _ = self - .platform_state - .cap_state - .grant_state - .update_grant_entry(app_id, grant_entry); + + for grant_info in user_grant_info { + let app_id = grant_info.app_name.to_owned(); + let grant_entry = GrantEntry { + role: grant_info.role, + capability: grant_info.capability.to_owned(), + status: grant_info.status, + lifespan: match grant_info.expiry_time { + Some(_) => Some(GrantLifespan::Seconds), + None => Some(GrantLifespan::Forever), + }, + last_modified_time: grant_info.last_modified_time, + lifespan_ttl_in_secs: grant_info.expiry_time.map(|epoch_duration| { + epoch_duration + .as_secs() + .saturating_sub(grant_info.last_modified_time.as_secs()) + }), + }; + let _ = self + .platform_state + .cap_state + .grant_state + .update_grant_entry(app_id, grant_entry); + } + Ok(()) } + async fn sync_user_grants_map(&self, _ctx: CallContext) -> RpcResult<()> { debug!("Handling sync grant map request"); let _ = self From a1c28ad2c04d1cecf552943749432c38a9791bf6 Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Fri, 24 Oct 2025 10:52:42 -0700 Subject: [PATCH 5/6] Synced up Read-after-connect changes from Release branch --- .../firebolt/handlers/provider_registrar.rs | 4 ++-- core/main/src/state/cap/permitted_state.rs | 7 +++++- core/main/src/state/ops_metrics_state.rs | 8 +++---- core/sdk/src/api/device/device_request.rs | 21 ++++++++++++++++- core/sdk/src/utils/ws_utils.rs | 23 +++++++++++++++++-- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/core/main/src/firebolt/handlers/provider_registrar.rs b/core/main/src/firebolt/handlers/provider_registrar.rs index f5b88ebd2..5d9d51b94 100644 --- a/core/main/src/firebolt/handlers/provider_registrar.rs +++ b/core/main/src/firebolt/handlers/provider_registrar.rs @@ -160,8 +160,8 @@ impl ProviderRegistrar { rpc_module: &mut RpcModule, ) -> bool { info!( - "register_method: method_name={}, method_type={:?}, rpc_module={:?}", - method_name, method_type, rpc_module + "register_method: method_name={}, method_type={:?}", + method_name, method_type ); let result = match method_type { diff --git a/core/main/src/state/cap/permitted_state.rs b/core/main/src/state/cap/permitted_state.rs index b24ae9c98..b3810199f 100644 --- a/core/main/src/state/cap/permitted_state.rs +++ b/core/main/src/state/cap/permitted_state.rs @@ -187,11 +187,16 @@ impl PermissionHandler { &mut permission_response_copy, ); } + error!("cloud_fetch_and_store : Invalid permission_response"); + Err(RippleError::InvalidOutput) + } + None => { + error!("cloud_fetch_and_store : No extn_response found"); Err(RippleError::InvalidOutput) } - None => Err(RippleError::InvalidOutput), } } else { + error!("cloud_fetch_and_store : No account session found"); Err(RippleError::InvalidOutput) } } diff --git a/core/main/src/state/ops_metrics_state.rs b/core/main/src/state/ops_metrics_state.rs index 001a22534..6691683b4 100644 --- a/core/main/src/state/ops_metrics_state.rs +++ b/core/main/src/state/ops_metrics_state.rs @@ -23,7 +23,7 @@ use std::{ use ripple_sdk::{ api::observability::metrics_util::ApiStats, chrono::{DateTime, Utc}, - log::{error, warn}, + log::trace, }; include!(concat!(env!("OUT_DIR"), "/version.rs")); @@ -79,7 +79,7 @@ impl OpMetricState { let size = api_stats_map.len(); if size >= API_STATS_MAP_SIZE_WARNING { - warn!("add_api_stats: api_stats_map size warning: {}", size); + trace!("add_api_stats: api_stats_map size warning: {}", size); } } @@ -93,7 +93,7 @@ impl OpMetricState { if let Some(stats) = api_stats_map.get_mut(request_id) { stats.stats_ref = stats_ref; } else { - println!( + trace!( "update_api_stats_ref: request_id not found: request_id={}", request_id ); @@ -105,7 +105,7 @@ impl OpMetricState { if let Some(stats) = api_stats_map.get_mut(request_id) { stats.stats.update_stage(stage) } else { - error!( + trace!( "update_api_stage: request_id not found: request_id={}", request_id ); diff --git a/core/sdk/src/api/device/device_request.rs b/core/sdk/src/api/device/device_request.rs index 7ad0b5a67..25d7782a6 100644 --- a/core/sdk/src/api/device/device_request.rs +++ b/core/sdk/src/api/device/device_request.rs @@ -87,12 +87,31 @@ impl std::fmt::Display for AudioProfile { } } -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] pub struct AccountToken { pub token: String, pub expires: u64, } +impl std::fmt::Debug for AccountToken { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("AccountToken") + .field("token", &"****") + .field("expires", &self.expires) + .finish() + } +} + +impl std::fmt::Display for AccountToken { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "AccountToken {{ token: ****, expires: {} }}", + self.expires + ) + } +} + #[derive(Debug, Serialize, Deserialize)] pub struct DeviceVersionResponse { pub api: FireboltSemanticVersion, diff --git a/core/sdk/src/utils/ws_utils.rs b/core/sdk/src/utils/ws_utils.rs index 0dd16a1e9..750e5e617 100644 --- a/core/sdk/src/utils/ws_utils.rs +++ b/core/sdk/src/utils/ws_utils.rs @@ -202,11 +202,20 @@ impl WebSocketUtils { RippleError, > { let mut index: i32 = 0; + let mut retry_count: u32 = 0; let mut delay_duration = tokio::time::Duration::from_millis(retry_every); + loop { match Self::connect_tcp_port(&tcp_port, &url_path).await { Ok(v) => { - info!("Websocket TCP Connection with {} succeeded", url_path); + if retry_count > 0 { + info!( + "Websocket TCP Connection with {} succeeded after {} retries", + url_path, retry_count + ); + } else { + info!("Websocket TCP Connection with {} succeeded", url_path); + } break Ok(v); } Err(e) => { @@ -220,18 +229,28 @@ impl WebSocketUtils { } } } + if let Some(fail) = &config.fail_after { if fail.eq(&index) { + warn!( + "Websocket TCP Connection with {} failed after {} retries", + url_path, retry_count + ); break Err(RippleError::NotAvailable); } } + index += 1; + retry_count += 1; + warn!( - "new Websocket TCP Connection with {} failed with retry for last {} millisecs in {}", + "Websocket TCP Connection with {} failed (retry #{}) - retrying after {} ms on {}", url_path, + retry_count, delay_duration.as_millis(), tcp_port ); + if delay_duration < tokio::time::Duration::from_secs(3) { delay_duration *= 2; } From c15c579b4b66cd74e6d3fdd9adc4b7a56fc3ad23 Mon Sep 17 00:00:00 2001 From: VinodSathyaseelan Date: Fri, 24 Oct 2025 11:24:21 -0700 Subject: [PATCH 6/6] Removed the unused privacy_settings and usergrants processors from the project --- core/main/src/processor/mod.rs | 2 - .../store_privacy_settings_processor.rs | 249 ------------------ .../processor/store_user_grants_processor.rs | 204 -------------- .../api/distributor/distributor_privacy.rs | 134 ---------- .../api/distributor/distributor_usergrants.rs | 42 +-- core/sdk/src/api/storage_property.rs | 4 - 6 files changed, 3 insertions(+), 632 deletions(-) delete mode 100644 core/main/src/processor/store_privacy_settings_processor.rs delete mode 100644 core/main/src/processor/store_user_grants_processor.rs diff --git a/core/main/src/processor/mod.rs b/core/main/src/processor/mod.rs index e150eafb4..8a86607d8 100644 --- a/core/main/src/processor/mod.rs +++ b/core/main/src/processor/mod.rs @@ -25,5 +25,3 @@ pub mod pin_processor; pub mod rpc_gateway_processor; pub mod settings_processor; pub mod storage; -pub mod store_privacy_settings_processor; -pub mod store_user_grants_processor; diff --git a/core/main/src/processor/store_privacy_settings_processor.rs b/core/main/src/processor/store_privacy_settings_processor.rs deleted file mode 100644 index 4c61b5b03..000000000 --- a/core/main/src/processor/store_privacy_settings_processor.rs +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2023 Comcast Cable Communications Management, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 -// - -/* -COMMENTED OUT: This processor is now dead code after migration to RPC handlers -All privacy settings functionality has been migrated to distributor.privacy RPC methods: -- distributor.privacy.getProperty -- distributor.privacy.getProperties -- distributor.privacy.setProperty -- distributor.privacy.getPartnerExclusions -The PrivacySettingsStoreRequest enum is commented out, making this processor non-functional - -use crate::processor::storage::storage_manager::StorageManager; -use crate::state::platform_state::PlatformState; -use ripple_sdk::{ - api::{ - distributor::distributor_privacy::{PrivacySettingsData, PrivacySettingsStoreRequest}, - storage_property::StorageProperty::{ - self, AllowAcrCollection, AllowAppContentAdTargeting, AllowBusinessAnalytics, - AllowCameraAnalytics, AllowPersonalization, AllowPrimaryBrowseAdTargeting, - AllowPrimaryContentAdTargeting, AllowProductAnalytics, AllowRemoteDiagnostics, - AllowResumePoints, AllowUnentitledPersonalization, AllowUnentitledResumePoints, - AllowWatchHistory, - }, - }, - async_trait::async_trait, - extn::{ - client::extn_processor::{ - DefaultExtnStreamer, ExtnRequestProcessor, ExtnStreamProcessor, ExtnStreamer, - }, - extn_client_message::ExtnMessage, - extn_client_message::ExtnResponse, - }, - log::{debug, error}, - tokio::sync::mpsc::{Receiver as MReceiver, Sender as MSender}, - utils::error::RippleError, -}; - -#[derive(Debug)] -pub struct StorePrivacySettingsProcessor { - state: PlatformState, - streamer: DefaultExtnStreamer, -} - -impl StorePrivacySettingsProcessor { - pub fn new(state: PlatformState) -> StorePrivacySettingsProcessor { - StorePrivacySettingsProcessor { - state, - streamer: DefaultExtnStreamer::new(), - } - } -} - -impl ExtnStreamProcessor for StorePrivacySettingsProcessor { - type STATE = PlatformState; - type VALUE = PrivacySettingsStoreRequest; - fn get_state(&self) -> Self::STATE { - self.state.clone() - } - - fn sender(&self) -> MSender { - self.streamer.sender() - } - - fn receiver(&mut self) -> MReceiver { - self.streamer.receiver() - } -} -impl StorePrivacySettingsProcessor { - async fn process_set_request( - state: &PlatformState, - msg: ExtnMessage, - storage_property: StorageProperty, - value: bool, - ) -> bool { - let result = StorageManager::set_bool(state, storage_property, value, None).await; - if result.is_ok() { - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } else { - Self::handle_error( - state.get_client().get_extn_client(), - msg, - RippleError::ProcessorError, - ) - .await - } - } - async fn process_get_request( - state: &PlatformState, - msg: ExtnMessage, - storage_property: StorageProperty, - ) -> bool { - let result = StorageManager::get_bool(state, storage_property).await; - match result { - Ok(val) => Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::Boolean(val), - ) - .await - .is_ok(), - Err(_err) => { - Self::handle_error( - state.get_client().get_extn_client(), - msg, - RippleError::ProcessorError, - ) - .await - } - } - } - async fn process_set_all_request( - state: &PlatformState, - msg: ExtnMessage, - privacy_settings_data: PrivacySettingsData, - ) -> bool { - let mut err = false; - macro_rules! set_property { - ($property:ident, $value:expr) => { - if let Some(value) = $value { - let res = StorageManager::set_bool(state, $property, value, None).await; - if let Err(e) = res { - error!("Unable to set property {:?} error: {:?}", $property, e); - err = true; - } - } - }; - } - - set_property!( - AllowAcrCollection, - privacy_settings_data.allow_acr_collection - ); - set_property!(AllowResumePoints, privacy_settings_data.allow_resume_points); - set_property!( - AllowAppContentAdTargeting, - privacy_settings_data.allow_app_content_ad_targeting - ); - - // business analytics is a special case, if it is not set, we set it to true - if privacy_settings_data.allow_business_analytics.is_none() { - set_property!(AllowBusinessAnalytics, Some(true)); - } else { - set_property!( - AllowBusinessAnalytics, - privacy_settings_data.allow_business_analytics - ); - } - set_property!( - AllowCameraAnalytics, - privacy_settings_data.allow_camera_analytics - ); - set_property!( - AllowPersonalization, - privacy_settings_data.allow_personalization - ); - set_property!( - AllowPrimaryBrowseAdTargeting, - privacy_settings_data.allow_primary_browse_ad_targeting - ); - set_property!( - AllowPrimaryContentAdTargeting, - privacy_settings_data.allow_primary_content_ad_targeting - ); - set_property!( - AllowProductAnalytics, - privacy_settings_data.allow_product_analytics - ); - set_property!( - AllowRemoteDiagnostics, - privacy_settings_data.allow_remote_diagnostics - ); - set_property!( - AllowUnentitledPersonalization, - privacy_settings_data.allow_unentitled_personalization - ); - set_property!( - AllowUnentitledResumePoints, - privacy_settings_data.allow_unentitled_resume_points - ); - set_property!(AllowWatchHistory, privacy_settings_data.allow_watch_history); - - if err { - return Self::handle_error( - state.get_client().get_extn_client(), - msg, - RippleError::ProcessorError, - ) - .await; - } - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } -} - -#[async_trait] -impl ExtnRequestProcessor for StorePrivacySettingsProcessor { - fn get_client(&self) -> ripple_sdk::extn::client::extn_client::ExtnClient { - self.state.get_client().get_extn_client() - } - - async fn process_request( - state: Self::STATE, - msg: ExtnMessage, - extracted_message: Self::VALUE, - ) -> bool { - debug!( - "processor received extracted message: {:?}", - extracted_message - ); - match extracted_message { - PrivacySettingsStoreRequest::GetPrivacySettings(storage_property) => { - Self::process_get_request(&state, msg, storage_property).await - } - PrivacySettingsStoreRequest::SetAllPrivacySettings(privacy_settings_data) => { - Self::process_set_all_request(&state, msg, privacy_settings_data).await - } - PrivacySettingsStoreRequest::SetPrivacySettings(storage_property, value) => { - Self::process_set_request(&state, msg, storage_property, value).await - } - } - } -} -*/ diff --git a/core/main/src/processor/store_user_grants_processor.rs b/core/main/src/processor/store_user_grants_processor.rs deleted file mode 100644 index 0906b0872..000000000 --- a/core/main/src/processor/store_user_grants_processor.rs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2023 Comcast Cable Communications Management, LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: Apache-2.0 - -// -// COMMENTED OUT: This processor is now dead code after migration to RPC handlers -// All user grants functionality has been migrated to distributor.usergrants RPC methods: -// - distributor.usergrants.getCloudUserGrants -// - distributor.usergrants.setCloudUserGrants -// The UserGrantsStoreRequest enum is commented out, making this processor non-functional - -/* -use crate::state::platform_state::PlatformState; -use ripple_sdk::{ - api::{ - device::device_user_grants_data::{ - GrantEntry, GrantLifespan, GrantStatus, PolicyPersistenceType, - }, - firebolt::fb_capabilities::FireboltPermission, - usergrant_entry::{UserGrantInfo, UserGrantsStoreRequest}, - }, - async_trait::async_trait, - extn::client::extn_processor::{ - DefaultExtnStreamer, ExtnRequestProcessor, ExtnStreamProcessor, ExtnStreamer, - }, - extn::extn_client_message::{ExtnMessage, ExtnResponse}, - log::debug, - tokio::sync::mpsc::{Receiver as MReceiver, Sender as MSender}, -}; -#[derive(Debug)] -pub struct StoreUserGrantsProcessor { - state: PlatformState, - streamer: DefaultExtnStreamer, -} - -impl StoreUserGrantsProcessor { - pub fn new(state: PlatformState) -> StoreUserGrantsProcessor { - StoreUserGrantsProcessor { - state, - streamer: DefaultExtnStreamer::new(), - } - } -} - -impl ExtnStreamProcessor for StoreUserGrantsProcessor { - type STATE = PlatformState; - type VALUE = UserGrantsStoreRequest; - fn get_state(&self) -> Self::STATE { - self.state.clone() - } - - fn sender(&self) -> MSender { - self.streamer.sender() - } - - fn receiver(&mut self) -> MReceiver { - self.streamer.receiver() - } -} - -impl StoreUserGrantsProcessor { - async fn process_get_request( - state: &PlatformState, - msg: ExtnMessage, - app_id: String, - permission: FireboltPermission, - ) -> bool { - let result = state - .cap_state - .grant_state - .get_grant_status(&app_id, &permission); - if let Some(granted) = result { - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::Boolean(match granted { - GrantStatus::Allowed => true, - GrantStatus::Denied => false, - }), - ) - .await - .is_ok() - } else { - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } - } - async fn process_set_request( - state: &PlatformState, - msg: ExtnMessage, - user_grant_info: UserGrantInfo, - ) -> bool { - debug!("Processor is handling set request: {:?}", user_grant_info); - let app_id = user_grant_info.app_name.to_owned(); - let grant_entry = GrantEntry { - role: user_grant_info.role, - capability: user_grant_info.capability.to_owned(), - status: user_grant_info.status, - lifespan: match user_grant_info.expiry_time { - Some(_) => Some(GrantLifespan::Seconds), - None => Some(GrantLifespan::Forever), - }, - last_modified_time: user_grant_info.last_modified_time, - lifespan_ttl_in_secs: user_grant_info.expiry_time.map(|epoch_duration| { - epoch_duration - .as_secs() - .saturating_sub(user_grant_info.last_modified_time.as_secs()) - }), - }; - state - .cap_state - .grant_state - .update_grant_entry(app_id, grant_entry); - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } - - async fn process_sync_grant_map(state: &PlatformState, msg: ExtnMessage) -> bool { - debug!("Processor is handling sync grant map request"); - state - .cap_state - .grant_state - .sync_grant_map_with_grant_policy(state) - .await; - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } - - async fn process_clear_request( - state: &PlatformState, - msg: ExtnMessage, - persistence_type: PolicyPersistenceType, - ) -> bool { - debug!("Processor is handling clear request"); - state - .cap_state - .grant_state - .clear_local_entries(state, persistence_type); - Self::respond( - state.get_client().get_extn_client(), - msg, - ExtnResponse::None(()), - ) - .await - .is_ok() - } -} - -#[async_trait] -impl ExtnRequestProcessor for StoreUserGrantsProcessor { - fn get_client(&self) -> ripple_sdk::extn::client::extn_client::ExtnClient { - self.state.get_client().get_extn_client() - } - - async fn process_request( - state: Self::STATE, - msg: ExtnMessage, - extracted_message: Self::VALUE, - ) -> bool { - debug!("process request: Received message: {:?}", extracted_message); - match extracted_message { - UserGrantsStoreRequest::GetUserGrants(app_id, permission) => { - Self::process_get_request(&state, msg, app_id, permission).await - } - UserGrantsStoreRequest::SetUserGrants(user_grant_info) => { - Self::process_set_request(&state, msg, user_grant_info).await - } - UserGrantsStoreRequest::SyncGrantMapPerPolicy() => { - Self::process_sync_grant_map(&state, msg).await - } - UserGrantsStoreRequest::ClearUserGrants(persistence_type) => { - Self::process_clear_request(&state, msg, persistence_type).await - } - } - } -} -*/ diff --git a/core/sdk/src/api/distributor/distributor_privacy.rs b/core/sdk/src/api/distributor/distributor_privacy.rs index 8ab513be1..15abd2967 100644 --- a/core/sdk/src/api/distributor/distributor_privacy.rs +++ b/core/sdk/src/api/distributor/distributor_privacy.rs @@ -194,75 +194,6 @@ impl From for PrivacySettingsData { } } } - -//impl ExtnPayloadProvider for PrivacySettingsStoreRequest { -// fn get_from_payload(payload: ExtnPayload) -> Option { -// match payload { -// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(storage_request)) => { -// Some(storage_request) -// } -// _ => None, -// } -// } -// -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore(self.clone())) -// } -// -// fn contract() -> RippleContract { -// RippleContract::Storage(StorageAdjective::PrivacyLocal) -// } -//} - -// -// COMMENTED OUT: Extension payload implementations for PrivacySettings -// These create storage contract dependencies. PrivacySettings is now used directly as RPC response types. -// - -// impl ExtnPayloadProvider for PrivacySettings { -// fn get_from_payload(payload: ExtnPayload) -> Option { -// if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { -// if let Ok(v) = serde_json::from_value(v) { -// return Some(v); -// } -// } -// -// None -// } -// -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Response(ExtnResponse::Value( -// serde_json::to_value(self.clone()).unwrap(), -// )) -// } -// -// fn contract() -> crate::framework::ripple_contract::RippleContract { -// RippleContract::Storage(StorageAdjective::PrivacyCloud) -// } -// } - -//impl ExtnPayloadProvider for PrivacySettingsData { -// fn get_from_payload(payload: ExtnPayload) -> Option { -// if let ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( -// PrivacySettingsStoreRequest::SetAllPrivacySettings(settings), -// )) = payload -// { -// return Some(settings); -// } -// None -// } -// -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Request(ExtnRequest::PrivacySettingsStore( -// PrivacySettingsStoreRequest::SetAllPrivacySettings(self.clone()), -// )) -// } -// -// fn contract() -> crate::framework::ripple_contract::RippleContract { -// RippleContract::Storage(StorageAdjective::PrivacyLocal) -// } -//} - #[derive(Debug, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct ContentListenRequest { @@ -284,44 +215,6 @@ pub struct SetPropertyParams { pub dist_session: AccountSession, } -// -//#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -//pub enum PrivacyCloudRequest { -// GetProperty(GetPropertyParams), -// GetProperties(AccountSession), -// SetProperty(SetPropertyParams), -// GetPartnerExclusions(AccountSession), -//} -// -//impl PrivacyCloudRequest { -// pub fn get_session(&self) -> AccountSession { -// match self { -// PrivacyCloudRequest::GetProperty(params) => params.dist_session.clone(), -// PrivacyCloudRequest::GetProperties(session) => session.clone(), -// PrivacyCloudRequest::SetProperty(params) => params.dist_session.clone(), -// PrivacyCloudRequest::GetPartnerExclusions(session) => session.clone(), -// } -// } -//} -// -//impl ExtnPayloadProvider for PrivacyCloudRequest { -// fn get_from_payload(payload: ExtnPayload) -> Option { -// if let ExtnPayload::Request(ExtnRequest::PrivacySettings(p)) = payload { -// return Some(p); -// } -// -// None -// } -// -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Request(ExtnRequest::PrivacySettings(self.clone())) -// } -// -// fn contract() -> crate::framework::ripple_contract::RippleContract { -// RippleContract::Storage(StorageAdjective::PrivacyCloud) -// } -//} - #[derive(Debug, PartialEq, Default, Serialize, Deserialize, Clone)] pub struct ExclusionPolicyData { pub data_events: Vec, @@ -346,33 +239,6 @@ pub struct ExclusionPolicy { pub watch_history: Option, } -// -// COMMENTED OUT: Extension payload implementations for ExclusionPolicy -// These create storage contract dependencies. ExclusionPolicy is now used directly as RPC response types. -// - -// impl ExtnPayloadProvider for ExclusionPolicy { -// fn get_from_payload(payload: ExtnPayload) -> Option { -// if let ExtnPayload::Response(ExtnResponse::Value(v)) = payload { -// if let Ok(v) = serde_json::from_value(v) { -// return Some(v); -// } -// } -// -// None -// } -// -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Response(ExtnResponse::Value( -// serde_json::to_value(self.clone()).unwrap(), -// )) -// } -// -// fn contract() -> crate::framework::ripple_contract::RippleContract { -// RippleContract::Storage(StorageAdjective::PrivacyCloud) -// } -// } - #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] pub enum DataEventType { Watched, diff --git a/core/sdk/src/api/distributor/distributor_usergrants.rs b/core/sdk/src/api/distributor/distributor_usergrants.rs index fadd0fc84..5599d7f20 100644 --- a/core/sdk/src/api/distributor/distributor_usergrants.rs +++ b/core/sdk/src/api/distributor/distributor_usergrants.rs @@ -17,17 +17,9 @@ use serde::{Deserialize, Serialize}; -use crate::{ - api::{ - firebolt::fb_capabilities::FireboltPermission, - session::AccountSession, - // Removed StorageAdjective import - not needed for RPC-only functionality - // storage_property::StorageAdjective, - usergrant_entry::UserGrantInfo, - }, - // Removed extension message imports - using direct RPC calls now - // extn::extn_client_message::{ExtnPayload, ExtnPayloadProvider, ExtnRequest}, - // framework::ripple_contract::RippleContract, +use crate::api::{ + firebolt::fb_capabilities::FireboltPermission, session::AccountSession, + usergrant_entry::UserGrantInfo, }; #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] @@ -41,34 +33,6 @@ pub struct UserGrantsCloudSetParams { pub account_session: AccountSession, pub user_grant_info: UserGrantInfo, } -// -// OBSOLETE EXTENSION REQUEST INFRASTRUCTURE - REPLACED WITH DIRECT RPC CALLS -// The structs above (UserGrantsCloudGetParams, UserGrantsCloudSetParams) are still used by RPC handlers -// but the extension request processing below has been replaced with direct eos-distributor RPC calls -// - -// #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -// pub enum UserGrantsCloudStoreRequest { -// GetCloudUserGrants(UserGrantsCloudGetParams), -// SetCloudUserGrants(UserGrantsCloudSetParams), -// } - -// impl ExtnPayloadProvider for UserGrantsCloudStoreRequest { -// fn get_extn_payload(&self) -> ExtnPayload { -// ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(self.clone())) -// } - -// fn get_from_payload(payload: ExtnPayload) -> Option { -// if let ExtnPayload::Request(ExtnRequest::UserGrantsCloudStore(r)) = payload { -// return Some(r); -// } -// None -// } - -// fn contract() -> RippleContract { -// RippleContract::Storage(StorageAdjective::UsergrantCloud) -// } -// } pub type UserGrants = Vec; diff --git a/core/sdk/src/api/storage_property.rs b/core/sdk/src/api/storage_property.rs index b7792db53..67fe6f257 100644 --- a/core/sdk/src/api/storage_property.rs +++ b/core/sdk/src/api/storage_property.rs @@ -655,10 +655,6 @@ impl ExtnPayloadProvider for StorageManagerRequest { #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(rename_all = "snake_case")] pub enum StorageAdjective { - PrivacyCloud, - PrivacyLocal, - //UsergrantCloud, - //UsergrantLocal, Local, Manager, Secure,