From 099aaf42181f7dd6157f5057fb2b2db1c5ad26d8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 17 Jul 2023 12:49:48 -0400 Subject: [PATCH] refactor: remove basic login page --- assets/auth.html | 1181 ---------------------- src/contentProviders/internalProvider.ts | 86 +- 2 files changed, 4 insertions(+), 1263 deletions(-) delete mode 100644 assets/auth.html diff --git a/assets/auth.html b/assets/auth.html deleted file mode 100644 index f93a575..0000000 --- a/assets/auth.html +++ /dev/null @@ -1,1181 +0,0 @@ - - - - - - diff --git a/src/contentProviders/internalProvider.ts b/src/contentProviders/internalProvider.ts index 288aa97..612f603 100644 --- a/src/contentProviders/internalProvider.ts +++ b/src/contentProviders/internalProvider.ts @@ -14,11 +14,9 @@ export default class InternalProvider extends BaseProvider { async shouldHandleRequest( details: OnBeforeRequestDetailsType, ): Promise { - return [ - "http://kernel.lume/", - "http://kernel.lume/auth.html", - "http://kernel.lume/favicon.ico", - ].includes(details.url); + return ["http://kernel.lume/", "http://kernel.lume/favicon.ico"].includes( + details.url, + ); } async handleRequest( @@ -35,68 +33,6 @@ export default class InternalProvider extends BaseProvider { return {}; } - // For the favicon, we make a request to a content script that has access - // to the favicon. - if (details.url === "http://kernel.lume/favicon.ico") { - // Send a message to the kernel requesting an override for the - // favicon.ico. The kernel is itself loading this favicon from the - // browser, I just wasn't certain how to get binary objects directly to - // the background page, so we fetch it via a content script instead. - let faviconPromise = queryKernel({ - method: "requestOverride", - data: { - url: details.url, - method: details.method, - }, - }); - - // Get the filter and swallow any response from the server. Setting - // 'onData' to a blank function will swallow all data from the server. - let filter = browser.webRequest.filterResponseData(details.requestId); - filter.ondata = () => { - // By setting 'ondata' to the emtpy function, we effectively ensure - // that none of the data will be processed. - }; - filter.onstop = () => { - faviconPromise.then((result: RequestOverrideResponse) => { - filter.write(result.body as Uint8Array); - filter.close(); - }); - }; - return {}; - } - - // For the favicon, we make a request to a content script that has access - // to the favicon. - if (details.url === "http://kernel.lume/auth.html") { - // Send a message to the kernel requesting an override for the auth - // page. The kernel is itself loading the auth page from the browser, I - // just wasn't certain how to get binary objects directly to the - // background page, so we fetch it via a content script instead. - let authPagePromise = queryKernel({ - method: "requestOverride", - data: { - url: details.url, - method: details.method, - }, - }); - - // Get the filter and swallow any response from the server. Setting - // 'onData' to a blank function will swallow all data from the server. - let filter = browser.webRequest.filterResponseData(details.requestId); - filter.ondata = () => { - // By setting 'ondata' to the emtpy function, we effectively ensure - // that none of the data will be processed. - }; - filter.onstop = () => { - authPagePromise.then((result: RequestOverrideResponse) => { - filter.write(result.body as Uint8Array); - filter.close(); - }); - }; - return {}; - } - // Otherwise do nothing. return false; } @@ -104,10 +40,7 @@ export default class InternalProvider extends BaseProvider { async handleHeaders( details: OnHeadersReceivedDetailsType, ): Promise { - if ( - details.url === "http://kernel.lume/" || - details.url === "http://kernel.lume/auth.html" - ) { + if (details.url === "http://kernel.lume/") { let headers = [ { name: "content-type", @@ -117,17 +50,6 @@ export default class InternalProvider extends BaseProvider { return { responseHeaders: headers } as unknown as OnRequestDetailsType; } - // For the favicon, replace the headers with png headers. - if (details.url === "http://kernel.lume/favicon.ico") { - let headers = [ - { - name: "content-type", - value: "image/png", - }, - ]; - return { responseHeaders: headers } as unknown as OnRequestDetailsType; - } - return false; }