is-github
v1.0.5
Published
A small library which checks if the provided IP address belongs to GitHub.
Downloads
3
Maintainers
Readme
is-github
A small JavaScript library which checks if the provided IP address belongs to GitHub. Works in Node and the browser.
It uses GitHub's meta endpoint to get the valid IP ranges. The response is cached for the duration GitHub provides in the Cache-Control
header.
Usage
$ npm i is-github
or "https://cdn.jsdelivr.net/npm/is-github@1".
import { isGitHub } from 'is-github';
if (await isGitHub('1.2.3.4')) {
console.log('Request came from GitHub!');
} else {
console.log('Request was not from GitHub.');
}
Options
It is possible to provide the following options in an object as the second argument:
service
: The service to check. One of: 'hooks', 'web', 'api', 'git', 'pages', 'importer' (Default: 'hooks')userAgent
: The user agent to use for the request to GitHub. This might not work in the browser. (Default: 'is-github')timeout
: The timeout in ms. (Default: 5000)
Requirements
The following API's are required when running in the browser.