Skip to content

Commit

Permalink
fix: add keytar sanity-check during install
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Harrison committed Nov 20, 2019
1 parent efe9511 commit b7b5b70
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/services/secure-storage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { CLI_NAME } = require('./config');
const { TwilioCliError } = require('./error');
const { HELP_ENVIRONMENT_VARIABLES } = require('./messaging/help-messages');
const { logger } = require('./messaging/logging');

const STORAGE_LOCATIONS = {
KEYCHAIN: 'keychain',
Expand All @@ -25,7 +26,11 @@ class SecureStorage {
if (!this.keytar) {
try {
this.keytar = await this.command.install('keytar');

// Also sanity-check that we can retrieve passwords (just use a dummy profile ID).
await this.keytar.getPassword(CLI_NAME, CLI_NAME);
} catch (error) {
logger.debug(`Error loading keytar: ${error}`);
// If we can't load up keytar, tell the user that maybe they should just stick to env vars.
throw new TwilioCliError('Secure credential storage failed to load.\n\n' + HELP_ENVIRONMENT_VARIABLES);
}
Expand Down

0 comments on commit b7b5b70

Please sign in to comment.