Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiviaMedeiros <livia@cirno.name>2022-05-21 12:57:01 +0300
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2022-06-11 13:18:15 +0300
commitcade060153415352457c8c647b1440adfdc0d0cb (patch)
tree005b13d131657a693a202f4d3f0da7ea4a9c0f8b
parentcacd72eb638355bc615c19d5ceb35b3b0d617aaa (diff)
tls: use `kEmptyObject`
PR-URL: https://github.com/nodejs/node/pull/43159 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
-rw-r--r--lib/_tls_common.js6
-rw-r--r--lib/_tls_wrap.js7
-rw-r--r--lib/internal/tls/secure-context.js6
-rw-r--r--lib/internal/tls/secure-pair.js3
4 files changed, 16 insertions, 6 deletions
diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index 79d3ac1136e..b6e1774f38f 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -48,6 +48,10 @@ const {
} = internalBinding('constants');
const {
+ kEmptyObject,
+} = require('internal/util');
+
+const {
validateInteger,
} = require('internal/validators');
@@ -93,7 +97,7 @@ function SecureContext(secureProtocol, secureOptions, minVersion, maxVersion) {
}
function createSecureContext(options) {
- if (!options) options = {};
+ if (!options) options = kEmptyObject;
const {
honorCipherOrder,
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index 24e04010a28..55c60c34e0a 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -40,7 +40,8 @@ const {
const {
assertCrypto,
- deprecate
+ deprecate,
+ kEmptyObject,
} = require('internal/util');
assertCrypto();
@@ -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);
}
diff --git a/lib/internal/tls/secure-context.js b/lib/internal/tls/secure-context.js
index 8cb3ae06d2e..152627b420a 100644
--- a/lib/internal/tls/secure-context.js
+++ b/lib/internal/tls/secure-context.js
@@ -18,6 +18,10 @@ const {
} = require('internal/errors');
const {
+ kEmptyObject,
+} = require('internal/util');
+
+const {
isArrayBufferView,
} = require('internal/util/types');
@@ -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 {
diff --git a/lib/internal/tls/secure-pair.js b/lib/internal/tls/secure-pair.js
index b3f0930a3c7..db999d90ccf 100644
--- a/lib/internal/tls/secure-pair.js
+++ b/lib/internal/tls/secure-pair.js
@@ -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');
@@ -57,7 +58,7 @@ class SecurePair extends EventEmitter {
isServer = false,
requestCert = !isServer,
rejectUnauthorized = false,
- options = {}) {
+ options = kEmptyObject) {
super();
const { socket1, socket2 } = new DuplexPair();