Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const notification = {
title: 'Keys Done Generating',
body: 'Copy your public key by clicking the icon to the right of your name.',
}
this.props.toggleGeneratingKey()
this.setState({ submitted: true })
await this.props.addKey({ id: 999, name, privateKeyArmored: 'generating' })
const key = await generateKey({ name, email }, passphrase)
key.avatar = 9
key.id = 999
new Notification(notification.title, notification) // eslint-disable-line no-new
keytar.addPassword('felony', `${ name } <${ email }>`, passphrase)
await this.props.addKey(key)
this.props.toggleGeneratingKey()
}
// Previously the master key was binary encoded, which caused compatibility
// issues with various keyrings. In 0.8.3, switch to hex encoding for storage.
const oldAccountName = 'login master key'
const accountName = 'login master key v2'
let oldMasterKey = keytar.getPassword(appName, oldAccountName)
let masterKey = keytar.getPassword(appName, accountName)
let success = false
if (masterKey === null) {
if (typeof oldMasterKey === 'string') {
// The user made a v1 (binary) key. Try converting it to hex if it
// appears to be 32 bytes.
let oldBuffer = new Buffer(oldMasterKey, 'binary')
if (oldBuffer.length === 32) {
success = keytar.addPassword(appName, accountName, oldBuffer.toString('hex'))
}
}
// Either the user denied access or no master key has ever been created.
// We can't tell the difference so try making a new master key.
success = success || keytar.addPassword(appName, accountName, CryptoUtil.getRandomBytes(32).toString('hex'))
if (success) {
// A key should have been created
masterKey = keytar.getPassword(appName, accountName)
}
}
if (typeof masterKey === 'string') {
// Convert from hex to binary
return (new Buffer(masterKey, 'hex')).toString('binary')
let success = false
if (masterKey === null) {
if (typeof oldMasterKey === 'string') {
// The user made a v1 (binary) key. Try converting it to hex if it
// appears to be 32 bytes.
let oldBuffer = new Buffer(oldMasterKey, 'binary')
if (oldBuffer.length === 32) {
success = keytar.addPassword(appName, accountName, oldBuffer.toString('hex'))
}
}
// Either the user denied access or no master key has ever been created.
// We can't tell the difference so try making a new master key.
success = success || keytar.addPassword(appName, accountName, CryptoUtil.getRandomBytes(32).toString('hex'))
if (success) {
// A key should have been created
masterKey = keytar.getPassword(appName, accountName)
}
}
if (typeof masterKey === 'string') {
// Convert from hex to binary
return (new Buffer(masterKey, 'hex')).toString('binary')
} else {
throttleKeytar = true
setTimeout(() => {
throttleKeytar = false
}, 1000 * 60 * 60 * 24)
return null
getToken(answers.registry, answers.username, answers.email, answers.password || password, function (err, token) {
if (err) {
console.error(err)
process.exit(1)
}
console.log(token)
if (keytar && !password && answers.password) keytar.addPassword('npm-get-token', answers.username, answers.password)
conf.set('username', answers.username, 'user')
conf.set('email', answers.email, 'user')
conf.save('user')
})
})
}], function(answers) {
keytar.addPassword('jira-terminal', answers.username, answers.password);
delete answers.password;
_.assign(config, answers);
console.log('Writing the configuration file to ' + configPath);
fs.mkdirSync(basePath);
fs.writeFileSync(configPath, JSON.stringify(config), 'utf8');
console.log('Starting the app.');
cb();
});
};
}).then(function(password) {
if (keytar.addPassword('wiki.edg.com', username, password)) {
return password;
} else {
throw new Error('Could not add password for ' + username + '@wiki.edg.com');
}
});
} else {
return (options) => {
const service = options.url.hostname;
let password = keytar.getPassword(service, username);
if (!password) {
password = prompt(`Enter ${chalk.bold(username)}'s password for ${chalk.bold(service)}: `, { secure: true });
keytar.addPassword(service, username, password);
}
return { username, password };
}
},
static setToken(token) {
if (this.isAuthenticated()) {
this.deleteToken()
}
keytar.addPassword(SERVICE, ACCOUNT, token)
if (isTest) {
storage.set(KEY, token)
}
}