Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add keytar sanity-check during install #75

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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