@depup/node-fetch 3.3.2-depup.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.
@@ -0,0 +1,219 @@
1
+ /// <reference types="node" />
2
+
3
+ import {RequestOptions} from 'http';
4
+ import {FormData} from 'formdata-polyfill/esm.min.js';
5
+ import {
6
+ Blob,
7
+ blobFrom,
8
+ blobFromSync,
9
+ File,
10
+ fileFrom,
11
+ fileFromSync
12
+ } from 'fetch-blob/from.js';
13
+
14
+ type AbortSignal = {
15
+ readonly aborted: boolean;
16
+
17
+ addEventListener: (type: 'abort', listener: (this: AbortSignal) => void) => void;
18
+ removeEventListener: (type: 'abort', listener: (this: AbortSignal) => void) => void;
19
+ };
20
+
21
+ export type HeadersInit = Headers | Record<string, string> | Iterable<readonly [string, string]> | Iterable<Iterable<string>>;
22
+
23
+ export {
24
+ FormData,
25
+ Blob,
26
+ blobFrom,
27
+ blobFromSync,
28
+ File,
29
+ fileFrom,
30
+ fileFromSync
31
+ };
32
+
33
+ /**
34
+ * This Fetch API interface allows you to perform various actions on HTTP request and response headers.
35
+ * These actions include retrieving, setting, adding to, and removing.
36
+ * A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs.
37
+ * You can add to this using methods like append() (see Examples.)
38
+ * In all methods of this interface, header names are matched by case-insensitive byte sequence.
39
+ * */
40
+ export class Headers {
41
+ constructor(init?: HeadersInit);
42
+
43
+ append(name: string, value: string): void;
44
+ delete(name: string): void;
45
+ get(name: string): string | null;
46
+ has(name: string): boolean;
47
+ set(name: string, value: string): void;
48
+ forEach(
49
+ callbackfn: (value: string, key: string, parent: Headers) => void,
50
+ thisArg?: any
51
+ ): void;
52
+
53
+ [Symbol.iterator](): IterableIterator<[string, string]>;
54
+ /**
55
+ * Returns an iterator allowing to go through all key/value pairs contained in this object.
56
+ */
57
+ entries(): IterableIterator<[string, string]>;
58
+ /**
59
+ * Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
60
+ */
61
+ keys(): IterableIterator<string>;
62
+ /**
63
+ * Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
64
+ */
65
+ values(): IterableIterator<string>;
66
+
67
+ /** Node-fetch extension */
68
+ raw(): Record<string, string[]>;
69
+ }
70
+
71
+ export interface RequestInit {
72
+ /**
73
+ * A BodyInit object or null to set request's body.
74
+ */
75
+ body?: BodyInit | null;
76
+ /**
77
+ * A Headers object, an object literal, or an array of two-item arrays to set request's headers.
78
+ */
79
+ headers?: HeadersInit;
80
+ /**
81
+ * A string to set request's method.
82
+ */
83
+ method?: string;
84
+ /**
85
+ * A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect.
86
+ */
87
+ redirect?: RequestRedirect;
88
+ /**
89
+ * An AbortSignal to set request's signal.
90
+ */
91
+ signal?: AbortSignal | null;
92
+ /**
93
+ * A string whose value is a same-origin URL, "about:client", or the empty string, to set request’s referrer.
94
+ */
95
+ referrer?: string;
96
+ /**
97
+ * A referrer policy to set request’s referrerPolicy.
98
+ */
99
+ referrerPolicy?: ReferrerPolicy;
100
+
101
+ // Node-fetch extensions to the whatwg/fetch spec
102
+ agent?: RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']);
103
+ compress?: boolean;
104
+ counter?: number;
105
+ follow?: number;
106
+ hostname?: string;
107
+ port?: number;
108
+ protocol?: string;
109
+ size?: number;
110
+ highWaterMark?: number;
111
+ insecureHTTPParser?: boolean;
112
+ }
113
+
114
+ export interface ResponseInit {
115
+ headers?: HeadersInit;
116
+ status?: number;
117
+ statusText?: string;
118
+ }
119
+
120
+ export type BodyInit =
121
+ | Blob
122
+ | Buffer
123
+ | URLSearchParams
124
+ | FormData
125
+ | NodeJS.ReadableStream
126
+ | string;
127
+ declare class BodyMixin {
128
+ constructor(body?: BodyInit, options?: {size?: number});
129
+
130
+ readonly body: NodeJS.ReadableStream | null;
131
+ readonly bodyUsed: boolean;
132
+ readonly size: number;
133
+
134
+ /** @deprecated Use `body.arrayBuffer()` instead. */
135
+ buffer(): Promise<Buffer>;
136
+ arrayBuffer(): Promise<ArrayBuffer>;
137
+ formData(): Promise<FormData>;
138
+ blob(): Promise<Blob>;
139
+ json(): Promise<unknown>;
140
+ text(): Promise<string>;
141
+ }
142
+
143
+ // `Body` must not be exported as a class since it's not exported from the JavaScript code.
144
+ export interface Body extends Pick<BodyMixin, keyof BodyMixin> {}
145
+
146
+ export type RequestRedirect = 'error' | 'follow' | 'manual';
147
+ export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
148
+ export type RequestInfo = string | Request;
149
+ export class Request extends BodyMixin {
150
+ constructor(input: URL | RequestInfo, init?: RequestInit);
151
+
152
+ /**
153
+ * Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
154
+ */
155
+ readonly headers: Headers;
156
+ /**
157
+ * Returns request's HTTP method, which is "GET" by default.
158
+ */
159
+ readonly method: string;
160
+ /**
161
+ * Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
162
+ */
163
+ readonly redirect: RequestRedirect;
164
+ /**
165
+ * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
166
+ */
167
+ readonly signal: AbortSignal;
168
+ /**
169
+ * Returns the URL of request as a string.
170
+ */
171
+ readonly url: string;
172
+ /**
173
+ * A string whose value is a same-origin URL, "about:client", or the empty string, to set request’s referrer.
174
+ */
175
+ readonly referrer: string;
176
+ /**
177
+ * A referrer policy to set request’s referrerPolicy.
178
+ */
179
+ readonly referrerPolicy: ReferrerPolicy;
180
+ clone(): Request;
181
+ }
182
+
183
+ type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect';
184
+
185
+ export class Response extends BodyMixin {
186
+ constructor(body?: BodyInit | null, init?: ResponseInit);
187
+
188
+ readonly headers: Headers;
189
+ readonly ok: boolean;
190
+ readonly redirected: boolean;
191
+ readonly status: number;
192
+ readonly statusText: string;
193
+ readonly type: ResponseType;
194
+ readonly url: string;
195
+ clone(): Response;
196
+
197
+ static error(): Response;
198
+ static redirect(url: string, status?: number): Response;
199
+ static json(data: any, init?: ResponseInit): Response;
200
+ }
201
+
202
+ export class FetchError extends Error {
203
+ constructor(message: string, type: string, systemError?: Record<string, unknown>);
204
+
205
+ name: 'FetchError';
206
+ [Symbol.toStringTag]: 'FetchError';
207
+ type: string;
208
+ code?: string;
209
+ errno?: string;
210
+ }
211
+
212
+ export class AbortError extends Error {
213
+ type: string;
214
+ name: 'AbortError';
215
+ [Symbol.toStringTag]: 'AbortError';
216
+ }
217
+
218
+ export function isRedirect(code: number): boolean;
219
+ export default function fetch(url: URL | RequestInfo, init?: RequestInit): Promise<Response>;
package/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 - 2020 Node Fetch Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+