| ... | ... |
@@ -35,11 +35,17 @@ |
| 35 | 35 |
function onSubmit() {
|
| 36 | 36 |
// Set the return URL depending on the runtime environment |
| 37 | 37 |
var return_to = getQueryParam("return_to", "pebblejs://close#");
|
| 38 |
+ var sign_enabled = document.getElementById("signEnable").checked;
|
|
| 38 | 39 |
var options = {
|
| 39 | 40 |
"url": document.getElementById("url").value,
|
| 40 | 41 |
"dataField": document.getElementById("dataField").value,
|
| 41 | 42 |
"bundleMax": document.getElementById("bundleMaxSize").value,
|
| 42 | 43 |
"bundleSeparator": encodeURIComponent(document.getElementById("bundleSeparator").value),
|
| 44 |
+ "signAlgorithm": document.getElementById("signAlgorithm").value,
|
|
| 45 |
+ "signFieldFormat": document.getElementById("signFieldFormat").value,
|
|
| 46 |
+ "signFieldName": document.getElementById("signFieldName").value,
|
|
| 47 |
+ "signKey": document.getElementById("signKey").value,
|
|
| 48 |
+ "signKeyFormat": document.getElementById("signKeyFormat").value,
|
|
| 43 | 49 |
} |
| 44 | 50 |
|
| 45 | 51 |
if (!document.getElementById("bundleEnable").checked) {
|
| ... | ... |
@@ -59,6 +65,12 @@ |
| 59 | 65 |
= document.getElementById("bundleEnable").checked
|
| 60 | 66 |
? "block" : "none"; |
| 61 | 67 |
} |
| 68 |
+ |
|
| 69 |
+ function updateSignVisibility() {
|
|
| 70 |
+ document.getElementById("signFields").style.display
|
|
| 71 |
+ = document.getElementById("signEnable").checked
|
|
| 72 |
+ ? "block" : "none"; |
|
| 73 |
+ } |
|
| 62 | 74 |
</script> |
| 63 | 75 |
</head> |
| 64 | 76 |
<body> |
| ... | ... |
@@ -112,6 +124,58 @@ |
| 112 | 124 |
</div> |
| 113 | 125 |
</div> |
| 114 | 126 |
|
| 127 |
+ <div class="item-container"> |
|
| 128 |
+ <div class="item-container-header">Data Signature</div> |
|
| 129 |
+ <div class="item-container-content"> |
|
| 130 |
+ <label class="item"> |
|
| 131 |
+ Enable |
|
| 132 |
+ <input type="checkbox" class="item-toggle" name="signEnable" id="signEnable" onchange="updateSignVisibility();"> |
|
| 133 |
+ </label> |
|
| 134 |
+ <div id=signFields> |
|
| 135 |
+ <label class="item"> |
|
| 136 |
+ Algorithm |
|
| 137 |
+ <select id="signAlgorithm" class="item-select"> |
|
| 138 |
+ <option class="item-select-option">SHA-1</option> |
|
| 139 |
+ <option class="item-select-option">SHA-224</option> |
|
| 140 |
+ <option class="item-select-option">SHA-256</option> |
|
| 141 |
+ <option class="item-select-option">SHA-384</option> |
|
| 142 |
+ <option class="item-select-option">SHA-512</option> |
|
| 143 |
+ </select> |
|
| 144 |
+ </label> |
|
| 145 |
+ <label class="item"> |
|
| 146 |
+ Field Format |
|
| 147 |
+ <select id="signFieldFormat" class="item-select"> |
|
| 148 |
+ <option class="item-select-option" value="HEX">Hex</option> |
|
| 149 |
+ <option class="item-select-option" value="B64">Base-64</option> |
|
| 150 |
+ <option class="item-select-option" value="TEXT">Text</option> |
|
| 151 |
+ <option class="item-select-option" value="BYTES">Bytes</option> |
|
| 152 |
+ </select> |
|
| 153 |
+ </label> |
|
| 154 |
+ <label class="item"> |
|
| 155 |
+ Signature Field Name |
|
| 156 |
+ <div class="item-input-wrapper"> |
|
| 157 |
+ <input type="text" class="item-input" name="signFieldName" id="signFieldName" value=""> |
|
| 158 |
+ </div> |
|
| 159 |
+ </label> |
|
| 160 |
+ <label class="item"> |
|
| 161 |
+ Private Key |
|
| 162 |
+ <div class="item-input-wrapper"> |
|
| 163 |
+ <input type="text" class="item-input" name="signKey" id="signKey"> |
|
| 164 |
+ </div> |
|
| 165 |
+ </label> |
|
| 166 |
+ <label class="item"> |
|
| 167 |
+ Private Key Format |
|
| 168 |
+ <select id="signKeyFormat" class="item-select"> |
|
| 169 |
+ <option class="item-select-option" value="HEX">Hex</option> |
|
| 170 |
+ <option class="item-select-option" value="B64">Base-64</option> |
|
| 171 |
+ <option class="item-select-option" value="TEXT">Text</option> |
|
| 172 |
+ <option class="item-select-option" value="BYTES">Bytes</option> |
|
| 173 |
+ </select> |
|
| 174 |
+ </label> |
|
| 175 |
+ </div> |
|
| 176 |
+ </div> |
|
| 177 |
+ </div> |
|
| 178 |
+ |
|
| 115 | 179 |
<div class="item-container"> |
| 116 | 180 |
<div class="button-container"> |
| 117 | 181 |
<input id="submitButton" type="button" class="item-button" value="SUBMIT" onClick="onSubmit()"> |
| ... | ... |
@@ -133,7 +197,14 @@ |
| 133 | 197 |
document.getElementById("bundleEnable").checked = (initBundleSize > 1);
|
| 134 | 198 |
document.getElementById("bundleMaxSize").value = initBundleSize;
|
| 135 | 199 |
document.getElementById("bundleSeparator").value = encodeURIComponent(getQueryParam("bundle_sep", ""));
|
| 200 |
+ document.getElementById("signAlgorithm").value = getQueryParam("s_algo", "SHA-1");
|
|
| 201 |
+ document.getElementById("signFieldFormat").value = getQueryParam("s_fieldf", "HEX");
|
|
| 202 |
+ document.getElementById("signFieldName").value = getQueryParam("s_field", "");
|
|
| 203 |
+ document.getElementById("signKey").value = getQueryParam("s_key", "");
|
|
| 204 |
+ document.getElementById("signKeyFormat").value = getQueryParam("s_keyf", "HEX");
|
|
| 205 |
+ document.getElementById("signEnable").checked = (getQueryParam("s_field", "") !== "");
|
|
| 136 | 206 |
updateBundleVisibility(); |
| 207 |
+ updateSignVisibility(); |
|
| 137 | 208 |
</script> |
| 138 | 209 |
</body> |
| 139 | 210 |
</html> |
| ... | ... |
@@ -18,6 +18,11 @@ var cfg_endpoint = null; |
| 18 | 18 |
var cfg_data_field = null; |
| 19 | 19 |
var cfg_bundle_max = 1; |
| 20 | 20 |
var cfg_bundle_separator = "\r\n"; |
| 21 |
+var cfg_sign_algo = ""; |
|
| 22 |
+var cfg_sign_field = ""; |
|
| 23 |
+var cfg_sign_field_format = ""; |
|
| 24 |
+var cfg_sign_key = ""; |
|
| 25 |
+var cfg_sign_key_format = ""; |
|
| 21 | 26 |
|
| 22 | 27 |
var to_send = []; |
| 23 | 28 |
var senders = [new XMLHttpRequest(), new XMLHttpRequest()]; |
| ... | ... |
@@ -80,6 +85,11 @@ Pebble.addEventListener("ready", function() {
|
| 80 | 85 |
cfg_data_field = localStorage.getItem("cfgDataField");
|
| 81 | 86 |
cfg_bundle_max = parseInt(localStorage.getItem("cfgBundleMax") || "1", 10);
|
| 82 | 87 |
cfg_bundle_separator = localStorage.getItem("cfgBundleSeparator");
|
| 88 |
+ cfg_sign_algo = localStorage.getItem("cfgSignAlgorithm");
|
|
| 89 |
+ cfg_sign_field = localStorage.getItem("cfgSignFieldName");
|
|
| 90 |
+ cfg_sign_field_format = localStorage.getItem("cfgSignFieldFormat");
|
|
| 91 |
+ cfg_sign_key = localStorage.getItem("cfgSignKey");
|
|
| 92 |
+ cfg_sign_key_format = localStorage.getItem("cfgSignKeyFormat");
|
|
| 83 | 93 |
|
| 84 | 94 |
if (!(cfg_bundle_max >= 1)) cfg_bundle_max = 1; |
| 85 | 95 |
|
| ... | ... |
@@ -123,6 +133,13 @@ Pebble.addEventListener("showConfiguration", function() {
|
| 123 | 133 |
if (cfg_bundle_separator) {
|
| 124 | 134 |
settings += "&bundle_sep=" + encodeURIComponent(cfg_bundle_separator); |
| 125 | 135 |
} |
| 136 |
+ if (cfg_sign_field) {
|
|
| 137 |
+ settings += "&s_algo=" + encodeURIComponent(cfg_sign_algo) |
|
| 138 |
+ + "&s_field=" + encodeURIComponent(cfg_sign_field) |
|
| 139 |
+ + "&s_fieldf=" + encodeURIComponent(cfg_sign_field_format) |
|
| 140 |
+ + "&s_key=" + encodeURIComponent(cfg_sign_key) |
|
| 141 |
+ + "&s_keyf=" + encodeURIComponent(cfg_sign_key_format); |
|
| 142 |
+ } |
|
| 126 | 143 |
|
| 127 | 144 |
Pebble.openURL("https://cdn.rawgit.com/faelys/pebble-health-export/v1.0/config.html" + settings);
|
| 128 | 145 |
}); |
| ... | ... |
@@ -152,6 +169,33 @@ Pebble.addEventListener("webviewclosed", function(e) {
|
| 152 | 169 |
localStorage.setItem("cfgBundleSeparator", cfg_bundle_separator);
|
| 153 | 170 |
} |
| 154 | 171 |
|
| 172 |
+ if (configData.signAlgorithm) {
|
|
| 173 |
+ cfg_sign_algo = configData.signAlgorithm; |
|
| 174 |
+ localStorage.setItem("cfgSignAlgorithm", cfg_sign_algo);
|
|
| 175 |
+ } |
|
| 176 |
+ |
|
| 177 |
+ if (configData.signFieldName) {
|
|
| 178 |
+ cfg_sign_field = configData.signFieldName; |
|
| 179 |
+ localStorage.setItem("cfgSignFieldName", cfg_sign_field);
|
|
| 180 |
+ } |
|
| 181 |
+ |
|
| 182 |
+ if (configData.signFieldFormat) {
|
|
| 183 |
+ cfg_sign_field_format = configData.signFieldFormat; |
|
| 184 |
+ localStorage.setItem("cfgSignFieldFormat", cfg_sign_field_format);
|
|
| 185 |
+ } |
|
| 186 |
+ |
|
| 187 |
+ if (configData.signKey) {
|
|
| 188 |
+ cfg_sign_key = configData.signKey; |
|
| 189 |
+ localStorage.setItem("cfgSignKey", cfg_sign_key);
|
|
| 190 |
+ } |
|
| 191 |
+ |
|
| 192 |
+ if (configData.signKeyFormat) {
|
|
| 193 |
+ cfg_sign_key_format = configData.signKeyFormat; |
|
| 194 |
+ localStorage.setItem("cfgSignKeyFormat", cfg_sign_key_format);
|
|
| 195 |
+ } |
|
| 196 |
+ |
|
| 197 |
+ console.log(cfg_sign_field ? "Signature enabled" : "Signature disabled"); |
|
| 198 |
+ |
|
| 155 | 199 |
if (configData.resend) {
|
| 156 | 200 |
senders[0].abort(); |
| 157 | 201 |
senders[1].abort(); |