Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Oct 22, 2021
1 parent a560446 commit 3a84454
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 60 deletions.
1 change: 1 addition & 0 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const gotOptions: OptionsInit & {isStream?: true} = {
const normalizedGotOptions = new Options(url, gotOptions);

const requestOptions = {
// eslint-disable-next-line @typescript-eslint/naming-convention
strictSSL: false,
agent: httpsAgent,
};
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,37 @@
"ky"
],
"dependencies": {
"@sindresorhus/is": "^4.0.1",
"@sindresorhus/is": "^4.2.0",
"@szmarczak/http-timer": "^5.0.1",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0",
"cacheable-lookup": "^6.0.1",
"cacheable-lookup": "^6.0.4",
"cacheable-request": "^7.0.2",
"decompress-response": "^6.0.0",
"form-data-encoder": "^1.5.1",
"decompress-response": "^7.0.0",
"form-data-encoder": "^1.6.0",
"get-stream": "^6.0.1",
"http2-wrapper": "^2.1.4",
"lowercase-keys": "^2.0.0",
"http2-wrapper": "^2.1.9",
"lowercase-keys": "^3.0.0",
"p-cancelable": "^3.0.0",
"responselike": "^2.0.0"
},
"devDependencies": {
"@hapi/bourne": "^2.0.0",
"@sindresorhus/tsconfig": "^2.0.0",
"@sinonjs/fake-timers": "^7.1.2",
"@sinonjs/fake-timers": "^8.0.1",
"@types/benchmark": "^2.1.1",
"@types/express": "^4.17.13",
"@types/node": "^16.7.2",
"@types/node-fetch": "^2.5.12",
"@types/node": "^16.11.3",
"@types/node-fetch": "^3.0.3",
"@types/pem": "^1.9.6",
"@types/pify": "^5.0.1",
"@types/readable-stream": "^2.3.11",
"@types/request": "^2.48.7",
"@types/sinon": "^10.0.2",
"@types/sinon": "^10.0.4",
"@types/sinonjs__fake-timers": "^6.0.4",
"@types/tough-cookie": "^4.0.1",
"ava": "^3.15.0",
"axios": "^0.21.1",
"axios": "^0.23.0",
"benchmark": "^2.1.4",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
Expand All @@ -83,9 +84,9 @@
"delay": "^5.0.0",
"express": "^4.17.1",
"form-data": "^4.0.0",
"formdata-node": "^4.0.1",
"nock": "^13.1.3",
"node-fetch": "^2.6.1",
"formdata-node": "^4.3.1",
"nock": "^13.1.4",
"node-fetch": "^2.6.5",
"np": "^7.5.0",
"nyc": "^15.1.0",
"p-event": "^4.2.0",
Expand All @@ -96,12 +97,12 @@
"sinon": "^11.1.2",
"slow-stream": "0.0.4",
"tempy": "^2.0.0",
"then-busboy": "^5.1.0",
"then-busboy": "^5.1.1",
"to-readable-stream": "^3.0.0",
"tough-cookie": "^4.0.0",
"ts-node": "^10.2.1",
"typescript": "4.4.2",
"xo": "^0.44.0"
"ts-node": "^10.3.1",
"typescript": "4.4.4",
"xo": "^0.45.0"
},
"types": "dist/source",
"sideEffects": false,
Expand Down Expand Up @@ -150,7 +151,8 @@
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/await-thenable": "off"
"@typescript-eslint/await-thenable": "off",
"no-lone-blocks": "off"
}
},
"runkitExampleFilename": "./documentation/examples/runkit-example.js"
Expand Down
1 change: 1 addition & 0 deletions source/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class MaxRedirectsError extends RequestError {
An error to be thrown when the server response code is not 2xx nor 3xx if `options.followRedirect` is `true`, but always except for 304.
Includes a `response` property.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export class HTTPError extends RequestError {
declare readonly response: Response;
declare readonly request: Request;
Expand Down
1 change: 1 addition & 0 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
const {headers} = options;

const isForm = !is.undefined(options.form);
// eslint-disable-next-line @typescript-eslint/naming-convention
const isJSON = !is.undefined(options.json);
const isBody = !is.undefined(options.body);
const cannotHaveBody = methodsWithoutBody.has(options.method) && !(options.method === 'GET' && options.allowGetBody);
Expand Down
2 changes: 2 additions & 0 deletions source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,7 @@ export default class Options {
this._internals.maxHeaderSize = value;
}

// eslint-disable-next-line @typescript-eslint/naming-convention
toJSON() {
return {...this._internals};
}
Expand Down Expand Up @@ -2267,6 +2268,7 @@ export default class Options {
...this._unixOptions,

// HTTPS options
// eslint-disable-next-line @typescript-eslint/naming-convention
ALPNProtocols: https.alpnProtocols,
ca: https.certificateAuthority,
cert: https.certificate,
Expand Down
1 change: 1 addition & 0 deletions source/core/utils/options-to-url.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* istanbul ignore file: deprecated */
import {URL} from 'node:url';

// eslint-disable-next-line @typescript-eslint/naming-convention
export interface URLOptions {
href?: string;
protocol?: string;
Expand Down
2 changes: 2 additions & 0 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface ExtendOptions extends OptionsInit {
}

export type OptionsOfTextResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType?: 'text'}>;
// eslint-disable-next-line @typescript-eslint/naming-convention
export type OptionsOfJSONResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType?: 'json'}>;
export type OptionsOfBufferResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false; responseType: 'buffer'}>;
export type OptionsOfUnknownResponseBody = Merge<OptionsInit, {isStream?: false; resolveBodyOnly?: false}>;
Expand Down Expand Up @@ -176,6 +177,7 @@ export interface GotRequestFunction {
/**
All available HTTP request methods provided by Got.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export type HTTPAlias =
| 'get'
| 'post'
Expand Down
16 changes: 8 additions & 8 deletions test/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ test('redirects are cached and re-used internally', withServer, async (t, server
server.get('/', cacheEndpoint);

const cache = new Map();
const A1 = await got('301', {cache});
const B1 = await got('302', {cache});
const a1 = await got('301', {cache});
const b1 = await got('302', {cache});

const A2 = await got('301', {cache});
const B2 = await got('302', {cache});
const a2 = await got('301', {cache});
const b2 = await got('302', {cache});

t.is(cache.size, 3);
t.is(A1.body, B1.body);
t.is(A1.body, A2.body);
t.is(B1.body, B2.body);
t.is(a1.body, b1.body);
t.is(a1.body, a2.body);
t.is(b1.body, b2.body);
});

test('cached response has got options', withServer, async (t, server, got) => {
Expand Down Expand Up @@ -327,7 +327,7 @@ test('cached response ETag', withServer, async (t, server, got) => {
response.writeHead(304);
response.end();
} else {
response.writeHead(200, {ETag: etag});
response.writeHead(200, {etag});
response.end(body);
}
});
Expand Down
1 change: 1 addition & 0 deletions test/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ test.skip('the old stacktrace is recovered', async t => {
});

test.serial('custom stack trace', withServer, async (t, _server, got) => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const ErrorCaptureStackTrace = Error.captureStackTrace;

const enable = () => {
Expand Down
14 changes: 7 additions & 7 deletions test/helpers/create-https-test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ export interface ExtendedHttpsTestServer extends express.Express {
}

const createHttpsTestServer = async (options: HttpsServerOptions = {}): Promise<ExtendedHttpsTestServer> => {
const createCSR = pify(pem.createCSR);
const createCsr = pify(pem.createCSR);
const createCertificate = pify(pem.createCertificate);

const caCSRResult = await createCSR({commonName: 'authority'});
const caCsrResult = await createCsr({commonName: 'authority'});
const caResult = await createCertificate({
csr: caCSRResult.csr,
clientKey: caCSRResult.clientKey,
csr: caCsrResult.csr,
clientKey: caCsrResult.clientKey,
selfSigned: true,
});
const caKey = caResult.clientKey;
const caCert = caResult.certificate;

const serverCSRResult = await createCSR({commonName: options.commonName ?? 'localhost'});
const serverCsrResult = await createCsr({commonName: options.commonName ?? 'localhost'});
const serverResult = await createCertificate({
csr: serverCSRResult.csr,
clientKey: serverCSRResult.clientKey,
csr: serverCsrResult.csr,
clientKey: serverCsrResult.clientKey,
serviceKey: caKey,
serviceCertificate: caCert,
days: options.days ?? 365,
Expand Down
2 changes: 2 additions & 0 deletions test/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import pEvent from 'p-event';
import got, {HTTPError, ReadError, RequestError} from '../source/index.js';
import withServer from './helpers/with-server.js';

// eslint-disable-next-line @typescript-eslint/naming-convention
const IPv6supported = Object.values(os.networkInterfaces()).some(iface => iface?.some(addr => !addr.internal && addr.family === 'IPv6'));

// eslint-disable-next-line @typescript-eslint/naming-convention
const testIPv6 = (IPv6supported && process.env.TRAVIS_DIST !== 'bionic' && process.env.TRAVIS_DIST !== 'focal') ? test : test.skip;

const echoIp: Handler = (request, response) => {
Expand Down
44 changes: 22 additions & 22 deletions test/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import got from '../source/index.js';
import {withHttpsServer} from './helpers/with-server.js';

const createPrivateKey = pify(pem.createPrivateKey);
const createCSR = pify(pem.createCSR);
const createCsr = pify(pem.createCSR);
const createCertificate = pify(pem.createCertificate);
const createPkcs12 = pify(pem.createPkcs12);

Expand Down Expand Up @@ -205,10 +205,10 @@ test('client certificate', withHttpsServer(), async (t, server, got) => {
});
});

const clientCSRResult = await createCSR({commonName: 'client'});
const clientCsrResult = await createCsr({commonName: 'client'});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
serviceKey: (server as any).caKey,
serviceCertificate: (server as any).caCert,
});
Expand Down Expand Up @@ -245,10 +245,10 @@ test('invalid client certificate (self-signed)', withHttpsServer(), async (t, se
});
});

const clientCSRResult = await createCSR({commonName: 'other-client'});
const clientCsrResult = await createCsr({commonName: 'other-client'});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
selfSigned: true,
});
// eslint-disable-next-line prefer-destructuring
Expand Down Expand Up @@ -277,19 +277,19 @@ test('invalid client certificate (other CA)', withHttpsServer(), async (t, serve
});
});

const caCSRResult = await createCSR({commonName: 'other-authority'});
const caCsrResult = await createCsr({commonName: 'other-authority'});
const caResult = await createCertificate({
csr: caCSRResult.csr,
clientKey: caCSRResult.clientKey,
csr: caCsrResult.csr,
clientKey: caCsrResult.clientKey,
selfSigned: true,
});
const caKey = caResult.clientKey;
const caCert = caResult.certificate;

const clientCSRResult = await createCSR({commonName: 'other-client'});
const clientCsrResult = await createCsr({commonName: 'other-client'});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
serviceKey: caKey,
serviceCertificate: caCert,
});
Expand Down Expand Up @@ -336,15 +336,15 @@ test('key passphrase', withHttpsServer(), async (t, server, got) => {
cipher: 'aes256',
password: 'randomPassword',
});
const clientCSRResult = await createCSR({
const clientCsrResult = await createCsr({
// eslint-disable-next-line object-shorthand
clientKey: clientKey,
clientKeyPassword: 'randomPassword',
commonName: 'client',
});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
clientKeyPassword: 'randomPassword',
serviceKey: (server as any).caKey,
serviceCertificate: (server as any).caCert,
Expand Down Expand Up @@ -391,15 +391,15 @@ test('invalid key passphrase', withHttpsServer(), async (t, server, got) => {
cipher: 'aes256',
password: 'randomPassword',
});
const clientCSRResult = await createCSR({
const clientCsrResult = await createCsr({
// eslint-disable-next-line object-shorthand
clientKey: clientKey,
clientKeyPassword: 'randomPassword',
commonName: 'client',
});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
clientKeyPassword: 'randomPassword',
serviceKey: (server as any).caKey,
serviceCertificate: (server as any).caCert,
Expand Down Expand Up @@ -430,10 +430,10 @@ test('client certificate PFX', withHttpsServer(), async (t, server, got) => {
});
});

const clientCSRResult = await createCSR({commonName: 'client'});
const clientCsrResult = await createCsr({commonName: 'client'});
const clientResult = await createCertificate({
csr: clientCSRResult.csr,
clientKey: clientCSRResult.clientKey,
csr: clientCsrResult.csr,
clientKey: clientCsrResult.clientKey,
serviceKey: (server as any).caKey,
serviceCertificate: (server as any).caCert,
});
Expand Down
9 changes: 5 additions & 4 deletions test/url-to-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ test('converts URL to options', t => {
});

test('converts IPv6 URL to options', t => {
const IPv6URL = 'https://[2001:cdba::3257:9652]:443/';
const parsedUrl = new URL(IPv6URL);
// eslint-disable-next-line @typescript-eslint/naming-convention
const IPv6Url = 'https://[2001:cdba::3257:9652]:443/';
const parsedUrl = new URL(IPv6Url);
const options = urlToOptions(parsedUrl);
const expected = {
hash: '',
Expand All @@ -59,8 +60,8 @@ test('converts IPv6 URL to options', t => {
});

test('only adds port to options for URLs with ports', t => {
const noPortURL = 'https://github.com/';
const parsedUrl = new URL(noPortURL);
const noPortUrl = 'https://github.com/';
const parsedUrl = new URL(noPortUrl);
const options = urlToOptions(parsedUrl);
const expected = {
hash: '',
Expand Down

0 comments on commit 3a84454

Please sign in to comment.