mongodb 6.9.0 → 6.10.0-dev.20241024.sha.5c4355ad
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/lib/beta.d.ts +411 -16
- package/lib/bson.js +1 -0
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +60 -71
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/unordered.js +3 -3
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +3 -2
- package/lib/change_stream.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +5 -8
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js +10 -1
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +50 -18
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connection.js +9 -2
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +2 -2
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +26 -1
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/connection_string.js +1 -7
- package/lib/connection_string.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/client_bulk_write_cursor.js +52 -0
- package/lib/cursor/client_bulk_write_cursor.js.map +1 -0
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +1 -1
- package/lib/error.js +83 -10
- package/lib/error.js.map +1 -1
- package/lib/explain.js +6 -6
- package/lib/explain.js.map +1 -1
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +14 -0
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js +6 -2
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/client_bulk_write/client_bulk_write.js +83 -0
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
- package/lib/operations/client_bulk_write/command_builder.js +154 -19
- package/lib/operations/client_bulk_write/command_builder.js.map +1 -1
- package/lib/operations/client_bulk_write/executor.js +109 -0
- package/lib/operations/client_bulk_write/executor.js.map +1 -0
- package/lib/operations/client_bulk_write/results_merger.js +204 -0
- package/lib/operations/client_bulk_write/results_merger.js.map +1 -0
- package/lib/operations/execute_operation.js +7 -0
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/operation.js +5 -1
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/search_indexes/create.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/search_indexes/update.js.map +1 -1
- package/lib/read_concern.js +1 -1
- package/lib/sdam/server.js +2 -1
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +5 -2
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -2
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +5 -1
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +9 -2
- package/lib/sessions.js.map +1 -1
- package/lib/utils.js +30 -11
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +411 -16
- package/package.json +2 -2
- package/src/beta.ts +1 -1
- package/src/bson.ts +3 -0
- package/src/bulk/common.ts +80 -120
- package/src/bulk/unordered.ts +3 -4
- package/src/change_stream.ts +5 -2
- package/src/cmap/auth/mongo_credentials.ts +5 -9
- package/src/cmap/auth/mongodb_aws.ts +1 -1
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +1 -1
- package/src/cmap/auth/mongodb_oidc/command_builders.ts +1 -2
- package/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +1 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +1 -1
- package/src/cmap/auth/mongodb_oidc.ts +1 -2
- package/src/cmap/command_monitoring_events.ts +16 -2
- package/src/cmap/commands.ts +71 -25
- package/src/cmap/connection.ts +17 -4
- 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 +1 -2
- package/src/cmap/wire_protocol/responses.ts +31 -2
- package/src/connection_string.ts +2 -9
- package/src/cursor/aggregation_cursor.ts +2 -2
- package/src/cursor/client_bulk_write_cursor.ts +79 -0
- package/src/cursor/find_cursor.ts +2 -2
- package/src/db.ts +1 -1
- package/src/error.ts +105 -9
- package/src/explain.ts +47 -11
- package/src/index.ts +26 -1
- package/src/mongo_client.ts +30 -2
- package/src/mongo_client_auth_providers.ts +8 -2
- package/src/mongo_types.ts +2 -1
- package/src/operations/aggregate.ts +9 -1
- package/src/operations/client_bulk_write/client_bulk_write.ts +107 -0
- package/src/operations/client_bulk_write/command_builder.ts +216 -30
- package/src/operations/client_bulk_write/common.ts +148 -23
- package/src/operations/client_bulk_write/executor.ts +137 -0
- package/src/operations/client_bulk_write/results_merger.ts +260 -0
- package/src/operations/execute_operation.ts +8 -0
- package/src/operations/find.ts +8 -1
- package/src/operations/operation.ts +6 -1
- package/src/operations/search_indexes/create.ts +1 -2
- package/src/operations/search_indexes/drop.ts +1 -2
- package/src/operations/search_indexes/update.ts +1 -2
- package/src/read_concern.ts +1 -1
- package/src/sdam/server.ts +2 -1
- package/src/sdam/server_description.ts +11 -2
- package/src/sdam/server_selection.ts +5 -2
- package/src/sdam/srv_polling.ts +5 -2
- package/src/sdam/topology_description.ts +0 -1
- package/src/sessions.ts +16 -2
- package/src/utils.ts +45 -12
- package/src/write_concern.ts +4 -1
- package/lib/cmap/auth/mongocr.js +0 -35
- package/lib/cmap/auth/mongocr.js.map +0 -1
- package/src/cmap/auth/mongocr.ts +0 -38
|
@@ -11,7 +11,8 @@ export const Aspect = {
|
|
|
11
11
|
EXPLAINABLE: Symbol('EXPLAINABLE'),
|
|
12
12
|
SKIP_COLLATION: Symbol('SKIP_COLLATION'),
|
|
13
13
|
CURSOR_CREATING: Symbol('CURSOR_CREATING'),
|
|
14
|
-
MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER')
|
|
14
|
+
MUST_SELECT_SAME_SERVER: Symbol('MUST_SELECT_SAME_SERVER'),
|
|
15
|
+
COMMAND_BATCHING: Symbol('COMMAND_BATCHING')
|
|
15
16
|
} as const;
|
|
16
17
|
|
|
17
18
|
/** @public */
|
|
@@ -98,6 +99,10 @@ export abstract class AbstractOperation<TResult = any> {
|
|
|
98
99
|
this[kSession] = undefined;
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
resetBatch(): boolean {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
101
106
|
get canRetryRead(): boolean {
|
|
102
107
|
return this.hasAspect(Aspect.RETRYABLE) && this.hasAspect(Aspect.READ_OPERATION);
|
|
103
108
|
}
|
package/src/read_concern.ts
CHANGED
|
@@ -31,7 +31,7 @@ export class ReadConcern {
|
|
|
31
31
|
* A spec test exists that allows level to be any string.
|
|
32
32
|
* "invalid readConcern with out stage"
|
|
33
33
|
* @see ./test/spec/crud/v2/aggregate-out-readConcern.json
|
|
34
|
-
* @see https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.
|
|
34
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.md#unknown-levels-and-additional-options-for-string-based-readconcerns
|
|
35
35
|
*/
|
|
36
36
|
this.level = ReadConcernLevel[level] ?? level;
|
|
37
37
|
}
|
package/src/sdam/server.ts
CHANGED
|
@@ -69,6 +69,12 @@ export class ServerDescription {
|
|
|
69
69
|
setVersion: number | null;
|
|
70
70
|
electionId: ObjectId | null;
|
|
71
71
|
logicalSessionTimeoutMinutes: number | null;
|
|
72
|
+
/** The max message size in bytes for the server. */
|
|
73
|
+
maxMessageSizeBytes: number | null;
|
|
74
|
+
/** The max number of writes in a bulk write command. */
|
|
75
|
+
maxWriteBatchSize: number | null;
|
|
76
|
+
/** The max bson object size. */
|
|
77
|
+
maxBsonObjectSize: number | null;
|
|
72
78
|
|
|
73
79
|
// NOTE: does this belong here? It seems we should gossip the cluster time at the CMAP level
|
|
74
80
|
$clusterTime?: ClusterTime;
|
|
@@ -111,6 +117,9 @@ export class ServerDescription {
|
|
|
111
117
|
this.setVersion = hello?.setVersion ?? null;
|
|
112
118
|
this.electionId = hello?.electionId ?? null;
|
|
113
119
|
this.logicalSessionTimeoutMinutes = hello?.logicalSessionTimeoutMinutes ?? null;
|
|
120
|
+
this.maxMessageSizeBytes = hello?.maxMessageSizeBytes ?? null;
|
|
121
|
+
this.maxWriteBatchSize = hello?.maxWriteBatchSize ?? null;
|
|
122
|
+
this.maxBsonObjectSize = hello?.maxBsonObjectSize ?? null;
|
|
114
123
|
this.primary = hello?.primary ?? null;
|
|
115
124
|
this.me = hello?.me?.toLowerCase() ?? null;
|
|
116
125
|
this.$clusterTime = hello?.$clusterTime ?? null;
|
|
@@ -150,8 +159,8 @@ export class ServerDescription {
|
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
/**
|
|
153
|
-
* Determines if another `ServerDescription` is equal to this one per the rules defined
|
|
154
|
-
*
|
|
162
|
+
* Determines if another `ServerDescription` is equal to this one per the rules defined in the SDAM specification.
|
|
163
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.md
|
|
155
164
|
*/
|
|
156
165
|
equals(other?: ServerDescription | null): boolean {
|
|
157
166
|
// Despite using the comparator that would determine a nullish topologyVersion as greater than
|
|
@@ -75,7 +75,9 @@ export function secondaryWritableServerSelector(
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Reduces the passed in array of servers by the rules of the "Max Staleness" specification
|
|
78
|
-
* found here:
|
|
78
|
+
* found here:
|
|
79
|
+
*
|
|
80
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/max-staleness/max-staleness.md
|
|
79
81
|
*
|
|
80
82
|
* @param readPreference - The read preference providing max staleness guidance
|
|
81
83
|
* @param topologyDescription - The topology description
|
|
@@ -212,7 +214,8 @@ function tagSetReducer(
|
|
|
212
214
|
/**
|
|
213
215
|
* Reduces a list of servers to ensure they fall within an acceptable latency window. This is
|
|
214
216
|
* further specified in the "Server Selection" specification, found here:
|
|
215
|
-
*
|
|
217
|
+
*
|
|
218
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.md
|
|
216
219
|
*
|
|
217
220
|
* @param topologyDescription - The topology description
|
|
218
221
|
* @param servers - The list of servers to reduce
|
package/src/sdam/srv_polling.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { clearTimeout, setTimeout } from 'timers';
|
|
|
3
3
|
|
|
4
4
|
import { MongoRuntimeError } from '../error';
|
|
5
5
|
import { TypedEventEmitter } from '../mongo_types';
|
|
6
|
-
import {
|
|
6
|
+
import { checkParentDomainMatch, HostAddress, squashError } from '../utils';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
@@ -127,8 +127,11 @@ export class SrvPoller extends TypedEventEmitter<SrvPollerEvents> {
|
|
|
127
127
|
|
|
128
128
|
const finalAddresses: dns.SrvRecord[] = [];
|
|
129
129
|
for (const record of srvRecords) {
|
|
130
|
-
|
|
130
|
+
try {
|
|
131
|
+
checkParentDomainMatch(record.name, this.srvHost);
|
|
131
132
|
finalAddresses.push(record);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
squashError(error);
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
|
package/src/sessions.ts
CHANGED
|
@@ -124,6 +124,10 @@ export class ClientSession
|
|
|
124
124
|
owner?: symbol | AbstractCursor;
|
|
125
125
|
defaultTransactionOptions: TransactionOptions;
|
|
126
126
|
transaction: Transaction;
|
|
127
|
+
/** @internal
|
|
128
|
+
* Keeps track of whether or not the current transaction has attempted to be committed. Is
|
|
129
|
+
* initially undefined. Gets set to false when startTransaction is called. When commitTransaction is sent to server, if the commitTransaction succeeds, it is then set to undefined, otherwise, set to true */
|
|
130
|
+
commitAttempted?: boolean;
|
|
127
131
|
/** @internal */
|
|
128
132
|
[kServerSession]: ServerSession | null;
|
|
129
133
|
/** @internal */
|
|
@@ -417,6 +421,7 @@ export class ClientSession
|
|
|
417
421
|
);
|
|
418
422
|
}
|
|
419
423
|
|
|
424
|
+
this.commitAttempted = false;
|
|
420
425
|
// increment txnNumber
|
|
421
426
|
this.incrementTransactionNumber();
|
|
422
427
|
// create transaction state
|
|
@@ -474,7 +479,7 @@ export class ClientSession
|
|
|
474
479
|
WriteConcern.apply(command, { wtimeoutMS: 10000, w: 'majority', ...wc });
|
|
475
480
|
}
|
|
476
481
|
|
|
477
|
-
if (this.transaction.state === TxnState.TRANSACTION_COMMITTED) {
|
|
482
|
+
if (this.transaction.state === TxnState.TRANSACTION_COMMITTED || this.commitAttempted) {
|
|
478
483
|
WriteConcern.apply(command, { wtimeoutMS: 10000, ...wc, w: 'majority' });
|
|
479
484
|
}
|
|
480
485
|
|
|
@@ -494,8 +499,10 @@ export class ClientSession
|
|
|
494
499
|
|
|
495
500
|
try {
|
|
496
501
|
await executeOperation(this.client, operation);
|
|
502
|
+
this.commitAttempted = undefined;
|
|
497
503
|
return;
|
|
498
504
|
} catch (firstCommitError) {
|
|
505
|
+
this.commitAttempted = true;
|
|
499
506
|
if (firstCommitError instanceof MongoError && isRetryableWriteError(firstCommitError)) {
|
|
500
507
|
// SPEC-1185: apply majority write concern when retrying commitTransaction
|
|
501
508
|
WriteConcern.apply(command, { wtimeoutMS: 10000, ...wc, w: 'majority' });
|
|
@@ -503,7 +510,14 @@ export class ClientSession
|
|
|
503
510
|
this.unpin({ force: true });
|
|
504
511
|
|
|
505
512
|
try {
|
|
506
|
-
await executeOperation(
|
|
513
|
+
await executeOperation(
|
|
514
|
+
this.client,
|
|
515
|
+
new RunAdminCommandOperation(command, {
|
|
516
|
+
session: this,
|
|
517
|
+
readPreference: ReadPreference.primary,
|
|
518
|
+
bypassPinningCheck: true
|
|
519
|
+
})
|
|
520
|
+
);
|
|
507
521
|
return;
|
|
508
522
|
} catch (retryCommitError) {
|
|
509
523
|
// If the retry failed, we process that error instead of the original
|
package/src/utils.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { FindCursor } from './cursor/find_cursor';
|
|
|
18
18
|
import type { Db } from './db';
|
|
19
19
|
import {
|
|
20
20
|
type AnyError,
|
|
21
|
+
MongoAPIError,
|
|
21
22
|
MongoCompatibilityError,
|
|
22
23
|
MongoInvalidArgumentError,
|
|
23
24
|
MongoNetworkTimeoutError,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
MongoParseError,
|
|
26
27
|
MongoRuntimeError
|
|
27
28
|
} from './error';
|
|
28
|
-
import type { Explain } from './explain';
|
|
29
|
+
import type { Explain, ExplainVerbosity } from './explain';
|
|
29
30
|
import type { MongoClient } from './mongo_client';
|
|
30
31
|
import type { CommandOperationOptions, OperationParent } from './operations/command';
|
|
31
32
|
import type { Hint, OperationOptions } from './operations/operation';
|
|
@@ -251,12 +252,23 @@ export function decorateWithReadConcern(
|
|
|
251
252
|
* @param command - the command on which to apply the explain
|
|
252
253
|
* @param options - the options containing the explain verbosity
|
|
253
254
|
*/
|
|
254
|
-
export function decorateWithExplain(
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
export function decorateWithExplain(
|
|
256
|
+
command: Document,
|
|
257
|
+
explain: Explain
|
|
258
|
+
): {
|
|
259
|
+
explain: Document;
|
|
260
|
+
verbosity: ExplainVerbosity;
|
|
261
|
+
maxTimeMS?: number;
|
|
262
|
+
} {
|
|
263
|
+
type ExplainCommand = ReturnType<typeof decorateWithExplain>;
|
|
264
|
+
const { verbosity, maxTimeMS } = explain;
|
|
265
|
+
const baseCommand: ExplainCommand = { explain: command, verbosity };
|
|
266
|
+
|
|
267
|
+
if (typeof maxTimeMS === 'number') {
|
|
268
|
+
baseCommand.maxTimeMS = maxTimeMS;
|
|
257
269
|
}
|
|
258
270
|
|
|
259
|
-
return
|
|
271
|
+
return baseCommand;
|
|
260
272
|
}
|
|
261
273
|
|
|
262
274
|
/**
|
|
@@ -1085,8 +1097,11 @@ export function shuffle<T>(sequence: Iterable<T>, limit = 0): Array<T> {
|
|
|
1085
1097
|
return limit % items.length === 0 ? items : items.slice(lowerBound);
|
|
1086
1098
|
}
|
|
1087
1099
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1100
|
+
/**
|
|
1101
|
+
* TODO(NODE-4936): read concern eligibility for commands should be codified in command construction
|
|
1102
|
+
* @internal
|
|
1103
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.md#read-concern
|
|
1104
|
+
*/
|
|
1090
1105
|
export function commandSupportsReadConcern(command: Document): boolean {
|
|
1091
1106
|
if (command.aggregate || command.count || command.distinct || command.find || command.geoNear) {
|
|
1092
1107
|
return true;
|
|
@@ -1131,29 +1146,47 @@ export function parseUnsignedInteger(value: unknown): number | null {
|
|
|
1131
1146
|
}
|
|
1132
1147
|
|
|
1133
1148
|
/**
|
|
1134
|
-
*
|
|
1149
|
+
* This function throws a MongoAPIError in the event that either of the following is true:
|
|
1150
|
+
* * If the provided address domain does not match the provided parent domain
|
|
1151
|
+
* * If the parent domain contains less than three `.` separated parts and the provided address does not contain at least one more domain level than its parent
|
|
1135
1152
|
*
|
|
1136
1153
|
* If a DNS server were to become compromised SRV records would still need to
|
|
1137
1154
|
* advertise addresses that are under the same domain as the srvHost.
|
|
1138
1155
|
*
|
|
1139
1156
|
* @param address - The address to check against a domain
|
|
1140
1157
|
* @param srvHost - The domain to check the provided address against
|
|
1141
|
-
* @returns
|
|
1158
|
+
* @returns void
|
|
1142
1159
|
*/
|
|
1143
|
-
export function
|
|
1160
|
+
export function checkParentDomainMatch(address: string, srvHost: string): void {
|
|
1144
1161
|
// Remove trailing dot if exists on either the resolved address or the srv hostname
|
|
1145
1162
|
const normalizedAddress = address.endsWith('.') ? address.slice(0, address.length - 1) : address;
|
|
1146
1163
|
const normalizedSrvHost = srvHost.endsWith('.') ? srvHost.slice(0, srvHost.length - 1) : srvHost;
|
|
1147
1164
|
|
|
1148
1165
|
const allCharacterBeforeFirstDot = /^.*?\./;
|
|
1166
|
+
const srvIsLessThanThreeParts = normalizedSrvHost.split('.').length < 3;
|
|
1149
1167
|
// Remove all characters before first dot
|
|
1150
1168
|
// Add leading dot back to string so
|
|
1151
1169
|
// an srvHostDomain = '.trusted.site'
|
|
1152
1170
|
// will not satisfy an addressDomain that endsWith '.fake-trusted.site'
|
|
1153
1171
|
const addressDomain = `.${normalizedAddress.replace(allCharacterBeforeFirstDot, '')}`;
|
|
1154
|
-
|
|
1172
|
+
let srvHostDomain = srvIsLessThanThreeParts
|
|
1173
|
+
? normalizedSrvHost
|
|
1174
|
+
: `.${normalizedSrvHost.replace(allCharacterBeforeFirstDot, '')}`;
|
|
1155
1175
|
|
|
1156
|
-
|
|
1176
|
+
if (!srvHostDomain.startsWith('.')) {
|
|
1177
|
+
srvHostDomain = '.' + srvHostDomain;
|
|
1178
|
+
}
|
|
1179
|
+
if (
|
|
1180
|
+
srvIsLessThanThreeParts &&
|
|
1181
|
+
normalizedAddress.split('.').length <= normalizedSrvHost.split('.').length
|
|
1182
|
+
) {
|
|
1183
|
+
throw new MongoAPIError(
|
|
1184
|
+
'Server record does not have at least one more domain level than parent URI'
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
if (!addressDomain.endsWith(srvHostDomain)) {
|
|
1188
|
+
throw new MongoAPIError('Server record does not share hostname with parent URI');
|
|
1189
|
+
}
|
|
1157
1190
|
}
|
|
1158
1191
|
|
|
1159
1192
|
interface RequestOptions {
|
package/src/write_concern.ts
CHANGED
|
@@ -58,7 +58,10 @@ interface CommandWriteConcernOptions {
|
|
|
58
58
|
* @see https://www.mongodb.com/docs/manual/reference/write-concern/
|
|
59
59
|
*/
|
|
60
60
|
export class WriteConcern {
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Request acknowledgment that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags.
|
|
63
|
+
* If w is 0 and is set on a write operation, the server will not send a response.
|
|
64
|
+
*/
|
|
62
65
|
readonly w?: W;
|
|
63
66
|
/** Request acknowledgment that the write operation has been written to the on-disk journal */
|
|
64
67
|
readonly journal?: boolean;
|
package/lib/cmap/auth/mongocr.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoCR = void 0;
|
|
4
|
-
const crypto = require("crypto");
|
|
5
|
-
const error_1 = require("../../error");
|
|
6
|
-
const utils_1 = require("../../utils");
|
|
7
|
-
const auth_provider_1 = require("./auth_provider");
|
|
8
|
-
class MongoCR extends auth_provider_1.AuthProvider {
|
|
9
|
-
async auth(authContext) {
|
|
10
|
-
const { connection, credentials } = authContext;
|
|
11
|
-
if (!credentials) {
|
|
12
|
-
throw new error_1.MongoMissingCredentialsError('AuthContext must provide credentials.');
|
|
13
|
-
}
|
|
14
|
-
const { username, password, source } = credentials;
|
|
15
|
-
const { nonce } = await connection.command((0, utils_1.ns)(`${source}.$cmd`), { getnonce: 1 }, undefined);
|
|
16
|
-
const hashPassword = crypto
|
|
17
|
-
.createHash('md5')
|
|
18
|
-
.update(`${username}:mongo:${password}`, 'utf8')
|
|
19
|
-
.digest('hex');
|
|
20
|
-
// Final key
|
|
21
|
-
const key = crypto
|
|
22
|
-
.createHash('md5')
|
|
23
|
-
.update(`${nonce}${username}${hashPassword}`, 'utf8')
|
|
24
|
-
.digest('hex');
|
|
25
|
-
const authenticateCommand = {
|
|
26
|
-
authenticate: 1,
|
|
27
|
-
user: username,
|
|
28
|
-
nonce,
|
|
29
|
-
key
|
|
30
|
-
};
|
|
31
|
-
await connection.command((0, utils_1.ns)(`${source}.$cmd`), authenticateCommand, undefined);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.MongoCR = MongoCR;
|
|
35
|
-
//# sourceMappingURL=mongocr.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongocr.js","sourceRoot":"","sources":["../../../src/cmap/auth/mongocr.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,uCAA2D;AAC3D,uCAAiC;AACjC,mDAAiE;AAEjE,MAAa,OAAQ,SAAQ,4BAAY;IAC9B,KAAK,CAAC,IAAI,CAAC,WAAwB;QAC1C,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;QAChD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,oCAA4B,CAAC,uCAAuC,CAAC,CAAC;QAClF,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;QAEnD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAA,UAAE,EAAC,GAAG,MAAM,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAE7F,MAAM,YAAY,GAAG,MAAM;aACxB,UAAU,CAAC,KAAK,CAAC;aACjB,MAAM,CAAC,GAAG,QAAQ,UAAU,QAAQ,EAAE,EAAE,MAAM,CAAC;aAC/C,MAAM,CAAC,KAAK,CAAC,CAAC;QAEjB,YAAY;QACZ,MAAM,GAAG,GAAG,MAAM;aACf,UAAU,CAAC,KAAK,CAAC;aACjB,MAAM,CAAC,GAAG,KAAK,GAAG,QAAQ,GAAG,YAAY,EAAE,EAAE,MAAM,CAAC;aACpD,MAAM,CAAC,KAAK,CAAC,CAAC;QAEjB,MAAM,mBAAmB,GAAG;YAC1B,YAAY,EAAE,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,GAAG;SACJ,CAAC;QAEF,MAAM,UAAU,CAAC,OAAO,CAAC,IAAA,UAAE,EAAC,GAAG,MAAM,OAAO,CAAC,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;IACjF,CAAC;CACF;AA/BD,0BA+BC"}
|
package/src/cmap/auth/mongocr.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
import { MongoMissingCredentialsError } from '../../error';
|
|
4
|
-
import { ns } from '../../utils';
|
|
5
|
-
import { type AuthContext, AuthProvider } from './auth_provider';
|
|
6
|
-
|
|
7
|
-
export class MongoCR extends AuthProvider {
|
|
8
|
-
override async auth(authContext: AuthContext): Promise<void> {
|
|
9
|
-
const { connection, credentials } = authContext;
|
|
10
|
-
if (!credentials) {
|
|
11
|
-
throw new MongoMissingCredentialsError('AuthContext must provide credentials.');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const { username, password, source } = credentials;
|
|
15
|
-
|
|
16
|
-
const { nonce } = await connection.command(ns(`${source}.$cmd`), { getnonce: 1 }, undefined);
|
|
17
|
-
|
|
18
|
-
const hashPassword = crypto
|
|
19
|
-
.createHash('md5')
|
|
20
|
-
.update(`${username}:mongo:${password}`, 'utf8')
|
|
21
|
-
.digest('hex');
|
|
22
|
-
|
|
23
|
-
// Final key
|
|
24
|
-
const key = crypto
|
|
25
|
-
.createHash('md5')
|
|
26
|
-
.update(`${nonce}${username}${hashPassword}`, 'utf8')
|
|
27
|
-
.digest('hex');
|
|
28
|
-
|
|
29
|
-
const authenticateCommand = {
|
|
30
|
-
authenticate: 1,
|
|
31
|
-
user: username,
|
|
32
|
-
nonce,
|
|
33
|
-
key
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
await connection.command(ns(`${source}.$cmd`), authenticateCommand, undefined);
|
|
37
|
-
}
|
|
38
|
-
}
|