Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-servers

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-servers - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

37

index.js

@@ -18,2 +18,4 @@ 'use strict';

var pemFormat = /-----BEGIN/;
var CIPHERS = [

@@ -38,6 +40,6 @@ 'ECDHE-RSA-AES256-SHA384',

//
// ### function createServers (dispatch, options, callback)
// Creates and listens on both HTTP and HTTPS servers.
//
/**
* function createServers (dispatch, options, callback)
* Creates and listens on both HTTP and HTTPS servers.
*/
module.exports = function createServers(options, listening) {

@@ -150,9 +152,5 @@ if (!options || (!options.http && !options.https)

//
key: fs.readFileSync(path.resolve(ssl.root, ssl.key)),
cert: fs.readFileSync(path.resolve(ssl.root, ssl.cert)),
ca: ca && ca.map(
function (file) {
return fs.readFileSync(path.resolve(ssl.root, file));
}
),
key: normalizeCertFile(ssl.root, ssl.key),
cert: normalizeCertFile(ssl.root, ssl.cert),
ca: ca && ca.map(normalizeCertFile.bind(null, ssl.root)),
//

@@ -187,1 +185,18 @@ // Properly expose ciphers for an A+ SSL rating:

};
/**
* function normalizeCertFile(root, file)
* Returns the contents of `file` verbatim if it is determined to be
* certificate material and not a file path. Otherwise, returns the
* certificate material read from that file path.
*/
function normalizeCertFile(root, file) {
//
// Assumption that this is a Buffer, a PEM file, or something broken
//
if (typeof(file) !== 'string' || pemFormat.test(file)) {
return file;
}
return fs.readFileSync(path.resolve(root, file));
}
{
"name": "create-servers",
"version": "2.1.0",
"version": "2.2.0",
"description": "Create an http AND/OR an https server and call the same request handler.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,2 +9,3 @@ /*

var path = require('path'),
fs = require('fs'),
http = require('http'),

@@ -180,2 +181,22 @@ https = require('https'),

test('supports cert contents instead of cert paths', function (t) {
t.plan(3);
var root = path.join(__dirname, 'fixtures');
createServers({
log: console.log,
https: {
port: 3456,
root: root,
cert: fs.readFileSync(path.resolve(root, 'agent2-cert.pem')),
key: fs.readFileSync(path.resolve(root, 'agent2-key.pem'))
},
handler: fend
}, function (err, servers) {
t.error(err);
t.equals(typeof servers, 'object');
t.equals(typeof servers.https, 'object');
servers.https.close();
});
});
test('supports requestCert https option', function (t) {

@@ -182,0 +203,0 @@ t.plan(2);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc