Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async storeLastUserCredentials(credentials: Credentials): Promise {
if (!credentials) {
return;
}
await this.settings.setLastUrl(credentials.serverURL);
await this.settings.setLastUsername(credentials.user);
try {
const keytar = require("keytar");
Logger.logDebug(`CommandHolder#storeLastUserCredentials: keytar is supported. Credentials will be stored.`);
keytar.setPassword("teamcity", "serverurl", credentials.serverURL);
keytar.setPassword("teamcity", "username", credentials.user);
keytar.setPassword("teamcity", "password", credentials.password);
} catch (err) {
Logger.logError(`CommandHolder#storeLastUserCredentials: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
}
}
async saveCredentials(projectId, username, password) {
await keytar.setPassword(TWILIO_CLI_IDENTIFIER, projectId, username + '|' + password);
}
addConnection(connectionData: TDbConnectionData, fromStorage = false) {
const { password, ...publicConnectionData } = connectionData;
const connection = new DbConnection(connectionData);
const rewrite = this.connections[connection.name];
this.connections[connection.name] = connection;
if (!rewrite) {
this.connectionsNames.push(connection.name);
}
if (!fromStorage) {
persistentStorage.set('connections', {
...(persistentStorage.get('connections') || {}),
[connection.name]: publicConnectionData,
});
return keytar.setPassword(connectionData.name, connectionData.user, password);
}
}
setKeychain: (accountName, content) => {
return keytar.setPassword(KEYTAR_SERVICE, accountName, content);
},
ipcMain.on('set-auth-token', (event, token) => {
keytar.setPassword("LBRY", "auth_token", token ? token.toString().trim() : null);
});
private async storeLastUserCreds(creds : Credential) : Promise {
if (!creds) {
return;
}
await this._extManager.settings.setLastUrl(creds.serverURL);
await this._extManager.settings.setLastUsername(creds.user);
try {
const keytar = require("keytar");
Logger.logDebug(`CommandHolder#storeLastUserCreds: keytar is supported. Good job user.`);
keytar.setPassword("teamcity", "serverurl", creds.serverURL);
keytar.setPassword("teamcity", "username", creds.user);
keytar.setPassword("teamcity", "password", creds.pass);
} catch (err) {
Logger.logError(`CommandHolder#storeLastUserCreds: Unfortunately storing a password is not supported. The reason: ${VsCodeUtils.formatErrorMessage(err)}`);
}
}
}
async storeKeyAndSecret (prop, key, secret) {
this.conf.set(`keys.${prop}`, key)
await keytar.setPassword(this.service, key, secret)
}
async clearKeyAndSecret (prop) {
function updateCert(host, port, cert) {
const account = getAccountNameForCert(host, port);
if (cert) {
return keytar.setPassword(SERVICE_NAME, account, cert);
} else {
return keytar.deletePassword(SERVICE_NAME, account);
}
}