Skip to content

feat(NODE-6773): add multiple collinfo option #70

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

Merged
merged 5 commits into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions .github/scripts/libmongocrypt.mjs
Original file line number Diff line number Diff line change
@@ -8,7 +8,12 @@ import events from 'node:events';
import path from 'node:path';
import https from 'node:https';
import stream from 'node:stream/promises';
import { buildLibmongocryptDownloadUrl, getLibmongocryptPrebuildName, resolveRoot, run } from './utils.mjs';
import {
buildLibmongocryptDownloadUrl,
getLibmongocryptPrebuildName,
resolveRoot,
run
} from './utils.mjs';

async function parseArguments() {
const pkg = JSON.parse(await fs.readFile(resolveRoot('package.json'), 'utf8'));
@@ -72,19 +77,11 @@ export async function buildLibMongoCrypt(libmongocryptRoot, nodeDepsRoot, option

const CMAKE_FLAGS = toCLIFlags({
/**
* We provide crypto hooks from Node.js binding to openssl (so disable system crypto)
* TODO: NODE-5455
* We provide crypto hooks from Node.js binding to openssl (so disable **system** crypto)
*
* One thing that is not obvious from the build instructions for libmongocrypt
* and the Node.js bindings is that the Node.js driver uses libmongocrypt in
* DISABLE_NATIVE_CRYPTO aka nocrypto mode, that is, instead of using native
* system libraries for crypto operations, it provides callbacks to libmongocrypt
* which, in the Node.js addon case, call JS functions that in turn call built-in
* Node.js crypto methods.
*
* That’s way more convoluted than it needs to be, considering that we always
* have a copy of OpenSSL available directly, but for now it seems to make sense
* to stick with what the Node.js addon does here.
* Node.js ships with openssl statically compiled into the runtime.
* We provide hooks to libmongocrypt that uses Node.js copy of openssl
* instead of the operating system's copy so we build without linking to the system crypto.
*/
DDISABLE_NATIVE_CRYPTO: '1',
/** A consistent name for the output "library" directory */
@@ -185,9 +182,7 @@ async function buildBindings(args, pkg) {

gypDefines = gypDefines.trim();
const prebuildOptions =
gypDefines.length > 0
? { env: { ...process.env, GYP_DEFINES: gypDefines } }
: undefined;
gypDefines.length > 0 ? { env: { ...process.env, GYP_DEFINES: gypDefines } } : undefined;

await run('npm', ['run', 'prebuild'], prebuildOptions);
// Compile Typescript
5 changes: 5 additions & 0 deletions addon/mongocrypt.cc
Original file line number Diff line number Diff line change
@@ -577,6 +577,11 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) {

mongocrypt_setopt_retry_kms(mongo_crypt(), true);

if (options.Get("enableMultipleCollinfo").ToBoolean()) {
/** TODO(NODE-6793): remove this option and have it always set in the next major */
mongocrypt_setopt_enable_multiple_collinfo(mongo_crypt());
}

// Initialize after all options are set.
if (!mongocrypt_init(mongo_crypt())) {
throw TypeError::New(Env(), errorStringFromStatus(mongo_crypt()));
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
},
"license": "Apache-2.0",
"gypfile": true,
"mongodb:libmongocrypt": "1.12.0",
"mongodb:libmongocrypt": "1.13.0",
"dependencies": {
"node-addon-api": "^4.3.0",
"prebuild-install": "^7.1.3"
@@ -96,4 +96,4 @@
"moduleResolution": "node"
}
}
}
}
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ export interface MongoCryptContext {
finishKMSRequests(): void;
finalize(): Buffer;

readonly status: MongoCryptStatus;
readonly state: number;
get status(): MongoCryptStatus;
get state(): number;
}

type MongoCryptConstructorOptions = {
@@ -67,6 +67,8 @@ type MongoCryptConstructorOptions = {
cryptSharedLibSearchPaths?: string[];
cryptSharedLibPath?: string;
bypassQueryAnalysis?: boolean;
/** TODO(NODE-6793): remove this option and have it always set in the next major */
enableMultipleCollinfo?: boolean;
};

export interface MongoCryptConstructor {