@fadhilp/stateql 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.
- package/README.md +5 -0
- package/dist/src/adapters.d.ts +1 -0
- package/dist/src/adapters.js +18 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,11 @@ stql connect --env SQLITE_DATABASE --name local --read-only
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
A connection accepts exactly one direct target, `--env`, or `--profile` source.
|
|
83
|
+
For PostgreSQL, StateQL preserves strict TLS verification by normalizing
|
|
84
|
+
`sslmode=prefer`, `require`, and `verify-ca` to `verify-full` before opening the
|
|
85
|
+
adapter. Use `sslmode=verify-full` explicitly for clarity. Setting
|
|
86
|
+
`uselibpqcompat=true` opts out and keeps libpq-compatible SSL semantics.
|
|
87
|
+
|
|
83
88
|
MySQL uses positional `?` parameters. MariaDB compatibility is not currently
|
|
84
89
|
claimed.
|
|
85
90
|
|
package/dist/src/adapters.d.ts
CHANGED
|
@@ -37,3 +37,4 @@ export declare function createAdapterContext(timeoutMs: number, signal?: AbortSi
|
|
|
37
37
|
export declare function createAdapter(connection: ConnectionRecord, context: AdapterContext, input: {
|
|
38
38
|
source: string;
|
|
39
39
|
}): Promise<Adapter>;
|
|
40
|
+
export declare function normalizePostgresConnectionString(source: string): string;
|
package/dist/src/adapters.js
CHANGED
|
@@ -182,6 +182,23 @@ class SQLiteAdapter {
|
|
|
182
182
|
this.pending.clear();
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
+
const STRICT_POSTGRES_SSL_MODE_ALIASES = new Set(["prefer", "require", "verify-ca"]);
|
|
186
|
+
export function normalizePostgresConnectionString(source) {
|
|
187
|
+
try {
|
|
188
|
+
const url = new URL(source);
|
|
189
|
+
const parameters = [...url.searchParams.entries()];
|
|
190
|
+
const libpqCompat = parameters.filter(([key]) => key === "uselibpqcompat").at(-1)?.[1];
|
|
191
|
+
const sslMode = parameters.filter(([key]) => key === "sslmode").at(-1)?.[1];
|
|
192
|
+
if (libpqCompat === "true" || !sslMode || !STRICT_POSTGRES_SSL_MODE_ALIASES.has(sslMode))
|
|
193
|
+
return source;
|
|
194
|
+
url.searchParams.delete("sslmode");
|
|
195
|
+
url.searchParams.append("sslmode", "verify-full");
|
|
196
|
+
return url.toString();
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return source;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
185
202
|
class PostgresAdapter {
|
|
186
203
|
readOnly;
|
|
187
204
|
context;
|
|
@@ -194,7 +211,7 @@ class PostgresAdapter {
|
|
|
194
211
|
this.context = context;
|
|
195
212
|
const timeout = Math.min(2_147_483_647, remainingMilliseconds(context));
|
|
196
213
|
this.client = new Client({
|
|
197
|
-
connectionString: source,
|
|
214
|
+
connectionString: normalizePostgresConnectionString(source),
|
|
198
215
|
connectionTimeoutMillis: timeout,
|
|
199
216
|
statement_timeout: timeout,
|
|
200
217
|
});
|