Skip to content

Commit 5ace101

Browse files
committed
Remove deprecated API
1 parent e1b28f3 commit 5ace101

16 files changed

+11
-603
lines changed

src/index.js

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,42 +103,23 @@ const logging = {
103103
* // TRUST_ALL_CERTIFICATES is the default choice for NodeJS deployments. It only requires
104104
* // new host to provide a certificate and does no verification of the provided certificate.
105105
* //
106-
* // TRUST_ON_FIRST_USE is available for modern NodeJS deployments, and works
107-
* // similarly to how `ssl` works - the first time we connect to a new host,
108-
* // we remember the certificate they use. If the certificate ever changes, we
109-
* // assume it is an attempt to hijack the connection and require manual intervention.
110-
* // This means that by default, connections "just work" while still giving you
111-
* // good encrypted protection.
112-
* //
113106
* // TRUST_CUSTOM_CA_SIGNED_CERTIFICATES is the classic approach to trust verification -
114107
* // whenever we establish an encrypted connection, we ensure the host is using
115108
* // an encryption certificate that is in, or is signed by, a certificate listed
116109
* // as trusted. In the web bundle, this list of trusted certificates is maintained
117110
* // by the web browser. In NodeJS, you configure the list with the next config option.
118111
* //
119112
* // TRUST_SYSTEM_CA_SIGNED_CERTIFICATES means that you trust whatever certificates
120-
* // are in the default certificate chain of th
121-
* trust: "TRUST_ALL_CERTIFICATES" | "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES" |
122-
* "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" | "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
113+
* // are in the default certificate chain of the underlying system.
114+
* trust: "TRUST_ALL_CERTIFICATES" | "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" |
115+
* "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
123116
*
124117
* // List of one or more paths to trusted encryption certificates. This only
125118
* // works in the NodeJS bundle, and only matters if you use "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES".
126119
* // The certificate files should be in regular X.509 PEM format.
127120
* // For instance, ['./trusted.pem']
128121
* trustedCertificates: [],
129122
*
130-
* // Path to a file where the driver saves hosts it has seen in the past, this is
131-
* // very similar to the ssl tool's known_hosts file. Each time we connect to a
132-
* // new host, a hash of their certificate is stored along with the domain name and
133-
* // port, and this is then used to verify the host certificate does not change.
134-
* // This setting has no effect unless TRUST_ON_FIRST_USE is enabled.
135-
* knownHosts:"~/.neo4j/known_hosts",
136-
*
137-
* // The max number of connections that are allowed idle in the pool at any time.
138-
* // Connection will be destroyed if this threshold is exceeded.
139-
* // **Deprecated:** please use `maxConnectionPoolSize` instead.
140-
* connectionPoolSize: 100,
141-
*
142123
* // The maximum total number of connections allowed to be managed by the connection pool, per host.
143124
* // This includes both in-use and idle connections. No maximum connection pool size is imposed
144125
* // by default.
@@ -164,12 +145,6 @@ const logging = {
164145
* // Default value is 30000 which is 30 seconds.
165146
* maxTransactionRetryTime: 30000, // 30 seconds
166147
*
167-
* // Provide an alternative load balancing strategy for the routing driver to use.
168-
* // Driver uses "least_connected" by default.
169-
* // **Note:** We are experimenting with different strategies. This could be removed in the next minor
170-
* // version.
171-
* loadBalancingStrategy: "least_connected" | "round_robin",
172-
*
173148
* // Specify socket connection timeout in milliseconds. Numeric values are expected. Negative and zero values
174149
* // result in no timeout being applied. Connection establishment will be then bound by the timeout configured
175150
* // on the operating system level. Default value is 5000, which is 5 seconds.

src/internal/channel-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 5000; // 5 seconds by default
2424

2525
const ALLOWED_VALUES_ENCRYPTED = [null, undefined, true, false, ENCRYPTION_ON, ENCRYPTION_OFF];
2626

27-
const ALLOWED_VALUES_TRUST = [null, undefined, 'TRUST_ALL_CERTIFICATES', 'TRUST_ON_FIRST_USE',
28-
'TRUST_SIGNED_CERTIFICATES', 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES', 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'];
27+
const ALLOWED_VALUES_TRUST = [null, undefined, 'TRUST_ALL_CERTIFICATES',
28+
'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES', 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'];
2929

3030
export default class ChannelConfig {
3131

src/internal/node/node-channel.js

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ function storeFingerprint( serverId, knownHostsPath, fingerprint, cb ) {
106106
}
107107

108108
const TrustStrategy = {
109-
/**
110-
* @deprecated Since version 1.0. Will be deleted in a future version. {@link #TRUST_CUSTOM_CA_SIGNED_CERTIFICATES}.
111-
*/
112-
TRUST_SIGNED_CERTIFICATES: function( config, onSuccess, onFailure ) {
113-
console.warn('`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of ' +
114-
"the driver. Please use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead.");
115-
return TrustStrategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(config, onSuccess, onFailure);
116-
},
117109
TRUST_CUSTOM_CA_SIGNED_CERTIFICATES : function( config, onSuccess, onFailure ) {
118110
if( !config.trustedCertificates || config.trustedCertificates.length === 0 ) {
119111
onFailure(newError("You are using TRUST_CUSTOM_CA_SIGNED_CERTIFICATES as the method " +
@@ -159,62 +151,6 @@ const TrustStrategy = {
159151
socket.on('error', onFailure);
160152
return configureSocket(socket);
161153
},
162-
/**
163-
* @deprecated in 1.1 in favour of {@link #TRUST_ALL_CERTIFICATES}. Will be deleted in a future version.
164-
*/
165-
TRUST_ON_FIRST_USE : function( config, onSuccess, onFailure ) {
166-
console.warn('`TRUST_ON_FIRST_USE` has been deprecated as option and will be removed in a future version of ' +
167-
"the driver. Please use `TRUST_ALL_CERTIFICATES` instead.");
168-
169-
const tlsOpts = newTlsOptions(config.url.host);
170-
const socket = tls.connect(config.url.port, config.url.host, tlsOpts, function () {
171-
const serverCert = socket.getPeerCertificate(/*raw=*/true);
172-
173-
if( !serverCert.raw ) {
174-
// If `raw` is not available, we're on an old version of NodeJS, and
175-
// the raw cert cannot be accessed (or, at least I couldn't find a way to)
176-
// therefore, we can't generate a SHA512 fingerprint, meaning we can't
177-
// do TOFU, and the safe approach is to fail.
178-
onFailure(newError("You are using a version of NodeJS that does not " +
179-
"support trust-on-first use encryption. You can either upgrade NodeJS to " +
180-
"a newer version, use `trust:TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` in your driver " +
181-
"config instead, or disable encryption using `encrypted:\"" + ENCRYPTION_OFF+ "\"`."));
182-
return;
183-
}
184-
185-
const serverFingerprint = crypto.createHash('sha512').update(serverCert.raw).digest('hex');
186-
const knownHostsPath = config.knownHostsPath || path.join(userHome(), ".neo4j", "known_hosts");
187-
const serverId = config.url.hostAndPort;
188-
189-
loadFingerprint(serverId, knownHostsPath, (knownFingerprint) => {
190-
if( knownFingerprint === serverFingerprint ) {
191-
onSuccess();
192-
} else if( knownFingerprint == null ) {
193-
storeFingerprint( serverId, knownHostsPath, serverFingerprint, (err) => {
194-
if (err) {
195-
return onFailure(err);
196-
}
197-
return onSuccess();
198-
});
199-
} else {
200-
onFailure(newError("Database encryption certificate has changed, and no longer " +
201-
"matches the certificate stored for " + serverId + " in `" + knownHostsPath +
202-
"`. As a security precaution, this driver will not automatically trust the new " +
203-
"certificate, because doing so would allow an attacker to pretend to be the Neo4j " +
204-
"instance we want to connect to. The certificate provided by the server looks like: " +
205-
serverCert + ". If you trust that this certificate is valid, simply remove the line " +
206-
"starting with " + serverId + " in `" + knownHostsPath + "`, and the driver will " +
207-
"update the file with the new certificate. You can configure which file the driver " +
208-
"should use to store this information by setting `knownHosts` to another path in " +
209-
"your driver configuration - and you can disable encryption there as well using " +
210-
"`encrypted:\"" + ENCRYPTION_OFF + "\"`."))
211-
}
212-
});
213-
});
214-
socket.on('error', onFailure);
215-
return configureSocket(socket);
216-
},
217-
218154
TRUST_ALL_CERTIFICATES: function (config, onSuccess, onFailure) {
219155
const tlsOpts = newTlsOptions(config.url.host);
220156
const socket = tls.connect(config.url.port, config.url.host, tlsOpts, function () {

src/internal/pool-config.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,8 @@ export default class PoolConfig {
3232
}
3333

3434
static fromDriverConfig(config) {
35-
const maxIdleSizeConfigured = isConfigured(config.connectionPoolSize);
3635
const maxSizeConfigured = isConfigured(config.maxConnectionPoolSize);
37-
38-
let maxSize;
39-
40-
if (maxSizeConfigured) {
41-
// correct size setting is set - use it's value
42-
maxSize = config.maxConnectionPoolSize;
43-
} else if (maxIdleSizeConfigured) {
44-
// deprecated size setting is set - use it's value
45-
console.warn('WARNING: neo4j-driver setting "connectionPoolSize" is deprecated, please use "maxConnectionPoolSize" instead');
46-
maxSize = config.connectionPoolSize;
47-
} else {
48-
maxSize = DEFAULT_MAX_SIZE;
49-
}
50-
36+
const maxSize = maxSizeConfigured ? config.maxConnectionPoolSize : DEFAULT_MAX_SIZE;
5137
const acquisitionTimeoutConfigured = isConfigured(config.connectionAcquisitionTimeout);
5238
const acquisitionTimeout = acquisitionTimeoutConfigured ? config.connectionAcquisitionTimeout : DEFAULT_ACQUISITION_TIMEOUT;
5339

src/internal/round-robin-load-balancing-strategy.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/routing-driver.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {Driver} from './driver';
2121
import {newError, SESSION_EXPIRED} from './error';
2222
import {LoadBalancer} from './internal/connection-providers';
2323
import LeastConnectedLoadBalancingStrategy, {LEAST_CONNECTED_STRATEGY_NAME} from './internal/least-connected-load-balancing-strategy';
24-
import RoundRobinLoadBalancingStrategy, {ROUND_ROBIN_STRATEGY_NAME} from './internal/round-robin-load-balancing-strategy';
2524
import ConnectionErrorHandler from './internal/connection-error-handler';
2625
import ConfiguredHostNameResolver from './internal/resolver/configured-host-name-resolver';
2726
import {HostNameResolver} from './internal/node';
@@ -75,14 +74,7 @@ class RoutingDriver extends Driver {
7574
* @private
7675
*/
7776
static _createLoadBalancingStrategy(config, connectionPool) {
78-
const configuredValue = config.loadBalancingStrategy;
79-
if (!configuredValue || configuredValue === LEAST_CONNECTED_STRATEGY_NAME) {
80-
return new LeastConnectedLoadBalancingStrategy(connectionPool);
81-
} else if (configuredValue === ROUND_ROBIN_STRATEGY_NAME) {
82-
return new RoundRobinLoadBalancingStrategy();
83-
} else {
84-
throw newError('Unknown load balancing strategy: ' + configuredValue);
85-
}
77+
return new LeastConnectedLoadBalancingStrategy(connectionPool);
8678
}
8779
}
8880

@@ -102,9 +94,6 @@ function createHostNameResolver(config) {
10294
* @returns {object} the given config.
10395
*/
10496
function validateConfig(config) {
105-
if (config.trust === 'TRUST_ON_FIRST_USE') {
106-
throw newError('The chosen trust mode is not compatible with a routing driver');
107-
}
10897
const resolver = config.resolver;
10998
if (resolver && typeof resolver !== 'function') {
11099
throw new TypeError(`Configured resolver should be a function. Got: ${resolver}`);

test/driver.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,6 @@ describe('driver', () => {
216216
routingDriver.close();
217217
});
218218

219-
it('should fail when TRUST_ON_FIRST_USE is used with routing', () => {
220-
const createRoutingDriverWithTOFU = () => {
221-
driver = neo4j.driver('bolt+routing://localhost', sharedNeo4j.username, {
222-
encrypted: "ENCRYPTION_ON",
223-
trust: 'TRUST_ON_FIRST_USE'
224-
});
225-
};
226-
227-
expect(createRoutingDriverWithTOFU).toThrow();
228-
});
229-
230219
it('should fail when bolt:// scheme used with routing params', () => {
231220
expect(() => neo4j.driver('bolt://localhost:7687/?policy=my_policy')).toThrow();
232221
});

test/examples.test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,6 @@ describe('examples', () => {
137137
};
138138
});
139139

140-
it('config load balancing example', done => {
141-
// tag::config-load-balancing-strategy[]
142-
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password),
143-
{
144-
loadBalancingStrategy: "least_connected"
145-
}
146-
);
147-
// end::config-load-balancing-strategy[]
148-
149-
driver.onCompleted = () => {
150-
driver.close();
151-
done();
152-
};
153-
});
154-
155140
it('config max retry time example', done => {
156141
// tag::config-max-retry-time[]
157142
const maxRetryTimeMs = 15 * 1000; // 15 seconds

test/internal/browser/browser-channel.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('WebSocketChannel', () => {
126126
};
127127

128128
const url = urlUtil.parseDatabaseUrl('bolt://localhost:8989');
129-
const driverConfig = {encrypted: true, trust: 'TRUST_ON_FIRST_USE'};
129+
const driverConfig = {encrypted: true, trust: 'TRUST_ALL_CERTIFICATES'};
130130
const channelConfig = new ChannelConfig(url, driverConfig, SERVICE_UNAVAILABLE);
131131

132132
const channel = new WebSocketChannel(channelConfig, protocolSupplier);

test/internal/channel-config.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ describe('ChannelConfig', () => {
147147
expect(new ChannelConfig(null, {trust: null}, '').trust).toBeNull();
148148
expect(new ChannelConfig(null, {trust: undefined}, '').trust).toBeUndefined();
149149
expect(new ChannelConfig(null, {trust: 'TRUST_ALL_CERTIFICATES'}, '').trust).toEqual('TRUST_ALL_CERTIFICATES');
150-
expect(new ChannelConfig(null, {trust: 'TRUST_ON_FIRST_USE'}, '').trust).toEqual('TRUST_ON_FIRST_USE');
151-
expect(new ChannelConfig(null, {trust: 'TRUST_SIGNED_CERTIFICATES'}, '').trust).toEqual('TRUST_SIGNED_CERTIFICATES');
152150
expect(new ChannelConfig(null, {trust: 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'}, '').trust).toEqual('TRUST_CUSTOM_CA_SIGNED_CERTIFICATES');
153151
expect(new ChannelConfig(null, {trust: 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'}, '').trust).toEqual('TRUST_SYSTEM_CA_SIGNED_CERTIFICATES');
154152

0 commit comments

Comments
 (0)