{"name":"ghauth","version":"7.0.1","keywords":["github","auth","frozenpizza"],"license":"MIT","_id":"ghauth@7.0.1","maintainers":[{"name":"rvagg","email":"r@va.gg"}],"homepage":"https://github.com/rvagg/ghauth","bugs":{"url":"https://github.com/rvagg/ghauth/issues"},"dist":{"shasum":"88e89e6655d37974835ba70e71fadb60923911da","tarball":"http://registry-npm.ywwl.com/ghauth/download/ghauth-7.0.1.tgz","fileCount":15,"integrity":"sha512-yGqhD2tS6A78O3oVr7oA2SWe0zTqU9oCAzTVV3U2vx31OJ+KEiF5vgNPf4pI5437Lvr50maBjo6rM9GyTGpRzQ==","signatures":[{"sig":"MEYCIQDb3LR2ocBtt3iyNlTW/Ip7VrWCfQ5z/yWZ9CxlAaT3pQIhAIMlMFWNP9vgGowmpB5O3/lccj+xhqrSj+GW8SxMXBDS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/ghauth@7.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":51401,"size":14959,"noattachment":false,"key":"/ghauth/-/ghauth-7.0.1.tgz"},"type":"module","authors":["Rod Vagg <r@va.gg> (https://github.com/rvagg)","Jeppe Nejsum Madsen <jeppe@ingolfs.dk> (https://github.com/jeppenejsum)","Max Ogden <max@maxogden.com> (https://github.com/maxogden)"],"engines":{"node":">=20"},"exports":"./ghauth.js","gitHead":"43bbdefa1372f7a09eb45a5459e2eb5aebb962c1","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"chore","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Trivial Changes"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"],"branches":["master"]},"scripts":{"lint":"standard","test":"npm run lint && npm run test:unit","build":"true","smoke":"node test/smoke.js","test:unit":"node --test test/*.test.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a4f3efce-08b4-40f6-86c5-889d66c85214"}},"repository":{"url":"git+https://github.com/rvagg/ghauth.git","type":"git"},"_npmVersion":"11.8.0","description":"Create and load persistent GitHub authentication tokens for command-line apps","directories":{},"_nodeVersion":"24.13.0","dependencies":{"ora":"^9.1.0","read":"^5.0.1"},"_hasShrinkwrap":false,"devDependencies":{"standard":"^17.1.2","semantic-release":"^25.0.0","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^13.0.0","@semantic-release/github":"^12.0.0","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^13.0.0","@semantic-release/release-notes-generator":"^14.0.1","conventional-changelog-conventionalcommits":"^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ghauth_7.0.1_1769511324006_0.2571976870847952","host":"s3://npm-registry-packages-npm-production"},"readme":"# ghauth\n\n**Create and load persistent GitHub authentication tokens for command-line apps**\n\n[![NPM](https://nodei.co/npm/ghauth.svg?style=flat&data=n,v&color=blue)](https://nodei.co/npm/ghauth/)\n\n## Example usage\n\n```js\nimport ghauth from 'ghauth'\n\nconst authData = await ghauth({\n  configName: 'my-app',\n  scopes: ['repo']\n})\n\nconsole.log(authData)\n// { user: 'rvagg', token: 'ghp_...' }\n```\n\nOn first run, this prompts the user to create a [Personal Access Token](https://github.com/settings/tokens). The token is saved to `~/.config/my-app/config.json` (Linux), `~/Library/Application Support/my-app/config.json` (macOS), or `%APPDATA%/my-app/config.json` (Windows). Subsequent runs return the cached token without prompting.\n\n```console\n$ node my-app.js\nPersonal access token auth for Github.\n\n  Create a Personal Access Token at https://github.com/settings/tokens\n\n    1. Click \"Generate new token\" → \"Generate new token (classic)\"\n       (fine-grained tokens also work)\n    2. Set a name, e.g. \"my-app\"\n    3. Select scopes: repo\n    4. Generate and copy the token\n\nPaste your token here: ✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔✔\n✔ Authorized for rvagg\nWrote access token to \"/home/rvagg/.config/my-app/config.json\"\n{ user: 'rvagg', token: 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }\n```\n\n## API\n\n<b><code>ghauth(options)</code></b>\n\nReturns a `Promise` that resolves to `{ user: String, token: String }`.\n\n### Options\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `configName` | String | Yes* | Name for the config file. Creates `<configName>/config.json` in the user's config directory. *Not required if `noSave: true`. |\n| `scopes` | Array | No | GitHub API [scopes](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps) your app requires. Defaults to `[]`. |\n| `noSave` | Boolean | No | Don't persist the token to disk. |\n| `clientId` | String | No | OAuth app client ID. If provided, uses device flow instead of PAT prompt. |\n| `noDeviceFlow` | Boolean | No | Force PAT prompt even if `clientId` is provided. |\n| `userAgent` | String | No | Custom User-Agent for GitHub API requests. |\n| `passwordReplaceChar` | String | No | Character to echo when entering tokens. Defaults to `'✔'`. |\n| `authUrl` | String | No | GitHub Enterprise auth URL (for GHE only). |\n| `promptName` | String | No | Name shown in prompts for GHE. Defaults to `'GitHub Enterprise'`. |\n| `note` | String | No | Note for the token (GHE only). |\n\n### Token formats\n\nghauth accepts all GitHub PAT formats:\n- **Classic PATs**: 40 hex characters or `ghp_` prefix\n- **Fine-grained PATs**: `github_pat_` prefix\n\n## OAuth Device Flow\n\nIf you register an [OAuth App](https://github.com/settings/developers) with GitHub, you can use the device flow instead of asking users to create PATs manually. This provides a smoother UX where users authorize in their browser.\n\n```js\nconst authData = await ghauth({\n  clientId: 'your-oauth-app-client-id',\n  configName: 'my-app',\n  scopes: ['repo']\n})\n```\n\nTo set up an OAuth App:\n1. Go to [GitHub Developer Settings](https://github.com/settings/developers)\n2. Create a new OAuth App\n3. Set any URL for the callback (it's not used by device flow)\n4. Enable \"Device Authorization Flow\" in the app settings\n5. Use the Client ID (not the secret) in your code\n\nSee [GitHub's device flow documentation](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow) for details.\n\n## GitHub Enterprise\n\nFor GitHub Enterprise instances that use basic auth:\n\n```js\nconst authData = await ghauth({\n  configName: 'my-app',\n  authUrl: 'https://github.mycompany.com/api/v3/authorizations',\n  scopes: ['repo']\n})\n```\n\n## v6 to v7 Migration\n\n**Breaking Changes:**\n\n1. **ESM only** - Update imports:\n   ```javascript\n   // Before (v6)\n   const ghauth = require('ghauth')\n\n   // After (v7)\n   import ghauth from 'ghauth'\n   ```\n\n2. **Promise-only API** - Callbacks removed:\n   ```javascript\n   // Before (v6)\n   ghauth(options, (err, data) => { ... })\n\n   // After (v7)\n   const data = await ghauth(options)\n   ```\n\n3. **Node.js 20+** required\n\n4. **PAT flow is now the default** - No need for `noDeviceFlow: true` or `clientId`. Just provide `configName` and optional `scopes`.\n\n5. **PAT validation updated** - Now accepts fine-grained PATs (`github_pat_` prefix) in addition to classic PATs.\n\n## Contributing\n\nghauth is an **OPEN Open Source Project**. This means that:\n\n> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.\n\nSee the [CONTRIBUTING.md](https://github.com/rvagg/ghauth/blob/master/CONTRIBUTING.md) file for more details.\n\n### Contributors\n\nghauth is made possible by the excellent work of the following contributors:\n\n<table><tbody>\n<tr><th align=\"left\">Rod Vagg</th><td><a href=\"https://github.com/rvagg\">GitHub/rvagg</a></td><td><a href=\"http://twitter.com/rvagg\">Twitter/@rvagg</a></td></tr>\n<tr><th align=\"left\">Jeppe Nejsum Madsen</th><td><a href=\"https://github.com/jeppenejsum\">GitHub/jeppenejsum</a></td><td><a href=\"http://twitter.com/nejsum\">Twitter/@nejsum</a></td></tr>\n<tr><th align=\"left\">Max Ogden</th><td><a href=\"https://github.com/maxogden\">GitHub/maxogden</a></td><td><a href=\"http://twitter.com/maxogden\">Twitter/@maxogden</a></td></tr>\n<tr><th align=\"left\">Bret Comnes</th><td><a href=\"https://github.com/bcomnes\">GitHub/bcomnes</a></td><td><a href=\"http://twitter.com/bcomnes\">Twitter/@bcomnes</a></td></tr>\n</tbody></table>\n\n## License\n\nCopyright (c) 2014 ghauth contributors (listed above).\n\nghauth is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.\n","publish_time":1769511324184,"_cnpm_publish_time":1769511324184,"dist-tags":{"latest":"7.0.16"}}