@tauri-apps/plugin-http 2.6.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ Access the HTTP client written in Rust.
12
12
 
13
13
  ## Install
14
14
 
15
- _This plugin requires a Rust version of at least **1.77.2**_
15
+ _This plugin requires a Rust version of at least **1.90**_
16
16
 
17
17
  There are three general methods of installation that we can recommend.
18
18
 
package/dist-js/index.cjs CHANGED
@@ -33,14 +33,24 @@ const ERROR_REQUEST_CANCELLED = 'Request cancelled';
33
33
  * Fetch a resource from the network. It returns a `Promise` that resolves to the
34
34
  * `Response` to that `Request`, whether it is successful or not.
35
35
  *
36
+ * The request is performed by the Rust backend instead of the webview, so it is not subject to
37
+ * CORS, but the URL must be allowed by the plugin scope.
38
+ *
36
39
  * @example
37
40
  * ```typescript
41
+ * import { fetch } from '@tauri-apps/plugin-http';
38
42
  * const response = await fetch("http://my.json.host/data.json");
39
43
  * console.log(response.status); // e.g. 200
40
44
  * console.log(response.statusText); // e.g. "OK"
41
45
  * const jsonData = await response.json();
42
46
  * ```
43
47
  *
48
+ * @param input The resource to fetch, as a URL, a string or a `Request` object.
49
+ * @param init The standard `fetch` request options, extended with the Rust client options from
50
+ * {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
51
+ * `signal` option can be used to abort the request.
52
+ * @returns A promise resolving to the `Response` of the request.
53
+ *
44
54
  * @since 2.0.0
45
55
  */
46
56
  async function fetch(input, init) {
@@ -17,6 +17,11 @@ export interface Proxy {
17
17
  */
18
18
  https?: string | ProxyConfig;
19
19
  }
20
+ /**
21
+ * Detailed configuration of a single proxy server, used when a plain URL string is not enough.
22
+ *
23
+ * @since 2.0.0
24
+ */
20
25
  export interface ProxyConfig {
21
26
  /**
22
27
  * The URL of the proxy server.
@@ -26,7 +31,13 @@ export interface ProxyConfig {
26
31
  * Set the `Proxy-Authorization` header using Basic auth.
27
32
  */
28
33
  basicAuth?: {
34
+ /**
35
+ * The user name sent to the proxy server.
36
+ */
29
37
  username: string;
38
+ /**
39
+ * The password sent to the proxy server.
40
+ */
30
41
  password: string;
31
42
  };
32
43
  /**
@@ -44,6 +55,10 @@ export interface ClientOptions {
44
55
  /**
45
56
  * Defines the maximum number of redirects the client should follow.
46
57
  * If set to 0, no redirects will be followed.
58
+ *
59
+ * When the `scopeRedirects` plugin configuration is enabled, every redirect must
60
+ * also be allowed by the configured scope, otherwise the request fails
61
+ * instead of being followed.
47
62
  */
48
63
  maxRedirections?: number;
49
64
  /** Timeout in milliseconds */
@@ -76,14 +91,24 @@ export interface DangerousSettings {
76
91
  * Fetch a resource from the network. It returns a `Promise` that resolves to the
77
92
  * `Response` to that `Request`, whether it is successful or not.
78
93
  *
94
+ * The request is performed by the Rust backend instead of the webview, so it is not subject to
95
+ * CORS, but the URL must be allowed by the plugin scope.
96
+ *
79
97
  * @example
80
98
  * ```typescript
99
+ * import { fetch } from '@tauri-apps/plugin-http';
81
100
  * const response = await fetch("http://my.json.host/data.json");
82
101
  * console.log(response.status); // e.g. 200
83
102
  * console.log(response.statusText); // e.g. "OK"
84
103
  * const jsonData = await response.json();
85
104
  * ```
86
105
  *
106
+ * @param input The resource to fetch, as a URL, a string or a `Request` object.
107
+ * @param init The standard `fetch` request options, extended with the Rust client options from
108
+ * {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
109
+ * `signal` option can be used to abort the request.
110
+ * @returns A promise resolving to the `Response` of the request.
111
+ *
87
112
  * @since 2.0.0
88
113
  */
89
114
  export declare function fetch(input: URL | Request | string, init?: RequestInit & ClientOptions): Promise<Response>;
package/dist-js/index.js CHANGED
@@ -31,14 +31,24 @@ const ERROR_REQUEST_CANCELLED = 'Request cancelled';
31
31
  * Fetch a resource from the network. It returns a `Promise` that resolves to the
32
32
  * `Response` to that `Request`, whether it is successful or not.
33
33
  *
34
+ * The request is performed by the Rust backend instead of the webview, so it is not subject to
35
+ * CORS, but the URL must be allowed by the plugin scope.
36
+ *
34
37
  * @example
35
38
  * ```typescript
39
+ * import { fetch } from '@tauri-apps/plugin-http';
36
40
  * const response = await fetch("http://my.json.host/data.json");
37
41
  * console.log(response.status); // e.g. 200
38
42
  * console.log(response.statusText); // e.g. "OK"
39
43
  * const jsonData = await response.json();
40
44
  * ```
41
45
  *
46
+ * @param input The resource to fetch, as a URL, a string or a `Request` object.
47
+ * @param init The standard `fetch` request options, extended with the Rust client options from
48
+ * {@linkcode ClientOptions}: `maxRedirections`, `connectTimeout`, `proxy` and `danger`. The
49
+ * `signal` option can be used to abort the request.
50
+ * @returns A promise resolving to the `Response` of the request.
51
+ *
42
52
  * @since 2.0.0
43
53
  */
44
54
  async function fetch(input, init) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-http",
3
- "version": "2.6.1",
3
+ "version": "2.8.0",
4
4
  "license": "MIT OR Apache-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -24,6 +24,6 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "dependencies": {
27
- "@tauri-apps/api": "^2.11.0"
27
+ "@tauri-apps/api": "^2.12.0"
28
28
  }
29
29
  }