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

fitbit-js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fitbit-js - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

77

lib/fitbit_client.js
/*
* Fitbit-js
*
* Copyright (c) 2011 Simon Murtha-Smith <simon@murtha-smith.com>
*/
var url = require('url');
var http = require('http');
var OAuth = require('oauth').OAuth;

@@ -16,7 +13,15 @@ var querystring = require('querystring');

module.exports = function (api_key, api_secret, callbackURI, unit_system) {
var client = {version: '0.2.1'};
var client = {
version: '0.3.1'
};
var serializer = Serializer.createSecureSerializer(api_key, api_secret);
var headers = {'Accept': '*/*', 'Connection': 'close', 'User-Agent': 'fitbit-js ' + client.version};
var headers = {
Accept: '*/*',
Connection: 'close',
'User-Agent': 'fitbit-js ' + client.version
};
if (typeof unit_system !== 'undefined' && unit_system !== null) headers['Accept-Language'] = unit_system;
if (typeof unit_system !== 'undefined' && unit_system !== null) {
headers['Accept-Language'] = unit_system;
}

@@ -34,3 +39,5 @@ var oAuth = new OAuth('https://api.fitbit.com/oauth/request_token',

data = JSON.parse(data);
} catch (e) { exception = e; }
} catch (e) {
exception = e;
}
callback(exception, response, data);

@@ -42,12 +49,21 @@ };

oAuth.get(baseURI + path + '?' + querystring.stringify(params),
token.oauth_token, token.oauth_token_secret, requestCallback(callback));
token.oauth_token,
token.oauth_token_secret,
requestCallback(callback));
}
function post(path, params, token, callback) {
oAuth.post(baseURI + path, token.oauth_token, token.oauth_token_secret,
params, null, requestCallback(callback));
oAuth.post(baseURI + path,
token.oauth_token,
token.oauth_token_secret,
params,
null,
requestCallback(callback));
}
function oAuthDelete(path, params, token, callback){
oAuth.delete(baseURI + path, token.oauth_token, token.oauth_token_secret, requestCallback(callback));
oAuth.delete(baseURI + path,
token.oauth_token,
token.oauth_token_secret,
requestCallback(callback));
}

@@ -66,5 +82,8 @@

var sess;
if(req.cookies && req.cookies.fitbit_client) {
try { sess = serializer.parse(req.cookies.fitbit_client); }catch(E){ }
if (req.cookies && req.cookies.fitbit_client) {
try {
sess = serializer.parse(req.cookies.fitbit_client);
} catch(E) { }
}
var qs = url.parse(req.url, true).query;

@@ -75,18 +94,32 @@

if(has_token && has_secret) { // Access token
if (has_token && has_secret) { // Access token
oAuth.getOAuthAccessToken(qs.oauth_token,
sess.tokenSecret,
sess.token_secret,
qs.oauth_verifier,
function (error, oauth_token, oauth_token_secret, additionalParameters) {
function (error, oauth_token, oauth_token_secret) {
if (error) return callback(error, null);
callback(null, {oauth_token: oauth_token, oauth_token_secret: oauth_token_secret});
callback(null, {
oauth_token: oauth_token,
oauth_token_secret: oauth_token_secret
});
});
} else { // Request token
oAuth.getOAuthRequestToken({oauth_callback: callbackURI},
function (error, oauth_token, oauth_token_secret, oauth_authorize_url, additionalParameters) {
function (error, oauth_token, oauth_token_secret) {
if (error) return callback(error, null);
// stash the secret
res.cookie('fitbit_client',
serializer.stringify({token_secret:oauth_token_secret}),
{ path: '/', httpOnly: false }); // stash the secret
res.redirect('https://www.fitbit.com/oauth/authorize?oauth_token=' + oauth_token);
serializer.stringify({
token_secret: oauth_token_secret
}),
{
path: '/',
httpOnly: false
}
);
res.redirect('https://www.fitbit.com/oauth/authorize?oauth_token=' +
oauth_token);
});

@@ -93,0 +126,0 @@ }

{
"name": "fitbit-js",
"description": "Simple FitBit API client",
"version": "0.3.0",
"version": "0.3.1",
"author": "Simon Murtha Smith <simon@murtha-smith.com>",

@@ -23,4 +23,4 @@ "keywords": ["fitbit"],

"engines": {
"node": ">=0.8.0 <0.9.0"
"node": ">=0.8.0 <0.11.0"
}
}

Sorry, the diff of this file is not supported yet

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