Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oauth

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth - npm Package Compare versions

Comparing version 0.9.8 to 0.9.9

.npmignore

8

lib/oauth.js

@@ -330,3 +330,9 @@ var crypto= require('crypto'),

if( (method == "POST" || method == "PUT") && ( post_body == null && extra_params != null) ) {
post_body= querystring.stringify(extra_params);
// Fix the mismatch between the output of querystring.stringify() and this._encodeData()
post_body= querystring.stringify(extra_params)
.replace(/\!/g, "%21")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
.replace(/\*/g, "%2A");
}

@@ -333,0 +339,0 @@

@@ -8,3 +8,3 @@ var querystring= require('querystring'),

exports.OAuth2= function(clientId, clientSecret, baseSite, authorizePath, accessTokenPath) {
exports.OAuth2= function(clientId, clientSecret, baseSite, authorizePath, accessTokenPath, customHeaders) {
this._clientId= clientId;

@@ -16,2 +16,4 @@ this._clientSecret= clientSecret;

this._accessTokenName= "access_token";
this._authMethod= "Bearer";
this._customHeaders = customHeaders || {};
}

@@ -28,2 +30,8 @@

// Sets the authorization method for Authorization header.
// e.g. Authorization: Bearer <token> # "Bearer" is the authorization method.
exports.OAuth2.prototype.setAuthMethod = function ( authMethod ) {
this._authMethod = authMethod;
};
exports.OAuth2.prototype._getAccessTokenUrl= function() {

@@ -33,2 +41,8 @@ return this._baseSite + this._accessTokenUrl; /* + "?" + querystring.stringify(params); */

// Build the authorization header. In particular, build the part after the colon.
// e.g. Authorization: Bearer <token> # Build "Bearer <token>"
exports.OAuth2.prototype._buildAuthHeader= function(token) {
return this._authMethod + ' ' + token;
};
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {

@@ -48,3 +62,3 @@

var realHeaders= {};
var realHeaders= this._customHeaders;
if( headers ) {

@@ -165,3 +179,6 @@ for(var key in headers) {

exports.OAuth2.prototype.get= function(url, access_token, callback) {
this._request("GET", url, {}, "", access_token, callback );
var headers= {
'Authorization': this._buildAuthHeader(access_token)
};
this._request("GET", url, headers, "", access_token, callback );
}

2

package.json
{ "name" : "oauth"
, "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.8"
, "version" : "0.9.9"
, "directories" : { "lib" : "./lib" }

@@ -5,0 +5,0 @@ , "main" : "index.js"

@@ -19,6 +19,9 @@ node-oauth

* 0.9.9
- OAuth1: Fix the mismatch between the output of querystring.stringify() and this._encodeData(). (thank you rolandboon)
- OAuth2: Adds Authorization Header and supports extra headers by default ( thanks to Brian Park)
* 0.9.8
- OAuth: Support overly-strict OAuth server's that require whitespace separating the Authorization Header parameters (e.g. 500px.com) (Thanks to Christian Schwarz)
- OAuth: Fix incorrect double-encoding of PLAINTEXT OAuth connections (Thanks to Joe Rozner)
- OAuth: Minor safety check added when checking hostnames. (Thanks to Garrick Cheung)
- OAuth1: Support overly-strict OAuth server's that require whitespace separating the Authorization Header parameters (e.g. 500px.com) (Thanks to Christian Schwarz)
- OAuth1: Fix incorrect double-encoding of PLAINTEXT OAuth connections (Thanks to Joe Rozner)
- OAuth1: Minor safety check added when checking hostnames. (Thanks to Garrick Cheung)
* 0.9.7

@@ -93,1 +96,3 @@ - OAuth2: Pass back any extra response data for calls to getOAuthAccessToken (Thanks to Tang Bo Hao)

* Garrick Cheung - http://www.garrickcheung.com/
* rolandboon - http://rolandboon.com
* Brian Park - http://github.com/yaru22
var vows = require('vows'),
assert = require('assert'),
https = require('https'),
OAuth2= require('../lib/oauth2').OAuth2;
vows.describe('OAuth2').addBatch({
'Given an OAuth2 instance, ': {
topic: new OAuth2(),
'Given an OAuth2 instance with clientId and clientSecret, ': {
topic: new OAuth2("clientId", "clientSecret"),
'When handling the access token response': {

@@ -43,4 +44,4 @@ 'we should correctly extract the token if received as form-data': function (oa) {

oa._request= function(method, url, headers, post_body, access_token, callback) {
assert.isTrue( post_body.indexOf("code=xsds23") != -1 )
}
assert.isTrue( post_body.indexOf("code=xsds23") != -1 );
};
oa.getOAuthAccessToken("xsds23", {} );

@@ -52,4 +53,4 @@ }

oa._request= function(method, url, headers, post_body, access_token, callback) {
assert.isTrue( post_body.indexOf("code=xsds23") != -1 )
}
assert.isTrue( post_body.indexOf("code=xsds23") != -1 );
};
oa.getOAuthAccessToken("xsds23", {grant_type:"refresh_toucan"} );

@@ -61,10 +62,39 @@ }

oa._request= function(method, url, headers, post_body, access_token, callback) {
assert.isTrue( post_body.indexOf("refresh_token=sdsds2") != -1 )
assert.isTrue( post_body.indexOf("grant_type=refresh_token") != -1 )
assert.isTrue( post_body.indexOf("code=") == -1 )
}
assert.isTrue( post_body.indexOf("refresh_token=sdsds2") != -1 );
assert.isTrue( post_body.indexOf("grant_type=refresh_token") != -1 );
assert.isTrue( post_body.indexOf("code=") == -1 );
};
oa.getOAuthAccessToken("sdsds2", {grant_type:"refresh_token"} );
}
},
'When calling get with the default authorization method': {
'we should pass the authorization header with Bearer method and value of the access_token' : function(oa) {
oa._request= function(method, url, headers, post_body, access_token, callback) {
assert.equal(headers["Authorization"], "Bearer abcd5");
};
oa.get("", "abcd5");
}
},
'When calling get with the authorization method set to Basic': {
'we should pass the authorization header with Basic method and value of the access_token' : function(oa) {
oa._request= function(method, url, headers, post_body, access_token, callback) {
assert.equal(headers["Authorization"], "Basic cdg2");
};
oa.setAuthMethod("Basic");
oa.get("", "cdg2");
}
}
},
'Given an OAuth2 instance with clientId, clientSecret and customHeaders': {
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
{ 'SomeHeader': '123' }),
'When calling get': {
'we should see the custom headers mixed into headers property in options passed to http-library' : function(oa) {
https.request = function(options, callback) {
assert.equal(headers["SomeHeader"], "123");
};
oa.get("", {});
}
}
}
}).export(module);
}).export(module);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc