An open API service indexing awesome lists of open source software.

https://github.com/traeok/keytar-rs

keytar meets Rust
https://github.com/traeok/keytar-rs

Last synced: 2 months ago
JSON representation

keytar meets Rust

Awesome Lists containing this project

README

        

# keytar-rs

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](https://github.com/atom/node-keytar).

![keytar-rs demo](./DEMO.svg)

## Compatibility


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

## Features

keytar-rs supports the following operations within credential storage:

- [x] **Set** a credential
- [x] **Retrieve** a credential
- [x] **Find all credentials** with matching attributes
- [x] **Find a password** with matching attributes

Some benefits to using keytar-rs:

- [x] **Cross-platform support** makes for straight-forward secrets management
- [x] **Existing OS credentials are supported** out-of-the-box
- [x] **Avoids memory allocation** - memory only allocated as needed for OS-specific APIs

## Node API documentation

### deletePassword

Deletes a password with matching `service` and `account` parameters.

**Returns:** Whether the password was deleted successfully.

```ts
function deletePassword(service: string, account: string) -> Promise
```

### findCredentials

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`.

```ts
interface Credential {
account: string;
password: string;
};

function findCredentials(service: string) -> Promise>
```

### findPassword

Finds a password with a matching `service` and `account` parameter.

**Returns:** The first password found in `/`, or `null` if not found.

```ts
function findPassword(service: string, account: string) -> Promise
```

### getPassword

Gets a password with a matching `service` and `account` parameter.

**Returns:** The password stored under `/`, or `null` if not found.

```ts
function getPassword(service: string, account: string) -> Promise
```

### setPassword

Stores a password with the given `service`, `account`, and `password`.

```ts
function setPassword(service: string, account: string, password: string) -> Promise
```