Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
zod-metadata
Advanced tools
Metadata support for Zod schemas.
npm install zod-metadata
yarn add zod-metadata
pnpm add zod-metadata
import 'zod-metadata/register';
import { z } from 'zod';
const schema = z.string().meta({
example: 'John',
number: 42,
});
schema.getMeta(); // => { example: 'John', number: 42 }
Import zod-metadata/register
at the top of your entry files:
JavaScript
require('zod-metadata/register');
TypeScript
import 'zod-metadata/register';
JavaScript
const { register } = require('zod-metadata');
const zod = require('zod');
register(zod);
TypeScript
import { register } from 'zod-metadata';
import zod from 'zod';
register(zod);
JavaScript
node -r zod-metadata/register my-script.js
// my-script.js
require('zod-metadata'); // make type declarations available
TypeScript
ts-node -r zod-metadata/register my-script.js
// my-script.ts
import {} from 'zod-metadata'; // make type declarations available
Via NODE_OPTIONS
NODE_OPTIONS='-r zod-metadata/register' node my-script.js
Since you can re-declare an interface to add stuff to it,
you can redeclare the ZodMeta
interface to add fields to it.
This may be helpful if you have handful, pre-defined keys you're going to use project-wide.
FAQs
Extends Zod with metadata
The npm package zod-metadata receives a total of 11,686 weekly downloads. As such, zod-metadata popularity was classified as popular.
We found that zod-metadata 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.