Merge pull request #1276 from PR0M3TH3AN/codex/watch-history-v2-encryption-596800188208881719

Enforce v=2 tag and mandatory encryption for watch history
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-17 07:56:44 -05:00
commit fef2d547ec
4 files changed
+48 -25

No files matched your search

+2
View File
@@ -41,6 +41,8 @@ import {
ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS,
} from "../config/instance-config.js";
export const WATCH_HISTORY_VERSION_TAG_VALUE = "2";
export const isDevMode = Boolean(IS_DEV_MODE);
export { IS_DEV_MODE };
+10 -3
View File
@@ -7,6 +7,7 @@ import {
WATCH_HISTORY_PAYLOAD_MAX_BYTES,
WATCH_HISTORY_FETCH_EVENT_LIMIT,
WATCH_HISTORY_CACHE_TTL_MS,
WATCH_HISTORY_VERSION_TAG_VALUE,
} from "../config.js";
import {
buildWatchHistoryEvent,
@@ -26,8 +27,8 @@ import { devLogger, userLogger } from "../utils/logger.js";
* relay publishing, fetch/decrypt flows, and exposes a manager factory that is
* dependency-injected with the nostr client hooks it needs.
*/
const WATCH_HISTORY_STORAGE_KEY = "bitvid:watch-history:v4";
const WATCH_HISTORY_STORAGE_VERSION = 4;
const WATCH_HISTORY_STORAGE_KEY = "bitvid:watch-history:v5";
const WATCH_HISTORY_STORAGE_VERSION = 5;
const WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS = 2000;
const WATCH_HISTORY_REPUBLISH_MAX_DELAY_MS = 5 * 60 * 1000;
const WATCH_HISTORY_REPUBLISH_MAX_ATTEMPTS = 8;
@@ -1653,6 +1654,11 @@ class WatchHistoryManager {
}
}
if (!encryptionTags.length) {
devLogger.warn("[nostr] Aborting watch history publish: mandatory encryption failed.");
return { ok: false, error: "encryption-failed", retryable: true };
}
const event = buildWatchHistoryEvent({
pubkey: actorPubkey,
created_at: createdAtCursor,
@@ -2045,7 +2051,8 @@ class WatchHistoryManager {
{
kinds,
authors: [actorKey],
// Fetch all parameterized replaceables of this kind to get history across all months
// Filter by the new version tag to ignore older history lists
"#v": [WATCH_HISTORY_VERSION_TAG_VALUE],
limit,
},
];
+2 -1
View File
@@ -7,6 +7,7 @@ import {
isDevMode,
WATCH_HISTORY_KIND,
WATCH_HISTORY_LIST_IDENTIFIER,
WATCH_HISTORY_VERSION_TAG_VALUE,
} from "./config.js";
export const NOTE_TYPES = Object.freeze({
@@ -359,7 +360,7 @@ const BASE_SCHEMAS = {
name: "d",
},
monthTagName: "month",
appendTags: DEFAULT_APPEND_TAGS,
appendTags: [["v", WATCH_HISTORY_VERSION_TAG_VALUE]],
content: {
format: "json",
description: