Skip to content

Commit

Permalink
tls: use kEmptyObject
Browse files Browse the repository at this point in the history
PR-URL: #43159
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
LiviaMedeiros authored and danielleadams committed Jun 13, 2022
1 parent fecad7a commit e31baca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const {
},
} = internalBinding('constants');

const {
kEmptyObject,
} = require('internal/util');

const {
validateInteger,
} = require('internal/validators');
Expand Down Expand Up @@ -93,7 +97,7 @@ function SecureContext(secureProtocol, secureOptions, minVersion, maxVersion) {
}

function createSecureContext(options) {
if (!options) options = {};
if (!options) options = kEmptyObject;

const {
honorCipherOrder,
Expand Down
7 changes: 4 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const {

const {
assertCrypto,
deprecate
deprecate,
kEmptyObject,
} = require('internal/util');

assertCrypto();
Expand Down Expand Up @@ -1182,9 +1183,9 @@ function Server(options, listener) {

if (typeof options === 'function') {
listener = options;
options = {};
options = kEmptyObject;
} else if (options == null || typeof options === 'object') {
options = options || {};
options = options ?? kEmptyObject;
} else {
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/internal/tls/secure-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const {
},
} = require('internal/errors');

const {
kEmptyObject,
} = require('internal/util');

const {
isArrayBufferView,
} = require('internal/util/types');
Expand Down Expand Up @@ -117,7 +121,7 @@ function processCiphers(ciphers, name) {
return { cipherList, cipherSuites };
}

function configSecureContext(context, options = {}, name = 'options') {
function configSecureContext(context, options = kEmptyObject, name = 'options') {
validateObject(options, name);

const {
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/tls/secure-pair.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const EventEmitter = require('events');
const { kEmptyObject } = require('internal/util');
const { Duplex } = require('stream');
const _tls_wrap = require('_tls_wrap');
const _tls_common = require('_tls_common');
Expand Down Expand Up @@ -57,7 +58,7 @@ class SecurePair extends EventEmitter {
isServer = false,
requestCert = !isServer,
rejectUnauthorized = false,
options = {}) {
options = kEmptyObject) {
super();
const { socket1, socket2 } = new DuplexPair();

Expand Down

0 comments on commit e31baca

Please sign in to comment.