Comparing version 0.2.0 to 0.3.0
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
94
0
7416
+ Addedrequest@latest
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedoauth@latest
- Removedoauth@0.10.0(transitive)