mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
652748f969
Issue https://github.com/laurent22/joplin/issues/3711 This patch replaces the 'isLinux' check by a more restrictive version which fixes the false positive in BSD systems. This was causing Joplin not to load due to the lack of X11 in headless mode.
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
|
|
const { shim } = require('lib/shim.js');
|
|
|
|
// keytar throws an error when system keychain is not present;
|
|
// even when keytar itself is installed.
|
|
// try/catch to ensure system keychain is present and no error is thrown.
|
|
|
|
// For now, keychain support is disabled on Linux because when keytar is loaded
|
|
// it seems to cause the following error when loading Sharp:
|
|
//
|
|
// Something went wrong installing the "sharp" module
|
|
// /lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/travis/build/laurent22/joplin/CliClient/node_modules/sharp/build/Release/../../vendor/lib/libpng16.so.16)
|
|
//
|
|
// See: https://travis-ci.org/github/laurent22/joplin/jobs/686222036
|
|
//
|
|
// Also disabled in portable mode obviously.
|
|
|
|
let keytar:any;
|
|
try {
|
|
keytar = (shim.isWindows() || shim.isMac()) && !shim.isPortable() ? require('keytar') : null;
|
|
} catch (error) {
|
|
console.error('Cannot load keytar - keychain support will be disabled', error);
|
|
keytar = null;
|
|
}
|
|
|
|
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
|
|
|
|
async setPassword(name:string, password:string):Promise<boolean> {
|
|
if (!keytar) return false;
|
|
await keytar.setPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`, password);
|
|
return true;
|
|
}
|
|
|
|
async password(name:string):Promise<string> {
|
|
if (!keytar) return null;
|
|
return keytar.getPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
|
|
}
|
|
|
|
async deletePassword(name:string):Promise<void> {
|
|
if (!keytar) return;
|
|
await keytar.deletePassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
|
|
}
|
|
|
|
}
|