@@ -57,9 +57,9 @@ function connect({ user, database, connection }) {
57
57
. end ( 0 )
58
58
}
59
59
60
- function auth ( type , x , options ) {
60
+ function auth ( type , x , options , pass ) {
61
61
if ( type in auths )
62
- return auths [ type ] ( type , x , options )
62
+ return auths [ type ] ( type , x , options , pass )
63
63
/* c8 ignore next */
64
64
throw errors . generic ( {
65
65
message : 'Auth type ' + ( authNames [ type ] || type ) + ' not implemented' ,
@@ -68,23 +68,23 @@ function auth(type, x, options) {
68
68
} )
69
69
}
70
70
71
- function AuthenticationCleartextPassword ( type , x , { pass } ) {
71
+ function AuthenticationCleartextPassword ( type , x , options , pass ) {
72
72
return bytes
73
73
. p ( )
74
74
. str ( pass )
75
75
. z ( 1 )
76
76
. end ( )
77
77
}
78
78
79
- function AuthenticationMD5Password ( type , x , { user , pass } ) {
79
+ function AuthenticationMD5Password ( type , x , options , pass ) {
80
80
return bytes
81
81
. p ( )
82
- . str ( 'md5' + md5 ( Buffer . concat ( [ Buffer . from ( md5 ( pass + user ) ) , x . slice ( 9 ) ] ) ) )
82
+ . str ( 'md5' + md5 ( Buffer . concat ( [ Buffer . from ( md5 ( pass + options . user ) ) , x . slice ( 9 ) ] ) ) )
83
83
. z ( 1 )
84
84
. end ( )
85
85
}
86
86
87
- function SASL ( type , x , options ) {
87
+ function SASL ( type , x , options , pass ) {
88
88
bytes
89
89
. p ( )
90
90
. str ( 'SCRAM-SHA-256' + N )
@@ -100,11 +100,11 @@ function SASL(type, x, options) {
100
100
. end ( )
101
101
}
102
102
103
- function SASLContinue ( type , x , options ) {
103
+ function SASLContinue ( type , x , options , pass ) {
104
104
const res = x . utf8Slice ( 9 ) . split ( ',' ) . reduce ( ( acc , x ) => ( acc [ x [ 0 ] ] = x . slice ( 2 ) , acc ) , { } )
105
105
106
106
const saltedPassword = crypto . pbkdf2Sync (
107
- options . pass ,
107
+ pass ,
108
108
Buffer . from ( res . s , 'base64' ) ,
109
109
parseInt ( res . i ) , 32 ,
110
110
'sha256'
0 commit comments