2020-11-05 18:58:23 +02:00
|
|
|
import KeychainServiceDriverBase from './KeychainServiceDriverBase';
|
|
|
|
import shim from '../../shim';
|
|
|
|
|
|
|
|
export default class KeychainServiceDriver extends KeychainServiceDriverBase {
|
2024-08-08 20:53:43 +02:00
|
|
|
public override readonly driverId: string = 'node-keytar';
|
|
|
|
|
|
|
|
public async supported(): Promise<boolean> {
|
|
|
|
return !!shim.keytar();
|
|
|
|
}
|
2020-11-05 18:58:23 +02:00
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async setPassword(name: string, password: string): Promise<boolean> {
|
2020-11-05 18:58:23 +02:00
|
|
|
await shim.keytar().setPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`, password);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async password(name: string): Promise<string> {
|
2020-11-05 18:58:23 +02:00
|
|
|
return shim.keytar().getPassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public async deletePassword(name: string): Promise<void> {
|
2020-11-05 18:58:23 +02:00
|
|
|
await shim.keytar().deletePassword(`${this.appId}.${name}`, `${this.clientId}@joplin`);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|