-
Notifications
You must be signed in to change notification settings - Fork 103
feat(NODE-4136): adjust Node.js bindings for shared library spec #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,12 @@ module.exports = function (modules) { | |
| : this._bson.serialize(options.schemaMap); | ||
| } | ||
|
|
||
| if (options.encryptedFieldsMap) { | ||
| mongoCryptOptions.encryptedFieldsMap = Buffer.isBuffer(options.encryptedFieldsMap) | ||
| ? options.encryptedFieldsMap | ||
| : this._bson.serialize(options.encryptedFieldsMap); | ||
| } | ||
|
|
||
| if (options.kmsProviders) { | ||
| mongoCryptOptions.kmsProviders = !Buffer.isBuffer(options.kmsProviders) | ||
| ? this._bson.serialize(options.kmsProviders) | ||
|
|
@@ -125,16 +131,27 @@ module.exports = function (modules) { | |
| } | ||
|
|
||
| if (options.extraOptions && options.extraOptions.csfleSearchPaths) { | ||
| // Only for driver testing | ||
| mongoCryptOptions.csfleSearchPaths = options.extraOptions.csfleSearchPaths; | ||
| } else if (!this._bypassEncryption) { | ||
| mongoCryptOptions.csfleSearchPaths = ['$SYSTEM']; | ||
| } | ||
|
|
||
| if (options.bypassQueryAnalysis) { | ||
| mongoCryptOptions.bypassQueryAnalysis = options.bypassQueryAnalysis; | ||
| } | ||
|
|
||
| Object.assign(mongoCryptOptions, { cryptoCallbacks }); | ||
| this._mongocrypt = new mc.MongoCrypt(mongoCryptOptions); | ||
| this._contextCounter = 0; | ||
|
|
||
| if (options.extraOptions && options.extraOptions.csfleRequired && !this.csfleVersionInfo) { | ||
| throw new MongoError('`csfleRequired` set but no csfle shared library loaded'); | ||
| } | ||
|
|
||
| // Only instantiate mongocryptd manager/client once we know for sure | ||
| // that we are not using the CSFLE shared library. | ||
| if (!this._bypassAutoEncryption && !this.csfleVersionInfo) { | ||
| if (!this._bypassEncryption && !this.csfleVersionInfo) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn’t realize in efad8b6 that this condition (before the addition of Obviously it would be possible to go the other way here as well, i.e. drop the conditional entirely and always create
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to not have the cryptdManager exist when we are using the lib. Good catch! |
||
| this._mongocryptdManager = new MongocryptdManager(options.extraOptions); | ||
| this._mongocryptdClient = new MongoClient(this._mongocryptdManager.uri, { | ||
| useNewUrlParser: true, | ||
|
|
@@ -181,7 +198,11 @@ module.exports = function (modules) { | |
| * @param {Function} callback Invoked when the mongocryptd client either successfully disconnects or errors | ||
| */ | ||
| teardown(force, callback) { | ||
| this._mongocryptdClient.close(force, callback); | ||
| if (this._mongocryptdClient) { | ||
| this._mongocryptdClient.close(force, callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.