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.1 to 12.0.4

2

dist/source/core/index.d.ts

@@ -124,4 +124,2 @@ /// <reference types="node" />

unpipe<T extends NodeJS.WritableStream>(destination: T): this;
private _lockWrite;
private _unlockWrite;
private _finalizeBody;

@@ -128,0 +126,0 @@ private _onResponseBase;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -228,20 +232,2 @@ if (k2 === undefined) k2 = k;

this._stopRetry = noop;
const unlockWrite = () => {
this._unlockWrite();
};
const lockWrite = () => {
this._lockWrite();
};
this.on('pipe', (source) => {
source.prependListener('data', unlockWrite);
source.on('data', lockWrite);
source.prependListener('end', unlockWrite);
source.on('end', lockWrite);
});
this.on('unpipe', (source) => {
source.off('data', unlockWrite);
source.off('data', lockWrite);
source.off('end', unlockWrite);
source.off('end', lockWrite);
});
this.on('pipe', source => {

@@ -278,8 +264,5 @@ if (source.headers) {

}
const { json, body, form } = this.options;
if (json || body || form) {
this._lockWrite();
}
// Important! If you replace `body` in a handler with another stream, make sure it's readable first.
// The below is run only once.
const { body } = this.options;
if (is_1.default.nodeStream(body)) {

@@ -441,3 +424,3 @@ body.once('error', error => {

while ((data = response.read()) !== null) {
this._downloadedSize += data.length;
this._downloadedSize += data.length; // eslint-disable-line @typescript-eslint/restrict-plus-operands
const progress = this.downloadProgress;

@@ -525,13 +508,2 @@ if (progress.percent < 1) {

}
_lockWrite() {
const onLockedWrite = () => {
throw new TypeError('The payload has been already provided');
};
this.write = onLockedWrite;
this.end = onLockedWrite;
}
_unlockWrite() {
this.write = super.write;
this.end = super.end;
}
async _finalizeBody() {

@@ -597,8 +569,2 @@ const { options } = this;

}
else if (cannotHaveBody) {
this._lockWrite();
}
else {
this._unlockWrite();
}
if (options.responseType === 'json' && !('accept' in options.headers)) {

@@ -866,14 +832,9 @@ options.headers.accept = 'application/json';

}
else {
this._unlockWrite();
if (!is_1.default.undefined(body)) {
this._writeRequest(body, undefined, () => { });
currentRequest.end();
this._lockWrite();
}
else if (this._cannotHaveBody || this._noPipe) {
currentRequest.end();
this._lockWrite();
}
else if (!is_1.default.undefined(body)) {
this._writeRequest(body, undefined, () => { });
currentRequest.end();
}
else if (this._cannotHaveBody || this._noPipe) {
currentRequest.end();
}
}

@@ -1159,3 +1120,2 @@ _prepareCache(cache) {

var _a;
// @ts-expect-error `@types/node` has incomplete types
return (_a = this._request) === null || _a === void 0 ? void 0 : _a.reusedSocket;

@@ -1162,0 +1122,0 @@ }

19

dist/source/core/options.d.ts

@@ -5,3 +5,4 @@ /// <reference types="node" />

import { checkServerIdentity } from 'tls';
import { request as httpsRequest } from 'https';
import http from 'http';
import https from 'https';
import type { Readable } from 'stream';

@@ -704,4 +705,4 @@ import type { Socket } from 'net';

*/
get json(): Record<string, any> | undefined;
set json(value: Record<string, any> | undefined);
get json(): unknown;
set json(value: unknown);
/**

@@ -1106,3 +1107,3 @@ The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).

password: string;
json: Record<string, any> | undefined;
json: unknown;
retry: Partial<RetryOptions>;

@@ -1157,3 +1158,3 @@ agent: Agents;

cert: string | Buffer | (string | Buffer)[] | undefined;
key: string | Buffer | (Buffer | import("tls").KeyObject)[] | undefined;
key: string | Buffer | (string | Buffer | import("tls").KeyObject)[] | undefined;
passphrase: string | undefined;

@@ -1181,3 +1182,3 @@ pfx: PfxType;

family: DnsLookupIpVersion;
agent: false | Agents | HttpAgent | undefined;
agent: false | Agents | http.Agent | undefined;
setHost: boolean;

@@ -1200,3 +1201,3 @@ method: Method;

auth?: string | null | undefined;
_defaultAgent?: HttpAgent | undefined;
_defaultAgent?: http.Agent | undefined;
clientCertEngine?: string | undefined;

@@ -1215,6 +1216,6 @@ privateKeyEngine?: string | undefined;

};
getRequestFunction(): RequestFunction | typeof httpsRequest | undefined;
getFallbackRequestFunction(): RequestFunction | typeof httpsRequest | undefined;
getRequestFunction(): RequestFunction | typeof https.request | undefined;
getFallbackRequestFunction(): RequestFunction | typeof https.request | undefined;
freeze(): void;
}
export {};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -29,4 +33,5 @@ if (k2 === undefined) k2 = k;

const tls_1 = require("tls");
const http_1 = require("http");
const https_1 = require("https");
// DO NOT use destructuring for `https.request` and `http.request` as it's not compatible with `nock`.
const http_1 = __importDefault(require("http"));
const https_1 = __importDefault(require("https"));
const is_1 = __importStar(require("@sindresorhus/is"));

@@ -178,3 +183,3 @@ const lowercase_keys_1 = __importDefault(require("lowercase-keys"));

pagination: {
transform: (response) => {
transform(response) {
if (response.request.options.responseType === 'json') {

@@ -185,3 +190,3 @@ return response.body;

},
paginate: ({ response }) => {
paginate({ response }) {
const rawLinkHeader = response.headers.link;

@@ -679,3 +684,2 @@ if (typeof rawLinkHeader !== 'string' || rawLinkHeader.trim() === '') {

set json(value) {
is_1.assert.any([is_1.default.object, is_1.default.undefined], value);
if (value !== undefined) {

@@ -1616,5 +1620,5 @@ is_1.assert.undefined(this._internals.body);

}
return https_1.request;
return https_1.default.request;
}
return http_1.request;
return http_1.default.request;
}

@@ -1621,0 +1625,0 @@ freeze() {

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

if (responseType === 'json') {
return rawBody.length === 0 ? '' : parseJson(rawBody.toString());
return rawBody.length === 0 ? '' : parseJson(rawBody.toString(encoding));
}

@@ -34,0 +34,0 @@ if (responseType === 'buffer') {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

{
"name": "got-cjs",
"version": "12.0.1",
"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"
}
"name": "got-cjs",
"version": "12.0.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.6.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.10",
"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": "^9.1.1",
"@types/benchmark": "^2.1.1",
"@types/express": "^4.17.13",
"@types/node": "^17.0.21",
"@types/pem": "^1.9.6",
"@types/pify": "^5.0.1",
"@types/readable-stream": "^2.3.13",
"@types/request": "^2.48.8",
"@types/sinon": "^10.0.11",
"@types/sinonjs__fake-timers": "^8.1.1",
"@types/tough-cookie": "^4.0.1",
"ava": "^3.15.0",
"axios": "^0.26.1",
"benchmark": "^2.1.4",
"bluebird": "^3.7.2",
"body-parser": "^1.19.2",
"create-cert": "^1.0.6",
"create-test-server": "^3.0.1",
"del-cli": "^4.0.1",
"delay": "^5.0.0",
"express": "^4.17.3",
"form-data": "^4.0.0",
"formdata-node": "^4.3.2",
"nock": "^13.2.4",
"node-fetch": "^3.2.3",
"np": "^7.6.0",
"nyc": "^15.1.0",
"p-event": "^5.0.1",
"pem": "^1.14.6",
"pify": "^5.0.0",
"readable-stream": "^3.6.0",
"request": "^2.88.2",
"sinon": "^13.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.7.0",
"typescript": "4.6.2",
"xo": "^0.48.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",
"main": "./dist/source/index.js"
}

@@ -73,6 +73,8 @@ <div align="center">

```sh
npm install got
```
$ npm install got
```
**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.
## Take a peek

@@ -79,0 +81,0 @@

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