wreq-js 2.0.1 → 2.1.1
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/dist/wreq-js.cjs +30 -1
- package/dist/wreq-js.cjs.map +1 -1
- package/dist/wreq-js.d.cts +13 -1
- package/dist/wreq-js.d.ts +13 -1
- package/dist/wreq-js.js +30 -1
- package/dist/wreq-js.js.map +1 -1
- package/package.json +6 -6
- package/rust/wreq-js.darwin-arm64.node +0 -0
- package/rust/wreq-js.darwin-x64.node +0 -0
- package/rust/wreq-js.linux-arm64-gnu.node +0 -0
- package/rust/wreq-js.linux-x64-gnu.node +0 -0
- package/rust/wreq-js.linux-x64-musl.node +0 -0
- package/rust/wreq-js.win32-x64-msvc.node +0 -0
package/dist/wreq-js.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
1
2
|
import { ReadableStream } from 'node:stream/web';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,7 +8,7 @@ import { ReadableStream } from 'node:stream/web';
|
|
|
7
8
|
/**
|
|
8
9
|
* Browser profile names supported
|
|
9
10
|
*/
|
|
10
|
-
type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_114' | 'chrome_116' | 'chrome_117' | 'chrome_118' | 'chrome_119' | 'chrome_120' | 'chrome_123' | 'chrome_124' | 'chrome_126' | 'chrome_127' | 'chrome_128' | 'chrome_129' | 'chrome_130' | 'chrome_131' | 'chrome_132' | 'chrome_133' | 'chrome_134' | 'chrome_135' | 'chrome_136' | 'chrome_137' | 'chrome_138' | 'chrome_139' | 'chrome_140' | 'chrome_141' | 'chrome_142' | 'chrome_143' | 'edge_101' | 'edge_122' | 'edge_127' | 'edge_131' | 'edge_134' | 'edge_135' | 'edge_136' | 'edge_137' | 'edge_138' | 'edge_139' | 'edge_140' | 'edge_141' | 'edge_142' | 'opera_116' | 'opera_117' | 'opera_118' | 'opera_119' | '
|
|
11
|
+
type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_114' | 'chrome_116' | 'chrome_117' | 'chrome_118' | 'chrome_119' | 'chrome_120' | 'chrome_123' | 'chrome_124' | 'chrome_126' | 'chrome_127' | 'chrome_128' | 'chrome_129' | 'chrome_130' | 'chrome_131' | 'chrome_132' | 'chrome_133' | 'chrome_134' | 'chrome_135' | 'chrome_136' | 'chrome_137' | 'chrome_138' | 'chrome_139' | 'chrome_140' | 'chrome_141' | 'chrome_142' | 'chrome_143' | 'chrome_144' | 'chrome_145' | 'edge_101' | 'edge_122' | 'edge_127' | 'edge_131' | 'edge_134' | 'edge_135' | 'edge_136' | 'edge_137' | 'edge_138' | 'edge_139' | 'edge_140' | 'edge_141' | 'edge_142' | 'edge_143' | 'edge_144' | 'edge_145' | 'opera_116' | 'opera_117' | 'opera_118' | 'opera_119' | 'firefox_109' | 'firefox_117' | 'firefox_128' | 'firefox_133' | 'firefox_135' | 'firefox_private_135' | 'firefox_android_135' | 'firefox_136' | 'firefox_private_136' | 'firefox_139' | 'firefox_142' | 'firefox_143' | 'firefox_144' | 'firefox_145' | 'firefox_146' | 'firefox_147' | 'safari_ios_17.2' | 'safari_ios_17.4.1' | 'safari_ios_16.5' | 'safari_15.3' | 'safari_15.5' | 'safari_15.6.1' | 'safari_16' | 'safari_16.5' | 'safari_17.0' | 'safari_17.2.1' | 'safari_17.4.1' | 'safari_17.5' | 'safari_17.6' | 'safari_18' | 'safari_ipad_18' | 'safari_18.2' | 'safari_ios_18.1.1' | 'safari_18.3' | 'safari_18.3.1' | 'safari_18.5' | 'safari_26' | 'safari_26.1' | 'safari_26.2' | 'safari_ipad_26' | 'safari_ipad_26.2' | 'safari_ios_26' | 'safari_ios_26.2' | 'okhttp_3.9' | 'okhttp_3.11' | 'okhttp_3.13' | 'okhttp_3.14' | 'okhttp_4.9' | 'okhttp_4.10' | 'okhttp_4.12' | 'okhttp_5';
|
|
11
12
|
/**
|
|
12
13
|
* Operating systems supported for emulation
|
|
13
14
|
*/
|
|
@@ -225,6 +226,14 @@ interface RequestInit {
|
|
|
225
226
|
* @default false
|
|
226
227
|
*/
|
|
227
228
|
insecure?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Whether to automatically decompress response bodies. When set to `false`,
|
|
231
|
+
* the raw compressed response body is returned as-is and the `Content-Encoding`
|
|
232
|
+
* header is preserved. Useful for proxy scenarios where the downstream client
|
|
233
|
+
* handles decompression.
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
compress?: boolean;
|
|
228
237
|
}
|
|
229
238
|
/**
|
|
230
239
|
* Configuration for {@link createSession}.
|
|
@@ -684,6 +693,7 @@ declare class Response {
|
|
|
684
693
|
text(): Promise<string>;
|
|
685
694
|
blob(): Promise<Blob>;
|
|
686
695
|
formData(): Promise<FormData>;
|
|
696
|
+
readable(): Readable;
|
|
687
697
|
clone(): Response;
|
|
688
698
|
private assertBodyAvailable;
|
|
689
699
|
private consumeBody;
|
|
@@ -708,6 +718,8 @@ declare class Session implements SessionHandle {
|
|
|
708
718
|
_defaultsRef(): SessionDefaults;
|
|
709
719
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
710
720
|
clearCookies(): Promise<void>;
|
|
721
|
+
getCookies(url: string | URL): Record<string, string>;
|
|
722
|
+
setCookie(name: string, value: string, url: string | URL): void;
|
|
711
723
|
/**
|
|
712
724
|
* Create a WebSocket connection that shares this session's cookies and TLS configuration.
|
|
713
725
|
*
|
package/dist/wreq-js.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
1
2
|
import { ReadableStream } from 'node:stream/web';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,7 +8,7 @@ import { ReadableStream } from 'node:stream/web';
|
|
|
7
8
|
/**
|
|
8
9
|
* Browser profile names supported
|
|
9
10
|
*/
|
|
10
|
-
type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_114' | 'chrome_116' | 'chrome_117' | 'chrome_118' | 'chrome_119' | 'chrome_120' | 'chrome_123' | 'chrome_124' | 'chrome_126' | 'chrome_127' | 'chrome_128' | 'chrome_129' | 'chrome_130' | 'chrome_131' | 'chrome_132' | 'chrome_133' | 'chrome_134' | 'chrome_135' | 'chrome_136' | 'chrome_137' | 'chrome_138' | 'chrome_139' | 'chrome_140' | 'chrome_141' | 'chrome_142' | 'chrome_143' | 'edge_101' | 'edge_122' | 'edge_127' | 'edge_131' | 'edge_134' | 'edge_135' | 'edge_136' | 'edge_137' | 'edge_138' | 'edge_139' | 'edge_140' | 'edge_141' | 'edge_142' | 'opera_116' | 'opera_117' | 'opera_118' | 'opera_119' | '
|
|
11
|
+
type BrowserProfile = 'chrome_100' | 'chrome_101' | 'chrome_104' | 'chrome_105' | 'chrome_106' | 'chrome_107' | 'chrome_108' | 'chrome_109' | 'chrome_110' | 'chrome_114' | 'chrome_116' | 'chrome_117' | 'chrome_118' | 'chrome_119' | 'chrome_120' | 'chrome_123' | 'chrome_124' | 'chrome_126' | 'chrome_127' | 'chrome_128' | 'chrome_129' | 'chrome_130' | 'chrome_131' | 'chrome_132' | 'chrome_133' | 'chrome_134' | 'chrome_135' | 'chrome_136' | 'chrome_137' | 'chrome_138' | 'chrome_139' | 'chrome_140' | 'chrome_141' | 'chrome_142' | 'chrome_143' | 'chrome_144' | 'chrome_145' | 'edge_101' | 'edge_122' | 'edge_127' | 'edge_131' | 'edge_134' | 'edge_135' | 'edge_136' | 'edge_137' | 'edge_138' | 'edge_139' | 'edge_140' | 'edge_141' | 'edge_142' | 'edge_143' | 'edge_144' | 'edge_145' | 'opera_116' | 'opera_117' | 'opera_118' | 'opera_119' | 'firefox_109' | 'firefox_117' | 'firefox_128' | 'firefox_133' | 'firefox_135' | 'firefox_private_135' | 'firefox_android_135' | 'firefox_136' | 'firefox_private_136' | 'firefox_139' | 'firefox_142' | 'firefox_143' | 'firefox_144' | 'firefox_145' | 'firefox_146' | 'firefox_147' | 'safari_ios_17.2' | 'safari_ios_17.4.1' | 'safari_ios_16.5' | 'safari_15.3' | 'safari_15.5' | 'safari_15.6.1' | 'safari_16' | 'safari_16.5' | 'safari_17.0' | 'safari_17.2.1' | 'safari_17.4.1' | 'safari_17.5' | 'safari_17.6' | 'safari_18' | 'safari_ipad_18' | 'safari_18.2' | 'safari_ios_18.1.1' | 'safari_18.3' | 'safari_18.3.1' | 'safari_18.5' | 'safari_26' | 'safari_26.1' | 'safari_26.2' | 'safari_ipad_26' | 'safari_ipad_26.2' | 'safari_ios_26' | 'safari_ios_26.2' | 'okhttp_3.9' | 'okhttp_3.11' | 'okhttp_3.13' | 'okhttp_3.14' | 'okhttp_4.9' | 'okhttp_4.10' | 'okhttp_4.12' | 'okhttp_5';
|
|
11
12
|
/**
|
|
12
13
|
* Operating systems supported for emulation
|
|
13
14
|
*/
|
|
@@ -225,6 +226,14 @@ interface RequestInit {
|
|
|
225
226
|
* @default false
|
|
226
227
|
*/
|
|
227
228
|
insecure?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Whether to automatically decompress response bodies. When set to `false`,
|
|
231
|
+
* the raw compressed response body is returned as-is and the `Content-Encoding`
|
|
232
|
+
* header is preserved. Useful for proxy scenarios where the downstream client
|
|
233
|
+
* handles decompression.
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
compress?: boolean;
|
|
228
237
|
}
|
|
229
238
|
/**
|
|
230
239
|
* Configuration for {@link createSession}.
|
|
@@ -684,6 +693,7 @@ declare class Response {
|
|
|
684
693
|
text(): Promise<string>;
|
|
685
694
|
blob(): Promise<Blob>;
|
|
686
695
|
formData(): Promise<FormData>;
|
|
696
|
+
readable(): Readable;
|
|
687
697
|
clone(): Response;
|
|
688
698
|
private assertBodyAvailable;
|
|
689
699
|
private consumeBody;
|
|
@@ -708,6 +718,8 @@ declare class Session implements SessionHandle {
|
|
|
708
718
|
_defaultsRef(): SessionDefaults;
|
|
709
719
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
710
720
|
clearCookies(): Promise<void>;
|
|
721
|
+
getCookies(url: string | URL): Record<string, string>;
|
|
722
|
+
setCookie(name: string, value: string, url: string | URL): void;
|
|
711
723
|
/**
|
|
712
724
|
* Create a WebSocket connection that shares this session's cookies and TLS configuration.
|
|
713
725
|
*
|
package/dist/wreq-js.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { randomUUID } from "crypto";
|
|
3
3
|
import { STATUS_CODES } from "http";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
|
+
import { Readable } from "stream";
|
|
5
6
|
import { ReadableStream } from "stream/web";
|
|
6
7
|
|
|
7
8
|
// src/types.ts
|
|
@@ -86,7 +87,7 @@ var bodyHandleFinalizer = typeof FinalizationRegistry === "function" ? new Final
|
|
|
86
87
|
}) : void 0;
|
|
87
88
|
var DEFAULT_BROWSER = "chrome_142";
|
|
88
89
|
var DEFAULT_OS = "macos";
|
|
89
|
-
var DEFAULT_REQUEST_TIMEOUT_MS =
|
|
90
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 3e5;
|
|
90
91
|
var SUPPORTED_OSES = ["windows", "macos", "linux", "android", "ios"];
|
|
91
92
|
var UTF8_DECODER = new TextDecoder("utf-8");
|
|
92
93
|
var ephemeralIdCounter = 0;
|
|
@@ -552,6 +553,15 @@ var Response = class _Response {
|
|
|
552
553
|
);
|
|
553
554
|
return response.formData();
|
|
554
555
|
}
|
|
556
|
+
readable() {
|
|
557
|
+
this.assertBodyAvailable();
|
|
558
|
+
this.bodyUsed = true;
|
|
559
|
+
const stream = this.body;
|
|
560
|
+
if (stream === null) {
|
|
561
|
+
return Readable.from([]);
|
|
562
|
+
}
|
|
563
|
+
return Readable.fromWeb(stream);
|
|
564
|
+
}
|
|
555
565
|
clone() {
|
|
556
566
|
if (this.bodyUsed) {
|
|
557
567
|
throw new TypeError("Cannot clone a Response whose body is already used");
|
|
@@ -688,6 +698,22 @@ var Session = class {
|
|
|
688
698
|
throw new RequestError(String(error));
|
|
689
699
|
}
|
|
690
700
|
}
|
|
701
|
+
getCookies(url) {
|
|
702
|
+
this.ensureActive();
|
|
703
|
+
try {
|
|
704
|
+
return nativeBinding.getCookies(this.id, String(url));
|
|
705
|
+
} catch (error) {
|
|
706
|
+
throw new RequestError(String(error));
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
setCookie(name, value, url) {
|
|
710
|
+
this.ensureActive();
|
|
711
|
+
try {
|
|
712
|
+
nativeBinding.setCookie(this.id, name, value, String(url));
|
|
713
|
+
} catch (error) {
|
|
714
|
+
throw new RequestError(String(error));
|
|
715
|
+
}
|
|
716
|
+
}
|
|
691
717
|
async websocket(urlOrOptions, options) {
|
|
692
718
|
this.ensureActive();
|
|
693
719
|
const normalized = normalizeSessionWebSocketArgs(urlOrOptions, options);
|
|
@@ -1169,6 +1195,9 @@ async function fetch(input, init) {
|
|
|
1169
1195
|
if (config.disableDefaultHeaders !== void 0) {
|
|
1170
1196
|
requestOptions.disableDefaultHeaders = config.disableDefaultHeaders;
|
|
1171
1197
|
}
|
|
1198
|
+
if (config.compress !== void 0) {
|
|
1199
|
+
requestOptions.compress = config.compress;
|
|
1200
|
+
}
|
|
1172
1201
|
if (headerTuples && headerTuples.length > 0) {
|
|
1173
1202
|
requestOptions.headers = headerTuples;
|
|
1174
1203
|
}
|