@@ -31,40 +31,67 @@ use url::Url;
3131pub struct RuntimeConfig {
3232 /// Canonical product identifier used for account derivation.
3333 pub product_id : String ,
34+ /// Host metadata shown by the wallet during SSO pairing.
35+ pub host_info : HostInfo ,
36+ /// Platform metadata shown by the wallet during SSO pairing.
37+ pub platform_info : PlatformInfo ,
38+ /// People-chain genesis hash used for statement-store SSO.
39+ pub people_chain_genesis_hash : [ u8 ; 32 ] ,
40+ /// Deeplink URI scheme used in pairing QR payloads, without `://`.
41+ pub pairing_deeplink_scheme : String ,
42+ }
43+
44+ /// Host metadata shown by the wallet during SSO pairing.
45+ #[ derive( Debug , Clone , PartialEq , Eq ) ]
46+ pub struct HostInfo {
3447 /// Host name shown by the wallet during SSO pairing.
35- pub host_name : String ,
48+ pub name : String ,
3649 /// Optional host icon URL/CID shown by the wallet during SSO pairing.
37- pub host_icon : Option < String > ,
50+ pub icon : Option < String > ,
3851 /// Optional host version shown by the wallet during SSO pairing.
39- pub host_version : Option < String > ,
52+ pub version : Option < String > ,
53+ }
54+
55+ /// Platform metadata shown by the wallet during SSO pairing.
56+ #[ derive( Debug , Clone , Default , PartialEq , Eq ) ]
57+ pub struct PlatformInfo {
4058 /// Optional platform/browser name shown by the wallet during SSO pairing.
41- pub platform_type : Option < String > ,
59+ pub kind : Option < String > ,
4260 /// Optional platform/browser version shown by the wallet during SSO pairing.
43- pub platform_version : Option < String > ,
44- /// People-chain genesis hash used for statement-store SSO.
45- pub people_chain_genesis_hash : [ u8 ; 32 ] ,
46- /// Deeplink URI scheme used in pairing QR payloads, without `://`.
47- pub pairing_deeplink_scheme : String ,
61+ pub version : Option < String > ,
4862}
4963
5064impl RuntimeConfig {
5165 /// Build a runtime config, validating fields whose representation cannot
5266 /// be made invalid by Rust types alone.
53- pub fn new ( config : Self ) -> Result < Self , RuntimeConfigValidationError > {
67+ pub fn new (
68+ product_id : String ,
69+ host_info : HostInfo ,
70+ platform_info : PlatformInfo ,
71+ people_chain_genesis_hash : [ u8 ; 32 ] ,
72+ pairing_deeplink_scheme : String ,
73+ ) -> Result < Self , RuntimeConfigValidationError > {
74+ let config = Self {
75+ product_id,
76+ host_info,
77+ platform_info,
78+ people_chain_genesis_hash,
79+ pairing_deeplink_scheme,
80+ } ;
5481 config. validate ( ) ?;
5582 Ok ( config)
5683 }
5784
5885 fn validate ( & self ) -> Result < ( ) , RuntimeConfigValidationError > {
5986 require_non_empty ( "product_id" , & self . product_id ) ?;
60- require_non_empty ( "host_name " , & self . host_name ) ?;
87+ require_non_empty ( "host_info.name " , & self . host_info . name ) ?;
6188 require_non_empty ( "pairing_deeplink_scheme" , & self . pairing_deeplink_scheme ) ?;
6289 if self . pairing_deeplink_scheme . contains ( "://" ) {
6390 return Err ( RuntimeConfigValidationError :: InvalidDeeplinkScheme {
6491 scheme : self . pairing_deeplink_scheme . clone ( ) ,
6592 } ) ;
6693 }
67- if let Some ( icon) = & self . host_icon {
94+ if let Some ( icon) = & self . host_info . icon {
6895 let parsed =
6996 Url :: parse ( icon) . map_err ( |err| RuntimeConfigValidationError :: InvalidHostIcon {
7097 reason : err. to_string ( ) ,
@@ -96,13 +123,13 @@ pub enum RuntimeConfigValidationError {
96123 field : & ' static str ,
97124 } ,
98125 /// Host icon URL could not be parsed as an absolute URL.
99- #[ display( "host_icon must be an absolute HTTPS URL: {reason}" ) ]
126+ #[ display( "host_info.icon must be an absolute HTTPS URL: {reason}" ) ]
100127 InvalidHostIcon {
101128 /// Parse failure reason.
102129 reason : String ,
103130 } ,
104131 /// Host icon URL used a non-HTTPS scheme.
105- #[ display( "host_icon must use https scheme, got {scheme:?}" ) ]
132+ #[ display( "host_info.icon must use https scheme, got {scheme:?}" ) ]
106133 InsecureHostIcon {
107134 /// Actual URL scheme.
108135 scheme : String ,
0 commit comments