Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass node-fetch as options.request.fetch to the Octokit constructor #225

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 97 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1803,18 +1803,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
// pkg/dist-src/index.js
var dist_src_exports = {};
__export(dist_src_exports, {
Octokit: () => Octokit,
RestEndpointMethodTypes: () => import_plugin_rest_endpoint_methods2.RestEndpointMethodTypes
Octokit: () => Octokit
});
module.exports = __toCommonJS(dist_src_exports);
var import_core = __nccwpck_require__(6762);
var import_auth_action = __nccwpck_require__(20);
var import_plugin_paginate_rest = __nccwpck_require__(4193);
var import_plugin_rest_endpoint_methods = __nccwpck_require__(3044);
var import_plugin_rest_endpoint_methods2 = __nccwpck_require__(3044);

// pkg/dist-src/version.js
var VERSION = "5.0.6";
var VERSION = "6.0.4";

// pkg/dist-src/index.js
var import_https_proxy_agent = __nccwpck_require__(7219);
Expand Down Expand Up @@ -1885,7 +1883,7 @@ __export(dist_src_exports, {
createActionAuth: () => createActionAuth
});
module.exports = __toCommonJS(dist_src_exports);
var import_auth_token = __nccwpck_require__(334);
var import_auth_token = __nccwpck_require__(6434);
var createActionAuth = function createActionAuth2() {
if (!process.env.GITHUB_ACTION) {
throw new Error(
Expand Down Expand Up @@ -1914,6 +1912,91 @@ var createActionAuth = function createActionAuth2() {
0 && (0);


/***/ }),

/***/ 6434:
/***/ ((module) => {

"use strict";

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// pkg/dist-src/index.js
var dist_src_exports = {};
__export(dist_src_exports, {
createTokenAuth: () => createTokenAuth
});
module.exports = __toCommonJS(dist_src_exports);

// pkg/dist-src/auth.js
var REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
var REGEX_IS_INSTALLATION = /^ghs_/;
var REGEX_IS_USER_TO_SERVER = /^ghu_/;
async function auth(token) {
const isApp = token.split(/\./).length === 3;
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
return {
type: "token",
token,
tokenType
};
}

// pkg/dist-src/with-authorization-prefix.js
function withAuthorizationPrefix(token) {
if (token.split(/\./).length === 3) {
return `bearer ${token}`;
}
return `token ${token}`;
}

// pkg/dist-src/hook.js
async function hook(token, request, route, parameters) {
const endpoint = request.endpoint.merge(
route,
parameters
);
endpoint.headers.authorization = withAuthorizationPrefix(token);
return request(endpoint);
}

// pkg/dist-src/index.js
var createTokenAuth = function createTokenAuth2(token) {
if (!token) {
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
}
if (typeof token !== "string") {
throw new Error(
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
);
}
token = token.replace(/^(token|bearer) +/i, "");
return Object.assign(auth.bind(null, token), {
hook: hook.bind(null, token)
});
};
// Annotate the CommonJS export names for ESM import in node:
0 && (0);


/***/ }),

/***/ 334:
Expand Down Expand Up @@ -2709,7 +2792,7 @@ __export(dist_src_exports, {
module.exports = __toCommonJS(dist_src_exports);

// pkg/dist-src/version.js
var VERSION = "6.1.2";
var VERSION = "7.1.2";

// pkg/dist-src/normalize-paginated-list-response.js
function normalizePaginatedListResponse(response) {
Expand Down Expand Up @@ -2876,6 +2959,7 @@ var paginatingEndpoints = [
"GET /orgs/{org}/projects",
"GET /orgs/{org}/public_members",
"GET /orgs/{org}/repos",
"GET /orgs/{org}/rulesets",
"GET /orgs/{org}/secret-scanning/alerts",
"GET /orgs/{org}/teams",
"GET /orgs/{org}/teams/{team_slug}/discussions",
Expand Down Expand Up @@ -2965,6 +3049,8 @@ var paginatingEndpoints = [
"GET /repos/{owner}/{repo}/releases",
"GET /repos/{owner}/{repo}/releases/{release_id}/assets",
"GET /repos/{owner}/{repo}/releases/{release_id}/reactions",
"GET /repos/{owner}/{repo}/rules/branches/{branch}",
"GET /repos/{owner}/{repo}/rulesets",
"GET /repos/{owner}/{repo}/secret-scanning/alerts",
"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations",
"GET /repos/{owner}/{repo}/security-advisories",
Expand Down Expand Up @@ -3096,7 +3182,7 @@ __export(dist_src_exports, {
module.exports = __toCommonJS(dist_src_exports);

// pkg/dist-src/version.js
var VERSION = "7.2.3";
var VERSION = "8.0.0";

// pkg/dist-src/generated/endpoints.js
var Endpoints = {
Expand Down Expand Up @@ -16560,13 +16646,16 @@ const { inspect } = __nccwpck_require__(3837);
const yaml = __nccwpck_require__(1917);
const core = __nccwpck_require__(2186);
const { Octokit } = __nccwpck_require__(1231);
const fetch = __nccwpck_require__(467);

main();

async function main() {
try {
``;
const octokit = new Octokit();
const octokit = new Octokit({
request: { fetch },
});
const { query, ...variables } = getAllInputs();

core.info(query);
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ const { inspect } = require("util");
const yaml = require("js-yaml");
const core = require("@actions/core");
const { Octokit } = require("@octokit/action");
const fetch = require("node-fetch");

main();

async function main() {
try {
``;
const octokit = new Octokit();
const octokit = new Octokit({
request: { fetch },
});
const { query, ...variables } = getAllInputs();

core.info(query);
Expand Down
Loading
Loading