From 1111eea9d5a650d2b3492b60abcfaa4c66ecd80e Mon Sep 17 00:00:00 2001 From: Luca Armaroli Date: Thu, 14 Oct 2021 21:56:23 +0200 Subject: [PATCH] fix target during SharePoint login --- src/LoginModules.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/LoginModules.ts b/src/LoginModules.ts index 1866cb1..c327977 100644 --- a/src/LoginModules.ts +++ b/src/LoginModules.ts @@ -23,7 +23,7 @@ export async function doStreamLogin(url: string, tokenCache: TokenCache, usernam ] }); - // try-finally because we were leaving zombie processes if there was an error + // try-finally because we were leaving zombie processes if there was an error try { const page: puppeteer.Page = (await browser.pages())[0]; @@ -94,7 +94,11 @@ export async function doStreamLogin(url: string, tokenCache: TokenCache, usernam export async function doShareLogin(url: string, username?: string): Promise { logger.info('Launching headless Chrome to perform the OpenID Connect dance...'); - const hostname = new URL(url).hostname; + const hostname = new URL(url).host; + logger.verbose(new URL(url).host); + logger.verbose(new URL(url).hostname); + + const browser: puppeteer.Browser = await puppeteer.launch({ executablePath: getPuppeteerChromiumPath(), headless: false, @@ -135,7 +139,7 @@ export async function doShareLogin(url: string, username?: string): Promise target.url().includes(hostname), { timeout: 150000 }); + await browser.waitForTarget((target: puppeteer.Target) => target.url().startsWith(`https://${hostname}`), { timeout: 150000 }); logger.info('We are logged in.'); let session: ShareSession | null = null;