Socket
Socket
Sign inDemoInstall

neo4j-driver

Package Overview
Dependencies
Maintainers
2
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo4j-driver - npm Package Compare versions

Comparing version 1.1.0-M01 to 1.1.0-M02

16

lib/v1/driver.js

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

}
}, {
key: 'onCompleted',
value: function onCompleted(message) {
if (this._driver.onCompleted) {
this._driver.onCompleted(message);
}
}
}]);

@@ -252,3 +259,3 @@

* //
* // TRUST_SIGNED_CERTIFICATES is the classic approach to trust verification -
* // TRUST_CUSTOM_CA_SIGNED_CERTIFICATES is the classic approach to trust verification -
* // whenever we establish an encrypted connection, we ensure the host is using

@@ -258,6 +265,9 @@ * // an encryption certificate that is in, or is signed by, a certificate listed

* // by the web browser. In NodeJS, you configure the list with the next config option.
* trust: "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES",
* //
* // TRUST_SYSTEM_CA_SIGNED_CERTIFICATES meand that you trust whatever certificates
* // are in the default certificate chain of th
* trust: "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES" | TRUST_CUSTOM_CA_SIGNED_CERTIFICATES | TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
*
* // List of one or more paths to trusted encryption certificates. This only
* // works in the NodeJS bundle, and only matters if you use "TRUST_SIGNED_CERTIFICATES".
* // works in the NodeJS bundle, and only matters if you use "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES".
* // The certificate files should be in regular X.509 PEM format.

@@ -264,0 +274,0 @@ * // For instance, ['./trusted.pem']

@@ -26,2 +26,4 @@ /**

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _integer = require('./integer');

@@ -35,2 +37,12 @@

var _result = require('./result');
var _result2 = _interopRequireDefault(_result);
var _resultSummary = require('./result-summary');
var _resultSummary2 = _interopRequireDefault(_resultSummary);
var _record = require('./record');
exports['default'] = {

@@ -43,3 +55,19 @@ driver: _driver.driver,

basic: function basic(username, password) {
return { scheme: "basic", principal: username, credentials: password };
var realm = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2];
if (realm) {
return { scheme: "basic", principal: username, credentials: password, realm: realm };
} else {
return { scheme: "basic", principal: username, credentials: password };
}
},
custom: function custom(principal, credentials, realm, scheme) {
var parameters = arguments.length <= 4 || arguments[4] === undefined ? undefined : arguments[4];
if (parameters) {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters };
} else {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
}
}

@@ -52,5 +80,8 @@ },

PathSegment: _graphTypes.PathSegment,
Path: _graphTypes.Path
Path: _graphTypes.Path,
Result: _result2['default'],
ResultSummary: _resultSummary2['default'],
Record: _record.Record
}
};
module.exports = exports['default'];

@@ -67,6 +67,25 @@ /**

function mkFullPath(pathToCreate) {
try {
_fs2['default'].mkdirSync(pathToCreate);
} catch (e) {
if (e.code === 'ENOENT') {
// Create parent dir
mkFullPath(_path2['default'].dirname(pathToCreate));
// And now try again
mkFullPath(pathToCreate);
return;
}
if (e.code === 'EEXIST') {
return;
}
throw e;
}
}
function loadFingerprint(serverId, knownHostsPath, cb) {
if (!_fs2['default'].existsSync(knownHostsPath)) {
cb(null);
return;
try {
_fs2['default'].accessSync(knownHostsPath);
} catch (e) {
return cb(null);
}

@@ -77,3 +96,3 @@ var found = false;

}).on('line', function (line) {
if (line.startsWith(serverId)) {
if (!found && line.startsWith(serverId)) {
found = true;

@@ -89,7 +108,27 @@ cb(line.split(" ")[1]);

function storeFingerprint(serverId, knownHostsPath, fingerprint) {
var _lockFingerprintFromAppending = {};
function storeFingerprint(serverId, knownHostsPath, fingerprint, cb) {
// we check if the serverId has been appended
if (!!_lockFingerprintFromAppending[serverId]) {
// if it has, we ignore it
return cb(null);
}
// we make the line as appended
// ( 1 is more efficient to store than true because true is an oddball )
_lockFingerprintFromAppending[serverId] = 1;
// If file doesn't exist, create full path to it
try {
_fs2['default'].accessSync(knownHostsPath);
} catch (_) {
mkFullPath(_path2['default'].dirname(knownHostsPath));
}
_fs2['default'].appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8", function (err) {
delete _lockFingerprintFromAppending[serverId];
if (err) {
console.log(err);
}
return cb(err);
});

@@ -99,5 +138,12 @@ }

var TrustStrategy = {
/**
* @deprecated Since version 1.0. Will be deleted in a future version. TRUST_CUSTOM_CA_SIGNED_CERTIFICATES.
*/
TRUST_SIGNED_CERTIFICATES: function TRUST_SIGNED_CERTIFICATES(opts, onSuccess, onFailure) {
console.log("`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of " + "the driver. Pleas use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead.");
return TrustStrategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(opts, onSuccess, onFailure);
},
TRUST_CUSTOM_CA_SIGNED_CERTIFICATES: function TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(opts, onSuccess, onFailure) {
if (!opts.trustedCertificates || opts.trustedCertificates.length == 0) {
onFailure((0, _error.newError)("You are using TRUST_SIGNED_CERTIFICATES as the method " + "to verify trust for encrypted connections, but have not configured any " + "trustedCertificates. You must specify the path to at least one trusted " + "X.509 certificate for this to work. Two other alternatives is to use " + "TRUST_ON_FIRST_USE or to disable encryption by setting encrypted=\"" + _util.ENCRYPTION_OFF + "\"" + "in your driver configuration."));
onFailure((0, _error.newError)("You are using TRUST_CUSTOM_CA_SIGNED_CERTIFICATES as the method " + "to verify trust for encrypted connections, but have not configured any " + "trustedCertificates. You must specify the path to at least one trusted " + "X.509 certificate for this to work. Two other alternatives is to use " + "TRUST_ON_FIRST_USE or to disable encryption by setting encrypted=\"" + _util.ENCRYPTION_OFF + "\"" + "in your driver configuration."));
return;

@@ -107,3 +153,5 @@ }

var tlsOpts = {
ca: opts.trustedCertificates.map(_fs2['default'].readFileSync),
ca: opts.trustedCertificates.map(function (f) {
return _fs2['default'].readFileSync(f);
}),
// Because we manually check for this in the connect callback, to give

@@ -116,3 +164,3 @@ // a more helpful error to the user

if (!socket.authorized) {
onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"` in the driver" + " options."));
onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));
} else {

@@ -125,2 +173,19 @@ onSuccess();

},
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES: function TRUST_SYSTEM_CA_SIGNED_CERTIFICATES(opts, onSuccess, onFailure) {
var tlsOpts = {
// Because we manually check for this in the connect callback, to give
// a more helpful error to the user
rejectUnauthorized: false
};
var socket = _tls2['default'].connect(opts.port, opts.host, tlsOpts, function () {
if (!socket.authorized) {
onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, use " + "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES and add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));
} else {
onSuccess();
}
});
socket.on('error', onFailure);
return socket;
},
TRUST_ON_FIRST_USE: function TRUST_ON_FIRST_USE(opts, onSuccess, onFailure) {

@@ -140,3 +205,3 @@ var tlsOpts = {

// do TOFU, and the safe approach is to fail.
onFailure((0, _error.newError)("You are using a version of NodeJS that does not " + "support trust-on-first use encryption. You can either upgrade NodeJS to " + "a newer version, use `trust:TRUST_SIGNED_CERTIFICATES` in your driver " + "config instead, or disable encryption using `encrypted:\"" + _util.ENCRYPTION_OFF + "\"`."));
onFailure((0, _error.newError)("You are using a version of NodeJS that does not " + "support trust-on-first use encryption. You can either upgrade NodeJS to " + "a newer version, use `trust:TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` in your driver " + "config instead, or disable encryption using `encrypted:\"" + _util.ENCRYPTION_OFF + "\"`."));
return;

@@ -153,4 +218,8 @@ }

} else if (knownFingerprint == null) {
storeFingerprint(serverId, knownHostsPath, serverFingerprint);
onSuccess();
storeFingerprint(serverId, knownHostsPath, serverFingerprint, function (err) {
if (err) {
return onFailure(err);
}
return onSuccess();
});
} else {

@@ -179,3 +248,3 @@ onFailure((0, _error.newError)("Database encryption certificate has changed, and no longer " + "matches the certificate stored for " + serverId + " in `" + knownHostsPath + "`. As a security precaution, this driver will not automatically trust the new " + "certificate, because doing so would allow an attacker to pretend to be the Neo4j " + "instance we want to connect to. The certificate provided by the server looks like: " + serverCert + ". If you trust that this certificate is valid, simply remove the line " + "starting with " + serverId + " in `" + knownHostsPath + "`, and the driver will " + "update the file with the new certificate. You can configure which file the driver " + "should use to store this information by setting `knownHosts` to another path in " + "your driver configuration - and you can disable encryption there as well using " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"`."));

} else {
onFailure((0, _error.newError)("Unknown trust strategy: " + opts.trust + ". Please use either " + "trust:'TRUST_SIGNED_CERTIFICATES' or trust:'TRUST_ON_FIRST_USE' in your driver " + "configuration. Alternatively, you can disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"`. There is no mechanism to use encryption without trust verification, " + "because this incurs the overhead of encryption without improving security. If " + "the driver does not verify that the peer it is connected to is really Neo4j, it " + "is very easy for an attacker to bypass the encryption by pretending to be Neo4j."));
onFailure((0, _error.newError)("Unknown trust strategy: " + opts.trust + ". Please use either " + "trust:'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES' or trust:'TRUST_ON_FIRST_USE' in your driver " + "configuration. Alternatively, you can disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"`. There is no mechanism to use encryption without trust verification, " + "because this incurs the overhead of encryption without improving security. If " + "the driver does not verify that the peer it is connected to is really Neo4j, it " + "is very easy for an attacker to bypass the encryption by pretending to be Neo4j."));
}

@@ -224,2 +293,3 @@ }

self._conn.on('error', self._handleConnectionError);
self._conn.on('end', self._handleConnectionTerminated);

@@ -244,2 +314,10 @@ // Drain all pending messages

}, {
key: '_handleConnectionTerminated',
value: function _handleConnectionTerminated() {
this._error = new Error('Connection was closed by server');
if (this.onerror) {
this.onerror(this._error);
}
}
}, {
key: 'isEncrypted',

@@ -283,2 +361,3 @@ value: function isEncrypted() {

this._conn.end();
this._conn.removeListener('end', this._handleConnectionTerminated);
this._conn.on('end', cb);

@@ -285,0 +364,0 @@ } else {

4

lib/v1/internal/ch-websocket.js

@@ -65,6 +65,6 @@ /**

if (opts.encrypted === true || opts.encrypted === _util.ENCRYPTION_ON || opts.encrypted === _util.ENCRYPTION_NON_LOCAL && !(0, _util.isLocalHost)(opts.host)) {
if (!opts.trust || opts.trust === "TRUST_SIGNED_CERTIFICATES") {
if (!opts.trust || opts.trust === "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES") {
scheme = "wss";
} else {
this._error = (0, _error.newError)("The browser version of this driver only supports one trust " + "strategy, 'TRUST_SIGNED_CERTIFICATES'. " + opts.trust + " is not supported. Please " + "either use TRUST_SIGNED_CERTIFICATES or disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"` in the driver configuration.");
this._error = (0, _error.newError)("The browser version of this driver only supports one trust " + "strategy, 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'. " + opts.trust + " is not supported. Please " + "either use TRUST_CUSTOM_CA_SIGNED_CERTIFICATES or disable encryption by setting " + "`encrypted:\"" + _util.ENCRYPTION_OFF + "\"` in the driver configuration.");
return;

@@ -71,0 +71,0 @@ }

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

this._chunker.messageBoundary();
this.sync();
}

@@ -537,3 +538,3 @@

// Default to using TRUST_ON_FIRST_USE if it is available
trust: config.trust || ((0, _features2["default"])("trust_on_first_use") ? "TRUST_ON_FIRST_USE" : "TRUST_SIGNED_CERTIFICATES"),
trust: config.trust || ((0, _features2["default"])("trust_on_first_use") ? "TRUST_ON_FIRST_USE" : "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES"),
trustedCertificates: config.trustedCertificates || [],

@@ -540,0 +541,0 @@ knownHosts: config.knownHosts

@@ -66,7 +66,12 @@ /**

value: function acquire() {
if (this._pool.length > 0) {
return this._pool.pop();
} else {
return this._create(this._release);
var resource = undefined;
while (this._pool.length) {
resource = this._pool.pop();
if (this._validate(resource)) {
return resource;
}
}
return this._create(this._release);
}

@@ -73,0 +78,0 @@ }, {

@@ -50,6 +50,11 @@ /**

this.statementType = metadata.type;
this.updateStatistics = new StatementStatistics(metadata.stats || {});
var counters = new StatementStatistics(metadata.stats || {});
this.counters = counters;
//for backwards compatibility, remove in future version
this.updateStatistics = counters;
this.plan = metadata.plan || metadata.profile ? new Plan(metadata.plan || metadata.profile) : false;
this.profile = metadata.profile ? new ProfiledPlan(metadata.profile) : false;
this.notifications = this._buildNotifications(metadata.notifications);
this.resultConsumedAfter = metadata.result_consumed_after;
this.resultAvailableAfter = metadata.result_available_after;
}

@@ -56,0 +61,0 @@

@@ -51,5 +51,6 @@ /**

* @param {Object} parameters - Map with parameters to use in statement
* @param metaSupplier function, when called provides metadata
*/
function Result(streamObserver, statement, parameters) {
function Result(streamObserver, statement, parameters, metaSupplier) {
_classCallCheck(this, Result);

@@ -61,2 +62,5 @@

this._parameters = parameters || {};
this._metaSupplier = metaSupplier || function () {
return {};
};
}

@@ -138,3 +142,11 @@

var onCompletedOriginal = observer.onCompleted;
var self = this;
var onCompletedWrapper = function onCompletedWrapper(metadata) {
var additionalMeta = self._metaSupplier();
for (var key in additionalMeta) {
if (additionalMeta.hasOwnProperty(key)) {
metadata[key] = additionalMeta[key];
}
}
var sum = new _resultSummary.ResultSummary(_this._statement, _this._parameters, metadata);

@@ -141,0 +153,0 @@ onCompletedOriginal.call(observer, sum);

@@ -26,2 +26,4 @@ /**

var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

@@ -31,2 +33,4 @@

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

@@ -46,2 +50,4 @@

var _integer = require("./integer");
var _error = require("./error");

@@ -70,2 +76,4 @@

/** Internal stream observer used for transactional results*/
_createClass(Session, [{

@@ -94,3 +102,3 @@ key: 'isEncrypted',

}
var streamObserver = new _internalStreamObserver2['default']();
var streamObserver = new _RunObserver();
if (!this._hasTx) {

@@ -103,3 +111,5 @@ this._conn.run(statement, parameters, streamObserver);

}
return new _result2['default'](streamObserver, statement, parameters);
return new _result2['default'](streamObserver, statement, parameters, function () {
return streamObserver.meta();
});
}

@@ -157,3 +167,33 @@

var _RunObserver = (function (_StreamObserver) {
_inherits(_RunObserver, _StreamObserver);
function _RunObserver() {
_classCallCheck(this, _RunObserver);
_get(Object.getPrototypeOf(_RunObserver.prototype), 'constructor', this).call(this);
this._meta = {};
}
_createClass(_RunObserver, [{
key: 'onCompleted',
value: function onCompleted(meta) {
_get(Object.getPrototypeOf(_RunObserver.prototype), 'onCompleted', this).call(this, meta);
for (var key in meta) {
if (meta.hasOwnProperty(key)) {
this._meta[key] = meta[key];
}
}
}
}, {
key: 'meta',
value: function meta() {
return this._meta;
}
}]);
return _RunObserver;
})(_internalStreamObserver2['default']);
exports['default'] = Session;
module.exports = exports['default'];
{
"name": "neo4j-driver",
"version": "1.1.0-M01",
"version": "1.1.0-M02",
"description": "Connect to Neo4j 3.1.0 and up from JavaScript",

@@ -5,0 +5,0 @@ "author": "Neo Technology Inc.",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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