
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@lincs.project/webannotation-schema
Advanced tools
LINCS Web Annotation Schema is a Typescript JSON Schema generator and validator for the browser and NodeJS. It extends the Web Annotation Model and provides the means to validate Web Annotations that follow this schema. The schema is defined by a JSON-LD object constructed using a combination of Typescript objects based on Zod and Ajv.
The first version of the schema follows this Table Alignment. Subsequent versions may introduce changes and improve upon this document.
You can check the modules and type definitions Type Docs. Check also the examples folder to see how to produce valid LINCS Web Annotations.
To install it as a dependency, simply type
npm install @lincs.project/webannotation-schema
Import the validate
function from the module and pass the annotation object
. It returns the ValidateResult object with one or two properties: valid
is a boolean and errors
lists where the errors occurred if the annotation is not valid.
import { validate } from '@lincs.project/webannotation-validator';
const validAnnotation = {...};
const resultValid = validate(validAnnotation);
console.log(resultValid);
/*
{ valid: true }
*/
const invalidAnnotation = {...};
const resultInvalid = validate(invalidAnnotation);
console.log(resultInvalid);
/*
{
valid: false,
error: [
{
"message": "property 'type' must not have fewer than 2 items",
"path": "{annotation}.generator.type",
"context": {
"errorType": "minItems"
}
},
{
"message": "'0' property must be equal to the allowed value",
"path": "{annotation}.generator.type.0",
"context": {
"errorType": "const",
"allowedValue": "Software"
}
}
]
}
*/
Name | Type | Description |
---|---|---|
Web Annotation Object | object | The Web Annotation Object |
Name | Type | Description |
---|---|---|
valid* | boolean | If the Annotation is valid or not |
Error | ValidationError[] | Collection of error ValidationError from better-ajv-errors |
Name | Type | Description |
---|---|---|
message* | string | Information about the error |
path* | string | Error location |
context* | object | Specific information about the error |
suggestion | string | Suggestion of correction |
Beyond the validate
function, this module export multiple assets that can be used to build a custom validator (Ajv Schema Object) or assist the developer in building Web Annotations using Typescript (Typing).
It can be used to combine a custom validator.
import { definitionSchema, webAnnotationSchema } from '@lincs.project/webannotation-schema';
import { defsId, schemaId } from '@lincs.project/webannotation-schema';
import { schemaContext } from '@lincs.project/webannotation-schema';
This module exports types. Check the available types in the documentation here.
import type {
Body,
Creator,
Motivation,
Software,
Status,
Target,
User,
WebAnnotation,
} from '@lincs.project/webannotation-schema';
It is also possible to import Zod Schema.
import {
Body,
Creator,
Motivation,
Software,
Status,
Target,
User,
WebAnnotation,
} from '@lincs.project/webannotation-schema';
Generate a new version of the schema with valid examples.
npm run generate-auxiliar-files
Attention!
The linter is partily setup ath the monorepo level (check the root of this project). We have configured a tight linter with strict Typescript and format (prettier) rules. Some of these rules can be relaxed if needed. Check eslint config: .eslintrc.js
.
The linter always runs before any commit. But you can also run it at any time to check the code.
npm run lint
This project use jest and mock tests to check the request and response from each endpoint. These tests will run before each commit.
You can also run them manually.
npm test
We follow Semantic Versioning. But it is important to note that the context and the schema are made public available on the web. They are also used in our web service for validation . Thus, when introducing changes, especially if there are breaking changes, it is important to update the schema IDs and introduce the new version in the web service.
FAQs
lincs project web annotation json-ld schema
We found that @lincs.project/webannotation-schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.