diff --git a/third_party/firefox_sendtophone/modules/OAuth.js b/third_party/firefox_sendtophone/modules/OAuth.js index 62c4818..876552c 100644 --- a/third_party/firefox_sendtophone/modules/OAuth.js +++ b/third_party/firefox_sendtophone/modules/OAuth.js @@ -10,7 +10,7 @@ function toConsole(text) Cc["@mozilla.org/consoleservice;1"] .getService(Ci.nsIConsoleService) .logStringMessage( text ); -}; +} function openTab(url, successUrl, callback) { @@ -103,7 +103,7 @@ ChromeExOAuth.prototype.setPreferencesBranch = function( branch ) { this.prefs = Cc["@mozilla.org/preferences-service;1"] .getService(Ci.nsIPrefService) .getBranch(branch) ; -} +}; /** * Constructor - no need to invoke directly, call initBackgroundPage instead. @@ -141,7 +141,7 @@ function ChromeExOAuth(url_request_token, url_auth_token, url_access_token, } } } -}; +} /******************************************************************************* * PUBLIC API METHODS @@ -301,8 +301,8 @@ ChromeExOAuth.sendRequest = function(method, url, headers, body, callback) { .createInstance(Ci.nsIXMLHttpRequest); xhr.onreadystatechange = function(data) { - callback(xhr, data); - } + callback(xhr, data, url); + }; xhr.open(method, url, true); if (headers) { for (var header in headers) { @@ -461,7 +461,7 @@ ChromeExOAuth.prototype.initOAuthFlow = function(callback) { var request_params = { 'url_callback_param' : 'chromeexoauthcallback', 'url_callback': this.callback_page - } + }; var self = this; this.getRequestToken(function(url, error) { if (error) @@ -475,7 +475,7 @@ ChromeExOAuth.prototype.initOAuthFlow = function(callback) { if (params['chromeexoauthcallback'] == 'true') { var oauth_token = params['oauth_token']; - var oauth_verifier = params['oauth_verifier'] + var oauth_verifier = params['oauth_verifier']; self.getAccessToken(oauth_token, oauth_verifier, callback); } else @@ -535,8 +535,9 @@ ChromeExOAuth.prototype.getRequestToken = function(callback, opt_args) { * approve the token. * @param {XMLHttpRequest} xhr The XMLHttpRequest object used to fetch the * request token. + * requestUrl: requested URL (to log errors better) */ -ChromeExOAuth.prototype.onRequestToken = function(callback, xhr) { +ChromeExOAuth.prototype.onRequestToken = function(callback, xhr, data, requestUrl) { if (xhr.readyState == 4) { if (xhr.status == 200) { var params = ChromeExOAuth.formDecode(xhr.responseText); @@ -552,6 +553,8 @@ ChromeExOAuth.prototype.onRequestToken = function(callback, xhr) { callback(url); } else { // throw new Error("Fetching request token failed. Status " + xhr.status); + toConsole("OAuth Request token response: " + xhr.responseText); + toConsole("OAuth Request token url: " +requestUrl); callback(null, "Fetching request token failed. Status " + xhr.status); } } @@ -765,7 +768,7 @@ if (OAuthSimple === undefined) this._getAccessToken(); } if(this._parameters['oauth_version'] === undefined) { - this._parameters['oauth_version']=='1.0'; + this._parameters['oauth_version']='1.0'; } return this; @@ -1031,14 +1034,15 @@ if (OAuthSimple === undefined) // heavily optimized and compressed version of http://pajhome.org.uk/crypt/md5/sha1.js // _p = b64pad, _z = character size; not used here but I left them available just in case if(!_p){_p='=';}if(!_z){_z=8;}function _f(t,b,c,d){if(t<20){return(b&c)|((~b)&d);}if(t<40){return b^c^d;}if(t<60){return(b&c)|(b&d)|(c&d);}return b^c^d;}function _k(t){return(t<20)?1518500249:(t<40)?1859775393:(t<60)?-1894007588:-899497514;}function _s(x,y){var l=(x&0xFFFF)+(y&0xFFFF),m=(x>>16)+(y>>16)+(l>>16);return(m<<16)|(l&0xFFFF);}function _r(n,c){return(n<>>(32-c));}function _c(x,l){x[l>>5]|=0x80<<(24-l%32);x[((l+64>>9)<<4)+15]=l;var w=[80],a=1732584193,b=-271733879,c=-1732584194,d=271733878,e=-1009589776;for(var i=0;i>5]|=(s.charCodeAt(i/8)&m)<<(32-_z-i%32);}return b;}function _h(k,d){var b=_b(k);if(b.length>16){b=_c(b,k.length*_z);}var p=[16],o=[16];for(var i=0;i<16;i++){p[i]=b[i]^0x36363636;o[i]=b[i]^0x5C5C5C5C;}var h=_c(p.concat(_b(d)),512+d.length*_z);return _c(o.concat(h),512+160);}function _n(b){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s='';for(var i=0;i>2]>>8*(3-i%4))&0xFF)<<16)|(((b[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((b[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(var j=0;j<4;j++){if(i*8+j*6>b.length*32){s+=_p;}else{s+=t.charAt((r>>6*(3-j))&0x3F);}}}return s;}function _x(k,d){return _n(_h(k,d));}return _x(k,d); - } + }; self._normalizedParameters = function() { var elements = new Array(), paramNames = [], i=0, - ra =0; + ra =0, + pLen; for (var paramName in this._parameters) { if (ra++ > 1000) { @@ -1100,7 +1104,7 @@ if (OAuthSimple === undefined) target[key] = source[key]; } return target; - } + }; return self; };