Skip to content

Commit 0f559ef

Browse files
committed
Fixes for HTTPS
1 parent e2f512f commit 0f559ef

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

examples/neo4j.html

+11-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
padding: 0 2px;
9494
}
9595
</style>
96-
<script src="../lib/browser/neo4j-web.min.js"></script>
96+
<script src="../lib/browser/neo4j-web.js"></script>
9797
</head>
9898
<body>
9999

@@ -131,7 +131,11 @@ <h1>Cypher Runner for New Remoting</h1>
131131
</div>
132132

133133
<script>
134-
var driver = neo4j.driver("bolt+ws://localhost");
134+
var authToken = neo4j.v1.auth.basic("neo4j", "neo4j");
135+
console.log(authToken);
136+
var driver = neo4j.v1.driver("bolt://localhost", authToken, {
137+
encrypted:true
138+
});
135139
var session = driver.session();
136140

137141
function run() {
@@ -143,13 +147,14 @@ <h1>Cypher Runner for New Remoting</h1>
143147
onNext: function(record) {
144148
// On receipt of RECORD
145149
var tr = document.createElement("tr");
146-
for(var i in record) {
150+
record.forEach( function( value ) {
147151
var td = document.createElement("td");
148-
td.appendChild(document.createTextNode(record[i]));
152+
td.appendChild(document.createTextNode(value));
149153
tr.appendChild(td);
150-
}
154+
});
151155
table.appendChild(tr);
152-
}, onCompleted: function(metadata) {
156+
},
157+
onCompleted: function(metadata) {
153158

154159
}
155160
});

src/v1/graph-types.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Relationship {
7373
}
7474

7575
toString() {
76-
let s = "(" + this.start.split('/')[1] + ")-[:" + this.type;
76+
let s = "(" + this.start + ")-[:" + this.type;
7777
let keys = Object.keys(this.properties);
7878
if (keys.length > 0) {
7979
s += " {";
@@ -83,7 +83,7 @@ class Relationship {
8383
}
8484
s += "}";
8585
}
86-
s += "]->(" + this.end.split('/')[1] + ")";
86+
s += "]->(" + this.end + ")";
8787
return s;
8888
}
8989
}

src/v1/internal/ch-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const TrustStrategy = {
100100
};
101101

102102
let socket = tls.connect(opts.port, opts.host, tlsOpts, function () {
103-
var serverCert = socket.getPeerCertificate(true);
103+
var serverCert = socket.getPeerCertificate(raw=true);
104104

105105
if( !serverCert.raw ) {
106106
// If `raw` is not available, we're on an old version of NodeJS, and

src/v1/internal/ch-websocket.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class WebSocketChannel {
3838
this._open = true;
3939
this._pending = [];
4040
this._error = null;
41+
this._handleConnectionError = this._handleConnectionError.bind(this);
4142

4243
let scheme = "ws";
4344
if( opts.encrypted ) {
@@ -48,12 +49,12 @@ class WebSocketChannel {
4849
"strategy, 'TRUST_SIGNED_CERTIFICATES'. "+opts.trust+" is not supported. Please " +
4950
"either use TRUST_SIGNED_CERTIFICATES or disable encryption by setting " +
5051
"`encrypted:false` in the driver configuration.");
52+
return;
5153
}
5254
}
5355
this._url = scheme + ":" + opts.host + ":" + opts.port;
5456
this._ws = new WebSocket(this._url);
5557
this._ws.binaryType = "arraybuffer";
56-
this._handleConnectionError = this._handleConnectionError.bind(this);
5758

5859
let self = this;
5960
this._ws.onopen = function() {
@@ -83,9 +84,10 @@ class WebSocketChannel {
8384
"to this Neo4j Driver. Please use your browsers development console to determine " +
8485
"the root cause of the failure. Common reasons include the database being " +
8586
"unavailable, using the wrong connection URL or temporary network problems. " +
86-
"WebSocket `readyState` is: " + this._ws.readyState );
87+
"If you have enabled encryption, ensure your browser is configured to trust the " +
88+
"certificate Neo4j is configured to use. WebSocket `readyState` is: " + this._ws.readyState );
8789
if (this.onerror) {
88-
this.onerror(error);
90+
this.onerror(this._error);
8991
}
9092
}
9193
}

src/v1/result.js

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Result {
4646
/**
4747
* Create and return new Promise
4848
* @return {Promise} new Promise.
49+
* @access private
4950
*/
5051
_createPromise() {
5152
if(this._p) {
@@ -106,6 +107,9 @@ class Result {
106107
onCompletedOriginal.call(observer, sum);
107108
};
108109
observer.onCompleted = onCompletedWrapper;
110+
observer.onError = observer.onError || ((err) => {
111+
console.log("Uncaught error when processing result: " + err);
112+
});
109113
this._streamObserver.subscribe(observer);
110114
}
111115
}

0 commit comments

Comments
 (0)