From 3ed56c2a0655a489c2d77e2f091552f6d2aff795 Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Fri, 8 Nov 2019 14:28:42 -0800 Subject: [PATCH] fix: auth.hook() uses app auth for "https://api.github.com/app/installations" --- src/hook.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hook.ts b/src/hook.ts index 56bda25e0..136aa1255 100644 --- a/src/hook.ts +++ b/src/hook.ts @@ -3,7 +3,6 @@ import { getInstallationAuthentication } from "./get-installation-authentication import { requiresAppAuth } from "./requires-app-auth"; import { AnyResponse, - EndpointDefaults, EndpointOptions, RequestParameters, RequestInterface, @@ -17,12 +16,13 @@ export async function hook( route: Route | EndpointOptions, parameters?: RequestParameters ): Promise { - let endpoint: EndpointDefaults = request.endpoint.merge( - route as string, - parameters - ); + let endpoint = request.endpoint.merge(route as string, parameters); - if (requiresAppAuth(endpoint.url)) { + if ( + requiresAppAuth( + (endpoint.url as string).replace(request.endpoint.DEFAULTS.baseUrl, "") + ) + ) { const { token } = await getAppAuthentication(state.id, state.privateKey); endpoint.headers.authorization = `bearer ${token}`;