validate-github-token
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
excluded?: string[]; | ||
exact?: string[]; | ||
} | ||
@@ -8,0 +9,0 @@ export interface ValidateOptions { |
@@ -79,2 +79,10 @@ "use strict"; | ||
} | ||
if (validation.exact) { | ||
const want = validation.exact; | ||
if (want.some(s => !scopes.includes(s)) || scopes.some(s => !want.includes(s))) { | ||
const got = JSON.stringify(scopes); | ||
const expected = JSON.stringify(want); | ||
throw new ValidationError(`The token's scopes ${got} don't exactly match to the expected scopes ${expected}`); | ||
} | ||
} | ||
} | ||
@@ -81,0 +89,0 @@ return scopes; |
{ | ||
"name": "validate-github-token", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Validation for GitHub API token", | ||
@@ -19,2 +19,3 @@ "main": "index.js", | ||
"lint": "eslint '**/*.ts'", | ||
"prepublishOnly": "npm-run-all -p lint test", | ||
"test": "npm-run-all build mocha" | ||
@@ -21,0 +22,0 @@ }, |
@@ -21,4 +21,7 @@ GitHub API Token Validation for Node.js | ||
This package was created to make a human-friendly error before actually calling GitHub APIs mainly | ||
for [GitHub Action][gh-action]. | ||
## Installation | ||
@@ -43,3 +46,3 @@ | ||
// Checks 'public_repo' scope is added to the token | ||
included: 'public_repo' | ||
included: ['public_repo'] | ||
} | ||
@@ -80,2 +83,3 @@ } | ||
- `excluded: Array<string>`: Scope names which should NOT be added to the token **Optional** | ||
- `exact: Array<string>`: Scope names should exactly match to scopes of the token **Optional** | ||
- `agent: https.Agent`: Node.js HTTPS agent. For example please pass [https-proxy-agent][proxy] for proxy support **Optional** | ||
@@ -153,1 +157,2 @@ - `endpointUrl: string`: Custom API endpoint URL. Deafult value is `"https://api.github.com"` **Optional** | ||
[npm-badge]: https://badge.fury.io/js/validate-github-token.svg | ||
[gh-action]: https://github.com/features/actions |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12262
133
155