pg 8.14.1 → 8.14.2-alpha.1
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 +6 -0
- package/esm/index.mjs +18 -0
- package/lib/crypto/cert-signatures.js +11 -10
- package/lib/crypto/utils-webcrypto.js +1 -0
- package/lib/index.js +4 -0
- package/lib/native/client.js +1 -0
- package/lib/stream.js +2 -0
- package/package.json +17 -7
package/README.md
CHANGED
|
@@ -50,6 +50,12 @@ node-postgres's continued development has been made possible in part by generous
|
|
|
50
50
|
|
|
51
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.
|
|
52
52
|
|
|
53
|
+
### Featured sponsor
|
|
54
|
+
|
|
55
|
+
Special thanks to [medplum](https://medplum.com) for their generous and thoughtful support of node-postgres!
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
53
59
|
## Contributing
|
|
54
60
|
|
|
55
61
|
**:heart: contributions!**
|
package/esm/index.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ESM wrapper for pg
|
|
2
|
+
import pg from '../lib/index.js'
|
|
3
|
+
|
|
4
|
+
// Re-export all the properties
|
|
5
|
+
export const Client = pg.Client
|
|
6
|
+
export const Pool = pg.Pool
|
|
7
|
+
export const Connection = pg.Connection
|
|
8
|
+
export const types = pg.types
|
|
9
|
+
export const Query = pg.Query
|
|
10
|
+
export const DatabaseError = pg.DatabaseError
|
|
11
|
+
export const escapeIdentifier = pg.escapeIdentifier
|
|
12
|
+
export const escapeLiteral = pg.escapeLiteral
|
|
13
|
+
|
|
14
|
+
// Also export the defaults
|
|
15
|
+
export const defaults = pg.defaults
|
|
16
|
+
|
|
17
|
+
// Re-export the default
|
|
18
|
+
export default pg
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function x509Error(msg, cert) {
|
|
2
|
-
|
|
2
|
+
return new Error('SASL channel binding: ' + msg + ' when parsing public certificate ' + cert.toString('base64'))
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
function readASN1Length(data, index) {
|
|
@@ -7,7 +7,7 @@ function readASN1Length(data, index) {
|
|
|
7
7
|
if (length < 0x80) return { length, index }
|
|
8
8
|
|
|
9
9
|
const lengthBytes = length & 0x7f
|
|
10
|
-
if (lengthBytes > 4) x509Error('bad length', data)
|
|
10
|
+
if (lengthBytes > 4) throw x509Error('bad length', data)
|
|
11
11
|
|
|
12
12
|
length = 0
|
|
13
13
|
for (let i = 0; i < lengthBytes; i++) {
|
|
@@ -18,11 +18,11 @@ function readASN1Length(data, index) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function readASN1OID(data, index) {
|
|
21
|
-
if (data[index++] !== 0x6) x509Error('non-OID data', data) // 6 = OID
|
|
21
|
+
if (data[index++] !== 0x6) throw x509Error('non-OID data', data) // 6 = OID
|
|
22
22
|
|
|
23
23
|
const { length: OIDLength, index: indexAfterOIDLength } = readASN1Length(data, index)
|
|
24
24
|
index = indexAfterOIDLength
|
|
25
|
-
lastIndex = index + OIDLength
|
|
25
|
+
let lastIndex = index + OIDLength
|
|
26
26
|
|
|
27
27
|
const byte1 = data[index++]
|
|
28
28
|
let oid = ((byte1 / 40) >> 0) + '.' + (byte1 % 40)
|
|
@@ -43,7 +43,7 @@ function readASN1OID(data, index) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function expectASN1Seq(data, index) {
|
|
46
|
-
if (data[index++] !== 0x30) x509Error('non-sequence data', data) // 30 = Sequence
|
|
46
|
+
if (data[index++] !== 0x30) throw x509Error('non-sequence data', data) // 30 = Sequence
|
|
47
47
|
return readASN1Length(data, index)
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -85,10 +85,10 @@ function signatureAlgorithmHashFromCertificate(data, index) {
|
|
|
85
85
|
case '1.2.840.10045.4.3.4':
|
|
86
86
|
return 'SHA-512'
|
|
87
87
|
// RSASSA-PSS: hash is indicated separately
|
|
88
|
-
case '1.2.840.113549.1.1.10':
|
|
88
|
+
case '1.2.840.113549.1.1.10': {
|
|
89
89
|
index = indexAfterOID
|
|
90
90
|
index = expectASN1Seq(data, index).index
|
|
91
|
-
if (data[index++] !== 0xa0) x509Error('non-tag data', data) // a0 = constructed tag 0
|
|
91
|
+
if (data[index++] !== 0xa0) throw x509Error('non-tag data', data) // a0 = constructed tag 0
|
|
92
92
|
index = readASN1Length(data, index).index // skip over tag length field
|
|
93
93
|
index = expectASN1Seq(data, index).index // skip over sequence length field
|
|
94
94
|
const { oid: hashOID } = readASN1OID(data, index)
|
|
@@ -105,7 +105,8 @@ function signatureAlgorithmHashFromCertificate(data, index) {
|
|
|
105
105
|
case '2.16.840.1.101.3.4.2.3':
|
|
106
106
|
return 'SHA-512'
|
|
107
107
|
}
|
|
108
|
-
x509Error('unknown hash OID ' + hashOID, data)
|
|
108
|
+
throw x509Error('unknown hash OID ' + hashOID, data)
|
|
109
|
+
}
|
|
109
110
|
// Ed25519 -- see https: return//github.com/openssl/openssl/issues/15477
|
|
110
111
|
case '1.3.101.110':
|
|
111
112
|
case '1.3.101.112': // ph
|
|
@@ -113,9 +114,9 @@ function signatureAlgorithmHashFromCertificate(data, index) {
|
|
|
113
114
|
// Ed448 -- still not in pg 17.2 (if supported, digest would be SHAKE256 x 64 bytes)
|
|
114
115
|
case '1.3.101.111':
|
|
115
116
|
case '1.3.101.113': // ph
|
|
116
|
-
x509Error('Ed448 certificate channel binding is not currently supported by Postgres')
|
|
117
|
+
throw x509Error('Ed448 certificate channel binding is not currently supported by Postgres')
|
|
117
118
|
}
|
|
118
|
-
x509Error('unknown OID ' + oid, data)
|
|
119
|
+
throw x509Error('unknown OID ' + oid, data)
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
module.exports = { signatureAlgorithmHashFromCertificate }
|
|
@@ -14,6 +14,7 @@ module.exports = {
|
|
|
14
14
|
* The Web Crypto API - grabbed from the Node.js library or the global
|
|
15
15
|
* @type Crypto
|
|
16
16
|
*/
|
|
17
|
+
// eslint-disable-next-line no-undef
|
|
17
18
|
const webCrypto = nodeCrypto.webcrypto || globalThis.crypto
|
|
18
19
|
/**
|
|
19
20
|
* The SubtleCrypto API for low level crypto operations.
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
var Client = require('./client')
|
|
4
4
|
var defaults = require('./defaults')
|
|
5
5
|
var Connection = require('./connection')
|
|
6
|
+
var Result = require('./result')
|
|
7
|
+
var utils = require('./utils')
|
|
6
8
|
var Pool = require('pg-pool')
|
|
7
9
|
const { DatabaseError } = require('pg-protocol')
|
|
8
10
|
const { escapeIdentifier, escapeLiteral } = require('./utils')
|
|
@@ -26,6 +28,8 @@ var PG = function (clientConstructor) {
|
|
|
26
28
|
this.DatabaseError = DatabaseError
|
|
27
29
|
this.escapeIdentifier = escapeIdentifier
|
|
28
30
|
this.escapeLiteral = escapeLiteral
|
|
31
|
+
this.Result = Result
|
|
32
|
+
this.utils = utils
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
|
package/lib/native/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line
|
|
4
4
|
var Native
|
|
5
|
+
// eslint-disable-next-line no-useless-catch
|
|
5
6
|
try {
|
|
6
7
|
// Wrap this `require()` in a try-catch to avoid upstream bundlers from complaining that this might not be available since it is an optional import
|
|
7
8
|
Native = require('pg-native')
|
package/lib/stream.js
CHANGED
|
@@ -60,7 +60,9 @@ function getCloudflareStreamFuncs() {
|
|
|
60
60
|
function isCloudflareRuntime() {
|
|
61
61
|
// Since 2022-03-21 the `global_navigator` compatibility flag is on for Cloudflare Workers
|
|
62
62
|
// which means that `navigator.userAgent` will be defined.
|
|
63
|
+
// eslint-disable-next-line no-undef
|
|
63
64
|
if (typeof navigator === 'object' && navigator !== null && typeof navigator.userAgent === 'string') {
|
|
65
|
+
// eslint-disable-next-line no-undef
|
|
64
66
|
return navigator.userAgent === 'Cloudflare-Workers'
|
|
65
67
|
}
|
|
66
68
|
// In case `navigator` or `navigator.userAgent` is not defined then try a more sneaky approach
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg",
|
|
3
|
-
"version": "8.14.1",
|
|
3
|
+
"version": "8.14.2-alpha.1",
|
|
4
4
|
"description": "PostgreSQL client - pure javascript & libpq with the same API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -19,25 +19,34 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Brian Carlson <brian.m.carlson@gmail.com>",
|
|
21
21
|
"main": "./lib",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./esm/index.mjs",
|
|
25
|
+
"require": "./lib/index.js",
|
|
26
|
+
"default": "./lib/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
22
29
|
"dependencies": {
|
|
23
|
-
"pg-connection-string": "^2.7.0",
|
|
24
|
-
"pg-pool": "^3.8.
|
|
25
|
-
"pg-protocol": "^1.8.0",
|
|
30
|
+
"pg-connection-string": "^2.7.1-alpha.0",
|
|
31
|
+
"pg-pool": "^3.8.1-alpha.1",
|
|
32
|
+
"pg-protocol": "^1.8.1-alpha.0",
|
|
26
33
|
"pg-types": "^2.1.0",
|
|
27
34
|
"pgpass": "1.x"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
37
|
+
"@cloudflare/vitest-pool-workers": "0.8.12",
|
|
30
38
|
"@cloudflare/workers-types": "^4.20230404.0",
|
|
31
39
|
"async": "2.6.4",
|
|
32
40
|
"bluebird": "3.7.2",
|
|
33
41
|
"co": "4.6.0",
|
|
34
42
|
"pg-copy-streams": "0.3.0",
|
|
35
43
|
"typescript": "^4.0.3",
|
|
44
|
+
"vitest": "~3.0.9",
|
|
36
45
|
"workerd": "^1.20230419.0",
|
|
37
|
-
"wrangler": "3.
|
|
46
|
+
"wrangler": "^3.x"
|
|
38
47
|
},
|
|
39
48
|
"optionalDependencies": {
|
|
40
|
-
"pg-cloudflare": "^1.1.1"
|
|
49
|
+
"pg-cloudflare": "^1.1.2-alpha.1"
|
|
41
50
|
},
|
|
42
51
|
"peerDependencies": {
|
|
43
52
|
"pg-native": ">=3.0.1"
|
|
@@ -52,11 +61,12 @@
|
|
|
52
61
|
},
|
|
53
62
|
"files": [
|
|
54
63
|
"lib",
|
|
64
|
+
"esm",
|
|
55
65
|
"SPONSORS.md"
|
|
56
66
|
],
|
|
57
67
|
"license": "MIT",
|
|
58
68
|
"engines": {
|
|
59
69
|
"node": ">= 8.0.0"
|
|
60
70
|
},
|
|
61
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "306fa83d84e7f99558146892c5f9bf8421ac98e0"
|
|
62
72
|
}
|