Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
pg-protocol
Advanced tools
The postgres client/server binary protocol, implemented in TypeScript
The pg-protocol npm package is a low-level library for parsing and serializing the PostgreSQL wire protocol. It is typically used as part of the PostgreSQL client libraries to handle communication with PostgreSQL servers.
Parsing PostgreSQL messages
This feature allows you to parse messages received from a PostgreSQL server. The `Parser` class emits a 'message' event whenever it successfully parses a message from the provided buffer.
const { Parser } = require('pg-protocol');
const parser = new Parser();
parser.on('message', msg => {
console.log('Received message:', msg);
});
const buffer = Buffer.from('some binary data from PostgreSQL server');
parser.parse(buffer);
Serializing PostgreSQL messages
This feature allows you to serialize messages to be sent to a PostgreSQL server. The `serialize` function takes a message type and the message content, and returns a buffer that can be sent over the wire.
const { serialize } = require('pg-protocol');
const buffer = serialize('query', 'SELECT * FROM users');
console.log('Serialized buffer:', buffer);
The `pg` package is a popular PostgreSQL client for Node.js. It provides a higher-level API for interacting with PostgreSQL databases, including connection pooling, query building, and transaction management. Unlike `pg-protocol`, which focuses on low-level protocol handling, `pg` abstracts away the details of the wire protocol and provides a more user-friendly interface.
The `pg-promise` package is another PostgreSQL client for Node.js that focuses on using promises for asynchronous operations. It provides a rich set of features for query building, transaction management, and connection pooling. Similar to `pg`, it abstracts away the low-level protocol details handled by `pg-protocol` and offers a more convenient API for developers.
The `node-postgres` package, also known as `pg`, is a comprehensive PostgreSQL client for Node.js. It includes support for connection pooling, query streaming, and prepared statements. Like `pg` and `pg-promise`, it provides a higher-level API compared to `pg-protocol`, making it easier to work with PostgreSQL databases without dealing with the wire protocol directly.
Low level postgres wire protocol parser and serializer written in Typescript. Used by node-postgres. Needs more documentation. :smile:
FAQs
The postgres client/server binary protocol, implemented in TypeScript
The npm package pg-protocol receives a total of 7,043,210 weekly downloads. As such, pg-protocol popularity was classified as popular.
We found that pg-protocol demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.