
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
capnp-schema-gen
Advanced tools
A Cap'n Proto schema and setter function generator compatible with Pooya Parsa's capnp-es.
Given an arbitrary JavaScript object:
const data = {
name: 'John',
email: 'john@doe.com',
friends: [
{
name: 'Jane',
email: 'jane@doe.com'
}
]
}
You can generate an inferred Cap'n Proto schema:
const schema = generateSchema('Person', data)
console.log(schema)
@0xe3603ad8685d0f0c;
struct Person {
name @0 :Text;
email @1 :Text;
friends @2 :List(PersonFriendsItem);
}
struct PersonFriendsItem {
name @0 :Text;
email @1 :Text;
}
And an accompanying setter function:
const setter = generateSetterFunction(data)
console.log(setter)
function setter(capnp, schemaClass, data) {
const message = new capnp.Message();
const obj = message.initRoot(schemaClass);
if (typeof data.name !== 'undefined') {
obj.name = data.name;
}
if (typeof data.email !== 'undefined') {
obj.email = data.email;
}
const friendsList = obj._initFriends(data.friends.length);
for (let i = 0; i < data.friends.length; i++) {
if (data.friends[i] !== null && typeof data.friends[i] === 'object') {
const friendsItem = friendsList.get(i);
if (typeof data.friends[i].name !== 'undefined') {
friendsItem.name = data.friends[i].name;
}
if (typeof data.friends[i].email !== 'undefined') {
friendsItem.email = data.friends[i].email;
}
}
}
return message.toArrayBuffer();
}
MIT
FAQs
A Cap'n Proto schema and setter function generator.
The npm package capnp-schema-gen receives a total of 0 weekly downloads. As such, capnp-schema-gen popularity was classified as not popular.
We found that capnp-schema-gen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.