Skip to content

Commit 8d77878

Browse files
committed
fix: hello getter
1 parent e9c32ed commit 8d77878

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/cmap/auth/mongo_credentials.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { OIDCRefreshFunction, OIDCRequestFunction } from './mongodb_oidc';
1212
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './providers';
1313

1414
// https://github.com/mongodb/specifications/blob/master/source/auth/auth.rst
15-
function getDefaultAuthMechanism(hello?: Document): AuthMechanism {
15+
function getDefaultAuthMechanism(hello: Document | null): AuthMechanism {
1616
if (hello) {
1717
// If hello contains saslSupportedMechs, use scram-sha-256
1818
// if it is available, else scram-sha-1
@@ -151,7 +151,7 @@ export class MongoCredentials {
151151
*
152152
* @param hello - A hello response from the server
153153
*/
154-
resolveAuthMechanism(hello?: Document): MongoCredentials {
154+
resolveAuthMechanism(hello: Document | null): MongoCredentials {
155155
// If the mechanism is not "default", then it does not need to be resolved
156156
if (this.mechanism.match(/DEFAULT/i)) {
157157
return new MongoCredentials({

src/cmap/connection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
228228
return this.controller.signal.aborted;
229229
}
230230

231+
public get hello() {
232+
return this.description.hello;
233+
}
234+
231235
// the `connect` method stores the result of the handshake hello on the connection
232236
public set hello(response: Document | null) {
233237
this.description.receiveResponse(response);

src/cmap/connection_pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
621621
)
622622
);
623623
}
624-
const resolvedCredentials = credentials.resolveAuthMechanism(connection.hello || undefined);
624+
const resolvedCredentials = credentials.resolveAuthMechanism(connection.hello);
625625
const provider = AUTH_PROVIDERS.get(resolvedCredentials.mechanism);
626626
if (!provider) {
627627
return callback(

0 commit comments

Comments
 (0)