Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@octokit/auth-app

Package Overview
Dependencies
Maintainers
2
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/auth-app - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

19

dist-node/index.js

@@ -19,3 +19,3 @@ 'use strict';

const appAuthentication = await universalGithubAppJwt.githubAppJwt({
id,
id: +id,
privateKey,

@@ -119,2 +119,17 @@ now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference

if (options.factory) {
// @ts-ignore if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
return options.factory({
cache: state.cache,
id: state.id,
privateKey: state.privateKey,
log: state.log,
request: state.request,
clientId: state.clientId,
clientSecret: state.clientSecret,
timeDifference: state.timeDifference,
installationId
});
}
const optionsWithInstallationTokenFromState = Object.assign({

@@ -416,3 +431,3 @@ installationId

const VERSION = "2.7.0";
const VERSION = "2.8.0";

@@ -419,0 +434,0 @@ const createAppAuth = function createAppAuth(options) {

2

dist-src/get-app-authentication.js
import { githubAppJwt } from "universal-github-app-jwt";
export async function getAppAuthentication({ id, privateKey, timeDifference, }) {
const appAuthentication = await githubAppJwt({
id,
id: +id,
privateKey,

@@ -6,0 +6,0 @@ now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference,

@@ -9,2 +9,16 @@ import { get, set } from "./cache";

}
if (options.factory) {
// @ts-ignore if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
return options.factory({
cache: state.cache,
id: state.id,
privateKey: state.privateKey,
log: state.log,
request: state.request,
clientId: state.clientId,
clientSecret: state.clientSecret,
timeDifference: state.timeDifference,
installationId,
});
}
const optionsWithInstallationTokenFromState = Object.assign({ installationId }, options);

@@ -11,0 +25,0 @@ if (!options.refresh) {

@@ -1,1 +0,1 @@

export const VERSION = "2.7.0";
export const VERSION = "2.8.0";

@@ -59,11 +59,12 @@ import * as OctokitTypes from "@octokit/types";

export declare type Authentication = AppAuthentication | InstallationAccessTokenAuthentication | OAuthAccesTokenAuthentication;
export declare type StrategyOptions = {
declare type OAuthStrategyOptions = {
clientId?: string;
clientSecret?: string;
};
export declare type StrategyOptions = OAuthStrategyOptions & {
id: number | string;
privateKey: string;
installationId?: number | string;
clientId?: string;
clientSecret?: string;
request?: OctokitTypes.RequestInterface;
cache?: Cache;
timeDifference?: number;
log?: {

@@ -74,7 +75,4 @@ warn: (message: string, additionalInfo?: object) => any;

};
export declare type StrategyOptionsWithDefaults = StrategyOptions & {
id: number;
request: OctokitTypes.RequestInterface;
cache: Cache;
};
export declare type FactoryOptions = Required<Omit<StrategyOptions, keyof State>> & State;
export declare type StrategyOptionsWithDefaults = StrategyOptions & Required<Omit<StrategyOptions, keyof OAuthStrategyOptions | "installationId">>;
export declare type Permissions = {

@@ -88,2 +86,3 @@ [name: string]: string;

refresh?: boolean;
factory?: (options: FactoryOptions) => unknown;
};

@@ -101,11 +100,5 @@ export declare type OAuthOptions = {

};
export declare type State = StrategyOptions & {
id: number;
installationId?: number;
request: OctokitTypes.RequestInterface;
cache: Cache;
log: {
warn: (message: string, additionalInfo?: object) => any;
[key: string]: any;
};
export declare type State = StrategyOptionsWithDefaults & {
timeDifference: number;
};
export {};

@@ -1,1 +0,1 @@

export declare const VERSION = "2.7.0";
export declare const VERSION = "2.8.0";

@@ -9,3 +9,3 @@ import { getUserAgent } from 'universal-user-agent';

const appAuthentication = await githubAppJwt({
id,
id: +id,
privateKey,

@@ -104,2 +104,16 @@ now: timeDifference && Math.floor(Date.now() / 1000) + timeDifference,

}
if (options.factory) {
// @ts-ignore if `options.factory` is set, the return type for `auth()` should be `Promise<ReturnType<options.factory>>`
return options.factory({
cache: state.cache,
id: state.id,
privateKey: state.privateKey,
log: state.log,
request: state.request,
clientId: state.clientId,
clientSecret: state.clientSecret,
timeDifference: state.timeDifference,
installationId,
});
}
const optionsWithInstallationTokenFromState = Object.assign({ installationId }, options);

@@ -326,3 +340,3 @@ if (!options.refresh) {

const VERSION = "2.7.0";
const VERSION = "2.8.0";

@@ -329,0 +343,0 @@ const createAppAuth = function createAppAuth(options) {

{
"name": "@octokit/auth-app",
"description": "GitHub App authentication for JavaScript",
"version": "2.7.0",
"version": "2.8.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "files": [

@@ -197,4 +197,4 @@ # auth-app.js

createAppAuth({
clientId: 123,
clientSecret: "secret",
id: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
request: request.defaults({

@@ -220,4 +220,4 @@ baseUrl: "https://ghe.my-company.com/api/v3",

createAppAuth({
clientId: 123,
clientSecret: "secret",
id: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
cache: {

@@ -247,4 +247,4 @@ async get(key) {

createAppAuth({
clientId: 123,
clientSecret: "secret",
id: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
log: require("console-log-level")({ level: "info" }),

@@ -320,5 +320,3 @@ });

<br>
The permissions granted to the access token. The permissions object includes the permission names and their access type. For a complete list of permissions and allowable values, see <a href="https://developer.github.com/apps/building-github-apps/creating-github-apps-using-url-parameters/#github-app-permissions">GitHub App permissions</a>.<br>
<br>
⚠️ <strong>Required for GitHub Enterprise Server 2.18 and below. Specify an empty object `{}` for all permissions granted by the installation.</strong>
The permissions granted to the access token. The permissions object includes the permission names and their access type. For a complete list of permissions and allowable values, see <a href="https://developer.github.com/apps/building-github-apps/creating-github-apps-using-url-parameters/#github-app-permissions">GitHub App permissions</a>.
</td>

@@ -328,2 +326,31 @@ </tr>

<th>
<code>factory</code>
</th>
<th>
<code>function</code>
</th>
<td>
Only relevant if `type` is set to `"installation"`.
When the `factory` option is, the `auth({type: "installation", installationId, factory })` call with resolve with whatever the factory function returns. The `factory` function will be called with all the strategy option that `auth` was created with, plus the additional options passed to `auth`, besides `type` and `factory`.
For example, you can create a new `auth` instance for an installation which shares the internal state (especially the access token cache) with the calling `auth` instance:
```js
const appAuth = createAppAuth({
id: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
});
const installationAuth123 = await appAuth({
type: "installation",
installationId: 123,
factory: createAppAuth,
});
```
</td>
</tr>
<tr>
<th>
<code>refresh</code>

@@ -330,0 +357,0 @@ </th>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc