Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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
The npm package hokage receives a total of 0 weekly downloads. As such, hokage popularity was classified as not popular.
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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.