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.0.3 to 1.0.4

7

lib/v1/driver.js

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

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

@@ -218,0 +225,0 @@

57

lib/v1/internal/ch-node.js

@@ -65,6 +65,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);
}

@@ -75,3 +94,3 @@ var found = false;

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

@@ -87,7 +106,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);
});

@@ -146,4 +185,8 @@ }

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

@@ -150,0 +193,0 @@ 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:false`."));

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

var Connection = (function () {
/**

@@ -374,5 +375,10 @@ * @constructor

value: function initialize(clientName, token, observer) {
var _this2 = this;
this._queueObserver(observer);
this._packer.packStruct(INIT, [clientName, token]);
this._packer.packStruct(INIT, [this._packable(clientName), this._packable(token)], function (err) {
return _this2._handleFatalError(err);
});
this._chunker.messageBoundary();
this.sync();
}

@@ -384,4 +390,8 @@

value: function run(statement, params, observer) {
var _this3 = this;
this._queueObserver(observer);
this._packer.packStruct(RUN, [statement, params]);
this._packer.packStruct(RUN, [this._packable(statement), this._packable(params)], function (err) {
return _this3._handleFatalError(err);
});
this._chunker.messageBoundary();

@@ -394,4 +404,8 @@ }

value: function pullAll(observer) {
var _this4 = this;
this._queueObserver(observer);
this._packer.packStruct(PULL_ALL);
this._packer.packStruct(PULL_ALL, [], function (err) {
return _this4._handleFatalError(err);
});
this._chunker.messageBoundary();

@@ -404,4 +418,8 @@ }

value: function discardAll(observer) {
var _this5 = this;
this._queueObserver(observer);
this._packer.packStruct(DISCARD_ALL);
this._packer.packStruct(DISCARD_ALL, [], function (err) {
return _this5._handleFatalError(err);
});
this._chunker.messageBoundary();

@@ -414,2 +432,4 @@ }

value: function reset(observer) {
var _this6 = this;
this._isHandlingFailure = true;

@@ -428,3 +448,5 @@ var self = this;

this._queueObserver(wrappedObs);
this._packer.packStruct(RESET);
this._packer.packStruct(RESET, [], function (err) {
return _this6._handleFatalError(err);
});
this._chunker.messageBoundary();

@@ -437,4 +459,8 @@ }

value: function _ackFailure(observer) {
var _this7 = this;
this._queueObserver(observer);
this._packer.packStruct(ACK_FAILURE);
this._packer.packStruct(ACK_FAILURE, [], function (err) {
return _this7._handleFatalError(err);
});
this._chunker.messageBoundary();

@@ -488,2 +514,11 @@ }

}
}, {
key: "_packable",
value: function _packable(value) {
var _this8 = this;
return this._packer.packable(value, function (err) {
return _this8._handleFatalError(err);
});
}
}]);

@@ -490,0 +525,0 @@

123

lib/v1/internal/packstream.js

@@ -120,53 +120,94 @@ /**

/**
* Creates a packable function out of the provided value
* @param x the value to pack
* @param onError callback for the case when value cannot be packed
* @returns Function
*/
_createClass(Packer, [{
key: "pack",
value: function pack(x) {
key: "packable",
value: function packable(x, onError) {
var _this = this;
if (x === null) {
this._ch.writeUInt8(NULL);
return function () {
return _this._ch.writeUInt8(NULL);
};
} else if (x === true) {
this._ch.writeUInt8(TRUE);
return function () {
return _this._ch.writeUInt8(TRUE);
};
} else if (x === false) {
this._ch.writeUInt8(FALSE);
return function () {
return _this._ch.writeUInt8(FALSE);
};
} else if (typeof x == "number") {
this.packFloat(x);
return function () {
return _this.packFloat(x);
};
} else if (typeof x == "string") {
this.packString(x);
return function () {
return _this.packString(x, onError);
};
} else if (x instanceof _integer.Integer) {
this.packInteger(x);
return function () {
return _this.packInteger(x);
};
} else if (x instanceof Array) {
this.packListHeader(x.length);
for (var i = 0; i < x.length; i++) {
this.pack(x[i] === undefined ? null : x[i]);
return function () {
_this.packListHeader(x.length, onError);
for (var _i = 0; _i < x.length; _i++) {
_this.packable(x[_i] === undefined ? null : x[_i], onError)();
}
};
} else if (x instanceof Structure) {
var packableFields = [];
for (var i = 0; i < x.fields.length; i++) {
packableFields[i] = this.packable(x.fields[i], onError);
}
} else if (x instanceof Structure) {
this.packStruct(x.signature, x.fields);
return function () {
return _this.packStruct(x.signature, packableFields);
};
} else if (typeof x == "object") {
var keys = Object.keys(x);
return function () {
var keys = Object.keys(x);
var count = 0;
for (var i = 0; i < keys.length; i++) {
if (x[keys[i]] !== undefined) {
count++;
var count = 0;
for (var _i2 = 0; _i2 < keys.length; _i2++) {
if (x[keys[_i2]] !== undefined) {
count++;
}
}
}
this.packMapHeader(count);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (x[key] !== undefined) {
this.packString(key);
this.pack(x[key]);
_this.packMapHeader(count, onError);
for (var _i3 = 0; _i3 < keys.length; _i3++) {
var key = keys[_i3];
if (x[key] !== undefined) {
_this.packString(key);
_this.packable(x[key], onError)();
}
}
};
} else {
if (onError) {
onError((0, _error.newError)("Cannot pack this value: " + x));
}
} else {
throw (0, _error.newError)("Cannot pack this value: " + x);
return function () {
return undefined;
};
}
}
/**
* Packs a struct
* @param signature the signature of the struct
* @param packableFields the fields of the struct, make sure you call `packable on all fields`
*/
}, {
key: "packStruct",
value: function packStruct(signature, fields) {
fields = fields || [];
this.packStructHeader(fields.length, signature);
for (var i = 0; i < fields.length; i++) {
this.pack(fields[i]);
value: function packStruct(signature, packableFields, onError) {
packableFields = packableFields || [];
this.packStructHeader(packableFields.length, signature, onError);
for (var i = 0; i < packableFields.length; i++) {
packableFields[i]();
}

@@ -205,3 +246,3 @@ }

key: "packString",
value: function packString(x) {
value: function packString(x, onError) {
var bytes = _utf82["default"].encode(x);

@@ -229,3 +270,3 @@ var size = bytes.length;

} else {
throw (0, _error.newError)("UTF-8 strings of size " + size + " are not supported");
onError((0, _error.newError)("UTF-8 strings of size " + size + " are not supported"));
}

@@ -235,3 +276,3 @@ }

key: "packListHeader",
value: function packListHeader(size) {
value: function packListHeader(size, onError) {
if (size < 0x10) {

@@ -253,3 +294,3 @@ this._ch.writeUInt8(TINY_LIST | size);

} else {
throw (0, _error.newError)("Lists of size " + size + " are not supported");
onError((0, _error.newError)("Lists of size " + size + " are not supported"));
}

@@ -259,3 +300,3 @@ }

key: "packMapHeader",
value: function packMapHeader(size) {
value: function packMapHeader(size, onError) {
if (size < 0x10) {

@@ -277,3 +318,3 @@ this._ch.writeUInt8(TINY_MAP | size);

} else {
throw (0, _error.newError)("Maps of size " + size + " are not supported");
onError((0, _error.newError)("Maps of size " + size + " are not supported"));
}

@@ -283,3 +324,3 @@ }

key: "packStructHeader",
value: function packStructHeader(size, signature) {
value: function packStructHeader(size, signature, onError) {
if (size < 0x10) {

@@ -297,3 +338,3 @@ this._ch.writeUInt8(TINY_STRUCT | size);

} else {
throw (0, _error.newError)("Structures of size " + size + " are not supported");
onError((0, _error.newError)("Structures of size " + size + " are not supported"));
}

@@ -300,0 +341,0 @@ }

{
"name": "neo4j-driver",
"version": "1.0.3",
"version": "1.0.4",
"description": "Connect to Neo4j 3.0.0 and up from JavaScript",

@@ -16,2 +16,3 @@ "author": "Neo Technology Inc.",

"stop-neo4j": "gulp stop-neo4j",
"run-tck": "gulp run-tck",
"docs": "node_modules/.bin/esdoc -c esdoc.json"

@@ -18,0 +19,0 @@ },

@@ -5,3 +5,3 @@ # Neo4j Driver for Javascript

Find detailed docs at [alpha.neohq.net](http://alpha.neohq.net/docs/javascript-driver/).
Find detailed docs [here](http://neo4j.com/docs/api/javascript-driver/current/).

@@ -8,0 +8,0 @@ ## Include module in Node.js application

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