Skip to content

Commit 91b2bc4

Browse files
authored
fix(NODE-4556): attempt to use exported BSON (#443)
1 parent fca24fc commit 91b2bc4

7 files changed

+267
-68
lines changed

lib/autoEncrypter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = function (modules) {
88
const MongocryptdManager = require('./mongocryptdManager').MongocryptdManager;
99
const MongoClient = modules.mongodb.MongoClient;
1010
const MongoError = modules.mongodb.MongoError;
11+
const BSON = modules.mongodb.BSON;
1112
const cryptoCallbacks = require('./cryptoCallbacks');
1213

1314
/**
@@ -91,7 +92,7 @@ module.exports = function (modules) {
9192
*/
9293
constructor(client, options) {
9394
this._client = client;
94-
this._bson = options.bson || client.topology.bson;
95+
this._bson = options.bson || BSON || client.topology.bson;
9596
this._bypassEncryption = options.bypassAutoEncryption === true;
9697

9798
this._keyVaultNamespace = options.keyVaultNamespace || 'admin.datakeys';

lib/clientEncryption.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function (modules) {
77
const collectionNamespace = common.collectionNamespace;
88
const promiseOrCallback = common.promiseOrCallback;
99
const StateMachine = modules.stateMachine.StateMachine;
10+
const BSON = modules.mongodb.BSON;
1011
const cryptoCallbacks = require('./cryptoCallbacks');
1112
const { promisify } = require('util');
1213

@@ -99,7 +100,7 @@ module.exports = function (modules) {
99100
*/
100101
constructor(client, options) {
101102
this._client = client;
102-
this._bson = options.bson || client.topology.bson;
103+
this._bson = options.bson || BSON || client.topology.bson;
103104
this._proxyOptions = options.proxyOptions;
104105
this._tlsOptions = options.tlsOptions;
105106

package-lock.json

+59-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"socks": "^2.6.1"
4141
},
4242
"devDependencies": {
43-
"bson": "^4.6.4",
4443
"chai": "^4.3.6",
4544
"chai-subset": "^1.6.0",
4645
"chalk": "^4.1.2",
@@ -51,7 +50,7 @@
5150
"eslint-plugin-prettier": "^4.0.0",
5251
"jsdoc-to-markdown": "^7.1.1",
5352
"mocha": "^9.2.0",
54-
"mongodb": "^4.6.0",
53+
"mongodb": "^4.9.0",
5554
"node-gyp": "^8.4.1",
5655
"prebuild": "^11.0.2",
5756
"prettier": "^2.5.1",

0 commit comments

Comments
 (0)