{"name":"pg-connection-string","version":"2.8.2","keywords":["pg","connection","string","parse"],"author":{"url":"http://iceddev.com/","name":"Blaine Bublitz","email":"blaine@iceddev.com"},"license":"MIT","_id":"pg-connection-string@2.8.2","maintainers":[{"name":"hjr3","email":"herman@hermanradtke.com"},{"name":"monteslu","email":"monteslu@gmail.com"},{"name":"brianc","email":"brian.m.carlson@gmail.com"},{"name":"bowerman","email":"me@andrewbowerman.com"}],"homepage":"https://github.com/brianc/node-postgres/tree/master/packages/pg-connection-string","bugs":{"url":"https://github.com/brianc/node-postgres/issues"},"dist":{"shasum":"9d8809d992c2af079b4d7bb2a39829c058b0f3a7","tarball":"http://registry-npm.ywwl.com/pg-connection-string/download/pg-connection-string-2.8.2.tgz","fileCount":6,"integrity":"sha512-rzFBCw8SXWIWXPpH0rzZjIDNmqt8DEAx+YulL6GKF1romGKrwmqm3BaQSHGffeUx195hiItKseA+Qe5QQLuD3g==","signatures":[{"sig":"MEUCIQD4O2iyFgAR476zvRiJcSPFvLbXI1TMXzxaJDmZJ9HavwIgLQUD3sEX1MILyJm8MpSSh2AyUwjJN0NxmnQjmK4rv5E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15072,"size":5466,"noattachment":false,"key":"/pg-connection-string/-/pg-connection-string-2.8.2.tgz"},"main":"./index.js","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./esm/index.mjs","default":"./index.js","require":"./index.js"}},"gitHead":"88ff6955e098257358640d33c354c35836369200","scripts":{"test":"istanbul cover _mocha && npm run check-coverage","coveralls":"cat ./coverage/lcov.info | ./node_modules/.bin/coveralls","check-coverage":"istanbul check-coverage --statements 100 --branches 100 --lines 100 --functions 100"},"_npmUser":{"name":"brianc","email":"brian.m.carlson@gmail.com"},"repository":{"url":"git://github.com/brianc/node-postgres.git","type":"git","directory":"packages/pg-connection-string"},"_npmVersion":"lerna/3.22.1/node@v20.10.0+arm64 (darwin)","description":"Functions for dealing with a PostgresSQL connection string","directories":{},"_nodeVersion":"20.10.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^4.1.1","mocha":"^10.5.2","istanbul":"^0.4.5","coveralls":"^3.0.4"},"_npmOperationalInternal":{"tmp":"tmp/pg-connection-string_2.8.2_1745427426267_0.8952948252908586","host":"s3://npm-registry-packages-npm-production"},"readme":"pg-connection-string\n====================\n\n[![NPM](https://nodei.co/npm/pg-connection-string.png?compact=true)](https://nodei.co/npm/pg-connection-string/)\n\nFunctions for dealing with a PostgreSQL connection string\n\n`parse` method taken from [node-postgres](https://github.com/brianc/node-postgres.git)\nCopyright (c) 2010-2014 Brian Carlson (brian.m.carlson@gmail.com)\nMIT License\n\n## Usage\n\n```js\nconst parse = require('pg-connection-string').parse;\n\nconst config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')\n```\n\nThe resulting config contains a subset of the following properties:\n\n* `user` - User with which to authenticate to the server\n* `password` - Corresponding password\n* `host` - Postgres server hostname or, for UNIX domain sockets, the socket filename\n* `port` - port on which to connect\n* `database` - Database name within the server\n* `client_encoding` - string encoding the client will use\n* `ssl`, either a boolean or an object with properties\n  * `rejectUnauthorized`\n  * `cert`\n  * `key`\n  * `ca`\n* any other query parameters (for example, `application_name`) are preserved intact.\n\n### ClientConfig Compatibility for TypeScript\n\nThe pg-connection-string `ConnectionOptions` interface is not compatible with the `ClientConfig` interface that [pg.Client](https://node-postgres.com/apis/client) expects. To remedy this, use the `parseIntoClientConfig` function instead of `parse`:\n\n```ts\nimport { ClientConfig } from 'pg';\nimport { parseIntoClientConfig } from 'pg-connection-string';\n\nconst config: ClientConfig = parseIntoClientConfig('postgres://someuser:somepassword@somehost:381/somedatabase')\n```\n\nYou can also use `toClientConfig` to convert an existing `ConnectionOptions` interface into a `ClientConfig` interface:\n\n```ts\nimport { ClientConfig } from 'pg';\nimport { parse, toClientConfig } from 'pg-connection-string';\n\nconst config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')\nconst clientConfig: ClientConfig = toClientConfig(config)\n```\n\n## Connection Strings\n\nThe short summary of acceptable URLs is:\n\n * `socket:<path>?<query>` - UNIX domain socket\n * `postgres://<user>:<password>@<host>:<port>/<database>?<query>` - TCP connection\n\nBut see below for more details.\n\n### UNIX Domain Sockets\n\nWhen user and password are not given, the socket path follows `socket:`, as in `socket:/var/run/pgsql`.\nThis form can be shortened to just a path: `/var/run/pgsql`.\n\nWhen user and password are given, they are included in the typical URL positions, with an empty `host`, as in `socket://user:pass@/var/run/pgsql`.\n\nQuery parameters follow a `?` character, including the following special query parameters:\n\n * `db=<database>` - sets the database name (urlencoded)\n * `encoding=<encoding>` - sets the `client_encoding` property\n\n### TCP Connections\n\nTCP connections to the Postgres server are indicated with `pg:` or `postgres:` schemes (in fact, any scheme but `socket:` is accepted).\nIf username and password are included, they should be urlencoded.\nThe database name, however, should *not* be urlencoded.\n\nQuery parameters follow a `?` character, including the following special query parameters:\n * `host=<host>` - sets `host` property, overriding the URL's host\n * `encoding=<encoding>` - sets the `client_encoding` property\n * `ssl=1`, `ssl=true`, `ssl=0`, `ssl=false` - sets `ssl` to true or false, accordingly\n * `uselibpqcompat=true` - use libpq semantics\n * `sslmode=<sslmode>` when `uselibpqcompat=true` is not set\n   * `sslmode=disable` - sets `ssl` to false\n   * `sslmode=no-verify` - sets `ssl` to `{ rejectUnauthorized: false }`\n   * `sslmode=prefer`, `sslmode=require`, `sslmode=verify-ca`, `sslmode=verify-full` - sets `ssl` to true\n * `sslmode=<sslmode>` when `uselibpqcompat=true`\n   * `sslmode=disable` - sets `ssl` to false\n   * `sslmode=prefer` - sets `ssl` to `{ rejectUnauthorized: false }`\n   * `sslmode=require` - sets `ssl` to `{ rejectUnauthorized: false }` unless `sslrootcert` is specified, in which case it behaves like `verify-ca`\n   * `sslmode=verify-ca` - sets `ssl` to `{ checkServerIdentity: no-op }` (verify CA, but not server identity). This verifies the presented certificate against the effective CA specified in sslrootcert.\n   * `sslmode=verify-full` - sets `ssl` to `{}` (verify CA and server identity)\n * `sslcert=<filename>` - reads data from the given file and includes the result as `ssl.cert`\n * `sslkey=<filename>` - reads data from the given file and includes the result as `ssl.key`\n * `sslrootcert=<filename>` - reads data from the given file and includes the result as `ssl.ca`\n\nA bare relative URL, such as `salesdata`, will indicate a database name while leaving other properties empty.\n\n> [!CAUTION]\n> Choosing an sslmode other than verify-full has serious security implications. Please read https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS to understand the trade-offs.\n","publish_time":1745427426441,"_cnpm_publish_time":1745427426441,"dist-tags":{"beta":"2.7.1-alpha.0","latest":"2.14.1"}}