fix(node/tls): fix TLSSocket constructor (#2749)

This commit is contained in:
Yoshiya Hinosawa 2022-10-06 23:11:16 +09:00 committed by GitHub
parent d2cf6c88f0
commit 198fbe5707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// Copyright 2018-2022 Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
// deno-lint-ignore-file no-explicit-any
import {
ObjectAssign,
StringPrototypeReplace,
@ -18,6 +19,8 @@ import {
Pipe,
} from "./internal_binding/pipe_wrap.ts";
import { EventEmitter } from "./events.ts";
import { kEmptyObject } from "./internal/util.mjs";
const kConnectOptions = Symbol("connect-options");
const kIsVerified = Symbol("verified");
const kPendingSession = Symbol("pendingSession");
@ -63,7 +66,7 @@ export class TLSSocket extends net.Socket {
[kConnectOptions]: any;
ssl: any;
_start: any;
constructor(socket: any, opts: any) {
constructor(socket: any, opts: any = kEmptyObject) {
const tlsOptions = { ...opts };
let hostname = tlsOptions?.secureContext?.servername;

View File

@ -95,6 +95,10 @@ Deno.test("tls.createServer creates a TLS server", async () => {
await p;
});
Deno.test("TLSSocket can construct without options", () => {
new tls.TLSSocket(new stream.PassThrough());
});
Deno.test("tlssocket._handle._parentWrap is set", () => {
// Note: This feature is used in popular 'http2-wrapper' module
// https://github.com/szmarczak/http2-wrapper/blob/51eeaf59ff9344fb192b092241bfda8506983620/source/utils/js-stream-socket.js#L6