@@ -10,11 +10,11 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
1010use std:: str:: FromStr as _;
1111
1212/// Current browser request/response protocol version.
13- pub const BROWSER_PROTOCOL_VERSION : u16 = 4 ;
13+ pub const BROWSER_PROTOCOL_VERSION : u16 = 5 ;
1414/// Protocol name authenticated by the node HELLO response.
15- pub const BROWSER_PROTOCOL_NAME : & str = "autonomi.web.poc.v4 " ;
15+ pub const BROWSER_PROTOCOL_NAME : & str = "autonomi.web.poc.v5 " ;
1616/// Ordered WebRTC `DataChannel` label used by Autonomi nodes.
17- pub const WEBRTC_DIRECT_DATA_CHANNEL : & str = "autonomi.web.v4 " ;
17+ pub const WEBRTC_DIRECT_DATA_CHANNEL : & str = "autonomi.web.v5 " ;
1818/// Maximum content carried by one browser protocol frame.
1919pub const MAX_BROWSER_RECORD_BYTES : usize = 4 * 1024 * 1024 ;
2020/// Maximum JSON header carried by one browser protocol frame.
@@ -173,11 +173,13 @@ impl BrowserEndpointInput {
173173 }
174174}
175175
176- /// Public EVM configuration transmitted by manifests and HELLO responses.
176+ /// Public EVM identity transmitted by manifests and HELLO responses.
177+ /// RPC endpoints belong to the node operator or client application and never
178+ /// form part of this wire record.
177179#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
178180pub struct BrowserPaymentNetwork {
179- /// HTTP(S) JSON-RPC endpoint .
180- pub rpc_url : String ,
181+ /// EVM chain ID used for payment verification .
182+ pub chain_id : u64 ,
181183 /// ERC-20 payment token contract.
182184 pub payment_token_address : String ,
183185 /// Autonomi payment vault contract.
@@ -380,6 +382,7 @@ pub enum BrowserResponseStatus {
380382/// Browser RPC response variants and their fields.
381383#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
382384#[ serde( tag = "type" , rename_all = "snake_case" ) ]
385+ #[ allow( clippy:: large_enum_variant) ] // Quote metadata intentionally stays inline.
383386pub enum BrowserResponseBody {
384387 /// Authenticated node and protocol metadata.
385388 Hello {
@@ -1099,9 +1102,9 @@ mod tests {
10991102 }
11001103
11011104 #[ test]
1102- fn rejects_stale_v3_and_length_mismatches ( ) {
1105+ fn rejects_stale_v4_and_length_mismatches ( ) {
11031106 let stale = serde_json:: json!( {
1104- "version" : 3 ,
1107+ "version" : 4 ,
11051108 "request_id" : 1 ,
11061109 "status" : "ok" ,
11071110 "content_length" : 0 ,
@@ -1133,7 +1136,7 @@ mod tests {
11331136 max_chunk_size : MAX_BROWSER_RECORD_BYTES ,
11341137 capabilities : vec ! [ "get_chunk" . to_string( ) ] ,
11351138 payment : BrowserPaymentNetwork {
1136- rpc_url : "http://127.0.0.1:8545/" . to_string ( ) ,
1139+ chain_id : 31337 ,
11371140 payment_token_address : "11" . repeat ( 20 ) ,
11381141 payment_vault_address : "22" . repeat ( 20 ) ,
11391142 } ,
@@ -1144,6 +1147,32 @@ mod tests {
11441147 ) ;
11451148 }
11461149
1150+ #[ test]
1151+ fn payment_metadata_contains_identity_without_rpc_configuration ( ) {
1152+ let payment = BrowserPaymentNetwork {
1153+ chain_id : 31337 ,
1154+ payment_token_address : "11" . repeat ( 20 ) ,
1155+ payment_vault_address : "22" . repeat ( 20 ) ,
1156+ } ;
1157+ let value = serde_json:: to_value ( payment) . expect ( "payment JSON" ) ;
1158+ assert_eq ! (
1159+ value,
1160+ serde_json:: json!( {
1161+ "chain_id" : 31337 ,
1162+ "payment_token_address" : "11" . repeat( 20 ) ,
1163+ "payment_vault_address" : "22" . repeat( 20 ) ,
1164+ } )
1165+ ) ;
1166+ assert ! (
1167+ serde_json:: from_value:: <BrowserPaymentNetwork >( serde_json:: json!( {
1168+ "rpc_url" : "https://operator.invalid/private-key" ,
1169+ "payment_token_address" : "11" . repeat( 20 ) ,
1170+ "payment_vault_address" : "22" . repeat( 20 ) ,
1171+ } ) )
1172+ . is_err( )
1173+ ) ;
1174+ }
1175+
11471176 #[ test]
11481177 fn synthesizes_pinned_v2_answer_without_mutating_the_offer ( ) {
11491178 let endpoint = endpoint ( ) . parse ( ) . expect ( "parse endpoint" ) ;
@@ -1157,7 +1186,7 @@ mod tests {
11571186 }
11581187
11591188 #[ test]
1160- fn value_shape_remains_the_v4_json_contract ( ) {
1189+ fn value_shape_uses_the_v5_json_contract ( ) {
11611190 let response = BrowserResponse :: ok (
11621191 42 ,
11631192 BrowserResponseBody :: Chunk {
@@ -1167,7 +1196,7 @@ mod tests {
11671196 3 ,
11681197 ) ;
11691198 let value = serde_json:: to_value ( response) . expect ( "response JSON" ) ;
1170- assert_eq ! ( value[ "version" ] , Value :: from( 4 ) ) ;
1199+ assert_eq ! ( value[ "version" ] , Value :: from( 5 ) ) ;
11711200 assert_eq ! ( value[ "request_id" ] , Value :: from( 42 ) ) ;
11721201 assert_eq ! ( value[ "status" ] , Value :: from( "ok" ) ) ;
11731202 assert_eq ! ( value[ "type" ] , Value :: from( "chunk" ) ) ;
0 commit comments