From 63dc8facb6da94318ab49b29f5bf67cd8fcb642e Mon Sep 17 00:00:00 2001 From: ciaranj Date: Sun, 9 May 2010 00:50:06 +0100 Subject: [PATCH] Adds support for 1.0A callback urls, and HTTPS endpoints Introduces a breaking constructing change, there is now a 'callback url' argument that can be supplied prior to the signatureMethod in the constructor. Pass 'null' to explicitly ensure the callback url is never used, 'undefined' to use 'oob', 'oob' to use 'oob' or an absolute url. --- lib/oauth.js | 142 +++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/lib/oauth.js b/lib/oauth.js index 5159448..e96b934 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -1,14 +1,21 @@ -var sha1= require('./sha1'), +var crypto= require('crypto'), + sha1= require('./sha1'), http= require('http'), URL= require('url'), querystring= require('querystring'); -exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, signatureMethod, nonceSize) { +exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize) { this._requestUrl= requestUrl; this._accessUrl= accessUrl; this._consumerKey= consumerKey; this._consumerSecret= this._encodeData( consumerSecret ); this._version= version; + if( authorize_callback === undefined ) { + this._authorize_callback= "oob"; + } + else { + this._authorize_callback= authorize_callback; + } if( signatureMethod != "PLAINTEXT" && signatureMethod != "HMAC-SHA1") throw new Error("Un-supported signature method: " + signatureMethod ) @@ -81,17 +88,17 @@ exports.OAuth.prototype._normaliseRequestParams= function(arguments) { var argument_pairs= this._sortRequestParams( arguments ); var args= ""; for(var i=0;i