Commit 60efe9d 1 parent 9244b17 commit 60efe9d Copy full SHA for 60efe9d
File tree 6 files changed +30
-21
lines changed
6 files changed +30
-21
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const url = require('url');
9
9
10
10
let aws4 ;
11
11
try {
12
+ // Ensure you always wrap an optional require in the try block NODE-3199
12
13
aws4 = require ( 'aws4' ) ;
13
14
} catch ( e ) {
14
15
// don't do anything;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const Binary = BSON.Binary;
11
11
12
12
let saslprep ;
13
13
try {
14
+ // Ensure you always wrap an optional require in the try block NODE-3199
14
15
saslprep = require ( 'saslprep' ) ;
15
16
} catch ( e ) {
16
17
// don't do anything;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const require_optional = require('optional-require')(require);
5
5
const EJSON = require ( './utils' ) . retrieveEJSON ( ) ;
6
6
7
7
try {
8
+ // Ensure you always wrap an optional require in the try block NODE-3199
8
9
// Attempt to grab the native BSON parser
9
10
const BSONNative = require_optional ( 'bson-ext' ) ;
10
11
// If we got the native parser, use it instead of the
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ function retrieveKerberos() {
27
27
let kerberos ;
28
28
29
29
try {
30
+ // Ensure you always wrap an optional require in the try block NODE-3199
30
31
kerberos = requireOptional ( 'kerberos' ) ;
31
32
} catch ( err ) {
32
33
if ( err . code === 'MODULE_NOT_FOUND' ) {
Original file line number Diff line number Diff line change @@ -3,22 +3,27 @@ const MongoClient = require('./mongo_client');
3
3
const BSON = require ( './core/connection/utils' ) . retrieveBSON ( ) ;
4
4
const MongoError = require ( './core/error' ) . MongoError ;
5
5
6
+ let mongodbClientEncryption = undefined ;
6
7
try {
7
- require . resolve ( 'mongodb-client-encryption' ) ;
8
+ // Ensure you always wrap an optional require in the try block NODE-3199
9
+ mongodbClientEncryption = require ( 'mongodb-client-encryption' ) ;
8
10
} catch ( err ) {
9
11
throw new MongoError (
10
12
'Auto-encryption requested, but the module is not installed. ' +
11
13
'Please add `mongodb-client-encryption` as a dependency of your project'
12
14
) ;
13
15
}
14
16
15
- const mongodbClientEncryption = require ( 'mongodb-client-encryption' ) ;
16
- if ( typeof mongodbClientEncryption . extension !== 'function' ) {
17
+ if (
18
+ mongodbClientEncryption === undefined ||
19
+ typeof mongodbClientEncryption . extension !== 'function'
20
+ ) {
17
21
throw new MongoError (
18
22
'loaded version of `mongodb-client-encryption` does not have property `extension`. ' +
19
23
'Please make sure you are loading the correct version of `mongodb-client-encryption`'
20
24
) ;
21
25
}
26
+
22
27
const AutoEncrypter = mongodbClientEncryption . extension ( require ( '../index' ) ) . AutoEncrypter ;
23
28
24
29
const kInternalClient = Symbol ( 'internalClient' ) ;
You can’t perform that action at this time.
0 commit comments