
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Support for Borsh (de)serialization
Borsher wraps the Borsh JS and simplifies the creation of schema
pnpm add borsher
import { borshSerialize, borshDeserialize, BorshSchema, Infer, Unit } from 'borsher';
const schema = BorshSchema.u8;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.u16;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.u32;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.u64;
const n: bigint = 100n;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.u128;
const n: bigint = 100n;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.i8;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.i16;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.i32;
const n: number = 100;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.i64;
const n: bigint = 100n;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.i128;
const n: bigint = 100n;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.f32;
const n: number = 1.0;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.f64;
const n: number = 1.0;
const buffer = borshSerialize(schema, n);
const schema = BorshSchema.bool;
const b: boolean = true;
const buffer = borshSerialize(schema, b);
const schema = BorshSchema.String;
const message: string = 'hello world';
const buffer = borshSerialize(schema, message);
const schema = BorshSchema.Option(BorshSchema.String);
const some: string | null = 'hello world';
const someBuffer = borshSerialize(schema, some);
const none: string | null = null;
const noneBuffer = borshSerialize(schema, none);
const schema = BorshSchema.Array(BorshSchema.String, 2);
const messages: string[] = ['hello', 'world'];
const buffer = borshSerialize(schema, messages);
const schema = BorshSchema.Vec(BorshSchema.String);
const messages: string[] = ['hello', 'world'];
const buffer = borshSerialize(schema, messages);
const schema = BorshSchema.HashSet(BorshSchema.String);
const messages: Set<string> = new Set(['hello', 'world']);
const buffer = borshSerialize(schema, messages);
const schema = BorshSchema.HashMap(BorshSchema.String, BorshSchema.u128);
const balances: Map<string, bigint> = new Map([
['alice', 1_000_000_000_000_000_000_000_000n],
['bob', 2_000_000_000_000_000_000_000_000n],
]);
const buffer = borshSerialize(schema, balances);
const schema = BorshSchema.Unit;
const unit: Unit = {};
const buffer = borshSerialize(schema, unit);
const schema = BorshSchema.Struct({
name: BorshSchema.String,
age: BorshSchema.u8,
});
type Person = Infer<typeof schema>;
// type Person = {
// name: string;
// age: number;
// };
const person: Person = {
name: 'alice',
age: 18,
};
const buffer = borshSerialize(schema, person);
const schema = BorshSchema.Enum({
Pending: BorshSchema.Unit,
Fulfilled: BorshSchema.Unit,
Rejected: BorshSchema.Unit,
});
type Status = Infer<typeof schema>;
// type Status =
// | {
// Pending: Unit;
// }
// | {
// Fulfilled: Unit;
// }
// | {
// Rejected: Unit;
// };
const status: Status = {
Pending: {},
};
const buffer = borshSerialize(schema, status);
const schema = BorshSchema.Enum({
Square: BorshSchema.u32,
Rectangle: BorshSchema.Struct({
length: BorshSchema.u32,
width: BorshSchema.u32,
}),
Circle: BorshSchema.Struct({
radius: BorshSchema.u32,
}),
});
type Shape = Infer<typeof schema>;
// type Shape =
// | {
// Square: number;
// }
// | {
// Rectangle: {
// length: number;
// width: number;
// };
// }
// | {
// Circle: {
// radius: number;
// };
// };
const shape: Shape = {
Square: 5,
};
const buffer = borshSerialize(schema, shape);
FAQs
Borsh (de)serialization
The npm package borsher receives a total of 989 weekly downloads. As such, borsher popularity was classified as not popular.
We found that borsher 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
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.