@kosha-ai/integration-postgres 0.4.1 → 0.4.2

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.
@@ -1,5 +1,5 @@
1
1
  import { Client } from 'pg';
2
- import { assertPublicHost, basic as basicAuth, defineIntegration, packageDirs, } from '@kosha-ai/integration-sdk';
2
+ import { assertResolvableHost, basic as basicAuth, defineIntegration, packageDirs, } from '@kosha-ai/integration-sdk';
3
3
  const { docsPath, migrationsPath } = packageDirs(import.meta.url);
4
4
  export class PostgresConnectionError extends Error {
5
5
  constructor(message) {
@@ -98,7 +98,7 @@ async function connectClient(target) {
98
98
  * Read-only is enforced by Postgres itself (`BEGIN READ ONLY` rejects
99
99
  * INSERT/UPDATE/DELETE/DDL/`SELECT ... FOR UPDATE` at the engine level), not
100
100
  * by Kosha parsing the SQL text: the same trust-the-real-protocol stance
101
- * `assertPublicUrl`/`assertPublicHost` take with DNS over regex.
101
+ * Host validation is performed with DNS resolution rather than regexes.
102
102
  *
103
103
  * No connection pooling: every call opens and closes its own client, which
104
104
  * is simplest and safest for a multi-tenant service where no two calls
@@ -110,7 +110,7 @@ async function withReadOnlyClient(fields, credential, fn) {
110
110
  // Re-checked on every call, not only when the configuration was saved: a
111
111
  // hostname that answered publicly yesterday can point inside the network
112
112
  // today (DNS rebinding).
113
- await assertPublicHost(target.host);
113
+ await assertResolvableHost(target.host);
114
114
  let client;
115
115
  try {
116
116
  client = await connectClient(target);
@@ -150,7 +150,7 @@ export function postgres() {
150
150
  label: 'URL',
151
151
  type: 'host',
152
152
  required: true,
153
- help: 'The database host, optionally with :port (defaults to 5432), e.g. db.acme.test:5432. Must resolve to a public address.',
153
+ help: 'The database host, optionally with :port (defaults to 5432), e.g. db.acme.test:5432. It must resolve from the Kosha server network.',
154
154
  },
155
155
  {
156
156
  key: 'database',
package/docs/setup.md CHANGED
@@ -9,10 +9,15 @@ each person who will end up running a query.
9
9
  When you create the configuration, give Kosha:
10
10
 
11
11
  - **URL** — the database host, optionally with `:port` (e.g. `db.acme.test`
12
- or `db.acme.test:5432`; defaults to `5432`). It must resolve to a public
13
- address; a host pointing at `localhost`, a private range or a link-local
14
- address is refused, because Kosha is the one connecting and an operator
15
- could otherwise reach inside the network Kosha runs in.
12
+ or `db.acme.test:5432`; defaults to `5432`). By default it must resolve to
13
+ a public address; a host pointing at `localhost`, a private range or a
14
+ link-local address is refused, because Kosha is the one connecting and an
15
+ operator could otherwise reach inside the network Kosha runs in.
16
+
17
+ The hostname may be public or private; it only needs to resolve from the
18
+ Kosha server network. This supports private databases such as RDS instances
19
+ in the same VPC.
20
+
16
21
  - **Database** — the database name.
17
22
 
18
23
  Connections are always encrypted in transit (TLS), but the server's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosha-ai/integration-postgres",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Postgres integration for Kosha: read-only queries against a connected database",
5
5
  "keywords": [
6
6
  "kosha",
@@ -48,10 +48,10 @@
48
48
  "key": "postgres"
49
49
  },
50
50
  "peerDependencies": {
51
- "@kosha-ai/integration-sdk": "0.4.1"
51
+ "@kosha-ai/integration-sdk": "0.4.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/pg": "^8.11.0",
55
- "@kosha-ai/integration-sdk": "0.4.1"
55
+ "@kosha-ai/integration-sdk": "0.4.2"
56
56
  }
57
57
  }