Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@apideck/reva
Advanced tools
[![npm (scoped)](https://img.shields.io/npm/v/@apideck/reva?color=brightgreen)](https://npmjs.com/@apideck/reva) [![npm](https://img.shields.io/npm/dm/@apideck/reva)](https://npmjs.com/@apideck/reva) [![GitHub Workflow Status](https://img.shields.io/githu
Server-side request validator for Node.js based on OpenAPI
$ yarn add @apideck/reva
or
$ npm i @apideck/reva
Create a Reva instance and call the validate
method with your OpenAPI operation and your request data.
import { Reva } from '@apideck/reva';
const reva = new Reva();
const result = reva.validate({
operation, // OpenAPI operation
request: {
headers: { 'X-My-Header': 'value', Cookie: 'Key=Value' },
pathParameters: { id: 'ed55e7a3' },
queryParameters: { order_by: 'created' },
body: { name: 'Jane Doe' },
},
});
if (result.ok) {
// Valid request!
} else {
// Invalid request, result.errors contains validation errors
console.log(result.errors);
// {
// "ok": false,
// "errors": [
// {
// "path": "request.query",
// "message": "'order_by' property must be equal to one of the allowed values",
// "suggestion": "Did you mean 'created_at'?",
// "context": { "errorType": "enum", "allowedValues": ["created_at", "updated_at"] }
// },
// {
// "path": "request.header",
// "message": "request.header must have required property 'x-required-header'",
// "context": { "errorType": "required" }
// },
// {
// "path": "request.body",
// "message": "'name' property is not expected to be here",
// "context": { "errorType": "additionalProperties" }
// }
// ]
// }
}
Reva is the main Request validation class. You can optionally pass options to the constructor.
Parameters
options: RevaOptions
allowAdditionalParameters?: true | OpenApiParameterType[]
Allow additional parameters to be passed that are not defined in the OpenAPI operation. Use true
to allow all parameter types to have additional parameters. Default value: ['header', 'cookie']
partialBody?: boolean
Ignore required properties on the requestBody. This option is useful for update endpoints where a subset of required properties is allowed. Default value: false
groupedParameters?: OpenApiParameterType[]
Validate multiple OpenAPI parameter types as one schema. This is useful for APIs where parameters (query
,path
, etc) are combined into a single parameters
object. Default value: []
paramAjvOptions?: AjvOptions
Custom AJV options for request param validation.bodyAjvOptions?: AjvOptions
Custom AJV options for request body validation.Validate requests based on OpenAPI. Parameter validation uses type coercion, request body validation does not. When a Content-Type header is passed, it has to match a Content-Type defined in the OpenAPI operation. Default Content-Type is application/json
.
Parameters
options: RevaValidateOptions
operation: OpenApiOperation
Your OpenAPI operation object to validate againstrequest: RevaRequest
The request data to validate. All properties are optional
queryParameters?: Record<string, unknown>
Query parameters to validateheaders?: Record<string, unknown>
Headers to validatepathParameters?: Record<string, unknown>
Path parameters to validatebody?: unknown
Request body to validateoptions?: RevaOptions
Override options set in the Reva constructorReturn Value
Result<ValidationError>
ok: boolean
Indicates if the request is valid or noterrors?: ValidationError[]
Array of formatted errors. Only populated when Result.ok
is false
message: string
Formatted error messagesuggestion?: string
Optional suggestion based on provided data and schemapath: string
Object path where the error occurred (example: .foo.bar.0.quz
)context: { errorType: DefinedError['keyword']; [additionalContext: string]: unknown }
errorType
is error.keyword
proxied from ajv
. errorType
can be used as a key for i18n if needed. There might be additional properties on context, based on the type of error.FAQs
[![npm (scoped)](https://img.shields.io/npm/v/@apideck/reva?color=brightgreen)](https://npmjs.com/@apideck/reva) [![npm](https://img.shields.io/npm/dm/@apideck/reva)](https://npmjs.com/@apideck/reva) [![GitHub Workflow Status](https://img.shields.io/githu
We found that @apideck/reva demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.