@zowe/secrets-for-zowe-sdk
v8.1.2
Published
Credential management facilities for Imperative, Zowe CLI, and extenders.
Downloads
14,237
Keywords
Readme
Secrets Package
Contains APIs for secure credential management.
keyring
API Examples
Developers that reference the dependency keytar
directly in their code need to use the new keyring
module from this package.
Use the keyring
module in the same fashion as keytar
.
Storing and loading credentials
const { keyring } = require("@zowe/secrets-for-zowe-sdk");
await keyring.setPassword("ServiceName", "AccountName", "SomePassword");
const password = await keyring.getPassword("ServiceName", "AccountName");
// password should equal "SomePassword"
Finding a credential
const { keyring } = require("@zowe/secrets-for-zowe-sdk");
const password = await keyring.findPassword("ServiceName/AccountName");
// password should equal "SomePassword"
Finding all credentials matching service
const { keyring } = require("@zowe/secrets-for-zowe-sdk");
const matchingCredentials = await keyring.findCredentials("ServiceName");
// returns:
// [
// { account: "AccountName", password: "SomePassword" },
// ...
// ]
Deleting a credential
const { keyring } = require("@zowe/secrets-for-zowe-sdk");
const wasDeleted = await keyring.deletePassword("ServiceName", "AccountName");
// wasDeleted should be true; ServiceName/AccountName removed from credential vault
For more detailed information, see src/keyring/EXTENDERS.md.