
Security News
/Research
Compromised Injective SDK npm Package Exfiltrates Wallet Keys and Mnemonics
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.
nativemodels
Advanced tools
Native Models provides a way to map objects in a clean and typed way. The main goal is to ensure runtime type checking and consistent models for APIs.
import { createModel } from 'nativemodels';
import { array, boolean, computed, date, int, object, string } from 'nativemodels/datatypes';
const photoSchema = {
ext: string(),
url: string().required(),
};
const contactSchema = {
email: string(),
phone: string(),
url: string(),
};
const userSchema = {
accountID: int().nullable(),
contact: object(contactSchema),
created: date(),
firstName: string().required(),
fullName: computed((record) => `${record.firstName} ${record.lastName}`),
isAdmin: boolean().nullable(),
lastName: string().required(),
photos: array(object(photoSchema)),
typeID: int().default(2),
};
const userModel = createModel(userSchema);
const johnSmith = userModel({
contact: {
email: 'j.smith@example.com',
},
firstName: 'John',
lastName: 'Smith',
photos: [
{
ext: '.jpg',
url: 'https://example.com/img.jpg',
},
],
});
// => { firstName: 'John', lastName: 'Smith', fullName: 'John Smith', ...}
const userRecords = [
{
firstName: 'John',
lastName: 'Smith',
},
{
firstName: 'Jane',
lastName: 'Doe',
},
];
const users = userRecords.map(userModel);
// => [{ firstName: 'John', lastName: 'Smith', fullName: 'John Smith', ...}]
const janeDoe = userModel({
...johnSmith,
firstName: 'Jane',
lastName: 'Doe',
});
// => { firstName: 'Jane', lastName: 'Doe', fullName: 'Jane Doe', ...}
Datatype methods that can be chained when defining schema.
Sets a default value if no value is set
Allows the value set to be null (useful for database models)
Forces the value to be required. Is ignored if default value is set
If value is valid, returns true, else throws error. Name is key on object;
Parses the value being set. Used to extend base datatype
Custom types are types that are useful to have and common enough for use to include them in our library. They currently include
const { email, enumberable, guid, phone, url } = require('nativemodels/customtypes');
const model = createModel({
email: email(),
enumberable: enumberable(['FOO', 'BAR']),
guid: guid(),
phone: phone(),
url: url(),
});
FAQs
Native Models for Javascript
The npm package nativemodels receives a total of 28 weekly downloads. As such, nativemodels popularity was classified as not popular.
We found that nativemodels demonstrated a not healthy version release cadence and project activity because the last version was released 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
/Research
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.

Security News
npm v12 is generally available, turning install scripts off by default and beginning the deprecation of 2FA-bypass publishing tokens.

Research
/Security News
Socket tracks the activity as Operation “Muck and Load”: a threat actor uses commit-farming workflows, public dead drops, and protected archives to stage Windows RAT and infostealer malware.