Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Make API calls look good. A javascript library to encapsulate API calls.
Using npm:
$ npm install hokage
Step 1: Initialize
let hokage = new Hokage('https://jsonplaceholder.typicode.com')
Step 2: Add a method to the hokage instance
hokage.addMethod({
name: 'listPosts',
method: 'GET',
path: '/posts',
})
Step 3: Make the API call
hokage.listPosts().then(resp => {
console.log(resp)
}).catch(err => {
console.log('err', err)
})
const Hokage = require('hokage')
async function main () {
// STEP 1: Initialize
let hokage = new Hokage('https://jsonplaceholder.typicode.com')
// STEP 2: Name your API calls
hokage.addMethod({
name: 'listPosts',
method: 'GET', // Default method is GET
path: '/posts',
})
hokage.addMethod({
name: 'createPost',
method: 'POST',
path: '/posts',
})
// STEP 3: Make API calls
hokage.listPosts().then(resp => {
console.log(resp) // use resp.body if you need only the body
}).catch(err => {
console.log('err', err)
})
// Using async/await
const newPost = await hokage.createPost({
title: 'foo',
body: 'bar',
userId: 1
})
console.log(newPost.body)
}
main()
new Hokage(baseUrl)
let hokage = new Hokage('https://yourdoamin.tld')
addMethod(opts)
hokage.addMethod({
name: String, // Name of the method to attach. (!Required)
method: String, // HTTP method. (Default: 'GET')
path: String, // URL endpoint. (!Required)
headers: Object, // Headers to append to the request. (Optional)
})
hokage.setHeaders(headers)
hokage.setHeaders({
'Authorization': 'Bearer token', // The headers will be added to the subsequent requests
})
hokage.resetHeaders()
hokage.resetHeaders() // Resets the headers object to default
I built this for my personal use, if you feel like any feature/improvement is required, then kindly let me know. Find me on twitter @prasannamestha
Pull requests are welcome.
FAQs
Javascript library to encapsulate API calls
We found that hokage 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.