@octokit/oauth-app
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -64,3 +64,3 @@ 'use strict'; | ||
const VERSION = "3.2.0"; | ||
const VERSION = "3.3.0"; | ||
@@ -499,3 +499,2 @@ function addEventHandler(state, eventName, eventHandler) { | ||
const { | ||
// @ts-expect-error scopes won't be set for GitHub Apps | ||
authentication: { | ||
@@ -502,0 +501,0 @@ token, |
@@ -18,3 +18,4 @@ import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; | ||
const Octokit = options.Octokit || OAuthAppOctokit; | ||
this.type = (options.clientType || "oauth-app"); | ||
this.type = (options.clientType || | ||
"oauth-app"); | ||
const octokit = new Octokit({ | ||
@@ -21,0 +22,0 @@ authStrategy: createOAuthAppAuth, |
@@ -70,5 +70,3 @@ import { parseRequest } from "./parse-request"; | ||
} | ||
const { | ||
// @ts-expect-error scopes won't be set for GitHub Apps | ||
authentication: { token, scopes }, } = await app.createToken({ | ||
const { authentication: { token, scopes }, } = await app.createToken({ | ||
state: oauthState, | ||
@@ -75,0 +73,0 @@ code, |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "3.2.0"; | ||
export const VERSION = "3.3.0"; |
@@ -1,2 +0,2 @@ | ||
import { EventHandler, EventAndActionName, State, ClientType, OAuthAppOctokitClassType } from "./types"; | ||
export declare function addEventHandler(state: State, eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<ClientType, OAuthAppOctokitClassType>): void; | ||
import { EventHandler, EventAndActionName, State, ClientType, Options } from "./types"; | ||
export declare function addEventHandler(state: State, eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<Options<ClientType>>): void; |
@@ -1,2 +0,2 @@ | ||
import { State, EventHandlerContext, ClientType, OAuthAppOctokitClassType } from "./types"; | ||
export declare function emitEvent(state: State, context: EventHandlerContext<ClientType, OAuthAppOctokitClassType>): Promise<void>; | ||
import { State, EventHandlerContext, ClientType, Options } from "./types"; | ||
export declare function emitEvent(state: State, context: EventHandlerContext<Options<ClientType>>): Promise<void>; |
@@ -10,21 +10,32 @@ import { GetUserOctokitWithStateInterface } from "./methods/get-user-octokit"; | ||
import { DeleteAuthorizationInterface } from "./methods/delete-authorization"; | ||
import { ConstructorOptions, OAuthAppOctokitClassType, ClientType, AddEventHandler } from "./types"; | ||
import { Options, ConstructorOptions, OctokitTypeFromOptions, ClientTypeFromOptions, ClientType, AddEventHandler } from "./types"; | ||
export { createNodeMiddleware } from "./middleware/node/index"; | ||
declare type Constructor<T> = new (...args: any[]) => T; | ||
export declare class OAuthApp<TClientType extends ClientType = "oauth-app", TOctokit extends OAuthAppOctokitClassType = OAuthAppOctokitClassType> { | ||
export declare class OAuthApp<TOptions extends Options<ClientType> = Options<"oauth-app">> { | ||
static VERSION: string; | ||
static defaults<TClientType extends ClientType, S extends Constructor<any>>(this: S, defaults: Partial<ConstructorOptions<TClientType>>): { | ||
static defaults<TDefaults extends Options<ClientType>, S extends Constructor<OAuthApp<TDefaults>>>(this: S, defaults: TDefaults): { | ||
new (...args: any[]): { | ||
[x: string]: any; | ||
type: ClientTypeFromOptions<TDefaults>; | ||
on: AddEventHandler<TDefaults>; | ||
octokit: OctokitTypeFromOptions<TDefaults>; | ||
getUserOctokit: GetUserOctokitWithStateInterface<ClientTypeFromOptions<TDefaults>>; | ||
getWebFlowAuthorizationUrl: GetWebFlowAuthorizationUrlInterface<ClientTypeFromOptions<TDefaults>>; | ||
createToken: CreateTokenInterface<ClientTypeFromOptions<TDefaults>>; | ||
checkToken: CheckTokenInterface<ClientTypeFromOptions<TDefaults>>; | ||
resetToken: ResetTokenInterface<ClientTypeFromOptions<TDefaults>>; | ||
refreshToken: RefreshTokenInterface; | ||
scopeToken: ScopeTokenInterface; | ||
deleteToken: DeleteTokenInterface; | ||
deleteAuthorization: DeleteAuthorizationInterface; | ||
}; | ||
} & S; | ||
constructor(options: ConstructorOptions<TClientType, TOctokit>); | ||
type: TClientType; | ||
on: AddEventHandler<TClientType, TOctokit>; | ||
octokit: InstanceType<TOctokit>; | ||
getUserOctokit: GetUserOctokitWithStateInterface<TClientType>; | ||
getWebFlowAuthorizationUrl: GetWebFlowAuthorizationUrlInterface<TClientType>; | ||
createToken: CreateTokenInterface<TClientType>; | ||
checkToken: CheckTokenInterface<TClientType>; | ||
resetToken: ResetTokenInterface<TClientType>; | ||
constructor(options: ConstructorOptions<TOptions>); | ||
type: ClientTypeFromOptions<TOptions>; | ||
on: AddEventHandler<TOptions>; | ||
octokit: OctokitTypeFromOptions<TOptions>; | ||
getUserOctokit: GetUserOctokitWithStateInterface<ClientTypeFromOptions<TOptions>>; | ||
getWebFlowAuthorizationUrl: GetWebFlowAuthorizationUrlInterface<ClientTypeFromOptions<TOptions>>; | ||
createToken: CreateTokenInterface<ClientTypeFromOptions<TOptions>>; | ||
checkToken: CheckTokenInterface<ClientTypeFromOptions<TOptions>>; | ||
resetToken: ResetTokenInterface<ClientTypeFromOptions<TOptions>>; | ||
refreshToken: RefreshTokenInterface; | ||
@@ -31,0 +42,0 @@ scopeToken: ScopeTokenInterface; |
@@ -6,5 +6,3 @@ import { OAuthAppStrategyOptionsWebFlow, OAuthAppStrategyOptionsDeviceFlow, OAuthAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsWebFlow, GitHubAppStrategyOptionsDeviceFlow, GitHubAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthenticationWithExpiration } from "@octokit/auth-oauth-user"; | ||
export declare type GetUserOctokitGitHubAppOptions = Omit<GitHubAppStrategyOptionsWebFlow, StateOptions> | Omit<GitHubAppStrategyOptionsDeviceFlow, StateOptions> | Omit<GitHubAppStrategyOptionsExistingAuthentication, StateOptions> | Omit<GitHubAppStrategyOptionsExistingAuthenticationWithExpiration, StateOptions>; | ||
export declare function getUserOctokitWithState(state: State, options: GetUserOctokitOAuthAppOptions | GetUserOctokitGitHubAppOptions): Promise<{ | ||
[x: string]: any; | ||
} & import("@octokit/core").Octokit>; | ||
export declare function getUserOctokitWithState(state: State, options: GetUserOctokitOAuthAppOptions | GetUserOctokitGitHubAppOptions): Promise<import("@octokit/core").Octokit>; | ||
export interface GetUserOctokitWithStateInterface<TClientType extends ClientType> { | ||
@@ -11,0 +9,0 @@ (options: TClientType extends "oauth-app" ? GetUserOctokitOAuthAppOptions : GetUserOctokitGitHubAppOptions): Promise<OctokitInstance>; |
/// <reference types="node" /> | ||
import { OAuthApp } from "../../index"; | ||
import { MiddlewareOptions } from "./types"; | ||
export declare function createNodeMiddleware(app: OAuthApp<"oauth-app"> | OAuthApp<"github-app">, { pathPrefix, onUnhandledRequest, }?: MiddlewareOptions): (request: import("http").IncomingMessage, response: import("http").ServerResponse) => Promise<void>; | ||
import { ClientType, Options } from "../../types"; | ||
export declare function createNodeMiddleware(app: OAuthApp<Options<ClientType>>, { pathPrefix, onUnhandledRequest, }?: MiddlewareOptions): (request: import("http").IncomingMessage, response: import("http").ServerResponse) => Promise<void>; |
@@ -5,2 +5,3 @@ /// <reference types="node" /> | ||
import { MiddlewareOptions } from "./types"; | ||
export declare function middleware(app: OAuthApp<"oauth-app"> | OAuthApp<"github-app">, options: Required<MiddlewareOptions>, request: IncomingMessage, response: ServerResponse): Promise<void>; | ||
import { Options, ClientType } from "../../types"; | ||
export declare function middleware(app: OAuthApp<Options<ClientType>>, options: Required<MiddlewareOptions>, request: IncomingMessage, response: ServerResponse): Promise<void>; |
import { Octokit } from "@octokit/core"; | ||
export declare const OAuthAppOctokit: (new (...args: any[]) => { | ||
[x: string]: any; | ||
}) & typeof Octokit; | ||
export declare const OAuthAppOctokit: typeof Octokit; |
@@ -0,1 +1,2 @@ | ||
import { Octokit } from "@octokit/core"; | ||
import { OAuthAppUserAuthentication, GitHubAppUserAuthentication, GitHubAppUserAuthenticationWithExpiration } from "@octokit/auth-oauth-app"; | ||
@@ -12,5 +13,5 @@ import { OAuthAppOctokit } from "./oauth-app-octokit"; | ||
export declare type EventAndActionName = "token" | "token.created" | "token.reset" | "token.refreshed" | "token.scoped" | "token.deleted" | "authorization" | "authorization.deleted"; | ||
declare type CommonConstructorOptions<TOctokit extends OAuthAppOctokitClassType> = { | ||
clientId: ClientId; | ||
clientSecret: ClientSecret; | ||
declare type CommonOptions<TOctokit extends OAuthAppOctokitClassType> = { | ||
clientId?: ClientId; | ||
clientSecret?: ClientSecret; | ||
allowSignup?: boolean; | ||
@@ -21,8 +22,15 @@ baseUrl?: string; | ||
}; | ||
export declare type ConstructorOptions<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType = OAuthAppOctokitClassType> = TClientType extends "oauth-app" ? CommonConstructorOptions<TOctokit> & { | ||
export declare type Options<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType = OAuthAppOctokitClassType> = TClientType extends "oauth-app" ? CommonOptions<TOctokit> & { | ||
clientType?: TClientType; | ||
defaultScopes?: Scope[]; | ||
} : CommonConstructorOptions<TOctokit> & { | ||
} : CommonOptions<TOctokit> & { | ||
clientType?: TClientType; | ||
}; | ||
export declare type ConstructorOptions<TOptions extends Options<ClientType>> = TOptions & { | ||
clientId: ClientId; | ||
clientSecret: ClientSecret; | ||
}; | ||
export declare type OctokitTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["Octokit"] extends typeof Octokit ? InstanceType<TOptions["Octokit"]> : Octokit; | ||
export declare type OctokitClassTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["Octokit"] extends typeof Octokit ? TOptions["Octokit"] : typeof Octokit; | ||
export declare type ClientTypeFromOptions<TOptions extends Options<ClientType>> = TOptions["clientType"] extends "github-app" ? "github-app" : "oauth-app"; | ||
export declare type OctokitInstance = InstanceType<OAuthAppOctokitClassType>; | ||
@@ -40,6 +48,6 @@ export declare type State = { | ||
eventHandlers: { | ||
[key: string]: EventHandler<ClientType, OAuthAppOctokitClassType>[]; | ||
[key: string]: EventHandler<Options<ClientType>>[]; | ||
}; | ||
}; | ||
export declare type EventHandlerContext<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType> = TClientType extends "oauth-app" ? { | ||
export declare type EventHandlerContext<TOptions extends Options<ClientType>> = ClientTypeFromOptions<TOptions> extends "oauth-app" ? { | ||
name: EventName; | ||
@@ -49,4 +57,4 @@ action: ActionName; | ||
scopes?: Scope[]; | ||
octokit: InstanceType<TOctokit>; | ||
authentication?: OAuthAppUserAuthentication; | ||
octokit: OctokitTypeFromOptions<TOptions>; | ||
authentication?: OAuthAppUserAuthentication | GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration; | ||
} : { | ||
@@ -56,7 +64,7 @@ name: EventName; | ||
token: Token; | ||
octokit: InstanceType<TOctokit>; | ||
octokit: OctokitTypeFromOptions<TOptions>; | ||
authentication?: GitHubAppUserAuthentication | GitHubAppUserAuthenticationWithExpiration; | ||
}; | ||
export declare type EventHandler<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType> = (context: EventHandlerContext<TClientType, TOctokit>) => void; | ||
export declare type AddEventHandler<TClientType extends ClientType, TOctokit extends OAuthAppOctokitClassType> = (eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<TClientType, TOctokit>) => void; | ||
export declare type EventHandler<TOptions extends Options<ClientType>> = (context: EventHandlerContext<TOptions>) => void; | ||
export declare type AddEventHandler<TOptions extends Options<ClientType>> = (eventName: EventAndActionName | EventAndActionName[], eventHandler: EventHandler<TOptions>) => void; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "3.2.0"; | ||
export declare const VERSION = "3.3.0"; |
{ | ||
"name": "@octokit/oauth-app", | ||
"description": "GitHub OAuth toolset for Node.js", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
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
132443
1470