Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-client-encryption

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-client-encryption - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

.evergreen/find_cmake.sh

53

lib/clientEncryption.js

@@ -12,2 +12,39 @@ 'use strict';

function sanitizeDataKeyOptions(bson, options) {
options = Object.assign({}, options);
// To avoid using libbson inside the bindings, we pre-serialize
// any keyAltNames here.
if (options.keyAltNames) {
if (!Array.isArray(options.keyAltNames)) {
throw new TypeError(
`Option "keyAltNames" must be an array of string, but was of type ${typeof options.keyAltNames}.`
);
}
const serializedKeyAltNames = [];
for (let i = 0; i < options.keyAltNames.length; i += 1) {
const item = options.keyAltNames[i];
const itemType = typeof item;
if (itemType !== 'string') {
throw new TypeError(
`Option "keyAltNames" must be an array of string, but item at index ${i} was of type ${itemType} `
);
}
serializedKeyAltNames.push(bson.serialize({ keyAltName: item }));
}
options.keyAltNames = serializedKeyAltNames;
} else if (options.keyAltNAmes == null) {
// If keyAltNames is null or undefined, we can assume the intent of
// the user is to not pass in the value. B/c Nan::Has will still
// register a value of null or undefined as present as long
// as the key is present, we delete it off of the options
// object here.
delete options.keyAltNames;
}
return options;
}
/**

@@ -46,3 +83,3 @@ * The public interface for explicit client side encryption

if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
options = sanitizeDataKeyOptions(this._bson, options);

@@ -91,3 +128,17 @@ const context = this._mongoCrypt.makeDataKeyContext(provider, options);

}
if (options.keyAltName) {
const keyAltName = options.keyAltName;
if (options.keyId) {
throw new TypeError(`"options" cannot contain both "keyId" and "keyAltName"`);
}
const keyAltNameType = typeof keyAltName;
if (keyAltNameType !== 'string') {
throw new TypeError(
`"options.keyAltName" must be of type string, but was of type ${keyAltNameType}`
);
}
contextOptions.keyAltName = bson.serialize({ keyAltName });
}
const stateMachine = new StateMachine();

@@ -94,0 +145,0 @@ const context = this._mongoCrypt.makeExplicitEncryptionContext(valueBuffer, contextOptions);

12

lib/cryptoCallbacks.js

@@ -12,3 +12,3 @@ 'use strict';

} catch (e) {
console.dir({ e });
return e;
}

@@ -27,3 +27,3 @@

} catch (e) {
console.dir({ e });
return e;
}

@@ -36,3 +36,3 @@

function randomHook(buffer, count) {
crypto.randomFillSync(buffer, count);
crypto.randomFillSync(buffer, 0, count);
}

@@ -48,6 +48,7 @@

} catch (e) {
console.dir({ e });
return e;
}
result.copy(output);
return result.length;
}

@@ -64,6 +65,7 @@

} catch (e) {
console.dir({ e });
return e;
}
result.copy(output);
return result.length;
};

@@ -70,0 +72,0 @@ }

@@ -5,3 +5,2 @@ 'use strict';

const readFile = require('fs').readFile;
const platform = require('os').platform;

@@ -62,6 +61,6 @@ /**

this.uri = extraOptions.mongocryptdURI;
} else if (platform() === 'win32') {
} else {
// TODO: eventually support connecting on Linux Socket for non-windows,
// blocked by SERVER-41029
this.uri = 'mongodb://localhost:27020/?serverSelectionTimeoutMS=1000';
} else {
this.uri = 'mongodb://%2Ftmp%2Fmongocryptd.sock/?serverSelectionTimeoutMS=1000';
}

@@ -97,2 +96,4 @@

this._child.on('error', () => {});
// unref child to remove handle from event loop

@@ -99,0 +100,0 @@ this._child.unref();

@@ -131,6 +131,15 @@ 'use strict';

// terminal states
case MONGOCRYPT_CTX_READY:
callback(null, bson.deserialize(context.finalize()));
case MONGOCRYPT_CTX_READY: {
const finalizedContext = context.finalize();
// TODO: Maybe rework the logic here so that instead of doing
// the callback here, finalize stores the result, and then
// we wait to MONGOCRYPT_CTX_DONE to do the callback
if (context.state === MONGOCRYPT_CTX_ERROR) {
const message = context.status.message || 'Finalization error';
callback(new MongoCryptError(message));
return;
}
callback(null, bson.deserialize(finalizedContext));
return;
}
case MONGOCRYPT_CTX_ERROR: {

@@ -137,0 +146,0 @@ const message = context.status.message;

{
"name": "mongodb-client-encryption",
"version": "0.2.0",
"version": "0.3.0",
"description": "Official client encryption module for the MongoDB Node.js driver",

@@ -10,3 +10,3 @@ "main": "index.js",

"scripts": {
"install": "node-gyp rebuild",
"install": "prebuild-install --tag-prefix node-v || node-gyp rebuild",
"format-cxx": "git-clang-format",

@@ -16,3 +16,5 @@ "format-js": "prettier --print-width 100 --tab-width 2 --single-quote --write index.js 'test/**/*.js' 'lib/**/*.js'",

"docs": "jsdoc2md --template etc/README.hbs --plugin dmd-clear --files lib/**/*.js > README.md",
"test": "mocha test"
"test": "mocha test",
"rebuild": "prebuild --compile",
"prebuild": "prebuild --strip --verbose --tag-prefix node-v -t 10.16.0 -t 8.16.0 -t 6.17.1 -t 4.9.1"
},

@@ -25,3 +27,4 @@ "author": "Matt Broadstone <mbroadst@mongodb.com>",

"bson": "^1.0.5",
"nan": "^2.14.0"
"nan": "^2.14.0",
"prebuild-install": "^5.3.0"
},

@@ -38,2 +41,4 @@ "devDependencies": {

"mongodb-extjson": "^3.0.3",
"node-gyp": "^5.0.3",
"prebuild": "^9.0.1",
"prettier": "~1.18.2",

@@ -43,3 +48,6 @@ "segfault-handler": "^1.2.0",

"sinon-chai": "^3.3.0"
},
"repository": {
"url": "https://github.com/mongodb/libmongocrypt"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc