Skip to content

keyring

Install the required plugin:

Terminal window
tynd add keyring
import { keyring } from "@tynd/plugin-keyring/client";

Encrypted secret storage backed by the OS credential manager. Use this for anything sensitive — tokens, passwords, session cookies, API keys.

const entry = { service: "com.example.myapp", account: "alice" };
await keyring.set(entry, "s3cr3t-token");
  • service — reverse-DNS recommended. Namespaces your secrets.
  • account — arbitrary string identifying the credential (username, "access_token", etc.).
  • value — the secret as a UTF-8 string.

service and account must be non-empty, contain no NUL character, and are limited to 256 characters. value is limited to 8 KiB of UTF-8 data and cannot contain NUL.

const token = await keyring.get(entry); // string | null

Returns null if no entry matches.

const existed = await keyring.delete(entry); // true if something was deleted
OS Backend
macOS Keychain — encrypted with the user’s login password
Windows Credential Manager + DPAPI
Linux Secret Service API (GNOME Keyring / KWallet / others via D-Bus)

On Linux, a Secret Service provider must be running (virtually every desktop environment has one). Headless VMs may not — get / set throw in that case. Fall back to a file-backed encrypted store or require the user to install gnome-keyring.

keyring store
Encrypted at rest ✓ ✗
Readable by other processes with user access ✗ ✓
Suitable for tokens / passwords ✓ ✗
Suitable for UI preferences ✗ (overkill) ✓
import { keyring } from "@tynd/plugin-keyring/client";
const ENTRY = { service: "com.example.myapp", account: "access_token" };
async function getOrRefreshToken() {
let token = await keyring.get(ENTRY);
if (!token || isExpired(token)) {
token = await refreshOAuth(); // your refresh flow
await keyring.set(ENTRY, token);
}
return token;
}
  • This is a host-backed plugin: credential storage is native code in the Tynd host, compiled in once keyring is listed in plugins.
  • Values are UTF-8 strings — encode binary secrets as base64 on the way in and decode on the way out.
  • macOS prompts the user to grant Keychain access on first call from a newly-signed binary. A signed / notarized build avoids repeat prompts.
  • There’s no “list all entries” API. Track the set of known account strings in store if you need enumeration.