{"id":15387277,"url":"https://github.com/rhysd/validate-github-token","last_synced_at":"2026-03-08T01:06:20.973Z","repository":{"id":38127492,"uuid":"236955631","full_name":"rhysd/validate-github-token","owner":"rhysd","description":"Tiny npm package to validate a GitHub API token","archived":false,"fork":false,"pushed_at":"2023-07-18T20:45:08.000Z","size":273,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-03T11:29:57.150Z","etag":null,"topics":["github-api","npm","validate"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/validate-github-token","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhysd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-29T10:21:37.000Z","updated_at":"2025-02-06T14:21:32.000Z","dependencies_parsed_at":"2024-10-18T19:01:00.467Z","dependency_job_id":"2c6599de-8355-40da-b434-eac544a1a169","html_url":"https://github.com/rhysd/validate-github-token","commit_stats":{"total_commits":49,"total_committers":3,"mean_commits":"16.333333333333332","dds":"0.18367346938775508","last_synced_commit":"0864d256e73ff218d8f48c83ec3d53009bd33675"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/rhysd/validate-github-token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fvalidate-github-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fvalidate-github-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fvalidate-github-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fvalidate-github-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhysd","download_url":"https://codeload.github.com/rhysd/validate-github-token/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhysd%2Fvalidate-github-token/sbom","scorecard":{"id":774615,"data":{"date":"2025-08-11","repo":{"name":"github.com/rhysd/validate-github-token","commit":"0864d256e73ff218d8f48c83ec3d53009bd33675"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/rhysd/validate-github-token/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/rhysd/validate-github-token/ci.yml/master?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yml:21","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 14 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T03:12:18.382Z","repository_id":38127492,"created_at":"2025-08-23T03:12:18.382Z","updated_at":"2025-08-23T03:12:18.382Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30240354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"ssl_error","status_checked_at":"2026-03-08T00:55:48.608Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-api","npm","validate"],"created_at":"2024-10-01T14:53:11.127Z","updated_at":"2026-03-08T01:06:20.952Z","avatar_url":"https://github.com/rhysd.png","language":"TypeScript","readme":"GitHub API Token Validation for Node.js\n=======================================\n[![CI workflow][ci-badge]][ci]\n[![npm package][npm-badge]][npm]\n\n[validate-github-token][repo] is a [npm package][npm] to validate [GitHub API][dev-gh] OAuth token.\n\nThis package can validate the given token\n\n- is actually authorized by API endpoint\n- has expected API scopes\n- doesn't have unexpected API scopes\n\nand returns the following information as the result of validation:\n\n- API scopes which the given token has\n- Rate limit\n\nSee [GitHub official authentication document][gh-auth] for more details.\n\nThis package aims to make a human-friendly error before actually calling GitHub APIs. It is useful\nfor validating inputs of [GitHub Action][gh-action] if you're making a [JavaScript Action][js-action].\n\n\n\n## Installation\n\n```\nnpm install --save validate-github-token\n```\n\n\n\n## JavaScript Example\n\n```javascript\nconst { validateGitHubToken, ValidationError } = require('validate-github-token');\n\n(async () =\u003e {\n    try {\n        const validated = await validateGitHubToken(\n            'your-secret-api-token',\n            {\n                scope: {\n                    // Checks 'public_repo' scope is added to the token\n                    included: ['public_repo']\n                }\n            }\n        );\n\n        console.log('Token scopes:', validated.scopes);\n        console.log('API rate limit remaining:', validated.rateLimit.remaining);\n    } catch(err) {\n        if (err instanceof ValidationError) {\n            console.error(`Validation failed!: ${err.message}`);\n        } else {\n            throw err;\n        }\n    }\n})();\n```\n\n\n\n## API\n\n```typescript\nimport { validateGitHubToken, ValidationError } from 'validate-github-token';\n// Types for TypeScript\nimport { ValidateOptions, RateLimit, Validated } from 'validate-github-token';\n```\n\n\n### `interface ValidateOptions`\n\nA TypeScript interface for configuring the validation behavior. It's keys are as follows:\n\n- `userName: string`: GitHub user name like `\"rhysd\"` for [@rhysd][me]. If this value is set, the endpoint will\n  check the token against the user **Optional**\n- `scope: Object`: Scope validation behavior **Optional**\n  - `included: Array\u003cstring\u003e`: Scope names which should be added to the token **Optional**\n  - `excluded: Array\u003cstring\u003e`: Scope names which should NOT be added to the token **Optional**\n  - `exact: Array\u003cstring\u003e`: Scope names should exactly match to scopes of the token **Optional**\n- `agent: https.Agent`: Node.js HTTPS agent. For example please pass [https-proxy-agent][proxy] for proxy support **Optional**\n- `endpointUrl: string`: Custom API endpoint URL. Default value is `\"https://api.github.com\"` **Optional**\n\ne.g.\n\n```typescript\nimport {ValidateOptions} from 'validate-github-token';\n\nconst opts: ValidateOptions = {\n    scope: {\n        included: ['public_repo'],\n        excluded: ['user'],\n    },\n    endpointUrl: 'https://github.your.company.com/api/v3',\n};\n```\n\n\n### `async function validateGitHubToken(token, options?)`\n\nA function which validates the given token for the given user. Validation behavior can be configured\nwith the 3rd parameter. It returns the information given from API endpoint.\nValidation failure is thrown as `ValidationError`.\n\n#### Parameters\n\n- `token: string`: API token to be validated **Required**\n- `options: Object`: Objects to configure validation behavior **Optional**\n\n#### Return value\n\n- Type: `Promise\u003cValidated\u003e`\n\nReturns a promise which is resolved to `Validated` interface object. Please read following 'interface Validated'\nsection for more details.\n\n#### Exceptions\n\n- `ValidationError`: Thrown when the given token is actually not authorized or its scopes don't meet `options.scope` option value\n- `Error`: Thrown when unexpected errors such as network error happen\n\n\n### `interface Validated`\n\nA TypeScript interface contains the all information returned from API endpoint.\n\n- `scopes: Array\u003cstring\u003e`: An array of scope names added to the API token\n- `rateLimit: RateLimit`: Rate limit information\n\n\n### `interface RateLimit`\n\nA TypeScript interface contains the rate limit information returned from an API endpoint.\nPlease read [GitHub's official rate limit documentation][rate-limit] for more details.\n\n- `limit: number`: Max rate limit count\n- `remaining: number`: Remaining rate limit count\n- `reset: Date`: The date when the rate limit count is reset\n\n\n\n## License\n\nDistributed under [the MIT license](./LICENSE.txt).\n\n[repo]: https://github.com/rhysd/validate-github-token\n[npm]: https://www.npmjs.com/package/validate-github-token\n[dev-gh]: https://developer.github.com/\n[proxy]: https://www.npmjs.com/package/https-proxy-agent\n[rate-limit]: https://developer.github.com/v3/rate_limit/\n[me]: https://github.com/rhysd\n[gh-auth]: https://developer.github.com/v3/#authentication\n[ci-badge]: https://github.com/rhysd/validate-github-token/workflows/CI/badge.svg?branch=master\u0026event=push\n[ci]: https://github.com/rhysd/validate-github-token/actions?query=workflow%3ACI+branch%3Amaster\n[npm-badge]: https://badge.fury.io/js/validate-github-token.svg\n[gh-action]: https://github.com/features/actions\n[js-action]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-a-javascript-action\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Fvalidate-github-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhysd%2Fvalidate-github-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhysd%2Fvalidate-github-token/lists"}