Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadAuthTokens: function(successCallback) {
keytar.findCredentials("Tomatoad_Slack").then(creds => {
_authTokens = {}
let remaining = creds.length
if(creds.length === 0) {
successCallback()
}
creds.forEach(cred => {
// Note that I'm re-looking up the password using getPassword rather than just
// using the cred.password field because of this bug ...
// https://github.com/atom/node-keytar/issues/96
// Once released, I can remove the getPassword call and just use cred.password.
keytar.getPassword("Tomatoad_Slack", cred.account).then(pw => {
_authTokens[cred.account] = pw;
public static set(username: string, password: string): Promise {
return keytar.findCredentials(SERVICE_NAME).then((credentials) => {
return Promise.all(credentials.map((credential) => {
keytar.deletePassword(SERVICE_NAME, credential.account);
})).then(() => {
return keytar.setPassword(SERVICE_NAME, username, password);
});
}).catch(() => {
return keytar.setPassword(SERVICE_NAME, username, password);
});
}
function clearCredentials() {
return keytar.findCredentials(KEYTAR_SERVICE_NAME).then(credentials => {
credentials.map(credential => {
keytar.deletePassword(KEYTAR_SERVICE_NAME, credential.account)
})
})
}
async getCredentials () {
try {
const credentials = await keychain.findCredentials(keychainService)
if (!credentials || !credentials.length)
throw 'No credentials yet'
log.info('Set credentials')
this.authKey = credentials[0].password
this.baseUrl = credentials[0].account
this.credentials = credentials[0]
return credentials[0]
} catch (error) {
return error
}
}
public static get(): Promise {
return keytar.findCredentials(SERVICE_NAME).then((credentials) => {
if (credentials.length > 0) {
return credentials[0];
}
return null;
});
}
listKeychain: () => {
return keytar.findCredentials(KEYTAR_SERVICE);
},
function clearCache() {
return keytar.findCredentials(app).then(creds => {
let reqs = [];
creds.forEach((c) => {
reqs.push(keytar.deletePassword(app, c.account));
});
return Promise.all(reqs);
}).catch(err => {
window.webContents.send('Secure-ClearCacheFailed', { error: 'GENERIC', detail: err });
});
}
async getCredentials() {
return keytar.findCredentials(APP_NAME);
},
async removeCredential(exchange) {