diff --git a/src/get-app-authentication.ts b/src/get-app-authentication.ts index 537ca8a8e..81274ffe8 100644 --- a/src/get-app-authentication.ts +++ b/src/get-app-authentication.ts @@ -6,7 +6,7 @@ export async function getAppAuthentication({ appId, privateKey, timeDifference, -}: State): Promise { +}: State & { timeDifference?: number }): Promise { const appAuthentication = await githubAppJwt({ id: +appId, privateKey, diff --git a/src/get-oauth-authentication.ts b/src/get-oauth-authentication.ts index eee2bde29..4020e64fa 100644 --- a/src/get-oauth-authentication.ts +++ b/src/get-oauth-authentication.ts @@ -1,13 +1,13 @@ import { RequestInterface, OAuthOptions, - StrategyOptionsWithDefaults, + State, OAuthAccesTokenAuthentication, } from "./types"; import { RequestError } from "@octokit/request-error"; export async function getOAuthAuthentication( - state: StrategyOptionsWithDefaults, + state: State, options: OAuthOptions, customRequest?: RequestInterface ): Promise { diff --git a/src/index.ts b/src/index.ts index c2b06b32e..d859e8838 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ import { getUserAgent } from "universal-user-agent"; import { request } from "@octokit/request"; -import { Deprecation } from "deprecation"; import { auth } from "./auth"; import { hook } from "./hook"; @@ -30,14 +29,6 @@ export const createAppAuth: StrategyInterface = function createAppAuth( options.log ); - if ("id" in options) { - log.warn( - new Deprecation( - '[@octokit/auth-app] "createAppAuth({ id })" is deprecated, use "createAppAuth({ appId })" instead' - ) - ); - } - const state: State = Object.assign( { request: request.defaults({ @@ -48,9 +39,6 @@ export const createAppAuth: StrategyInterface = function createAppAuth( cache: getCache(), }, options, - { - appId: Number("appId" in options ? options.appId : options.id), - }, options.installationId ? { installationId: Number(options.installationId) } : {}, diff --git a/src/types.ts b/src/types.ts index 54c807af3..de5365495 100644 --- a/src/types.ts +++ b/src/types.ts @@ -78,6 +78,7 @@ type OAuthStrategyOptions = { }; type CommonStrategyOptions = { + appId: number | string; privateKey: string; installationId?: number | string; request?: OctokitTypes.RequestInterface; @@ -88,34 +89,12 @@ type CommonStrategyOptions = { }; }; -type DeprecatedStrategyOptions = OAuthStrategyOptions & - CommonStrategyOptions & { - /** - * @deprecated id is deprecated, use appId instead - */ - id: number | string; - }; - -type CurrentStrategyOptions = OAuthStrategyOptions & - CommonStrategyOptions & { - appId: number | string; - }; +export type StrategyOptions = OAuthStrategyOptions & + CommonStrategyOptions & { [key: string]: unknown }; -export type StrategyOptions = ( - | DeprecatedStrategyOptions - | CurrentStrategyOptions -) & { [key: string]: unknown }; - -export type FactoryOptions = Required< - Omit -> & +export type FactoryOptions = Required> & State; -export type StrategyOptionsWithDefaults = CurrentStrategyOptions & - Required< - Omit - >; - export type Permissions = { [name: string]: string; }; @@ -146,6 +125,6 @@ export type WithInstallationId = { installationId: number; }; -export type State = StrategyOptionsWithDefaults & { - timeDifference: number; -}; +export type State = Required> & { + installationId?: number; +} & OAuthStrategyOptions; diff --git a/test/deprecations.test.ts b/test/deprecations.test.ts index f3a2a71f5..936b86840 100644 --- a/test/deprecations.test.ts +++ b/test/deprecations.test.ts @@ -1,23 +1,24 @@ -import { Deprecation } from "deprecation"; -import { createAppAuth } from "../src/index"; - describe("deprecations", () => { - test("createAppAuth({ id }) - #44", () => { - const warn = jest.fn(); + test("There are currently no deprecations", () => {}); + + // example: + // + // test("createAppAuth({ id }) - #44", () => { + // const warn = jest.fn(); - createAppAuth({ - id: 1, - privateKey: "...", - log: { - warn, - }, - }); + // createAppAuth({ + // id: 1, + // privateKey: "...", + // log: { + // warn, + // }, + // }); - expect(warn).toHaveBeenCalledTimes(1); - expect(warn).toHaveBeenCalledWith( - new Deprecation( - '[@octokit/auth-app] "createAppAuth({ id })" is deprecated, use "createAppAuth({ appId })" instead' - ) - ); - }); + // expect(warn).toHaveBeenCalledTimes(1); + // expect(warn).toHaveBeenCalledWith( + // new Deprecation( + // '[@octokit/auth-app] "createAppAuth({ id })" is deprecated, use "createAppAuth({ appId })" instead' + // ) + // ); + // }); });