Skip to content

Commit 5c7fd98

Browse files
authored
Merge branch 'main' into NODE-7198
2 parents a8dd9e7 + e15d0fe commit 5c7fd98

38 files changed

Lines changed: 2414 additions & 3644 deletions

.evergreen/setup-mongodb-aws-auth-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cd $DRIVERS_TOOLS/.evergreen/auth_aws
1818
# Create a python virtual environment.
1919
. ./activate-authawsvenv.sh
2020
# Source the environment variables. Configure the environment and the server.
21-
. aws_setup.sh $AWS_CREDENTIAL_TYPE
21+
. aws_setup.sh --nouri $AWS_CREDENTIAL_TYPE
2222

2323
cd $BEFORE
2424

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "drivers-evergreen-tools"]
22
path = drivers-evergreen-tools
3-
url = https://github.com/mongodb-labs/drivers-evergreen-tools.git
3+
url = https://github.com/mongodb-labs/drivers-evergreen-tools.git

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
145145
"check:atlas": "nyc mocha --config test/manual/mocharc.js test/manual/atlas_connectivity.test.ts",
146146
"check:drivers-atlas-testing": "nyc mocha --config test/mocha_mongodb.js test/atlas/drivers_atlas_testing.test.ts",
147-
"check:aws": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts",
147+
"check:aws": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_aws.test.ts test/integration/auth/mongodb_aws.prose.test.ts",
148148
"check:oidc-auth": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/auth.spec.test.ts",
149149
"check:oidc-test": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc.prose.test.ts",
150150
"check:oidc-azure": "nyc mocha --config test/mocha_mongodb.js test/integration/auth/mongodb_oidc_azure.prose.05.test.ts",

src/change_stream.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Readable } from 'stream';
33
import type { Binary, Document, Timestamp } from './bson';
44
import { Collection } from './collection';
55
import { CHANGE, CLOSE, END, ERROR, INIT, MORE, RESPONSE, RESUME_TOKEN_CHANGED } from './constants';
6-
import { type CursorStreamOptions, CursorTimeoutContext } from './cursor/abstract_cursor';
6+
import { CursorTimeoutContext } from './cursor/abstract_cursor';
77
import { ChangeStreamCursor, type ChangeStreamCursorOptions } from './cursor/change_stream_cursor';
88
import { Db } from './db';
99
import {
@@ -594,7 +594,6 @@ export class ChangeStream<
594594
type: symbol;
595595
/** @internal */
596596
private cursor: ChangeStreamCursor<TSchema, TChange>;
597-
streamOptions?: CursorStreamOptions;
598597
/** @internal */
599598
private cursorStream?: Readable & AsyncIterable<TChange>;
600599
/** @internal */
@@ -862,13 +861,12 @@ export class ChangeStream<
862861
*
863862
* @throws MongoChangeStreamError if the underlying cursor or the change stream is closed
864863
*/
865-
stream(options?: CursorStreamOptions): Readable & AsyncIterable<TChange> {
864+
stream(): Readable & AsyncIterable<TChange> {
866865
if (this.closed) {
867866
throw new MongoChangeStreamError(CHANGESTREAM_CLOSED_ERROR);
868867
}
869868

870-
this.streamOptions = options;
871-
return this.cursor.stream(options);
869+
return this.cursor.stream();
872870
}
873871

874872
/** @internal */

src/cmap/auth/mongo_credentials.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface AuthMechanismProperties extends Document {
5858
SERVICE_NAME?: string;
5959
SERVICE_REALM?: string;
6060
CANONICALIZE_HOST_NAME?: GSSAPICanonicalizationValue;
61+
/** @internal */
6162
AWS_SESSION_TOKEN?: string;
6263
/** A user provided OIDC machine callback function. */
6364
OIDC_CALLBACK?: OIDCCallbackFunction;

src/cmap/auth/mongodb_aws.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ export class MongoDBAWS extends AuthProvider {
5656
);
5757
}
5858

59-
if (!authContext.credentials.username) {
60-
authContext.credentials = await makeTempCredentials(
61-
authContext.credentials,
62-
this.credentialFetcher
63-
);
64-
}
59+
authContext.credentials = await makeTempCredentials(
60+
authContext.credentials,
61+
this.credentialFetcher
62+
);
6563

6664
const { credentials } = authContext;
6765

src/cmap/connection.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export interface CommandOptions extends BSONSerializeOptions {
9090
/** Session to use for the operation */
9191
session?: ClientSession;
9292
documentsReturnedIn?: string;
93-
noResponse?: boolean;
9493
omitMaxTimeMS?: boolean;
9594

9695
// TODO(NODE-2802): Currently the CommandOptions take a property willRetryWrite which is a hint
@@ -467,7 +466,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
467466
signal: options.signal
468467
});
469468

470-
if (options.noResponse || message.moreToCome) {
469+
if (message.moreToCome) {
471470
yield MongoDBResponse.empty;
472471
return;
473472
}
@@ -567,11 +566,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
567566
new CommandSucceededEvent(
568567
this,
569568
message,
570-
options.noResponse
571-
? undefined
572-
: message.moreToCome
573-
? { ok: 1 }
574-
: (object ??= document.toObject(bsonOptions)),
569+
message.moreToCome ? { ok: 1 } : (object ??= document.toObject(bsonOptions)),
575570
started,
576571
this.description.serverConnectionId
577572
)

src/connection_string.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import { MongoCredentials } from './cmap/auth/mongo_credentials';
77
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './cmap/auth/providers';
88
import { Compressor, type CompressorName } from './cmap/wire_protocol/compression';
99
import { Encrypter } from './encrypter';
10-
import {
11-
MongoAPIError,
12-
MongoInvalidArgumentError,
13-
MongoMissingCredentialsError,
14-
MongoParseError
15-
} from './error';
10+
import { MongoAPIError, MongoInvalidArgumentError, MongoParseError } from './error';
1611
import {
1712
MongoClient,
1813
type MongoClientOptions,
@@ -417,10 +412,18 @@ export function parseOptions(
417412
});
418413
}
419414

420-
if (isAws && mongoOptions.credentials.username && !mongoOptions.credentials.password) {
421-
throw new MongoMissingCredentialsError(
422-
`When using ${mongoOptions.credentials.mechanism} password must be set when a username is specified`
423-
);
415+
if (isAws) {
416+
const { username, password } = mongoOptions.credentials;
417+
if (username || password) {
418+
throw new MongoAPIError(
419+
'username and password cannot be provided when using MONGODB-AWS. Credentials must be provided in a manner that can be read by the AWS SDK.'
420+
);
421+
}
422+
if (mongoOptions.credentials.mechanismProperties.AWS_SESSION_TOKEN) {
423+
throw new MongoAPIError(
424+
'AWS_SESSION_TOKEN cannot be provided when using MONGODB-AWS. Credentials must be provided in a manner that can be read by the AWS SDK.'
425+
);
426+
}
424427
}
425428

426429
mongoOptions.credentials.validate();

src/cursor/abstract_cursor.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Readable, Transform } from 'stream';
1+
import { Readable } from 'stream';
22

33
import { type BSONSerializeOptions, type Document, Long, pluckBSONSerializeOptions } from '../bson';
44
import { type OnDemandDocumentDeserializeOptions } from '../cmap/wire_protocol/on_demand/document';
@@ -58,12 +58,6 @@ export const CURSOR_FLAGS = [
5858
'partial'
5959
] as const;
6060

61-
/** @public */
62-
export interface CursorStreamOptions {
63-
/** A transformation method applied to each document emitted by the stream */
64-
transform?(this: void, doc: Document): Document;
65-
}
66-
6761
/** @public */
6862
export type CursorFlag = (typeof CURSOR_FLAGS)[number];
6963

@@ -519,7 +513,7 @@ export abstract class AbstractCursor<
519513
}
520514
}
521515

522-
stream(options?: CursorStreamOptions): Readable & AsyncIterable<TSchema> {
516+
stream(): Readable & AsyncIterable<TSchema> {
523517
const readable = new ReadableCursorStream(this);
524518
const abortListener = addAbortListener(this.signal, function () {
525519
readable.destroy(this.reason);
@@ -528,31 +522,6 @@ export abstract class AbstractCursor<
528522
abortListener?.[kDispose]();
529523
});
530524

531-
if (options?.transform) {
532-
const transform = options.transform;
533-
534-
const transformedStream = readable.pipe(
535-
new Transform({
536-
objectMode: true,
537-
highWaterMark: 1,
538-
transform(chunk, _, callback) {
539-
try {
540-
const transformed = transform(chunk);
541-
callback(undefined, transformed);
542-
} catch (err) {
543-
callback(err);
544-
}
545-
}
546-
})
547-
);
548-
549-
// Bubble errors to transformed stream, because otherwise no way
550-
// to handle this error.
551-
readable.on('error', err => transformedStream.emit('error', err));
552-
553-
return transformedStream;
554-
}
555-
556525
return readable;
557526
}
558527

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ export type {
365365
export type {
366366
AbstractCursorEvents,
367367
AbstractCursorOptions,
368-
CursorFlag,
369-
CursorStreamOptions
368+
CursorFlag
370369
} from './cursor/abstract_cursor';
371370
export type {
372371
CursorTimeoutContext,

0 commit comments

Comments
 (0)