Skip to content

Commit 3f7196e

Browse files
feat(NODE-7043, NODE-7217)!: adopt mongodb-client-encryption v7 (#4705)
1 parent 6a82d45 commit 3f7196e

17 files changed

+123
-359
lines changed

.evergreen/config.in.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,9 @@ functions:
617617
export AWS_ACCESS_KEY_ID=${aws_key}
618618
export AWS_SECRET_ACCESS_KEY=${aws_secret}
619619
620+
# use Node20
621+
export PATH=/opt/devtools/node20/bin:/opt/dev/tools/bin:$PATH
622+
620623
# Download all the task coverage files.
621624
# NOTE: All coverage files are too large for V8 to handle the resulting call to
622625
# JSON.stringify from within nyc, so with stick to Fermiun to include the

.evergreen/config.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ functions:
556556
export AWS_ACCESS_KEY_ID=${aws_key}
557557
export AWS_SECRET_ACCESS_KEY=${aws_secret}
558558
559+
# use Node20
560+
export PATH=/opt/devtools/node20/bin:/opt/dev/tools/bin:$PATH
561+
559562
# Download all the task coverage files.
560563
# NOTE: All coverage files are too large for V8 to handle the resulting call to
561564
# JSON.stringify from within nyc, so with stick to Fermiun to include the
@@ -1994,24 +1997,6 @@ tasks:
19941997
- func: install mongodb-client-encryption from source
19951998
- func: assume secrets manager role
19961999
- func: run custom csfle tests
1997-
- name: test-latest-driver-mongodb-client-encryption-6.0.0
1998-
tags:
1999-
- run-custom-dependency-tests
2000-
commands:
2001-
- command: expansions.update
2002-
type: setup
2003-
params:
2004-
updates:
2005-
- {key: NODE_LTS_VERSION, value: 20.19.0}
2006-
- {key: VERSION, value: '7.0'}
2007-
- {key: TOPOLOGY, value: replica_set}
2008-
- {key: CLIENT_ENCRYPTION, value: 'true'}
2009-
- func: install dependencies
2010-
- func: bootstrap mongo-orchestration
2011-
- func: install package
2012-
vars:
2013-
2014-
- func: run tests
20152000
- name: test-alpine-fle
20162001
tags:
20172002
- alpine-fle
@@ -3205,7 +3190,6 @@ buildvariants:
32053190
- run-custom-csfle-tests-5.0
32063191
- run-custom-csfle-tests-rapid
32073192
- run-custom-csfle-tests-latest
3208-
- test-latest-driver-mongodb-client-encryption-6.0.0
32093193
- name: rhel8-test-gcp-kms
32103194
display_name: GCP KMS Test
32113195
run_on: debian11-small

.evergreen/generate_evergreen_tasks.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -623,27 +623,28 @@ for (const serverVersion of ['5.0', 'rapid', 'latest']) {
623623
});
624624
}
625625

626-
customDependencyTests.push({
627-
name: `test-latest-driver-mongodb-client-encryption-6.0.0`,
628-
tags: ['run-custom-dependency-tests'],
629-
commands: [
630-
updateExpansions({
631-
NODE_LTS_VERSION: LOWEST_LTS,
632-
VERSION: '7.0',
633-
TOPOLOGY: 'replica_set',
634-
CLIENT_ENCRYPTION: true
635-
}),
636-
{ func: 'install dependencies' },
637-
{ func: 'bootstrap mongo-orchestration' },
638-
{
639-
func: 'install package',
640-
vars: {
641-
PACKAGE: '[email protected]'
642-
}
643-
},
644-
{ func: 'run tests' }
645-
]
646-
});
626+
// TODO(NODE-6997): update to 7.0.0 after release
627+
// customDependencyTests.push({
628+
// name: `test-latest-driver-mongodb-client-encryption-6.0.0`,
629+
// tags: ['run-custom-dependency-tests'],
630+
// commands: [
631+
// updateExpansions({
632+
// NODE_LTS_VERSION: LOWEST_LTS,
633+
// VERSION: '7.0',
634+
// TOPOLOGY: 'replica_set',
635+
// CLIENT_ENCRYPTION: true
636+
// }),
637+
// { func: 'install dependencies' },
638+
// { func: 'bootstrap mongo-orchestration' },
639+
// {
640+
// func: 'install package',
641+
// vars: {
642+
// PACKAGE: '[email protected]'
643+
// }
644+
// },
645+
// { func: 'run tests' }
646+
// ]
647+
// });
647648

648649
const coverageTask = {
649650
name: 'download and merge coverage'.split(' ').join('-'),

.evergreen/install-mongodb-client-encryption.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ rm -rf mongodb-client-encryption
1212
git clone https://github.com/mongodb-js/mongodb-client-encryption.git
1313
pushd mongodb-client-encryption
1414

15-
# TODO(NODE-7218): test against latest mongodb-client-encryption
16-
git checkout aa61a35f5e174cd1c1e247e036093e18c88268c6
15+
git checkout main
1716

1817
node --version
1918
npm --version

package-lock.json

Lines changed: 63 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@mongodb-js/zstd": "^1.1.0 || ^2.0.0",
3535
"gcp-metadata": "^5.2.0",
3636
"kerberos": "^2.0.1",
37-
"mongodb-client-encryption": ">=6.0.0 <7",
37+
"mongodb-client-encryption": "^7.0.0-alpha",
3838
"snappy": "^7.3.2",
3939
"socks": "^2.7.1"
4040
},
@@ -96,7 +96,7 @@
9696
"js-yaml": "^4.1.0",
9797
"mocha": "^11.7.1",
9898
"mocha-sinon": "^2.1.2",
99-
"mongodb-client-encryption": "^6.5.0",
99+
"mongodb-client-encryption": "^7.0.0-alpha.1",
100100
"mongodb-legacy": "^6.1.3",
101101
"nyc": "^15.1.0",
102102
"prettier": "^3.6.2",
@@ -174,4 +174,4 @@
174174
"moduleResolution": "node"
175175
}
176176
}
177-
}
177+
}

src/client-side-encryption/auto_encrypter.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
type MongoCrypt,
3-
type MongoCryptConstructor,
4-
type MongoCryptOptions
5-
} from 'mongodb-client-encryption';
1+
import { type MongoCrypt, type MongoCryptOptions } from 'mongodb-client-encryption';
62
import * as net from 'net';
73

84
import { deserialize, type Document, serialize } from '../bson';
@@ -14,8 +10,7 @@ import { MongoClient, type MongoClientOptions } from '../mongo_client';
1410
import { type Abortable } from '../mongo_types';
1511
import { MongoDBCollectionNamespace } from '../utils';
1612
import { autoSelectSocketOptions } from './client_encryption';
17-
import * as cryptoCallbacks from './crypto_callbacks';
18-
import { MongoCryptInvalidArgumentError } from './errors';
13+
import { defaultErrorWrapper, MongoCryptInvalidArgumentError } from './errors';
1914
import { MongocryptdManager } from './mongocryptd_manager';
2015
import {
2116
type CredentialProviders,
@@ -183,7 +178,7 @@ export class AutoEncrypter {
183178
[kDecorateResult] = false;
184179

185180
/** @internal */
186-
static getMongoCrypt(): MongoCryptConstructor {
181+
static getMongoCrypt(): typeof MongoCrypt {
187182
const encryption = getMongoDBClientEncryption();
188183
if ('kModuleError' in encryption) {
189184
throw encryption.kModuleError;
@@ -258,8 +253,7 @@ export class AutoEncrypter {
258253
}
259254

260255
const mongoCryptOptions: MongoCryptOptions = {
261-
enableMultipleCollinfo: true,
262-
cryptoCallbacks
256+
errorWrapper: defaultErrorWrapper
263257
};
264258
if (options.schemaMap) {
265259
mongoCryptOptions.schemaMap = Buffer.isBuffer(options.schemaMap)

src/client-side-encryption/client_encryption.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {
22
ExplicitEncryptionContextOptions,
33
MongoCrypt,
4-
MongoCryptConstructor,
54
MongoCryptOptions
65
} from 'mongodb-client-encryption';
76

@@ -26,8 +25,8 @@ import { type CreateCollectionOptions } from '../operations/create_collection';
2625
import { type DeleteResult } from '../operations/delete';
2726
import { type CSOTTimeoutContext, TimeoutContext } from '../timeout';
2827
import { MongoDBCollectionNamespace, resolveTimeoutOptions } from '../utils';
29-
import * as cryptoCallbacks from './crypto_callbacks';
3028
import {
29+
defaultErrorWrapper,
3130
MongoCryptCreateDataKeyError,
3231
MongoCryptCreateEncryptedCollectionError,
3332
MongoCryptInvalidArgumentError
@@ -87,7 +86,7 @@ export class ClientEncryption {
8786
_credentialProviders?: CredentialProviders;
8887

8988
/** @internal */
90-
static getMongoCrypt(): MongoCryptConstructor {
89+
static getMongoCrypt(): typeof MongoCrypt {
9190
const encryption = getMongoDBClientEncryption();
9291
if ('kModuleError' in encryption) {
9392
throw encryption.kModuleError;
@@ -144,10 +143,10 @@ export class ClientEncryption {
144143

145144
const mongoCryptOptions: MongoCryptOptions = {
146145
...options,
147-
cryptoCallbacks,
148146
kmsProviders: !Buffer.isBuffer(this._kmsProviders)
149147
? (serialize(this._kmsProviders) as Buffer)
150-
: this._kmsProviders
148+
: this._kmsProviders,
149+
errorWrapper: defaultErrorWrapper
151150
};
152151

153152
this._keyVaultNamespace = options.keyVaultNamespace;

0 commit comments

Comments
 (0)