Use publicID instead of privateID for /userInfo calls

This should reduce the load on the server a bit, as it will no longer have to compute the publicID for each sponsorblock user.
This also reduces the list of actions that leak the privateID to the server.
This commit is contained in:
mini-bomba 2022-10-29 13:18:41 +02:00
parent d68c3659be
commit ea73a92fb7
No known key found for this signature in database
GPG key ID: 30F8B138B4794886
4 changed files with 11 additions and 11 deletions

View file

@ -532,7 +532,7 @@ function activatePrivateTextChange(element: HTMLElement) {
case "userID": case "userID":
if (Config.config[option]) { if (Config.config[option]) {
utils.asyncRequestToServer("GET", "/api/userInfo", { utils.asyncRequestToServer("GET", "/api/userInfo", {
userID: Config.config[option], publicUserID: utils.getHash(Config.config[option]),
values: ["warnings", "banned"] values: ["warnings", "banned"]
}).then((result) => { }).then((result) => {
const userInfo = JSON.parse(result.responseText); const userInfo = JSON.parse(result.responseText);
@ -672,4 +672,4 @@ function copyDebugOutputToClipboard() {
function isIncognitoAllowed(): Promise<boolean> { function isIncognitoAllowed(): Promise<boolean> {
return new Promise((resolve) => chrome.extension.isAllowedIncognitoAccess(resolve)); return new Promise((resolve) => chrome.extension.isAllowedIncognitoAccess(resolve));
} }

View file

@ -281,7 +281,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
if (!Config.config.payments.freeAccess && !noRefreshFetchingChaptersAllowed()) values.push("freeChaptersAccess"); if (!Config.config.payments.freeAccess && !noRefreshFetchingChaptersAllowed()) values.push("freeChaptersAccess");
utils.asyncRequestToServer("GET", "/api/userInfo", { utils.asyncRequestToServer("GET", "/api/userInfo", {
userID: Config.config.userID, publicUserID: await utils.getHash(Config.config.userID),
values values
}).then((res) => { }).then((res) => {
if (res.status === 200) { if (res.status === 200) {
@ -461,7 +461,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
} else { } else {
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("segmentsStillLoading"); PageElements.videoFound.innerHTML = chrome.i18n.getMessage("segmentsStillLoading");
} }
PageElements.issueReporterImportExport.classList.remove("hidden"); PageElements.issueReporterImportExport.classList.remove("hidden");
} }
} }

View file

@ -15,7 +15,7 @@ export async function checkLicenseKey(licenseKey: string): Promise<boolean> {
Config.config.showChapterInfoMessage = false; Config.config.showChapterInfoMessage = false;
Config.config.payments.lastCheck = Date.now(); Config.config.payments.lastCheck = Date.now();
Config.forceSyncUpdate("payments"); Config.forceSyncUpdate("payments");
return true; return true;
} }
} catch (e) { } //eslint-disable-line no-empty } catch (e) { } //eslint-disable-line no-empty
@ -43,7 +43,7 @@ export async function fetchingChaptersAllowed(): Promise<boolean> {
return licensePromise; return licensePromise;
} }
} }
if (Config.config.payments.chaptersAllowed) return true; if (Config.config.payments.chaptersAllowed) return true;
if (Config.config.payments.lastCheck === 0 && Date.now() - Config.config.payments.lastFreeCheck > 2 * 24 * 60 * 60 * 1000) { if (Config.config.payments.lastCheck === 0 && Date.now() - Config.config.payments.lastFreeCheck > 2 * 24 * 60 * 60 * 1000) {
@ -53,7 +53,7 @@ export async function fetchingChaptersAllowed(): Promise<boolean> {
// Check for free access if no license key, and it is the first time // Check for free access if no license key, and it is the first time
const result = await utils.asyncRequestToServer("GET", "/api/userInfo", { const result = await utils.asyncRequestToServer("GET", "/api/userInfo", {
value: "freeChaptersAccess", value: "freeChaptersAccess",
userID: Config.config.userID publicUserID: await utils.getHash(Config.config.userID)
}); });
try { try {
@ -66,7 +66,7 @@ export async function fetchingChaptersAllowed(): Promise<boolean> {
Config.config.payments.chaptersAllowed = true; Config.config.payments.chaptersAllowed = true;
Config.config.showChapterInfoMessage = false; Config.config.showChapterInfoMessage = false;
Config.forceSyncUpdate("payments"); Config.forceSyncUpdate("payments");
return true; return true;
} }
} }
@ -74,4 +74,4 @@ export async function fetchingChaptersAllowed(): Promise<boolean> {
} }
return false; return false;
} }

View file

@ -13,7 +13,7 @@ export interface ChatConfig {
export async function openWarningDialog(contentContainer: ContentContainer): Promise<void> { export async function openWarningDialog(contentContainer: ContentContainer): Promise<void> {
const userInfo = await utils.asyncRequestToServer("GET", "/api/userInfo", { const userInfo = await utils.asyncRequestToServer("GET", "/api/userInfo", {
userID: Config.config.userID, publicUserID: await utils.getHash(Config.config.userID),
values: ["warningReason"] values: ["warningReason"]
}); });
@ -63,4 +63,4 @@ export async function openWarningDialog(contentContainer: ContentContainer): Pro
export function openChat(config: ChatConfig): void { export function openChat(config: ChatConfig): void {
window.open("https://chat.sponsor.ajay.app/#" + GenericUtils.objectToURI("", config, false)); window.open("https://chat.sponsor.ajay.app/#" + GenericUtils.objectToURI("", config, false));
} }