KeychainNode

KeychainNode

macOS Keychain utilities for Node.js

Constructor

new KeychainNode(service, account)

Description:
  • Create an empty Keychain implementation
Source:
Since:
  • 0.1.0
See:
Example
// Import this class as `Keychain`.
// If you use Node.js, `KeychainNode` will be automatically selected.
import { Keychain } from '@pinemz/safe-storage'
Parameters:
Name Type Description
service string Service name
account string Account name

Methods

(async) getOrCreatePassword() → {Promise.<string>}

Description:
  • Get password from Keychain, if none is saved generate new one and save
Source:
Since:
  • 0.1.0
Example
import { Keychain } from '@pinemz/safe-storage'

const keychain = new Keychain('myService', 'safeStorage')
const password = await keychain.getOrCreatePassword()

// Here, `password` is always a non-null string.
console.log(password)
Returns:
Promise that resolves with the password string
Type
Promise.<string>

(async) getPassword() → {Promise.<(string|null)>}

Description:
  • Get password stored in Keychain
Source:
Since:
  • 1.0.0
Example
import { Keychain } from '@pinemz/safe-storage'

const keychain = new Keychain('myService', 'safeStorage')
const password = await keychain.getPassowrd()

// Here, `password` may be a null string.
console.log(password)
Returns:
Promise that resolves with the password string, if a password has been stored, otherwise Promise that resolves with null.
Type
Promise.<(string|null)>