Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@planetscale/database
Advanced tools
A JavaScript client for PlanetScale databases.
$ npm install @planetscale/database
import { connect } from '@planetscale/database'
const config = {
host: 'aws.connect.psdb.cloud',
username: '<user>',
password: '<password>'
}
const conn = await connect(config)
const results = await conn.execute('select 1 from dual where 1=?', [1])
console.log(results)
Use the Client
connection factory class to create fresh connections for each transaction or web request handler.
import { Client } from '@planetscale/database'
const client = new Client({
host: 'aws.connect.psdb.cloud',
username: '<user>',
password: '<password>'
})
const conn = await client.connection()
const results = await conn.execute('select 1 from dual')
console.log(results)
Node.js version 18 includes a built-in global fetch
function. When using an older version of Node.js, you can provide a custom fetch function implementation. We recommend the undici
package on which Node's built-in fetch is based.
import { connect } from '@planetscale/database'
import { fetch } from 'undici'
const config = {
fetch,
host: 'aws.connect.psdb.cloud',
username: '<user>',
password: '<password>'
}
const conn = await connect(config)
const results = await conn.execute('select 1 from dual')
console.log(results)
Query replacement parameters identified with ?
are replaced with escaped values. Providing a custom format function overrides the built-in escaping with an external library, like sqlstring
.
import { connect } from '@planetscale/database'
import SqlString from 'sqlstring'
const config = {
format: SqlString.format,
host: 'aws.connect.psdb.cloud',
username: '<user>',
password: '<password>'
}
const conn = await connect(config)
const results = await conn.execute('select 1 from dual where 1=?', [42])
console.log(results)
Named replacement parameters are supported with a colon prefix.
const results = await conn.execute('select 1 from dual where 1=:id', { id: 42 })
npm install
npm test
Distributed under the Apache 2.0 license. See LICENSE for details.
FAQs
A Fetch API-compatible PlanetScale database driver
The npm package @planetscale/database receives a total of 65,247 weekly downloads. As such, @planetscale/database popularity was classified as popular.
We found that @planetscale/database demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.