Some minor reformatting and 'standardisation' of the merged code
Also updating package.json to reflect Echo support
This commit is contained in:
parent
c1c9270181
commit
37c2408187
@ -4,8 +4,7 @@ A simple oauth API for node.js . This API allows users to authenticate against
|
||||
|
||||
Tested against Twitter (http://twitter.com), term.ie (http://term.ie/oauth/example/), TwitPic, and Yahoo!
|
||||
|
||||
Also provides rudimentary OAuth2 support, tested against facebook connect and github. For more complete usage examples please take a look
|
||||
at connect-auth (http://github.com/ciaranj/connect-auth)
|
||||
Also provides rudimentary OAuth2 support, tested against facebook connect and github. For more complete usage examples please take a look at connect-auth (http://github.com/ciaranj/connect-auth)
|
||||
|
||||
If you're running a node.js version more recent than 0.4 then you will need to use a version of node-oauth greater than or equal to 0.9.0.
|
||||
If you're running a node.js version in the 0.2x stable branch, then you will need to use version 0.8.4.
|
||||
|
18
lib/oauth.js
18
lib/oauth.js
@ -6,7 +6,7 @@ var crypto= require('crypto'),
|
||||
querystring= require('querystring');
|
||||
|
||||
exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders) {
|
||||
this._echo = false;
|
||||
this._isEcho = false;
|
||||
|
||||
this._requestUrl= requestUrl;
|
||||
this._accessUrl= accessUrl;
|
||||
@ -30,7 +30,7 @@ exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, vers
|
||||
};
|
||||
|
||||
exports.OAuthEcho= function(realm, verify_credentials, consumerKey, consumerSecret, version, signatureMethod, nonceSize, customHeaders) {
|
||||
this._echo = true;
|
||||
this._isEcho = true;
|
||||
|
||||
this._realm= realm;
|
||||
this._verifyCredentials = verify_credentials;
|
||||
@ -107,7 +107,7 @@ exports.OAuth.prototype._isParameterNameAnOAuthParameter= function(parameter) {
|
||||
// build the OAuth request authorization header
|
||||
exports.OAuth.prototype._buildAuthorizationHeaders= function(orderedParameters) {
|
||||
var authHeader="OAuth ";
|
||||
if (this._echo) {
|
||||
if( this._isEcho ) {
|
||||
authHeader += 'realm="' + this._realm + '",';
|
||||
}
|
||||
|
||||
@ -252,7 +252,10 @@ exports.OAuth.prototype._prepareParameters= function( oauth_token, oauth_token_s
|
||||
}
|
||||
|
||||
var sig;
|
||||
if (!this._echo) {
|
||||
if( this._isEcho ) {
|
||||
sig = this._getSignature( "GET", this._verifyCredentials, this._normaliseRequestParams(oauthParameters), oauth_token_secret);
|
||||
}
|
||||
else {
|
||||
if( extra_params ) {
|
||||
for( var key in extra_params ) {
|
||||
oauthParameters[key]= extra_params[key];
|
||||
@ -277,8 +280,6 @@ exports.OAuth.prototype._prepareParameters= function( oauth_token, oauth_token_s
|
||||
}
|
||||
|
||||
sig = this._getSignature( method, url, this._normaliseRequestParams(oauthParameters), oauth_token_secret);
|
||||
} else {
|
||||
sig = this._getSignature( "GET", this._verifyCredentials, this._normaliseRequestParams(oauthParameters), oauth_token_secret);
|
||||
}
|
||||
|
||||
var orderedParameters= this._sortRequestParams( this._makeArrayOfArgumentsHash(oauthParameters) );
|
||||
@ -298,9 +299,10 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
||||
|
||||
var headers= {};
|
||||
var authorization = this._buildAuthorizationHeaders(orderedParameters);
|
||||
if (this._echo) {
|
||||
if ( this._isEcho ) {
|
||||
headers["X-Verify-Credentials-Authorization"]= authorization;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
headers["Authorization"]= authorization;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ "name" : "oauth"
|
||||
, "description" : "Library for interacting with OAuth 1.0, 1.0A and 2. Provides simplified client access and allows for construction of more complex apis and OAuth providers."
|
||||
, "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.1"
|
||||
, "directories" : { "lib" : "./lib" }
|
||||
, "main" : "index.js"
|
||||
|
Loading…
x
Reference in New Issue
Block a user