mongodb 6.8.0-dev.20240905.sha.65e0e15c → 6.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -14
- package/lib/bson.js +13 -4
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +21 -16
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +8 -10
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +3 -14
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +7 -25
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/crypto_callbacks.js +6 -6
- package/lib/client-side-encryption/crypto_callbacks.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +5 -9
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/client-side-encryption/providers/aws.js +2 -1
- package/lib/client-side-encryption/providers/aws.js.map +1 -1
- package/lib/client-side-encryption/providers/azure.js +5 -5
- package/lib/client-side-encryption/providers/azure.js.map +1 -1
- package/lib/client-side-encryption/providers/gcp.js +2 -1
- package/lib/client-side-encryption/providers/gcp.js.map +1 -1
- package/lib/client-side-encryption/providers/index.js +3 -2
- package/lib/client-side-encryption/providers/index.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +4 -9
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +4 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongocr.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +3 -2
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +2 -0
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +5 -62
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +7 -9
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +5 -3
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +9 -11
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +3 -7
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +5 -5
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/metrics.js +1 -1
- package/lib/cmap/metrics.js.map +1 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +5 -5
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/cmap/wire_protocol/on_data.js +2 -1
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js +3 -12
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +15 -6
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +3 -2
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +5 -10
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +16 -25
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +2 -2
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +4 -4
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +1 -1
- package/lib/db.js.map +1 -1
- package/lib/deps.js +8 -16
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +14 -19
- package/lib/error.js.map +1 -1
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +4 -1
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +1 -1
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +4 -0
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +1 -15
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_logger.js +8 -8
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +0 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +0 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/collections.js.map +1 -1
- package/lib/operations/command.js +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +2 -2
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +109 -111
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +8 -2
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js +5 -5
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +2 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_concern.js.map +1 -1
- package/lib/read_preference.js +1 -1
- package/lib/read_preference.js.map +1 -1
- package/lib/sdam/common.js +3 -3
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/monitor.js +5 -1
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +2 -2
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +3 -3
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -5
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +3 -2
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +1 -1
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +218 -221
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +3 -2
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +1 -0
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js +2 -2
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +51 -49
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js +2 -2
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +143 -146
- package/package.json +28 -27
- package/src/bson.ts +13 -1
- package/src/bulk/common.ts +18 -18
- package/src/change_stream.ts +15 -33
- package/src/client-side-encryption/auto_encrypter.ts +82 -18
- package/src/client-side-encryption/client_encryption.ts +54 -51
- package/src/client-side-encryption/mongocryptd_manager.ts +6 -10
- package/src/client-side-encryption/state_machine.ts +6 -28
- package/src/cmap/auth/gssapi.ts +1 -1
- package/src/cmap/auth/mongodb_aws.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
- package/src/cmap/commands.ts +5 -70
- package/src/cmap/connect.ts +1 -3
- package/src/cmap/connection.ts +4 -3
- package/src/cmap/connection_pool.ts +9 -17
- package/src/cmap/connection_pool_events.ts +2 -34
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/constants.ts +2 -2
- package/src/cmap/wire_protocol/on_demand/document.ts +14 -18
- package/src/cmap/wire_protocol/responses.ts +23 -5
- package/src/cmap/wire_protocol/shared.ts +2 -1
- package/src/collection.ts +15 -16
- package/src/connection_string.ts +2 -8
- package/src/constants.ts +0 -1
- package/src/cursor/abstract_cursor.ts +28 -42
- package/src/cursor/aggregation_cursor.ts +5 -7
- package/src/cursor/find_cursor.ts +1 -1
- package/src/deps.ts +1 -8
- package/src/error.ts +14 -33
- package/src/gridfs/download.ts +4 -28
- package/src/gridfs/upload.ts +6 -1
- package/src/index.ts +6 -6
- package/src/mongo_client.ts +3 -25
- package/src/mongo_logger.ts +3 -5
- package/src/mongo_types.ts +68 -69
- package/src/operations/aggregate.ts +1 -2
- package/src/operations/bulk_write.ts +2 -2
- package/src/operations/command.ts +1 -1
- package/src/operations/execute_operation.ts +131 -137
- package/src/operations/find_and_modify.ts +7 -2
- package/src/operations/insert.ts +4 -3
- package/src/operations/operation.ts +10 -7
- package/src/operations/search_indexes/drop.ts +1 -4
- package/src/sdam/monitor.ts +5 -3
- package/src/sdam/server.ts +1 -1
- package/src/sdam/server_description.ts +6 -5
- package/src/sdam/srv_polling.ts +2 -1
- package/src/sessions.ts +277 -291
- package/src/sort.ts +1 -1
- package/src/timeout.ts +1 -0
- package/src/transactions.ts +2 -1
- package/src/utils.ts +4 -9
- package/src/write_concern.ts +2 -2
- package/tsconfig.json +1 -2
- package/lib/beta.d.ts +0 -7900
- package/lib/beta.js +0 -21
- package/lib/beta.js.map +0 -1
- package/lib/operations/client_bulk_write/command_builder.js +0 -198
- package/lib/operations/client_bulk_write/command_builder.js.map +0 -1
- package/lib/operations/client_bulk_write/common.js +0 -3
- package/lib/operations/client_bulk_write/common.js.map +0 -1
- package/lib/resource_management.js +0 -58
- package/lib/resource_management.js.map +0 -1
- package/src/beta.ts +0 -22
- package/src/operations/client_bulk_write/command_builder.ts +0 -283
- package/src/operations/client_bulk_write/common.ts +0 -146
- package/src/resource_management.ts +0 -74
package/src/bulk/common.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promisify } from 'util';
|
|
2
2
|
|
|
3
|
-
import { type BSONSerializeOptions, type Document,
|
|
3
|
+
import { type BSONSerializeOptions, type Document, resolveBSONOptions } from '../bson';
|
|
4
4
|
import type { Collection } from '../collection';
|
|
5
5
|
import {
|
|
6
6
|
type AnyError,
|
|
@@ -20,12 +20,12 @@ import { makeUpdateStatement, UpdateOperation, type UpdateStatement } from '../o
|
|
|
20
20
|
import type { Server } from '../sdam/server';
|
|
21
21
|
import type { Topology } from '../sdam/topology';
|
|
22
22
|
import type { ClientSession } from '../sessions';
|
|
23
|
+
import { maybeAddIdToDocuments } from '../utils';
|
|
23
24
|
import {
|
|
24
25
|
applyRetryableWrites,
|
|
25
26
|
type Callback,
|
|
26
27
|
getTopology,
|
|
27
28
|
hasAtomicOperators,
|
|
28
|
-
maybeAddIdToDocuments,
|
|
29
29
|
type MongoDBNamespace,
|
|
30
30
|
resolveOptions
|
|
31
31
|
} from '../utils';
|
|
@@ -294,7 +294,7 @@ export class BulkWriteResult {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
toString(): string {
|
|
297
|
-
return `BulkWriteResult(${
|
|
297
|
+
return `BulkWriteResult(${this.result})`;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
isOk(): boolean {
|
|
@@ -583,12 +583,13 @@ function executeCommands(
|
|
|
583
583
|
const operation = isInsertBatch(batch)
|
|
584
584
|
? new InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
585
585
|
: isUpdateBatch(batch)
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
586
|
+
? new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
587
|
+
: isDeleteBatch(batch)
|
|
588
|
+
? new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
589
|
+
: null;
|
|
590
590
|
|
|
591
591
|
if (operation != null) {
|
|
592
|
+
// eslint-disable-next-line github/no-then
|
|
592
593
|
executeOperation(bulkOperation.s.collection.client, operation).then(
|
|
593
594
|
result => resultHandler(undefined, result),
|
|
594
595
|
error => resultHandler(error)
|
|
@@ -615,8 +616,8 @@ function handleMongoWriteConcernError(
|
|
|
615
616
|
callback(
|
|
616
617
|
new MongoBulkWriteError(
|
|
617
618
|
{
|
|
618
|
-
message: err.result
|
|
619
|
-
code: err.result
|
|
619
|
+
message: err.result?.writeConcernError.errmsg,
|
|
620
|
+
code: err.result?.writeConcernError.result
|
|
620
621
|
},
|
|
621
622
|
new BulkWriteResult(bulkResult, isOrdered)
|
|
622
623
|
)
|
|
@@ -918,11 +919,7 @@ export abstract class BulkOperationBase {
|
|
|
918
919
|
* Create a new OrderedBulkOperation or UnorderedBulkOperation instance
|
|
919
920
|
* @internal
|
|
920
921
|
*/
|
|
921
|
-
constructor(
|
|
922
|
-
private collection: Collection,
|
|
923
|
-
options: BulkWriteOptions,
|
|
924
|
-
isOrdered: boolean
|
|
925
|
-
) {
|
|
922
|
+
constructor(private collection: Collection, options: BulkWriteOptions, isOrdered: boolean) {
|
|
926
923
|
// determine whether bulkOperation is ordered or unordered
|
|
927
924
|
this.isOrdered = isOrdered;
|
|
928
925
|
|
|
@@ -1181,10 +1178,6 @@ export abstract class BulkOperationBase {
|
|
|
1181
1178
|
);
|
|
1182
1179
|
}
|
|
1183
1180
|
|
|
1184
|
-
get length(): number {
|
|
1185
|
-
return this.s.currentIndex;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
1181
|
get bsonOptions(): BSONSerializeOptions {
|
|
1189
1182
|
return this.s.bsonOptions;
|
|
1190
1183
|
}
|
|
@@ -1281,6 +1274,13 @@ export abstract class BulkOperationBase {
|
|
|
1281
1274
|
}
|
|
1282
1275
|
}
|
|
1283
1276
|
|
|
1277
|
+
Object.defineProperty(BulkOperationBase.prototype, 'length', {
|
|
1278
|
+
enumerable: true,
|
|
1279
|
+
get() {
|
|
1280
|
+
return this.s.currentIndex;
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
1284
|
function isInsertBatch(batch: Batch): boolean {
|
|
1285
1285
|
return batch.batchType === BatchType.INSERT;
|
|
1286
1286
|
}
|
package/src/change_stream.ts
CHANGED
|
@@ -18,7 +18,6 @@ import { type InferIdType, TypedEventEmitter } from './mongo_types';
|
|
|
18
18
|
import type { AggregateOptions } from './operations/aggregate';
|
|
19
19
|
import type { CollationOptions, OperationParent } from './operations/command';
|
|
20
20
|
import type { ReadPreference } from './read_preference';
|
|
21
|
-
import { type AsyncDisposable, configureResourceManagement } from './resource_management';
|
|
22
21
|
import type { ServerSessionId } from './sessions';
|
|
23
22
|
import { filterOptions, getTopology, type MongoDBNamespace, squashError } from './utils';
|
|
24
23
|
|
|
@@ -44,7 +43,7 @@ const CHANGE_DOMAIN_TYPES = {
|
|
|
44
43
|
CLUSTER: Symbol('Cluster')
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE]
|
|
46
|
+
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE];
|
|
48
47
|
|
|
49
48
|
const NO_RESUME_TOKEN_ERROR =
|
|
50
49
|
'A change stream document has been received that lacks a resume token (_id).';
|
|
@@ -545,23 +544,9 @@ export type ChangeStreamEvents<
|
|
|
545
544
|
* @public
|
|
546
545
|
*/
|
|
547
546
|
export class ChangeStream<
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>>
|
|
552
|
-
implements AsyncDisposable
|
|
553
|
-
{
|
|
554
|
-
/**
|
|
555
|
-
* @beta
|
|
556
|
-
* @experimental
|
|
557
|
-
* An alias for {@link ChangeStream.close|ChangeStream.close()}.
|
|
558
|
-
*/
|
|
559
|
-
declare [Symbol.asyncDispose]: () => Promise<void>;
|
|
560
|
-
/** @internal */
|
|
561
|
-
async asyncDispose() {
|
|
562
|
-
await this.close();
|
|
563
|
-
}
|
|
564
|
-
|
|
547
|
+
TSchema extends Document = Document,
|
|
548
|
+
TChange extends Document = ChangeStreamDocument<TSchema>
|
|
549
|
+
> extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>> {
|
|
565
550
|
pipeline: Document[];
|
|
566
551
|
/**
|
|
567
552
|
* @remarks WriteConcern can still be present on the options because
|
|
@@ -680,7 +665,7 @@ export class ChangeStream<
|
|
|
680
665
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
681
666
|
// This loop continues until either a change event is received or until a resume attempt
|
|
682
667
|
// fails.
|
|
683
|
-
|
|
668
|
+
// eslint-disable-next-line no-constant-condition
|
|
684
669
|
while (true) {
|
|
685
670
|
try {
|
|
686
671
|
const hasNext = await this.cursor.hasNext();
|
|
@@ -706,7 +691,7 @@ export class ChangeStream<
|
|
|
706
691
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
707
692
|
// This loop continues until either a change event is received or until a resume attempt
|
|
708
693
|
// fails.
|
|
709
|
-
|
|
694
|
+
// eslint-disable-next-line no-constant-condition
|
|
710
695
|
while (true) {
|
|
711
696
|
try {
|
|
712
697
|
const change = await this.cursor.next();
|
|
@@ -735,7 +720,7 @@ export class ChangeStream<
|
|
|
735
720
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
736
721
|
// This loop continues until either a change event is received or until a resume attempt
|
|
737
722
|
// fails.
|
|
738
|
-
|
|
723
|
+
// eslint-disable-next-line no-constant-condition
|
|
739
724
|
while (true) {
|
|
740
725
|
try {
|
|
741
726
|
const change = await this.cursor.tryNext();
|
|
@@ -780,9 +765,7 @@ export class ChangeStream<
|
|
|
780
765
|
return this[kClosed] || this.cursor.closed;
|
|
781
766
|
}
|
|
782
767
|
|
|
783
|
-
/**
|
|
784
|
-
* Frees the internal resources used by the change stream.
|
|
785
|
-
*/
|
|
768
|
+
/** Close the Change Stream */
|
|
786
769
|
async close(): Promise<void> {
|
|
787
770
|
this[kClosed] = true;
|
|
788
771
|
|
|
@@ -850,10 +833,10 @@ export class ChangeStream<
|
|
|
850
833
|
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
|
|
851
834
|
? (this.parent as MongoClient)
|
|
852
835
|
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
836
|
+
? (this.parent as Db).client
|
|
837
|
+
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
|
|
838
|
+
? (this.parent as Collection).client
|
|
839
|
+
: null;
|
|
857
840
|
|
|
858
841
|
if (client == null) {
|
|
859
842
|
// This should never happen because of the assertion in the constructor
|
|
@@ -884,6 +867,7 @@ export class ChangeStream<
|
|
|
884
867
|
private _closeEmitterModeWithError(error: AnyError): void {
|
|
885
868
|
this.emit(ChangeStream.ERROR, error);
|
|
886
869
|
|
|
870
|
+
// eslint-disable-next-line github/no-then
|
|
887
871
|
this.close().then(undefined, squashError);
|
|
888
872
|
}
|
|
889
873
|
|
|
@@ -948,7 +932,7 @@ export class ChangeStream<
|
|
|
948
932
|
|
|
949
933
|
if (isResumableError(changeStreamError, this.cursor.maxWireVersion)) {
|
|
950
934
|
this._endStream();
|
|
951
|
-
|
|
935
|
+
// eslint-disable-next-line github/no-then
|
|
952
936
|
this.cursor.close().then(undefined, squashError);
|
|
953
937
|
|
|
954
938
|
const topology = getTopology(this.parent);
|
|
@@ -956,7 +940,7 @@ export class ChangeStream<
|
|
|
956
940
|
.selectServer(this.cursor.readPreference, {
|
|
957
941
|
operationName: 'reconnect topology in change stream'
|
|
958
942
|
})
|
|
959
|
-
|
|
943
|
+
// eslint-disable-next-line github/no-then
|
|
960
944
|
.then(
|
|
961
945
|
() => {
|
|
962
946
|
this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
|
|
@@ -1002,5 +986,3 @@ export class ChangeStream<
|
|
|
1002
986
|
}
|
|
1003
987
|
}
|
|
1004
988
|
}
|
|
1005
|
-
|
|
1006
|
-
configureResourceManagement(ChangeStream.prototype);
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
type MongoCryptConstructor,
|
|
4
4
|
type MongoCryptOptions
|
|
5
5
|
} from 'mongodb-client-encryption';
|
|
6
|
-
import * as net from 'net';
|
|
7
6
|
|
|
8
7
|
import { deserialize, type Document, serialize } from '../bson';
|
|
9
8
|
import { type CommandOptions, type ProxyOptions } from '../cmap/connection';
|
|
@@ -12,7 +11,6 @@ import { getMongoDBClientEncryption } from '../deps';
|
|
|
12
11
|
import { MongoRuntimeError } from '../error';
|
|
13
12
|
import { MongoClient, type MongoClientOptions } from '../mongo_client';
|
|
14
13
|
import { MongoDBCollectionNamespace } from '../utils';
|
|
15
|
-
import { autoSelectSocketOptions } from './client_encryption';
|
|
16
14
|
import * as cryptoCallbacks from './crypto_callbacks';
|
|
17
15
|
import { MongoCryptInvalidArgumentError } from './errors';
|
|
18
16
|
import { MongocryptdManager } from './mongocryptd_manager';
|
|
@@ -28,7 +26,85 @@ export interface AutoEncryptionOptions {
|
|
|
28
26
|
/** The namespace where keys are stored in the key vault */
|
|
29
27
|
keyVaultNamespace?: string;
|
|
30
28
|
/** Configuration options that are used by specific KMS providers during key generation, encryption, and decryption. */
|
|
31
|
-
kmsProviders?:
|
|
29
|
+
kmsProviders?: {
|
|
30
|
+
/** Configuration options for using 'aws' as your KMS provider */
|
|
31
|
+
aws?:
|
|
32
|
+
| {
|
|
33
|
+
/** The access key used for the AWS KMS provider */
|
|
34
|
+
accessKeyId: string;
|
|
35
|
+
/** The secret access key used for the AWS KMS provider */
|
|
36
|
+
secretAccessKey: string;
|
|
37
|
+
/**
|
|
38
|
+
* An optional AWS session token that will be used as the
|
|
39
|
+
* X-Amz-Security-Token header for AWS requests.
|
|
40
|
+
*/
|
|
41
|
+
sessionToken?: string;
|
|
42
|
+
}
|
|
43
|
+
| Record<string, never>;
|
|
44
|
+
/** Configuration options for using 'local' as your KMS provider */
|
|
45
|
+
local?: {
|
|
46
|
+
/**
|
|
47
|
+
* The master key used to encrypt/decrypt data keys.
|
|
48
|
+
* A 96-byte long Buffer or base64 encoded string.
|
|
49
|
+
*/
|
|
50
|
+
key: Buffer | string;
|
|
51
|
+
};
|
|
52
|
+
/** Configuration options for using 'azure' as your KMS provider */
|
|
53
|
+
azure?:
|
|
54
|
+
| {
|
|
55
|
+
/** The tenant ID identifies the organization for the account */
|
|
56
|
+
tenantId: string;
|
|
57
|
+
/** The client ID to authenticate a registered application */
|
|
58
|
+
clientId: string;
|
|
59
|
+
/** The client secret to authenticate a registered application */
|
|
60
|
+
clientSecret: string;
|
|
61
|
+
/**
|
|
62
|
+
* If present, a host with optional port. E.g. "example.com" or "example.com:443".
|
|
63
|
+
* This is optional, and only needed if customer is using a non-commercial Azure instance
|
|
64
|
+
* (e.g. a government or China account, which use different URLs).
|
|
65
|
+
* Defaults to "login.microsoftonline.com"
|
|
66
|
+
*/
|
|
67
|
+
identityPlatformEndpoint?: string | undefined;
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
/**
|
|
71
|
+
* If present, an access token to authenticate with Azure.
|
|
72
|
+
*/
|
|
73
|
+
accessToken: string;
|
|
74
|
+
}
|
|
75
|
+
| Record<string, never>;
|
|
76
|
+
/** Configuration options for using 'gcp' as your KMS provider */
|
|
77
|
+
gcp?:
|
|
78
|
+
| {
|
|
79
|
+
/** The service account email to authenticate */
|
|
80
|
+
email: string;
|
|
81
|
+
/** A PKCS#8 encrypted key. This can either be a base64 string or a binary representation */
|
|
82
|
+
privateKey: string | Buffer;
|
|
83
|
+
/**
|
|
84
|
+
* If present, a host with optional port. E.g. "example.com" or "example.com:443".
|
|
85
|
+
* Defaults to "oauth2.googleapis.com"
|
|
86
|
+
*/
|
|
87
|
+
endpoint?: string | undefined;
|
|
88
|
+
}
|
|
89
|
+
| {
|
|
90
|
+
/**
|
|
91
|
+
* If present, an access token to authenticate with GCP.
|
|
92
|
+
*/
|
|
93
|
+
accessToken: string;
|
|
94
|
+
}
|
|
95
|
+
| Record<string, never>;
|
|
96
|
+
/**
|
|
97
|
+
* Configuration options for using 'kmip' as your KMS provider
|
|
98
|
+
*/
|
|
99
|
+
kmip?: {
|
|
100
|
+
/**
|
|
101
|
+
* The output endpoint string.
|
|
102
|
+
* The endpoint consists of a hostname and port separated by a colon.
|
|
103
|
+
* E.g. "example.com:123". A port is always present.
|
|
104
|
+
*/
|
|
105
|
+
endpoint?: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
32
108
|
/**
|
|
33
109
|
* A map of namespaces to a local JSON schema for encryption
|
|
34
110
|
*
|
|
@@ -299,20 +375,10 @@ export class AutoEncrypter {
|
|
|
299
375
|
serverSelectionTimeoutMS: 10000
|
|
300
376
|
};
|
|
301
377
|
|
|
302
|
-
if (
|
|
303
|
-
(options.extraOptions == null || typeof options.extraOptions.mongocryptdURI !== 'string') &&
|
|
304
|
-
!net.getDefaultAutoSelectFamily
|
|
305
|
-
) {
|
|
306
|
-
// Only set family if autoSelectFamily options are not supported.
|
|
378
|
+
if (options.extraOptions == null || typeof options.extraOptions.mongocryptdURI !== 'string') {
|
|
307
379
|
clientOptions.family = 4;
|
|
308
380
|
}
|
|
309
381
|
|
|
310
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
311
|
-
// @ts-ignore: TS complains as this always returns true on versions where it is present.
|
|
312
|
-
if (net.getDefaultAutoSelectFamily) {
|
|
313
|
-
Object.assign(clientOptions, autoSelectSocketOptions(this._client.options));
|
|
314
|
-
}
|
|
315
|
-
|
|
316
382
|
this._mongocryptdClient = new MongoClient(this._mongocryptdManager.uri, clientOptions);
|
|
317
383
|
}
|
|
318
384
|
}
|
|
@@ -391,8 +457,7 @@ export class AutoEncrypter {
|
|
|
391
457
|
promoteValues: false,
|
|
392
458
|
promoteLongs: false,
|
|
393
459
|
proxyOptions: this._proxyOptions,
|
|
394
|
-
tlsOptions: this._tlsOptions
|
|
395
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
460
|
+
tlsOptions: this._tlsOptions
|
|
396
461
|
});
|
|
397
462
|
|
|
398
463
|
return deserialize(await stateMachine.execute(this, context), {
|
|
@@ -412,8 +477,7 @@ export class AutoEncrypter {
|
|
|
412
477
|
const stateMachine = new StateMachine({
|
|
413
478
|
...options,
|
|
414
479
|
proxyOptions: this._proxyOptions,
|
|
415
|
-
tlsOptions: this._tlsOptions
|
|
416
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
480
|
+
tlsOptions: this._tlsOptions
|
|
417
481
|
});
|
|
418
482
|
|
|
419
483
|
return await stateMachine.execute(this, context);
|
|
@@ -5,22 +5,14 @@ import type {
|
|
|
5
5
|
MongoCryptOptions
|
|
6
6
|
} from 'mongodb-client-encryption';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
type Binary,
|
|
10
|
-
deserialize,
|
|
11
|
-
type Document,
|
|
12
|
-
type Int32,
|
|
13
|
-
type Long,
|
|
14
|
-
serialize,
|
|
15
|
-
type UUID
|
|
16
|
-
} from '../bson';
|
|
8
|
+
import { type Binary, deserialize, type Document, type Long, serialize, type UUID } from '../bson';
|
|
17
9
|
import { type AnyBulkWriteOperation, type BulkWriteResult } from '../bulk/common';
|
|
18
10
|
import { type ProxyOptions } from '../cmap/connection';
|
|
19
11
|
import { type Collection } from '../collection';
|
|
20
12
|
import { type FindCursor } from '../cursor/find_cursor';
|
|
21
13
|
import { type Db } from '../db';
|
|
22
14
|
import { getMongoDBClientEncryption } from '../deps';
|
|
23
|
-
import { type MongoClient
|
|
15
|
+
import { type MongoClient } from '../mongo_client';
|
|
24
16
|
import { type Filter, type WithId } from '../mongo_types';
|
|
25
17
|
import { type CreateCollectionOptions } from '../operations/create_collection';
|
|
26
18
|
import { type DeleteResult } from '../operations/delete';
|
|
@@ -36,11 +28,7 @@ import {
|
|
|
36
28
|
type KMSProviders,
|
|
37
29
|
refreshKMSCredentials
|
|
38
30
|
} from './providers/index';
|
|
39
|
-
import {
|
|
40
|
-
type ClientEncryptionSocketOptions,
|
|
41
|
-
type CSFLEKMSTlsOptions,
|
|
42
|
-
StateMachine
|
|
43
|
-
} from './state_machine';
|
|
31
|
+
import { type CSFLEKMSTlsOptions, StateMachine } from './state_machine';
|
|
44
32
|
|
|
45
33
|
/**
|
|
46
34
|
* @public
|
|
@@ -211,8 +199,7 @@ export class ClientEncryption {
|
|
|
211
199
|
|
|
212
200
|
const stateMachine = new StateMachine({
|
|
213
201
|
proxyOptions: this._proxyOptions,
|
|
214
|
-
tlsOptions: this._tlsOptions
|
|
215
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
202
|
+
tlsOptions: this._tlsOptions
|
|
216
203
|
});
|
|
217
204
|
|
|
218
205
|
const dataKey = deserialize(await stateMachine.execute(this, context)) as DataKey;
|
|
@@ -269,8 +256,7 @@ export class ClientEncryption {
|
|
|
269
256
|
const context = this._mongoCrypt.makeRewrapManyDataKeyContext(filterBson, keyEncryptionKeyBson);
|
|
270
257
|
const stateMachine = new StateMachine({
|
|
271
258
|
proxyOptions: this._proxyOptions,
|
|
272
|
-
tlsOptions: this._tlsOptions
|
|
273
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
259
|
+
tlsOptions: this._tlsOptions
|
|
274
260
|
});
|
|
275
261
|
|
|
276
262
|
const { v: dataKeys } = deserialize(await stateMachine.execute(this, context));
|
|
@@ -609,7 +595,9 @@ export class ClientEncryption {
|
|
|
609
595
|
/**
|
|
610
596
|
* Encrypts a Match Expression or Aggregate Expression to query a range index.
|
|
611
597
|
*
|
|
612
|
-
* Only supported when queryType is "
|
|
598
|
+
* Only supported when queryType is "rangePreview" and algorithm is "RangePreview".
|
|
599
|
+
*
|
|
600
|
+
* @experimental The Range algorithm is experimental only. It is not intended for production use. It is subject to breaking changes.
|
|
613
601
|
*
|
|
614
602
|
* @param expression - a BSON document of one of the following forms:
|
|
615
603
|
* 1. A Match Expression of this form:
|
|
@@ -649,8 +637,7 @@ export class ClientEncryption {
|
|
|
649
637
|
|
|
650
638
|
const stateMachine = new StateMachine({
|
|
651
639
|
proxyOptions: this._proxyOptions,
|
|
652
|
-
tlsOptions: this._tlsOptions
|
|
653
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
640
|
+
tlsOptions: this._tlsOptions
|
|
654
641
|
});
|
|
655
642
|
|
|
656
643
|
const { v } = deserialize(await stateMachine.execute(this, context));
|
|
@@ -728,8 +715,7 @@ export class ClientEncryption {
|
|
|
728
715
|
const valueBuffer = serialize({ v: value });
|
|
729
716
|
const stateMachine = new StateMachine({
|
|
730
717
|
proxyOptions: this._proxyOptions,
|
|
731
|
-
tlsOptions: this._tlsOptions
|
|
732
|
-
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
718
|
+
tlsOptions: this._tlsOptions
|
|
733
719
|
});
|
|
734
720
|
const context = this._mongoCrypt.makeExplicitEncryptionContext(valueBuffer, contextOptions);
|
|
735
721
|
|
|
@@ -751,7 +737,7 @@ export interface ClientEncryptionEncryptOptions {
|
|
|
751
737
|
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
|
|
752
738
|
| 'Indexed'
|
|
753
739
|
| 'Unindexed'
|
|
754
|
-
| '
|
|
740
|
+
| 'RangePreview';
|
|
755
741
|
|
|
756
742
|
/**
|
|
757
743
|
* The id of the Binary dataKey to use for encryption
|
|
@@ -767,11 +753,13 @@ export interface ClientEncryptionEncryptOptions {
|
|
|
767
753
|
contentionFactor?: bigint | number;
|
|
768
754
|
|
|
769
755
|
/**
|
|
770
|
-
* The query type.
|
|
756
|
+
* The query type supported. Only the queryType `equality` is stable.
|
|
757
|
+
*
|
|
758
|
+
* @experimental Public Technical Preview: The queryType `rangePreview` is experimental.
|
|
771
759
|
*/
|
|
772
|
-
queryType?: 'equality' | '
|
|
760
|
+
queryType?: 'equality' | 'rangePreview';
|
|
773
761
|
|
|
774
|
-
/** The index options for a Queryable Encryption field supporting "
|
|
762
|
+
/** @experimental Public Technical Preview: The index options for a Queryable Encryption field supporting "rangePreview" queries.*/
|
|
775
763
|
rangeOptions?: RangeOptions;
|
|
776
764
|
}
|
|
777
765
|
|
|
@@ -959,37 +947,52 @@ export interface ClientEncryptionRewrapManyDataKeyResult {
|
|
|
959
947
|
|
|
960
948
|
/**
|
|
961
949
|
* @public
|
|
962
|
-
* RangeOptions specifies index options for a Queryable Encryption field supporting "
|
|
963
|
-
* min, max, sparsity,
|
|
950
|
+
* RangeOptions specifies index options for a Queryable Encryption field supporting "rangePreview" queries.
|
|
951
|
+
* min, max, sparsity, and range must match the values set in the encryptedFields of the destination collection.
|
|
964
952
|
* For double and decimal128, min/max/precision must all be set, or all be unset.
|
|
965
953
|
*/
|
|
966
954
|
export interface RangeOptions {
|
|
967
|
-
/** min is the minimum value for the encrypted index. Required if precision is set. */
|
|
968
955
|
min?: any;
|
|
969
|
-
/** max is the minimum value for the encrypted index. Required if precision is set. */
|
|
970
956
|
max?: any;
|
|
971
|
-
|
|
972
|
-
sparsity?: Long | bigint;
|
|
973
|
-
/** trimFactor may be used to tune performance. must be non-negative. When omitted, a default value is used. */
|
|
974
|
-
trimFactor?: Int32 | number;
|
|
975
|
-
/* precision determines the number of significant digits after the decimal point. May only be set for double or decimal128. */
|
|
957
|
+
sparsity: Long;
|
|
976
958
|
precision?: number;
|
|
977
959
|
}
|
|
978
960
|
|
|
979
961
|
/**
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
* @returns ClientEncryptionSocketOptions
|
|
962
|
+
* @public
|
|
963
|
+
* Options to provide when encrypting data.
|
|
983
964
|
*/
|
|
984
|
-
export
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
965
|
+
export interface ClientEncryptionEncryptOptions {
|
|
966
|
+
/**
|
|
967
|
+
* The algorithm to use for encryption.
|
|
968
|
+
*/
|
|
969
|
+
algorithm:
|
|
970
|
+
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic'
|
|
971
|
+
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
|
|
972
|
+
| 'Indexed'
|
|
973
|
+
| 'Unindexed'
|
|
974
|
+
| 'RangePreview';
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* The id of the Binary dataKey to use for encryption
|
|
978
|
+
*/
|
|
979
|
+
keyId?: Binary;
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* A unique string name corresponding to an already existing dataKey.
|
|
983
|
+
*/
|
|
984
|
+
keyAltName?: string;
|
|
985
|
+
|
|
986
|
+
/** The contention factor. */
|
|
987
|
+
contentionFactor?: bigint | number;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* The query type supported. Only the queryType `equality` is stable.
|
|
991
|
+
*
|
|
992
|
+
* @experimental Public Technical Preview: The queryType `rangePreview` is experimental.
|
|
993
|
+
*/
|
|
994
|
+
queryType?: 'equality' | 'rangePreview';
|
|
995
|
+
|
|
996
|
+
/** @experimental Public Technical Preview: The index options for a Queryable Encryption field supporting "rangePreview" queries.*/
|
|
997
|
+
rangeOptions?: RangeOptions;
|
|
995
998
|
}
|
|
@@ -12,8 +12,8 @@ export class MongocryptdManager {
|
|
|
12
12
|
|
|
13
13
|
uri: string;
|
|
14
14
|
bypassSpawn: boolean;
|
|
15
|
-
spawnPath
|
|
16
|
-
spawnArgs: Array<string
|
|
15
|
+
spawnPath: string;
|
|
16
|
+
spawnArgs: Array<string>;
|
|
17
17
|
_child?: ChildProcess;
|
|
18
18
|
|
|
19
19
|
constructor(extraOptions: AutoEncryptionExtraOptions = {}) {
|
|
@@ -24,13 +24,9 @@ export class MongocryptdManager {
|
|
|
24
24
|
|
|
25
25
|
this.bypassSpawn = !!extraOptions.mongocryptdBypassSpawn;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
Object.hasOwn(extraOptions, 'mongocryptdSpawnArgs') &&
|
|
32
|
-
Array.isArray(extraOptions.mongocryptdSpawnArgs)
|
|
33
|
-
) {
|
|
27
|
+
this.spawnPath = extraOptions.mongocryptdSpawnPath || '';
|
|
28
|
+
this.spawnArgs = [];
|
|
29
|
+
if (Array.isArray(extraOptions.mongocryptdSpawnArgs)) {
|
|
34
30
|
this.spawnArgs = this.spawnArgs.concat(extraOptions.mongocryptdSpawnArgs);
|
|
35
31
|
}
|
|
36
32
|
if (
|
|
@@ -49,7 +45,7 @@ export class MongocryptdManager {
|
|
|
49
45
|
async spawn(): Promise<void> {
|
|
50
46
|
const cmdName = this.spawnPath || 'mongocryptd';
|
|
51
47
|
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
53
49
|
const { spawn } = require('child_process') as typeof import('child_process');
|
|
54
50
|
|
|
55
51
|
// Spawned with stdio: ignore and detached: true
|
|
@@ -14,7 +14,7 @@ import { type ProxyOptions } from '../cmap/connection';
|
|
|
14
14
|
import { getSocks, type SocksLib } from '../deps';
|
|
15
15
|
import { type MongoClient, type MongoClientOptions } from '../mongo_client';
|
|
16
16
|
import { BufferPool, MongoDBCollectionNamespace, promiseWithResolvers } from '../utils';
|
|
17
|
-
import {
|
|
17
|
+
import { type DataKey } from './client_encryption';
|
|
18
18
|
import { MongoCryptError } from './errors';
|
|
19
19
|
import { type MongocryptdManager } from './mongocryptd_manager';
|
|
20
20
|
import { type KMSProviders } from './providers';
|
|
@@ -114,16 +114,6 @@ export type CSFLEKMSTlsOptions = {
|
|
|
114
114
|
[key: string]: ClientEncryptionTlsOptions | undefined;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
* @public
|
|
119
|
-
*
|
|
120
|
-
* Socket options to use for KMS requests.
|
|
121
|
-
*/
|
|
122
|
-
export type ClientEncryptionSocketOptions = Pick<
|
|
123
|
-
MongoClientOptions,
|
|
124
|
-
'autoSelectFamily' | 'autoSelectFamilyAttemptTimeout'
|
|
125
|
-
>;
|
|
126
|
-
|
|
127
117
|
/**
|
|
128
118
|
* This is kind of a hack. For `rewrapManyDataKey`, we have tests that
|
|
129
119
|
* guarantee that when there are no matching keys, `rewrapManyDataKey` returns
|
|
@@ -163,9 +153,6 @@ export type StateMachineOptions = {
|
|
|
163
153
|
|
|
164
154
|
/** TLS options for KMS requests, if set. */
|
|
165
155
|
tlsOptions: CSFLEKMSTlsOptions;
|
|
166
|
-
|
|
167
|
-
/** Socket specific options we support. */
|
|
168
|
-
socketOptions: ClientEncryptionSocketOptions;
|
|
169
156
|
} & Pick<BSONSerializeOptions, 'promoteLongs' | 'promoteValues'>;
|
|
170
157
|
|
|
171
158
|
/**
|
|
@@ -302,17 +289,10 @@ export class StateMachine {
|
|
|
302
289
|
async kmsRequest(request: MongoCryptKMSRequest): Promise<void> {
|
|
303
290
|
const parsedUrl = request.endpoint.split(':');
|
|
304
291
|
const port = parsedUrl[1] != null ? Number.parseInt(parsedUrl[1], 10) : HTTPS_PORT;
|
|
305
|
-
const
|
|
306
|
-
const options: tls.ConnectionOptions & {
|
|
307
|
-
host: string;
|
|
308
|
-
port: number;
|
|
309
|
-
autoSelectFamily?: boolean;
|
|
310
|
-
autoSelectFamilyAttemptTimeout?: number;
|
|
311
|
-
} = {
|
|
292
|
+
const options: tls.ConnectionOptions & { host: string; port: number } = {
|
|
312
293
|
host: parsedUrl[0],
|
|
313
294
|
servername: parsedUrl[0],
|
|
314
|
-
port
|
|
315
|
-
...socketOptions
|
|
295
|
+
port
|
|
316
296
|
};
|
|
317
297
|
const message = request.message;
|
|
318
298
|
const buffer = new BufferPool();
|
|
@@ -371,12 +351,10 @@ export class StateMachine {
|
|
|
371
351
|
|
|
372
352
|
try {
|
|
373
353
|
if (this.options.proxyOptions && this.options.proxyOptions.proxyHost) {
|
|
374
|
-
|
|
354
|
+
netSocket.connect({
|
|
375
355
|
host: this.options.proxyOptions.proxyHost,
|
|
376
|
-
port: this.options.proxyOptions.proxyPort || 1080
|
|
377
|
-
|
|
378
|
-
};
|
|
379
|
-
netSocket.connect(netSocketOptions);
|
|
356
|
+
port: this.options.proxyOptions.proxyPort || 1080
|
|
357
|
+
});
|
|
380
358
|
await willConnect;
|
|
381
359
|
|
|
382
360
|
try {
|
package/src/cmap/auth/gssapi.ts
CHANGED
|
@@ -168,7 +168,7 @@ export async function performGSSAPICanonicalizeHostName(
|
|
|
168
168
|
const results = await dns.promises.resolvePtr(address);
|
|
169
169
|
// If the ptr did not error but had no results, return the host.
|
|
170
170
|
return results.length > 0 ? results[0] : host;
|
|
171
|
-
} catch {
|
|
171
|
+
} catch (error) {
|
|
172
172
|
// This can error as ptr records may not exist for all ips. In this case
|
|
173
173
|
// fallback to a cname lookup as dns.lookup() does not return the
|
|
174
174
|
// cname.
|
|
@@ -78,8 +78,8 @@ export class MongoDBAWS extends AuthProvider {
|
|
|
78
78
|
accessKeyId && secretAccessKey && sessionToken
|
|
79
79
|
? { accessKeyId, secretAccessKey, sessionToken }
|
|
80
80
|
: accessKeyId && secretAccessKey
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
? { accessKeyId, secretAccessKey }
|
|
82
|
+
: undefined;
|
|
83
83
|
|
|
84
84
|
const db = credentials.source;
|
|
85
85
|
const nonce = await randomBytes(32);
|