fix: revert command back to fetch_read_body to comply with permissions

pull/2522/head
adrieljss 4 months ago
parent 1ec0de83fa
commit 6cf36fb566
No known key found for this signature in database
GPG Key ID: 849F13CBD0B4AD05

@ -186,6 +186,19 @@ export async function fetch(
throw new Error(ERROR_REQUEST_CANCELLED)
}
const rid = await invoke<number>('plugin:http|fetch', {
clientConfig: {
method: req.method,
url: req.url,
headers: mappedHeaders,
data,
maxRedirections,
connectTimeout,
proxy,
danger
}
})
const readableStreamBody = new ReadableStream({
start: (controller) => {
const streamChannel = new Channel<ArrayBuffer | number[]>()
@ -212,7 +225,7 @@ export async function fetch(
}
// run a non-blocking body stream fetch
invoke('plugin:http|fetch_stream_body', {
invoke('plugin:http|fetch_read_body', {
rid,
streamChannel
}).catch((e) => {
@ -221,19 +234,6 @@ export async function fetch(
}
})
const rid = await invoke<number>('plugin:http|fetch', {
clientConfig: {
method: req.method,
url: req.url,
headers: mappedHeaders,
data,
maxRedirections,
connectTimeout,
proxy,
danger
}
})
const abort = () => invoke('plugin:http|fetch_cancel', { rid })
// abort early here if needed

@ -15,7 +15,7 @@ All fetch operations are enabled.
- `allow-fetch`
- `allow-fetch-cancel`
- `allow-fetch-read-body`
- `allow-fetch-stream-body`
- `allow-fetch-send`
## Permission Table

@ -314,6 +314,16 @@
"type": "string",
"const": "deny-fetch-cancel"
},
{
"description": "Enables the fetch_read_body command without any pre-configured scope.",
"type": "string",
"const": "allow-fetch-read-body"
},
{
"description": "Denies the fetch_read_body command without any pre-configured scope.",
"type": "string",
"const": "deny-fetch-read-body"
},
{
"description": "Enables the fetch_send command without any pre-configured scope.",
"type": "string",

@ -360,7 +360,7 @@ pub fn fetch_cancel<R: Runtime>(webview: Webview<R>, rid: ResourceId) -> crate::
}
#[command]
pub async fn fetch_stream_body<R: Runtime>(
pub async fn fetch_read_body<R: Runtime>(
webview: Webview<R>,
rid: ResourceId,
stream_channel: Channel<tauri::ipc::InvokeResponseBody>,

@ -37,7 +37,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
commands::fetch,
commands::fetch_cancel,
commands::fetch_send,
commands::fetch_stream_body,
commands::fetch_read_body,
])
.build()
}

Loading…
Cancel
Save