Skip to content

Commit 80aa69f

Browse files
author
Sam Harrison
committed
fix: add keytar sanity-check during install
1 parent efe9511 commit 80aa69f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ githooks:
44
ln -sf ../../githooks/pre-commit .git/hooks/pre-commit
55

66
install: githooks
7-
npm install
7+
npm install --no-optional
88

99
test:
1010
npm test

src/services/secure-storage.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { CLI_NAME } = require('./config');
22
const { TwilioCliError } = require('./error');
33
const { HELP_ENVIRONMENT_VARIABLES } = require('./messaging/help-messages');
4+
const { logger } = require('./messaging/logging');
45

56
const STORAGE_LOCATIONS = {
67
KEYCHAIN: 'keychain',
@@ -25,7 +26,11 @@ class SecureStorage {
2526
if (!this.keytar) {
2627
try {
2728
this.keytar = await this.command.install('keytar');
29+
30+
// Also sanity-check that we can retrieve passwords (just use a dummy profile ID).
31+
await this.keytar.getPassword(CLI_NAME, CLI_NAME);
2832
} catch (error) {
33+
logger.debug(`Error loading keytar: ${error}`);
2934
// If we can't load up keytar, tell the user that maybe they should just stick to env vars.
3035
throw new TwilioCliError('Secure credential storage failed to load.\n\n' + HELP_ENVIRONMENT_VARIABLES);
3136
}

0 commit comments

Comments
 (0)