From e190f6f16bff401f8b0b284d1d0cf591c6b0487f Mon Sep 17 00:00:00 2001 From: Zach Benz Date: Sun, 16 Feb 2014 22:04:37 -0700 Subject: [PATCH] Working on ZachBenz/IndigoRemote#1 - digest authentication --- node_modules/http-digest-client/http-digest-client.js | 2 +- src/js-pre-browserify/pebble-js-app-pre-browserify.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/node_modules/http-digest-client/http-digest-client.js b/node_modules/http-digest-client/http-digest-client.js index 12d0d16..4fe5bba 100644 --- a/node_modules/http-digest-client/http-digest-client.js +++ b/node_modules/http-digest-client/http-digest-client.js @@ -140,7 +140,7 @@ var HTTPDigest = function () { return HTTPDigest; }(); -module.exports = function createDigestClient(username, password, https) { +module.exports = function (username, password, https) { return new HTTPDigest(username, password, https); }; diff --git a/src/js-pre-browserify/pebble-js-app-pre-browserify.js b/src/js-pre-browserify/pebble-js-app-pre-browserify.js index d99e7c2..50fed95 100644 --- a/src/js-pre-browserify/pebble-js-app-pre-browserify.js +++ b/src/js-pre-browserify/pebble-js-app-pre-browserify.js @@ -25,7 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var digest = require('http-digest-client').createDigestClient('username', 'password'); +// Some things we need to define to get node.js modules to work +if (typeof window.location === "undefined") { + window.location = []; +} +if (typeof window.location.protocol === "undefined") { + window.location.protocol = "http:"; +} var MAX_DEVICE_NAME_LENGTH = 95; // 1 less than max on Pebble side to allow for strncpy to insert terminating null in strncpy var MAX_ACTION_NAME_LENGTH = 95; // 1 less than max on Pebble side to allow for strncpy to insert terminating null in strncpy @@ -74,13 +80,12 @@ console.log("prefixForGet is: " + prefixForGet); // Set callback for the app ready event Pebble.addEventListener("ready", function(e) { - console.log("connect!" + e.ready); + console.log("Ready: " + e.ready); console.log(e.type); }); Pebble.addEventListener("showConfiguration", function() { console.log("showing configuration"); -// Pebble.openURL('https://s3.amazonaws.com/IndigoRemote/settings.html?serverAddress=' + serverAddress + '&serverPort=' + serverPort); var html = config_html.replace('__CONFIG__', JSON.stringify(config), 'g'); Pebble.openURL('data:text/html,' + encodeURI(html + '