mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 08:06:23 +00:00
Bump Octokit core, REST pagination, REST methdos
This commit is contained in:
375
dist/index.js
vendored
375
dist/index.js
vendored
@@ -211,11 +211,7 @@ const Endpoints = {
|
||||
unstarRepoForAuthenticatedUser: ["DELETE /user/starred/{owner}/{repo}"]
|
||||
},
|
||||
apps: {
|
||||
addRepoToInstallation: ["PUT /user/installations/{installation_id}/repositories/{repository_id}", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
addRepoToInstallation: ["PUT /user/installations/{installation_id}/repositories/{repository_id}"],
|
||||
checkToken: ["POST /applications/{client_id}/token"],
|
||||
createContentAttachment: ["POST /content_references/{content_reference_id}/attachments", {
|
||||
mediaType: {
|
||||
@@ -223,81 +219,29 @@ const Endpoints = {
|
||||
}
|
||||
}],
|
||||
createFromManifest: ["POST /app-manifests/{code}/conversions"],
|
||||
createInstallationAccessToken: ["POST /app/installations/{installation_id}/access_tokens", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
createInstallationAccessToken: ["POST /app/installations/{installation_id}/access_tokens"],
|
||||
deleteAuthorization: ["DELETE /applications/{client_id}/grant"],
|
||||
deleteInstallation: ["DELETE /app/installations/{installation_id}", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
deleteInstallation: ["DELETE /app/installations/{installation_id}"],
|
||||
deleteToken: ["DELETE /applications/{client_id}/token"],
|
||||
getAuthenticated: ["GET /app", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getBySlug: ["GET /apps/{app_slug}", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getInstallation: ["GET /app/installations/{installation_id}", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getOrgInstallation: ["GET /orgs/{org}/installation", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getRepoInstallation: ["GET /repos/{owner}/{repo}/installation", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getAuthenticated: ["GET /app"],
|
||||
getBySlug: ["GET /apps/{app_slug}"],
|
||||
getInstallation: ["GET /app/installations/{installation_id}"],
|
||||
getOrgInstallation: ["GET /orgs/{org}/installation"],
|
||||
getRepoInstallation: ["GET /repos/{owner}/{repo}/installation"],
|
||||
getSubscriptionPlanForAccount: ["GET /marketplace_listing/accounts/{account_id}"],
|
||||
getSubscriptionPlanForAccountStubbed: ["GET /marketplace_listing/stubbed/accounts/{account_id}"],
|
||||
getUserInstallation: ["GET /users/{username}/installation", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
getUserInstallation: ["GET /users/{username}/installation"],
|
||||
listAccountsForPlan: ["GET /marketplace_listing/plans/{plan_id}/accounts"],
|
||||
listAccountsForPlanStubbed: ["GET /marketplace_listing/stubbed/plans/{plan_id}/accounts"],
|
||||
listInstallationReposForAuthenticatedUser: ["GET /user/installations/{installation_id}/repositories", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
listInstallations: ["GET /app/installations", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
listInstallationsForAuthenticatedUser: ["GET /user/installations", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
listInstallationReposForAuthenticatedUser: ["GET /user/installations/{installation_id}/repositories"],
|
||||
listInstallations: ["GET /app/installations"],
|
||||
listInstallationsForAuthenticatedUser: ["GET /user/installations"],
|
||||
listPlans: ["GET /marketplace_listing/plans"],
|
||||
listPlansStubbed: ["GET /marketplace_listing/stubbed/plans"],
|
||||
listReposAccessibleToInstallation: ["GET /installation/repositories", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
listReposAccessibleToInstallation: ["GET /installation/repositories"],
|
||||
listSubscriptionsForAuthenticatedUser: ["GET /user/marketplace_purchases"],
|
||||
listSubscriptionsForAuthenticatedUserStubbed: ["GET /user/marketplace_purchases/stubbed"],
|
||||
removeRepoFromInstallation: ["DELETE /user/installations/{installation_id}/repositories/{repository_id}", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
removeRepoFromInstallation: ["DELETE /user/installations/{installation_id}/repositories/{repository_id}"],
|
||||
resetToken: ["PATCH /applications/{client_id}/token"],
|
||||
revokeInstallationAccessToken: ["DELETE /installation/token"],
|
||||
suspendInstallation: ["PUT /app/installations/{installation_id}/suspended"],
|
||||
@@ -369,8 +313,15 @@ const Endpoints = {
|
||||
}]
|
||||
},
|
||||
codeScanning: {
|
||||
getAlert: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_id}"],
|
||||
listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"]
|
||||
getAlert: ["GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}", {}, {
|
||||
renamedParameters: {
|
||||
alert_id: "alert_number"
|
||||
}
|
||||
}],
|
||||
listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"],
|
||||
listRecentAnalyses: ["GET /repos/{owner}/{repo}/code-scanning/analyses"],
|
||||
updateAlert: ["PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}"],
|
||||
uploadSarif: ["POST /repos/{owner}/{repo}/code-scanning/sarifs"]
|
||||
},
|
||||
codesOfConduct: {
|
||||
getAllCodesOfConduct: ["GET /codes_of_conduct", {
|
||||
@@ -612,11 +563,7 @@ const Endpoints = {
|
||||
getMembershipForUser: ["GET /orgs/{org}/memberships/{username}"],
|
||||
getWebhook: ["GET /orgs/{org}/hooks/{hook_id}"],
|
||||
list: ["GET /organizations"],
|
||||
listAppInstallations: ["GET /orgs/{org}/installations", {
|
||||
mediaType: {
|
||||
previews: ["machine-man"]
|
||||
}
|
||||
}],
|
||||
listAppInstallations: ["GET /orgs/{org}/installations"],
|
||||
listBlockedUsers: ["GET /orgs/{org}/blocks"],
|
||||
listForAuthenticatedUser: ["GET /user/orgs"],
|
||||
listForUser: ["GET /users/{username}/orgs"],
|
||||
@@ -1229,7 +1176,7 @@ const Endpoints = {
|
||||
}
|
||||
};
|
||||
|
||||
const VERSION = "4.1.2";
|
||||
const VERSION = "4.2.1";
|
||||
|
||||
function endpointsToMethods(octokit, endpointsMap) {
|
||||
const newMethods = {};
|
||||
@@ -1658,7 +1605,7 @@ exports.getState = getState;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const VERSION = "2.3.0";
|
||||
const VERSION = "2.6.0";
|
||||
|
||||
/**
|
||||
* Some “list” response that can be paginated have a different response structure
|
||||
@@ -1711,26 +1658,23 @@ function iterator(octokit, route, parameters) {
|
||||
let url = options.url;
|
||||
return {
|
||||
[Symbol.asyncIterator]: () => ({
|
||||
next() {
|
||||
if (!url) {
|
||||
return Promise.resolve({
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
return requestMethod({
|
||||
async next() {
|
||||
if (!url) return {
|
||||
done: true
|
||||
};
|
||||
const response = await requestMethod({
|
||||
method,
|
||||
url,
|
||||
headers
|
||||
}).then(normalizePaginatedListResponse).then(response => {
|
||||
// `response.headers.link` format:
|
||||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
|
||||
// sets `url` to undefined if "next" URL is not present or `link` header is not set
|
||||
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
|
||||
return {
|
||||
value: response
|
||||
};
|
||||
});
|
||||
const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format:
|
||||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
|
||||
// sets `url` to undefined if "next" URL is not present or `link` header is not set
|
||||
|
||||
url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
|
||||
return {
|
||||
value: normalizedResponse
|
||||
};
|
||||
}
|
||||
|
||||
})
|
||||
@@ -1768,6 +1712,10 @@ function gather(octokit, results, iterator, mapFn) {
|
||||
});
|
||||
}
|
||||
|
||||
const composePaginateRest = Object.assign(paginate, {
|
||||
iterator
|
||||
});
|
||||
|
||||
/**
|
||||
* @param octokit Octokit instance
|
||||
* @param options Options passed to Octokit constructor
|
||||
@@ -1782,6 +1730,7 @@ function paginateRest(octokit) {
|
||||
}
|
||||
paginateRest.VERSION = VERSION;
|
||||
|
||||
exports.composePaginateRest = composePaginateRest;
|
||||
exports.paginateRest = paginateRest;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
@@ -2128,18 +2077,18 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
||||
|
||||
var endpoint = __webpack_require__(440);
|
||||
var universalUserAgent = __webpack_require__(429);
|
||||
var isPlainObject = _interopDefault(__webpack_require__(840));
|
||||
var isPlainObject = __webpack_require__(287);
|
||||
var nodeFetch = _interopDefault(__webpack_require__(467));
|
||||
var requestError = __webpack_require__(537);
|
||||
|
||||
const VERSION = "5.4.7";
|
||||
const VERSION = "5.4.10";
|
||||
|
||||
function getBufferResponse(response) {
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
|
||||
function fetchWrapper(requestOptions) {
|
||||
if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
|
||||
if (isPlainObject.isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
|
||||
requestOptions.body = JSON.stringify(requestOptions.body);
|
||||
}
|
||||
|
||||
@@ -2296,6 +2245,52 @@ function toCommandValue(input) {
|
||||
exports.toCommandValue = toCommandValue;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 287:
|
||||
/***/ (function(__unusedmodule, exports) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
exports.isPlainObject = isPlainObject;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 294:
|
||||
@@ -2837,9 +2832,7 @@ exports.getOctokit = getOctokit;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var isPlainObject = _interopDefault(__webpack_require__(840));
|
||||
var isPlainObject = __webpack_require__(287);
|
||||
var universalUserAgent = __webpack_require__(429);
|
||||
|
||||
function lowercaseKeys(object) {
|
||||
@@ -2856,7 +2849,7 @@ function lowercaseKeys(object) {
|
||||
function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach(key => {
|
||||
if (isPlainObject(options[key])) {
|
||||
if (isPlainObject.isPlainObject(options[key])) {
|
||||
if (!(key in defaults)) Object.assign(result, {
|
||||
[key]: options[key]
|
||||
});else result[key] = mergeDeep(defaults[key], options[key]);
|
||||
@@ -2869,6 +2862,16 @@ function mergeDeep(defaults, options) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === undefined) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
@@ -2883,7 +2886,10 @@ function merge(defaults, route, options) {
|
||||
} // lowercase header names before merging with defaults to avoid duplicates
|
||||
|
||||
|
||||
options.headers = lowercaseKeys(options.headers);
|
||||
options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging
|
||||
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten
|
||||
|
||||
if (defaults && defaults.mediaType.previews.length) {
|
||||
@@ -3105,7 +3111,7 @@ function parse(options) {
|
||||
// https://fetch.spec.whatwg.org/#methods
|
||||
let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible
|
||||
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{+$1}");
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later
|
||||
@@ -3119,9 +3125,9 @@ function parse(options) {
|
||||
|
||||
const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
|
||||
if (!isBinaryRequset) {
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
|
||||
headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(",");
|
||||
@@ -3190,7 +3196,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION = "6.0.5";
|
||||
const VERSION = "6.0.9";
|
||||
|
||||
const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url.
|
||||
// So we use RequestParameters and add method as additional required property.
|
||||
@@ -5094,7 +5100,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var request = __webpack_require__(234);
|
||||
var universalUserAgent = __webpack_require__(429);
|
||||
|
||||
const VERSION = "4.5.4";
|
||||
const VERSION = "4.5.7";
|
||||
|
||||
class GraphqlError extends Error {
|
||||
constructor(request, response) {
|
||||
@@ -5117,13 +5123,18 @@ class GraphqlError extends Error {
|
||||
}
|
||||
|
||||
const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query", "mediaType"];
|
||||
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||||
function graphql(request, query, options) {
|
||||
options = typeof query === "string" ? options = Object.assign({
|
||||
if (typeof query === "string" && options && "query" in options) {
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
||||
}
|
||||
|
||||
const parsedOptions = typeof query === "string" ? Object.assign({
|
||||
query
|
||||
}, options) : options = query;
|
||||
const requestOptions = Object.keys(options).reduce((result, key) => {
|
||||
}, options) : query;
|
||||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
||||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||||
result[key] = options[key];
|
||||
result[key] = parsedOptions[key];
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5131,9 +5142,17 @@ function graphql(request, query, options) {
|
||||
result.variables = {};
|
||||
}
|
||||
|
||||
result.variables[key] = options[key];
|
||||
result.variables[key] = parsedOptions[key];
|
||||
return result;
|
||||
}, {});
|
||||
}, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
|
||||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
|
||||
|
||||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
|
||||
|
||||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||||
}
|
||||
|
||||
return request(requestOptions).then(response => {
|
||||
if (response.data.errors) {
|
||||
const headers = {};
|
||||
@@ -5425,56 +5444,43 @@ var request = __webpack_require__(234);
|
||||
var graphql = __webpack_require__(668);
|
||||
var authToken = __webpack_require__(334);
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
function _objectWithoutPropertiesLoose(source, excluded) {
|
||||
if (source == null) return {};
|
||||
var target = {};
|
||||
var sourceKeys = Object.keys(source);
|
||||
var key, i;
|
||||
|
||||
for (i = 0; i < sourceKeys.length; i++) {
|
||||
key = sourceKeys[i];
|
||||
if (excluded.indexOf(key) >= 0) continue;
|
||||
target[key] = source[key];
|
||||
}
|
||||
|
||||
return obj;
|
||||
return target;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
function _objectWithoutProperties(source, excluded) {
|
||||
if (source == null) return {};
|
||||
|
||||
var target = _objectWithoutPropertiesLoose(source, excluded);
|
||||
|
||||
var key, i;
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
});
|
||||
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
||||
key = sourceSymbolKeys[i];
|
||||
if (excluded.indexOf(key) >= 0) continue;
|
||||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const VERSION = "3.1.2";
|
||||
const VERSION = "3.2.1";
|
||||
|
||||
class Octokit {
|
||||
constructor(options = {}) {
|
||||
@@ -5506,9 +5512,7 @@ class Octokit {
|
||||
}
|
||||
|
||||
this.request = request.request.defaults(requestDefaults);
|
||||
this.graphql = graphql.withCustomRequest(this.request).defaults(_objectSpread2(_objectSpread2({}, requestDefaults), {}, {
|
||||
baseUrl: requestDefaults.baseUrl.replace(/\/api\/v3$/, "/api")
|
||||
}));
|
||||
this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults);
|
||||
this.log = Object.assign({
|
||||
debug: () => {},
|
||||
info: () => {},
|
||||
@@ -5516,7 +5520,7 @@ class Octokit {
|
||||
error: console.error.bind(console)
|
||||
}, options.log);
|
||||
this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
|
||||
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registred.
|
||||
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
|
||||
// (2) If only `options.auth` is set, use the default token authentication strategy.
|
||||
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
|
||||
// TODO: type `options.auth` based on `options.authStrategy`.
|
||||
@@ -5535,8 +5539,21 @@ class Octokit {
|
||||
this.auth = auth;
|
||||
}
|
||||
} else {
|
||||
const auth = options.authStrategy(Object.assign({
|
||||
request: this.request
|
||||
const {
|
||||
authStrategy
|
||||
} = options,
|
||||
otherOptions = _objectWithoutProperties(options, ["authStrategy"]);
|
||||
|
||||
const auth = authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
log: this.log,
|
||||
// we pass the current octokit instance as well as its constructor options
|
||||
// to allow for authentication strategies that return a new octokit instance
|
||||
// that shares the same internal state as the current one. The original
|
||||
// requirement for this was the "event-octokit" authentication strategy
|
||||
// of https://github.com/probot/octokit-auth-probot.
|
||||
octokit: this,
|
||||
octokitOptions: otherOptions
|
||||
}, options.auth)); // @ts-ignore ¯\_(ツ)_/¯
|
||||
|
||||
hook.wrap("request", auth.hook);
|
||||
@@ -5624,50 +5641,6 @@ function removeHook (state, name, method) {
|
||||
|
||||
module.exports = require("url");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 840:
|
||||
/***/ (function(module) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
function isObject(o) {
|
||||
return Object.prototype.toString.call(o) === '[object Object]';
|
||||
}
|
||||
|
||||
function isPlainObject(o) {
|
||||
var ctor,prot;
|
||||
|
||||
if (isObject(o) === false) return false;
|
||||
|
||||
// If has modified constructor
|
||||
ctor = o.constructor;
|
||||
if (ctor === undefined) return true;
|
||||
|
||||
// If has modified prototype
|
||||
prot = ctor.prototype;
|
||||
if (isObject(prot) === false) return false;
|
||||
|
||||
// If constructor does not have an Object-specific method
|
||||
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Most likely a plain Object
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = isPlainObject;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 875:
|
||||
|
||||
Reference in New Issue
Block a user