
Security News
minimatch Patches 3 High-Severity ReDoS Vulnerabilities
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.
@solana/codecs
Advanced tools
This package contains all types and helpers for encoding and decoding anything to and from a Uint8Array. It can be used standalone, but it is also exported as part of Kit @solana/kit.
No matter which serialization strategy we use, Codecs abstract away its implementation and offers a simple encode and decode interface. Codecs are also highly composable, allowing us to build complex data structures from simple building blocks.
Here's a quick example that encodes and decodes a simple Person object.
// Use composable codecs to build complex data structures.
type Person = { name: string; age: number };
const getPersonCodec = (): Codec<Person> =>
getStructCodec([
['name', addCodecSizePrefix(getUtf8Codec(), getU32Codec())],
['age', getU32Codec()],
]);
// Use your own codecs to encode and decode data.
const person = { name: 'John', age: 42 };
const personCodec = getPersonCodec();
const encodedPerson: Uint8Array = personCodec.encode(person);
const decodedPerson: Person = personCodec.decode(encodedPerson);
Whilst Codecs can both encode and decode, it is possible to only focus on encoding or decoding data, enabling the unused logic to be tree-shaken. For instance, here’s our previous example using Decoders only to decode a Person type.
const getPersonDecoder = (): Decoder<Person> =>
getStructDecoder([
['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
['age', getU32Decoder()],
]);
The @solana/codecs package is composed of several smaller packages, each with its own set of responsibilities. You can learn more about codecs and how to create your own by reading their respective documentation.
@solana/codecs-core This package lays the foundation of codecs by providing core type and helper functions to create and compose them.
@solana/codecs-numbers This package offers codecs for numbers of various sizes and characteristics.
@solana/codecs-strings This package provides codecs for strings of various encodings and size strategies.
@solana/codecs-data-structures This package offers a set of helpers for a variety of data structures such as objects, enums, arrays, maps, etc.
@solana/options This package adds Rust-like Options to JavaScript and offers codecs and helpers to manage them.
FAQs
A library for encoding and decoding any data structure
The npm package @solana/codecs receives a total of 1,091,936 weekly downloads. As such, @solana/codecs popularity was classified as popular.
We found that @solana/codecs 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.

Security News
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.

Research
/Security News
Socket uncovered 26 malicious npm packages tied to North Korea's Contagious Interview campaign, retrieving a live 9-module infostealer and RAT from the adversary's C2.

Research
An impersonated golang.org/x/crypto clone exfiltrates passwords, executes a remote shell stager, and delivers a Rekoobe backdoor on Linux.