No description
  • C++ 70.9%
  • JavaScript 17.7%
  • Python 4.1%
  • Dockerfile 3.9%
  • PowerShell 2.9%
  • Other 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-02-12 18:08:42 +01:00
.github Run codeql on push 2026-02-12 16:42:38 +01:00
docker upgrade keytar toolchain to modern Node versions, add support for packaging on arm (#1) 2025-02-04 12:28:23 -04:00
lib Fix prebuild path 2025-10-14 16:57:05 -04:00
script fix: update prebuilds directory path formatting 2025-09-06 01:48:39 -04:00
spec add support for building and testing with GitHub Actions (#323) 2020-11-08 22:09:15 -04:00
src Update src/keytar_win.cc 2021-11-09 08:44:28 -08:00
.babelrc oops 2017-04-12 17:30:22 -07:00
.gitignore pin local version to Node 14 to avoid upgrading lockfile just yet (#357) 2021-02-15 14:25:51 -04:00
.node-version upgrade keytar toolchain to modern Node versions, add support for packaging on arm (#1) 2025-02-04 12:28:23 -04:00
.npmignore Ignore .tags files and CI configuration in npm 2017-05-16 08:49:28 -04:00
binding.gyp Add cf and qspectre flags 2022-03-01 16:05:24 -08:00
CODE_OF_CONDUCT.md Add useful files 2026-02-06 20:28:25 +01:00
CONTRIBUTING.md Add support 2026-02-09 15:04:52 +01:00
keytar.d.ts bracket type 2018-05-04 05:37:06 -07:00
LICENSE.md Update LICENSE.md to MIT License format 2026-02-06 14:10:46 -05:00
package-lock.json Merge pull request #7 from github/dependabot/npm_and_yarn/node-gyp-12.2.0 2026-02-12 18:08:42 +01:00
package.json Bump node-gyp from 11.0.0 to 12.2.0 2026-02-12 16:59:46 +00:00
README.md Update README.md 2026-02-06 14:15:21 -05:00
SECURITY.md Add useful files 2026-02-06 20:28:25 +01:00
SUPPORT.md Add support 2026-02-09 15:04:52 +01:00

keytar - Node module to manage system keychain

A native Node module to get, add, replace, and delete passwords in system's keychain. On macOS the passwords are managed by the Keychain, on Linux they are managed by the Secret Service API/libsecret, and on Windows they are managed by Credential Vault.

Installing

npm install keytar

On Linux

Currently this library uses libsecret so you may need to install it before running npm install.

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

Building

  • Clone the repository
  • Run npm install
  • Run npm test to run the tests

Supported versions

Each release of keytar includes prebuilt binaries for the versions of Node and Electron that are actively supported by these projects. Please refer to the release documentation for Node and Electron to see what is supported currently.

Bindings from other languages

Docs

const keytar = require('keytar')

Every function in keytar is asynchronous and returns a promise. The promise will be rejected with any error that occurs or will be resolved with the function's "yields" value.

getPassword(service, account)

Get the stored password for the service and account.

service - The string service name.

account - The string account name.

Yields the string password or null if an entry for the given service and account was not found.

setPassword(service, account, password)

Save the password for the service and account to the keychain. Adds a new entry if necessary, or updates an existing entry if one exists.

service - The string service name.

account - The string account name.

password - The string password.

Yields nothing.

deletePassword(service, account)

Delete the stored password for the service and account.

service - The string service name.

account - The string account name.

Yields true if a password was deleted, or false if an entry with the given service and account was not found.

findCredentials(service)

Find all accounts and password for the service in the keychain.

service - The string service name.

Yields an array of { account: 'foo', password: 'bar' }.

findPassword(service)

Find a password for the service in the keychain. This is ideal for scenarios where an account is not required.

service - The string service name.

Yields the string password, or null if an entry for the given service was not found.

License

This project is licensed under the terms of the MIT open source license. Please refer to the LICENSE.md file for the full terms.