1.0.5 • Published 4 years ago

is-github v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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.

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago