@octokit/auth-app
Advanced tools
Comparing version 7.1.1 to 7.1.2
@@ -14,7 +14,12 @@ // pkg/dist-src/index.js | ||
try { | ||
const appAuthentication = await githubAppJwt({ | ||
const authOptions = { | ||
id: appId, | ||
privateKey, | ||
now: timeDifference && Math.floor(Date.now() / 1e3) + timeDifference | ||
}); | ||
privateKey | ||
}; | ||
if (timeDifference) { | ||
Object.assign(authOptions, { | ||
now: Math.floor(Date.now() / 1e3) + timeDifference | ||
}); | ||
} | ||
const appAuthentication = await githubAppJwt(authOptions); | ||
return { | ||
@@ -191,2 +196,22 @@ type: "app", | ||
const request = customRequest || state.request; | ||
const payload = { | ||
installation_id: installationId, | ||
mediaType: { | ||
previews: ["machine-man"] | ||
}, | ||
headers: { | ||
authorization: `bearer ${appAuthentication.token}` | ||
} | ||
}; | ||
if (options.repositoryIds) { | ||
Object.assign(payload, { repository_ids: options.repositoryIds }); | ||
} | ||
if (options.repositoryNames) { | ||
Object.assign(payload, { | ||
repositories: options.repositoryNames | ||
}); | ||
} | ||
if (options.permissions) { | ||
Object.assign(payload, { permissions: options.permissions }); | ||
} | ||
const { | ||
@@ -201,14 +226,6 @@ data: { | ||
} | ||
} = await request("POST /app/installations/{installation_id}/access_tokens", { | ||
installation_id: installationId, | ||
repository_ids: options.repositoryIds, | ||
repositories: options.repositoryNames, | ||
permissions: options.permissions, | ||
mediaType: { | ||
previews: ["machine-man"] | ||
}, | ||
headers: { | ||
authorization: `bearer ${appAuthentication.token}` | ||
} | ||
}); | ||
} = await request( | ||
"POST /app/installations/{installation_id}/access_tokens", | ||
payload | ||
); | ||
const permissions = permissionsOptional || {}; | ||
@@ -219,3 +236,3 @@ const repositorySelection = repositorySelectionOptional || "all"; | ||
const createdAt = (/* @__PURE__ */ new Date()).toISOString(); | ||
await set(state.cache, optionsWithInstallationTokenFromState, { | ||
const cacheOptions = { | ||
token, | ||
@@ -227,6 +244,9 @@ createdAt, | ||
repositoryIds, | ||
repositoryNames, | ||
singleFileName | ||
}); | ||
return toTokenAuthentication({ | ||
repositoryNames | ||
}; | ||
if (singleFileName) { | ||
Object.assign(payload, { singleFileName }); | ||
} | ||
await set(state.cache, optionsWithInstallationTokenFromState, cacheOptions); | ||
const cacheData = { | ||
installationId, | ||
@@ -239,5 +259,8 @@ token, | ||
repositoryIds, | ||
repositoryNames, | ||
singleFileName | ||
}); | ||
repositoryNames | ||
}; | ||
if (singleFileName) { | ||
Object.assign(cacheData, { singleFileName }); | ||
} | ||
return toTokenAuthentication(cacheData); | ||
} | ||
@@ -393,3 +416,3 @@ | ||
// pkg/dist-src/version.js | ||
var VERSION = "7.1.1"; | ||
var VERSION = "7.1.2"; | ||
@@ -396,0 +419,0 @@ // pkg/dist-src/index.js |
@@ -8,7 +8,12 @@ import githubAppJwt from "universal-github-app-jwt"; | ||
try { | ||
const appAuthentication = await githubAppJwt({ | ||
const authOptions = { | ||
id: appId, | ||
privateKey, | ||
now: timeDifference && Math.floor(Date.now() / 1e3) + timeDifference | ||
}); | ||
privateKey | ||
}; | ||
if (timeDifference) { | ||
Object.assign(authOptions, { | ||
now: Math.floor(Date.now() / 1e3) + timeDifference | ||
}); | ||
} | ||
const appAuthentication = await githubAppJwt(authOptions); | ||
return { | ||
@@ -15,0 +20,0 @@ type: "app", |
@@ -53,2 +53,22 @@ import { get, set } from "./cache.js"; | ||
const request = customRequest || state.request; | ||
const payload = { | ||
installation_id: installationId, | ||
mediaType: { | ||
previews: ["machine-man"] | ||
}, | ||
headers: { | ||
authorization: `bearer ${appAuthentication.token}` | ||
} | ||
}; | ||
if (options.repositoryIds) { | ||
Object.assign(payload, { repository_ids: options.repositoryIds }); | ||
} | ||
if (options.repositoryNames) { | ||
Object.assign(payload, { | ||
repositories: options.repositoryNames | ||
}); | ||
} | ||
if (options.permissions) { | ||
Object.assign(payload, { permissions: options.permissions }); | ||
} | ||
const { | ||
@@ -63,14 +83,6 @@ data: { | ||
} | ||
} = await request("POST /app/installations/{installation_id}/access_tokens", { | ||
installation_id: installationId, | ||
repository_ids: options.repositoryIds, | ||
repositories: options.repositoryNames, | ||
permissions: options.permissions, | ||
mediaType: { | ||
previews: ["machine-man"] | ||
}, | ||
headers: { | ||
authorization: `bearer ${appAuthentication.token}` | ||
} | ||
}); | ||
} = await request( | ||
"POST /app/installations/{installation_id}/access_tokens", | ||
payload | ||
); | ||
const permissions = permissionsOptional || {}; | ||
@@ -81,3 +93,3 @@ const repositorySelection = repositorySelectionOptional || "all"; | ||
const createdAt = (/* @__PURE__ */ new Date()).toISOString(); | ||
await set(state.cache, optionsWithInstallationTokenFromState, { | ||
const cacheOptions = { | ||
token, | ||
@@ -89,6 +101,9 @@ createdAt, | ||
repositoryIds, | ||
repositoryNames, | ||
singleFileName | ||
}); | ||
return toTokenAuthentication({ | ||
repositoryNames | ||
}; | ||
if (singleFileName) { | ||
Object.assign(payload, { singleFileName }); | ||
} | ||
await set(state.cache, optionsWithInstallationTokenFromState, cacheOptions); | ||
const cacheData = { | ||
installationId, | ||
@@ -101,5 +116,8 @@ token, | ||
repositoryIds, | ||
repositoryNames, | ||
singleFileName | ||
}); | ||
repositoryNames | ||
}; | ||
if (singleFileName) { | ||
Object.assign(cacheData, { singleFileName }); | ||
} | ||
return toTokenAuthentication(cacheData); | ||
} | ||
@@ -106,0 +124,0 @@ export { |
@@ -1,4 +0,4 @@ | ||
const VERSION = "7.1.1"; | ||
const VERSION = "7.1.2"; | ||
export { | ||
VERSION | ||
}; |
import type { AppAuthentication, State } from "./types.js"; | ||
export declare function getAppAuthentication({ appId, privateKey, timeDifference, }: State & { | ||
timeDifference?: number; | ||
timeDifference?: number | undefined; | ||
}): Promise<AppAuthentication>; |
@@ -1,4 +0,4 @@ | ||
import * as OctokitTypes from "@octokit/types"; | ||
import { LRUCache } from "lru-cache"; | ||
import * as OAuthAppAuth from "@octokit/auth-oauth-app"; | ||
import type * as OctokitTypes from "@octokit/types"; | ||
import type { LRUCache } from "lru-cache"; | ||
import type * as OAuthAppAuth from "@octokit/auth-oauth-app"; | ||
type OAuthStrategyOptions = { | ||
@@ -102,5 +102,5 @@ clientId?: string; | ||
repositorySelection: REPOSITORY_SELECTION; | ||
repositoryIds?: number[]; | ||
repositoryNames?: string[]; | ||
singleFileName?: string; | ||
repositoryIds?: number[] | undefined; | ||
repositoryNames?: string[] | undefined; | ||
singleFileName?: string | undefined; | ||
}; | ||
@@ -107,0 +107,0 @@ export type CacheData = InstallationAccessTokenData; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "7.1.1"; | ||
export declare const VERSION = "7.1.2"; |
@@ -8,3 +8,3 @@ { | ||
"type": "module", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "GitHub App authentication for JavaScript", | ||
@@ -26,3 +26,3 @@ "repository": "github:octokit/auth-app.js", | ||
"@octokit/types": "^13.4.1", | ||
"lru-cache": "^10.0.0", | ||
"lru-cache": "npm:@wolfy1339/lru-cache@^11.0.2-patch.1", | ||
"universal-github-app-jwt": "^2.2.0", | ||
@@ -32,14 +32,13 @@ "universal-user-agent": "^7.0.0" | ||
"devDependencies": { | ||
"@octokit/tsconfig": "^3.0.0", | ||
"@types/fetch-mock": "^7.3.1", | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "^20.0.0", | ||
"esbuild": "^0.23.0", | ||
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1", | ||
"glob": "^10.2.5", | ||
"jest": "^29.0.0", | ||
"@octokit/tsconfig": "^4.0.0", | ||
"@types/node": "^22.0.0", | ||
"@vitest/coverage-v8": "^2.1.2", | ||
"@vitest/ui": "^2.1.2", | ||
"esbuild": "^0.24.0", | ||
"fetch-mock": "^11.0.0", | ||
"glob": "^11.0.0", | ||
"prettier": "3.3.3", | ||
"semantic-release-plugin-update-version-in-files": "^1.0.0", | ||
"ts-jest": "^29.0.0", | ||
"typescript": "^5.0.0" | ||
"typescript": "^5.0.0", | ||
"vitest": "^2.1.2" | ||
}, | ||
@@ -46,0 +45,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99229
11
1099
+ Added@wolfy1339/lru-cache@11.0.2-patch.1(transitive)
- Removedlru-cache@10.4.3(transitive)