Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

node:tls: SNICallback, new tls.TLSSocket(socket, {isServer}), and ALPNProtocols not supported

Aperta
#1,438 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start at the node:tls type definitions and the compiler's lowering for tls.createServer, tls.connect, and tls.TLSSocket; the issue reports missing support in all three areas. Trace how runtime option records are lowered and check existing TLS tests before assessing each requested case. Done means the SNI callback, socket wrapping, and ALPN options work in the described server and client examples.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: scriptc 0.3.6, Linux x64

Use case: an intercepting HTTPS proxy that terminates TLS for many hostnames on a single listener, or upgrades a raw socket after an HTTP CONNECT. A fixed-cert tls.createServer({key, cert}) works, but the pieces needed for the multi-host case are missing.

1. SNICallback
import * as tls from "node:tls";
import * as fs from "node:fs";
const ctx = tls.createSecureContext({ key: fs.readFileSync("k.pem"), cert: fs.readFileSync("c.pem") });
tls.createServer({ SNICallback: (name: string, cb: (e: Error | null, c?: tls.SecureContext) => void) => cb(null, ctx) },
  (s) => s.end("hi")).listen(0);

→ SC2020: 'tls.createServer option 'SNICallback'' is part of the standard library types but has no scriptc lowering yet

2. Wrapping an existing socket
import * as tls from "node:tls";
import * as net from "node:net";
net.createServer((raw) => {
  new tls.TLSSocket(raw, { isServer: true, key, cert }).end("hi");
}).listen(0);

→ SC0001: Property 'TLSSocket' does not exist on type 'typeof import("node:tls")'.
(Equivalently, server.emit("connection", rawSocket) or tls.connect({ socket }) would cover the client side.)

3. ALPN on tls.connect
const s = tls.connect({ host: "example.com", port: 443, servername: "example.com", ALPNProtocols: ["h2", "http/1.1"] },
  () => console.log(s.alpnProtocol));

Compiles, then fails at runtime:
Uncaught Error: tls.connect option 'ALPNProtocols' has no static lowering — port/host/rejectUnauthorized/ca/servername are the honestly-implemented members of a runtime options record
Server-side ALPNProtocols would be useful too.

Current workaround

Spin up one loopback https.createServer per hostname and pipe the CONNECT socket into it. It works, but it adds an extra hop and costs a listener per host.

Lingua principale
TypeScript
Stelle
6.2k
Fork
183
Merge medio
2h 20m
PR unite (30g)
893

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.