From a195daabb61ffa41a5904896b798057297e6644e Mon Sep 17 00:00:00 2001 From: Bailey Pearson <bailey.pearson@mongodb.com> Date: Mon, 10 Jun 2024 10:23:43 -0600 Subject: [PATCH 1/2] use Range instead of RangePreview --- addon/mongocrypt.cc | 4 ++-- test/bindings.test.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addon/mongocrypt.cc b/addon/mongocrypt.cc index 1688b11..b2e7dc7 100644 --- a/addon/mongocrypt.cc +++ b/addon/mongocrypt.cc @@ -596,10 +596,10 @@ Value MongoCrypt::MakeExplicitEncryptionContext(const CallbackInfo& info) { throw TypeError::New(Env(), errorStringFromStatus(context.get())); } - if (strcasecmp(algorithm.c_str(), "rangepreview") == 0) { + if (strcasecmp(algorithm.c_str(), "range") == 0) { if (!options.Has("rangeOptions")) { throw TypeError::New( - Env(), "`rangeOptions` must be provided if `algorithm` is set to RangePreview"); + Env(), "`rangeOptions` must be provided if `algorithm` is set to Range"); } Uint8Array rangeOptions = Uint8ArrayFromValue(options["rangeOptions"], "rangeOptions"); diff --git a/test/bindings.test.ts b/test/bindings.test.ts index c91e86b..186bc01 100644 --- a/test/bindings.test.ts +++ b/test/bindings.test.ts @@ -341,17 +341,17 @@ describe('MongoCryptConstructor', () => { }); }); - context('when algorithm is `rangePreview', () => { + context('when algorithm is `Range', () => { it('throws a TypeError if rangeOptions is not provided', () => { expect(() => mc.makeExplicitEncryptionContext(value, { // minimum required arguments from libmongocrypt keyId: keyId.buffer, expressionMode: false, - algorithm: 'rangePreview' + algorithm: 'Range' }) ) - .to.throw(/`rangeOptions` must be provided if `algorithm` is set to RangePreview/) + .to.throw(/`rangeOptions` must be provided if `algorithm` is set to Range/) .to.be.instanceOf(TypeError); }); @@ -361,7 +361,7 @@ describe('MongoCryptConstructor', () => { // minimum required arguments from libmongocrypt keyId: keyId.buffer, expressionMode: false, - algorithm: 'rangePreview', + algorithm: 'Range', rangeOptions: 'non-buffer' }) ) @@ -369,18 +369,18 @@ describe('MongoCryptConstructor', () => { .to.be.instanceOf(TypeError); }); - it('checks if `rangePreview` is set case-insensitive', () => { + it('checks if `Range` is set case-insensitive', () => { expect( mc.makeExplicitEncryptionContext(value, { // minimum required arguments from libmongocrypt keyId: keyId.buffer, expressionMode: false, - algorithm: 'RANGEPREVIEW', + algorithm: 'RANGE', rangeOptions: serialize({ sparsity: new Long(42) }), - // contention factor is required for `rangePreview` but + // contention factor is required for `Range` but // is enforced in libmongocrypt, not our bindings contentionFactor: 2 }) From dc1d87bdd79b3a8ed7632e1c0f5b6d7630474bf9 Mon Sep 17 00:00:00 2001 From: Bailey Pearson <bailey.pearson@mongodb.com> Date: Tue, 11 Jun 2024 11:09:35 -0600 Subject: [PATCH 2/2] add support for range v2 --- addon/mongocrypt.cc | 4 +--- src/index.ts | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/addon/mongocrypt.cc b/addon/mongocrypt.cc index b2e7dc7..4ed2a8a 100644 --- a/addon/mongocrypt.cc +++ b/addon/mongocrypt.cc @@ -514,9 +514,7 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info) mongocrypt_setopt_bypass_query_analysis(_mongo_crypt.get()); } - if (options.Get("rangeV2").ToBoolean()) { - mongocrypt_setopt_use_range_v2(_mongo_crypt.get()); - } + mongocrypt_setopt_use_range_v2(_mongo_crypt.get()); mongocrypt_setopt_use_need_kms_credentials_state(_mongo_crypt.get()); diff --git a/src/index.ts b/src/index.ts index b47218b..7355840 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,8 +40,6 @@ export interface MongoCryptConstructor { cryptSharedLibSearchPaths?: string[]; cryptSharedLibPath?: string; bypassQueryAnalysis?: boolean; - /** @experimental */ - rangeV2?: boolean; }): MongoCrypt; libmongocryptVersion: string; }