UNPKG

@gr2m/net-interceptor

Version:

Intercept and mock outgoing network TCP/TLS connections

21 lines (17 loc) 501 B
// @ts-check import net from "node:net"; import tls from "node:tls"; /** * TlsSocket is not extending `tls.TLSSocket` because the * logic is a lot different to `net.Socket`. So we inherit * from `net.Socket` instead and then only apply the instances * methods from `tls.TLSSocket`. */ export default class NetInterceptorTlsSocket extends net.Socket { encrypted = true; authorized = true; constructor(...args) { super(...args); Object.assign(this, tls.TLSSocket.prototype); } }