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.
A Node.js package for accessing NPR APIs.
This module is a npm package, and requires the latest stable version of node.js.
$ node -v
v6.2.0
$ mkdir npr_test && cd npr_test
$ npm install npr-api
As of right now, the full NPR One API is available in this package.
It is also set up in a way where it will support the future addition of other NPR 'Open APIs'
by adding additional API modules to the lib/
folder.
First, you will need to create a new file called get_token.js
in your favorite text editor.
$ vim get_token.js
Then, paste the example below into the file and update the creditials to match your NPR Developer account info.
const NPR = require('npr-api'),
npr = new NPR();
const client_id = 'your_oauth_client_id',
client_secret = 'your_oauth_client_secret';
npr.one.init()
.then(function() {
return npr.one.authorization
.generateDeviceCode({
client_id: client_id,
client_secret: client_secret,
scope: 'listening.write identity.readonly'
});
})
.then(function(res) {
return new Promise(function(resolve, reject) {
console.log('Please visit the following URL:');
console.log(`${res.verification_uri}\n`);
console.log(`Enter code: ${res.user_code}\n`);
console.log('Press the Spacebar when complete.');
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', function() {
resolve(res.device_code);
});
});
})
.then(function(code) {
return npr.one.authorization
.createToken({
grant_type: 'device_code',
client_id: client_id,
client_secret: client_secret,
code: code
});
})
.then(function(res) {
console.log(`ACCESS TOKEN: ${res.access_token}`);
process.exit();
})
.catch(function(err) {
console.log(err.statusText);
process.exit(1);
});
Then, run the example using node
.
$ node get_token.js
You will only need this once to get an access token to use from
now on. Next, you will need to create a new file called get_recommendations.js
in your favorite text editor.
$ vim get_recommendations.js
Then, paste the example below into the file and update the creditials to match your NPR Developer account info.
const NPR = require('npr-api'),
npr = new NPR();
// paste in your token here
const token = 'access_token_from_step_1';
npr.one.init(token)
.then(function() {
return npr.one.listening.getRecommendations({ channel: 'npr' });
})
.then(function(recommendations) {
// print out the first two recommendations to the console
console.log(recommendations.items.slice(0,2));
}).catch(console.err);
Then, run the example using node
.
$ node get_recommendations.js
You should then see a couple of the listening recommendations for your NPR account dumped to your terminal's stdout
.
More information about the NPR One API can be found at the NPR One Developer Center.
npr.one.authorization.createToken()
npr.one.authorization.generateDeviceCode()
npr.one.authorization.getAuthorizationPage()
npr.one.identity.getUser()
npr.one.identity.postFollowing()
npr.one.identity.updateFollowingStatus()
npr.one.identity.updateStations()
npr.one.listening.getAggRecommendations()
npr.one.listening.getChannels()
npr.one.listening.getHistory()
npr.one.listening.getRecommendations()
npr.one.listening.getSearchRecommendations()
npr.one.listening.postRating()
npr.one.localactivation.sendDonationEmail()
npr.one.sponsorship.getAds()
npr.one.sponsorship.receiveAdTracking()
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp.
Copyright (c) 2015 Adafruit Industries. Licensed under the MIT license.
FAQs
Node.js NPR API client
The npm package npr-api receives a total of 1 weekly downloads. As such, npr-api popularity was classified as not popular.
We found that npr-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.