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

git-credential-helper

v0.0.1

Published

Node library that allows using the git credential API

Downloads

13

Readme

git-credential-helper

Build Status Coverage Status

Node library that allows using the Git credential API. The Git credential API allows you to store and retrieve credentials for Git hosts, preventing you from having to enter your username and password every time. To use this, you have to set up your local Git client installation to make use of a credential helper. Credential helper applications are available for all major operating systems.

Please refer to the following documentation for installing a local credential helper for your operating system:

  • https://confluence.atlassian.com/display/STASH/Permanently+authenticating+with+Git+repositories
  • https://help.github.com/articles/caching-your-github-password-in-git/

Installation

To use this library in your application, install it using npm:

npm install --save git-credential-helper

Usage

The library provides the following functions that can be used to interact with a locally installed Git credential tool. All functions are asynchronous and expect a callback, which is called with the results of the operation.

To include the library in your application, do the following:

var gitCredentialHelper = require('git-credential-helper');

See the examples folder for more info.

available(callback)

Checks whether a Git credential tool is installed locally. The provided callback is called with two parameters:

  • err: An error object in case the call failed.
  • data: A Boolean parameter, indicating whether a Git credential tool is available.

Example:

gitCredentialHelper.available(function (err, data) {
  // data will be true or false
  console.log(data);
});

fill(target, callback, options)

Retrieves any stored credentials for the provided target server. The following parameters are expected:

  • target: A String parameter indicating the URL of the target server.
  • callback: Called when the call to the Git credential tool finishes.
  • options: Optional Object parameter, the following options are available:
    • silent: Boolean option, default value false. Tries to do a silent check, not asking for credentials if the system does not have a stored set of credentials for the requested target repo. Might not be supported on all platforms.

The provided callback is called with two parameters:

  • err: An error object in case the call failed.
  • data: An object, containing the server information and the stored credentials. If there aren't any stored credentials for the requested target server, the object will be empty.

When there aren't any stored credentials for the requested target server, the Git credential helper will not ask for credentials, it will simply provide an empty result object to the callback.

The result object will be in the form of

{ 
  protocol: 'http',
  host: 'foo',
  username: 'user',
  password: 'pass' 
}

Example:

gitCredentialHelper.fill('http://foo/bar.git', function (err, data) {
  // data will contain any stored credentials, or will be {}
  console.log(data);
}, {
  silent: true
);

approve(target, callback, options)

Stores the provided credentials for the provided target server. The following parameters are expected:

  • target: A String parameter indicating the URL of the target server.
  • callback: Called when the call to the Git credential tool finishes.
  • options: An object containing username and password properties with the credentials to be stored.

The provided callback is called with two parameters:

  • err: An error object in case the call failed.
  • data: An object, in the case of approve this is always empty.

Example:

gitCredentialHelper.approve('http://foo/bar.git',
  function (err, data) {
    // data will be {}
    console.log(data);
}, {
  username: 'user',
  password: 'pass'
});

reject(target, callback, options)

Removes any stored credentials for the provided target server. The following parameters are expected:

  • target: A String parameter indicating the URL of the target server.
  • callback: Called when the call to the Git credential tool finishes.
  • options: Optional parameter, there currently aren't any supported options for this command.

The provided callback is called with two parameters:

  • err: An error object in case the call failed.
  • data: An object, in the case of reject this is always empty.

Example:

gitCredentialHelper.reject('http://foo/bar.git', function (err, data) {
  // data will be {}
  console.log(data);
});

Known Issues

  • The silent option of the fill command currently does not work on Windows using the Winstore credential helper.

License

Copyright (c) 2014 Nils Winkler. Licensed under the MIT license.