This is the initial port to github actions. Still pending are the SSL and client SSL cert tests which are currently being skipped. But perfect is the enemy of the good here, and having no CI because travis-ci keeps not working is unacceptable.
* pg: Re-export DatabaseError from 'pg-protocol'
Before, users would have to import DatabaseError from 'pg-protocol'. If
there are multiple versions of 'pg-protocol', you might end up using the
wrong one.
Closes#2378
* Update error-handling-tests.js
* Update query-error-handling-tests.js
Co-authored-by: Brian C <brian.m.carlson@gmail.com>
* Make tests pass in github codespaces
There were a few tests which didn't specify a host or port which wasn't working well inside the codespaces docker environment. Added host & port where required. Also noticed one test wasn't actually _testing_, it was just `console.log`-ing its output, so I added proper assertions there. Finally set `PGTESTNOSSL: true` in the codespaces environment until I can get the postgres docker container configured w/ SSL...which I will do l8r.
* lint
* Add sha256 SASL helper
* Rename internal createHMAC(...) to hmacSha256(...)
* Add parseAttributePairs(...) helper for SASL
* Tighten arg checks in SASL xorBuffers(...)
* Add SASL nonce check for printable chars
* Add SASL server salt and server signature base64 validation
* Add check for non-empty SASL server nonce
* Rename SASL helper to parseServerFirstMessage(...)
* Add parameter validation to SASL continueSession(...)
* Split out SASL final message parsing into parseServerFinalMessage(...)
* Fix SCRAM tests
Removes custom assert.throws(...) so that the real one from the assert package is used and
fixes the SCRAM tests to reflect the updated error messages and actual checking of errors.
Previously the custom assert.throws(...) was ignoring the error signature validation.
Replaces __dirname concatentation in pg test scripts so that editors like
VS Code can automatically generate typings and support code navigation (F12).
This switches the internals to use faster protocol parsing & serializing. This results in a significant (30% - 50%) speed up in some common query patterns. There is quite a bit more performance work I need to do, but this takes care of some initial stuff & removes a big fork in the code.
The `readyState` of a newly-created `net.Socket` changed from `'closed'` to `'open'` in Node 14.0.0, so this makes the JS driver work on Node 14.
`Connection` now always calls `connect` on its `stream` when `connect` is called on it.
* Drop support for EOL versions of node (#2062)
* Drop support for EOL versions of node
* Re-add testing for node@8.x
* Revert changes to .travis.yml
* Update packages/pg-pool/package.json
Co-Authored-By: Charmander <~@charmander.me>
Co-authored-by: Charmander <~@charmander.me>
* Remove password from stringified outputs (#2066)
* Remove password from stringified outputs
Theres a security concern where if you're not careful and you include your client or pool instance in console.log or stack traces it might include the database password. To widen the pit of success I'm making that field non-enumerable. You can still get at it...it just wont show up "by accident" when you're logging things now.
The backwards compatiblity impact of this is very small, but it is still technically somewhat an API change so...8.0.
* Implement feedback
* Fix more whitespace the autoformatter changed
* Simplify code a bit
* Remove password from stringified outputs (#2070)
* Keep ConnectionParameters’s password property writable
`Client` writes to it when `password` is a function.
* Avoid creating password property on pool options
when it didn’t exist previously.
* Allow password option to be non-enumerable
to avoid breaking uses like `new Pool(existingPool.options)`.
* Make password property definitions consistent
in formatting and configurability.
Co-authored-by: Charmander <~@charmander.me>
* Make `native` non-enumerable (#2065)
* Make `native` non-enumerable
Making it non-enumerable means less spurious "Cannot find module"
errors in your logs when iterating over `pg` objects.
`Object.defineProperty` has been available since Node 0.12.
See https://github.com/brianc/node-postgres/issues/1894#issuecomment-543300178
* Add test for `native` enumeration
Co-authored-by: Gabe Gorelick <gabegorelick@gmail.com>
* Use class-extends to wrap Pool (#1541)
* Use class-extends to wrap Pool
* Minimize diff
* Test `BoundPool` inheritance
Co-authored-by: Charmander <~@charmander.me>
Co-authored-by: Brian C <brian.m.carlson@gmail.com>
* Continue support for creating a pg.Pool from another instance’s options (#2076)
* Add failing test for creating a `BoundPool` from another instance’s settings
* Continue support for creating a pg.Pool from another instance’s options
by dropping the requirement for the `password` property to be enumerable.
* Use user name as default database when user is non-default (#1679)
Not entirely backwards-compatible.
* Make native client password property consistent with others
i.e. configurable.
* Make notice messages not an instance of Error (#2090)
* Make notice messages not an instance of Error
Slight API cleanup to make a notice instance the same shape as it was, but not be an instance of error. This is a backwards incompatible change though I expect the impact to be minimal.
Closes#1982
* skip notice test in travis
* Pin node@13.6 for regression in async iterators
* Check and see if node 13.8 is still borked on async iterator
* Yeah, node still has changed edge case behavior on stream
* Emit notice messages on travis
* Revert "Revert "Support additional tls.connect() options (#1996)" (#2010)" (#2113)
This reverts commit 510a273ce45fb73d0355cf384e97ea695c8a5bcc.
* Fix ssl tests (#2116)
* Convert Query to an ES6 class (#2126)
The last missing `new` deprecation warning for pg 8.
Co-authored-by: Charmander <~@charmander.me>
Co-authored-by: Gabe Gorelick <gabegorelick@gmail.com>
Co-authored-by: Natalie Wolfe <natalie@lifewanted.com>
* Call callback when end called on unconnected client
Closes#2108
* Revert a bit of the change
* Use readyState because pending doesn't exist in node 8.x
* Update packages/pg/lib/client.js
use bring your own promise
Co-Authored-By: Charmander <~@charmander.me>
Co-authored-by: Charmander <~@charmander.me>
When error happens on socket, potentially dead socket is kept open indefinitely by calling "connection.end()".
Similar issue is that it keeps socket open until long-running query is finished even though the connection was ended.
* Remove double-send of ssl request packet
I missed the fact that we are already sending this. Since I don't have good test coverage for ssl [which I am planning on fixing next](https://github.com/brianc/node-postgres/issues/2009) this got missed.
I'm forcing an SSL test on travis. This will break for me locally as I don't have SSL enabled on my local test DB. Something I will also remedy.
* Fix tests skipped because of missing suffixes
Mocha will happen eventually!
* Skip password tests when they can’t work
Will be made more visible when tests are ported to Mocha.
* Add testing with a user with a password to CI
Should reveal a bug in the password enumerability work, I think.
* Explain new CI matrix entry for password authentication
[ci skip]