Skip to content

Commit 0875e3a

Browse files
committed
Remove unused or alias options
1 parent 167850d commit 0875e3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+808
-1045
lines changed

src/cmap/auth/mongo_credentials.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Resolves the default auth mechanism according to
22

33
import type { Document } from '../../bson';
4+
import { MongoParseError } from '../../error';
45
import { AuthMechanism, AuthMechanismEnum } from './defaultAuthProviders';
56

67
// https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst
@@ -108,4 +109,37 @@ export class MongoCredentials {
108109

109110
return this;
110111
}
112+
113+
validate(): void {
114+
if (
115+
(this.mechanism === 'GSSAPI' ||
116+
this.mechanism === 'MONGODB-CR' ||
117+
this.mechanism === 'PLAIN' ||
118+
this.mechanism === 'SCRAM-SHA-1' ||
119+
this.mechanism === 'SCRAM-SHA-256') &&
120+
!this.username
121+
) {
122+
throw new MongoParseError(`Username required for mechanism '${this.mechanism}'`);
123+
}
124+
125+
if (
126+
this.mechanism === 'GSSAPI' ||
127+
this.mechanism === 'MONGODB-AWS' ||
128+
this.mechanism === 'MONGODB-X509'
129+
) {
130+
if (this.source != null && this.source !== '$external') {
131+
throw new MongoParseError(
132+
`Invalid source '${this.source}' for mechanism '${this.mechanism}' specified.`
133+
);
134+
}
135+
}
136+
137+
if (this.mechanism === 'PLAIN' && this.source == null) {
138+
throw new MongoParseError('PLAIN Authentication Mechanism needs an auth source');
139+
}
140+
141+
if (this.mechanism === 'MONGODB-X509' && this.password != null) {
142+
throw new MongoParseError(`Password not allowed for mechanism MONGODB-X509`);
143+
}
144+
}
111145
}

src/connection_string.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,13 @@ function assertRepelOptions(options: AnyOptions, optionKeyA: string, optionKeyB:
529529
* @param options - The options used for options parsing
530530
* @throws MongoParseError if TLS options are invalid
531531
*/
532-
function checkTLSOptions(options: AnyOptions) {
533-
if (!options) return null;
534-
const check = (a: any, b: any) => assertRepelOptions(options, a, b);
532+
export function checkTLSOptions(options: AnyOptions): void {
533+
if (!options) return;
534+
const check = (a: string, b: string) => {
535+
if (Reflect.has(options, a) && Reflect.has(options, b)) {
536+
throw new MongoParseError(`The '${a}' option cannot be used with '${b}'`);
537+
}
538+
};
535539
check('tlsInsecure', 'tlsAllowInvalidCertificates');
536540
check('tlsInsecure', 'tlsAllowInvalidHostnames');
537541
check('tlsInsecure', 'tlsDisableCertificateRevocationCheck');

src/db.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ const legalOptionNames = [
7171
'pkFactory',
7272
'serializeFunctions',
7373
'raw',
74-
'bufferMaxEntries',
7574
'authSource',
7675
'ignoreUndefined',
7776
'promoteLongs',

src/mongo_client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export interface MongoURIOptions extends Pick<WriteConcernOptions, 'journal' | '
127127
serverSelectionTryOnce?: boolean;
128128
/** heartbeatFrequencyMS controls when the driver checks the state of the MongoDB deployment. Specify the interval (in milliseconds) between checks, counted from the end of the previous check until the beginning of the next one. */
129129
heartbeatFrequencyMS?: number;
130+
/** Sets the minimum heartbeat frequency. In the event that the driver has to frequently re-check a server's availability, it will wait at least this long since the previous check to avoid wasted effort. */
131+
minHeartbeatFrequencyMS?: number;
130132
/** The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections */
131133
appName?: string;
132134
/** Enables retryable reads. */
@@ -142,8 +144,6 @@ export interface MongoClientOptions
142144
extends WriteConcernOptions,
143145
MongoURIOptions,
144146
BSONSerializeOptions {
145-
/** The maximum number of connections in the connection pool. */
146-
poolSize?: MongoURIOptions['maxPoolSize'];
147147
/** Validate mongod server certificate against Certificate Authority */
148148
sslValidate?: boolean;
149149
/** SSL Certificate store binary buffer. */
@@ -192,8 +192,6 @@ export interface MongoClientOptions
192192
numberOfRetries?: number;
193193
/** Enable command monitoring for this client */
194194
monitorCommands?: boolean;
195-
/** If present, the connection pool will be initialized with minSize connections, and will never dip below minSize connections */
196-
minSize?: number;
197195
/** Optionally enable client side auto encryption */
198196
autoEncryption?: AutoEncryptionOptions;
199197
/** Allows a wrapping driver to amend the client metadata generated by the driver to include information about the wrapping driver */
@@ -202,6 +200,8 @@ export interface MongoClientOptions
202200
servername?: string;
203201

204202
dbName?: string;
203+
username?: string;
204+
password?: string;
205205
}
206206

207207
/** @public */

src/operations/connect.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const validOptionNames = [
5858
'serializeFunctions',
5959
'ignoreUndefined',
6060
'raw',
61-
'bufferMaxEntries',
6261
'readPreference',
6362
'pkFactory',
6463
'promiseLibrary',
@@ -88,7 +87,6 @@ const validOptionNames = [
8887
'retryReads',
8988
'useNewUrlParser',
9089
'serverSelectionTimeoutMS',
91-
'useRecoveryToken',
9290
'autoEncryption',
9391
'driverInfo',
9492
'tls',
@@ -219,7 +217,6 @@ export function connect(
219217
if (finalOptions.socketTimeoutMS == null) finalOptions.socketTimeoutMS = 0;
220218
if (finalOptions.connectTimeoutMS == null) finalOptions.connectTimeoutMS = 10000;
221219
if (finalOptions.retryWrites == null) finalOptions.retryWrites = true;
222-
if (finalOptions.useRecoveryToken == null) finalOptions.useRecoveryToken = true;
223220
if (finalOptions.readPreference == null) finalOptions.readPreference = 'primary';
224221

225222
if (finalOptions.db_options && finalOptions.db_options.auth) {

src/sdam/common.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ export const TOPOLOGY_DEFAULTS = {
4040
localThresholdMS: 15,
4141
serverSelectionTimeoutMS: 30000,
4242
heartbeatFrequencyMS: 10000,
43-
minHeartbeatFrequencyMS: 500,
44-
45-
// TODO: remove in v4
46-
useRecoveryToken: true
43+
minHeartbeatFrequencyMS: 500
4744
};
4845

4946
/** @internal */

src/sdam/topology.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ export interface TopologyOptions extends ServerOptions, BSONSerializeOptions, Lo
162162
directConnection: boolean;
163163

164164
metadata: ClientMetadata;
165-
useRecoveryToken: boolean;
166165
}
167166

168167
/** @public */

src/sessions.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,8 @@ function endTransaction(session: ClientSession, commandName: string, callback: C
536536
callback(e, r);
537537
}
538538

539-
if (
539+
if (session.transaction.recoveryToken) {
540540
// Assumption here that commandName is "commitTransaction" or "abortTransaction"
541-
session.transaction.recoveryToken &&
542-
supportsRecoveryToken(session)
543-
) {
544541
command.recoveryToken = session.transaction.recoveryToken;
545542
}
546543

@@ -580,11 +577,6 @@ function endTransaction(session: ClientSession, commandName: string, callback: C
580577
);
581578
}
582579

583-
function supportsRecoveryToken(session: ClientSession) {
584-
const topology = session.topology;
585-
return !!topology.s.options.useRecoveryToken;
586-
}
587-
588580
/** @internal */
589581
export type ServerSessionId = { id: Binary };
590582

test/functional/aggregation.test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Aggregation', function () {
2222
},
2323

2424
test: function (done) {
25-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
25+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
2626
databaseName = this.configuration.db;
2727

2828
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -99,7 +99,7 @@ describe('Aggregation', function () {
9999
},
100100

101101
test: function (done) {
102-
const client = this.configuration.newClient({ w: 1 }, { poolSize: 1 });
102+
const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 });
103103

104104
client.connect(function (err, client) {
105105
expect(err).to.not.exist;
@@ -139,7 +139,7 @@ describe('Aggregation', function () {
139139
},
140140

141141
test: function (done) {
142-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
142+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
143143
databaseName = this.configuration.db;
144144

145145
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -227,7 +227,7 @@ describe('Aggregation', function () {
227227
},
228228

229229
test: function (done) {
230-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
230+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
231231
databaseName = this.configuration.db;
232232

233233
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -315,7 +315,7 @@ describe('Aggregation', function () {
315315
},
316316

317317
test: function (done) {
318-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
318+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
319319
databaseName = this.configuration.db;
320320

321321
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -400,7 +400,7 @@ describe('Aggregation', function () {
400400
},
401401

402402
test: function (done) {
403-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
403+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
404404
databaseName = this.configuration.db;
405405

406406
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -488,7 +488,7 @@ describe('Aggregation', function () {
488488
},
489489

490490
test: function (done) {
491-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
491+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
492492
databaseName = this.configuration.db;
493493

494494
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -578,7 +578,7 @@ describe('Aggregation', function () {
578578
},
579579

580580
test: function (done) {
581-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
581+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
582582
databaseName = this.configuration.db;
583583

584584
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -663,7 +663,7 @@ describe('Aggregation', function () {
663663
},
664664

665665
test: function (done) {
666-
var client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
666+
var client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
667667
databaseName = this.configuration.db;
668668

669669
// LINE var MongoClient = require('mongodb').MongoClient;
@@ -751,7 +751,7 @@ describe('Aggregation', function () {
751751
test: function (done) {
752752
var databaseName = this.configuration.db;
753753
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
754-
poolSize: 1
754+
maxPoolSize: 1
755755
});
756756

757757
client.connect(function (err, client) {
@@ -804,7 +804,7 @@ describe('Aggregation', function () {
804804
test: function (done) {
805805
var databaseName = this.configuration.db;
806806
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
807-
poolSize: 1
807+
maxPoolSize: 1
808808
});
809809

810810
client.connect(function (err, client) {
@@ -864,7 +864,7 @@ describe('Aggregation', function () {
864864
test: function (done) {
865865
var databaseName = this.configuration.db;
866866
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
867-
poolSize: 1
867+
maxPoolSize: 1
868868
});
869869

870870
client.connect(function (err, client) {
@@ -939,7 +939,7 @@ describe('Aggregation', function () {
939939
test: function (done) {
940940
var databaseName = this.configuration.db;
941941
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
942-
poolSize: 1
942+
maxPoolSize: 1
943943
});
944944

945945
const testCases = [
@@ -1005,7 +1005,7 @@ describe('Aggregation', function () {
10051005
},
10061006

10071007
test: function (done) {
1008-
const client = this.configuration.newClient({ w: 1 }, { poolSize: 1 }),
1008+
const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
10091009
databaseName = this.configuration.db;
10101010

10111011
// DOC_LINE var db = new Db('test', new Server('localhost', 27017));
@@ -1133,7 +1133,7 @@ describe('Aggregation', function () {
11331133
}
11341134
},
11351135
test: function (done) {
1136-
const client = this.configuration.newClient({ w: 1 }, { poolSize: 1 });
1136+
const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 });
11371137
const databaseName = this.configuration.db;
11381138

11391139
const comment = 'Darmok and Jalad at Tanagra';
@@ -1176,7 +1176,7 @@ describe('Aggregation', function () {
11761176
test: function (done) {
11771177
var databaseName = this.configuration.db;
11781178
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
1179-
poolSize: 1
1179+
maxPoolSize: 1
11801180
});
11811181

11821182
// DOC_LINE var client = new MongoClient(new Server('localhost', 27017));
@@ -1243,7 +1243,7 @@ describe('Aggregation', function () {
12431243
test: function (done) {
12441244
var databaseName = this.configuration.db;
12451245
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
1246-
poolSize: 1
1246+
maxPoolSize: 1
12471247
});
12481248

12491249
// DOC_LINE var client = new MongoClient(new Server('localhost', 27017));
@@ -1284,7 +1284,7 @@ describe('Aggregation', function () {
12841284
test: function (done) {
12851285
const databaseName = this.configuration.db;
12861286
const client = this.configuration.newClient(this.configuration.writeConcernMax(), {
1287-
poolSize: 1,
1287+
maxPoolSize: 1,
12881288
monitorCommands: true
12891289
});
12901290

0 commit comments

Comments
 (0)