Skip to content

Commit

Permalink
move helper to separate rep; get version from native app
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen committed Mar 12, 2024
1 parent 2d3dacc commit feb080f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 320 deletions.
18 changes: 16 additions & 2 deletions extension/background.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
/**
* Copyright (c) 2024, Tidepool Project
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the associated License, which is identical to the BSD 2-Clause
* License as published by the Open Source Initiative at opensource.org.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the License for more details.
*
* You should have received a copy of the License along with this program; if
* not, you can obtain one from Tidepool Project at tidepool.org.
*/

let reply;
let port;

/* global chrome */

function connect() {
const hostName = 'org.tidepool.uploader';
const hostName = 'org.tidepool.uploader-helper';
console.log('Connecting to native messaging host', hostName);
port = chrome.runtime.connectNative(hostName);
port.onMessage.addListener(onNativeMessage);
Expand Down Expand Up @@ -44,7 +58,7 @@ chrome.runtime.onMessageExternal.addListener(
sendNativeMessage(request);

reply = sendResponse;
return true; // indicates you will asynchronously use sendResponse
return true; // indicates we will asynchronously use sendResponse
} else {
sendResponse({ msgType: 'error', details: 'Not connected.'});
}
Expand Down
13 changes: 8 additions & 5 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"manifest_version": 3,
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcBHwzDvyBQ6bDppkIs9MP4ksKqCMyXQ/A52JivHZKh4YO/9vJsT3oaYhSpDCE9RPocOEQvwsHsFReW2nUEc6OLLyoCFFxIb7KkLGsmfakkut/fFdNJYh0xOTbSN8YvLWcqph09XAY2Y/f0AL7vfO1cuCqtkMt8hFrBGWxDdf9CQIDAQAB",
"name": "Native Messaging Example",
"name": "Tidepool Uploader Helper",
"version": "1.0",
"description": "Send a message to a native application.",
"description": "This extension supports additional upload mechanisms for specific blood glucose meters, expanding support for compatible devices.",
"icons": {
"128": "icon-128.png"
},
Expand All @@ -14,6 +13,10 @@
"service_worker": "background.js"
},
"externally_connectable": {
"matches": ["http://localhost:3005/*"]
}
"matches": [
"http://localhost:3005/*",
"https://*.tidepool.org/*"
]
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAos4V4S/7tWoEGVppnpQaDsl0DjibWk12sSUfr3chmbDcPfQPw+1iZNZ16oMazdfyj/UBQA5hYlCycSSGExvl8N1JM0/sJ5DEs1hy5cmyR6MuAdXOuu0X1NzRS8rdi67msWXVJUO51AUIByHy5BArjw3AzaE4kxAWRexUvMjb8wC7/k5hmU7pimL/t7sa0O6ghmzJFvqu7nzK6x5+bGeHRfXg0OLqtAc3eLByRZbT0HOfgPEFsBq5LrbS3/MvzjNorWon0BcLYV7JayFkmpV/p3nQp+7SwiHKadsexlwreOly+Gk6tppkieiYsznI4kqQOpVrPrI+iMe+LCfw4NzhVQIDAQAB"
}
3 changes: 0 additions & 3 deletions extension/verio-helper/helper.reg

This file was deleted.

296 changes: 0 additions & 296 deletions extension/verio-helper/helper.zig

This file was deleted.

9 changes: 0 additions & 9 deletions extension/verio-helper/manifest.json

This file was deleted.

10 changes: 5 additions & 5 deletions lib/drivers/onetouch/oneTouchVerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,13 @@ class BlockDevice {

class NativeMessaging {
constructor() {
this.extensionId = 'knldjmfmopnpolahpmmgbagdohdnhkik'; // TODO: replace for prod
this.extensionId = 'nejgoemnddedidafdoppamlbijokiahb';
}

openDevice(deviceInfo, callback) {
try {
chrome.runtime.sendMessage(this.extensionId, { command: 'getAppVersion' }, (version) => {
debug('App version:', version?.details);

chrome.runtime.sendMessage(this.extensionId, { command: 'openDevice' }, (response) => {
debug('Response from extension:', response);
if (response.msgType === 'error') {
Expand All @@ -435,9 +437,7 @@ class NativeMessaging {
callback(null);
}
});
} catch (err) {
callback(err);
}
});
}

closeDevice(callback) {
Expand Down

0 comments on commit feb080f

Please sign in to comment.