Skip to content

Commit 03e7590

Browse files
authored
feat(core): expose invoke key for custom IPC implementations (#11235)
custom IPC systems that manually call Webview::on_message must know the invoke key checked by Tauri. This exposes that key in the App/AppHandle instances. This is safe because the key is never leaked to remote denied webview URLs
1 parent e2a4da0 commit 03e7590

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changes/expose-invoke-key.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch:enhance
3+
---
4+
5+
Added `App::invoke_key` and `AppHandle::invoke_key` for custom invoke systems that rely on manual `Webview::on_message` calls.

crates/tauri/src/app.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,15 @@ macro_rules! shared_app_impl {
878878
webview.resources_table().clear();
879879
}
880880
}
881+
882+
/// Gets the invoke key that must be referenced when using [`crate::webview::InvokeRequest`].
883+
///
884+
/// # Security
885+
///
886+
/// DO NOT expose this key to third party scripts as might grant access to the backend from external URLs and iframes.
887+
pub fn invoke_key(&self) -> &str {
888+
self.manager.invoke_key()
889+
}
881890
}
882891

883892
impl<R: Runtime> Listener<R> for $app {

0 commit comments

Comments
 (0)