pg 8.7.3 → 8.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # node-postgres
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/brianc/node-postgres.svg?branch=master)](http://travis-ci.org/brianc/node-postgres)
4
- [![Dependency Status](https://david-dm.org/brianc/node-postgres.svg?path=packages/pg)](https://david-dm.org/brianc/node-postgres?path=packages/pg)
5
4
  <span class="badge-npmversion"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/v/pg.svg" alt="NPM version" /></a></span>
6
5
  <span class="badge-npmdownloads"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/pg.svg" alt="NPM downloads" /></a></span>
7
6
 
@@ -47,18 +46,7 @@ You can also follow me [@briancarlson](https://twitter.com/briancarlson) if that
47
46
 
48
47
  ## Sponsorship :two_hearts:
49
48
 
50
- node-postgres's continued development has been made possible in part by generous finanical support from [the community](https://github.com/brianc/node-postgres/blob/master/SPONSORS.md) and these featured sponsors:
51
-
52
- <div align="center">
53
- <a href="https://crate.io" target="_blank">
54
- <img height="80" src="https://node-postgres.com/crate-io.png" />
55
- </a>
56
-
57
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAABCAQAAAB0m0auAAAADElEQVR42mNkIBIAAABSAAI2VLqiAAAAAElFTkSuQmCC" />
58
- <a href="https://www.eaze.com" target="_blank">
59
- <img height="80" src="https://node-postgres.com/eaze.png" />
60
- </a>
61
- </div>
49
+ node-postgres's continued development has been made possible in part by generous finanical support from [the community](https://github.com/brianc/node-postgres/blob/master/SPONSORS.md).
62
50
 
63
51
  If you or your company are benefiting from node-postgres and would like to help keep the project financially sustainable [please consider supporting](https://github.com/sponsors/brianc) its development.
64
52
 
package/lib/client.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  var EventEmitter = require('events').EventEmitter
4
- var util = require('util')
5
4
  var utils = require('./utils')
6
5
  var sasl = require('./sasl')
7
6
  var pgPass = require('pgpass')
@@ -248,19 +247,31 @@ class Client extends EventEmitter {
248
247
 
249
248
  _handleAuthSASL(msg) {
250
249
  this._checkPgPass(() => {
251
- this.saslSession = sasl.startSession(msg.mechanisms)
252
- this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response)
250
+ try {
251
+ this.saslSession = sasl.startSession(msg.mechanisms)
252
+ this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response)
253
+ } catch (err) {
254
+ this.connection.emit('error', err)
255
+ }
253
256
  })
254
257
  }
255
258
 
256
259
  _handleAuthSASLContinue(msg) {
257
- sasl.continueSession(this.saslSession, this.password, msg.data)
258
- this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)
260
+ try {
261
+ sasl.continueSession(this.saslSession, this.password, msg.data)
262
+ this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)
263
+ } catch (err) {
264
+ this.connection.emit('error', err)
265
+ }
259
266
  }
260
267
 
261
268
  _handleAuthSASLFinal(msg) {
262
- sasl.finalizeSession(this.saslSession, msg.data)
263
- this.saslSession = null
269
+ try {
270
+ sasl.finalizeSession(this.saslSession, msg.data)
271
+ this.saslSession = null
272
+ } catch (err) {
273
+ this.connection.emit('error', err)
274
+ }
264
275
  }
265
276
 
266
277
  _handleBackendKeyData(msg) {
@@ -403,6 +414,9 @@ class Client extends EventEmitter {
403
414
  if (params.statement_timeout) {
404
415
  data.statement_timeout = String(parseInt(params.statement_timeout, 10))
405
416
  }
417
+ if (params.lock_timeout) {
418
+ data.lock_timeout = String(parseInt(params.lock_timeout, 10))
419
+ }
406
420
  if (params.idle_in_transaction_session_timeout) {
407
421
  data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10))
408
422
  }
@@ -103,6 +103,7 @@ class ConnectionParameters {
103
103
  this.application_name = val('application_name', config, 'PGAPPNAME')
104
104
  this.fallback_application_name = val('fallback_application_name', config, false)
105
105
  this.statement_timeout = val('statement_timeout', config, false)
106
+ this.lock_timeout = val('lock_timeout', config, false)
106
107
  this.idle_in_transaction_session_timeout = val('idle_in_transaction_session_timeout', config, false)
107
108
  this.query_timeout = val('query_timeout', config, false)
108
109
 
package/lib/connection.js CHANGED
@@ -14,7 +14,12 @@ class Connection extends EventEmitter {
14
14
  constructor(config) {
15
15
  super()
16
16
  config = config || {}
17
+
17
18
  this.stream = config.stream || new net.Socket()
19
+ if (typeof this.stream === 'function') {
20
+ this.stream = this.stream(config)
21
+ }
22
+
18
23
  this._keepAlive = config.keepAlive
19
24
  this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis
20
25
  this.lastBuffer = false
@@ -173,7 +178,6 @@ class Connection extends EventEmitter {
173
178
 
174
179
  sync() {
175
180
  this._ending = true
176
- this._send(flushBuffer)
177
181
  this._send(syncBuffer)
178
182
  }
179
183
 
package/lib/defaults.js CHANGED
@@ -54,6 +54,10 @@ module.exports = {
54
54
  // false=unlimited
55
55
  statement_timeout: false,
56
56
 
57
+ // Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock.
58
+ // false=unlimited
59
+ lock_timeout: false,
60
+
57
61
  // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
58
62
  // false=unlimited
59
63
  idle_in_transaction_session_timeout: false,
@@ -3,7 +3,6 @@
3
3
  // eslint-disable-next-line
4
4
  var Native = require('pg-native')
5
5
  var TypeOverrides = require('../type-overrides')
6
- var pkg = require('../../package.json')
7
6
  var EventEmitter = require('events').EventEmitter
8
7
  var util = require('util')
9
8
  var ConnectionParameters = require('../connection-parameters')
package/lib/query.js CHANGED
@@ -135,7 +135,14 @@ class Query extends EventEmitter {
135
135
  return this.handleError(this._canceledDueToError, con)
136
136
  }
137
137
  if (this.callback) {
138
- this.callback(null, this._results)
138
+ try {
139
+ this.callback(null, this._results)
140
+ }
141
+ catch(err) {
142
+ process.nextTick(() => {
143
+ throw err
144
+ })
145
+ }
139
146
  }
140
147
  this.emit('end', this._results)
141
148
  }
package/lib/sasl.js CHANGED
@@ -23,6 +23,9 @@ function continueSession(session, password, serverData) {
23
23
  if (typeof password !== 'string') {
24
24
  throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string')
25
25
  }
26
+ if (password === '') {
27
+ throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string')
28
+ }
26
29
  if (typeof serverData !== 'string') {
27
30
  throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string')
28
31
  }
@@ -37,7 +40,7 @@ function continueSession(session, password, serverData) {
37
40
 
38
41
  var saltBytes = Buffer.from(sv.salt, 'base64')
39
42
 
40
- var saltedPassword = Hi(password, saltBytes, sv.iteration)
43
+ var saltedPassword = crypto.pbkdf2Sync(password, saltBytes, sv.iteration, 32, 'sha256')
41
44
 
42
45
  var clientKey = hmacSha256(saltedPassword, 'Client Key')
43
46
  var storedKey = sha256(clientKey)
@@ -191,17 +194,6 @@ function hmacSha256(key, msg) {
191
194
  return crypto.createHmac('sha256', key).update(msg).digest()
192
195
  }
193
196
 
194
- function Hi(password, saltBytes, iterations) {
195
- var ui1 = hmacSha256(password, Buffer.concat([saltBytes, Buffer.from([0, 0, 0, 1])]))
196
- var ui = ui1
197
- for (var i = 0; i < iterations - 1; i++) {
198
- ui1 = hmacSha256(password, ui1)
199
- ui = xorBuffers(ui, ui1)
200
- }
201
-
202
- return ui
203
- }
204
-
205
197
  module.exports = {
206
198
  startSession,
207
199
  continueSession,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "8.7.3",
3
+ "version": "8.9.0",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "database",
@@ -23,19 +23,19 @@
23
23
  "buffer-writer": "2.0.0",
24
24
  "packet-reader": "1.0.0",
25
25
  "pg-connection-string": "^2.5.0",
26
- "pg-pool": "^3.5.1",
27
- "pg-protocol": "^1.5.0",
26
+ "pg-pool": "^3.5.2",
27
+ "pg-protocol": "^1.6.0",
28
28
  "pg-types": "^2.1.0",
29
29
  "pgpass": "1.x"
30
30
  },
31
31
  "devDependencies": {
32
- "async": "0.9.0",
32
+ "async": "2.6.4",
33
33
  "bluebird": "3.5.2",
34
34
  "co": "4.6.0",
35
35
  "pg-copy-streams": "0.3.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "pg-native": ">=2.0.0"
38
+ "pg-native": ">=3.0.1"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "pg-native": {
@@ -53,5 +53,5 @@
53
53
  "engines": {
54
54
  "node": ">= 8.0.0"
55
55
  },
56
- "gitHead": "4fa7ee891a456168a75695ac026792136f16577f"
56
+ "gitHead": "20a243e8b30926a348cafc44177e95345618f7bc"
57
57
  }