keytar-rs is a native Node.js module for accessing and managing OS credential storage. It is a Rust approach to the npm library node-keytar.
| OS / Architecture | Node.js Version | ||||
|---|---|---|---|---|---|
| v12 | v14 | v16 | v18 | ||
| Windows | x64 | ✓ | ✓ | ✓ | ✓ |
| x86 | ✓ | ✓ | ✓ | ✓ | |
| arm64 | ✓ | ✓ | ✓ | ✓ | |
| macOS | x64 | ✓ | ✓ | ✓ | ✓ |
| aarch64 | ✓ | ✓ | ✓ | ✓ | |
| Linux (gnu) | x64 | ✓ | ✓ | ✓ | ✓ |
| aarch64 | ✓ | ✓ | ✓ | ✓ | |
| Linux (musl) | x64 | ✓ | ✓ | ✓ | ✓ |
| aarch64 | ✓ | ✓ | ✓ | ✓ | |
| FreeBSD | x64 | ✓* | ✓* | ✓* | ✓* |
| zLinux | s390x | ✓* | ✓* | ✓* | ✓* |
| *Using node-password-store fallback | |||||
keytar-rs supports the following operations within credential storage:
- Set a credential
- Retrieve a credential
- Find all credentials with matching attributes
- Find a password with matching attributes
Some benefits to using keytar-rs:
- Cross-platform support makes for straight-forward secrets management
- Existing OS credentials are supported out-of-the-box
- Avoids memory allocation - memory only allocated as needed for OS-specific APIs
Deletes a password with matching service and account parameters.
Returns: Whether the password was deleted successfully.
function deletePassword(service: string, account: string) -> Promise<boolean>Finds all credentials with a matching service parameter.
Returns: An array of Credential objects, containing the account and password for each credential that is found within service.
interface Credential {
account: string;
password: string;
};
function findCredentials(service: string) -> Promise<Array<Credential>>Finds a password with a matching service and account parameter.
Returns: The first password found in <service>/<account>, or null if not found.
function findPassword(service: string, account: string) -> Promise<string | null>Gets a password with a matching service and account parameter.
Returns: The password stored under <service>/<account>, or null if not found.
function getPassword(service: string, account: string) -> Promise<string | null>Stores a password with the given service, account, and password.
function setPassword(service: string, account: string, password: string) -> Promise<void>