Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Enable App Lock feature for Linux arm64 (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 committed Feb 16, 2021
1 parent 82de1d4 commit 3fd40e2
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions main-src/libs/app-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,13 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/* eslint-disable global-require */
const { ipcMain, systemPreferences } = require('electron');
// do not call require('keytar') here
// it would prevent the app from starting on Linux arm64
// details: https://github.com/atom/node-keytar/issues/318

const sendToAllWindows = require('./send-to-all-windows');
const { createMenu } = require('./menu');

const appJson = require('../constants/app-json');

const getAppLockStatusAsync = async () => {
// keytar is incompatible with Linux arm64
// details: https://github.com/atom/node-keytar/issues/318
if (process.platform === 'linux' && process.arch === 'arm64') {
return {
supported: false,
useTouchId: false,
hasPassword: false,
};
}

try {
const currentPassword = await require('keytar').getPassword(appJson.id, 'app-lock-password');
const useTouchId = process.platform === 'darwin' && systemPreferences.canPromptTouchID()
Expand All @@ -46,24 +33,12 @@ const getAppLockStatusAsync = async () => {
};

const validateAppLockPasswordAsync = async (inputPassword) => {
// keytar is incompatible with Linux arm64
// details: https://github.com/atom/node-keytar/issues/318
if (process.platform === 'linux' && process.arch === 'arm64') {
return false;
}

const currentPassword = await require('keytar').getPassword(appJson.id, 'app-lock-password');
if (currentPassword && inputPassword !== currentPassword) return false;
return true;
};

const deleteAppLockPasswordAsync = async (inputPassword) => {
// keytar is incompatible with Linux arm64
// details: https://github.com/atom/node-keytar/issues/318
if (process.platform === 'linux' && process.arch === 'arm64') {
return Promise.resolve();
}

const validPassword = await validateAppLockPasswordAsync(inputPassword);
if (!validPassword) return null;
return require('keytar').deletePassword(appJson.id, 'app-lock-password')
Expand All @@ -75,12 +50,6 @@ const deleteAppLockPasswordAsync = async (inputPassword) => {
};

const setAppLockPasswordAsync = async (inputPassword, newPassword) => {
// keytar is incompatible with Linux arm64
// details: https://github.com/atom/node-keytar/issues/318
if (process.platform === 'linux' && process.arch === 'arm64') {
return Promise.resolve();
}

const validPassword = await validateAppLockPasswordAsync(inputPassword);
if (!validPassword) return null;
return require('keytar').setPassword(appJson.id, 'app-lock-password', newPassword)
Expand All @@ -92,12 +61,6 @@ const setAppLockPasswordAsync = async (inputPassword, newPassword) => {
};

const setAppLockTouchIdAsync = async (inputPassword, useTouchId) => {
// keytar is incompatible with Linux arm64
// details: https://github.com/atom/node-keytar/issues/318
if (process.platform === 'linux' && process.arch === 'arm64') {
return Promise.resolve();
}

const validPassword = await validateAppLockPasswordAsync(inputPassword);
if (!validPassword) return null;
if (useTouchId) {
Expand Down

0 comments on commit 3fd40e2

Please sign in to comment.