@@ -166,11 +166,10 @@ async function continueScramConversation(
166166 const clientKey = await HMAC ( cryptoMethod , saltedPassword , 'Client Key' ) ;
167167 const serverKey = await HMAC ( cryptoMethod , saltedPassword , 'Server Key' ) ;
168168 const storedKey = await H ( cryptoMethod , clientKey ) ;
169- const authMessage = [
170- clientFirstMessageBare ( username , nonce ) ,
171- payload . toString ( 'utf8' ) ,
172- withoutProof
173- ] . join ( ',' ) ;
169+ const firstMessageBytes = clientFirstMessageBare ( username , nonce ) ;
170+ const firstMessage = ByteUtils . toUTF8 ( firstMessageBytes , 0 , firstMessageBytes . length , false ) ;
171+ const payloadString = ByteUtils . toUTF8 ( payload . buffer , 0 , payload . position , false ) ;
172+ const authMessage = [ firstMessage , payloadString , withoutProof ] . join ( ',' ) ;
174173
175174 const clientSignature = await HMAC ( cryptoMethod , storedKey , authMessage ) ;
176175 const clientProof = `p=${ xor ( clientKey , clientSignature ) } ` ;
@@ -205,7 +204,7 @@ async function continueScramConversation(
205204}
206205
207206function parsePayload ( payload : Binary ) {
208- const payloadStr = payload . toString ( 'utf8' ) ;
207+ const payloadStr = ByteUtils . toUTF8 ( payload . buffer , 0 , payload . position , false ) ;
209208 const dict : Document = { } ;
210209 const parts = payloadStr . split ( ',' ) ;
211210 for ( let i = 0 ; i < parts . length ; i ++ ) {
0 commit comments