New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fetch-h2

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-h2 - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

dist/test/fetch-h2/headers.d.ts

4

dist/index.d.ts

@@ -6,3 +6,3 @@ import { AbortController, AbortSignal } from "./lib/abort";

import { CookieJar } from "./lib/cookie-jar";
import { AbortError, DecodeFunction, Decoder, FetchInit, HttpProtocols, OnTrailers, TimeoutError } from "./lib/core";
import { AbortError, DecodeFunction, Decoder, FetchInit, HttpProtocols, Method, OnTrailers, TimeoutError } from "./lib/core";
import { Headers } from "./lib/headers";

@@ -23,2 +23,2 @@ import { Request } from "./lib/request";

};
export { setup, context, fetch, disconnect, disconnectAll, onPush, AbortController, AbortSignal, HttpProtocols, Body, JsonBody, StreamBody, DataBody, Headers, Request, Response, AbortError, TimeoutError, OnTrailers, ContextOptions, DecodeFunction, Decoder, CookieJar, };
export { setup, context, fetch, disconnect, disconnectAll, onPush, AbortController, AbortSignal, HttpProtocols, Body, JsonBody, StreamBody, DataBody, Headers, Request, Response, AbortError, TimeoutError, OnTrailers, ContextOptions, DecodeFunction, Decoder, CookieJar, Method, };

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

protected setBody(body: BodyTypes | IBody | null, mime?: string | null, integrity?: string | null, length?: number | null): void;
private awaitBuffer;
private validateIntegrity;

@@ -23,0 +24,0 @@ private _ensureNotAborted;

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

const core_1 = require("./core");
const abortError = new core_1.AbortError("Response aborted");
function makeUnknownDataError() {

@@ -45,3 +46,3 @@ return new Error("Unknown body data");

else if (isStream(this._body))
return get_stream_1.default.buffer(this._body)
return this.awaitBuffer(this._body)
.then(buffer => this.validateIntegrity(buffer, allowIncomplete))

@@ -64,3 +65,3 @@ .then(buffer => toArrayBuffer(buffer));

else if (isStream(this._body))
return get_stream_1.default.buffer(this._body)
return this.awaitBuffer(this._body)
.then(already_1.tap(buffer => this.validateIntegrity(buffer, false)))

@@ -82,3 +83,3 @@ .then(buffer => JSON.parse(buffer.toString()));

else if (isStream(this._body))
return get_stream_1.default.buffer(this._body)
return this.awaitBuffer(this._body)
.then(already_1.tap(buffer => this.validateIntegrity(buffer, allowIncomplete)))

@@ -141,2 +142,26 @@ .then(buffer => buffer.toString());

}
async awaitBuffer(readable) {
if (!this._signal)
return get_stream_1.default.buffer(readable);
// Race the readable against the abort signal
let callback = () => { };
const onAborted = new Promise((_, reject) => {
var _a;
callback = () => { reject(abortError); };
(_a = this._signal) === null || _a === void 0 ? void 0 : _a.addListener('abort', callback);
});
try {
this._ensureNotAborted();
return await Promise.race([
get_stream_1.default.buffer(readable),
onAborted,
]);
}
finally {
this._signal.removeListener('abort', callback);
// Could happen if abort and other error happen practically
// simultaneously. Ensure Node.js won't get mad about this.
onAborted.catch(() => { });
}
}
validateIntegrity(data, allowIncomplete) {

@@ -165,3 +190,3 @@ this._ensureNotAborted();

if (this._signal && this._signal.aborted)
throw new core_1.AbortError("Response aborted");
throw abortError;
}

@@ -168,0 +193,0 @@ _ensureUnused() {

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

export declare const version = "2.2.2";
export declare const version = "2.3.0";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "2.2.2";
exports.version = "2.3.0";
//# sourceMappingURL=version.js.map

@@ -9,2 +9,4 @@ export declare type GuardTypes = "immutable" | "request" | "request-no-cors" | "response" | "none";

constructor(init?: RawHeaders | Headers);
get [Symbol.toStringTag](): string;
[Symbol.iterator](): IterableIterator<[string, string]>;
append(name: string, value: string): void;

@@ -11,0 +13,0 @@ delete(name: string): void;

@@ -110,2 +110,8 @@ "use strict";

}
get [Symbol.toStringTag]() {
return "Map"; // This causes unit test libraries to treat this as a Map
}
[Symbol.iterator]() {
return this.entries();
}
append(name, value) {

@@ -112,0 +118,0 @@ const _name = filterName(name);

@@ -77,4 +77,4 @@ "use strict";

const { server, port } = await makeServer();
setTimeout(abort, 50);
const response = utils_1.ensureStatusSuccess(await index_1.fetch(`${proto}://localhost:${port}/slow/100`, { signal }));
setTimeout(abort, 100);
const response = utils_1.ensureStatusSuccess(await index_1.fetch(`${proto}://localhost:${port}/slow/200`, { signal }));
const awaitBody = response.arrayBuffer();

@@ -81,0 +81,0 @@ await expect(awaitBody).rejects.toThrowError(index_1.AbortError);

{
"name": "fetch-h2",
"version": "2.2.2",
"version": "2.3.0",
"description": "HTTP/1+2 Fetch API client for Node.js",

@@ -21,10 +21,13 @@ "author": "Gustaf Räntilä",

"scripts": {
"build": "./node_modules/.bin/rimraf dist && ./node_modules/.bin/tsc -p .",
"build:ts": "./node_modules/.bin/rimraf dist && ./node_modules/.bin/tsc -p .",
"build:cert": "scripts/make-certs.sh",
"build": "concurrently 'yarn build:ts' 'yarn build:cert'",
"lint": "node_modules/.bin/tslint --project .",
"jest": "node_modules/.bin/jest",
"jest:core": "node_modules/.bin/jest --forceExit --detectOpenHandles --coverage",
"jest:fast": "yarn jest:core --config jest.config.unit.js $@",
"jest:integration": "node_modules/.bin/compd -f test/docker-compose.yaml yarn jest:core",
"jest:debug": "node --inspect-brk node_modules/.bin/jest",
"test": "npm run lint && node_modules/.bin/jest --forceExit --detectOpenHandles --coverage",
"test": "yarn lint && yarn jest:integration",
"buildtest": "npm run build && npm run jest",
"buildtestcov": "npm run build && npm run test",
"coverage": "node_modules/.bin/nyc report --reporter=html",
"coveralls": "cat coverage/lcov.info | node_modules/.bin/coveralls",

@@ -55,23 +58,22 @@ "version": "./node_modules/.bin/ts-node scripts/version-update.ts && npm run build && npm run test && scripts/version-git-add.sh",

"@types/from2": "2.x",
"@types/jest": "24.x",
"@types/node": "12.x",
"@types/jest": "25.1.0",
"@types/node": "13.5.1",
"@types/through2": "2.x",
"commitizen": "^4.0.3",
"coveralls": "3.x",
"cz-conventional-changelog": "^3.0.2",
"execa": "^2.0.4",
"compd": "^1.3.7",
"concurrently": "^5.1.0",
"cz-conventional-changelog": "^3.1.0",
"execa": "^4.0.0",
"from2": "2.x",
"jest": "24.x",
"nyc": "14.x",
"rimraf": "^3.0.0",
"semantic-release": "15.x",
"travis-deploy-once": "5.x",
"ts-jest": "24.x",
"ts-node": "8.x",
"tslint": "5.x",
"typescript": "3.x"
"jest": "25.1.0",
"mkcert": "^1.2.0",
"rimraf": "^3.0.1",
"ts-jest": "25.0.0",
"ts-node": "8.6.2",
"tslint": "6.0.0",
"typescript": "3.7.5"
},
"dependencies": {
"@types/tough-cookie": "2.x",
"already": "1.x",
"already": "1.10.1",
"callguard": "1.x",

@@ -78,0 +80,0 @@ "get-stream": "5.x",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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