@bytebase/dbhub 0.4.2 → 0.4.5
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 -6
- package/dist/index.js +35 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,9 +184,9 @@ You can specify the SSL mode using the `sslmode` parameter in your DSN string:
|
|
|
184
184
|
| PostgreSQL | ✅ | ✅ | Certificate verification |
|
|
185
185
|
| MySQL | ✅ | ✅ | Certificate verification |
|
|
186
186
|
| MariaDB | ✅ | ✅ | Certificate verification |
|
|
187
|
-
| SQL Server |
|
|
187
|
+
| SQL Server | ✅ | ✅ | Certificate verification |
|
|
188
|
+
| Oracle | ✅ | ✅ | N/A (use Oracle client config) |
|
|
188
189
|
| SQLite | ❌ | ❌ | N/A (file-based) |
|
|
189
|
-
| Oracle | ❌ | ❌ | Built-in encryption |
|
|
190
190
|
|
|
191
191
|
**SSL Mode Options:**
|
|
192
192
|
|
|
@@ -257,12 +257,12 @@ DBHub supports the following database connection string formats:
|
|
|
257
257
|
|
|
258
258
|
| Database | DSN Format | Example |
|
|
259
259
|
| ---------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
260
|
-
| MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname` |
|
|
261
|
-
| MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname` |
|
|
260
|
+
| MySQL | `mysql://[user]:[password]@[host]:[port]/[database]` | `mysql://user:password@localhost:3306/dbname?sslmode=disable` |
|
|
261
|
+
| MariaDB | `mariadb://[user]:[password]@[host]:[port]/[database]` | `mariadb://user:password@localhost:3306/dbname?sslmode=disable` |
|
|
262
262
|
| PostgreSQL | `postgres://[user]:[password]@[host]:[port]/[database]` | `postgres://user:password@localhost:5432/dbname?sslmode=disable` |
|
|
263
|
-
| SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname`
|
|
263
|
+
| SQL Server | `sqlserver://[user]:[password]@[host]:[port]/[database]` | `sqlserver://user:password@localhost:1433/dbname?sslmode=disable` |
|
|
264
264
|
| SQLite | `sqlite:///[path/to/file]` or `sqlite::memory:` | `sqlite:///path/to/database.db`, `sqlite:C:/Users/YourName/data/database.db (windows)` or `sqlite::memory:` |
|
|
265
|
-
| Oracle | `oracle://[user]:[password]@[host]:[port]/[service_name]` | `oracle://username:password@localhost:1521/service_name`
|
|
265
|
+
| Oracle | `oracle://[user]:[password]@[host]:[port]/[service_name]` | `oracle://username:password@localhost:1521/service_name?sslmode=disable` |
|
|
266
266
|
|
|
267
267
|
#### Oracle
|
|
268
268
|
|
package/dist/index.js
CHANGED
|
@@ -394,16 +394,22 @@ var SQLServerDSNParser = class {
|
|
|
394
394
|
const password = url.password ? decodeURIComponent(url.password) : "";
|
|
395
395
|
const options = {};
|
|
396
396
|
for (const [key, value] of url.searchParams.entries()) {
|
|
397
|
-
if (key === "
|
|
398
|
-
options.encrypt = value === "true" ? true : value === "false" ? false : value;
|
|
399
|
-
} else if (key === "trustServerCertificate") {
|
|
400
|
-
options.trustServerCertificate = value === "true";
|
|
401
|
-
} else if (key === "connectTimeout") {
|
|
397
|
+
if (key === "connectTimeout") {
|
|
402
398
|
options.connectTimeout = parseInt(value, 10);
|
|
403
399
|
} else if (key === "requestTimeout") {
|
|
404
400
|
options.requestTimeout = parseInt(value, 10);
|
|
405
401
|
} else if (key === "authentication") {
|
|
406
402
|
options.authentication = value;
|
|
403
|
+
} else if (key === "sslmode") {
|
|
404
|
+
options.sslmode = value;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (options.sslmode) {
|
|
408
|
+
if (options.sslmode === "disable") {
|
|
409
|
+
options.encrypt = false;
|
|
410
|
+
} else if (options.sslmode === "require") {
|
|
411
|
+
options.encrypt = true;
|
|
412
|
+
options.trustServerCertificate = true;
|
|
407
413
|
}
|
|
408
414
|
}
|
|
409
415
|
const config = {
|
|
@@ -439,7 +445,7 @@ var SQLServerDSNParser = class {
|
|
|
439
445
|
return config;
|
|
440
446
|
}
|
|
441
447
|
getSampleDSN() {
|
|
442
|
-
return "sqlserver://username:password@localhost:1433/database?
|
|
448
|
+
return "sqlserver://username:password@localhost:1433/database?sslmode=require";
|
|
443
449
|
}
|
|
444
450
|
isValidDSN(dsn) {
|
|
445
451
|
try {
|
|
@@ -1635,7 +1641,7 @@ ConnectorRegistry.register(mariadbConnector);
|
|
|
1635
1641
|
// src/connectors/oracle/index.ts
|
|
1636
1642
|
import oracledb from "oracledb";
|
|
1637
1643
|
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
|
|
1638
|
-
var
|
|
1644
|
+
var _OracleConnector = class _OracleConnector {
|
|
1639
1645
|
// constructor(config: ConnectionConfig) { // Removed config
|
|
1640
1646
|
constructor() {
|
|
1641
1647
|
// Connector ID and Name are part of the Connector interface
|
|
@@ -1679,6 +1685,15 @@ var OracleConnector = class {
|
|
|
1679
1685
|
case "poolincrement":
|
|
1680
1686
|
config.poolIncrement = parseInt(value, 10);
|
|
1681
1687
|
break;
|
|
1688
|
+
case "sslmode":
|
|
1689
|
+
switch (value.toLowerCase()) {
|
|
1690
|
+
case "disable":
|
|
1691
|
+
break;
|
|
1692
|
+
case "require":
|
|
1693
|
+
config.sslServerDNMatch = false;
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
break;
|
|
1682
1697
|
}
|
|
1683
1698
|
});
|
|
1684
1699
|
return config;
|
|
@@ -1687,7 +1702,7 @@ var OracleConnector = class {
|
|
|
1687
1702
|
}
|
|
1688
1703
|
},
|
|
1689
1704
|
getSampleDSN: () => {
|
|
1690
|
-
return "oracle://username:password@host:1521/service_name";
|
|
1705
|
+
return "oracle://username:password@host:1521/service_name?sslmode=require";
|
|
1691
1706
|
},
|
|
1692
1707
|
isValidDSN: (dsn) => {
|
|
1693
1708
|
try {
|
|
@@ -1698,6 +1713,13 @@ var OracleConnector = class {
|
|
|
1698
1713
|
}
|
|
1699
1714
|
}
|
|
1700
1715
|
};
|
|
1716
|
+
oracledb.autoCommit = true;
|
|
1717
|
+
}
|
|
1718
|
+
// Initialize Oracle client only once
|
|
1719
|
+
initClient() {
|
|
1720
|
+
if (_OracleConnector.clientInitialized) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1701
1723
|
try {
|
|
1702
1724
|
if (process.env.ORACLE_LIB_DIR) {
|
|
1703
1725
|
oracledb.initOracleClient({ libDir: process.env.ORACLE_LIB_DIR });
|
|
@@ -1705,13 +1727,14 @@ var OracleConnector = class {
|
|
|
1705
1727
|
} else {
|
|
1706
1728
|
console.error("ORACLE_LIB_DIR not specified, will use Thin mode by default");
|
|
1707
1729
|
}
|
|
1730
|
+
_OracleConnector.clientInitialized = true;
|
|
1708
1731
|
} catch (err) {
|
|
1709
1732
|
console.error("Failed to initialize Oracle client:", err);
|
|
1710
1733
|
}
|
|
1711
|
-
oracledb.autoCommit = true;
|
|
1712
1734
|
}
|
|
1713
1735
|
async connect(dsn, initializationScript) {
|
|
1714
1736
|
try {
|
|
1737
|
+
this.initClient();
|
|
1715
1738
|
const config = await this.dsnParser.parse(dsn);
|
|
1716
1739
|
this.pool = await oracledb.createPool(config);
|
|
1717
1740
|
const conn = await this.getConnection();
|
|
@@ -2092,6 +2115,9 @@ To resolve this, you need to use Thick mode:
|
|
|
2092
2115
|
return this.pool.getConnection();
|
|
2093
2116
|
}
|
|
2094
2117
|
};
|
|
2118
|
+
// Track if we've already initialized the client
|
|
2119
|
+
_OracleConnector.clientInitialized = false;
|
|
2120
|
+
var OracleConnector = _OracleConnector;
|
|
2095
2121
|
function formatOracleDataType(dataType, dataLength, dataPrecision, dataScale) {
|
|
2096
2122
|
if (!dataType) {
|
|
2097
2123
|
return "UNKNOWN";
|