mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 10:52:27 +00:00
Stop obfuscating private magnets
This commit is contained in:
1 parent
484343b027
commit
004c6426a8
5 files changed
+9
-66
No files matched your search
@@ -71,7 +71,6 @@ import ProfileModalController from "./ui/profileModalController.js";
|
||||
import ZapController from "./ui/zapController.js";
|
||||
import { MediaLoader } from "./utils/mediaLoader.js";
|
||||
import { pointerArrayToKey } from "./utils/pointer.js";
|
||||
import { fakeDecrypt } from "./utils/fakeDecrypt.js";
|
||||
import { isValidMagnetUri } from "./utils/magnetValidators.js";
|
||||
import { dedupeToNewestByRoot } from "./utils/videoDeduper.js";
|
||||
import {
|
||||
@@ -6199,15 +6198,6 @@ class Application {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
video.isPrivate &&
|
||||
video.pubkey === this.pubkey &&
|
||||
!video.alreadyDecrypted
|
||||
) {
|
||||
video.magnet = fakeDecrypt(video.magnet);
|
||||
video.alreadyDecrypted = true;
|
||||
}
|
||||
|
||||
let trimmedUrl = typeof video.url === "string" ? video.url.trim() : "";
|
||||
if (!trimmedUrl && fallbackUrl) {
|
||||
trimmedUrl = fallbackUrl;
|
||||
|
||||
@@ -1769,15 +1769,6 @@ function renderChannelVideosFromList({
|
||||
};
|
||||
|
||||
videos.forEach((video, index) => {
|
||||
if (
|
||||
video.isPrivate &&
|
||||
video.pubkey === nostrClient.pubkey &&
|
||||
!video.alreadyDecrypted
|
||||
) {
|
||||
video.magnet = fakeDecrypt(video.magnet);
|
||||
video.alreadyDecrypted = true;
|
||||
}
|
||||
|
||||
app?.videosMap?.set(video.id, video);
|
||||
|
||||
const canEdit = video.pubkey === app?.pubkey;
|
||||
@@ -2281,13 +2272,6 @@ window.addEventListener("bitvid:access-control-updated", () => {
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Minimal placeholder for private video decryption.
|
||||
*/
|
||||
function fakeDecrypt(str) {
|
||||
return str.split("").reverse().join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep only the newest version of each video root.
|
||||
*/
|
||||
|
||||
+8
-26
@@ -1689,17 +1689,6 @@ function cloneEventForCache(event) {
|
||||
return cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Example "encryption" that just reverses strings.
|
||||
* In real usage, replace with actual crypto.
|
||||
*/
|
||||
function fakeEncrypt(magnet) {
|
||||
return magnet.split("").reverse().join("");
|
||||
}
|
||||
function fakeDecrypt(encrypted) {
|
||||
return encrypted.split("").reverse().join("");
|
||||
}
|
||||
|
||||
function decodeNpubToHex(npub) {
|
||||
if (typeof npub !== "string" || !npub.trim()) {
|
||||
return "";
|
||||
@@ -4827,10 +4816,7 @@ class NostrClient {
|
||||
}
|
||||
|
||||
const rawMagnet = typeof videoData.magnet === "string" ? videoData.magnet : "";
|
||||
let finalMagnet = rawMagnet.trim();
|
||||
if (videoData.isPrivate && finalMagnet) {
|
||||
finalMagnet = fakeEncrypt(finalMagnet);
|
||||
}
|
||||
const finalMagnet = rawMagnet.trim();
|
||||
const finalUrl =
|
||||
typeof videoData.url === "string" ? videoData.url.trim() : "";
|
||||
const finalThumbnail =
|
||||
@@ -5052,12 +5038,12 @@ class NostrClient {
|
||||
throw new Error("You do not own this video (pubkey mismatch).");
|
||||
}
|
||||
|
||||
// Decrypt the old magnet if the note is private
|
||||
let oldPlainMagnet = baseEvent.magnet || "";
|
||||
if (baseEvent.isPrivate && oldPlainMagnet) {
|
||||
oldPlainMagnet = fakeDecrypt(oldPlainMagnet);
|
||||
}
|
||||
|
||||
const oldMagnet =
|
||||
typeof baseEvent.rawMagnet === "string" && baseEvent.rawMagnet.trim()
|
||||
? baseEvent.rawMagnet.trim()
|
||||
: typeof baseEvent.magnet === "string"
|
||||
? baseEvent.magnet.trim()
|
||||
: "";
|
||||
const oldUrl = baseEvent.url || "";
|
||||
|
||||
// Determine if the updated note should be private
|
||||
@@ -5067,11 +5053,7 @@ class NostrClient {
|
||||
const magnetEdited = updatedData.magnetEdited === true;
|
||||
const newMagnetValue =
|
||||
typeof updatedData.magnet === "string" ? updatedData.magnet.trim() : "";
|
||||
let finalPlainMagnet = magnetEdited ? newMagnetValue : oldPlainMagnet;
|
||||
let finalMagnet =
|
||||
wantPrivate && finalPlainMagnet
|
||||
? fakeEncrypt(finalPlainMagnet)
|
||||
: finalPlainMagnet;
|
||||
const finalMagnet = magnetEdited ? newMagnetValue : oldMagnet;
|
||||
|
||||
const urlEdited = updatedData.urlEdited === true;
|
||||
const newUrlValue =
|
||||
|
||||
@@ -562,7 +562,7 @@ export class RevertModal {
|
||||
? escape(this.truncateMiddle(displayMagnet, 72))
|
||||
: escape(displayMagnet);
|
||||
const caption = isPrivate
|
||||
? '<span class="block text-xs text-purple-200/90 mt-1">Encrypted magnet (only decrypted locally for the owner).</span>'
|
||||
? '<span class="block text-xs text-purple-200/90 mt-1">Magnet stays visible only to you — private notes keep the raw string local.</span>'
|
||||
: "";
|
||||
magnetHtml = `<div class="break-all">${label}${caption}</div>`;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// js/utils/fakeDecrypt.js
|
||||
|
||||
/**
|
||||
* Simple "decryption" placeholder for private videos.
|
||||
*/
|
||||
export function fakeDecrypt(str) {
|
||||
if (typeof str !== "string") {
|
||||
return "";
|
||||
}
|
||||
return str.split("").reverse().join("");
|
||||
}
|
||||
|
||||
export default fakeDecrypt;
|
||||
Reference in new issue
Block a user