@@ -656,27 +656,30 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
656
656
657
657
/* c8 ignore next 5 */
658
658
async function AuthenticationCleartextPassword ( ) {
659
+ const payload = await Pass ( )
659
660
write (
660
- b ( ) . p ( ) . str ( await Pass ( ) ) . z ( 1 ) . end ( )
661
+ b ( ) . p ( ) . str ( payload ) . z ( 1 ) . end ( )
661
662
)
662
663
}
663
664
664
665
async function AuthenticationMD5Password ( x ) {
665
- write (
666
- b ( ) . p ( ) . str (
667
- 'md5' +
668
- ( await md5 ( Buffer . concat ( [
666
+ const payload = 'md5' + (
667
+ await md5 (
668
+ Buffer . concat ( [
669
669
Buffer . from ( await md5 ( ( await Pass ( ) ) + user ) ) ,
670
670
x . subarray ( 9 )
671
- ] ) ) )
672
- ) . z ( 1 ) . end ( )
671
+ ] )
672
+ )
673
+ )
674
+ write (
675
+ b ( ) . p ( ) . str ( payload ) . z ( 1 ) . end ( )
673
676
)
674
677
}
675
678
676
679
async function SASL ( ) {
680
+ nonce = ( await crypto . randomBytes ( 18 ) ) . toString ( 'base64' )
677
681
b ( ) . p ( ) . str ( 'SCRAM-SHA-256' + b . N )
678
682
const i = b . i
679
- nonce = ( await crypto . randomBytes ( 18 ) ) . toString ( 'base64' )
680
683
write ( b . inc ( 4 ) . str ( 'n,,n=*,r=' + nonce ) . i32 ( b . i - i - 4 , i ) . end ( ) )
681
684
}
682
685
@@ -698,12 +701,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
698
701
699
702
serverSignature = ( await hmac ( await hmac ( saltedPassword , 'Server Key' ) , auth ) ) . toString ( 'base64' )
700
703
704
+ const payload = 'c=biws,r=' + res . r + ',p=' + xor (
705
+ clientKey , Buffer . from ( await hmac ( await sha256 ( clientKey ) , auth ) )
706
+ ) . toString ( 'base64' )
707
+
701
708
write (
702
- b ( ) . p ( ) . str (
703
- 'c=biws,r=' + res . r + ',p=' + xor (
704
- clientKey , Buffer . from ( await hmac ( await sha256 ( clientKey ) , auth ) )
705
- ) . toString ( 'base64' )
706
- ) . end ( )
709
+ b ( ) . p ( ) . str ( payload ) . end ( )
707
710
)
708
711
}
709
712
0 commit comments