Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
2
Versions
176
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 11.2.0 to 11.3.0

dist/source/core/utils/dns-ip-version.d.ts

4

dist/source/as-promise/core.d.ts
/// <reference types="node" />
import { URL } from 'url';
import { Options, NormalizedOptions, Defaults, ResponseType, Response } from './types';
import Request from '../core';
import Request, { ParseJsonFunction } from '../core';
export declare const knownBodyTypes: string[];
export declare const parseBody: (response: Response<unknown>, responseType: ResponseType, encoding?: string | undefined) => unknown;
export declare const parseBody: (response: Response<unknown>, responseType: ResponseType, parseJson: ParseJsonFunction, encoding?: string | undefined) => unknown;
export default class PromisableRequest extends Request {

@@ -8,0 +8,0 @@ ['constructor']: typeof PromisableRequest;

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

// @ts-ignore The error is: Not all code paths return a value.
exports.parseBody = (response, responseType, encoding) => {
exports.parseBody = (response, responseType, parseJson, encoding) => {
const { rawBody } = response;

@@ -19,3 +19,3 @@ try {

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

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

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

try {
response.body = core_1.parseBody(response, options.responseType, options.encoding);
response.body = core_1.parseBody(response, options.responseType, options.parseJson, options.encoding);
}

@@ -207,3 +207,3 @@ catch (error) {

await promise;
return core_1.parseBody(globalResponse, responseType, options.encoding);
return core_1.parseBody(globalResponse, responseType, options.parseJson, options.encoding);
})();

@@ -210,0 +210,0 @@ Object.defineProperties(newPromise, Object.getOwnPropertyDescriptors(promise));

@@ -15,2 +15,3 @@ /// <reference types="node" />

import { URLOptions } from './utils/options-to-url';
import { DnsLookupIpVersion } from './utils/dns-ip-version';
declare type HttpRequestFunction = typeof httpRequest;

@@ -73,3 +74,5 @@ declare type Error = NodeJS.ErrnoException;

export declare type Headers = Record<string, string | string[] | undefined>;
declare type CheckServerIdentityFn = (hostname: string, certificate: DetailedPeerCertificate) => Error | void;
declare type CheckServerIdentityFunction = (hostname: string, certificate: DetailedPeerCertificate) => Error | void;
export declare type ParseJsonFunction = (text: string) => unknown;
export declare type StringifyJsonFunction = (object: unknown) => string;
export interface Options extends URLOptions {

@@ -108,2 +111,5 @@ request?: RequestFunction;

methodRewriting?: boolean;
dnsLookupIpVersion?: DnsLookupIpVersion;
parseJson?: ParseJsonFunction;
stringifyJson?: StringifyJsonFunction;
localAddress?: string;

@@ -118,3 +124,3 @@ socketPath?: string;

rejectUnauthorized?: https.RequestOptions['rejectUnauthorized'];
checkServerIdentity?: CheckServerIdentityFn;
checkServerIdentity?: CheckServerIdentityFunction;
certificateAuthority?: SecureContextOptions['ca'];

@@ -149,2 +155,4 @@ key?: SecureContextOptions['key'];

password: string;
parseJson: ParseJsonFunction;
stringifyJson: StringifyJsonFunction;
[kRequest]: HttpRequestFunction;

@@ -172,2 +180,4 @@ [kIsNormalizedAlready]?: boolean;

methodRewriting: boolean;
parseJson: ParseJsonFunction;
stringifyJson: StringifyJsonFunction;
agent?: Agents | false;

@@ -174,0 +184,0 @@ request?: RequestFunction;

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

const weakable_map_1 = require("./utils/weakable-map");
const dns_ip_version_1 = require("./utils/dns-ip-version");
const deprecation_warning_1 = require("../utils/deprecation-warning");

@@ -337,2 +338,3 @@ const kRequest = Symbol('request');

is_1.assert.any([is_1.default.string, is_1.default.undefined], options.localAddress);
is_1.assert.any([dns_ip_version_1.isDnsLookupIpVersion, is_1.default.undefined], options.dnsLookupIpVersion);
is_1.assert.any([is_1.default.object, is_1.default.undefined], options.https);

@@ -528,3 +530,10 @@ is_1.assert.any([is_1.default.boolean, is_1.default.undefined], options.rejectUnauthorized);

}
// DNS options
if ('family' in options) {
deprecation_warning_1.default('"options.family" was never documented, please use "options.dnsLookupIpVersion"');
}
// HTTPS options
if (defaults === null || defaults === void 0 ? void 0 : defaults.https) {
options.https = { ...defaults.https, ...options.https };
}
if ('rejectUnauthorized' in options) {

@@ -621,3 +630,3 @@ deprecation_warning_1.default('"options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"');

}
this[kBody] = JSON.stringify(options.json);
this[kBody] = options.stringifyJson(options.json);
}

@@ -946,2 +955,11 @@ const uploadBodySize = await get_body_size_1.default(this[kBody], options.headers);

const requestOptions = options;
// If `dnsLookupIpVersion` is not present do not override `family`
if (options.dnsLookupIpVersion !== undefined) {
try {
requestOptions.family = dns_ip_version_1.dnsLookupIpVersionToFamily(options.dnsLookupIpVersion);
}
catch (_b) {
throw new Error('Invalid `dnsLookupIpVersion` option value');
}
}
// HTTPS options remapping

@@ -948,0 +966,0 @@ if (options.https) {

@@ -109,3 +109,5 @@ "use strict";

stackAllItems: true
}
},
parseJson: (text) => JSON.parse(text),
stringifyJson: (object) => JSON.stringify(object)
},

@@ -112,0 +114,0 @@ handlers: [create_1.defaultHandler],

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

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is too big to display

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