Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

got

Package Overview
Dependencies
Maintainers
2
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 12.1.0 to 12.2.0

6

dist/source/core/errors.d.ts

@@ -84,2 +84,8 @@ /// <reference types="node" />

}
/**
An error to be thrown when the request is aborted by AbortController.
*/
export declare class AbortError extends RequestError {
constructor(request: Request);
}
export {};

@@ -169,1 +169,11 @@ import is from '@sindresorhus/is';

}
/**
An error to be thrown when the request is aborted by AbortController.
*/
export class AbortError extends RequestError {
constructor(request) {
super('This operation was aborted.', {}, request);
this.code = 'ERR_ABORTED';
this.name = 'AbortError';
}
}
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { Duplex } from 'node:stream';

@@ -29,2 +34,4 @@ import { URL } from 'node:url';

```
import got from 'got';
got.stream('https://github.com')

@@ -59,2 +66,4 @@ .on('request', request => setTimeout(() => request.destroy(), 50));

```
import got from 'got';
const response = await got('https://sindresorhus.com')

@@ -61,0 +70,0 @@ .on('downloadProgress', progress => {

11

dist/source/core/index.js

@@ -11,3 +11,3 @@ import process from 'node:process';

import { buffer as getBuffer } from 'get-stream';
import { FormDataEncoder, isFormDataLike } from 'form-data-encoder';
import { FormDataEncoder, isFormData as isFormDataLike } from 'form-data-encoder';
import getBodySize from './utils/get-body-size.js';

@@ -24,3 +24,3 @@ import isFormData from './utils/is-form-data.js';

import isUnixSocketURL from './utils/is-unix-socket-url.js';
import { RequestError, ReadError, MaxRedirectsError, HTTPError, TimeoutError, UploadError, CacheError, } from './errors.js';
import { RequestError, ReadError, MaxRedirectsError, HTTPError, TimeoutError, UploadError, CacheError, AbortError, } from './errors.js';
const supportsBrotli = is.string(process.versions.brotli);

@@ -46,2 +46,3 @@ const methodsWithoutBody = new Set(['GET', 'HEAD']);

});
// @ts-expect-error - Ignoring for now.
Object.defineProperty(this, 'constructor', {

@@ -239,2 +240,8 @@ enumerable: true,

}
if (this.options.signal?.aborted) {
this.destroy(new AbortError(this));
}
this.options.signal?.addEventListener('abort', () => {
this.destroy(new AbortError(this));
});
// Important! If you replace `body` in a handler with another stream, make sure it's readable first.

@@ -241,0 +248,0 @@ // The below is run only once.

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { Buffer } from 'node:buffer';

@@ -734,2 +742,24 @@ import { URL, URLSearchParams } from 'node:url';

/**
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
*Requires Node.js 16 or later.*
@example
```
import got from 'got';
const abortController = new AbortController();
const request = got('https://httpbin.org/anything', {
signal: abortController.signal
});
setTimeout(() => {
abortController.abort();
}, 100);
```
*/
get signal(): any | undefined;
set signal(value: any | undefined);
/**
Ignore invalid cookies instead of throwing an error.

@@ -1100,2 +1130,4 @@ Only useful when the `cookieJar` option has been set. Not recommended.

set maxHeaderSize(value: number | undefined);
get enableUnixSockets(): boolean;
set enableUnixSockets(value: boolean);
toJSON(): {

@@ -1117,2 +1149,3 @@ headers: Headers;

cookieJar: PromiseCookieJar | ToughCookieJar | undefined;
signal: any;
ignoreInvalidCookies: boolean;

@@ -1153,2 +1186,3 @@ searchParams: string | SearchParameters | URLSearchParams | undefined;

maxHeaderSize: number | undefined;
enableUnixSockets: boolean;
};

@@ -1155,0 +1189,0 @@ createNativeRequestOptions(): {

@@ -12,5 +12,5 @@ import process from 'node:process';

import http2wrapper from 'http2-wrapper';
import { isFormDataLike } from 'form-data-encoder';
import { isFormData } from 'form-data-encoder';
import parseLinkHeader from './parse-link-header.js';
const [major, minor] = process.versions.node.split('.').map(v => Number(v));
const [major, minor] = process.versions.node.split('.').map(Number);
function validateSearchParameters(searchParameters) {

@@ -184,2 +184,4 @@ // eslint-disable-next-line guard-for-in

maxHeaderSize: undefined,
signal: undefined,
enableUnixSockets: true,
};

@@ -612,3 +614,3 @@ const cloneInternals = (internals) => {

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

@@ -715,2 +717,5 @@ assert.truthy(value.readable);

if (url.hostname === 'unix') {
if (!this._internals.enableUnixSockets) {
throw new Error('Using UNIX domain sockets but option `enableUnixSockets` is not enabled');
}
const matches = /(?<socketPath>.+?):(?<path>.+)/.exec(`${url.pathname}${url.search}`);

@@ -763,2 +768,31 @@ if (matches?.groups) {

/**
You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
*Requires Node.js 16 or later.*
@example
```
import got from 'got';
const abortController = new AbortController();
const request = got('https://httpbin.org/anything', {
signal: abortController.signal
});
setTimeout(() => {
abortController.abort();
}, 100);
```
*/
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
get signal() {
return this._internals.signal;
}
// TODO: Replace `any` with `AbortSignal` when targeting Node 16.
set signal(value) {
assert.object(value);
this._internals.signal = value;
}
/**
Ignore invalid cookies instead of throwing an error.

@@ -1506,2 +1540,9 @@ Only useful when the `cookieJar` option has been set. Not recommended.

}
get enableUnixSockets() {
return this._internals.enableUnixSockets;
}
set enableUnixSockets(value) {
assert.boolean(value);
this._internals.enableUnixSockets = value;
}
// eslint-disable-next-line @typescript-eslint/naming-convention

@@ -1615,3 +1656,4 @@ toJSON() {

Object.freeze(options.context);
Object.freeze(options.signal);
}
}

3

dist/source/core/response.d.ts
/// <reference types="node" />
/// <reference types="node" />
import type { Buffer } from 'node:buffer';

@@ -109,2 +110,2 @@ import type { URL } from 'node:url';

}
export declare const parseBody: (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding | undefined) => unknown;
export declare const parseBody: (response: Response, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: BufferEncoding) => unknown;

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

export * from './core/errors.js';
export { Delays } from './core/timed-out.js';
export type { Delays } from './core/timed-out.js';
export { default as calculateRetryDelay } from './core/calculate-retry-delay.js';

@@ -13,0 +13,0 @@ export * from './as-promise/types.js';

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

@@ -112,2 +113,4 @@ import type { URL } from 'node:url';

```
import got from 'got';
const countLimit = 10;

@@ -134,2 +137,4 @@

```
import got from 'got';
const countLimit = 10;

@@ -208,2 +213,4 @@

```
import got from 'got';
const countLimit = 10;

@@ -240,2 +247,4 @@

```
import got from 'got';
const client = got.extend({

@@ -242,0 +251,0 @@ prefixUrl: 'https://example.com',

{
"name": "got",
"version": "12.1.0",
"version": "12.2.0",
"description": "Human-friendly and powerful HTTP request library for Node.js",

@@ -10,2 +10,3 @@ "license": "MIT",

"exports": "./dist/source/index.js",
"types": "./dist/source/index.d.ts",
"engines": {

@@ -48,3 +49,3 @@ "node": ">=14.16"

"dependencies": {
"@sindresorhus/is": "^4.6.0",
"@sindresorhus/is": "^5.2.0",
"@szmarczak/http-timer": "^5.0.1",

@@ -56,3 +57,3 @@ "@types/cacheable-request": "^6.0.2",

"decompress-response": "^6.0.0",
"form-data-encoder": "1.7.1",
"form-data-encoder": "^2.0.1",
"get-stream": "^6.0.1",

@@ -65,3 +66,3 @@ "http2-wrapper": "^2.1.10",

"devDependencies": {
"@hapi/bourne": "^2.0.0",
"@hapi/bourne": "^3.0.0",
"@sindresorhus/tsconfig": "^2.0.0",

@@ -71,3 +72,3 @@ "@sinonjs/fake-timers": "^9.1.1",

"@types/express": "^4.17.13",
"@types/node": "^17.0.21",
"@types/node": "^18.0.1",
"@types/pem": "^1.9.6",

@@ -81,3 +82,3 @@ "@types/pify": "^5.0.1",

"ava": "^3.15.0",
"axios": "^0.26.1",
"axios": "^0.27.2",
"benchmark": "^2.1.4",

@@ -99,16 +100,15 @@ "bluebird": "^3.7.2",

"pem": "^1.14.6",
"pify": "^5.0.0",
"readable-stream": "^3.6.0",
"pify": "^6.0.0",
"readable-stream": "^4.0.0",
"request": "^2.88.2",
"sinon": "^13.0.1",
"sinon": "^14.0.0",
"slow-stream": "0.0.4",
"tempy": "^2.0.0",
"tempy": "^3.0.0",
"then-busboy": "^5.1.1",
"to-readable-stream": "^3.0.0",
"tough-cookie": "^4.0.0",
"ts-node": "^10.7.0",
"typescript": "4.6.2",
"xo": "^0.48.0"
"ts-node": "^10.8.2",
"typescript": "^4.7.4",
"xo": "^0.50.0"
},
"types": "dist/source",
"sideEffects": false,

@@ -150,5 +150,5 @@ "ava": {

"@typescript-eslint/no-empty-function": "off",
"node/no-deprecated-api": "off",
"node/prefer-global/url": "off",
"node/prefer-global/url-search-params": "off",
"n/no-deprecated-api": "off",
"n/prefer-global/url": "off",
"n/prefer-global/url-search-params": "off",
"@typescript-eslint/no-implicit-any-catch": "off",

@@ -162,2 +162,3 @@ "unicorn/prefer-node-protocol": "off",

"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"no-lone-blocks": "off",

@@ -164,0 +165,0 @@ "unicorn/no-await-expression-member": "off"

@@ -143,3 +143,3 @@ <div align="center">

**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. You can also use [Got v11](https://github.com/sindresorhus/got/tree/v11.8.3) instead which is pretty stable.
**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM. You can also use [Got v11](https://github.com/sindresorhus/got/tree/v11.8.3) instead which is pretty stable. We will backport security fixes to v11 for the foreseeable future.

@@ -172,3 +172,3 @@ ## Take a peek

- [Used by 6K+ packages and 3M+ repos](https://github.com/sindresorhus/got/network/dependents)
- [Used by 8K+ packages and 4M+ repos](https://github.com/sindresorhus/got/network/dependents)
- [Actively maintained](https://github.com/sindresorhus/got/graphs/contributors)

@@ -207,3 +207,3 @@ - [Trusted by many companies](#widely-used)

- [x] [Proxy support](documentation/tips.md#proxying)
- [x] [Unix Domain Sockets](documentation/tips.md#unix)
- [x] [Unix Domain Sockets](documentation/2-options.md#enableunixsockets)

@@ -210,0 +210,0 @@ #### Integration

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