MongoDB Client Encryption
The Node.js wrapper for libmongocrypt
Requirements
Follow the instructions for building libmongocrypt
here.
Installation
Now you can install mongodb-client-encryption
with the following:
npm install mongodb-client-encryption
Testing
Run the test suite using:
npm test
Documentation
Classes
- AutoEncrypter
An internal class to be used by the driver for auto encryption
NOTE: Not meant to be instantiated directly, this is for internal use only.
- ClientEncryption
The public interface for explicit client side encryption
Typedefs
- AutoEncryptionExtraOptions
AutoEncrypter
An internal class to be used by the driver for auto encryption
NOTE: Not meant to be instantiated directly, this is for internal use only.
new AutoEncrypter(options)
Param | Type | Description |
---|
options | object | Optional settings |
options.client | MongoClient | The parent client auto encryption is enabled on |
options.keyVaultNamespace | string | The namespace of the key vault, used to store encryption keys |
options.schemaMap | object | |
options.kmsProviders | object | |
options.logger | function | |
[options.extraOptions] | AutoEncryptionExtraOptions | Extra options related to mongocryptd |
Create an AutoEncrypter
autoEncrypter.encrypt(ns, cmd, callback)
Param | Type | Description |
---|
ns | string | The namespace for this encryption context |
cmd | object | The command to encrypt |
callback | function | |
Encrypt a command for a given namespace
autoEncrypter.decrypt(buffer, callback)
Param | Type |
---|
buffer | * |
callback | * |
Decrypt a command response
ClientEncryption
The public interface for explicit client side encryption
new ClientEncryption(client, options)
Param | Type | Description |
---|
client | MongoClient | The client used for encryption |
options | object | Optional settings |
options.keyVaultNamespace | string | The namespace of the key vault, used to store encryption keys |
Create a new encryption instance
clientEncryption.createDataKey(provider, options, callback)
Param | Type | Description |
---|
provider | string | The KMS provider used for this data key |
options | * | |
callback | function | |
Creates a data key used for explicit encryption
clientEncryption.encrypt(value, options, callback)
Param | Type |
---|
value | * |
options | * |
callback | * |
Explicitly encrypt a provided value
clientEncryption.decrypt(value, callback)
Explicitly decrypt a provided encrypted value
Properties
Name | Type | Default | Description |
---|
[mongocryptdURI] | string | | overrides the uri used to connect to mongocryptd |
[mongocryptdBypassSpawn] | boolean | false | if true, autoEncryption will not spawn a mongocryptd |
[mongocryptdSpawnPath] | string | | the path to the mongocryptd executable |
[mongocryptdSpawnArgs] | Array.<string> | | command line arguments to pass to the mongocryptd executable |