Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudpt

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudpt - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

44

cloudpt.js

@@ -8,2 +8,3 @@ // cloudPT.js

var request = require('request');
var schema = {

@@ -38,21 +39,23 @@ metadata : ['get', 'https://publicapi.cloudpt.pt/1/Metadata/[cloudpt|sandbox]/[pathname]'],

var OAuth= require('oauth').OAuth;
oAuth= new OAuth("https://cloudpt.pt/oauth/request_token", "https://cloudpt.pt/oauth/access_token", config.oAuthAppKey, config.oAuthAppSecret, "1.0", "oob", "HMAC-SHA1" );
// Everything passes here.
function httpCall(verb, url, params, cb, oAuthConf){
// Object to querystring: stackoverflow.com/questions/1714786/
var serialize = function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
}
var requestParams = {
url:url,
method:verb,
body: (verb == 'post') ? params : null,
qs: (verb == 'get') ? params : null,
json:true,
oauth: {
'consumer_key': config.oAuthAppKey,
'consumer_secret': config.oAuthAppSecret,
'token': oAuthConf.oAuthConsumerKey || config.oAuthConsumerKey,
'token_secret': oAuthConf.oAuthConsumerSecret || config.oAuthConsumerSecret
}
}
function httpCall(verb, url, params, cb, oAuthConf){
if (verb == 'post')
oAuth.post(url, oAuthConf.oAuthConsumerKey || config.oAuthConsumerKey, oAuthConf.oAuthConsumerSecret || config.oAuthConsumerSecret, params, cb);
else
oAuth.get(url+(params ? '?'+serialize(params): ''), oAuthConf.oAuthConsumerKey || config.oAuthConsumerKey, oAuthConf.oAuthConsumerSecret || config.oAuthConsumerSecret, cb);
//console.log(url);
// We are also returning the request object (so you can use to pipe it)
return request(requestParams, function(error, response, body){
cb(error, body);
})
}

@@ -77,8 +80,3 @@

httpCall(schema[method][0], url, params, function(error, data){
if (error)
cb(error)
else
cb(null, ((method != 'thumbnails') ? JSON.parse(data) : data) )
}, oAuthConf || {})
return httpCall(schema[method][0], url, params, cb, oAuthConf || {})

@@ -85,0 +83,0 @@ }

{
"name": "cloudpt",
"description": "cloudPT API with multiple sessions support",
"version": "0.2.0",
"version": "0.3.0",
"author": "Hugo Rodrigues <hugo@StartEffect.com>",

@@ -14,4 +14,4 @@ "repository": {

"dependencies": {
"oauth": "latest"
"request": "latest"
}
}

@@ -66,2 +66,4 @@ cloudPT.js

## Streams
Every request returns a stream. use it with imagination :)

@@ -68,0 +70,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc