Skip to content

Commit 94962d1

Browse files
authored
Merge branch 'v2' into feature/v2-http-dangerous-settings
2 parents 6c58554 + 57efb47 commit 94962d1

File tree

7 files changed

+206
-162
lines changed

7 files changed

+206
-162
lines changed

.changes/updater-builder-header.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"updater": "patch"
3+
"updater-js": "patch"
4+
---
5+
6+
Add `Builder::header` and `Builder::headers` method to configure default headers for updater.
7+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This repo and all plugins require a Rust version of at least **1.77.2**
2929
| [process](plugins/process) | This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. |||| ? | ? |
3030
| [shell](plugins/shell) | Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. |||| ? | ? |
3131
| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. ||||||
32-
| [sql](plugins/sql) | Interface with SQL databases. |||| ? ||
32+
| [sql](plugins/sql) | Interface with SQL databases. |||| ||
3333
| [store](plugins/store) | Persistent key value storage. ||||||
3434
| [stronghold](plugins/stronghold) | Encrypted, secure database. |||| ? | ? |
3535
| [updater](plugins/updater) | In-app updates for Tauri applications. ||||||

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"eslint-config-prettier": "9.1.0",
2222
"eslint-plugin-security": "3.0.1",
2323
"prettier": "3.4.2",
24-
"rollup": "4.28.1",
24+
"rollup": "4.29.1",
2525
"tslib": "2.8.1",
2626
"typescript": "5.7.2",
27-
"typescript-eslint": "8.18.0"
27+
"typescript-eslint": "8.18.2"
2828
},
2929
"resolutions": {
3030
"semver": ">=7.5.2",

plugins/sql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ windows = { level = "full", notes = "" }
1919
linux = { level = "full", notes = "" }
2020
macos = { level = "full", notes = "" }
2121
android = { level = "full", notes = "" }
22-
ios = { level = "none", notes = "" }
22+
ios = { level = "full", notes = "" }
2323

2424
[build-dependencies]
2525
tauri-plugin = { workspace = true, features = ["build"] }

plugins/updater/src/lib.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use std::{ffi::OsString, sync::Arc};
1515

16+
use http::{HeaderMap, HeaderName, HeaderValue};
1617
use semver::Version;
1718
use tauri::{
1819
plugin::{Builder as PluginBuilder, TauriPlugin},
@@ -74,13 +75,15 @@ impl<R: Runtime, T: Manager<R>> UpdaterExt<R> for T {
7475
config,
7576
target,
7677
version_comparator,
78+
headers,
7779
} = self.state::<UpdaterState>().inner();
7880

7981
let mut builder = UpdaterBuilder::new(
8082
package_info.name.clone(),
8183
package_info.version.clone(),
8284
config.clone(),
83-
);
85+
)
86+
.headers(headers.clone());
8487

8588
if let Some(target) = target {
8689
builder = builder.target(target);
@@ -124,13 +127,15 @@ struct UpdaterState {
124127
target: Option<String>,
125128
config: Config,
126129
version_comparator: Option<VersionComparator>,
130+
headers: HeaderMap,
127131
}
128132

129133
#[derive(Default)]
130134
pub struct Builder {
131135
target: Option<String>,
132136
pubkey: Option<String>,
133137
installer_args: Vec<OsString>,
138+
headers: HeaderMap,
134139
default_version_comparator: Option<VersionComparator>,
135140
}
136141

@@ -172,6 +177,26 @@ impl Builder {
172177
self
173178
}
174179

180+
pub fn header<K, V>(mut self, key: K, value: V) -> Result<Self>
181+
where
182+
HeaderName: TryFrom<K>,
183+
<HeaderName as TryFrom<K>>::Error: Into<http::Error>,
184+
HeaderValue: TryFrom<V>,
185+
<HeaderValue as TryFrom<V>>::Error: Into<http::Error>,
186+
{
187+
let key: std::result::Result<HeaderName, http::Error> = key.try_into().map_err(Into::into);
188+
let value: std::result::Result<HeaderValue, http::Error> =
189+
value.try_into().map_err(Into::into);
190+
self.headers.insert(key?, value?);
191+
192+
Ok(self)
193+
}
194+
195+
pub fn headers(mut self, headers: HeaderMap) -> Self {
196+
self.headers = headers;
197+
self
198+
}
199+
175200
pub fn default_version_comparator<
176201
F: Fn(Version, RemoteRelease) -> bool + Send + Sync + 'static,
177202
>(
@@ -187,6 +212,7 @@ impl Builder {
187212
let target = self.target;
188213
let version_comparator = self.default_version_comparator;
189214
let installer_args = self.installer_args;
215+
let headers = self.headers;
190216
PluginBuilder::<R, Config>::new("updater")
191217
.setup(move |app, api| {
192218
let mut config = api.config().clone();
@@ -200,6 +226,7 @@ impl Builder {
200226
target,
201227
config,
202228
version_comparator,
229+
headers,
203230
});
204231
Ok(())
205232
})

plugins/updater/src/updater.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ impl UpdaterBuilder {
179179
Ok(self)
180180
}
181181

182+
pub fn headers(mut self, headers: HeaderMap) -> Self {
183+
self.headers = headers;
184+
self
185+
}
186+
187+
pub fn clear_headers(mut self) -> Self {
188+
self.headers.clear();
189+
self
190+
}
191+
182192
pub fn timeout(mut self, timeout: Duration) -> Self {
183193
self.timeout = Some(timeout);
184194
self

0 commit comments

Comments
 (0)