@@ -1359,6 +1359,38 @@ impl TauriConfig {
13591359 }
13601360}
13611361
1362+ /// A URL to an updater server.
1363+ ///
1364+ /// The URL must use the `https` scheme on production.
1365+ #[ skip_serializing_none]
1366+ #[ derive( Debug , PartialEq , Clone , Serialize ) ]
1367+ #[ cfg_attr( feature = "schema" , derive( JsonSchema ) ) ]
1368+ pub struct UpdaterEndpoint ( pub Url ) ;
1369+
1370+ impl std:: fmt:: Display for UpdaterEndpoint {
1371+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
1372+ write ! ( f, "{}" , self . 0 )
1373+ }
1374+ }
1375+
1376+ impl < ' de > Deserialize < ' de > for UpdaterEndpoint {
1377+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
1378+ where
1379+ D : Deserializer < ' de > ,
1380+ {
1381+ let url = Url :: deserialize ( deserializer) ?;
1382+ #[ cfg( all( not( debug_assertions) , not( feature = "schema" ) ) ) ]
1383+ {
1384+ if url. scheme ( ) != "https" {
1385+ return Err ( serde:: de:: Error :: custom (
1386+ "The configured updater endpoint must use the `https` protocol." ,
1387+ ) ) ;
1388+ }
1389+ }
1390+ Ok ( Self ( url) )
1391+ }
1392+ }
1393+
13621394/// The Updater configuration object.
13631395#[ skip_serializing_none]
13641396#[ derive( Debug , PartialEq , Clone , Deserialize , Serialize ) ]
@@ -1371,8 +1403,8 @@ pub struct UpdaterConfig {
13711403 /// Display built-in dialog or use event system if disabled.
13721404 #[ serde( default = "default_dialog" ) ]
13731405 pub dialog : bool ,
1374- /// The updater endpoints.
1375- pub endpoints : Option < Vec < String > > ,
1406+ /// The updater endpoints. TLS is enforced on production.
1407+ pub endpoints : Option < Vec < UpdaterEndpoint > > ,
13761408 /// Signature public key.
13771409 pub pubkey : String ,
13781410}
@@ -2029,7 +2061,18 @@ mod build {
20292061 let active = self . active ;
20302062 let dialog = self . dialog ;
20312063 let pubkey = str_lit ( & self . pubkey ) ;
2032- let endpoints = opt_vec_str_lit ( self . endpoints . as_ref ( ) ) ;
2064+ let endpoints = opt_lit (
2065+ self
2066+ . endpoints
2067+ . as_ref ( )
2068+ . map ( |list| {
2069+ vec_lit ( list, |url| {
2070+ let url = url. 0 . as_str ( ) ;
2071+ quote ! { :: tauri:: utils:: config:: UpdaterEndpoint ( #url. parse( ) . unwrap( ) ) }
2072+ } )
2073+ } )
2074+ . as_ref ( ) ,
2075+ ) ;
20332076
20342077 literal_struct ! ( tokens, UpdaterConfig , active, dialog, pubkey, endpoints) ;
20352078 }
0 commit comments