Comparing version 2.9.0 to 2.10.0
var crypto = require('crypto'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var util = require('util'); | ||
var pgPass = require('pgpass'); | ||
@@ -41,2 +42,3 @@ var ConnectionParameters = require(__dirname + '/connection-parameters'); | ||
var con = this.connection; | ||
if(this.host && this.host.indexOf('/') === 0) { | ||
@@ -68,9 +70,24 @@ con.connect(this.host + '/.s.PGSQL.' + this.port); | ||
function checkPgPass(cb) { | ||
return function(msg) { | ||
if (null !== self.password) { | ||
cb(msg); | ||
} else { | ||
pgPass(self.connectionParameters, function(pass){ | ||
if (undefined !== pass) { | ||
self.connectionParameters.password = self.password = pass; | ||
} | ||
cb(msg); | ||
}); | ||
} | ||
}; | ||
} | ||
//password request handling | ||
con.on('authenticationCleartextPassword', function() { | ||
con.on('authenticationCleartextPassword', checkPgPass(function() { | ||
con.password(self.password); | ||
}); | ||
})); | ||
//password request handling | ||
con.on('authenticationMD5Password', function(msg) { | ||
con.on('authenticationMD5Password', checkPgPass(function(msg) { | ||
var inner = Client.md5(self.password + self.user); | ||
@@ -80,3 +97,3 @@ var outer = Client.md5(inner + msg.salt.toString('binary')); | ||
con.password(md5password); | ||
}); | ||
})); | ||
@@ -83,0 +100,0 @@ con.once('backendKeyData', function(msg) { |
@@ -88,4 +88,6 @@ var dns = require('dns'); | ||
} | ||
if(this.host) { | ||
params.push("host=" + this.host); | ||
} | ||
if(this.isDomainSocket) { | ||
params.push("host=" + this.host); | ||
return cb(null, params.join(' ')); | ||
@@ -92,0 +94,0 @@ } |
{ | ||
"name": "pg.js", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "node-postgres without the bindings", | ||
@@ -13,3 +13,4 @@ "main": "index.js", | ||
"generic-pool": "~2.0.4", | ||
"buffer-writer": "~1.0.0" | ||
"buffer-writer": "~1.0.0", | ||
"pgpass": "0.0.1" | ||
}, | ||
@@ -16,0 +17,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76074
2490
3
+ Addedpgpass@0.0.1
+ Addedpgpass@0.0.1(transitive)
+ Addedsplit@0.2.10(transitive)
+ Addedthrough@2.3.8(transitive)