refactor: remove basic login page
This commit is contained in:
parent
b355648db5
commit
099aaf4218
1181
assets/auth.html
1181
assets/auth.html
File diff suppressed because it is too large
Load Diff
|
@ -14,11 +14,9 @@ export default class InternalProvider extends BaseProvider {
|
||||||
async shouldHandleRequest(
|
async shouldHandleRequest(
|
||||||
details: OnBeforeRequestDetailsType,
|
details: OnBeforeRequestDetailsType,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return [
|
return ["http://kernel.lume/", "http://kernel.lume/favicon.ico"].includes(
|
||||||
"http://kernel.lume/",
|
details.url,
|
||||||
"http://kernel.lume/auth.html",
|
);
|
||||||
"http://kernel.lume/favicon.ico",
|
|
||||||
].includes(details.url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleRequest(
|
async handleRequest(
|
||||||
|
@ -35,68 +33,6 @@ export default class InternalProvider extends BaseProvider {
|
||||||
return {};
|
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.
|
// Otherwise do nothing.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -104,10 +40,7 @@ export default class InternalProvider extends BaseProvider {
|
||||||
async handleHeaders(
|
async handleHeaders(
|
||||||
details: OnHeadersReceivedDetailsType,
|
details: OnHeadersReceivedDetailsType,
|
||||||
): Promise<OnRequestDetailsType | boolean> {
|
): Promise<OnRequestDetailsType | boolean> {
|
||||||
if (
|
if (details.url === "http://kernel.lume/") {
|
||||||
details.url === "http://kernel.lume/" ||
|
|
||||||
details.url === "http://kernel.lume/auth.html"
|
|
||||||
) {
|
|
||||||
let headers = [
|
let headers = [
|
||||||
{
|
{
|
||||||
name: "content-type",
|
name: "content-type",
|
||||||
|
@ -117,17 +50,6 @@ export default class InternalProvider extends BaseProvider {
|
||||||
return { responseHeaders: headers } as unknown as OnRequestDetailsType;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue