Skip to content

Commit

Permalink
0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bartve committed Oct 20, 2014
1 parent fc9f4e1 commit 0b9362d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.4.2 / 2014-10-20
==================
* Fixed `this` scoping in `about()`
* Switched from `http` to the newly implemented `https` Discogs API connection for added security

0.4.1 / 2014-10-16
==================
* Fixed "Unexpected token u" error when trying to parse an `undefined` response value to JSON
Expand Down
21 changes: 11 additions & 10 deletions lib/client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var http = require('http'),
var https = require('https'),
zlib = require('zlib'),
url = require('url'),
queryString = require('querystring'),
Expand Down Expand Up @@ -28,10 +28,10 @@ var merge = function(target, source){

var config = {
host: 'api.discogs.com',
oauthRequestUrl: 'http://api.discogs.com/oauth/request_token',
oauthAccessUrl: 'http://api.discogs.com/oauth/access_token',
oauthAuthorizeUrl: 'http://www.discogs.com/oauth/authorize',
port: 80,
oauthRequestUrl: 'https://api.discogs.com/oauth/request_token',
oauthAccessUrl: 'https://api.discogs.com/oauth/access_token',
oauthAuthorizeUrl: 'https://www.discogs.com/oauth/authorize',
port: 443,
customHeaders: {
'Accept': 'application/json; application/octet-stream',
'Accept-Encoding': 'gzip,deflate',
Expand Down Expand Up @@ -148,8 +148,9 @@ DiscogsClient.prototype.identity = function(callback){
*/

DiscogsClient.prototype.about = function(callback){
var self = this;
this.get('', function(err, data){
if(data){ data.disconnect = { version: pkg.version, userAgent: (this.userAgent||config.customHeaders['User-Agent']) }; }
if(data){ data.disconnect = { version: pkg.version, userAgent: (self.userAgent||config.customHeaders['User-Agent']) }; }
(typeof callback === 'function')&&callback(err, data);
});
};
Expand Down Expand Up @@ -193,12 +194,12 @@ DiscogsClient.prototype._rawRequest = function(options, callback){
// Add Authorization header when authenticated or in the process of authenticating
if(oauth.status){
var oa = new OAuth({consumer: {public: oauth.consumerKey, secret: oauth.consumerSecret}}),
fullUrl = (urlParts.protocol && urlParts.host) ? urlParts.href : 'http://'+config.host+urlParts.path,
fullUrl = (urlParts.protocol && urlParts.host) ? urlParts.href : 'https://'+config.host+urlParts.path,
authObj = oa.authorize({method: method, url: fullUrl}, {public: oauth.token, secret: oauth.tokenSecret});
headers['Authorization'] = oa.toHeader(authObj).Authorization;
}

// Set the HTTP request options
// Set the HTTPS request options
var options = {
host: urlParts.host||config.host,
port: urlParts.port||config.port,
Expand All @@ -207,8 +208,8 @@ DiscogsClient.prototype._rawRequest = function(options, callback){
headers: headers
};

// Build the HTTP request
var req = http.request(options, function(res){
// Build the HTTPS request
var req = https.request(options, function(res){
var data = '',
rateLimit = null,
add = function(chunk){ data += chunk.toString(); };
Expand Down
4 changes: 2 additions & 2 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ module.exports = function(client){
};

/**
* Search the database (requires authentication starting 2014-10-14)
* Search the database
* @param {String} query - The search query
* @param {Object} [params] - Search parameters as defined on http://www.discogs.com/developers/resources/database/search-endpoint.html
* @param {Object} [params] - Search parameters as defined on http://www.discogs.com/developers/#page:database,header:database-search
* @param {Function} [callback] - Callback function
*/

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "disconnect",
"description": "An easy to use client library to connect with the discogs.com API v2.0",
"version": "0.4.1",
"version": "0.4.2",
"keywords": ["discogs", "api", "client", "oauth"],
"homepage": "https://github.com/bartve/disconnect",
"bugs": "https://github.com/bartve/disconnect/issues",
Expand Down

0 comments on commit 0b9362d

Please sign in to comment.