*Don't attempt to process if we are not logged in

This commit is contained in:
Derrick Hammer 2022-08-14 14:36:59 -04:00
parent c9b0daf053
commit d485116f89
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 13 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import WebEngine from "../webEngine.js";
import { getTld, isDomain, isIp, normalizeDomain } from "../util.js"; import { getTld, isDomain, isIp, normalizeDomain } from "../util.js";
import tldEnum from "@lumeweb/tld-enum"; import tldEnum from "@lumeweb/tld-enum";
import { resolve } from "@lumeweb/kernel-dns-client"; import { resolve } from "@lumeweb/kernel-dns-client";
import { getAuthStatus } from "../main/vars.js";
export default abstract class BaseProvider { export default abstract class BaseProvider {
private engine: WebEngine; private engine: WebEngine;
@ -48,6 +49,10 @@ export default abstract class BaseProvider {
const originalUrl = new URL(details.url); const originalUrl = new URL(details.url);
const hostname = normalizeDomain(originalUrl.hostname); const hostname = normalizeDomain(originalUrl.hostname);
if (getAuthStatus().loginComplete !== true) {
return false;
}
if (tldEnum.list.includes(getTld(hostname))) { if (tldEnum.list.includes(getTld(hostname))) {
return false; return false;
} }

View File

@ -15,7 +15,7 @@ import { getTld, isDomain, isIp, normalizeDomain } from "./util.js";
import tldEnum from "@lumeweb/tld-enum"; import tldEnum from "@lumeweb/tld-enum";
import { resolve } from "@lumeweb/kernel-dns-client"; import { resolve } from "@lumeweb/kernel-dns-client";
import { blake2b, bufToHex } from "libskynet"; import { blake2b, bufToHex } from "libskynet";
import { authStatus } from "./main/background.js"; import { getAuthStatus } from "./main/vars.js";
export default class WebEngine { export default class WebEngine {
private contentProviders: BaseProvider[] = []; private contentProviders: BaseProvider[] = [];
@ -70,9 +70,6 @@ export default class WebEngine {
} }
private async proxyHandler(details: OnRequestDetailsType): Promise<any> { private async proxyHandler(details: OnRequestDetailsType): Promise<any> {
if (authStatus.loginComplete !== true) {
return {};
}
let handle = null; let handle = null;
for (const provider of this.contentProviders) { for (const provider of this.contentProviders) {
if (await provider.shouldHandleRequest(details)) { if (await provider.shouldHandleRequest(details)) {
@ -217,6 +214,13 @@ export default class WebEngine {
} }
} }
if ("kernel.skynet" === hostname) {
return;
}
if (getAuthStatus().loginComplete !== true) {
return;
}
let resolveRequest: any, rejectRequest: any; let resolveRequest: any, rejectRequest: any;
let promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {