Skip to content

Commit

Permalink
build(release): compiled action for 1.1.6
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
semantic-release-bot committed Sep 15, 2020
1 parent 8f22158 commit d8b1072
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ async function hook(state, request, route, parameters) {
/**
* Newly created tokens might not be accessible immediately after creation.
* In case of a 401 response, we retry with an exponential delay until more
* than one minute passes since the creation of the token.
* than five seconds pass since the creation of the token.
*
* @see https://github.com/octokit/auth-app.js/issues/65
*/
Expand All @@ -1327,18 +1327,22 @@ async function sendRequestWithRetries(request, options, createdAt, retries = 0)
}

if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
if (retries > 0) {
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1000}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
}

throw error;
}

++retries;
const awaitTime = retries * 1000;
console.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime}ms)`);
console.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1000}s)`);
await new Promise(resolve => setTimeout(resolve, awaitTime));
return sendRequestWithRetries(request, options, createdAt, retries);
}
}

const VERSION = "2.4.15";
const VERSION = "2.5.0";

const createAppAuth = function createAppAuth(options) {
const state = Object.assign({
Expand Down Expand Up @@ -2873,17 +2877,18 @@ async function getToken({

async function githubAppJwt({
id,
privateKey
privateKey,
now = Math.floor(Date.now() / 1000)
}) {
// When creating a JSON Web Token, it sets the "issued at time" (iat) to 30s
// in the past as we have seen people running situations where the GitHub API
// claimed the iat would be in future. It turned out the clocks on the
// different machine were not in sync.
const now = Math.floor(Date.now() / 1000) - 30;
const expiration = now + 60 * 10; // JWT expiration time (10 minute maximum)
const nowWithSafetyMargin = now - 30;
const expiration = nowWithSafetyMargin + 60 * 10; // JWT expiration time (10 minute maximum)

const payload = {
iat: now,
iat: nowWithSafetyMargin,
exp: expiration,
iss: id
};
Expand Down

0 comments on commit d8b1072

Please sign in to comment.