From 8258c3f826940d860833b44164bd5fd52b4b74a5 Mon Sep 17 00:00:00 2001 From: "R. Aidan Campbell" Date: Sun, 28 Feb 2016 00:49:20 -0500 Subject: [PATCH] added untested saving and loading of cert --- static/js/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/static/js/index.js b/static/js/index.js index cbfb2ea..03f05ea 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -20,6 +20,26 @@ function updateBitrateField() { function moduleDidLoad() { console.log("NaCl module loaded."); + console.log("Loading certs"); + if (chrome.storage) { // load the cert if we have the ability to load things. + chrome.storage.sync.get('cert', function(savedCert) { + if (savedCert.cert != null) { // we have a saved cert + var cert = savedCert.cert.cert; + var pk = savedCert.cert.privateKey; + sendMessage('httpInit', [cert, pk]).then(function (ret) { + return api.pair(cert, "1234"); + }); + } else { // we don't have a saved cert. make one. + // TODO: NaCl call to make a new cert + sendMessage('makeCert', []).then(function (cert) { + storeData('cert', cert, null); // we just made a cert. save it. + return sendMessage('httpInit', [cert.cert, cert.privateKey]).then(function (ret) { + return api.pair(cert, "1234"); + }); + }); + } + } + } } // we want the user to progress through the streaming process