From d485116f8940e70f3ec7863ccd8234c7a2b9c41e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 14 Aug 2022 14:36:59 -0400 Subject: [PATCH] *Don't attempt to process if we are not logged in --- src/contentProviders/baseProvider.ts | 5 +++++ src/webEngine.ts | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/contentProviders/baseProvider.ts b/src/contentProviders/baseProvider.ts index 55f7154..eeae7e9 100644 --- a/src/contentProviders/baseProvider.ts +++ b/src/contentProviders/baseProvider.ts @@ -9,6 +9,7 @@ import WebEngine from "../webEngine.js"; import { getTld, isDomain, isIp, normalizeDomain } from "../util.js"; import tldEnum from "@lumeweb/tld-enum"; import { resolve } from "@lumeweb/kernel-dns-client"; +import { getAuthStatus } from "../main/vars.js"; export default abstract class BaseProvider { private engine: WebEngine; @@ -48,6 +49,10 @@ export default abstract class BaseProvider { const originalUrl = new URL(details.url); const hostname = normalizeDomain(originalUrl.hostname); + if (getAuthStatus().loginComplete !== true) { + return false; + } + if (tldEnum.list.includes(getTld(hostname))) { return false; } diff --git a/src/webEngine.ts b/src/webEngine.ts index afd85c5..fef55a1 100644 --- a/src/webEngine.ts +++ b/src/webEngine.ts @@ -15,7 +15,7 @@ import { getTld, isDomain, isIp, normalizeDomain } from "./util.js"; import tldEnum from "@lumeweb/tld-enum"; import { resolve } from "@lumeweb/kernel-dns-client"; import { blake2b, bufToHex } from "libskynet"; -import { authStatus } from "./main/background.js"; +import { getAuthStatus } from "./main/vars.js"; export default class WebEngine { private contentProviders: BaseProvider[] = []; @@ -70,9 +70,6 @@ export default class WebEngine { } private async proxyHandler(details: OnRequestDetailsType): Promise { - if (authStatus.loginComplete !== true) { - return {}; - } let handle = null; for (const provider of this.contentProviders) { 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 promise = new Promise((resolve, reject) => {