Skip to content

Commit 3240ea0

Browse files
committed
Remove built-in pgpass support.
1 parent 412dc88 commit 3240ea0

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

packages/pg/lib/client.js

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ const queryQueueDeprecationNotice = nodeUtils.deprecate(
2020
'Client.queryQueue is deprecated and will be removed in pg@9.0.'
2121
)
2222

23-
const pgPassDeprecationNotice = nodeUtils.deprecate(
24-
() => {},
25-
'pgpass support is deprecated and will be removed in pg@9.0. ' +
26-
'You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code.'
27-
)
28-
2923
const byoPromiseDeprecationNotice = nodeUtils.deprecate(
3024
() => {},
3125
'Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0.'
@@ -248,42 +242,29 @@ class Client extends EventEmitter {
248242
}
249243

250244
_getPassword(cb) {
251-
const con = this.connection
252-
if (typeof this.password === 'function') {
253-
this._Promise
254-
.resolve()
255-
.then(() => this.password(this.connectionParameters))
256-
.then((pass) => {
257-
if (pass !== undefined) {
258-
if (typeof pass !== 'string') {
259-
con.emit('error', new TypeError('Password must be a string'))
260-
return
261-
}
262-
this.connectionParameters.password = this.password = pass
263-
} else {
264-
this.connectionParameters.password = this.password = null
265-
}
266-
cb()
267-
})
268-
.catch((err) => {
269-
con.emit('error', err)
270-
})
271-
} else if (this.password !== null) {
245+
if (typeof this.password !== 'function') {
272246
cb()
273-
} else {
274-
try {
275-
const pgPass = require('pgpass')
276-
pgPass(this.connectionParameters, (pass) => {
277-
if (undefined !== pass) {
278-
pgPassDeprecationNotice()
279-
this.connectionParameters.password = this.password = pass
280-
}
281-
cb()
282-
})
283-
} catch (e) {
284-
this.emit('error', e)
285-
}
247+
return
286248
}
249+
const con = this.connection
250+
this._Promise
251+
.resolve()
252+
.then(() => this.password(this.connectionParameters))
253+
.then((pass) => {
254+
if (pass !== undefined) {
255+
if (typeof pass !== 'string') {
256+
con.emit('error', new TypeError('Password must be a string'))
257+
return
258+
}
259+
this.connectionParameters.password = this.password = pass
260+
} else {
261+
this.connectionParameters.password = this.password = null
262+
}
263+
cb()
264+
})
265+
.catch((err) => {
266+
con.emit('error', err)
267+
})
287268
}
288269

289270
_handleAuthCleartextPassword(msg) {

packages/pg/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
"pg-connection-string": "^2.12.0",
3636
"pg-pool": "^3.13.0",
3737
"pg-protocol": "^1.13.0",
38-
"pg-types": "2.2.0",
39-
"pgpass": "1.0.5"
38+
"pg-types": "2.2.0"
4039
},
4140
"devDependencies": {
4241
"@cloudflare/vitest-pool-workers": "0.8.23",
4342
"@cloudflare/workers-types": "^4.20230404.0",
4443
"async": "2.6.4",
4544
"bluebird": "3.7.2",
4645
"co": "4.6.0",
46+
"pgpass": "1.0.5",
4747
"pg-copy-streams": "0.3.0",
4848
"typescript": "^4.0.3",
4949
"vitest": "~3.0.9",

0 commit comments

Comments
 (0)