Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultCredentialManager

Default Credential Manager is our implementation of the Imperative Credential Manager. This manager invokes methods created by the keytar utility (https://www.npmjs.com/package/keytar) to access the secure credential vault on the user's machine.

Keychains Used by Keytar

OS Vault
Windows Credential Vault
macOS Keychain
Linux Secret Sevice API/libsecret

Optional Install of Keytar

It should be noted that keytar is an optional dependency of Imperative. This is because on Linux, it will not work out of the box without some additional configuration to install libsecret. Keytar provides the following documentation for Linux users to install libsecret:


Depending on your distribution, you will need to run the following command:

  • Debian/Ubuntu: sudo apt-get install libsecret-1-dev
  • Red Hat-based: sudo yum install libsecret-devel
  • Arch Linux: sudo pacman -S libsecret

Hierarchy

Index

Constructors

constructor

Properties

Private keytar

keytar: typeof keytar

Reference to the lazily loaded keytar module.

Private loadError

loadError: ImperativeError

Errors that occurred while loading keytar will be stored in here.

Every method of this class should call the checkForKeytar method before proceeding. It is this method that will check for keytar and throw this error if it was detected that keytar wasn't loaded.

Protected Readonly service

service: string

The service that the Credential Manager is running under. Imperative will set this to the cliName

Accessors

name

  • get name(): string

Methods

Private checkForKeytar

  • checkForKeytar(): void
  • This function is called before the {@link deletePassword}, {@link getPassword}, and {@link setPassword} functions. It will check if keytar is not null and will throw an error if it is.

    The error thrown will be the contents of loadError or a new ImperativeError. The former error will be the most common one as we expect failures during the load since keytar is optional. The latter error will indicate that some unknown condition has happened so we will create a new ImperativeError with the report suppressed. The report is suppressed because it may be possible that a detailed report could capture a username and password, which would probably be a bad thing.

    throws

    ImperativeError when keytar is null or undefined.

    Returns void

delete

  • delete(account: string): Promise<void>

Protected deleteCredentials

  • deleteCredentials(account: string): Promise<void>

Private getMissingEntryMessage

  • getMissingEntryMessage(account: string): string

initialize

load

  • load(account: string, optional?: boolean): Promise<string>

Protected loadCredentials

save

  • save(account: string, secureValue: string): Promise<void>

Protected saveCredentials

Generated using TypeDoc