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

oauth

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth - npm Package Compare versions

Comparing version 0.9.4 to 0.9.5

merge_coopernurse

53

lib/oauth.js

@@ -31,2 +31,4 @@ var crypto= require('crypto'),

"User-Agent" : "Node authentication"}
this._clientOptions= this._defaultClientOptions= {"requestTokenHttpMethod": "POST",
"accessTokenHttpMethod": "POST"};
};

@@ -406,2 +408,18 @@

exports.OAuth.prototype.setClientOptions= function(options) {
var key,
mergedOptions= {},
hasOwnProperty= Object.prototype.hasOwnProperty;
for( key in this._defaultClientOptions ) {
if( !hasOwnProperty.call(options, key) ) {
mergedOptions[key]= this._defaultClientOptions[key];
} else {
mergedOptions[key]= options[key];
}
}
this._clientOptions= mergedOptions;
};
exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) {

@@ -415,3 +433,3 @@ var extraParams= {};

this._performSecureRequest( oauth_token, oauth_token_secret, "POST", this._accessUrl, extraParams, null, null, function(error, data, response) {
this._performSecureRequest( oauth_token, oauth_token_secret, this._clientOptions.accessTokenHttpMethod, this._accessUrl, extraParams, null, null, function(error, data, response) {
if( error ) callback(error);

@@ -465,8 +483,27 @@ else {

exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) {
if( typeof extraParams == "function" ){
callback = extraParams;
extraParams = {};
}
/**
* Gets a request token from the OAuth provider and passes that information back
* to the calling code.
*
* The callback should expect a function of the following form:
*
* function(err, token, token_secret, parsedQueryString) {}
*
* This method has optional parameters so can be called in the following 2 ways:
*
* 1) Primary use case: Does a basic request with no extra parameters
* getOAuthRequestToken( callbackFunction )
*
* 2) As above but allows for provision of extra parameters to be sent as part of the query to the server.
* getOAuthRequestToken( extraParams, callbackFunction )
*
* N.B. This method will HTTP POST verbs by default, if you wish to override this behaviour you will
* need to provide a requestTokenHttpMethod option when creating the client.
*
**/
exports.OAuth.prototype.getOAuthRequestToken= function( extraParams, callback ) {
if( typeof extraParams == "function" ){
callback = extraParams;
extraParams = {};
}
// Callbacks are 1.0A related

@@ -476,3 +513,3 @@ if( this._authorize_callback ) {

}
this._performSecureRequest( null, null, "POST", this._requestUrl, extraParams, null, null, function(error, data, response) {
this._performSecureRequest( null, null, this._clientOptions.requestTokenHttpMethod, this._requestUrl, extraParams, null, null, function(error, data, response) {
if( error ) callback(error);

@@ -479,0 +516,0 @@ else {

2

package.json
{ "name" : "oauth"
, "description" : "Library for interacting with OAuth 1.0, 1.0A, 2 and Echo. Provides simplified client access and allows for construction of more complex apis and OAuth providers."
, "version" : "0.9.4"
, "version" : "0.9.5"
, "directories" : { "lib" : "./lib" }

@@ -5,0 +5,0 @@ , "main" : "index.js"

@@ -13,2 +13,3 @@ node-oauth

* 0.9.5 - Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (OAuth1) (Thanks to Raoul Millais)
* 0.9.4 - Support for OAuth providers that drop connections (don't send response lengths? [Google]) And change OAuth2 getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) )

@@ -39,1 +40,2 @@ * 0.9.3 - Adds support for following 301 redirects (Thanks bdickason)

* Ryan LeFevre - http://meltingice.net
* Raoul Millais

@@ -136,2 +136,40 @@ var vows = require('vows'),

},
'When getting a request token': {
topic: function() {
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
oa._getTimestamp= function(){ return "1272399856"; }
oa._getNonce= function(){ return "ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp"; }
oa._performSecureRequest= function(){ return this.requestArguments = arguments; }
return oa;
},
'Use the HTTP method in the client options': function(oa) {
oa.setClientOptions({ requestTokenHttpMethod: "GET" });
oa.getOAuthRequestToken(function() {});
assert.equal(oa.requestArguments[2], "GET");
},
'Use a POST by default': function(oa) {
oa.setClientOptions({});
oa.getOAuthRequestToken(function() {});
assert.equal(oa.requestArguments[2], "POST");
}
},
'When getting an access token': {
topic: function() {
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
oa._getTimestamp= function(){ return "1272399856"; }
oa._getNonce= function(){ return "ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp"; }
oa._performSecureRequest= function(){ return this.requestArguments = arguments; }
return oa;
},
'Use the HTTP method in the client options': function(oa) {
oa.setClientOptions({ accessTokenHttpMethod: "GET" });
oa.getOAuthAccessToken(function() {});
assert.equal(oa.requestArguments[2], "GET");
},
'Use a POST by default': function(oa) {
oa.setClientOptions({});
oa.getOAuthAccessToken(function() {});
assert.equal(oa.requestArguments[2], "POST");
}
},
'When get authorization header' : {

@@ -138,0 +176,0 @@ topic: function() {

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