Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@apicase/jsonapi
Advanced tools
Apicase plugin that helps you work with JSON API (based on json-api-normalize)
npm install @apicase/jsonapi
import fetch from "@apicase/adapter-fetch"
import { ApiService } from "@apicase/core"
import { jsonApiPlugin } from "@apicase/jsonapi"
const Root = new ApiService(fetch, {
url: "/api"
}).use(jsonApiPlugin) // <- Add this line
Imagine that we have API route with the following result.body
:
{
"data": [
{
"id": "1",
"type": "post",
"attributes": {
"title": "Hello world",
"text": "Lorem Ipsum Dolor ..."
},
"relationships": {
"author": {
"data": {
"id": "1",
"type": "user"
}
}
}
}
],
"included": [
{
"id": "1",
"type": "user",
"attributes": {
"name": "Anton",
"surname": "Kosykh"
}
}
]
}
We'll create a service with meta.normalize
options:
const GetPosts = Root.extend({
meta: {
normalize: ["id", "title", "text", "author.id", "author.name"]
}
})
GetPosts
.doRequest()
.then(({ result }) => {
console.log(result.body)
})
It will convert result.body
to:
[
{
"id": "1",
"title": "Hello world",
"text": "Lorem Ipsum Dolor ...",
"author": {
"id": "1",
"name": "Anton"
}
}
]
If you need links
or another options from original body, it's stored in result.rawBody
:
console.log(result.rawBody.included)
/*
[{
"id": "1",
"type": "user",
"attributes": {
"name": "Anton",
"surname": "Kosykh"
}
}]
*/
MIT
FAQs
JSON API plugin for Apicase (jsonapi.org)
We found that @apicase/jsonapi demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.