diff --git a/dist/query.js b/dist/query.js index 674d1485..9f849ca5 100644 --- a/dist/query.js +++ b/dist/query.js @@ -79619,8 +79619,9 @@ function wrapRequest2(state, request2, options) { return state.retryLimiter.schedule(doRequest, state, request2, options); } async function doRequest(state, request2, options) { - const isWrite = options.method !== "GET" && options.method !== "HEAD"; const { pathname } = new URL(options.url, "http://github.test"); + const isAuth = isAuthRequest(options.method, pathname); + const isWrite = !isAuth && options.method !== "GET" && options.method !== "HEAD"; const isSearch = options.method === "GET" && pathname.startsWith("/search/"); const isGraphQL = pathname.startsWith("/graphql"); const retryCount = ~~request2.retryCount; @@ -79637,7 +79638,7 @@ async function doRequest(state, request2, options) { if (isSearch) { await state.search.key(state.id).schedule(jobOptions, noop2); } - const req = state.global.key(state.id).schedule(jobOptions, request2, options); + const req = (isAuth ? state.auth : state.global).key(state.id).schedule(jobOptions, request2, options); if (isGraphQL) { const res = await req; if (res.data.errors != null && res.data.errors.some((error2) => error2.type === "RATE_LIMITED")) { @@ -79650,6 +79651,13 @@ async function doRequest(state, request2, options) { } return req; } +function isAuthRequest(method, pathname) { + return method === "PATCH" && // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-a-scoped-access-token + /^\/applications\/[^/]+\/token\/scoped$/.test(pathname) || method === "POST" && // https://docs.github.com/en/rest/apps/oauth-applications?apiVersion=2022-11-28#reset-a-token + (/^\/applications\/[^/]+\/token$/.test(pathname) || // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app + /^\/app\/installations\/[^/]+\/access_tokens$/.test(pathname) || // https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps + pathname === "/login/oauth/access_token"); +} var triggers_notification_paths_default = [ "/orgs/{org}/invitations", "/orgs/{org}/invitations/{invitation_id}", @@ -79687,6 +79695,11 @@ var createGroups = function(Bottleneck2, common) { maxConcurrent: 10, ...common }); + groups.auth = new Bottleneck2.Group({ + id: "octokit-auth", + maxConcurrent: 1, + ...common + }); groups.search = new Bottleneck2.Group({ id: "octokit-search", maxConcurrent: 1, diff --git a/dist/update-repo-task-status.js b/dist/update-repo-task-status.js index 7a54a23e..34bc2e53 100644 --- a/dist/update-repo-task-status.js +++ b/dist/update-repo-task-status.js @@ -48843,8 +48843,9 @@ function wrapRequest2(state, request2, options) { return state.retryLimiter.schedule(doRequest, state, request2, options); } async function doRequest(state, request2, options) { - const isWrite = options.method !== "GET" && options.method !== "HEAD"; const { pathname } = new URL(options.url, "http://github.test"); + const isAuth = isAuthRequest(options.method, pathname); + const isWrite = !isAuth && options.method !== "GET" && options.method !== "HEAD"; const isSearch = options.method === "GET" && pathname.startsWith("/search/"); const isGraphQL = pathname.startsWith("/graphql"); const retryCount = ~~request2.retryCount; @@ -48861,7 +48862,7 @@ async function doRequest(state, request2, options) { if (isSearch) { await state.search.key(state.id).schedule(jobOptions, noop2); } - const req = state.global.key(state.id).schedule(jobOptions, request2, options); + const req = (isAuth ? state.auth : state.global).key(state.id).schedule(jobOptions, request2, options); if (isGraphQL) { const res = await req; if (res.data.errors != null && res.data.errors.some((error) => error.type === "RATE_LIMITED")) { @@ -48874,6 +48875,13 @@ async function doRequest(state, request2, options) { } return req; } +function isAuthRequest(method, pathname) { + return method === "PATCH" && // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-a-scoped-access-token + /^\/applications\/[^/]+\/token\/scoped$/.test(pathname) || method === "POST" && // https://docs.github.com/en/rest/apps/oauth-applications?apiVersion=2022-11-28#reset-a-token + (/^\/applications\/[^/]+\/token$/.test(pathname) || // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app + /^\/app\/installations\/[^/]+\/access_tokens$/.test(pathname) || // https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps + pathname === "/login/oauth/access_token"); +} var triggers_notification_paths_default = [ "/orgs/{org}/invitations", "/orgs/{org}/invitations/{invitation_id}", @@ -48911,6 +48919,11 @@ var createGroups = function(Bottleneck2, common) { maxConcurrent: 10, ...common }); + groups.auth = new Bottleneck2.Group({ + id: "octokit-auth", + maxConcurrent: 1, + ...common + }); groups.search = new Bottleneck2.Group({ id: "octokit-search", maxConcurrent: 1, diff --git a/dist/update-repo-task-statuses.js b/dist/update-repo-task-statuses.js index fa1bfe89..111ffbb5 100644 --- a/dist/update-repo-task-statuses.js +++ b/dist/update-repo-task-statuses.js @@ -48845,8 +48845,9 @@ function wrapRequest2(state, request2, options) { return state.retryLimiter.schedule(doRequest, state, request2, options); } async function doRequest(state, request2, options) { - const isWrite = options.method !== "GET" && options.method !== "HEAD"; const { pathname } = new URL(options.url, "http://github.test"); + const isAuth = isAuthRequest(options.method, pathname); + const isWrite = !isAuth && options.method !== "GET" && options.method !== "HEAD"; const isSearch = options.method === "GET" && pathname.startsWith("/search/"); const isGraphQL = pathname.startsWith("/graphql"); const retryCount = ~~request2.retryCount; @@ -48863,7 +48864,7 @@ async function doRequest(state, request2, options) { if (isSearch) { await state.search.key(state.id).schedule(jobOptions, noop2); } - const req = state.global.key(state.id).schedule(jobOptions, request2, options); + const req = (isAuth ? state.auth : state.global).key(state.id).schedule(jobOptions, request2, options); if (isGraphQL) { const res = await req; if (res.data.errors != null && res.data.errors.some((error) => error.type === "RATE_LIMITED")) { @@ -48876,6 +48877,13 @@ async function doRequest(state, request2, options) { } return req; } +function isAuthRequest(method, pathname) { + return method === "PATCH" && // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-a-scoped-access-token + /^\/applications\/[^/]+\/token\/scoped$/.test(pathname) || method === "POST" && // https://docs.github.com/en/rest/apps/oauth-applications?apiVersion=2022-11-28#reset-a-token + (/^\/applications\/[^/]+\/token$/.test(pathname) || // https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app + /^\/app\/installations\/[^/]+\/access_tokens$/.test(pathname) || // https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps + pathname === "/login/oauth/access_token"); +} var triggers_notification_paths_default = [ "/orgs/{org}/invitations", "/orgs/{org}/invitations/{invitation_id}", @@ -48913,6 +48921,11 @@ var createGroups = function(Bottleneck2, common) { maxConcurrent: 10, ...common }); + groups.auth = new Bottleneck2.Group({ + id: "octokit-auth", + maxConcurrent: 1, + ...common + }); groups.search = new Bottleneck2.Group({ id: "octokit-search", maxConcurrent: 1, diff --git a/package-lock.json b/package-lock.json index 0d1ff2dd..a02b700b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@actions/tool-cache": "^2.0.2", "@octokit/action": "^7.0.2", "@octokit/plugin-retry": "^7.2.1", - "@octokit/plugin-throttling": "^9.6.0", + "@octokit/plugin-throttling": "^10.0.0", "ajv": "8.17.1", "form-data": "^4.0.2", "jszip": "3.10.1", @@ -3476,11 +3476,11 @@ } }, "node_modules/@octokit/plugin-throttling": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-9.6.0.tgz", - "integrity": "sha512-zn7m1N3vpJDaVzLqjCRdJ0cRzNiekHEWPi8Ww9xyPNrDt5PStHvVE0eR8wy4RSU8Eg7YO8MHyvn6sv25EGVhhg==", + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-10.0.0.tgz", + "integrity": "sha512-Kuq5/qs0DVYTHZuBAzCZStCzo2nKvVRo/TDNhCcpC2TKiOGz/DisXMCvjt3/b5kr6SCI1Y8eeeJTHBxxpFvZEg==", "dependencies": { - "@octokit/types": "^13.7.0", + "@octokit/types": "^14.0.0", "bottleneck": "^2.15.3" }, "engines": { @@ -3490,6 +3490,19 @@ "@octokit/core": "^6.1.3" } }, + "node_modules/@octokit/plugin-throttling/node_modules/@octokit/openapi-types": { + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-25.0.0.tgz", + "integrity": "sha512-FZvktFu7HfOIJf2BScLKIEYjDsw6RKc7rBJCdvCTfKsVnx2GEB/Nbzjr29DUdb7vQhlzS/j8qDzdditP0OC6aw==" + }, + "node_modules/@octokit/plugin-throttling/node_modules/@octokit/types": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-14.0.0.tgz", + "integrity": "sha512-VVmZP0lEhbo2O1pdq63gZFiGCKkm8PPp8AUOijlwPO6hojEVjspA0MWKP7E4hbvGxzFKNqKr6p0IYtOH/Wf/zA==", + "dependencies": { + "@octokit/openapi-types": "^25.0.0" + } + }, "node_modules/@octokit/request": { "version": "9.2.3", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.2.3.tgz", diff --git a/package.json b/package.json index ed78a323..d839021b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@actions/tool-cache": "^2.0.2", "@octokit/action": "^7.0.2", "@octokit/plugin-retry": "^7.2.1", - "@octokit/plugin-throttling": "^9.6.0", + "@octokit/plugin-throttling": "^10.0.0", "ajv": "8.17.1", "form-data": "^4.0.2", "jszip": "3.10.1",