7
7
*
8
8
* ## Security
9
9
*
10
- * This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns.
10
+ * This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns.
11
11
*
12
- * For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization :
12
+ * For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app` :
13
13
* ```json
14
14
* {
15
- * "plugins": {
16
- * "http": {
17
- * "scope": ["https://api.github.com/repos/tauri-apps/*"]
15
+ * "permissions": [
16
+ * {
17
+ * "identifier": "http:default",
18
+ * "allow": [{ "url": "https://*.tauri.app" }],
19
+ * "deny": [{ "url": "https://private.tauri.app" }]
18
20
* }
19
- * }
21
+ * ]
20
22
* }
21
23
* ```
22
24
* Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.
@@ -100,7 +102,7 @@ export interface ClientOptions {
100
102
*/
101
103
export async function fetch (
102
104
input : URL | Request | string ,
103
- init ?: RequestInit & ClientOptions ,
105
+ init ?: RequestInit & ClientOptions
104
106
) : Promise < Response > {
105
107
const maxRedirections = init ?. maxRedirections ;
106
108
const connectTimeout = init ?. connectTimeout ;
@@ -148,7 +150,7 @@ export async function fetch(
148
150
// we need to ensure we have all header values as strings
149
151
// eslint-disable-next-line
150
152
typeof val === "string" ? val : ( val as any ) . toString ( ) ,
151
- ] ,
153
+ ]
152
154
) ;
153
155
154
156
const rid = await invoke < number > ( "plugin:http|fetch" , {
@@ -191,7 +193,7 @@ export async function fetch(
191
193
"plugin:http|fetch_read_body" ,
192
194
{
193
195
rid : responseRid ,
194
- } ,
196
+ }
195
197
) ;
196
198
197
199
const res = new Response (
@@ -204,7 +206,7 @@ export async function fetch(
204
206
headers : responseHeaders ,
205
207
status,
206
208
statusText,
207
- } ,
209
+ }
208
210
) ;
209
211
210
212
// url is read only but seems like we can do this
0 commit comments