Skip to content

Commit 8f9e279

Browse files
committed
JS driver v1.3.0-beta01: Checking in transpiled files for bower
1 parent fa2ce28 commit 8f9e279

20 files changed

+12215
-4756
lines changed

lib/browser/neo4j-web.js

Lines changed: 1299 additions & 731 deletions
Large diffs are not rendered by default.

lib/browser/neo4j-web.min.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

Lines changed: 9925 additions & 3704 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/driver.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ var Driver = function () {
103103
this._token = token;
104104
this._config = config;
105105
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
106-
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));
106+
107+
/**
108+
* Reference to the connection provider. Initialized lazily by {@link _getOrCreateConnectionProvider}.
109+
* @type {ConnectionProvider}
110+
* @private
111+
*/
112+
this._connectionProvider = null;
107113
}
108114

109115
/**
@@ -117,7 +123,7 @@ var Driver = function () {
117123
key: '_createConnection',
118124
value: function _createConnection(url, release) {
119125
var sessionId = this._sessionIdGenerator++;
120-
var conn = (0, _connector.connect)(url, this._config);
126+
var conn = (0, _connector.connect)(url, this._config, this._connectionErrorCode());
121127
var streamObserver = new _ConnectionStreamObserver(this, conn);
122128
conn.initialize(this._userAgent, this._token, streamObserver);
123129
conn._id = sessionId;
@@ -170,24 +176,43 @@ var Driver = function () {
170176
key: 'session',
171177
value: function session(mode, bookmark) {
172178
var sessionMode = Driver._validateSessionMode(mode);
173-
return this._createSession(sessionMode, this._connectionProvider, bookmark, this._config);
179+
var connectionProvider = this._getOrCreateConnectionProvider();
180+
return this._createSession(sessionMode, connectionProvider, bookmark, this._config);
174181
}
175182
}, {
176183
key: '_createConnectionProvider',
177184

178185

179-
//Extension point
186+
// Extension point
180187
value: function _createConnectionProvider(address, connectionPool, driverOnErrorCallback) {
181188
return new _connectionProviders.DirectConnectionProvider(address, connectionPool, driverOnErrorCallback);
182189
}
183190

184-
//Extension point
191+
// Extension point
185192

186193
}, {
187194
key: '_createSession',
188195
value: function _createSession(mode, connectionProvider, bookmark, config) {
189196
return new _session2.default(mode, connectionProvider, bookmark, config);
190197
}
198+
199+
// Extension point
200+
201+
}, {
202+
key: '_connectionErrorCode',
203+
value: function _connectionErrorCode() {
204+
// connection errors might result in different error codes depending on the driver
205+
return _error.SERVICE_UNAVAILABLE;
206+
}
207+
}, {
208+
key: '_getOrCreateConnectionProvider',
209+
value: function _getOrCreateConnectionProvider() {
210+
if (!this._connectionProvider) {
211+
var driverOnErrorCallback = this._driverOnErrorCallback.bind(this);
212+
this._connectionProvider = this._createConnectionProvider(this._url, this._pool, driverOnErrorCallback);
213+
}
214+
return this._connectionProvider;
215+
}
191216
}, {
192217
key: '_driverOnErrorCallback',
193218
value: function _driverOnErrorCallback(error) {
@@ -267,8 +292,9 @@ var _ConnectionStreamObserver = function (_StreamObserver) {
267292
if (this._driver.onCompleted) {
268293
this._driver.onCompleted(message);
269294
}
270-
if (this._conn && message && message.server) {
271-
this._conn.setServerVersion(message.server);
295+
296+
if (this._observer && this._observer.onComplete) {
297+
this._observer.onCompleted(message);
272298
}
273299
}
274300
}]);

lib/v1/index.js

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,51 +33,59 @@ var _version = require('../version');
3333

3434
var _version2 = _interopRequireDefault(_version);
3535

36-
var _connector = require('./internal/connector');
37-
3836
var _util = require('./internal/util');
3937

4038
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4139

40+
/**
41+
* Copyright (c) 2002-2017 "Neo Technology,","
42+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
43+
*
44+
* This file is part of Neo4j.
45+
*
46+
* Licensed under the Apache License, Version 2.0 (the "License");
47+
* you may not use this file except in compliance with the License.
48+
* You may obtain a copy of the License at
49+
*
50+
* http://www.apache.org/licenses/LICENSE-2.0
51+
*
52+
* Unless required by applicable law or agreed to in writing, software
53+
* distributed under the License is distributed on an "AS IS" BASIS,
54+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55+
* See the License for the specific language governing permissions and
56+
* limitations under the License.
57+
*/
58+
4259
var auth = {
4360
basic: function basic(username, password) {
4461
var realm = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
4562

4663
if (realm) {
47-
return { scheme: "basic", principal: username, credentials: password, realm: realm };
64+
return { scheme: 'basic', principal: username, credentials: password, realm: realm };
4865
} else {
49-
return { scheme: "basic", principal: username, credentials: password };
66+
return { scheme: 'basic', principal: username, credentials: password };
5067
}
5168
},
69+
kerberos: function kerberos(base64EncodedTicket) {
70+
return {
71+
scheme: 'kerberos',
72+
principal: '', // This empty string is required for backwards compatibility.
73+
credentials: base64EncodedTicket
74+
};
75+
},
5276
custom: function custom(principal, credentials, realm, scheme) {
5377
var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
5478

5579
if (parameters) {
56-
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm,
57-
parameters: parameters };
80+
return {
81+
scheme: scheme, principal: principal, credentials: credentials, realm: realm,
82+
parameters: parameters
83+
};
5884
} else {
5985
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
6086
}
6187
}
62-
}; /**
63-
* Copyright (c) 2002-2017 "Neo Technology,","
64-
* Network Engine for Objects in Lund AB [http://neotechnology.com]
65-
*
66-
* This file is part of Neo4j.
67-
*
68-
* Licensed under the Apache License, Version 2.0 (the "License");
69-
* you may not use this file except in compliance with the License.
70-
* You may obtain a copy of the License at
71-
*
72-
* http://www.apache.org/licenses/LICENSE-2.0
73-
*
74-
* Unless required by applicable law or agreed to in writing, software
75-
* distributed under the License is distributed on an "AS IS" BASIS,
76-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77-
* See the License for the specific language governing permissions and
78-
* limitations under the License.
79-
*/
80-
88+
};
8189
var USER_AGENT = "neo4j-javascript/" + _version2.default;
8290

8391
/**
@@ -152,13 +160,17 @@ function driver(url, authToken) {
152160
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
153161

154162
(0, _util.assertString)(url, 'Bolt URL');
155-
var scheme = (0, _connector.parseScheme)(url);
156-
if (scheme === "bolt+routing://") {
157-
return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
158-
} else if (scheme === "bolt://") {
159-
return new _driver.Driver((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
163+
var scheme = (0, _util.parseScheme)(url);
164+
var routingContext = (0, _util.parseRoutingContext)(url);
165+
if (scheme === 'bolt+routing://') {
166+
return new _routingDriver2.default((0, _util.parseUrl)(url), routingContext, USER_AGENT, authToken, config);
167+
} else if (scheme === 'bolt://') {
168+
if (!(0, _util.isEmptyObjectOrNull)(routingContext)) {
169+
throw new Error('Parameters are not supported with scheme \'bolt\'. Given URL: \'' + url + '\'');
170+
}
171+
return new _driver.Driver((0, _util.parseUrl)(url), USER_AGENT, authToken, config);
160172
} else {
161-
throw new Error("Unknown scheme: " + scheme);
173+
throw new Error('Unknown scheme: ' + scheme);
162174
}
163175
}
164176

lib/v1/internal/ch-config.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
8+
9+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
10+
11+
var _createClass2 = require('babel-runtime/helpers/createClass');
12+
13+
var _createClass3 = _interopRequireDefault(_createClass2);
14+
15+
var _features = require('./features');
16+
17+
var _features2 = _interopRequireDefault(_features);
18+
19+
var _error = require('../error');
20+
21+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22+
23+
/**
24+
* Copyright (c) 2002-2017 "Neo Technology,","
25+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
26+
*
27+
* This file is part of Neo4j.
28+
*
29+
* Licensed under the Apache License, Version 2.0 (the "License");
30+
* you may not use this file except in compliance with the License.
31+
* You may obtain a copy of the License at
32+
*
33+
* http://www.apache.org/licenses/LICENSE-2.0
34+
*
35+
* Unless required by applicable law or agreed to in writing, software
36+
* distributed under the License is distributed on an "AS IS" BASIS,
37+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38+
* See the License for the specific language governing permissions and
39+
* limitations under the License.
40+
*/
41+
42+
var ChannelConfig = function () {
43+
function ChannelConfig(host, port, driverConfig, connectionErrorCode) {
44+
(0, _classCallCheck3.default)(this, ChannelConfig);
45+
46+
this.host = host;
47+
this.port = port;
48+
this.encrypted = ChannelConfig._extractEncrypted(driverConfig);
49+
this.trust = ChannelConfig._extractTrust(driverConfig);
50+
this.trustedCertificates = ChannelConfig._extractTrustedCertificates(driverConfig);
51+
this.knownHostsPath = ChannelConfig._extractKnownHostsPath(driverConfig);
52+
this.connectionErrorCode = connectionErrorCode || _error.SERVICE_UNAVAILABLE;
53+
}
54+
55+
(0, _createClass3.default)(ChannelConfig, null, [{
56+
key: '_extractEncrypted',
57+
value: function _extractEncrypted(driverConfig) {
58+
// check if encryption was configured by the user, use explicit null check because we permit boolean value
59+
var encryptionConfigured = driverConfig.encrypted == null;
60+
// default to using encryption if trust-all-certificates is available
61+
return encryptionConfigured ? (0, _features2.default)('trust_all_certificates') : driverConfig.encrypted;
62+
}
63+
}, {
64+
key: '_extractTrust',
65+
value: function _extractTrust(driverConfig) {
66+
if (driverConfig.trust) {
67+
return driverConfig.trust;
68+
}
69+
// default to using TRUST_ALL_CERTIFICATES if it is available
70+
return (0, _features2.default)('trust_all_certificates') ? 'TRUST_ALL_CERTIFICATES' : 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES';
71+
}
72+
}, {
73+
key: '_extractTrustedCertificates',
74+
value: function _extractTrustedCertificates(driverConfig) {
75+
return driverConfig.trustedCertificates || [];
76+
}
77+
}, {
78+
key: '_extractKnownHostsPath',
79+
value: function _extractKnownHostsPath(driverConfig) {
80+
return driverConfig.knownHosts || null;
81+
}
82+
}]);
83+
return ChannelConfig;
84+
}();
85+
86+
exports.default = ChannelConfig;
87+
;

lib/v1/internal/ch-dummy.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ var observer = {
4242
*/
4343

4444
var DummyChannel = function () {
45-
function DummyChannel(opts) {
45+
46+
/**
47+
* @constructor
48+
* @param {ChannelConfig} config - configuration for the new channel.
49+
*/
50+
function DummyChannel(config) {
4651
(0, _classCallCheck3.default)(this, DummyChannel);
4752

4853
this.written = [];

0 commit comments

Comments
 (0)