From cf9c4f0031a46b58989a984af0528a2005547e2d Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 26 Oct 2021 22:27:47 +0200 Subject: feat(ext/net): add TlsConn.handshake() (#12467) A `handshake()` method was added that returns when the TLS handshake is complete. The `TlsListener` and `TlsConn` interfaces were added to accomodate this new method. Closes: #11759. --- ext/net/lib.deno_net.d.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ext/net/lib.deno_net.d.ts') diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index 45f1194fb..1b67fcf22 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -33,6 +33,13 @@ declare namespace Deno { [Symbol.asyncIterator](): AsyncIterableIterator; } + /** Specialized listener that accepts TLS connections. */ + export interface TlsListener extends Listener, AsyncIterable { + /** Waits for a TLS client to connect and accepts the connection. */ + accept(): Promise; + [Symbol.asyncIterator](): AsyncIterableIterator; + } + export interface Conn extends Reader, Writer, Closer { /** The local address of the connection. */ readonly localAddr: Addr; @@ -45,6 +52,13 @@ declare namespace Deno { closeWrite(): Promise; } + export interface TlsConn extends Conn { + /** Runs the client or server handshake protocol to completion if that has + * not happened yet. Calling this method is optional; the TLS handshake + * will be completed automatically as soon as data is sent or received. */ + handshake(): Promise; + } + export interface ListenOptions { /** The port to listen on. */ port: number; @@ -90,7 +104,7 @@ declare namespace Deno { * ``` * * Requires `allow-net` permission. */ - export function listenTls(options: ListenTlsOptions): Listener; + export function listenTls(options: ListenTlsOptions): TlsListener; export interface ConnectOptions { /** The port to connect to. */ @@ -150,7 +164,7 @@ declare namespace Deno { * * Requires `allow-net` permission. */ - export function connectTls(options: ConnectTlsOptions): Promise; + export function connectTls(options: ConnectTlsOptions): Promise; /** Shutdown socket send operations. * -- cgit v1.2.3