@daryal/eksicli
Version:
Ekşi Sözlük CLI Tool
24 lines (18 loc) • 582 B
JavaScript
const ConfigStore = require('configstore');
const Keytar = require('keytar');
class CredentialManager {
constructor(name) {
this.storeName = name;
this.configStore = new ConfigStore(this.storeName);
}
async saveUser(email, password) {
this.configStore.set('email', email);
await Keytar.setPassword(this.storeName, email, password);
}
async retrieveUser() {
const email = this.configStore.get('email');
const password = await Keytar.getPassword(this.storeName, email);
return [username, password];
}
}
module.exports = CredentialManager;