Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@lens-protocol/metadata
Advanced tools
Schema vaidation and TS types for LIP-2 Lens Protocol Metadata Standards.
# npm:
npm install @lens-protocol/metadata zod
# yarn:
yarn add @lens-protocol/metadata zod
# pnpm:
pnpm add @lens-protocol/metadata zod
[!NOTE]
zod
is marked as optional peer dependency, so if you all you need is the JSON Schema definitions, you can install@lens-protocol/metadata
withoutzod
.
import { PublicationMetadataSchema } from '@lens-protocol/metadata';
const valid = {
/** example of valid publication metadata **/
};
const invalid = {
/** example of invalid publication metadata **/
};
PublicationMetadataSchema.parse(valid); // => PublicationMetadata
PublicationMetadataSchema.parse(invalid); // => throws ZodError
// OR
PublicationMetadataSchema.safeParse(valid);
// => { success: true, data: PublicationMetadata }
PublicationMetadataSchema.safeParse(invalid);
// => { success: false, error: ZodError }
ZodError
contains all the information needed to inform you about the validation error, but it's not very user friendly. You can use formatZodError
to get a more readable error message.
import { PublicationMetadataSchema, formatZodError } from '@lens-protocol/metadata';
const result = PublicationMetadataSchema.safeParse(invalid);
if (!result.success) {
console.log(formatZodError(result.error));
}
import { PublicationMetadata, PublicationMetadataSchema, SchemaId } from '@lens-protocol/metadata';
const publicationMetadata = PublicationMetadataSchema.parse(valid);
switch (publicationMetadata.$schema) {
case SchemaId.ARTICLE:
// publicationMetadata is ArticleMetadata
break;
case SchemaId.AUDIO:
// publicationMetadata is AudioMetadata
break;
case SchemaId.IMAGE:
// publicationMetadata is ImageMetadata
break;
case SchemaId.TEXT_ONLY:
// publicationMetadata is TextOnlyMetadata
break;
// ...
}
Importing JSON schema in TypeScript is a simple as:
import audio from '@lens-protocol/metadata/jsonschemas/audio/1-0-0.json' assert { type: 'json' };
import embed from '@lens-protocol/metadata/jsonschemas/embed/1-0-0.json' assert { type: 'json' };
You can the use them in your JSON Schema validator of choice, for example ajv.
To contribute to the Lens Protocol Metadata Standards, please fork this repository and submit a pull request with your changes.
To build the project, run:
pnpm build
Add changeset with:
pnpm changeset add
Use keepachangelog format for the changeset message.
Release flow is managed by changesets.
To release a new version follow the steps below:
main
with the name release/<version>
pnpm install && pnpm build
package.json
's versions and update CHANGELOG.md
for each package:pnpm changeset version
release/<version>
to main
@lens-protocol
):pnpm changeset publish
git push origin release/<version> --follow-tags
Lens Protocol Metadata Standards is MIT licensed
See the Lens API and SDK channel on our Discord
0.1.0-alpha.1
formatZodError
, datetimes instead of unix timestamps and future proof events datetimesFAQs
Lens Protocol Metadata Standards
We found that @lens-protocol/metadata demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.