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.4.1 to 2.4.2

17

dist/lib/context.js

@@ -84,6 +84,3 @@ "use strict";

const { origin } = this.parseInput(url);
const sessions = this._originCache.getAny(origin);
sessions.forEach(({ session }) => {
this._originCache.delete(session);
});
this._originCache.disconnect(origin);
await Promise.all([

@@ -95,3 +92,3 @@ this.h1Context.disconnect(url),

async disconnectAll() {
this._originCache.clear();
this._originCache.disconnectAll();
await Promise.all([

@@ -222,2 +219,8 @@ this.h1Context.disconnectAll(),

const { protocol, socket, altNameMatch } = await context_https_1.connectTLS(hostname, port, core_1.getByOrigin(this._httpsProtocols, origin), core_1.getByOrigin(this._sessionOptions, origin));
const disconnect = already_1.once(() => {
if (!socket.destroyed) {
socket.destroy();
socket.unref();
}
});
if (protocol === "http2") {

@@ -229,3 +232,3 @@ // Convert socket into http2 session, this will ref (*)

});
this._originCache.set(origin, "https2", cacheableSession, altNameMatch);
this._originCache.set(origin, "https2", cacheableSession, altNameMatch, disconnect);
shortcut();

@@ -241,3 +244,3 @@ // Session now lingering, it will be re-used by the next get()

if (!cacheItem)
this._originCache.set(origin, "https1", session, altNameMatch);
this._originCache.set(origin, "https1", session, altNameMatch, disconnect);
const cleanup = this.h1Context.addUsedSocket(session, socket);

@@ -244,0 +247,0 @@ shortcut();

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

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

@@ -14,8 +14,8 @@ import { AltNameMatch } from "./san";

private staticMap;
getAny(origin: string): (OriginCacheEntry<"https1", SessionMap["https1"]> | OriginCacheEntry<"https2", SessionMap["https2"]> | OriginCacheEntry<"http1", SessionMap["http1"]> | OriginCacheEntry<"http2", SessionMap["http2"]>)[];
get<P extends Protocol>(protocol: P, origin: string): OriginCacheEntry<typeof protocol, SessionMap[P]> | undefined;
set(origin: string, protocol: Protocol, session: SessionMap[typeof protocol], altNameMatch?: AltNameMatch): void;
set(origin: string, protocol: Protocol, session: SessionMap[typeof protocol], altNameMatch?: AltNameMatch, cleanup?: () => void): void;
delete(session: SessionMap[keyof SessionMap]): boolean;
clear(): void;
disconnectAll(): void;
disconnect(origin: string): void;
}
export {};

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

}
getAny(origin) {
return [
this.get('https1', origin),
this.get('https2', origin),
this.get('http1', origin),
this.get('http2', origin),
]
.filter((t) => !!t);
}
get(protocol, origin) {

@@ -46,3 +37,3 @@ const key = makeKey(protocol, origin);

}
set(origin, protocol, session, altNameMatch) {
set(origin, protocol, session, altNameMatch, cleanup) {
const state = {

@@ -54,2 +45,3 @@ protocol,

resolved: [],
cleanup,
};

@@ -80,8 +72,26 @@ this.sessionMap.set(session, state);

}
clear() {
disconnectAll() {
[...this.sessionMap].forEach(([_, session]) => {
var _a;
(_a = session.cleanup) === null || _a === void 0 ? void 0 : _a.call(session);
});
this.sessionMap.clear();
this.staticMap.clear();
}
disconnect(origin) {
[
this.get('https1', origin),
this.get('https2', origin),
this.get('http1', origin),
this.get('http2', origin),
]
.filter((t) => !!t)
.forEach(({ session }) => {
var _a, _b;
(_b = (_a = this.sessionMap.get(session)) === null || _a === void 0 ? void 0 : _a.cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
this.delete(session);
});
}
}
exports.default = OriginCache;
//# sourceMappingURL=origin-cache.js.map

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

return async () => {
const { fetch } = index_1.context({
const { fetch, disconnectAll } = index_1.context({
httpsProtocols: protos,

@@ -36,3 +36,3 @@ session: certs

// the sockets correctly.
await fn(fetch);
await fn(fetch, disconnectAll);
};

@@ -96,10 +96,14 @@ }

}));
it("should save and forward cookies", wrapContext(async (fetch) => {
it("should save and forward cookies", wrapContext(async (fetch, disconnectAll) => {
const responseSet = await fetch(`${host}/cookies/set?foo=bar`, { redirect: "manual" });
expect(responseSet.headers.has("location")).toBe(true);
const redirectedTo = responseSet.headers.get("location");
await responseSet.text();
if (scheme === "https:")
// Over TLS, we need to read the payload, or the socket will not
// deref.
await responseSet.text();
const response = await fetch(baseHost + redirectedTo);
const data = await response.json();
expect(data.cookies).toEqual({ foo: "bar" });
await disconnectAll();
}));

@@ -106,0 +110,0 @@ it("should handle (and follow) relative paths", wrapContext(async (fetch) => {

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

@@ -5,0 +5,0 @@ "author": "Gustaf Räntilä",

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