is-github

1.0.5 • Public • Published

npm version

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.

Package Sidebar

Install

npm i is-github

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

15.7 kB

Total Files

5

Last publish

Collaborators

  • tjenkinson