diff --git a/package.json b/package.json index ad6927e6d62..3d029d4186d 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ }, "peerDependencies": { "@aws-sdk/credential-providers": "^3.201.0", - "snappy": "7.x.x" + "snappy": "7.x.x", + "mongodb-client-encryption": "^2.3.0" }, "peerDependenciesMeta": { "@aws-sdk/credential-providers": { @@ -42,6 +43,9 @@ }, "snappy": { "optional": true + }, + "mongodb-client-encryption": { + "optional": true } }, "devDependencies": { diff --git a/src/collection.ts b/src/collection.ts index 5babeaa8edc..7c6a37e6df1 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -86,7 +86,6 @@ import { Callback, checkCollectionName, DEFAULT_PK_FACTORY, - emitWarningOnce, MongoDBNamespace, normalizeHintField, resolveOptions @@ -283,12 +282,6 @@ export class Collection { options = {}; } - // versions of mongodb-client-encryption before v1.2.6 pass in hardcoded { w: 'majority' } - // specifically to an insertOne call in createDataKey, so we want to support this only here - if (options && Reflect.get(options, 'w')) { - options.writeConcern = WriteConcern.fromOptions(Reflect.get(options, 'w')); - } - return executeOperation( this.s.db.s.client, new InsertOneOperation( diff --git a/src/deps.ts b/src/deps.ts index 28290fb6703..bb675baa526 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -import type { deserialize, Document, serialize } from './bson'; +import type { Document } from './bson'; import type { AWSCredentials } from './cmap/auth/mongodb_aws'; import type { ProxyOptions } from './cmap/connection'; import { MongoMissingDependencyError } from './error'; @@ -214,8 +214,6 @@ export interface AutoEncryptionTlsOptions { /** @public */ export interface AutoEncryptionOptions { - /** @internal */ - bson?: { serialize: typeof serialize; deserialize: typeof deserialize }; /** @internal client for metadata lookups */ metadataClient?: MongoClient; /** A `MongoClient` used to fetch keys from a key vault */ diff --git a/src/encrypter.ts b/src/encrypter.ts index ee95f0ba1bf..d24e0de2b0a 100644 --- a/src/encrypter.ts +++ b/src/encrypter.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -import { deserialize, serialize } from './bson'; import { MONGO_CLIENT_EVENTS } from './constants'; import type { AutoEncrypter, AutoEncryptionOptions } from './deps'; import { MongoInvalidArgumentError, MongoMissingDependencyError } from './error'; @@ -58,12 +57,6 @@ export class Encrypter { }; } - options.autoEncryption.bson = Object.create(null); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - options.autoEncryption.bson!.serialize = serialize; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - options.autoEncryption.bson!.deserialize = deserialize; - this.autoEncrypter = new AutoEncrypterClass(client, options.autoEncryption); } diff --git a/src/sdam/topology.ts b/src/sdam/topology.ts index 4d1f40329c9..3b447a6f00c 100644 --- a/src/sdam/topology.ts +++ b/src/sdam/topology.ts @@ -2,7 +2,6 @@ import { clearTimeout, setTimeout } from 'timers'; import { promisify } from 'util'; import type { BSONSerializeOptions, Document } from '../bson'; -import { deserialize, serialize } from '../bson'; import type { MongoCredentials } from '../cmap/auth/mongo_credentials'; import type { ConnectionEvents, DestroyOptions } from '../cmap/connection'; import type { CloseOptions, ConnectionPoolEvents } from '../cmap/connection_pool'; @@ -222,16 +221,6 @@ export class Topology extends TypedEventEmitter { /** @event */ static readonly TIMEOUT = TIMEOUT; - /** - * @internal - * - * @privateRemarks - * mongodb-client-encryption's class ClientEncryption falls back to finding the bson lib - * defined on client.topology.bson, in order to maintain compatibility with any version - * of mongodb-client-encryption we keep a reference to serialize and deserialize here. - */ - bson: { serialize: typeof serialize; deserialize: typeof deserialize }; - selectServerAsync: ( selector: string | ReadPreference | ServerSelector, options: SelectServerOptions @@ -251,12 +240,6 @@ export class Topology extends TypedEventEmitter { ) => this.selectServer(selector, options, callback as any) ); - // Saving a reference to these BSON functions - // supports v2.2.0 and older versions of mongodb-client-encryption - this.bson = Object.create(null); - this.bson.serialize = serialize; - this.bson.deserialize = deserialize; - // Options should only be undefined in tests, MongoClient will always have defined options options = options ?? { hosts: [HostAddress.fromString('localhost:27017')], diff --git a/test/action/dependency.test.ts b/test/action/dependency.test.ts index 1ca7afe43ec..88f890bc6e4 100644 --- a/test/action/dependency.test.ts +++ b/test/action/dependency.test.ts @@ -7,7 +7,11 @@ import { expect } from 'chai'; import { dependencies, peerDependencies, peerDependenciesMeta } from '../../package.json'; const EXPECTED_DEPENDENCIES = ['bson', 'mongodb-connection-string-url', 'socks']; -const EXPECTED_PEER_DEPENDENCIES = ['@aws-sdk/credential-providers', 'snappy']; +const EXPECTED_PEER_DEPENDENCIES = [ + '@aws-sdk/credential-providers', + 'snappy', + 'mongodb-client-encryption' +]; describe('package.json', function () { describe('dependencies', function () {