@@ -11,7 +11,7 @@ import {
11
11
MongoMissingCredentialsError ,
12
12
MongoRuntimeError
13
13
} from '../../error' ;
14
- import { Callback , maxWireVersion , ns } from '../../utils' ;
14
+ import { ByteUtils , Callback , maxWireVersion , ns } from '../../utils' ;
15
15
import { AuthContext , AuthProvider } from './auth_provider' ;
16
16
import { MongoCredentials } from './mongo_credentials' ;
17
17
import { AuthMechanism } from './providers' ;
@@ -108,7 +108,8 @@ export class MongoDBAWS extends AuthProvider {
108
108
return ;
109
109
}
110
110
111
- if ( serverNonce . compare ( nonce , 0 , nonce . length , 0 , nonce . length ) !== 0 ) {
111
+ // TODO(NODE-4990)
112
+ if ( ! ByteUtils . equals ( serverNonce . subarray ( 0 , nonce . byteLength ) , nonce ) ) {
112
113
// TODO(NODE-3483)
113
114
callback ( new MongoRuntimeError ( 'Server nonce does not begin with client nonce' ) ) ;
114
115
return ;
@@ -130,7 +131,7 @@ export class MongoDBAWS extends AuthProvider {
130
131
headers : {
131
132
'Content-Type' : 'application/x-www-form-urlencoded' ,
132
133
'Content-Length' : body . length ,
133
- 'X-MongoDB-Server-Nonce' : serverNonce . toString ( 'base64' ) ,
134
+ 'X-MongoDB-Server-Nonce' : ByteUtils . toBase64 ( serverNonce ) ,
134
135
'X-MongoDB-GS2-CB-Flag' : 'n'
135
136
} ,
136
137
path : '/' ,
0 commit comments