request
Advanced tools
Comparing version 2.2.6 to 2.2.9
@@ -232,4 +232,4 @@ // Copyright 2010-2011 Mikeal Rogers | ||
self.headers.authorization = | ||
'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+encodeURIComponent(oa[i])+'"'}).join(',') | ||
self.headers.authorization += ',oauth_signature="'+encodeURIComponent(signature)+'"' | ||
'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',') | ||
self.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"' | ||
} | ||
@@ -236,0 +236,0 @@ |
15
oauth.js
@@ -9,2 +9,12 @@ var crypto = require('crypto') | ||
function rfc3986 (str) { | ||
return encodeURIComponent(str) | ||
.replace('!','%21') | ||
.replace('*','%2A') | ||
.replace('(','%28') | ||
.replace(')','%29') | ||
.replace("'",'%27') | ||
; | ||
} | ||
function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret, body) { | ||
@@ -17,3 +27,3 @@ // adapted from https://dev.twitter.com/docs/auth/oauth | ||
// big WTF here with the escape + encoding but it's what twitter wants | ||
return encodeURIComponent(escape(i)) + "%3D" + encodeURIComponent(escape(params[i])) | ||
return escape(rfc3986(i)) + "%3D" + escape(rfc3986(params[i])) | ||
}).join("%26") | ||
@@ -25,2 +35,3 @@ var key = consumer_secret + '&' | ||
exports.hmacsign = hmacsign | ||
exports.hmacsign = hmacsign | ||
exports.rfc3986 = rfc3986 |
{ "name" : "request" | ||
, "description" : "Simplified HTTP request client." | ||
, "tags" : ["http", "simple", "util", "utility"] | ||
, "version" : "2.2.6" | ||
, "version" : "2.2.9" | ||
, "author" : "Mikeal Rogers <mikeal.rogers@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "repository" : |
103768
1444