@@ -11,7 +11,7 @@ import {
1111 MongoMissingCredentialsError ,
1212 MongoRuntimeError
1313} from '../../error' ;
14- import { Callback , maxWireVersion , ns } from '../../utils' ;
14+ import { ByteUtils , Callback , maxWireVersion , ns } from '../../utils' ;
1515import { AuthContext , AuthProvider } from './auth_provider' ;
1616import { MongoCredentials } from './mongo_credentials' ;
1717import { AuthMechanism } from './providers' ;
@@ -108,7 +108,8 @@ export class MongoDBAWS extends AuthProvider {
108108 return ;
109109 }
110110
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 ) ) {
112113 // TODO(NODE-3483)
113114 callback ( new MongoRuntimeError ( 'Server nonce does not begin with client nonce' ) ) ;
114115 return ;
@@ -130,7 +131,7 @@ export class MongoDBAWS extends AuthProvider {
130131 headers : {
131132 'Content-Type' : 'application/x-www-form-urlencoded' ,
132133 'Content-Length' : body . length ,
133- 'X-MongoDB-Server-Nonce' : serverNonce . toString ( 'base64' ) ,
134+ 'X-MongoDB-Server-Nonce' : ByteUtils . toBase64 ( serverNonce ) ,
134135 'X-MongoDB-GS2-CB-Flag' : 'n'
135136 } ,
136137 path : '/' ,
0 commit comments