1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/lib/services/keychain/KeychainServiceDriver.node.ts

23 lines
780 B
TypeScript
Raw Normal View History

2020-11-05 18:58:23 +02:00
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
import shim from '../../shim';
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
public async setPassword(name: string, password: string): Promise<boolean> {
2020-11-05 18:58:23 +02:00
if (!shim.keytar()) return false;
await shim.keytar().setPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`, password);
return true;
}
public async password(name: string): Promise<string> {
2020-11-05 18:58:23 +02:00
if (!shim.keytar()) return null;
return shim.keytar().getPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
}
public async deletePassword(name: string): Promise<void> {
2020-11-05 18:58:23 +02:00
if (!shim.keytar()) return;
await shim.keytar().deletePassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
}
}