From 22a5510135f27b35d6b23fef0978b26fbb3ca4fc Mon Sep 17 00:00:00 2001 From: Neal Beeken <neal.beeken@mongodb.com> Date: Wed, 19 Feb 2025 18:08:55 -0500 Subject: [PATCH 1/5] wip --- addon/mongocrypt.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addon/mongocrypt.cc b/addon/mongocrypt.cc index 1fcda3f..eb2579c 100644 --- a/addon/mongocrypt.cc +++ b/addon/mongocrypt.cc @@ -577,6 +577,8 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) { mongocrypt_setopt_retry_kms(mongo_crypt(), true); + 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())); From 38ad114d85bcf4035f2f913426225a11504063ec Mon Sep 17 00:00:00 2001 From: Neal Beeken <neal.beeken@mongodb.com> Date: Fri, 21 Feb 2025 10:33:48 -0500 Subject: [PATCH 2/5] check build --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5dbaceb..ee3d7ce 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "license": "Apache-2.0", "gypfile": true, - "mongodb:libmongocrypt": "1.12.0", + "mongodb:libmongocrypt": "67f10bfb8de69549987cc62a1d4548d7b511a7ef", "dependencies": { "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.3" @@ -96,4 +96,4 @@ "moduleResolution": "node" } } -} \ No newline at end of file +} From 737535e1b4989385f0016a333e89d40ab071f4e8 Mon Sep 17 00:00:00 2001 From: Neal Beeken <neal.beeken@mongodb.com> Date: Fri, 21 Feb 2025 13:13:15 -0500 Subject: [PATCH 3/5] chore: add a way to configure this --- addon/mongocrypt.cc | 4 +++- src/index.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addon/mongocrypt.cc b/addon/mongocrypt.cc index eb2579c..191f89d 100644 --- a/addon/mongocrypt.cc +++ b/addon/mongocrypt.cc @@ -577,7 +577,9 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) : ObjectWrap(info) { mongocrypt_setopt_retry_kms(mongo_crypt(), true); - mongocrypt_setopt_enable_multiple_collinfo(mongo_crypt()); + if (options.Get("enableMultipleCollinfo").ToBoolean()) { + mongocrypt_setopt_enable_multiple_collinfo(mongo_crypt()); + } // Initialize after all options are set. if (!mongocrypt_init(mongo_crypt())) { diff --git a/src/index.ts b/src/index.ts index 281570f..2860fc1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,6 +67,7 @@ type MongoCryptConstructorOptions = { cryptSharedLibSearchPaths?: string[]; cryptSharedLibPath?: string; bypassQueryAnalysis?: boolean; + enableMultipleCollinfo?: boolean; }; export interface MongoCryptConstructor { From c571c16e0b5a9ccceee2d304fd4dd230904b9b25 Mon Sep 17 00:00:00 2001 From: Neal Beeken <neal.beeken@mongodb.com> Date: Thu, 27 Feb 2025 11:58:15 -0500 Subject: [PATCH 4/5] chore: bump version, prettier build script and update comment, getters for accuracy --- .github/scripts/libmongocrypt.mjs | 27 +++++++++++---------------- package.json | 2 +- src/index.ts | 4 ++-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/scripts/libmongocrypt.mjs b/.github/scripts/libmongocrypt.mjs index d61a7bd..b933ca6 100644 --- a/.github/scripts/libmongocrypt.mjs +++ b/.github/scripts/libmongocrypt.mjs @@ -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 diff --git a/package.json b/package.json index ee3d7ce..12c925d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ }, "license": "Apache-2.0", "gypfile": true, - "mongodb:libmongocrypt": "67f10bfb8de69549987cc62a1d4548d7b511a7ef", + "mongodb:libmongocrypt": "1.13.0", "dependencies": { "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.3" diff --git a/src/index.ts b/src/index.ts index 2860fc1..fc72701 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 = { From 52193529534b6b7dd4f2837a9c0fa78ce0cefbaa Mon Sep 17 00:00:00 2001 From: Neal Beeken <neal.beeken@mongodb.com> Date: Thu, 27 Feb 2025 12:43:37 -0500 Subject: [PATCH 5/5] chore: add todos --- addon/mongocrypt.cc | 1 + src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/addon/mongocrypt.cc b/addon/mongocrypt.cc index 191f89d..32f1a60 100644 --- a/addon/mongocrypt.cc +++ b/addon/mongocrypt.cc @@ -578,6 +578,7 @@ 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()); } diff --git a/src/index.ts b/src/index.ts index fc72701..d75449a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,6 +67,7 @@ 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; };