How to use the keytar.replacePassword function in keytar

To help you get started, we’ve selected a few keytar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nylas-mail-lives / nylas-mail / src / browser / nylas-pro-migrator.es6 View on Github external
_migrateKeychain() {
    console.log("---> Migrating keychain from Nylas Mail Basic")
    try {
      const raw = keytar.getPassword("Nylas Mail", "Nylas Mail Keys") || "{}";
      const passwords = JSON.parse(raw);
      const token = passwords["Nylas Account"]
      if (token) {
        keytar.replacePassword("Nylas", "Nylas Account", token)
      }
    } catch (err) {
      console.error(err);
      // dont' throw
    }
  }
github nylas-mail-lives / nylas-mail / packages / client-app / src / key-manager.es6 View on Github external
_writeKeyHash(keys) {
    // returns true if successful
    return keytar.replacePassword(this.SERVICE_NAME, this.KEY_NAME, JSON.stringify(keys));
  }
github wix / quick-2fa / src / index.js View on Github external
'use strict';

const speakeasy = require('speakeasy');
const notifier = require('node-notifier');
const keytar = require('keytar');
const ncp = require('copy-paste');

if (!process.argv[2]) {
  console.error('Usage: quick-2fa --save KEY-NAME YOUR-KEY');
  console.error('Usage: quick-2fa KEY-NAME');
  process.exit(1);
}

if (process.argv[2] === '--save') {
  const [, , , account, password] = process.argv;
  const done = keytar.replacePassword('quick-2fa', account, password);
  if (done) {
    console.log('Key stored!', 'Now you can retrieve your two-factor authentication token by running:');
    console.log(`$ quick-2fa ${account}`);
    process.exit(0);
  } else {
    console.error('Failed to store your key!');
    process.exit(1);
  }
}

const key = process.argv[2] === '--key' ? process.argv[3] : keytar.getPassword('quick-2fa', process.argv[2]);
if (!key) {
  console.error('Sorry, could not find your key...');
  process.exit(1);
}
github parro-it / tunnels / src / middlewares / save-password-keychain.js View on Github external
export default () => next => action => {
	if (action.type === 'SAVE_TUNNEL') {
		if (action.tunnel.password && action.tunnel.password[0] !== '\0') {
			const password = action.tunnel.password;
			action.tunnel.password = '\0encrypted';
			const saved = keytar.replacePassword('tunnels2', action.tunnel.id, password);
			if (!saved) {
				console.error('Cannot save password to keytar.');
			}
		}
	}

	return next(action);
};
github atom / github / lib / github / auth / github-auth.js View on Github external
setToken (token) {
    const tokenResult = keytar.replacePassword(KEYCHAIN_SERVICE_NAME, KEYCHAIN_ACCOUNT, token)
    this.emitter.emit('did-set-token')
    return tokenResult
  }
github nylas-mail-lives / nylas-mail / src / key-manager.es6 View on Github external
this._try(() => {
      const keys = this._getKeyHash();
      delete keys[keyName];
      return keytar.replacePassword(this.SERVICE_NAME, this.KEY_NAME, JSON.stringify(keys))
    })
  }
github jaebradley / uber-cli / src / services / tokenStore.js View on Github external
const setGoogleMapsAPIToken = token => replacePassword('uber-cli', 'Google Maps API Token', token);
github jaebradley / uber-cli / src / services / tokenStore.js View on Github external
const setUberAPIToken = token => replacePassword('uber-cli', 'Uber API Token', token);

keytar

Bindings to native Mac/Linux/Windows password APIs

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis