Skip to content

Commit

Permalink
fix: add keytar sanity-check during install (twilio#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
childish-sambino committed Nov 21, 2019
1 parent efe9511 commit b7c2d2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ githooks:
ln -sf ../../githooks/pre-commit .git/hooks/pre-commit

install: githooks
npm install
npm install --no-optional

test:
npm test
Expand Down
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 b7c2d2c

Please sign in to comment.