Skip to content

Commit 4650f7c

Browse files
feat(NODE-5908): support range v2 protocol (#13)
1 parent 39d898a commit 4650f7c

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

addon/mongocrypt.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,7 @@ MongoCrypt::MongoCrypt(const CallbackInfo& info)
514514
mongocrypt_setopt_bypass_query_analysis(_mongo_crypt.get());
515515
}
516516

517-
if (options.Get("rangeV2").ToBoolean()) {
518-
mongocrypt_setopt_use_range_v2(_mongo_crypt.get());
519-
}
517+
mongocrypt_setopt_use_range_v2(_mongo_crypt.get());
520518

521519
mongocrypt_setopt_use_need_kms_credentials_state(_mongo_crypt.get());
522520

@@ -596,10 +594,10 @@ Value MongoCrypt::MakeExplicitEncryptionContext(const CallbackInfo& info) {
596594
throw TypeError::New(Env(), errorStringFromStatus(context.get()));
597595
}
598596

599-
if (strcasecmp(algorithm.c_str(), "rangepreview") == 0) {
597+
if (strcasecmp(algorithm.c_str(), "range") == 0) {
600598
if (!options.Has("rangeOptions")) {
601599
throw TypeError::New(
602-
Env(), "`rangeOptions` must be provided if `algorithm` is set to RangePreview");
600+
Env(), "`rangeOptions` must be provided if `algorithm` is set to Range");
603601
}
604602

605603
Uint8Array rangeOptions = Uint8ArrayFromValue(options["rangeOptions"], "rangeOptions");

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ export interface MongoCryptConstructor {
4040
cryptSharedLibSearchPaths?: string[];
4141
cryptSharedLibPath?: string;
4242
bypassQueryAnalysis?: boolean;
43-
/** @experimental */
44-
rangeV2?: boolean;
4543
}): MongoCrypt;
4644
libmongocryptVersion: string;
4745
}

test/bindings.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,17 @@ describe('MongoCryptConstructor', () => {
341341
});
342342
});
343343

344-
context('when algorithm is `rangePreview', () => {
344+
context('when algorithm is `Range', () => {
345345
it('throws a TypeError if rangeOptions is not provided', () => {
346346
expect(() =>
347347
mc.makeExplicitEncryptionContext(value, {
348348
// minimum required arguments from libmongocrypt
349349
keyId: keyId.buffer,
350350
expressionMode: false,
351-
algorithm: 'rangePreview'
351+
algorithm: 'Range'
352352
})
353353
)
354-
.to.throw(/`rangeOptions` must be provided if `algorithm` is set to RangePreview/)
354+
.to.throw(/`rangeOptions` must be provided if `algorithm` is set to Range/)
355355
.to.be.instanceOf(TypeError);
356356
});
357357

@@ -361,26 +361,26 @@ describe('MongoCryptConstructor', () => {
361361
// minimum required arguments from libmongocrypt
362362
keyId: keyId.buffer,
363363
expressionMode: false,
364-
algorithm: 'rangePreview',
364+
algorithm: 'Range',
365365
rangeOptions: 'non-buffer'
366366
})
367367
)
368368
.to.throw(/Parameter `rangeOptions` must be a Uint8Array./)
369369
.to.be.instanceOf(TypeError);
370370
});
371371

372-
it('checks if `rangePreview` is set case-insensitive', () => {
372+
it('checks if `Range` is set case-insensitive', () => {
373373
expect(
374374
mc.makeExplicitEncryptionContext(value, {
375375
// minimum required arguments from libmongocrypt
376376
keyId: keyId.buffer,
377377
expressionMode: false,
378-
algorithm: 'RANGEPREVIEW',
378+
algorithm: 'RANGE',
379379
rangeOptions: serialize({
380380
sparsity: new Long(42)
381381
}),
382382

383-
// contention factor is required for `rangePreview` but
383+
// contention factor is required for `Range` but
384384
// is enforced in libmongocrypt, not our bindings
385385
contentionFactor: 2
386386
})

0 commit comments

Comments
 (0)