wreq-js 2.1.1 → 2.2.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.
@@ -54,6 +54,94 @@ type HeaderTuple = [string, string];
54
54
  * ```
55
55
  */
56
56
  type HeadersInit = Iterable<HeaderTuple> | Array<HeaderTuple> | Record<string, string | number | boolean | null | undefined>;
57
+ type AlpnProtocol = "HTTP1" | "HTTP2" | "HTTP3";
58
+ type AlpsProtocol = "HTTP1" | "HTTP2" | "HTTP3";
59
+ type TlsVersion = "1.0" | "1.1" | "1.2" | "1.3" | "TLS1.0" | "TLS1.1" | "TLS1.2" | "TLS1.3";
60
+ type Http2PseudoHeaderId = "Method" | "Scheme" | "Authority" | "Path" | "Protocol";
61
+ type Http2SettingId = "HeaderTableSize" | "EnablePush" | "MaxConcurrentStreams" | "InitialWindowSize" | "MaxFrameSize" | "MaxHeaderListSize" | "EnableConnectProtocol" | "NoRfc7540Priorities";
62
+ interface Http2StreamDependency {
63
+ dependencyId: number;
64
+ weight: number;
65
+ exclusive?: boolean;
66
+ }
67
+ interface Http2Priority {
68
+ streamId: number;
69
+ dependency: Http2StreamDependency;
70
+ }
71
+ interface Http2ExperimentalSetting {
72
+ id: number;
73
+ value: number;
74
+ }
75
+ interface CustomTlsOptions {
76
+ alpnProtocols?: AlpnProtocol[];
77
+ alpsProtocols?: AlpsProtocol[];
78
+ alpsUseNewCodepoint?: boolean;
79
+ sessionTicket?: boolean;
80
+ minTlsVersion?: TlsVersion;
81
+ maxTlsVersion?: TlsVersion;
82
+ preSharedKey?: boolean;
83
+ enableEchGrease?: boolean;
84
+ permuteExtensions?: boolean;
85
+ greaseEnabled?: boolean;
86
+ enableOcspStapling?: boolean;
87
+ enableSignedCertTimestamps?: boolean;
88
+ recordSizeLimit?: number;
89
+ pskSkipSessionTicket?: boolean;
90
+ keySharesLimit?: number;
91
+ pskDheKe?: boolean;
92
+ renegotiation?: boolean;
93
+ delegatedCredentials?: string;
94
+ curvesList?: string;
95
+ cipherList?: string;
96
+ sigalgsList?: string;
97
+ certificateCompressionAlgorithms?: Array<"zlib" | "brotli" | "zstd">;
98
+ extensionPermutation?: number[];
99
+ aesHwOverride?: boolean;
100
+ preserveTls13CipherList?: boolean;
101
+ randomAesHwOverride?: boolean;
102
+ }
103
+ interface CustomHttp1Options {
104
+ http09Responses?: boolean;
105
+ writev?: boolean;
106
+ maxHeaders?: number;
107
+ readBufExactSize?: number;
108
+ maxBufSize?: number;
109
+ ignoreInvalidHeadersInResponses?: boolean;
110
+ allowSpacesAfterHeaderNameInResponses?: boolean;
111
+ allowObsoleteMultilineHeadersInResponses?: boolean;
112
+ }
113
+ interface CustomHttp2Options {
114
+ adaptiveWindow?: boolean;
115
+ initialStreamId?: number;
116
+ initialConnectionWindowSize?: number;
117
+ initialWindowSize?: number;
118
+ initialMaxSendStreams?: number;
119
+ maxFrameSize?: number;
120
+ keepAliveInterval?: number;
121
+ keepAliveTimeout?: number;
122
+ keepAliveWhileIdle?: boolean;
123
+ maxConcurrentResetStreams?: number;
124
+ maxSendBufferSize?: number;
125
+ maxConcurrentStreams?: number;
126
+ maxHeaderListSize?: number;
127
+ maxPendingAcceptResetStreams?: number;
128
+ enablePush?: boolean;
129
+ headerTableSize?: number;
130
+ enableConnectProtocol?: boolean;
131
+ noRfc7540Priorities?: boolean;
132
+ settingsOrder?: Http2SettingId[];
133
+ headersPseudoOrder?: Http2PseudoHeaderId[];
134
+ headersStreamDependency?: Http2StreamDependency;
135
+ priorities?: Http2Priority[];
136
+ experimentalSettings?: Http2ExperimentalSetting[];
137
+ }
138
+ interface CustomEmulationOptions {
139
+ tlsOptions?: CustomTlsOptions;
140
+ http1Options?: CustomHttp1Options;
141
+ http2Options?: CustomHttp2Options;
142
+ headers?: HeadersInit;
143
+ origHeaders?: string[];
144
+ }
57
145
  /**
58
146
  * Represents the various types of data that can be used as a request body.
59
147
  * Supports strings, binary payloads, URL-encoded parameters, multipart forms, and blobs.
@@ -177,6 +265,12 @@ interface RequestInit {
177
265
  * @default 'macos'
178
266
  */
179
267
  os?: EmulationOS;
268
+ /**
269
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
270
+ * layer on top of the resolved preset profile. When both are omitted, this
271
+ * switches the request into standalone custom emulation mode.
272
+ */
273
+ emulation?: CustomEmulationOptions;
180
274
  /**
181
275
  * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
182
276
  * Proxy support depends on the native layer and proxy scheme.
@@ -255,6 +349,10 @@ interface CreateSessionOptions {
255
349
  * Operating system to bind to this session. Defaults to 'macos'.
256
350
  */
257
351
  os?: EmulationOS;
352
+ /**
353
+ * Custom emulation overrides or a standalone custom emulation for the session transport.
354
+ */
355
+ emulation?: CustomEmulationOptions;
258
356
  /**
259
357
  * Optional proxy for every request made through the session.
260
358
  */
@@ -295,6 +393,10 @@ interface CreateTransportOptions {
295
393
  * Operating system to emulate for this transport.
296
394
  */
297
395
  os?: EmulationOS;
396
+ /**
397
+ * Custom emulation overrides or a standalone custom emulation for this transport.
398
+ */
399
+ emulation?: CustomEmulationOptions;
298
400
  /**
299
401
  * Disable HTTPS certificate verification for this transport.
300
402
  */
@@ -357,6 +459,12 @@ interface RequestOptions {
357
459
  * @default 'macos'
358
460
  */
359
461
  os?: EmulationOS;
462
+ /**
463
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
464
+ * layer on top of the resolved preset profile. When both are omitted, this
465
+ * switches the request into standalone custom emulation mode.
466
+ */
467
+ emulation?: CustomEmulationOptions;
360
468
  /**
361
469
  * HTTP method to use for the request.
362
470
  * @default 'GET'
@@ -506,6 +614,12 @@ interface WebSocketOptions {
506
614
  * @default 'macos'
507
615
  */
508
616
  os?: EmulationOS;
617
+ /**
618
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
619
+ * layer on top of the resolved preset profile. When both are omitted, this
620
+ * switches the handshake into standalone custom emulation mode.
621
+ */
622
+ emulation?: CustomEmulationOptions;
509
623
  /**
510
624
  * Additional headers to send with the WebSocket upgrade request.
511
625
  * Common headers include Authorization, Origin, or custom application headers.
@@ -548,7 +662,7 @@ interface LegacyWebSocketOptions extends WebSocketOptions {
548
662
  */
549
663
  onError?: (error: string) => void;
550
664
  }
551
- type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy">;
665
+ type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy" | "emulation">;
552
666
  interface LegacySessionWebSocketOptions extends SessionWebSocketOptions {
553
667
  /**
554
668
  * @deprecated Use `session.websocket(url, options)`.
@@ -616,8 +730,7 @@ interface NativeWebSocketCloseEvent {
616
730
  reason: string;
617
731
  }
618
732
  type SessionDefaults = {
619
- browser: BrowserProfile;
620
- os: EmulationOS;
733
+ transportMode: ResolvedEmulationMode;
621
734
  proxy?: string;
622
735
  timeout?: number;
623
736
  insecure?: boolean;
@@ -625,6 +738,17 @@ type SessionDefaults = {
625
738
  transportId?: string;
626
739
  ownsTransport?: boolean;
627
740
  };
741
+ type PresetEmulationMode = {
742
+ kind: "preset";
743
+ browser: BrowserProfile;
744
+ os: EmulationOS;
745
+ emulationJson?: string;
746
+ };
747
+ type CustomEmulationMode = {
748
+ kind: "custom";
749
+ emulationJson: string;
750
+ };
751
+ type ResolvedEmulationMode = PresetEmulationMode | CustomEmulationMode;
628
752
  type LegacyWebSocketCallbacks = {
629
753
  onMessage?: (data: string | Buffer) => void;
630
754
  onClose?: (event: WebSocketCloseEvent) => void;
@@ -914,4 +1038,4 @@ declare const _default: {
914
1038
  RequestError: typeof RequestError;
915
1039
  };
916
1040
 
917
- export { type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type EmulationOS, Headers, type HeadersInit, RequestError, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };
1041
+ export { type AlpnProtocol, type AlpsProtocol, type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type CustomEmulationOptions, type CustomHttp1Options, type CustomHttp2Options, type CustomTlsOptions, type EmulationOS, Headers, type HeadersInit, type Http2ExperimentalSetting, type Http2Priority, type Http2PseudoHeaderId, type Http2SettingId, type Http2StreamDependency, RequestError, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, type TlsVersion, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };
package/dist/wreq-js.d.ts CHANGED
@@ -54,6 +54,94 @@ type HeaderTuple = [string, string];
54
54
  * ```
55
55
  */
56
56
  type HeadersInit = Iterable<HeaderTuple> | Array<HeaderTuple> | Record<string, string | number | boolean | null | undefined>;
57
+ type AlpnProtocol = "HTTP1" | "HTTP2" | "HTTP3";
58
+ type AlpsProtocol = "HTTP1" | "HTTP2" | "HTTP3";
59
+ type TlsVersion = "1.0" | "1.1" | "1.2" | "1.3" | "TLS1.0" | "TLS1.1" | "TLS1.2" | "TLS1.3";
60
+ type Http2PseudoHeaderId = "Method" | "Scheme" | "Authority" | "Path" | "Protocol";
61
+ type Http2SettingId = "HeaderTableSize" | "EnablePush" | "MaxConcurrentStreams" | "InitialWindowSize" | "MaxFrameSize" | "MaxHeaderListSize" | "EnableConnectProtocol" | "NoRfc7540Priorities";
62
+ interface Http2StreamDependency {
63
+ dependencyId: number;
64
+ weight: number;
65
+ exclusive?: boolean;
66
+ }
67
+ interface Http2Priority {
68
+ streamId: number;
69
+ dependency: Http2StreamDependency;
70
+ }
71
+ interface Http2ExperimentalSetting {
72
+ id: number;
73
+ value: number;
74
+ }
75
+ interface CustomTlsOptions {
76
+ alpnProtocols?: AlpnProtocol[];
77
+ alpsProtocols?: AlpsProtocol[];
78
+ alpsUseNewCodepoint?: boolean;
79
+ sessionTicket?: boolean;
80
+ minTlsVersion?: TlsVersion;
81
+ maxTlsVersion?: TlsVersion;
82
+ preSharedKey?: boolean;
83
+ enableEchGrease?: boolean;
84
+ permuteExtensions?: boolean;
85
+ greaseEnabled?: boolean;
86
+ enableOcspStapling?: boolean;
87
+ enableSignedCertTimestamps?: boolean;
88
+ recordSizeLimit?: number;
89
+ pskSkipSessionTicket?: boolean;
90
+ keySharesLimit?: number;
91
+ pskDheKe?: boolean;
92
+ renegotiation?: boolean;
93
+ delegatedCredentials?: string;
94
+ curvesList?: string;
95
+ cipherList?: string;
96
+ sigalgsList?: string;
97
+ certificateCompressionAlgorithms?: Array<"zlib" | "brotli" | "zstd">;
98
+ extensionPermutation?: number[];
99
+ aesHwOverride?: boolean;
100
+ preserveTls13CipherList?: boolean;
101
+ randomAesHwOverride?: boolean;
102
+ }
103
+ interface CustomHttp1Options {
104
+ http09Responses?: boolean;
105
+ writev?: boolean;
106
+ maxHeaders?: number;
107
+ readBufExactSize?: number;
108
+ maxBufSize?: number;
109
+ ignoreInvalidHeadersInResponses?: boolean;
110
+ allowSpacesAfterHeaderNameInResponses?: boolean;
111
+ allowObsoleteMultilineHeadersInResponses?: boolean;
112
+ }
113
+ interface CustomHttp2Options {
114
+ adaptiveWindow?: boolean;
115
+ initialStreamId?: number;
116
+ initialConnectionWindowSize?: number;
117
+ initialWindowSize?: number;
118
+ initialMaxSendStreams?: number;
119
+ maxFrameSize?: number;
120
+ keepAliveInterval?: number;
121
+ keepAliveTimeout?: number;
122
+ keepAliveWhileIdle?: boolean;
123
+ maxConcurrentResetStreams?: number;
124
+ maxSendBufferSize?: number;
125
+ maxConcurrentStreams?: number;
126
+ maxHeaderListSize?: number;
127
+ maxPendingAcceptResetStreams?: number;
128
+ enablePush?: boolean;
129
+ headerTableSize?: number;
130
+ enableConnectProtocol?: boolean;
131
+ noRfc7540Priorities?: boolean;
132
+ settingsOrder?: Http2SettingId[];
133
+ headersPseudoOrder?: Http2PseudoHeaderId[];
134
+ headersStreamDependency?: Http2StreamDependency;
135
+ priorities?: Http2Priority[];
136
+ experimentalSettings?: Http2ExperimentalSetting[];
137
+ }
138
+ interface CustomEmulationOptions {
139
+ tlsOptions?: CustomTlsOptions;
140
+ http1Options?: CustomHttp1Options;
141
+ http2Options?: CustomHttp2Options;
142
+ headers?: HeadersInit;
143
+ origHeaders?: string[];
144
+ }
57
145
  /**
58
146
  * Represents the various types of data that can be used as a request body.
59
147
  * Supports strings, binary payloads, URL-encoded parameters, multipart forms, and blobs.
@@ -177,6 +265,12 @@ interface RequestInit {
177
265
  * @default 'macos'
178
266
  */
179
267
  os?: EmulationOS;
268
+ /**
269
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
270
+ * layer on top of the resolved preset profile. When both are omitted, this
271
+ * switches the request into standalone custom emulation mode.
272
+ */
273
+ emulation?: CustomEmulationOptions;
180
274
  /**
181
275
  * Proxy URL to route the request through (e.g., 'http://proxy.example.com:8080').
182
276
  * Proxy support depends on the native layer and proxy scheme.
@@ -255,6 +349,10 @@ interface CreateSessionOptions {
255
349
  * Operating system to bind to this session. Defaults to 'macos'.
256
350
  */
257
351
  os?: EmulationOS;
352
+ /**
353
+ * Custom emulation overrides or a standalone custom emulation for the session transport.
354
+ */
355
+ emulation?: CustomEmulationOptions;
258
356
  /**
259
357
  * Optional proxy for every request made through the session.
260
358
  */
@@ -295,6 +393,10 @@ interface CreateTransportOptions {
295
393
  * Operating system to emulate for this transport.
296
394
  */
297
395
  os?: EmulationOS;
396
+ /**
397
+ * Custom emulation overrides or a standalone custom emulation for this transport.
398
+ */
399
+ emulation?: CustomEmulationOptions;
298
400
  /**
299
401
  * Disable HTTPS certificate verification for this transport.
300
402
  */
@@ -357,6 +459,12 @@ interface RequestOptions {
357
459
  * @default 'macos'
358
460
  */
359
461
  os?: EmulationOS;
462
+ /**
463
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
464
+ * layer on top of the resolved preset profile. When both are omitted, this
465
+ * switches the request into standalone custom emulation mode.
466
+ */
467
+ emulation?: CustomEmulationOptions;
360
468
  /**
361
469
  * HTTP method to use for the request.
362
470
  * @default 'GET'
@@ -506,6 +614,12 @@ interface WebSocketOptions {
506
614
  * @default 'macos'
507
615
  */
508
616
  os?: EmulationOS;
617
+ /**
618
+ * Custom emulation overrides. When `browser` or `os` is present, these fields
619
+ * layer on top of the resolved preset profile. When both are omitted, this
620
+ * switches the handshake into standalone custom emulation mode.
621
+ */
622
+ emulation?: CustomEmulationOptions;
509
623
  /**
510
624
  * Additional headers to send with the WebSocket upgrade request.
511
625
  * Common headers include Authorization, Origin, or custom application headers.
@@ -548,7 +662,7 @@ interface LegacyWebSocketOptions extends WebSocketOptions {
548
662
  */
549
663
  onError?: (error: string) => void;
550
664
  }
551
- type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy">;
665
+ type SessionWebSocketOptions = Omit<WebSocketOptions, "browser" | "os" | "proxy" | "emulation">;
552
666
  interface LegacySessionWebSocketOptions extends SessionWebSocketOptions {
553
667
  /**
554
668
  * @deprecated Use `session.websocket(url, options)`.
@@ -616,8 +730,7 @@ interface NativeWebSocketCloseEvent {
616
730
  reason: string;
617
731
  }
618
732
  type SessionDefaults = {
619
- browser: BrowserProfile;
620
- os: EmulationOS;
733
+ transportMode: ResolvedEmulationMode;
621
734
  proxy?: string;
622
735
  timeout?: number;
623
736
  insecure?: boolean;
@@ -625,6 +738,17 @@ type SessionDefaults = {
625
738
  transportId?: string;
626
739
  ownsTransport?: boolean;
627
740
  };
741
+ type PresetEmulationMode = {
742
+ kind: "preset";
743
+ browser: BrowserProfile;
744
+ os: EmulationOS;
745
+ emulationJson?: string;
746
+ };
747
+ type CustomEmulationMode = {
748
+ kind: "custom";
749
+ emulationJson: string;
750
+ };
751
+ type ResolvedEmulationMode = PresetEmulationMode | CustomEmulationMode;
628
752
  type LegacyWebSocketCallbacks = {
629
753
  onMessage?: (data: string | Buffer) => void;
630
754
  onClose?: (event: WebSocketCloseEvent) => void;
@@ -914,4 +1038,4 @@ declare const _default: {
914
1038
  RequestError: typeof RequestError;
915
1039
  };
916
1040
 
917
- export { type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type EmulationOS, Headers, type HeadersInit, RequestError, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };
1041
+ export { type AlpnProtocol, type AlpsProtocol, type BodyInit, type BrowserProfile, type CookieMode, type CreateSessionOptions, type CreateTransportOptions, type CustomEmulationOptions, type CustomHttp1Options, type CustomHttp2Options, type CustomTlsOptions, type EmulationOS, Headers, type HeadersInit, type Http2ExperimentalSetting, type Http2Priority, type Http2PseudoHeaderId, type Http2SettingId, type Http2StreamDependency, RequestError, type RequestInit, type RequestOptions, Response, Session, type SessionHandle, type SessionWebSocketOptions, type TlsVersion, Transport, WebSocket, type WebSocketBinaryType, type WebSocketCloseEvent, type WebSocketErrorEvent, type WebSocketEventType, type WebSocketMessageEvent, type WebSocketOpenEvent, type WebSocketOptions, createSession, createTransport, _default as default, fetch, get, getOperatingSystems, getProfiles, post, request, websocket, withSession };