Skip to content

Commit a1e7979

Browse files
committed
Don't check in lib
1 parent e9d75dc commit a1e7979

11 files changed

+33722
-37723
lines changed

lib/browser/neo4j-web.js

+16,752-17,505
Large diffs are not rendered by default.

lib/browser/neo4j-web.min.js

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

+16,932-20,076
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/driver.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ var USER_AGENT = "neo4j-javascript/" + _version.VERSION;
230230
* options are as follows:
231231
*
232232
* {
233-
* // Encryption level: one of ENCRYPTION_ON, ENCRYPTION_OFF or ENCRYPTION_NON_LOCAL.
234-
* // ENCRYPTION_NON_LOCAL is on by default in modern NodeJS installs,
233+
* // Enable TLS encryption. This is on by default in modern NodeJS installs,
235234
* // but off by default in the Web Bundle and old (<=1.0.0) NodeJS installs
236235
* // due to technical limitations on those platforms.
237-
* encrypted: ENCRYPTION_ON|ENCRYPTION_OFF|ENCRYPTION_NON_LOCAL
236+
* encrypted: true|false,
238237
*
239238
* // Trust strategy to use if encryption is enabled. There is no mode to disable
240239
* // trust other than disabling encryption altogether. The reason for

lib/v1/internal/ch-dummy.js

-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ var DummyChannel = (function () {
4444
}
4545

4646
_createClass(DummyChannel, [{
47-
key: "isEncrypted",
48-
value: function isEncrypted() {
49-
return false;
50-
}
51-
}, {
5247
key: "write",
5348
value: function write(buf) {
5449
this.written.push(buf);

lib/v1/internal/ch-node.js

+7-20
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ var _os = require('os');
4949

5050
var _buf = require('./buf');
5151

52-
var _util = require('./util');
53-
5452
var _error = require('./../error');
5553

5654
var _CONNECTION_IDGEN = 0;
@@ -85,17 +83,13 @@ function loadFingerprint(serverId, knownHostsPath, cb) {
8583
}
8684

8785
function storeFingerprint(serverId, knownHostsPath, fingerprint) {
88-
_fs2['default'].appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8", function (err) {
89-
if (err) {
90-
console.log(err);
91-
}
92-
});
86+
_fs2['default'].appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8");
9387
}
9488

9589
var TrustStrategy = {
9690
TRUST_SIGNED_CERTIFICATES: function TRUST_SIGNED_CERTIFICATES(opts, onSuccess, onFailure) {
9791
if (!opts.trustedCertificates || opts.trustedCertificates.length == 0) {
98-
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."));
92+
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=false " + "in your driver configuration."));
9993
return;
10094
}
10195

@@ -108,7 +102,7 @@ var TrustStrategy = {
108102

109103
var socket = _tls2['default'].connect(opts.port, opts.host, tlsOpts, function () {
110104
if (!socket.authorized) {
111-
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."));
105+
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=false` in the driver" + " options."));
112106
} else {
113107
onSuccess();
114108
}
@@ -130,7 +124,7 @@ var TrustStrategy = {
130124
// the raw cert cannot be accessed (or, at least I couldn't find a way to)
131125
// therefore, we can't generate a SHA512 fingerprint, meaning we can't
132126
// do TOFU, and the safe approach is to fail.
133-
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 + "\"`."));
127+
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:false`."));
134128
return;
135129
}
136130

@@ -145,7 +139,7 @@ var TrustStrategy = {
145139
storeFingerprint(serverId, knownHostsPath, serverFingerprint);
146140
onSuccess();
147141
} else {
148-
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 + "\"`."));
142+
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`."));
149143
}
150144
});
151145
});
@@ -159,15 +153,14 @@ function connect(opts, onSuccess) {
159153
return null;
160154
} : arguments[2];
161155

162-
//still allow boolean for backwards compatibility
163-
if (opts.encrypted === false || opts.encrypted === _util.ENCRYPTION_OFF || opts.encrypted === _util.ENCRYPTION_NON_LOCAL && (0, _util.isLocalHost)(opts.host)) {
156+
if (opts.encrypted === false) {
164157
var conn = _net2['default'].connect(opts.port, opts.host, onSuccess);
165158
conn.on('error', onFailure);
166159
return conn;
167160
} else if (TrustStrategy[opts.trust]) {
168161
return TrustStrategy[opts.trust](opts, onSuccess, onFailure);
169162
} else {
170-
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."));
163+
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:false`. 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."));
171164
}
172165
}
173166

@@ -198,7 +191,6 @@ var NodeChannel = (function () {
198191
this._error = null;
199192
this._handleConnectionError = this._handleConnectionError.bind(this);
200193

201-
this._encrypted = opts.encrypted;
202194
this._conn = connect(opts, function () {
203195
if (!self._open) {
204196
return;
@@ -229,11 +221,6 @@ var NodeChannel = (function () {
229221
this.onerror(err);
230222
}
231223
}
232-
}, {
233-
key: 'isEncrypted',
234-
value: function isEncrypted() {
235-
return this._encrypted;
236-
}
237224

238225
/**
239226
* Write the passed in buffer to connection

lib/v1/internal/ch-websocket.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ var _buf = require("./buf");
3333

3434
var _error = require('./../error');
3535

36-
var _util = require('./util');
37-
3836
/**
3937
* Create a new WebSocketChannel to be used in web browsers.
4038
* @access private
@@ -57,15 +55,12 @@ var WebSocketChannel = (function () {
5755
this._error = null;
5856
this._handleConnectionError = this._handleConnectionError.bind(this);
5957

60-
this._encrypted = opts.encrypted;
61-
6258
var scheme = "ws";
63-
//Allow boolean for backwards compatibility
64-
if (opts.encrypted === true || opts.encrypted === _util.ENCRYPTION_ON || opts.encrypted === _util.ENCRYPTION_NON_LOCAL && !(0, _util.isLocalHost)(opts.host)) {
59+
if (opts.encrypted) {
6560
if (!opts.trust || opts.trust === "TRUST_SIGNED_CERTIFICATES") {
6661
scheme = "wss";
6762
} else {
68-
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.");
63+
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:false` in the driver configuration.");
6964
return;
7065
}
7166
}
@@ -111,11 +106,6 @@ var WebSocketChannel = (function () {
111106
}
112107
}
113108
}
114-
}, {
115-
key: "isEncrypted",
116-
value: function isEncrypted() {
117-
return this._encrypted;
118-
}
119109

120110
/**
121111
* Write the passed in buffer to connection

lib/v1/internal/connector.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ var _integer = require('../integer');
5959

6060
var _error = require('./../error');
6161

62-
var _util = require('./util');
63-
6462
var Channel = undefined;
6563
if (_chWebsocket2["default"].available) {
6664
Channel = _chWebsocket2["default"].channel;
@@ -469,11 +467,6 @@ var Connection = (function () {
469467
value: function isOpen() {
470468
return !this._isBroken && this._ch._open;
471469
}
472-
}, {
473-
key: "isEncrypted",
474-
value: function isEncrypted() {
475-
return this._ch.isEncrypted();
476-
}
477470

478471
/**
479472
* Call close on the channel.
@@ -496,9 +489,9 @@ function connect(url) {
496489
return new Connection(new Ch({
497490
host: host(url),
498491
port: port(url) || 7687,
499-
// Default to using ENCRYPTION_NON_LOCAL if trust-on-first-use is available
500-
encrypted: (0, _util.shouldEncrypt)(config.encrypted, (0, _features2["default"])("trust_on_first_use") ? _util.ENCRYPTION_NON_LOCAL : _util.ENCRYPTION_OFF, host(url)),
501-
// Default to using TRUST_ON_FIRST_USE if it is available
492+
// Default to using encryption if trust-on-first-use is available
493+
encrypted: config.encrypted == null ? (0, _features2["default"])("trust_on_first_use") : config.encrypted,
494+
// Default to using trust-on-first-use if it is available
502495
trust: config.trust || ((0, _features2["default"])("trust_on_first_use") ? "TRUST_ON_FIRST_USE" : "TRUST_SIGNED_CERTIFICATES"),
503496
trustedCertificates: config.trustedCertificates || [],
504497
knownHosts: config.knownHosts

lib/v1/internal/util.js

+1-30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* Copyright (c) 2002-2016 "Neo Technology,"
34
* Network Engine for Objects in Lund AB [http://neotechnology.com]
@@ -31,37 +32,7 @@ function isLocalHost(host) {
3132
return LOCALHOST_MATCHER.test(host);
3233
}
3334

34-
/* Coerce an encryption setting to a definitive boolean value,
35-
* given a valid default and a target host. If encryption is
36-
* explicitly set on or off, then the mapping is a simple
37-
* conversion to true or false respectively. If set to
38-
* ENCRYPTION_NON_LOCAL then respond according to whether or
39-
* not the host is localhost/127.x.x.x. In all other cases
40-
* (including undefined) then fall back to the default and
41-
* re-evaluate.
42-
*/
43-
function shouldEncrypt(_x, _x2, _x3) {
44-
var _again = true;
45-
46-
_function: while (_again) {
47-
var encryption = _x,
48-
encryptionDefault = _x2,
49-
host = _x3;
50-
_again = false;
51-
52-
if (encryption === ENCRYPTION_ON || encryption === true) return true;
53-
if (encryption === ENCRYPTION_OFF || encryption === false) return false;
54-
if (encryption === ENCRYPTION_NON_LOCAL) return !isLocalHost(host);
55-
_x = encryptionDefault;
56-
_x2 = ENCRYPTION_OFF;
57-
_x3 = host;
58-
_again = true;
59-
continue _function;
60-
}
61-
}
62-
6335
exports.isLocalHost = isLocalHost;
64-
exports.shouldEncrypt = shouldEncrypt;
6536
exports.ENCRYPTION_ON = ENCRYPTION_ON;
6637
exports.ENCRYPTION_OFF = ENCRYPTION_OFF;
6738
exports.ENCRYPTION_NON_LOCAL = ENCRYPTION_NON_LOCAL;

lib/v1/record.js

-34
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,6 @@ var Record = (function () {
9797
}
9898
}
9999

100-
/**
101-
* Generates an object out of the current Record
102-
*
103-
* @returns {Object}
104-
*/
105-
}, {
106-
key: "toObject",
107-
value: function toObject() {
108-
var object = {};
109-
this.forEach(function (value, key) {
110-
object[key] = value;
111-
});
112-
113-
return object;
114-
}
115-
116100
/**
117101
* Get a value from this record, either by index or by field key.
118102
*
@@ -138,24 +122,6 @@ var Record = (function () {
138122

139123
return this._fields[index];
140124
}
141-
142-
/**
143-
* Check if a value from this record, either by index or by field key, exists.
144-
*
145-
* @param {string|Number} key Field key, or the index of the field.
146-
* @returns {boolean}
147-
*/
148-
}, {
149-
key: "has",
150-
value: function has(key) {
151-
// if key is a number, we check if it is in the _fields array
152-
if (typeof key === "number") {
153-
return key >= 0 && key < this._fields.length;
154-
}
155-
156-
// if it's not a number, we check _fieldLookup dictionary directly
157-
return this._fieldLookup[key] !== undefined;
158-
}
159125
}]);
160126

161127
return Record;

lib/v1/session.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,16 @@ var Session = (function () {
6464
this._hasTx = false;
6565
}
6666

67-
_createClass(Session, [{
68-
key: 'isEncrypted',
69-
value: function isEncrypted() {
70-
return this._conn.isEncrypted();
71-
}
67+
/**
68+
* Run Cypher statement
69+
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
70+
* or with the statement and parameters as separate arguments.
71+
* @param {mixed} statement - Cypher statement to execute
72+
* @param {Object} parameters - Map with parameters to use in statement
73+
* @return {Result} - New Result
74+
*/
7275

73-
/**
74-
* Run Cypher statement
75-
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
76-
* or with the statement and parameters as separate arguments.
77-
* @param {mixed} statement - Cypher statement to execute
78-
* @param {Object} parameters - Map with parameters to use in statement
79-
* @return {Result} - New Result
80-
*/
81-
}, {
76+
_createClass(Session, [{
8277
key: 'run',
8378
value: function run(statement) {
8479
var parameters = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

0 commit comments

Comments
 (0)