facebook-node-sdk
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -413,3 +413,9 @@ var https = require('https'); | ||
if (param !== null) { | ||
this.signedRequest = this.parseSignedRequest(param); | ||
try { | ||
this.signedRequest = this.parseSignedRequest(param); | ||
} | ||
catch (err) { | ||
this.signedRequest = null; | ||
this.errorLog('Parse error sigened_request parameter: ' + param); | ||
} | ||
} | ||
@@ -420,3 +426,9 @@ if (this.signedRequest === null) { | ||
if (cookieValue !== null) { | ||
this.signedRequest = this.parseSignedRequest(cookieValue); | ||
try { | ||
this.signedRequest = this.parseSignedRequest(cookieValue); | ||
} | ||
catch (err) { | ||
this.signedRequest = null; | ||
this.errorLog('Parse error sigened_request cookie: ' + cookieValue); | ||
} | ||
} | ||
@@ -567,3 +579,10 @@ } | ||
else { | ||
var result = JSON.parse(response); | ||
try { | ||
var result = JSON.parse(response); | ||
} | ||
catch (err) { | ||
callback(new Error('Parse REST server response error: ' + err), null); | ||
callback = null; | ||
return; | ||
} | ||
// results are returned, errors are thrown | ||
@@ -623,5 +642,13 @@ if (result && typeof result === 'object' && result.hasOwnProperty('error_code')) { | ||
else { | ||
result = JSON.parse(response); | ||
try { | ||
result = JSON.parse(response); | ||
} | ||
catch (err) { | ||
callback(new Error('Parse Graph API server response error: ' + err), null); | ||
callback = null; | ||
return; | ||
} | ||
if (result && typeof result === 'object' && result.hasOwnProperty('error')) { | ||
callback(self.createApiError(result), null); | ||
callback = null; | ||
} | ||
@@ -769,2 +796,4 @@ else { | ||
* @return array The payload inside it or null if the sig is wrong | ||
* | ||
* @throws Error | ||
*/ | ||
@@ -778,2 +807,4 @@ BaseFacebook.prototype.parseSignedRequest = function(signedRequest) { | ||
var sig = this.base64UrlDecode(encodedSig); | ||
// must catch in caller | ||
var data = JSON.parse(this.base64UrlDecode(payload).toString('utf8')); | ||
@@ -780,0 +811,0 @@ |
{ | ||
"name": "facebook-node-sdk", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Node.js SDK for the Facebook API", | ||
@@ -11,2 +11,5 @@ "tags": ["facebook"], | ||
}, | ||
"scripts": { | ||
"test": "TEST_FB_APP_ID=227710073967374 TEST_FB_SECRET=a25a2216fb1b772f1c554ebb9d950aec node_modules/.bin/expresso test/*" | ||
}, | ||
"bugs": { | ||
@@ -13,0 +16,0 @@ "url": "https://github.com/amachang/facebook-node-sdk/issues" |
@@ -1327,2 +1327,30 @@ var path = require('path'); | ||
graph: function(beforeExit, assert) { | ||
var done = false; | ||
beforeExit(function() { assert.ok(done) }); | ||
var facebook = new TransientFacebook({ | ||
appId: config.appId, | ||
secret: config.secret | ||
}); | ||
facebook.graph('/amachang', function(err, data) { | ||
assert.equal(err, null); | ||
assert.equal(data.id, '1055572299'); | ||
facebook.graph('/amachang', 'POST', function(err, data) { | ||
assert.ok(err instanceof Error); | ||
assert.equal(data, null); | ||
facebook.graph('/', { ids: 'amachang,yukoba' }, function(err, data) { | ||
assert.equal(data.amachang.id, '1055572299'); | ||
assert.equal(data.yukoba.id, '1192222589'); | ||
facebook.graph('invalid path', function(err, data) { | ||
assert.ok(err instanceof Error); | ||
assert.equal(data, null); | ||
done = true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}, | ||
makeRequest: function(beforeExit, assert) { | ||
@@ -1329,0 +1357,0 @@ var done = false; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86411
10
2535