@@ -3,7 +3,7 @@ const utils = require('./utils')
33const nodeUtils = require ( 'util' )
44const sasl = require ( './crypto/sasl' )
55const { checkAuthRequest, resolveAuthRequirement } = require ( './require-auth' )
6- const { normalizeChannelBinding } = require ( './channel-binding' )
6+ const { validatedChannelBinding , channelBindingFromDeprecatedBoolean } = require ( './channel-binding' )
77const TypeOverrides = require ( './type-overrides' )
88
99const ConnectionParameters = require ( './connection-parameters' )
@@ -91,10 +91,10 @@ class Client extends EventEmitter {
9191 // enableChannelBinding options and the PGCHANNELBINDING environment variable.
9292 this . _channelBinding = this . connectionParameters . channel_binding
9393 // What the server has to do to authenticate itself, from require_auth and
94- // channel_binding, or null if any supported method will do
94+ // channel_binding, or null if any supported method will do.
9595 this . _authRequirement = this . connectionParameters . authRequirement
9696 // Whether the client has done all the authenticating it is going to do, and whether
97- // that included binding the exchange to the server's certificate
97+ // that included binding the exchange to the server's certificate.
9898 this . _authFinished = false
9999 this . _channelBound = false
100100 // Whether a requirement has been broken, which nothing later can put right. Anything
@@ -103,6 +103,7 @@ class Client extends EventEmitter {
103103 // loop, and Connection#end() sends its Terminate before ending the stream, so a write
104104 // that arrived in the meantime would still reach the server.
105105 this . _authAborted = false
106+
106107 this . scramMaxIterations = coerceNumberOrDefault ( c . scramMaxIterations , sasl . DEFAULT_MAX_SCRAM_ITERATIONS )
107108 this . connection =
108109 c . connection ||
@@ -139,11 +140,9 @@ class Client extends EventEmitter {
139140 }
140141
141142 // Changing the level after construction re-derives what the server has to do, so that
142- // the two cannot come to disagree over whether channel binding is mandatory. The value
143- // is checked as it would have been in the constructor, so that a level this client does
144- // not know cannot pass for the weakest one.
143+ // the two cannot come to disagree over whether channel binding is mandatory.
145144 set channelBinding ( value ) {
146- this . _channelBinding = normalizeChannelBinding ( value )
145+ this . _channelBinding = validatedChannelBinding ( value )
147146 this . _authRequirement = resolveAuthRequirement ( this . connectionParameters . require_auth , this . _channelBinding )
148147 }
149148
@@ -155,7 +154,7 @@ class Client extends EventEmitter {
155154 }
156155
157156 set enableChannelBinding ( value ) {
158- this . channelBinding = value
157+ this . channelBinding = channelBindingFromDeprecatedBoolean ( value )
159158 }
160159
161160 get activeQuery ( ) {
0 commit comments