# keychain

> Basic access to the Mac OS X Keychain

Latest version **1.5.0** (published 2023-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install keychain
pnpm add keychain
yarn add keychain
bun add keychain
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2023-06-07 |
| First published | 2012-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/keychain) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 146 |
| Author | Nicholas Penree |
| Maintainers | drudge |
| Keywords | osx, keychain, password, mac |

## Links

- npm: https://www.npmjs.com/package/keychain
- Repository: https://github.com/drudge/node-keychain
- Homepage: https://github.com/drudge/node-keychain#readme
- Issues: https://github.com/drudge/node-keychain/issues
- npm.io page: https://npm.io/package/keychain

## Recent versions

- 1.5.0 (latest) — 2023-06-07
- 1.4.0 — 2023-03-01
- 1.3.0 — 2017-02-21
- 1.2.0 — 2016-12-28
- 1.1.0 — 2016-12-27
- 1.0.0 — 2015-11-11
- 0.0.4 — 2013-03-25
- 0.0.3 — 2012-12-14
- 0.0.2 — 2012-08-09
- 0.0.1 — 2012-08-09

## README

#  Basic Keychain Access on Mac computers running Node.js
[![Build Status](https://img.shields.io/github/actions/workflow/status/drudge/node-keychain/test.yaml?branch=master)](https://github.com/drudge/node-keychain/actions/workflows/test.yaml)

  This module adds methods for basic Keychain access in Node.js by way of the `security` command-line tool.

## Requirements

 * Mac OS X 10.6+

## Installation

    npm install keychain

## Examples

### Generic Password Example

```javascript
var keychain = require('keychain');

keychain.setPassword({ account: 'foo', service: 'FooBar', password: 'baz' }, function(err) {
  keychain.getPassword({ account: 'foo', service: 'FooBar' }, function(err, pass) {
    console.log('Password is', pass);
    // Prints: Password is baz
  });
});
```

### Internet Password Example
```javascript
var keychain = require('keychain');

keychain.setPassword({ account: 'foo', service: 'FooBar.com', type: 'internet', password: 'baz' }, function(err) {
  keychain.getPassword({ account: 'foo', service: 'FooBar.com', type: 'internet' }, function(err, pass) {
    console.log('Password is', pass);
    // Prints: Password is baz
  });
});
```

## Usage

The available 
```js
keychain.setPassword(options[, callback]);
keychain.getPassword(options, callback);
keychain.deletePassword(options[, callback]);
keychain.createKeychain(options[, callback]);
keychain.deleteKeychain(options[, callback]);
keychain.setDefaultKeychain(options[, callback]);
```

### Options

Available params you can pass to the options object:

| Param | Description |
| ----- | ----------- |
| `account` | Specify account name (required) |
| `service` | Specify service name (required) |
| `password` | Specify password to be added (required for `setPassword`) |
| `type` | The type of password to get or save. Supported values are `generic` and `internet`. See [docs](https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/security.1.html). Default: `generic` |
| `keychainName` | Specify the name of the keychain (required for 'createKeychain' and 'deleteKeychain') |

## Contributors

The following are the major contributors of `node-keychain` (in no specific order).

  * Nicholas Penree ([drudge](https://github.com/drudge))
  * Tejesh Mehta ([tjmehta](https://github.com/tjmehta))
  * Benjamin Hutchins ([benhutchins](https://github.com/benhutchins))
  * Manuel de la Pena ([mandel-macaque](https://github.com/mandel-macaque))

## License

(The MIT License)

Copyright (c) 2013-2023 Nicholas Penree &lt;nick@penree.com&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/keychain · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
