Permalink
Browse files

Revert "Merge pull request #362 from jeffmarshall/master"

This reverts commit 32713ad, reversing
changes made to 4a81507.
  • Loading branch information...
1 parent 32713ad commit f7dc90c8dae743d5736dc6c807eecde613eb4fd4 @mikeal mikeal committed Nov 5, 2012
Showing with 13 additions and 21 deletions.
  1. +13 −21 oauth.js
View
@@ -16,27 +16,19 @@ function rfc3986 (str) {
;
}
-function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret) {
- // adapted from https://dev.twitter.com/docs/auth/oauth and
- // https://dev.twitter.com/docs/auth/creating-signature
-
- var querystring = Object.keys(params).sort().map(function(key){
- return key +"="+ params[key];
- }).join('&');
-
- var base = [
- httpMethod ? httpMethod.toUpperCase : 'GET',
- rfc3986(base_uri),
- rfc3986(querystring),
- ].join('&');
-
- var key = [
- consumer_secret,
- token_secret || ''
- ].map(rfc3986).join('&');
-
- return sha1(key, base);
+function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret, body) {
+ // adapted from https://dev.twitter.com/docs/auth/oauth
+ var base =
+ (httpMethod || 'GET') + "&" +
+ encodeURIComponent( base_uri ) + "&" +
+ Object.keys(params).sort().map(function (i) {
+ // big WTF here with the escape + encoding but it's what twitter wants
+ return escape(rfc3986(i)) + "%3D" + escape(rfc3986(params[i]))
+ }).join("%26")
+ var key = encodeURIComponent(consumer_secret) + '&'
+ if (token_secret) key += encodeURIComponent(token_secret)
+ return sha1(key, base)
}
exports.hmacsign = hmacsign
-exports.rfc3986 = rfc3986
+exports.rfc3986 = rfc3986

0 comments on commit f7dc90c

Please sign in to comment.