@@ -58,7 +58,14 @@ function connect({ user, database, connection }) {
58
58
}
59
59
60
60
function auth ( type , x , options ) {
61
- return ( auths [ type ] || authNotImplemented ) ( type , x , options ) || ''
61
+ if ( type in auths )
62
+ return auths [ type ] ( type , x , options )
63
+ /* c8 ignore next 5 */
64
+ throw errors . generic ( {
65
+ message : 'Auth type ' + ( authNames [ type ] || type ) + ' not implemented' ,
66
+ type : authNames [ type ] || type ,
67
+ code : 'AUTH_TYPE_NOT_IMPLEMENTED'
68
+ } )
62
69
}
63
70
64
71
function AuthenticationCleartextPassword ( type , x , { pass } ) {
@@ -115,21 +122,12 @@ function SASLContinue(type, x, options) {
115
122
}
116
123
117
124
function SASLFinal ( type , x , options ) {
118
- if ( x . utf8Slice ( 9 ) . split ( N , 1 ) [ 0 ] . slice ( 2 ) !== options . serverSignature ) {
119
- /* c8 ignore next 5 */
120
- throw errors . generic ( {
121
- message : 'The server did not return the correct signature' ,
122
- code : 'SASL_SIGNATURE_MISMATCH'
123
- } )
124
- }
125
- }
126
-
127
- /* c8 ignore next 7 */
128
- function authNotImplemented ( type ) {
125
+ if ( x . utf8Slice ( 9 ) . split ( N , 1 ) [ 0 ] . slice ( 2 ) === options . serverSignature )
126
+ return ''
127
+ /* c8 ignore next 4 */
129
128
throw errors . generic ( {
130
- message : 'Auth type ' + ( authNames [ type ] || type ) + ' not implemented' ,
131
- type : authNames [ type ] || type ,
132
- code : 'AUTH_TYPE_NOT_IMPLEMENTED'
129
+ message : 'The server did not return the correct signature' ,
130
+ code : 'SASL_SIGNATURE_MISMATCH'
133
131
} )
134
132
}
135
133
0 commit comments