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.
simple-github-api
Advanced tools
A wrapper for the github api to ease requesting files, directory information from a repository
This is a simple wrapper for the GitHub API to ease requesting files, directory information from a repository.
# To download and install
npm install --save simple-github-api
const API = require('simple-github-api')
let instance = new API({
// https://github.com/blog/1509-personal-api-tokens
token: "Some valid OAUTH key issued by github",
// choose your repo, or you can omit this option and set it later
repo: "myProject",
// the username/owner of the repo(s)
username: "markzuckerberg"
})
instance.get('/some/path')
.then(metafile => {
// returns a file object or if
// a directory a list of file objects
console.log(metafile)
})
.catch(err => {
throw err
})
// OR
instance.getContents('some/file/path')
.then(file => {
// contains actual file
console.log(file)
})
const API = require('simple-github-api')
The new
keyword is required to
create an instance of the API
object.
It is recommended to get an OAUTH
key issued for your application and
instantiate with that token.
let instance = new API(
{
token: "A valid token"
})
The default object however doesn't require any config.
// results in a warning.
// If you do > 60 requests per day
// you will get a 401 error for api requests.
let instance = new API()
You can also pass in basic auth credentials, and a repository.
// all valid options you can pass in
options = {
username: "jeff",
pw: "secret",
repo: "sweetProject",
// token will override basic auth if provided
token: "OAUTHToken"
}
The basic interface below is unlikely to change, although further features may be added later. For all of the below path is a string.
Interface | Description |
---|---|
.get(path) | Returns the fileObject or directory for the relevant file. Takes a string relative path, and requires the repo and user to be set. |
.getUrl(path) | Returns the current url formed for the request. Mainly called internally. |
.getContents(path) | Returns the file contents directly, decoded and ready to use. |
.decode(encodedFile) | Decodes a file object in base64Unicode. |
// sets/update a new repo
instance.repo = "NewRepo"
// sets/update user
instance.user = "newUser"
// returns the underlying axios instance
// which you can configure as you so desire
// More on axios here https://github.com/axios/axios
let axios = instance.axios
Project built leaning heavily on the simplicity of the axios api.
MIT
FAQs
A wrapper for the github api to ease requesting files, directory information from a repository
The npm package simple-github-api receives a total of 1 weekly downloads. As such, simple-github-api popularity was classified as not popular.
We found that simple-github-api 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.