refactor: remove basic login page

This commit is contained in:
Derrick Hammer 2023-07-17 12:49:48 -04:00
parent b355648db5
commit 099aaf4218
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 4 additions and 1263 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,11 +14,9 @@ export default class InternalProvider extends BaseProvider {
async shouldHandleRequest(
details: OnBeforeRequestDetailsType,
): Promise<boolean> {
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<OnRequestDetailsType | boolean> {
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;
}