Skip to content

Commit

Permalink
Feat/major package updates (#210)
Browse files Browse the repository at this point in the history
* update all npm packages
* Keys tab layout tweak
* Additional checkForNewFw log
* fix bug in external-links.js
* bump manifest version to 5.5.0
* win-specific npm scrips
* chmod nwjs runtime files to 755
* fix Linux autolaunch
* bump release manifest info

---------

Co-authored-by: Rodney G <rodgolpe@gmail.com>
  • Loading branch information
rodgolpe and rodgolpe authored Mar 14, 2023
1 parent 5e2db8a commit 5401c29
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 41 deletions.
6 changes: 3 additions & 3 deletions app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ <h2>
</p>
<hr />
<div class="flex-container">
<div class="flex-item">
<div class="flex-item" style="max-width: 40%">
<p>
Need an OpenPGP key? Follow our guide
<a
Expand All @@ -831,15 +831,15 @@ <h2>
for generating an OpenPGP key with Keybase.
</p>
<p>
Before loading a key, <span class="strong">you must first put your OnlyKey into config mode</span>.
Before loading a key, <span class="critical-text">you must first put your OnlyKey into config mode</span>.
<br/><br/>
To do this
<span class="device-specific ok-classic">hold down button #6 on your OnlyKey for 5+ seconds and release.</span>
<span class="device-specific ok-duo">hold down button #1 on your OnlyKey DUO for 10+ seconds and release.</span>
The light will turn off.
<span class="device-specific ok-duo">If a PIN was previously set, re-enter the PIN to enter config mode.</span>
You will notice the OnlyKey flashes red in config mode.
</p>
</p>
</div>
<div class="flex-item">
<form id="rsaForm" name="rsaForm" class="auth-form">
Expand Down
11 changes: 7 additions & 4 deletions app/scripts/external-links.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const openMethod = typeof nw === 'undefined' ? window.open : nw.Shell.openExternal;

// Formerly checked for 'external' in classList. Now fires for all https:// links.
document.querySelector('#main').addEventListener('click', evt => {
const parent = (evt.path && evt.path[1]) || {};
const href = evt.target && evt.target.href ? evt.target.href : parent.href;
let href = evt.target && evt.target.href;
if (!href) href = evt.target && evt.target.offsetParent && evt.target.offsetParent.href;
if (!href) href = evt.path && evt.path[1] && evt.path[1].href;

if ((evt.target !== evt.currentTarget) && (!!href && (evt.target.classList.contains('external') || parent.classList.contains('external')))) {
const openMethod = typeof nw === 'undefined' ? window.open : nw.Shell.openExternal;
if (!!href && href.indexOf('https://') == 0) {
openMethod(href);
evt.preventDefault && evt.preventDefault();
evt.stopPropgation && evt.stopPropagation();
Expand Down
1 change: 1 addition & 0 deletions app/scripts/non-renderer-app-path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const devApp = 'nwjs Helper.app';
const prodApp = 'OnlyKey App.app';
// path should use "nwjs Helper", not "nwjs Helper (Renderer)"
console.log({ location: 'non-renderer-app-path.js', process_execPath: process.execPath })
const tempPath = process.execPath.replace(/ \(Renderer\)/g, '');
let appPath;
if (tempPath.includes(prodApp)) {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/onlyKey/OnlyKeyComm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2184,12 +2184,12 @@ function checkForNewFW(checkForNewFW, fwUpdateSupport, version) {
fwchecked = true;
if (checkForNewFW == true && fwUpdateSupport == true) {
//fw checking enabled and firmware version supports app updates
var r = request.get(
console.info("Checking for new firmware");
request.get(
"https://github.com/trustcrypto/OnlyKey-Firmware/releases/latest",
function (err, res, body) {
if (err) return reject(err);

console.log(r.uri.href);
console.log(this.uri.href);
//var testupgradeurl = 'https://github.com/trustcrypto/OnlyKey-Firmware/releases/tag/v2.1.0-prod'
//var latestver = testupgradeurl.split("/tag/v"); //end of redirected URL is the version
Expand Down
29 changes: 23 additions & 6 deletions app/scripts/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,32 @@
const userPreferences = require('./scripts/userPreferences.js');
const settingsMenu = new nw.Menu();

const appPath = require('./scripts/non-renderer-app-path');
const appName = appPath.includes('nwjs Helper') ? 'OnlyKey-dev' : 'OnlyKey';
const os = require('os');
const osx = os.platform() === 'darwin';
const linux = os.platform() === 'linux';

const appPath = osx ? require('./scripts/non-renderer-app-path') : process.execPath;
const appName = appPath.includes('node_modules') ? 'OnlyKey-dev' : 'OnlyKey';

const logParams = {
location: 'tray.js',
appPath,
appName,
os_platform: os.platform(),
}

console.info(logParams);

const AutoLaunch = require("auto-launch");

// LINUX: adds "~/.config/autostart/nw.desktop" file when autoLaunch is enabled
const autoLaunchOptions = {
name: appName,
isHidden: true
name: appName, // the AutoLaunch class overwrites this required prop! (see the "fixOpts" method)
isHidden: !(osx || linux), // this flag breaks the autoLaunch feature in Mac & Linux
};

if (osx) {
autoLaunchOptions.path = appPath;
autoLaunchOptions.isHidden = false;
}

const autoLaunch = new AutoLaunch(autoLaunchOptions);
Expand Down Expand Up @@ -84,7 +95,13 @@
settingsMenu.append(autoLaunchMenuItem);
settingsMenu.append(autoUpdateMenuItem);
settingsMenu.append(autoUpdateFWMenuItem);
tray.menu = settingsMenu;

// using setTimeout to counteract anomalies including empty tray menu
setTimeout(() => {
tray.menu = settingsMenu;
console.info({ ...logParams, tray });
}, 500);


// discovered on linux that the menu item checked state does not live update
function refreshMenuItem(menuItem, index) {
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "OnlyKey Configuration",
"manifest_version": 2,
"version": "5.3.6",
"version_name": "5.3.6",
"version": "5.5.0",
"version_name": "5.5.0",
"minimum_chrome_version": "45.0.2439.3",
"app": {
"background": {
Expand Down
38 changes: 21 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
{
"name": "OnlyKey",
"productName": "OnlyKey App",
"version": "5.3.6",
"version_name": "5.3.6",
"version": "5.5.0",
"version_name": "5.5.0",
"description": "Setup and configure OnlyKey",
"main": "app.js",
"scripts": {
"build": "./node_modules/.bin/gulp build",
"build_win": ".\\node_modules\\.bin\\gulp build",
"prerelease": "rm -rf ./node_modules/* && npm install --production && rm -rf ./release_node_modules && mkdir release_node_modules && cd release_node_modules && mkdir node_modules && cd .. && cp -R ./node_modules/* ./release_node_modules/node_modules && npm install && npm run build -- --env=production",
"prerelease_win": "rm -rf ./node_modules/* && npm install --production && rm -rf ./release_node_modules && mkdir release_node_modules && cd release_node_modules && mkdir node_modules && cd .. && cp -R ./node_modules/* ./release_node_modules/node_modules && npm install && npm run build_win -- --env=production",
"release": "./node_modules/.bin/gulp release --env=production",
"release_win": ".\\node_modules\\.bin\\gulp release --env=production",
"start": "node ./tasks/start",
"pretest": "npm run-script build",
"test": "mocha",
"testgulp": ".\\node_modules\\.bin\\gulp -v",
"prechrome": "./node_modules/.bin/gulp build --env=chrome",
"chrome": "echo 'Please run something like:'; echo \"chrome --load-and-launch-app=$(pwd)/build\""
},
"dependencies": {
"auto-launch": "^5.0.5",
"js-sha256": "^0.9.0",
"nw": "^0.55.0",
"nw-autoupdater": "^1.1.8",
"request": "^2.88.0",
"sshpk": "^1.16.1"
"nw": "^0.71.1",
"nw-autoupdater": "^1.1.11",
"request": "^2.88.2",
"sshpk": "^1.17.0"
},
"devDependencies": {
"chai": "^4.2.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"eslint": "^6.4.0",
"fs-jetpack": "^4.1.0",
"eslint": "^8.33.0",
"fs-jetpack": "^5.1.0",
"gulp": "^4.0.2",
"gulp-sourcemaps": "^2.6.4",
"json": "^10.0.0",
"mocha": "^8.2.0",
"gulp-sourcemaps": "^3.0.0",
"json": "^11.0.0",
"mocha": "^10.2.0",
"nw-dev": "^3.0.1",
"q": "^1.5.1",
"selenium-webdriver": "^3.6.0",
"tree-kill": "^1.2.1",
"yargs": "^16.1.0"
"selenium-webdriver": "^4.8.0",
"tree-kill": "^1.2.2",
"yargs": "^17.6.2"
},
"optionalDependencies": {
"appdmg": "^0.6.0"
"appdmg": "^0.6.4"
},
"repository": {
"type": "git",
Expand All @@ -57,7 +61,7 @@
"author": "CryptoTrust <admin@crp.to>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/trustcrypto/OnlyKey-App/issues"
"url": "https://onlykey.discourse.group/"
},
"homepage": "https://github.com/trustcrypto/OnlyKey-App#readme",
"window": {
Expand Down
14 changes: 7 additions & 7 deletions releases/manifest.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "OnlyKey",
"productName": "OnlyKey App",
"version": "5.2.0",
"version": "5.5.0",
"packages": {
"linux64": {
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.2.0_amd64.deb",
"size": 64000000
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.5.0_amd64.deb",
"size": 105000000
},
"win64": {
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.2.0.exe",
"size": 67000000
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.5.0.exe",
"size": 95000000
},
"mac64": {
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.2.0.dmg",
"size": 105000000
"url": "https://s3.amazonaws.com/onlykey/apps/desktop/releases/latest/OnlyKey_5.5.0.dmg",
"size": 134000000
}
},
"description": "OnlyKey Configuration App"
Expand Down
21 changes: 21 additions & 0 deletions tasks/release_linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var init = function (params={}) {
};

var copyRuntime = function () {
// this pulls all files and directories from node_modules/nw/nwjs
// and copies them into /opt/OnlyKey
return projectDir.copyAsync(`${node_modules_dir}/nw/nwjs`, readyAppDir.path(), { overwrite: true });
};

Expand Down Expand Up @@ -57,6 +59,24 @@ var prepareOsSpecificThings = function () {
return Q();
};

var updateRuntimeFileMode = function () {
var deferred = Q.defer();

console.log('chmodding nwjs runtime...');

childProcess.exec('chmod -R 755 ' + readyAppDir.path(),
function (error, stdout, stderr) {
if (error || stderr) {
console.log("ERROR while chmodding nwjs runtime:");
console.log(error);
console.log(stderr);
}
deferred.resolve();
});

return deferred.promise;
};

var packToDebFile = function () {
var deferred = Q.defer();

Expand Down Expand Up @@ -102,6 +122,7 @@ var cleanClutter = function () {
module.exports = function (params) {
return init(params)
.then(copyRuntime)
.then(updateRuntimeFileMode)
.then(copyBuiltApp)
.then(prepareOsSpecificThings)
.then(packToDebFile)
Expand Down

0 comments on commit 5401c29

Please sign in to comment.