Socket
Socket
Sign inDemoInstall

@octokit/core

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/core - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

21

dist-node/index.js

@@ -5,5 +5,3 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var getUserAgent = _interopDefault(require('universal-user-agent'));
var universalUserAgent = require('universal-user-agent');
var beforeAfterHook = require('before-after-hook');

@@ -43,3 +41,3 @@ var request = require('@octokit/request');

requestDefaults.headers["user-agent"] = [options.userAgent, `octokit-core.js/${VERSION} ${getUserAgent()}`].filter(Boolean).join(" ");
requestDefaults.headers["user-agent"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(" ");

@@ -64,3 +62,3 @@ if (options.baseUrl) {

this.request = request.request.defaults(requestDefaults);
this.graphql = graphql.graphql.defaults(requestDefaults);
this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults);
this.hook = hook; // apply plugins

@@ -73,2 +71,15 @@ // https://stackoverflow.com/a/16345172

static defaults(defaults) {
return class OctokitWithDefaults extends this {
static defaults(newDefaults) {
return Octokit.defaults(Object.assign({}, defaults, newDefaults));
}
constructor(options = {}) {
super(Object.assign({}, defaults, options));
}
};
}
static plugin(plugins) {

@@ -75,0 +86,0 @@ var _a;

@@ -1,5 +0,5 @@

import getUserAgent from "universal-user-agent";
import { getUserAgent } from "universal-user-agent";
import { Collection } from "before-after-hook";
import { request } from "@octokit/request";
import { graphql } from "@octokit/graphql";
import { withCustomRequest } from "@octokit/graphql";
import { VERSION } from "./version";

@@ -44,3 +44,3 @@ import { withAuthorizationPrefix } from "./auth";

this.request = request.defaults(requestDefaults);
this.graphql = graphql.defaults(requestDefaults);
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
this.hook = hook;

@@ -52,2 +52,12 @@ // apply plugins

}
static defaults(defaults) {
return class OctokitWithDefaults extends this {
static defaults(newDefaults) {
return Octokit.defaults(Object.assign({}, defaults, newDefaults));
}
constructor(options = {}) {
super(Object.assign({}, defaults, options));
}
};
}
static plugin(plugins) {

@@ -54,0 +64,0 @@ var _a;

@@ -6,2 +6,23 @@ import { HookCollection } from "before-after-hook";

export declare class Octokit {
static defaults(defaults: OctokitOptions): {
new (options?: OctokitOptions): {
[key: string]: any;
request: import("@octokit/request/dist-types/types").request;
graphql: import("@octokit/graphql/dist-types/types").graphql;
hook: HookCollection;
};
defaults(newDefaults: OctokitOptions): typeof Octokit;
plugins: Plugin[];
plugin(plugins: Plugin | Plugin[]): {
new (options?: OctokitOptions): {
[key: string]: any;
request: import("@octokit/request/dist-types/types").request;
graphql: import("@octokit/graphql/dist-types/types").graphql;
hook: HookCollection;
};
plugins: Plugin[];
defaults(defaults: OctokitOptions): any;
plugin(plugins: Plugin | Plugin[]): any;
};
};
static plugins: Plugin[];

@@ -16,2 +37,13 @@ static plugin(plugins: Plugin | Plugin[]): {

plugins: Plugin[];
defaults(defaults: OctokitOptions): {
new (options?: OctokitOptions): {
[key: string]: any;
request: import("@octokit/request/dist-types/types").request;
graphql: import("@octokit/graphql/dist-types/types").graphql;
hook: HookCollection;
};
defaults(newDefaults: OctokitOptions): typeof Octokit;
plugins: Plugin[];
plugin(plugins: Plugin | Plugin[]): any;
};
plugin(plugins: Plugin | Plugin[]): any;

@@ -18,0 +50,0 @@ };

@@ -1,5 +0,5 @@

import getUserAgent from 'universal-user-agent';
import { getUserAgent } from 'universal-user-agent';
import { Collection } from 'before-after-hook';
import { request } from '@octokit/request';
import { graphql } from '@octokit/graphql';
import { withCustomRequest } from '@octokit/graphql';

@@ -56,3 +56,3 @@ const VERSION = "0.0.0-development";

this.request = request.defaults(requestDefaults);
this.graphql = graphql.defaults(requestDefaults);
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
this.hook = hook;

@@ -64,2 +64,12 @@ // apply plugins

}
static defaults(defaults) {
return class OctokitWithDefaults extends this {
static defaults(newDefaults) {
return Octokit.defaults(Object.assign({}, defaults, newDefaults));
}
constructor(options = {}) {
super(Object.assign({}, defaults, options));
}
};
}
static plugin(plugins) {

@@ -66,0 +76,0 @@ var _a;

{
"name": "@octokit/core",
"description": "Extendable client for GitHub's REST & GraphQL APIs",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",

@@ -28,6 +28,6 @@ "files": [

"dependencies": {
"@octokit/graphql": "^4.0.0",
"@octokit/request": "^5.0.2",
"@octokit/graphql": "^4.2.0",
"@octokit/request": "^5.1.0",
"before-after-hook": "^2.1.0",
"universal-user-agent": "^3.0.0"
"universal-user-agent": "^4.0.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

# core.js
[![@latest](https://img.shields.io/npm/v/@octokit/core.svg)](https://www.npmjs.com/package/@octokit/core)
[![Build Status](https://travis-ci.org/octokit/core.js.svg?branch=master)](https://travis-ci.org/octokit/core.js)
[![Build Status](https://github.com/octokit/core.js/workflows/Test/badge.svg)](https://github.com/octokit/core.js/actions)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/core.js.svg)](https://greenkeeper.io/)

@@ -14,2 +14,4 @@

- [GraphQL example](#graphql-example)
- [Options](#options)
- [Defaults](#defaults)
- [Authentication](#authentication)

@@ -60,3 +62,4 @@ - [Hooks](#hooks)

```js
const octokit = new Octokit({ auth: `secret123` });
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: `personal-access-token123` });

@@ -69,3 +72,3 @@ const response = await octokit.request("GET /orgs/:org/repos", {

See https://github.com/octokit/request.js for full documentation of the `.request` method.
See [`@octokit/request`](https://github.com/octokit/request.js) for full documentation of the `.request` method.

@@ -89,4 +92,138 @@ ### GraphQL example

See https://github.com/octokit/graphql.js for full documentation of the `.graphql` method.
See (`@octokit/graphql`](https://github.com/octokit/graphql.js) for full documentation of the `.graphql` method.
## Options
<table>
<thead align=left>
<tr>
<th>
name
</th>
<th>
type
</th>
<th width=100%>
description
</th>
</tr>
</thead>
<tbody align=left valign=top>
<tr>
<th>
<code>options.auth</code>
</th>
<td>
<code>String</code> or <a href="https://github.com/octokit/auth.js"><code>@octokit/auth</code></a> instance
</td>
<td>
If set to a <code>String</code>, then it's expected to be a <a href="https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line">personal access token</a> or <a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow">OAuth access token</a> and used accordingly in the <code>Authorization</code> header.<br>
<br>
For all other authentication strategies, set <code>options.auth</code> to a <a href="https://github.com/octokit/auth.js"><code>@octokit/auth</code></a> instance.<br>
<br>
See <a href="authentication">Authentication</a> below for examples.
</td>
</tr>
<tr>
<th>
<code>options.baseUrl</code>
</th>
<td>
<code>String</code>
</td>
<td>
When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example
```js
const octokit = new Octokit({
baseUrl: "https://github.acme-inc.com/api/v3"
});
```
</td></tr>
<tr>
<th>
<code>options.previews</code>
</th>
<td>
<code>Array of Strings</code>
</td>
<td>
Some REST API endpoints require preview headers to be set, or enable
additional features. Preview headers can be set on a per-request basis, e.g.
```js
octokit.request("POST /repos/:owner/:repo/pulls", {
mediaType: {
previews: ["shadow-cat"]
},
owner,
repo,
title: "My pull request",
base: "master",
head: "my-feature",
draft: true
});
```
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
```js
const octokit = new Octokit({
previews: ["shadow-cat"]
});
```
</td></tr>
<tr>
<th>
<code>options.request</code>
</th>
<td>
<code>Object</code>
</td>
<td>
Set a default request timeout (`options.request.timeout`) or an [`http(s).Agent`](https://nodejs.org/api/http.html#http_class_http_agent) e.g. for proxy usage (Node only, `options.request.agent`).
There are more `options.request.*` options, see [`@octokit/request` options](https://github.com/octokit/request.js#request). `options.request` can also be set on a per-request basis.
</td></tr>
<tr>
<th>
<code>options.userAgent</code>
</th>
<td>
<code>String</code>
</td>
<td>
A custom user agent string for your app or library. Example
```js
const octokit = new Octokit({
userAgent: "my-app/v1.2.3"
});
```
</td></tr>
</tbody>
</table>
## Defaults
You can create a new Octokit class with customized default options.
```js
const MyOctokit = Octokit.defaults({
auth: "personal-access-token123",
baseUrl: "https://github.acme-inc.com/api/v3",
userAgent: "my-app/v1.2.3"
});
const octokit1 = new MyOctokit();
const octokit2 = new MyOctokit();
```
## Authentication

@@ -106,3 +243,3 @@

All other authentication strategies are supported using [`@octokit/auth`](@octokit/auth-app.js#readme), just pass the `auth()` method returned by any of the strategies as `options.auth`. Example
All other authentication strategies are supported using [`@octokit/auth`](https://github.com/octokit/auth-app.js#readme), just pass the `auth()` method returned by any of the strategies as `options.auth`. Example

@@ -109,0 +246,0 @@ ```js

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc