Skip to content

Commit bc4b7bc

Browse files
authored
docs(NODE-5261): update readme to mention cryptSharedLibPath and cryptSharedLibRequired (#643)
1 parent e6b5be5 commit bc4b7bc

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ It protects against a malicious server advertising a false JSON Schema, which co
168168
Schemas supplied in the schemaMap only apply to configuring automatic encryption for Client-Side Field Level Encryption.
169169
Other validation rules in the JSON schema will not be enforced by the driver and will result in an error.
170170

171-
**Example**
171+
**Example** *(Create an AutoEncrypter that makes use of mongocryptd)*
172172
```js
173-
// Enabling autoEncryption via a MongoClient
173+
// Enabling autoEncryption via a MongoClient using mongocryptd
174174
const { MongoClient } = require('mongodb');
175175
const client = new MongoClient(URL, {
176176
autoEncryption: {
@@ -183,6 +183,25 @@ const client = new MongoClient(URL, {
183183
}
184184
});
185185

186+
await client.connect();
187+
// From here on, the client will be encrypting / decrypting automatically
188+
```
189+
**Example** *(Create an AutoEncrypter that makes use of libmongocrypt's CSFLE shared library)*
190+
```js
191+
// Enabling autoEncryption via a MongoClient using CSFLE shared library
192+
const { MongoClient } = require('mongodb');
193+
const client = new MongoClient(URL, {
194+
autoEncryption: {
195+
kmsProviders: {
196+
aws: {}
197+
},
198+
extraOptions: {
199+
cryptSharedLibPath: '/path/to/local/crypt/shared/lib',
200+
cryptSharedLibRequired: true
201+
}
202+
}
203+
});
204+
186205
await client.connect();
187206
// From here on, the client will be encrypting / decrypting automatically
188207
```
@@ -243,8 +262,11 @@ Configuration options for a automatic client encryption.
243262
| [mongocryptdBypassSpawn] | <code>boolean</code> | <code>false</code> | If true, autoEncryption will not attempt to spawn a mongocryptd before connecting |
244263
| [mongocryptdSpawnPath] | <code>string</code> | | The path to the mongocryptd executable on the system |
245264
| [mongocryptdSpawnArgs] | <code>Array.&lt;string&gt;</code> | | Command line arguments to use when auto-spawning a mongocryptd |
265+
| [cryptSharedLibPath] | <code>string</code> | | Full path to a MongoDB Crypt shared library on the system. If specified, autoEncryption will not attempt to spawn a mongocryptd, but makes use of the shared library file specified. Note that the path must point to the shared libary file itself, not the folder which contains it \* |
266+
| [cryptSharedLibRequired] | <code>boolean</code> | | If true, never use mongocryptd and fail when the MongoDB Crypt shared libary cannot be loaded. Defaults to true if [cryptSharedLibPath] is specified and false otherwise \* |
246267

247268
Extra options related to the mongocryptd process
269+
\* _Available in MongoDB 6.0 or higher._
248270

249271
<a name="AutoEncrypter..logger"></a>
250272

lib/autoEncrypter.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ module.exports = function (modules) {
2727

2828
/**
2929
* Extra options related to the mongocryptd process
30+
* \* _Available in MongoDB 6.0 or higher._
3031
* @typedef {object} AutoEncrypter~AutoEncryptionExtraOptions
3132
* @property {string} [mongocryptdURI] A local process the driver communicates with to determine how to encrypt values in a command. Defaults to "mongodb://%2Fvar%2Fmongocryptd.sock" if domain sockets are available or "mongodb://localhost:27020" otherwise
3233
* @property {boolean} [mongocryptdBypassSpawn=false] If true, autoEncryption will not attempt to spawn a mongocryptd before connecting
3334
* @property {string} [mongocryptdSpawnPath] The path to the mongocryptd executable on the system
3435
* @property {string[]} [mongocryptdSpawnArgs] Command line arguments to use when auto-spawning a mongocryptd
36+
* @property {string} [cryptSharedLibPath] Full path to a MongoDB Crypt shared library on the system. If specified, autoEncryption will not attempt to spawn a mongocryptd, but makes use of the shared library file specified. Note that the path must point to the shared libary file itself, not the folder which contains it \*
37+
* @property {boolean} [cryptSharedLibRequired] If true, never use mongocryptd and fail when the MongoDB Crypt shared libary cannot be loaded. Defaults to true if [cryptSharedLibPath] is specified and false otherwise \*
3538
*/
3639

3740
/**
@@ -74,8 +77,8 @@ module.exports = function (modules) {
7477
* @param {MongoClient} client The client autoEncryption is enabled on
7578
* @param {AutoEncrypter~AutoEncryptionOptions} [options] Optional settings
7679
*
77-
* @example
78-
* // Enabling autoEncryption via a MongoClient
80+
* @example <caption>Create an AutoEncrypter that makes use of mongocryptd</caption>
81+
* // Enabling autoEncryption via a MongoClient using mongocryptd
7982
* const { MongoClient } = require('mongodb');
8083
* const client = new MongoClient(URL, {
8184
* autoEncryption: {
@@ -90,6 +93,23 @@ module.exports = function (modules) {
9093
*
9194
* await client.connect();
9295
* // From here on, the client will be encrypting / decrypting automatically
96+
* @example <caption>Create an AutoEncrypter that makes use of libmongocrypt's CSFLE shared library</caption>
97+
* // Enabling autoEncryption via a MongoClient using CSFLE shared library
98+
* const { MongoClient } = require('mongodb');
99+
* const client = new MongoClient(URL, {
100+
* autoEncryption: {
101+
* kmsProviders: {
102+
* aws: {}
103+
* },
104+
* extraOptions: {
105+
* cryptSharedLibPath: '/path/to/local/crypt/shared/lib',
106+
* cryptSharedLibRequired: true
107+
* }
108+
* }
109+
* });
110+
*
111+
* await client.connect();
112+
* // From here on, the client will be encrypting / decrypting automatically
93113
*/
94114
constructor(client, options) {
95115
this._client = client;

0 commit comments

Comments
 (0)