{"_id":"git-credential-node","_rev":"131453","name":"git-credential-node","description":"Thin wrapper around `git credential` command","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"parroit","email":"andrea.parodi@ebansoftware.net"}],"time":{"modified":"2021-06-03T11:11:28.000Z","created":"2015-08-09T10:53:35.222Z","1.1.0":"2017-02-02T16:10:28.481Z","1.0.0":"2015-08-09T10:53:35.222Z"},"users":{},"author":{"name":"Andrea Parodi","email":"andrea@parro.it"},"repository":{"type":"git","url":"git+https://github.com/parro-it/git-credential-node.git"},"versions":{"1.1.0":{"name":"git-credential-node","description":"Thin wrapper around `git credential` command","repository":{"type":"git","url":"git+https://github.com/parro-it/git-credential-node.git"},"version":"1.1.0","license":"MIT","engines":{"node":">=6"},"author":{"name":"Andrea Parodi","email":"andrea@parro.it"},"scripts":{"test":"ava && xo"},"files":["index.js"],"devDependencies":{"ava":"^0.17.0","pify":"^2.3.0","xo":"^0.17.1"},"dependencies":{"execa":"^0.6.0"},"gitHead":"2681f612f452ed3392328fce2aa835270611cfb1","bugs":{"url":"https://github.com/parro-it/git-credential-node/issues"},"homepage":"https://github.com/parro-it/git-credential-node#readme","_id":"git-credential-node@1.1.0","_shasum":"2507544ac031d0082cd9e0f833aac758f15fd80d","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"parroit","email":"andrea@parro.it"},"dist":{"shasum":"2507544ac031d0082cd9e0f833aac758f15fd80d","size":3457,"noattachment":false,"key":"/git-credential-node/-/git-credential-node-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/git-credential-node/download/git-credential-node-1.1.0.tgz"},"maintainers":[{"name":"parroit","email":"andrea.parodi@ebansoftware.net"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/git-credential-node-1.1.0.tgz_1486051827793_0.3456059596501291"},"directories":{},"publish_time":1486051828481,"_cnpm_publish_time":1486051828481,"_hasShrinkwrap":false},"1.0.0":{"name":"git-credential-node","description":"switch git credentials within your accounts","repository":{"type":"git","url":"git+https://github.com/parro-it/git-credential-node.git"},"version":"1.0.0","license":"MIT","main":"dist/index.js","dependencies":{"babel-runtime":"^5.8.20"},"author":{"name":"andrea@parro.it"},"scripts":{"test":"mocha test/*_test.js test/**/*_test.js --require ./test/_init || echo failed","test-release":"export TEST_RELEASE=1 && mocha dist_test/*_test.js dist_test/**/*_test.js --require ./dist_test/_init-release","build":"babel es6 --out-dir dist","build-test":"babel test --out-dir dist_test","lint":"eslint es6/*.js test/*.js","check":"npm run lint && npm run build && npm run build-test && npm run test-release"},"eslintConfig":{"extends":"eslint-config-airbnb","plugins":["babel"]},"babel":{"stage":0,"optional":["runtime"]},"devDependencies":{"babel":"^5.1.11","babel-eslint":"^4.0.5","chai":"^2.2.0","co":"^4.5.2","co-mocha":"^1.1.0","eslint":"^0.24.1","eslint-config-airbnb":"0.0.6","eslint-plugin-babel":"^1.2.0","mocha":"^2.2.4","thenify":"^3.1.0"},"gitHead":"4ad950c67bb7edb2f0ed36c4e3ec44d6deab8a56","bugs":{"url":"https://github.com/parro-it/git-credential-node/issues"},"homepage":"https://github.com/parro-it/git-credential-node#readme","_id":"git-credential-node@1.0.0","_shasum":"d104075067458375f6a54c4ae3e86b3a0804c4c3","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"parroit","email":"andrea.parodi@ebansoftware.net"},"dist":{"shasum":"d104075067458375f6a54c4ae3e86b3a0804c4c3","size":7001,"noattachment":false,"key":"/git-credential-node/-/git-credential-node-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/git-credential-node/download/git-credential-node-1.0.0.tgz"},"maintainers":[{"name":"parroit","email":"andrea.parodi@ebansoftware.net"}],"directories":{},"publish_time":1439117615222,"_cnpm_publish_time":1439117615222,"_hasShrinkwrap":false}},"readme":"# git-credential-node\n\n> Thin wrapper around `git credential` command\n> Allow you to use [Git credential API](http://git-scm.com/docs/git-credential) from node.\n\n[![Travis Build Status](https://img.shields.io/travis/parro-it/git-credential-node.svg)](http://travis-ci.org/parro-it/git-credential-node)\n[![NPM module](https://img.shields.io/npm/v/git-credential-node.svg)](https://npmjs.org/package/git-credential-node)\n[![NPM downloads](https://img.shields.io/npm/dt/git-credential-node.svg)](https://npmjs.org/package/git-credential-node)\n\n\n## Installation\n\n```bash\nnpm install --save git-credential-node\n```\n\n## How it works\n\nThis is a thin wrapper around the `git credential` command.\n\nThe library use the GIT_TERMINAL_PROMPT environment variable to\navoid asking the user credential on stdin.\n\nThe option is avalable starting with git 2.3, so you must have this version of git intalled on your system (or a newer one).\n\nSee [detail on the option here](https://github.com/blog/1957-git-2-3-has-been-released)\n\n## Usage\n\nThe library provides the following functions that can be used to interact with a locally installed Git credential tool.\nAll functions with names ending in `sync` are synchronous, and either return the result of operation or throws.\nAll other functions are asynchronous and could be used in one of two ways:\n  * a callback could be provided as last argument which is called with the error or the results of the operation as arguments, following the standard node semantic.\n  * a promise is returned that is either resolved with results, or rejected with errors.\n\n\n### fill(url, callback)\n\nRetrieves any stored credentials for the provided target server.\n\n* `url`: A `String` parameter indicating the URL of the target server, e.g. https://github.com\n* `callback`: Called when the call to the Git credential tool finishes.\n\nThe provided `callback` is called with two parameters:\n\n* `err`: An error object in case the call failed.\n* `result`: { username, password }, containing the stored credentials. If there aren't any stored credentials for the requested target server, result will be null.\n\nWhen 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.\n\nExample:\n\n```javascript\nimport { fill } from 'git-credential-node';\nfill('http://foo/bar.git', (err, data) => {\n  if (err) {\n    return console.log(err.message);\n  }\n  if (!data) {\n    console.log('credentials not stored!');\n  }\n  console.dir(data);\n});\n```\n\n### approve(options, callback)\n\nStores the provided credentials for the provided target server. The following parameters are expected:\n\n\n* `options`: { username, password, url } An object containing `username` and `password` properties with the credentials to be stored, and `url` indicating the URL of the target server.\n* `callback`: Called when the call to the Git credential tool finishes.\n\nThe provided `callback` is called with one parameters:\n\n* `err`: An error object in case the call failed. If it is null, it means the call has succedeed.\n\nExample:\n\n```javascript\nimport { approve } from 'git-credential-node';\nconst opts = {\n  username: 'user',\n  password: 'pass',\n  url: 'http://foo/bar.git'\n};\n\napprove(opts, err => {\n  if (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials stored!');\n});\n```\n\n### reject(url, callback)\n\nRemoves any stored credentials for the provided target server. The following parameters are expected:\n\n\n* `url`: A `String` parameter indicating the URL of the target server, e.g. https://github.com\n* `callback`: Called when the call to the Git credential tool finishes.\n\nThe provided `callback` is called with one parameters:\n\n* `err`: An error object in case the call failed. If it is null, it means the call has succedeed.\n\nExample:\n\n```javascript\nimport { reject } from 'git-credential-node';\nreject('http://foo/bar.git', err => {\n  if (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials removed!');\n});\n```\n\n\n## Promises usage\n\nExample of use of the async functions with promise.\n\nAll functions resolve or reject the returned promise with the same arguments passed\nto the callback.\nWe use es2016 proposed async function in these example for clarity, but this is obviously\nnot required.\nAny other comment specified in the callback section apply also to the promise usage.\n\n### fill(url)\n\nExample:\n\n```javascript\nimport { fill } from 'git-credential-node';\n\nasync function example() {\n  try {\n\n    const data = await fill('http://foo/bar.git');\n\n    if (!data) {\n      console.log('credentials not stored!');\n    }\n    return data;\n\n  } catch (err) {\n    console.log(err.message);\n  }\n}\n```\n\n### approve(options)\n\nExample:\n\n```javascript\nimport { approve } from 'git-credential-node';\n\nasync function example() {\n  const opts = {\n    username: 'user',\n    password: 'pass',\n    url: 'http://foo/bar.git'\n  };\n\n  try {\n    await approve(opts);\n\n  } catch (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials stored!');\n});\n```\n\n### reject(url, callback)\n\nExample:\n\n```javascript\nimport { reject } from 'git-credential-node';\n\nasync function example() {\n  try {\n    await reject('http://foo/bar.git');\n\n  } catch (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials removed!');\n});\n```\n\n\n\n## Sync usage\n\nExample of use of the sync functions.\n\nAll functions hasve a synchronous counterpart, with name ending in `Sync`.\nThese can be particulary useful to use within bin scripts.\n\nAny other comment specified in the callback section apply also to the sync functions.\n\n### fillSync(url)\n\nExample:\n\n```javascript\nimport { fillSync } from 'git-credential-node';\n\nfunction example() {\n  try {\n\n    const data = fillSync('http://foo/bar.git');\n\n    if (!data) {\n      console.log('credentials not stored!');\n    }\n    return data;\n\n  } catch (err) {\n    console.log(err.message);\n  }\n}\n```\n\n### Sync(options)\n\nExample:\n\n```javascript\nimport { Sync } from 'git-credential-node';\n\nfunction example() {\n  const opts = {\n    username: 'user',\n    password: 'pass',\n    url: 'http://foo/bar.git'\n  };\n\n  try {\n    Sync(opts);\n\n  } catch (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials stored!');\n});\n```\n\n### rejectSync(url, callback)\n\nExample:\n\n```javascript\nimport { rejectSync } from 'git-credential-node';\n\nfunction example() {\n  try {\n    rejectSync('http://foo/bar.git');\n\n  } catch (err) {\n    return console.log(err.message);\n  }\n\n  console.log('credentials removed!');\n});\n```\n\n\n## Credits\n\nI took inspiration and documentation from\n[git-credential-helper](https://github.com/nwinkler/git-credential-helper)\nby [nwinkler](https://github.com/nwinkler)\n\n## License\n\nMIT - © 2015 Andrea Parodi\n","_attachments":{},"homepage":"https://github.com/parro-it/git-credential-node#readme","bugs":{"url":"https://github.com/parro-it/git-credential-node/issues"},"license":"MIT"}