npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dawaltconley/secret

v0.1.0

Published

Saving and retrieving passwords via the OSX security cli.

Downloads

5

Readme

Storing information in the Mac Keychain

Uses the OSX security cli to save and retrieve passwords and other sensitive data.

Examples

Instantiates a Secret object. Takes an argument for the service/url and an optional second argument for the account name.

const Secret = require('./secret.js')

const generic = new Secret('jekyll-comments')
// creates a generic password with no account info

const internet = new Secret('https://api.github.com', 'dawaltconley')
// creates an internet password for the account 'dawaltconley'

Following the behavior of security, Secret returns slightly different information depending on whether that Secret is of a generic or internet type.

// generic.get().then(s => console.log(s))
{
    type: 'generic',
    keychain: '/Users/dylan/Library/Keychains/login.keychain-db',
    label: 'jekyll-comments',
    account: null,
    service: 'jekyll-comments',
    password: 'passw0rd!'
}

// internet.get().then(s => console.log(s))
{
    type: 'internet',
    keychain: '/Users/dylan/Library/Keychains/login.keychain-db',
    label: 'api.github.com',
    account: 'dawaltconley',
    host: 'api.github.com',
    path: '/',
    protocol: 'https:',
    password: 'passw0rd!'
}

Configuration

Secret.prompt

Determines how the user is prompted to enter a password. Defaults to 'secret: '.

Secret.executablePath

The path of the security child process. Defaults to '/usr/bin/security'.

Methods

config()

Runs an interactive commandline prompt to assign or overwrite the secret. Adds an extra prompt to confirm overwriting, if the secret has already been set.

get(interactive)

Gets a secret from the command line. Accepts a boolean as its argument, which affects its behavior if the secret hasn't been set yet.

If set to true, get will prompt the user to input a secret (similar to config). If set to false, get will reject with a SecretNotFoundError (default: true).

set(password, force)

Sets the secret to a provided string, storing it in the Keychain. Second argument determines whether to overwrite an existing secret in the Keychain, If false, rejects with a SecretAlreadySetError (default: false).

delete()

Deletes the secret from the Keychain. Doesn't delete the secret object; secrets can still be reset or configured after deletion.