Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@interledger/openapi
Advanced tools
Validates requests and responses according to an OpenAPI 3.1 schema
This package exposes functionality to validate requests and responses according to a given OpenAPI 3.1 schema.
You can install the package using:
npm install @interledger/openapi
First, instantiate an OpenAPI
validator object with a reference to your OpenAPI spec:
const openApi = await createOpenAPI(OPEN_API_URL_OR_FILE_PATH)
Then, validate requests and responses as such:
const validateRequest = openApi.createRequestValidator({
path: '/resource/{id}',
method: HttpMethod.GET
})
validateRequest(request) // throws or returns true
const validateResponse = openApi.createResponseValidator({
path: '/resource/{id}',
method: HttpMethod.GET
})
validateResponse({ body: response.body, status }) // throws or returns true
Note
The underlying response & request validator packages use the Ajv schema validator library. Each time validators are created via
createRequestValidator
andcreateResponseValidator
, anew Ajv()
instance is also created. Since Ajv recommends instantiating once at initialization, these validators should also be instantiated just once during the lifecycle of the application to avoid any issues.
Likewise, you can validate both requests and responses inside a Koa middleware method, using createValidatorMiddleware
:
const openApi = await createOpenAPI(OPEN_API_URL)
const router = new SomeRouter()
router.get(
'/resource/{id}',
createValidatorMiddleware(openApi, {
path: '/resource/{id}',
method: HttpMethod.GET
})
)
FAQs
Validates requests and responses according to an OpenAPI 3.1 schema
The npm package @interledger/openapi receives a total of 868 weekly downloads. As such, @interledger/openapi popularity was classified as not popular.
We found that @interledger/openapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.