Socket
Socket
Sign inDemoInstall

got-cjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got-cjs - npm Package Compare versions

Comparing version 12.0.0-beta.4 to 12.0.0

2

dist/source/as-promise/index.d.ts
import Request from '../core/index.js';
import type { CancelableRequest } from './types.js';
export default function asPromise<T>(firstRequest: Request): CancelableRequest<T>;
export default function asPromise<T>(firstRequest?: Request): CancelableRequest<T>;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const node_events_1 = require("node:events");
const is_1 = __importDefault(require("@sindresorhus/is"));

@@ -26,3 +26,3 @@ const p_cancelable_1 = __importDefault(require("p-cancelable"));

let normalizedOptions;
const emitter = new events_1.EventEmitter();
const emitter = new node_events_1.EventEmitter();
const promise = new p_cancelable_1.default((resolve, reject, onCancel) => {

@@ -50,3 +50,3 @@ onCancel(() => {

const contentEncoding = ((_a = response.headers['content-encoding']) !== null && _a !== void 0 ? _a : '').toLowerCase();
const isCompressed = contentEncoding === 'gzip' || contentEncoding === 'defalte' || contentEncoding === 'br';
const isCompressed = contentEncoding === 'gzip' || contentEncoding === 'deflate' || contentEncoding === 'br';
const { options } = request;

@@ -58,8 +58,8 @@ if (isCompressed && !options.decompress) {

try {
response.body = response_js_1.parseBody(response, options.responseType, options.parseJson, options.encoding);
response.body = (0, response_js_1.parseBody)(response, options.responseType, options.parseJson, options.encoding);
}
catch (error) {
// Fallback to `utf8`
// Fall back to `utf8`
response.body = response.rawBody.toString();
if (response_js_1.isResponseOk(response)) {
if ((0, response_js_1.isResponseOk)(response)) {
request._beforeError(error);

@@ -72,6 +72,3 @@ return;

const hooks = options.hooks.afterResponse;
// TODO: `xo` should detect if `index` is being used for something else
// eslint-disable-next-line unicorn/no-for-loop
for (let index = 0; index < hooks.length; index++) {
const hook = hooks[index];
for (const [index, hook] of hooks.entries()) {
// @ts-expect-error TS doesn't notice that CancelableRequest is a Promise

@@ -100,3 +97,3 @@ // eslint-disable-next-line no-await-in-loop

globalResponse = response;
if (!response_js_1.isResponseOk(response)) {
if (!(0, response_js_1.isResponseOk)(response)) {
request._beforeError(new errors_js_1.HTTPError(response));

@@ -124,3 +121,2 @@ return;

request.once('retry', (newRetryCount, error) => {
// @ts-expect-error
firstRequest = undefined;

@@ -138,3 +134,3 @@ const newBody = request.options.body;

});
proxy_events_js_1.default(request, emitter, proxiedRequestEvents);
(0, proxy_events_js_1.default)(request, emitter, proxiedRequestEvents);
if (is_1.default.undefined(firstRequest)) {

@@ -155,3 +151,3 @@ void request.flush();

const { options } = globalResponse.request;
return response_js_1.parseBody(globalResponse, responseType, options.parseJson, options.encoding);
return (0, response_js_1.parseBody)(globalResponse, responseType, options.parseJson, options.encoding);
})();

@@ -158,0 +154,0 @@ // eslint-disable-next-line @typescript-eslint/no-floating-promises

/// <reference types="node" />
import type { Buffer } from 'node:buffer';
import PCancelable from 'p-cancelable';

@@ -13,8 +14,26 @@ import { RequestError } from '../core/errors.js';

constructor(request: Request);
/**
Whether the promise is canceled.
*/
get isCanceled(): boolean;
}
export interface CancelableRequest<T extends Response | Response['body'] = Response['body']> extends PCancelable<T>, RequestEvents<CancelableRequest<T>> {
/**
A shortcut method that gives a Promise returning a JSON object.
It is semantically the same as settings `options.resolveBodyOnly` to `true` and `options.responseType` to `'json'`.
*/
json: <ReturnType>() => CancelableRequest<ReturnType>;
/**
A shortcut method that gives a Promise returning a [Buffer](https://nodejs.org/api/buffer.html).
It is semantically the same as settings `options.resolveBodyOnly` to `true` and `options.responseType` to `'buffer'`.
*/
buffer: () => CancelableRequest<Buffer>;
/**
A shortcut method that gives a Promise returning a string.
It is semantically the same as settings `options.resolveBodyOnly` to `true` and `options.responseType` to `'text'`.
*/
text: () => CancelableRequest<string>;
}

@@ -14,2 +14,5 @@ "use strict";

}
/**
Whether the promise is canceled.
*/
get isCanceled() {

@@ -16,0 +19,0 @@ return true;

@@ -105,2 +105,3 @@ "use strict";

*/
// eslint-disable-next-line @typescript-eslint/naming-convention
class HTTPError extends RequestError {

@@ -107,0 +108,0 @@ constructor(response) {

/// <reference types="node" />
import { Duplex } from 'stream';
import { URL } from 'url';
import { ServerResponse } from 'http';
import type { ClientRequest } from 'http';
import type { Socket } from 'net';
import { Duplex } from 'node:stream';
import { URL } from 'node:url';
import { ServerResponse } from 'node:http';
import type { ClientRequest } from 'node:http';
import type { Socket } from 'node:net';
import CacheableRequest from 'cacheable-request';

@@ -117,3 +117,3 @@ import type { Timings } from '@szmarczak/http-timer';

_read(): void;
_write(chunk: any, encoding: string | undefined, callback: (error?: Error | null) => void): void;
_write(chunk: unknown, encoding: BufferEncoding | undefined, callback: (error?: Error | null) => void): void;
_final(callback: (error?: Error | null) => void): void;

@@ -120,0 +120,0 @@ _destroy(error: Error | null, callback: (error: Error | null) => void): void;

@@ -25,5 +25,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
const url_1 = require("url");
const http_1 = __importStar(require("http"));
const node_process_1 = __importDefault(require("node:process"));
const node_buffer_1 = require("node:buffer");
const node_stream_1 = require("node:stream");
const node_url_1 = require("node:url");
const node_http_1 = __importStar(require("node:http"));
const http_timer_1 = __importDefault(require("@szmarczak/http-timer"));

@@ -34,2 +36,3 @@ const cacheable_request_1 = __importDefault(require("cacheable-request"));

const get_stream_1 = require("get-stream");
const form_data_encoder_1 = require("form-data-encoder");
const get_body_size_js_1 = __importDefault(require("./utils/get-body-size.js"));

@@ -46,3 +49,3 @@ const is_form_data_js_1 = __importDefault(require("./utils/is-form-data.js"));

const errors_js_1 = require("./errors.js");
const supportsBrotli = is_1.default.string(process.versions.brotli);
const supportsBrotli = is_1.default.string(node_process_1.default.versions.brotli);
const methodsWithoutBody = new Set(['GET', 'HEAD']);

@@ -59,3 +62,3 @@ const cacheableStore = new weakable_map_js_1.default();

const noop = () => { };
class Request extends stream_1.Duplex {
class Request extends node_stream_1.Duplex {
constructor(url, options, defaults) {

@@ -252,2 +255,7 @@ super({

});
this.on('newListener', event => {
if (event === 'retry' && this.listenerCount('retry') > 0) {
throw new Error('A retry listener has been attached already.');
}
});
try {

@@ -371,3 +379,3 @@ this.options = new options_js_1.default(url, options, defaults);

retryAfter,
computedValue: calculate_retry_delay_js_1.default({
computedValue: (0, calculate_retry_delay_js_1.default)({
attemptCount,

@@ -412,3 +420,10 @@ retryOptions,

this.destroy();
this.emit('retry', this.retryCount + 1, error);
this.emit('retry', this.retryCount + 1, error, (updatedOptions) => {
const request = new Request(options.url, updatedOptions, options);
request.retryCount = this.retryCount + 1;
node_process_1.default.nextTick(() => {
void request.flush();
});
return request;
});
return;

@@ -440,3 +455,2 @@ }

}
// Node.js 12 has incorrect types, so the encoding must be a string
_write(chunk, encoding, callback) {

@@ -504,3 +518,3 @@ const write = () => {

pipe(destination, options) {
if (destination instanceof http_1.ServerResponse) {
if (destination instanceof node_http_1.ServerResponse) {
this._pipedServerResponses.add(destination);

@@ -511,3 +525,3 @@ }

unpipe(destination) {
if (destination instanceof http_1.ServerResponse) {
if (destination instanceof node_http_1.ServerResponse) {
this._pipedServerResponses.delete(destination);

@@ -533,2 +547,3 @@ }

const isForm = !is_1.default.undefined(options.form);
// eslint-disable-next-line @typescript-eslint/naming-convention
const isJSON = !is_1.default.undefined(options.json);

@@ -545,4 +560,13 @@ const isBody = !is_1.default.undefined(options.body);

if (isBody) {
// Body is spec-compliant FormData
if ((0, form_data_encoder_1.isFormDataLike)(options.body)) {
const encoder = new form_data_encoder_1.FormDataEncoder(options.body);
if (noContentType) {
headers['content-type'] = encoder.headers['Content-Type'];
}
headers['content-length'] = encoder.headers['Content-Length'];
options.body = encoder.encode();
}
// Special case for https://github.com/form-data/form-data
if (is_form_data_js_1.default(options.body) && noContentType) {
if ((0, is_form_data_js_1.default)(options.body) && noContentType) {
headers['content-type'] = `multipart/form-data; boundary=${options.body.getBoundary()}`;

@@ -557,3 +581,3 @@ }

options.form = undefined;
options.body = (new url_1.URLSearchParams(form)).toString();
options.body = (new node_url_1.URLSearchParams(form)).toString();
}

@@ -568,3 +592,3 @@ else {

}
const uploadBodySize = await get_body_size_js_1.default(options.body, options.headers);
const uploadBodySize = await (0, get_body_size_js_1.default)(options.body, options.headers);
// See https://tools.ietf.org/html/rfc7230#section-3.3.2

@@ -604,7 +628,7 @@ // A user agent SHOULD send a Content-Length in a request message when

if (options.decompress) {
response = decompress_response_1.default(response);
response = (0, decompress_response_1.default)(response);
}
const statusCode = response.statusCode;
const typedResponse = response;
typedResponse.statusMessage = typedResponse.statusMessage ? typedResponse.statusMessage : http_1.default.STATUS_CODES[statusCode];
typedResponse.statusMessage = typedResponse.statusMessage ? typedResponse.statusMessage : node_http_1.default.STATUS_CODES[statusCode];
typedResponse.url = options.url.toString();

@@ -688,4 +712,4 @@ typedResponse.requestUrl = this.requestUrl;

// We need this in order to support UTF-8
const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();
const redirectUrl = new url_1.URL(redirectBuffer, url);
const redirectBuffer = node_buffer_1.Buffer.from(response.headers.location, 'binary').toString();
const redirectUrl = new node_url_1.URL(redirectBuffer, url);
// Redirecting to a different site, clear sensitive data.

@@ -728,3 +752,3 @@ if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) {

}
if (options.isStream && options.throwHttpErrors && !response_js_1.isResponseOk(typedResponse)) {
if (options.isStream && options.throwHttpErrors && !(0, response_js_1.isResponseOk)(typedResponse)) {
this._beforeError(new errors_js_1.HTTPError(typedResponse));

@@ -776,3 +800,3 @@ return;

// Errors are emitted via the `error` event
const rawBody = await get_stream_1.buffer(from);
const rawBody = await (0, get_stream_1.buffer)(from);
// On retry Request is destroyed with no error, therefore the above will successfully resolve.

@@ -800,3 +824,3 @@ // So in order to check if this was really successfull, we need to check if it has been properly ended.

const { timeout, url } = options;
http_timer_1.default(request);
(0, http_timer_1.default)(request);
if (this.options.http2) {

@@ -806,3 +830,3 @@ // Unset stream timeout, as the `timeout` option was used only for connection timeout.

}
this._cancelTimeouts = timed_out_js_1.default(request, timeout, url);
this._cancelTimeouts = (0, timed_out_js_1.default)(request, timeout, url);
const responseEventName = options.cache ? 'cacheableResponse' : 'response';

@@ -819,3 +843,3 @@ request.once(responseEventName, (response) => {

});
this._unproxyEvents = proxy_events_js_1.default(request, this, proxiedRequestEvents);
this._unproxyEvents = (0, proxy_events_js_1.default)(request, this, proxiedRequestEvents);
this._request = request;

@@ -879,3 +903,3 @@ this.emit('uploadProgress', this.uploadProgress);

// The result will be a promise anyway.
// @ts-expect-error
// @ts-expect-error ignore
// eslint-disable-next-line @typescript-eslint/promise-function-async

@@ -918,3 +942,3 @@ result.once = (event, handler) => {

// TODO: Remove `utils/url-to-options.ts` when `cacheable-request` is fixed
Object.assign(options, url_to_options_js_1.default(url));
Object.assign(options, (0, url_to_options_js_1.default)(url));
let request;

@@ -960,3 +984,3 @@ // TODO: Fix `cacheable-response`. This is ugly.

if (username || password) {
const credentials = Buffer.from(`${username}:${password}`).toString('base64');
const credentials = node_buffer_1.Buffer.from(`${username}:${password}`).toString('base64');
headers.authorization = `Basic ${credentials}`;

@@ -1009,3 +1033,3 @@ }

}
if (is_client_request_js_1.default(requestOrResponse)) {
if ((0, is_client_request_js_1.default)(requestOrResponse)) {
this._onRequest(requestOrResponse);

@@ -1049,3 +1073,3 @@ }

if (!error) {
this._uploadedSize += Buffer.byteLength(chunk, encoding);
this._uploadedSize += node_buffer_1.Buffer.byteLength(chunk, encoding);
const progress = this.uploadProgress;

@@ -1052,0 +1076,0 @@ if (progress.percent < 1) {

/// <reference types="node" />
import { URL, URLSearchParams } from 'url';
import { checkServerIdentity } from 'tls';
import { request as httpsRequest } from 'https';
import type { Readable } from 'stream';
import type { Socket } from 'net';
import type { SecureContextOptions, DetailedPeerCertificate } from 'tls';
import type { Agent as HttpAgent, ClientRequest } from 'http';
import type { RequestOptions as HttpsRequestOptions, Agent as HttpsAgent } from 'https';
import { Buffer } from 'node:buffer';
import { URL, URLSearchParams } from 'node:url';
import { checkServerIdentity } from 'node:tls';
import { request as httpsRequest } from 'node:https';
import type { Readable } from 'node:stream';
import type { Socket } from 'node:net';
import type { SecureContextOptions, DetailedPeerCertificate } from 'node:tls';
import type { Agent as HttpAgent, ClientRequest } from 'node:http';
import type { RequestOptions as HttpsRequestOptions, Agent as HttpsAgent } from 'node:https';
import CacheableLookup from 'cacheable-lookup';
import http2wrapper, { ClientHttp2Session } from 'http2-wrapper';
import type { FormDataLike } from 'form-data-encoder';
import type CacheableRequest from 'cacheable-request';

@@ -53,30 +55,137 @@ import type ResponseLike from 'responselike';

/**
Called with plain request options, right before their normalization.
Called with the plain request options, right before their normalization.
The second argument represents the current `Options` instance.
@default []
**Note:**
> - This hook must be synchronous.
**Note:**
> - This is called every time options are merged.
**Note:**
> - The `options` object may not have the `url` property. To modify it, use a `beforeRequest` hook instead.
**Note:**
> - This hook is called when a new instance of `Options` is created.
> - Do not confuse this with the creation of `Request` or `got(…)`.
**Note:**
> - When using `got(url)` or `got(url, undefined, defaults)` this hook will **not** be called.
This is especially useful in conjunction with `got.extend()` when the input needs custom handling.
__Note #1__: This hook must be synchronous!
For example, this can be used to fix typos to migrate from older versions faster.
__Note #2__: Errors in this hook will be converted into an instances of `RequestError`.
@example
```
import got from 'got';
__Note #3__: The options object may not have a `url` property.
To modify it, use a `beforeRequest` hook instead.
const instance = got.extend({
hooks: {
init: [
plain => {
if ('followRedirects' in plain) {
plain.followRedirect = plain.followRedirects;
delete plain.followRedirects;
}
}
]
}
});
@default []
// Normally, the following would throw:
const response = await instance(
'https://example.com',
{
followRedirects: true
}
);
// There is no option named `followRedirects`, but we correct it in an `init` hook.
```
Or you can create your own option and store it in a context:
```
import got from 'got';
const instance = got.extend({
hooks: {
init: [
(plain, options) => {
if ('secret' in plain) {
options.context.secret = plain.secret;
delete plain.secret;
}
}
],
beforeRequest: [
options => {
options.headers.secret = options.context.secret;
}
]
}
});
const {headers} = await instance(
'https://httpbin.org/anything',
{
secret: 'passphrase'
}
).json();
console.log(headers.Secret);
//=> 'passphrase'
```
*/
init: InitHook[];
/**
Called with normalized request options.
Got will make no further changes to the request before it is sent.
This is especially useful in conjunction with `got.extend()` when you want to create an API client that, for example, uses HMAC-signing.
Called right before making the request with `options.createNativeRequestOptions()`.
This hook is especially useful in conjunction with `got.extend()` when you want to sign your request.
@default []
**Note:**
> - Got will make no further changes to the request before it is sent.
**Note:**
> - Changing `options.json` or `options.form` has no effect on the request. You should change `options.body` instead. If needed, update the `options.headers` accordingly.
@example
```
import got from 'got';
const response = await got.post(
'https://httpbin.org/anything',
{
json: {payload: 'old'},
hooks: {
beforeRequest: [
options => {
options.body = JSON.stringify({payload: 'new'});
options.headers['content-length'] = options.body.length.toString();
}
]
}
}
);
```
**Tip:**
> - You can indirectly override the `request` function by early returning a [`ClientRequest`-like](https://nodejs.org/api/http.html#http_class_http_clientrequest) instance or a [`IncomingMessage`-like](https://nodejs.org/api/http.html#http_class_http_incomingmessage) instance. This is very useful when creating a custom cache mechanism.
> - [Read more about this tip](https://github.com/sindresorhus/got/blob/main/documentation/cache.md#advanced-caching-mechanisms).
*/
beforeRequest: BeforeRequestHook[];
/**
Called with normalized request options and the redirect response.
Got will make no further changes to the request.
This is especially useful when you want to avoid dead sites.
The equivalent of `beforeRequest` but when redirecting.
@default []
**Tip:**
> - This is especially useful when you want to avoid dead sites.
@example

@@ -86,3 +195,3 @@ ```

await got('https://example.com', {
const response = await got('https://example.com', {
hooks: {

@@ -102,15 +211,13 @@ beforeRedirect: [

/**
Called with an `Error` instance.
The error is passed to the hook right before it's thrown.
Called with a `RequestError` instance. The error is passed to the hook right before it's thrown.
This is especially useful when you want to have more detailed errors.
__Note__: Errors thrown while normalizing input options are thrown directly and not part of this hook.
@default []
@example
```
import got from 'got';
await got('https://api.github.com/some-endpoint', {
await got('https://api.github.com/repos/sindresorhus/got/commits', {
responseType: 'json',
hooks: {

@@ -134,11 +241,17 @@ beforeError: [

/**
Called with normalized request options, the error and the retry count.
Got will make no further changes to the request.
This is especially useful when some extra work is required before the next try.
The equivalent of `beforeError` but when retrying. Additionally, there is a second argument `retryCount`, the current retry number.
__Note__: When using streams, this hook is ignored.
__Note__: When retrying in a `afterResponse` hook, all remaining `beforeRetry` hooks will be called without the `error` and `retryCount` arguments.
@default []
**Note:**
> - When using the Stream API, this hook is ignored.
**Note:**
> - When retrying, the `beforeRequest` hook is called afterwards.
**Note:**
> - If no retry occurs, the `beforeError` hook is called instead.
This hook is especially useful when you want to retrieve the cause of a retry.
@example

@@ -148,9 +261,8 @@ ```

got.post('https://example.com', {
await got('https://httpbin.org/status/500', {
hooks: {
beforeRetry: [
(options, error, retryCount) => {
if (error.response.statusCode === 413) { // Payload too large
options.body = getNewBody();
}
(error, retryCount) => {
console.log(`Retrying [${retryCount}]: ${error.code}`);
// Retrying [1]: ERR_NON_2XX_3XX_RESPONSE
}

@@ -164,10 +276,11 @@ ]

/**
Called with [response object](#response) and a retry function.
Each function should return the response. This is especially useful when you want to refresh an access token.
Each function should return the response.
This is especially useful when you want to refresh an access token.
@default []
__Note__: When using streams, this hook is ignored.
**Note:**
> - When using the Stream API, this hook is ignored.
__Note__: Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead.
**Note:**
> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead.
Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped.

@@ -183,11 +296,13 @@

(response, retryWithMergedOptions) => {
if (response.statusCode === 401) { // Unauthorized
// Unauthorized
if (response.statusCode === 401) {
// Refresh the access token
const updatedOptions = {
headers: {
token: getNewToken() // Refresh the access token
token: getNewToken()
}
};
// Save for further requests
instance.defaults.options = got.mergeOptions(instance.defaults.options, updatedOptions);
// Update the defaults
instance.defaults.options.merge(updatedOptions);

@@ -203,3 +318,3 @@ // Make a new retry

beforeRetry: [
(options, error, retryCount) => {
error => {
// This will be called on `retryWithMergedOptions(...)`

@@ -572,8 +687,8 @@ }

The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
Since Got 12, the `content-length` is not automatically set when `body` is a `fs.createReadStream`.
*/
get body(): string | Buffer | Readable | Generator | AsyncGenerator | undefined;
set body(value: string | Buffer | Readable | Generator | AsyncGenerator | undefined);
get body(): string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined;
set body(value: string | Buffer | Readable | Generator | AsyncGenerator | FormDataLike | undefined);
/**

@@ -996,2 +1111,4 @@ The form body is converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).

request: RequestFunction | undefined;
username: string;
password: string;
json: Record<string, any> | undefined;

@@ -1003,3 +1120,3 @@ retry: Partial<RetryOptions>;

prefixUrl: string | URL;
body: string | Readable | Buffer | Generator<unknown, any, unknown> | AsyncGenerator<unknown, any, unknown> | undefined;
body: string | Readable | Buffer | Generator<unknown, any, unknown> | AsyncGenerator<unknown, any, unknown> | FormDataLike | undefined;
form: Record<string, any> | undefined;

@@ -1011,8 +1128,8 @@ url: string | URL | undefined;

dnsLookup: {
(hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions & {
all: true;
}, callback: (error: NodeJS.ErrnoException, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
}, callback: (error: NodeJS.ErrnoException | null, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
} | undefined;

@@ -1026,4 +1143,2 @@ dnsCache: boolean | CacheableLookup | undefined;

throwHttpErrors: boolean;
username: string;
password: string;
http2: boolean;

@@ -1067,8 +1182,8 @@ allowGetBody: boolean;

lookup: {
(hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, family: import("cacheable-lookup").IPFamily, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions & {
all: true;
}, callback: (error: NodeJS.ErrnoException, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
}, callback: (error: NodeJS.ErrnoException | null, result: readonly import("cacheable-lookup").EntryObject[]) => void): void;
(hostname: string, options: import("cacheable-lookup").LookupOptions, callback: (error: NodeJS.ErrnoException | null, address: string, family: import("cacheable-lookup").IPFamily) => void): void;
} | undefined;

@@ -1085,2 +1200,3 @@ family: DnsLookupIpVersion;

h2session: http2wrapper.ClientHttp2Session | undefined;
signal?: AbortSignal | undefined;
protocol?: string | null | undefined;

@@ -1087,0 +1203,0 @@ host?: string | null | undefined;

@@ -25,7 +25,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const url_1 = require("url");
const tls_1 = require("tls");
const http_1 = require("http");
const https_1 = require("https");
const node_process_1 = __importDefault(require("node:process"));
const node_util_1 = require("node:util");
const node_url_1 = require("node:url");
const node_tls_1 = require("node:tls");
const node_http_1 = require("node:http");
const node_https_1 = require("node:https");
const is_1 = __importStar(require("@sindresorhus/is"));

@@ -35,4 +36,5 @@ const lowercase_keys_1 = __importDefault(require("lowercase-keys"));

const http2_wrapper_1 = __importDefault(require("http2-wrapper"));
const form_data_encoder_1 = require("form-data-encoder");
const parse_link_header_js_1 = __importDefault(require("./parse-link-header.js"));
const [major, minor] = process.versions.node.split('.').map(v => Number(v));
const [major, minor] = node_process_1.default.versions.node.split('.').map(v => Number(v));
function validateSearchParameters(searchParameters) {

@@ -188,7 +190,7 @@ // eslint-disable-next-line guard-for-in

}
const parsed = parse_link_header_js_1.default(rawLinkHeader);
const parsed = (0, parse_link_header_js_1.default)(rawLinkHeader);
const next = parsed.find(entry => entry.parameters.rel === 'next' || entry.parameters.rel === '"next"');
if (next) {
return {
url: new url_1.URL(next.reference, response.url),
url: new node_url_1.URL(next.reference, response.url),
};

@@ -232,3 +234,3 @@ }

},
searchParams: internals.searchParams ? new url_1.URLSearchParams(internals.searchParams) : undefined,
searchParams: internals.searchParams ? new node_url_1.URLSearchParams(internals.searchParams) : undefined,
pagination: { ...internals.pagination },

@@ -244,53 +246,55 @@ };

const result = { ...raw };
if (raw.context) {
if (is_1.default.object(raw.context)) {
result.context = { ...raw.context };
}
if (raw.cacheOptions) {
if (is_1.default.object(raw.cacheOptions)) {
result.cacheOptions = { ...raw.cacheOptions };
}
if (raw.https) {
if (is_1.default.object(raw.https)) {
result.https = { ...raw.https };
}
if (raw.cacheOptions) {
if (is_1.default.object(raw.cacheOptions)) {
result.cacheOptions = { ...result.cacheOptions };
}
if (raw.agent) {
if (is_1.default.object(raw.agent)) {
result.agent = { ...raw.agent };
}
if (raw.headers) {
if (is_1.default.object(raw.headers)) {
result.headers = { ...raw.headers };
}
if (retry) {
if (is_1.default.object(retry)) {
result.retry = { ...retry };
if (retry.errorCodes) {
if (is_1.default.array(retry.errorCodes)) {
result.retry.errorCodes = [...retry.errorCodes];
}
if (retry.methods) {
if (is_1.default.array(retry.methods)) {
result.retry.methods = [...retry.methods];
}
if (retry.statusCodes) {
if (is_1.default.array(retry.statusCodes)) {
result.retry.statusCodes = [...retry.statusCodes];
}
}
if (raw.timeout) {
if (is_1.default.object(raw.timeout)) {
result.timeout = { ...raw.timeout };
}
if (hooks) {
result.hooks = {};
if (hooks.init) {
if (is_1.default.object(hooks)) {
result.hooks = {
...hooks,
};
if (is_1.default.array(hooks.init)) {
result.hooks.init = [...hooks.init];
}
if (hooks.beforeRequest) {
if (is_1.default.array(hooks.beforeRequest)) {
result.hooks.beforeRequest = [...hooks.beforeRequest];
}
if (hooks.beforeError) {
if (is_1.default.array(hooks.beforeError)) {
result.hooks.beforeError = [...hooks.beforeError];
}
if (hooks.beforeRedirect) {
if (is_1.default.array(hooks.beforeRedirect)) {
result.hooks.beforeRedirect = [...hooks.beforeRedirect];
}
if (hooks.beforeRetry) {
if (is_1.default.array(hooks.beforeRetry)) {
result.hooks.beforeRetry = [...hooks.beforeRetry];
}
if (hooks.afterResponse) {
if (is_1.default.array(hooks.afterResponse)) {
result.hooks.afterResponse = [...hooks.afterResponse];

@@ -300,3 +304,3 @@ }

// TODO: raw.searchParams
if (raw.pagination) {
if (is_1.default.object(raw.pagination)) {
result.pagination = { ...raw.pagination };

@@ -629,3 +633,3 @@ }

The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.

@@ -638,3 +642,3 @@ Since Got 12, the `content-length` is not automatically set when `body` is a `fs.createReadStream`.

set body(value) {
is_1.assert.any([is_1.default.string, is_1.default.buffer, is_1.default.nodeStream, is_1.default.generator, is_1.default.asyncGenerator, is_1.default.undefined], value);
is_1.assert.any([is_1.default.string, is_1.default.buffer, is_1.default.nodeStream, is_1.default.generator, is_1.default.asyncGenerator, form_data_encoder_1.isFormDataLike, is_1.default.undefined], value);
if (is_1.default.nodeStream(value)) {

@@ -718,3 +722,3 @@ is_1.assert.truthy(value.readable);

const urlString = `${this.prefixUrl}${value.toString()}`;
const url = new url_1.URL(urlString);
const url = new node_url_1.URL(urlString);
this._internals.url = url;

@@ -778,4 +782,4 @@ decodeURI(urlString);

if (setCookie.length === 4 && getCookieString.length === 0) {
setCookie = util_1.promisify(setCookie.bind(value));
getCookieString = util_1.promisify(getCookieString.bind(value));
setCookie = (0, node_util_1.promisify)(setCookie.bind(value));
getCookieString = (0, node_util_1.promisify)(getCookieString.bind(value));
this._internals.cookieJar = {

@@ -826,3 +830,3 @@ setCookie,

if (this._internals.searchParams === undefined) {
this._internals.searchParams = new url_1.URLSearchParams();
this._internals.searchParams = new node_url_1.URLSearchParams();
}

@@ -844,5 +848,5 @@ return this._internals.searchParams;

if (is_1.default.string(value)) {
updated = new url_1.URLSearchParams(value);
updated = new node_url_1.URLSearchParams(value);
}
else if (value instanceof url_1.URLSearchParams) {
else if (value instanceof node_url_1.URLSearchParams) {
updated = value;

@@ -852,3 +856,3 @@ }

validateSearchParameters(value);
updated = new url_1.URLSearchParams();
updated = new node_url_1.URLSearchParams();
// eslint-disable-next-line guard-for-in

@@ -1160,6 +1164,6 @@ for (const key in value) {

if (this._merging) {
Object.assign(this._internals.headers, lowercase_keys_1.default(value));
Object.assign(this._internals.headers, (0, lowercase_keys_1.default)(value));
}
else {
this._internals.headers = lowercase_keys_1.default(value);
this._internals.headers = (0, lowercase_keys_1.default)(value);
}

@@ -1537,2 +1541,3 @@ }

}
// eslint-disable-next-line @typescript-eslint/naming-convention
toJSON() {

@@ -1542,3 +1547,3 @@ return { ...this._internals };

[Symbol.for('nodejs.util.inspect.custom')](_depth, options) {
return util_1.inspect(this._internals, options);
return (0, node_util_1.inspect)(this._internals, options);
}

@@ -1568,2 +1573,3 @@ createNativeRequestOptions() {

// HTTPS options
// eslint-disable-next-line @typescript-eslint/naming-convention
ALPNProtocols: https.alpnProtocols,

@@ -1576,3 +1582,3 @@ ca: https.certificateAuthority,

rejectUnauthorized: https.rejectUnauthorized,
checkServerIdentity: (_a = https.checkServerIdentity) !== null && _a !== void 0 ? _a : tls_1.checkServerIdentity,
checkServerIdentity: (_a = https.checkServerIdentity) !== null && _a !== void 0 ? _a : node_tls_1.checkServerIdentity,
ciphers: https.ciphers,

@@ -1624,5 +1630,5 @@ honorCipherOrder: https.honorCipherOrder,

}
return https_1.request;
return node_https_1.request;
}
return http_1.request;
return node_http_1.request;
}

@@ -1629,0 +1635,0 @@ freeze() {

/// <reference types="node" />
import type { URL } from 'url';
import type { Buffer } from 'node:buffer';
import type { URL } from 'node:url';
import type { IncomingMessageWithTimings, Timings } from '@szmarczak/http-timer';

@@ -4,0 +5,0 @@ import { RequestError } from './errors.js';

@@ -36,6 +36,2 @@ "use strict";

}
throw new ParseError({
message: `Unknown body type '${responseType}'`,
name: 'Error',
}, response);
}

@@ -45,3 +41,7 @@ catch (error) {

}
throw new ParseError({
message: `Unknown body type '${responseType}'`,
name: 'Error',
}, response);
};
exports.parseBody = parseBody;

@@ -1,2 +0,2 @@

import { ClientRequest } from 'http';
import { ClientRequest } from 'node:http';
declare const reentry: unique symbol;

@@ -3,0 +3,0 @@ interface TimedOutOptions {

@@ -7,3 +7,3 @@ "use strict";

exports.TimeoutError = void 0;
const net_1 = __importDefault(require("net"));
const node_net_1 = __importDefault(require("node:net"));
const unhandle_js_1 = __importDefault(require("./utils/unhandle.js"));

@@ -38,3 +38,3 @@ const reentry = Symbol('reentry');

const cancelers = [];
const { once, unhandleAll } = unhandle_js_1.default();
const { once, unhandleAll } = (0, unhandle_js_1.default)();
const addTimeout = (delay, callback, event) => {

@@ -97,3 +97,3 @@ var _a;

if (socket.connecting) {
const hasPath = Boolean(socketPath !== null && socketPath !== void 0 ? socketPath : net_1.default.isIP((_a = hostname !== null && hostname !== void 0 ? hostname : host) !== null && _a !== void 0 ? _a : '') !== 0);
const hasPath = Boolean(socketPath !== null && socketPath !== void 0 ? socketPath : node_net_1.default.isIP((_a = hostname !== null && hostname !== void 0 ? hostname : host) !== null && _a !== void 0 ? _a : '') !== 0);
if (hasLookup && !hasPath && typeof socket.address().address === 'undefined') {

@@ -100,0 +100,0 @@ const cancelTimeout = addTimeout(delays.lookup, timeoutHandler, 'lookup');

/// <reference types="node" />
import { ClientRequestArgs } from 'http';
import { ClientRequestArgs } from 'node:http';
export default function getBodySize(body: unknown, headers: ClientRequestArgs['headers']): Promise<number | undefined>;

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const node_buffer_1 = require("node:buffer");
const node_util_1 = require("node:util");
const is_1 = __importDefault(require("@sindresorhus/is"));

@@ -18,3 +19,3 @@ const is_form_data_js_1 = __importDefault(require("./is-form-data.js"));

if (is_1.default.string(body)) {
return Buffer.byteLength(body);
return node_buffer_1.Buffer.byteLength(body);
}

@@ -24,4 +25,4 @@ if (is_1.default.buffer(body)) {

}
if (is_form_data_js_1.default(body)) {
return util_1.promisify(body.getLength.bind(body))();
if ((0, is_form_data_js_1.default)(body)) {
return (0, node_util_1.promisify)(body.getLength.bind(body))();
}

@@ -28,0 +29,0 @@ return undefined;

/// <reference types="node" />
import type { Writable, Readable } from 'stream';
import type { ClientRequest } from 'http';
import type { Writable, Readable } from 'node:stream';
import type { ClientRequest } from 'node:http';
declare function isClientRequest(clientRequest: Writable | Readable): clientRequest is ClientRequest;
export default isClientRequest;
/// <reference types="node" />
import { Readable } from 'stream';
import { Readable } from 'node:stream';
interface FormData extends Readable {

@@ -4,0 +4,0 @@ getBoundary: () => string;

/// <reference types="node" />
import { URL } from 'url';
import { URL } from 'node:url';
export interface URLOptions {

@@ -4,0 +4,0 @@ href?: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* istanbul ignore file: deprecated */
const url_1 = require("url");
const node_url_1 = require("node:url");
const keys = [

@@ -35,3 +35,3 @@ 'protocol',

}
const url = new url_1.URL(origin);
const url = new node_url_1.URL(origin);
if (options.path) {

@@ -38,0 +38,0 @@ const searchIndex = options.path.indexOf('?');

/// <reference types="node" />
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
export default function proxyEvents(from: EventEmitter, to: EventEmitter, events: Readonly<string[]>): () => void;
/// <reference types="node" />
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
declare type Origin = EventEmitter;

@@ -4,0 +4,0 @@ declare type Event = string | symbol;

/// <reference types="node" />
import { URL, UrlWithStringQuery } from 'url';
import { URL, UrlWithStringQuery } from 'node:url';
export interface LegacyUrlOptions {

@@ -4,0 +4,0 @@ protocol: string;

@@ -66,3 +66,3 @@ "use strict";

if (!promise) {
promise = index_js_1.default(request);
promise = (0, index_js_1.default)(request);
}

@@ -78,3 +78,3 @@ return promise;

if (!promise) {
promise = index_js_1.default(request);
promise = (0, index_js_1.default)(request);
}

@@ -81,0 +81,0 @@ if (result !== promise) {

@@ -7,2 +7,3 @@ declare const got: import("./types.js").Got;

export * from './core/response.js';
export type { default as Request } from './core/index.js';
export * from './core/index.js';

@@ -9,0 +10,0 @@ export * from './core/errors.js';

@@ -24,3 +24,3 @@ "use strict";

};
const got = create_js_1.default(defaults);
const got = (0, create_js_1.default)(defaults);
exports.got = got;

@@ -27,0 +27,0 @@ exports.default = got;

/// <reference types="node" />
import type { URL } from 'url';
import type { Buffer } from 'node:buffer';
import type { URL } from 'node:url';
import type { CancelableRequest } from './as-promise/types.js';

@@ -4,0 +5,0 @@ import type { Response } from './core/response.js';

{
"name": "got-cjs",
"version": "12.0.0-beta.4",
"description": "Human-friendly and powerful HTTP request library for Node.js",
"license": "MIT",
"repository": "apify/got-cjs",
"funding": "https://github.com/sindresorhus/got?sponsor=1",
"type": "commonjs",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava",
"release": "np",
"build": "del-cli dist && tsc",
"prepare": "npm run build"
},
"files": [
"dist/source"
],
"keywords": [
"http",
"https",
"http2",
"get",
"got",
"url",
"uri",
"request",
"simple",
"curl",
"wget",
"fetch",
"net",
"network",
"gzip",
"brotli",
"requests",
"human-friendly",
"axios",
"superagent",
"node-fetch",
"ky"
],
"dependencies": {
"@sindresorhus/is": "^4.0.1",
"@szmarczak/http-timer": "^4.0.6",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.0",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
"get-stream": "^6.0.1",
"http2-wrapper": "^2.0.7",
"lowercase-keys": "^2.0.0",
"p-cancelable": "^2.1.1",
"responselike": "^2.0.0"
},
"devDependencies": {
"@hapi/bourne": "^2.0.0",
"@sindresorhus/tsconfig": "^1.0.2",
"@sinonjs/fake-timers": "^6.0.1",
"@types/benchmark": "^2.1.1",
"@types/express": "^4.17.13",
"@types/node": "^14.14.45",
"@types/node-fetch": "^2.5.11",
"@types/pem": "^1.9.6",
"@types/pify": "^5.0.1",
"@types/readable-stream": "^2.3.11",
"@types/request": "^2.48.6",
"@types/sinon": "^9.0.9",
"@types/tough-cookie": "^4.0.1",
"ava": "^3.15.0",
"axios": "^0.21.1",
"benchmark": "^2.1.4",
"body-parser": "^1.19.0",
"create-cert": "^1.0.6",
"create-test-server": "^3.0.1",
"del-cli": "^3.0.1",
"delay": "^5.0.0",
"express": "^4.17.1",
"form-data": "^4.0.0",
"nock": "^13.1.1",
"node-fetch": "^2.6.1",
"np": "^7.5.0",
"nyc": "^15.1.0",
"p-event": "^4.2.0",
"pem": "^1.14.4",
"pify": "^5.0.0",
"readable-stream": "^3.6.0",
"request": "^2.88.2",
"sinon": "^10.0.0",
"slow-stream": "0.0.4",
"tempy": "^1.0.1",
"to-readable-stream": "^3.0.0",
"tough-cookie": "^4.0.0",
"ts-node": "^10.1.0",
"typescript": "4.3.5",
"xo": "^0.41.0"
},
"types": "dist/source",
"sideEffects": false,
"ava": {
"files": [
"test/*"
],
"timeout": "1m",
"nonSemVerExperiments": {
"nextGenConfig": true,
"configurableModuleFormat": true
},
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"nyc": {
"reporter": [
"text",
"html",
"lcov"
],
"extension": [
".ts"
],
"exclude": [
"**/test/**"
]
},
"xo": {
"ignores": [
"documentation/examples/*"
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"node/no-deprecated-api": "off",
"node/prefer-global/url": "off",
"node/prefer-global/url-search-params": "off",
"@typescript-eslint/no-implicit-any-catch": "off",
"unicorn/prefer-node-protocol": "off",
"ava/assertion-arguments": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/await-thenable": "off"
}
},
"runkitExampleFilename": "./documentation/examples/runkit-example.js",
"main": "./dist/source/index.js"
}
"name": "got-cjs",
"version": "12.0.0",
"description": "Human-friendly and powerful HTTP request library for Node.js",
"license": "MIT",
"repository": "sindresorhus/got",
"funding": "https://github.com/sindresorhus/got?sponsor=1",
"type": "commonjs",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava",
"release": "np",
"build": "del-cli dist && tsc",
"prepare": "npm run build"
},
"files": [
"dist/source"
],
"keywords": [
"http",
"https",
"http2",
"get",
"got",
"url",
"uri",
"request",
"simple",
"curl",
"wget",
"fetch",
"net",
"network",
"gzip",
"brotli",
"requests",
"human-friendly",
"axios",
"superagent",
"node-fetch",
"ky"
],
"dependencies": {
"@sindresorhus/is": "^4.2.0",
"@szmarczak/http-timer": "4.0.6",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.4",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
"form-data-encoder": "1.7.1",
"get-stream": "^6.0.1",
"http2-wrapper": "^2.1.9",
"lowercase-keys": "2.0.0",
"p-cancelable": "2.1.1",
"responselike": "^2.0.0"
},
"devDependencies": {
"@hapi/bourne": "^2.0.0",
"@sindresorhus/tsconfig": "^2.0.0",
"@sinonjs/fake-timers": "^8.1.0",
"@types/benchmark": "^2.1.1",
"@types/express": "^4.17.13",
"@types/node": "^16.11.12",
"@types/pem": "^1.9.6",
"@types/pify": "^5.0.1",
"@types/readable-stream": "^2.3.12",
"@types/request": "^2.48.7",
"@types/sinon": "^10.0.6",
"@types/sinonjs__fake-timers": "^8.1.1",
"@types/tough-cookie": "^4.0.1",
"ava": "^3.15.0",
"axios": "^0.24.0",
"benchmark": "^2.1.4",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
"create-cert": "^1.0.6",
"create-test-server": "^3.0.1",
"del-cli": "^4.0.1",
"delay": "^5.0.0",
"express": "^4.17.1",
"form-data": "^4.0.0",
"formdata-node": "^4.3.1",
"nock": "^13.2.1",
"node-fetch": "^3.1.0",
"np": "^7.6.0",
"nyc": "^15.1.0",
"p-event": "^5.0.1",
"pem": "^1.14.4",
"pify": "^5.0.0",
"readable-stream": "^3.6.0",
"request": "^2.88.2",
"sinon": "^12.0.1",
"slow-stream": "0.0.4",
"tempy": "^2.0.0",
"then-busboy": "^5.1.1",
"to-readable-stream": "^3.0.0",
"tough-cookie": "^4.0.0",
"ts-node": "^10.4.0",
"typescript": "4.5.3",
"xo": "^0.47.0"
},
"types": "dist/source",
"sideEffects": false,
"ava": {
"files": [
"test/*"
],
"timeout": "1m",
"nonSemVerExperiments": {
"nextGenConfig": true,
"configurableModuleFormat": true
},
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"nyc": {
"reporter": [
"text",
"html",
"lcov"
],
"extension": [
".ts"
],
"exclude": [
"**/test/**"
]
},
"xo": {
"ignores": [
"documentation/examples/*"
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"node/no-deprecated-api": "off",
"node/prefer-global/url": "off",
"node/prefer-global/url-search-params": "off",
"@typescript-eslint/no-implicit-any-catch": "off",
"unicorn/prefer-node-protocol": "off",
"ava/assertion-arguments": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/await-thenable": "off",
"no-lone-blocks": "off",
"unicorn/no-await-expression-member": "off"
}
},
"runkitExampleFilename": "./documentation/examples/runkit-example.js",
"respository": "apify/got-cjs",
"main": "./dist/source/index.js"
}

@@ -15,8 +15,2 @@ <div align="center">

<br>
<a href="https://moxy.studio">
<img src="https://sindresorhus.com/assets/thanks/moxy-logo.svg" width="160">
</a>
<br>
<br>
<br>
<a href="https://retool.com/?utm_campaign=sindresorhus">

@@ -39,6 +33,20 @@ <img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="210">

<a href="https://www.monito.com">
<img src="https://sindresorhus.com/assets/thanks/monito-logo.svg" width="210">
<div>
<img src="https://sindresorhus.com/assets/thanks/monito-logo.svg" width="210">
</div>
<b>Find the cheapest way to send money abroad</b>
</a>
<br>
<br>
<br>
<a href="https://keygen.sh">
<div>
<img src="https://sindresorhus.com/assets/thanks/keygen-logo.svg" width="180" alt="Keygen">
</div>
<b>A dead-simple software licensing and distribution API built for developers</b>
</a>
<br>
<br>
<br>
<br>
</p>

@@ -53,3 +61,3 @@ <br>

[![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got)
[![Install size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)
[![Install size](https://packagephobia.com/badge?p=got)](https://packagephobia.com/result?p=got)

@@ -157,2 +165,3 @@ [See how Got compares to other HTTP libraries](#comparison)

- [`got-scraping`](https://github.com/apify/got-scraping) - Got wrapper specifically designed for web scraping purposes
- [`got-ssrf`](https://github.com/JaneJeon/got-ssrf) - Got wrapper to protect server-side requests against SSRF attacks

@@ -214,8 +223,8 @@ ### Legacy

<!-- ISSUES OPEN -->
[gio]: https://badgen.net/github/open-issues/sindresorhus/got?label
[kio]: https://badgen.net/github/open-issues/sindresorhus/ky?label
[rio]: https://badgen.net/github/open-issues/request/request?label
[nio]: https://badgen.net/github/open-issues/bitinn/node-fetch?label
[aio]: https://badgen.net/github/open-issues/axios/axios?label
[sio]: https://badgen.net/github/open-issues/visionmedia/superagent?label
[gio]: https://img.shields.io/github/issues-raw/sindresorhus/got?color=gray&label
[kio]: https://img.shields.io/github/issues-raw/sindresorhus/ky?color=gray&label
[rio]: https://img.shields.io/github/issues-raw/request/request?color=gray&label
[nio]: https://img.shields.io/github/issues-raw/bitinn/node-fetch?color=gray&label
[aio]: https://img.shields.io/github/issues-raw/axios/axios?color=gray&label
[sio]: https://img.shields.io/github/issues-raw/visionmedia/superagent?color=gray&label

@@ -230,8 +239,8 @@ [g1]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc

<!-- ISSUES CLOSED -->
[gic]: https://badgen.net/github/closed-issues/sindresorhus/got?label
[kic]: https://badgen.net/github/closed-issues/sindresorhus/ky?label
[ric]: https://badgen.net/github/closed-issues/request/request?label
[nic]: https://badgen.net/github/closed-issues/bitinn/node-fetch?label
[aic]: https://badgen.net/github/closed-issues/axios/axios?label
[sic]: https://badgen.net/github/closed-issues/visionmedia/superagent?label
[gic]: https://img.shields.io/github/issues-closed-raw/sindresorhus/got?color=blue&label
[kic]: https://img.shields.io/github/issues-closed-raw/sindresorhus/ky?color=blue&label
[ric]: https://img.shields.io/github/issues-closed-raw/request/request?color=blue&label
[nic]: https://img.shields.io/github/issues-closed-raw/bitinn/node-fetch?color=blue&label
[aic]: https://img.shields.io/github/issues-closed-raw/axios/axios?color=blue&label
[sic]: https://img.shields.io/github/issues-closed-raw/visionmedia/superagent?color=blue&label

@@ -246,8 +255,8 @@ [g2]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc

<!-- DOWNLOADS -->
[gd]: https://badgen.net/npm/dm/got?label
[kd]: https://badgen.net/npm/dm/ky?label
[rd]: https://badgen.net/npm/dm/request?label
[nd]: https://badgen.net/npm/dm/node-fetch?label
[ad]: https://badgen.net/npm/dm/axios?label
[sd]: https://badgen.net/npm/dm/superagent?label
[gd]: https://img.shields.io/npm/dm/got?color=darkgreen&label
[kd]: https://img.shields.io/npm/dm/ky?color=darkgreen&label
[rd]: https://img.shields.io/npm/dm/request?color=darkgreen&label
[nd]: https://img.shields.io/npm/dm/node-fetch?color=darkgreen&label
[ad]: https://img.shields.io/npm/dm/axios?color=darkgreen&label
[sd]: https://img.shields.io/npm/dm/superagent?color=darkgreen&label

@@ -262,8 +271,8 @@ [g3]: https://www.npmjs.com/package/got

<!-- COVERAGE -->
[gc]: https://badgen.net/coveralls/c/github/sindresorhus/got?label
[kc]: https://badgen.net/codecov/c/github/sindresorhus/ky?label
[rc]: https://badgen.net/coveralls/c/github/request/request?label
[nc]: https://badgen.net/coveralls/c/github/bitinn/node-fetch?label
[ac]: https://badgen.net/coveralls/c/github/mzabriskie/axios?label
[sc]: https://badgen.net/codecov/c/github/visionmedia/superagent?label
[gc]: https://img.shields.io/coveralls/github/sindresorhus/got?color=0b9062&label
[kc]: https://img.shields.io/codecov/c/github/sindresorhus/ky?color=0b9062&label
[rc]: https://img.shields.io/coveralls/github/request/request?color=0b9062&label
[nc]: https://img.shields.io/coveralls/github/bitinn/node-fetch?color=0b9062&label
[ac]: https://img.shields.io/coveralls/github/mzabriskie/axios?color=0b9062&label
[sc]: https://img.shields.io/codecov/c/github/visionmedia/superagent?color=0b9062&label

@@ -280,6 +289,6 @@ [g4]: https://coveralls.io/github/sindresorhus/got

[kb]: https://github.com/sindresorhus/ky/actions/workflows/main.yml/badge.svg
[rb]: https://badgen.net/travis/request/request?label
[nb]: https://badgen.net/travis/bitinn/node-fetch?label
[ab]: https://badgen.net/travis/axios/axios?label
[sb]: https://badgen.net/travis/visionmedia/superagent?label
[rb]: https://img.shields.io/travis/request/request?label
[nb]: https://img.shields.io/travis/bitinn/node-fetch?label
[ab]: https://img.shields.io/travis/axios/axios?label
[sb]: https://img.shields.io/travis/visionmedia/superagent?label

@@ -294,8 +303,8 @@ [g5]: https://github.com/sindresorhus/got/actions/workflows/main.yml

<!-- BUGS -->
[gbg]: https://badgen.net/github/label-issues/sindresorhus/got/bug/open?label
[kbg]: https://badgen.net/github/label-issues/sindresorhus/ky/bug/open?label
[rbg]: https://badgen.net/github/label-issues/request/request/Needs%20investigation/open?label
[nbg]: https://badgen.net/github/label-issues/bitinn/node-fetch/bug/open?label
[abg]: https://badgen.net/github/label-issues/axios/axios/type:confirmed%20bug/open?label
[sbg]: https://badgen.net/github/label-issues/visionmedia/superagent/Bug/open?label
[gbg]: https://img.shields.io/github/issues-raw/sindresorhus/got/bug?color=darkred&label
[kbg]: https://img.shields.io/github/issues-raw/sindresorhus/ky/bug?color=darkred&label
[rbg]: https://img.shields.io/github/issues-raw/request/request/Needs%20investigation?color=darkred&label
[nbg]: https://img.shields.io/github/issues-raw/bitinn/node-fetch/bug?color=darkred&label
[abg]: https://img.shields.io/github/issues-raw/axios/axios/type:confirmed%20bug?color=darkred&label
[sbg]: https://img.shields.io/github/issues-raw/visionmedia/superagent/Bug?color=darkred&label

@@ -310,8 +319,8 @@ [g6]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug

<!-- DEPENDENTS -->
[gdp]: https://badgen.net/npm/dependents/got?label
[kdp]: https://badgen.net/npm/dependents/ky?label
[rdp]: https://badgen.net/npm/dependents/request?label
[ndp]: https://badgen.net/npm/dependents/node-fetch?label
[adp]: https://badgen.net/npm/dependents/axios?label
[sdp]: https://badgen.net/npm/dependents/superagent?label
[gdp]: https://badgen.net/npm/dependents/got?color=orange&label
[kdp]: https://badgen.net/npm/dependents/ky?color=orange&label
[rdp]: https://badgen.net/npm/dependents/request?color=orange&label
[ndp]: https://badgen.net/npm/dependents/node-fetch?color=orange&label
[adp]: https://badgen.net/npm/dependents/axios?color=orange&label
[sdp]: https://badgen.net/npm/dependents/superagent?color=orange&label

@@ -326,23 +335,23 @@ [g7]: https://www.npmjs.com/package/got?activeTab=dependents

<!-- INSTALL SIZE -->
[gis]: https://badgen.net/packagephobia/install/got?label
[kis]: https://badgen.net/packagephobia/install/ky?label
[ris]: https://badgen.net/packagephobia/install/request?label
[nis]: https://badgen.net/packagephobia/install/node-fetch?label
[ais]: https://badgen.net/packagephobia/install/axios?label
[sis]: https://badgen.net/packagephobia/install/superagent?label
[gis]: https://badgen.net/packagephobia/install/got?color=blue&label
[kis]: https://badgen.net/packagephobia/install/ky?color=blue&label
[ris]: https://badgen.net/packagephobia/install/request?color=blue&label
[nis]: https://badgen.net/packagephobia/install/node-fetch?color=blue&label
[ais]: https://badgen.net/packagephobia/install/axios?color=blue&label
[sis]: https://badgen.net/packagephobia/install/superagent?color=blue&label
[g8]: https://packagephobia.now.sh/result?p=got
[k8]: https://packagephobia.now.sh/result?p=ky
[r8]: https://packagephobia.now.sh/result?p=request
[n8]: https://packagephobia.now.sh/result?p=node-fetch
[a8]: https://packagephobia.now.sh/result?p=axios
[s8]: https://packagephobia.now.sh/result?p=superagent
[g8]: https://packagephobia.com/result?p=got
[k8]: https://packagephobia.com/result?p=ky
[r8]: https://packagephobia.com/result?p=request
[n8]: https://packagephobia.com/result?p=node-fetch
[a8]: https://packagephobia.com/result?p=axios
[s8]: https://packagephobia.com/result?p=superagent
<!-- GITHUB STARS -->
[gs]: https://badgen.net/github/stars/sindresorhus/got?label
[ks]: https://badgen.net/github/stars/sindresorhus/ky?label
[rs]: https://badgen.net/github/stars/request/request?label
[ns]: https://badgen.net/github/stars/bitinn/node-fetch?label
[as]: https://badgen.net/github/stars/axios/axios?label
[ss]: https://badgen.net/github/stars/visionmedia/superagent?label
[gs]: https://img.shields.io/github/stars/sindresorhus/got?color=white&label
[ks]: https://img.shields.io/github/stars/sindresorhus/ky?color=white&label
[rs]: https://img.shields.io/github/stars/request/request?color=white&label
[ns]: https://img.shields.io/github/stars/bitinn/node-fetch?color=white&label
[as]: https://img.shields.io/github/stars/axios/axios?color=white&label
[ss]: https://img.shields.io/github/stars/visionmedia/superagent?color=white&label

@@ -372,8 +381,8 @@ [g9]: https://github.com/sindresorhus/got

<!-- LAST COMMIT -->
[glc]: https://badgen.net/github/last-commit/sindresorhus/got?label
[klc]: https://badgen.net/github/last-commit/sindresorhus/ky?label
[rlc]: https://badgen.net/github/last-commit/request/request?label
[nlc]: https://badgen.net/github/last-commit/bitinn/node-fetch?label
[alc]: https://badgen.net/github/last-commit/axios/axios?label
[slc]: https://badgen.net/github/last-commit/visionmedia/superagent?label
[glc]: https://img.shields.io/github/last-commit/sindresorhus/got?color=gray&label
[klc]: https://img.shields.io/github/last-commit/sindresorhus/ky?color=gray&label
[rlc]: https://img.shields.io/github/last-commit/request/request?color=gray&label
[nlc]: https://img.shields.io/github/last-commit/bitinn/node-fetch?color=gray&label
[alc]: https://img.shields.io/github/last-commit/axios/axios?color=gray&label
[slc]: https://img.shields.io/github/last-commit/visionmedia/superagent?color=gray&label

@@ -380,0 +389,0 @@ [g11]: https://github.com/sindresorhus/got/commits

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc