
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@tediousjs/connection-string
Advanced tools
@tediousjs/connection-string is a utility package designed to parse and format connection strings for use with the Tedious library, which is a TDS (Tabular Data Stream) protocol implementation for Node.js. This package helps in managing and manipulating connection strings for SQL Server databases.
Parsing Connection Strings
This feature allows you to parse a connection string into a configuration object that can be used with the Tedious library. The `parseConnectionString` function takes a connection string and returns an object with the parsed details.
const { parseConnectionString } = require('@tediousjs/connection-string');
const connectionString = 'Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;';
const config = parseConnectionString(connectionString);
console.log(config);
Formatting Connection Strings
This feature allows you to format a configuration object into a connection string. The `formatConnectionString` function takes a configuration object and returns a connection string that can be used to connect to a SQL Server database.
const { formatConnectionString } = require('@tediousjs/connection-string');
const config = {
server: 'myServerAddress',
authentication: {
type: 'default',
options: {
userName: 'myUsername',
password: 'myPassword'
}
},
options: {
database: 'myDataBase'
}
};
const connectionString = formatConnectionString(config);
console.log(connectionString);
The `pg-connection-string` package is used for parsing and formatting PostgreSQL connection strings. It provides similar functionality to @tediousjs/connection-string but is specifically designed for PostgreSQL databases. It can parse connection strings into configuration objects and format configuration objects back into connection strings.
The `connection-string` package is a more general-purpose library for parsing and formatting connection strings for various databases. It supports multiple database types, including PostgreSQL, MySQL, and SQL Server, making it more versatile compared to @tediousjs/connection-string, which is specific to SQL Server.
This node library is designed to allow the parsing of Connection Strings see https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring
The library also provides the ability to parse SQL Connection Strings.
The library comes with a generic connection string parser that will parse through valid connection strings and produce a key-value readonly Map of the entries in that string. No additional validation is performed.
const { parse } = require('@tediousjs/connection-string');
const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';
const parsed = parse(connectionString);
console.log(parsed);
Output to the console will be:
Map(4) {
'user id' => 'user',
'password' => 'password',
'initial catalog' => 'AdventureWorks',
'server' => 'MySqlServer'
}
SQL connection strings can be parsed to a JSON object using the toSchema()
method and the provided
MSSQL_SCHEMA
.
const { parse, MSSQL_SCHEMA } = require('@tediousjs/connection-string');
const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';
const parsed = parse(connectionString);
console.log(parsed.toSchema(MSSQL_SCHEMA));
Output to console will be:
{
"data source": "MySqlServer",
"initial catalog": "AdventureWorks",
"password": "password",
"user id":"user"
}
NB: The Server
property from the connection string has been re-written to the value Data Source
If you need to parse a connection string into a custom schema, the format is as follows:
import { parse } from '@tediousjs/connection-string';
// a keyed map of name => config
const schema = {
'a string': {
type: 'string',
default: 'a default value',
aliases: ['other', 'allowed', 'names'],
},
'a number': {
type: 'number',
default: 123,
},
'a boolean': {
type: 'boolean',
default: true,
},
};
const parsed = parse('a string=test;a number=987;a boolean=false;other value=missing');
console.log(parsed.toSchema(schema));
Output:
{
"a string": "test",
"a number": 987,
"a boolean": false
}
The parsed connection string object is a readonly Map
with an overloadded get()
method allowing
coercion of the value:
import { parse } from '@tediousjs/connection-string';
const parsed = parse('a string=test;a number=987;a boolean=false;other value=missing');
// all values are strings by default
console.log(parsed.get('a number')); // "987"
// values can be coersed to an expected type
console.log(parsed.get('a number', 'number')); // 987
// coersion will be permissive in its type coersion
console.log(parsed.get('a number', 'boolean')); // true
1.0.0 (2025-06-08)
connectionStringParser()
with parse()
method. Rename
buildConnectionString()
to build()
. Remove parseSqlConnectionString
and
replace with a way to transform parsed connection strings into a specific
object schema (see ConnectionString.toSchema()`).FAQs
SQL ConnectionString parser
The npm package @tediousjs/connection-string receives a total of 868,226 weekly downloads. As such, @tediousjs/connection-string popularity was classified as popular.
We found that @tediousjs/connection-string demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.