mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #2181 from PR0M3TH3AN/refactor/deduplicate-hex64-regex-4819369490365472168
🧹 Refactor: Deduplicate HEX64_REGEX constant
This commit is contained in:
23 files changed
+43
-23
No files matched your search
@@ -189,6 +189,7 @@ import { createPlaybackCoordinator } from "./app/playbackCoordinator.js";
|
||||
import { createAuthSessionCoordinator } from "./app/authSessionCoordinator.js";
|
||||
import { createModalCoordinator } from "./app/modalCoordinator.js";
|
||||
import { createModerationCoordinator } from "./app/moderationCoordinator.js";
|
||||
import { HEX64_REGEX } from "./utils/hex.js";
|
||||
|
||||
const recordVideoViewApi = (...args) => recordVideoView(nostrClient, ...args);
|
||||
|
||||
@@ -197,7 +198,7 @@ const UNSUPPORTED_BTITH_MESSAGE =
|
||||
|
||||
const FALLBACK_THUMBNAIL_SRC = "/assets/jpg/video-thumbnail-fallback.jpg";
|
||||
const VIDEO_EVENT_KIND = 30078;
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
const RELAY_UI_BATCH_DELAY_MS = 250;
|
||||
/**
|
||||
* Simple IntersectionObserver-based lazy loader for images (or videos).
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { userLogger } from "./utils/logger.js";
|
||||
import { HEX64_REGEX } from "./utils/hex.js";
|
||||
|
||||
const DB_NAME = "bitvidSettings";
|
||||
const DB_VERSION = 1;
|
||||
@@ -6,7 +7,7 @@ const STORE_NAME = "kv";
|
||||
const KEY_PREFIX = "dmSnapshot:";
|
||||
const LOCALSTORAGE_PREFIX = "bitvid:dmSnapshot:";
|
||||
const PREVIEW_MAX_LENGTH = 160;
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
function isIndexedDbAvailable() {
|
||||
try {
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// js/dmDecryptor.js
|
||||
|
||||
import { normalizeActorKey } from "./nostr/watchHistory.js";
|
||||
import { HEX64_REGEX } from "./utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/;
|
||||
|
||||
const SUPPORTED_KINDS = new Set([4, 1059]);
|
||||
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import { resolveVideoPointer } from "./utils/videoPointer.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import { nostrToolsReady } from "./nostrToolsBootstrap.js";
|
||||
import { THEME_ACCENT_OVERRIDES } from "../config/instance-config.js";
|
||||
import { HEX64_REGEX } from "./utils/hex.js";
|
||||
|
||||
// Set accent color from instance config
|
||||
try {
|
||||
@@ -51,7 +52,7 @@ const diagPromise = embedDebugEnabled
|
||||
|
||||
const POINTER_PARAM = "pointer";
|
||||
const PLAYBACK_PARAM = "playback";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
const statusEl = document.getElementById("embedStatus");
|
||||
const videoEl = document.getElementById("embedVideo");
|
||||
|
||||
@@ -4,8 +4,9 @@ import { signEventWithPrivateKey } from "../publishHelpers.js";
|
||||
import { createPrivateKeyCipherClosures } from "../signerHelpers.js";
|
||||
import { ensureNostrTools, getCachedNostrTools } from "../toolkit.js";
|
||||
import { normalizeActorKey } from "../watchHistory.js";
|
||||
import { HEX64_REGEX } from "../../utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
function normalizePrivateKey(privateKey) {
|
||||
if (typeof privateKey !== "string") {
|
||||
|
||||
+1
-1
@@ -157,8 +157,8 @@ import {
|
||||
readStoredSessionActorEntry,
|
||||
isSessionActor,
|
||||
} from "./sessionActor.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
import {
|
||||
HEX64_REGEX,
|
||||
NIP46_RPC_KIND,
|
||||
NIP46_HANDSHAKE_TIMEOUT_MS,
|
||||
NIP46_AUTH_CHALLENGE_MAX_ATTEMPTS,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { ensureNostrTools, getCachedNostrTools } from "./toolkit.js";
|
||||
import { devLogger } from "../utils/logger.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
const workerScope = typeof self !== "undefined" ? self : null;
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
const postResponse = (payload) => {
|
||||
if (!workerScope || typeof workerScope.postMessage !== "function") {
|
||||
|
||||
@@ -26,8 +26,7 @@ import {
|
||||
} from "../nostrPublish.js";
|
||||
import { devLogger, userLogger } from "../utils/logger.js";
|
||||
import { Nip46RequestQueue, NIP46_PRIORITY } from "./nip46Queue.js";
|
||||
|
||||
export const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
export const NIP46_RPC_KIND = 24_133;
|
||||
const NIP46_SESSION_STORAGE_KEY = "bitvid:nip46:session:v1";
|
||||
|
||||
@@ -20,12 +20,13 @@ import { DEFAULT_NIP07_PERMISSION_METHODS } from "./nip07Permissions.js";
|
||||
import { devLogger, userLogger } from "../utils/logger.js";
|
||||
import { logRebroadcastCountFailure } from "./countDiagnostics.js";
|
||||
import { queueSignEvent } from "./signRequestQueue.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
const REBROADCAST_GUARD_PREFIX = "bitvid:rebroadcast:v1";
|
||||
const rebroadcastAttemptMemory = new Map();
|
||||
|
||||
const HEX_PRIVATE_KEY_REGEX = /^[0-9a-f]{64}$/i;
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
function normalizeSha256TagValue(value) {
|
||||
if (value === undefined || value === null) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// js/nostr/signerHelpers.js
|
||||
|
||||
import { devLogger } from "../utils/logger.js";
|
||||
import { HEX64_REGEX } from "./nip46Client.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
import { ensureNostrTools, getCachedNostrTools } from "./toolkit.js";
|
||||
import { normalizeActorKey } from "./watchHistory.js";
|
||||
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
import { userLogger } from "./utils/logger.js";
|
||||
import { HEX64_REGEX } from "./utils/hex.js";
|
||||
const DB_NAME = "bitvidSettings";
|
||||
const DB_VERSION = 1;
|
||||
const STORE_NAME = "kv";
|
||||
const KEY_PREFIX = "nwcSettings:";
|
||||
const LOCALSTORAGE_PREFIX = "bitvid:nwcSettings:";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
const MIN_DEFAULT_ZAP = 0;
|
||||
const MAX_DEFAULT_ZAP = 100000000;
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ import { nostrToolsReady } from "../nostrToolsBootstrap.js";
|
||||
import { signEventWithPrivateKey } from "../nostr/publishHelpers.js";
|
||||
import { userLogger } from "../utils/logger.js";
|
||||
import { isZapAllowanceExhaustedError } from "./zapSharedState.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
const URI_SCHEMES = [
|
||||
"nostr+walletconnect://",
|
||||
"walletconnect://",
|
||||
|
||||
@@ -5,8 +5,9 @@ import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { setProfileCacheEntry } from "../state/cache.js";
|
||||
import { nostrToolsReady } from "../nostrToolsBootstrap.js";
|
||||
import { userLogger } from "../utils/logger.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
const CACHE_TTL_MS = 10 * 60 * 1000;
|
||||
|
||||
let cachedAddress = null;
|
||||
|
||||
@@ -20,8 +20,9 @@ import {
|
||||
parsePercentValue,
|
||||
resolvePlatformFeePercent,
|
||||
} from "./platformFee.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
const ZAP_KIND = 9734;
|
||||
const DEFAULT_DEPS = Object.freeze({
|
||||
lnurl: Object.freeze({
|
||||
|
||||
@@ -27,6 +27,7 @@ import getDefaultAuthProvider, {
|
||||
providers as defaultAuthProviders,
|
||||
} from "./authProviders/index.js";
|
||||
import { fetchProfileMetadata } from "./profileMetadataService.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
class SimpleEventEmitter {
|
||||
constructor(logger = null) {
|
||||
@@ -69,7 +70,7 @@ class SimpleEventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
const FALLBACK_PROFILE = {
|
||||
name: "Unknown",
|
||||
picture: "assets/svg/default-profile.svg",
|
||||
|
||||
@@ -30,10 +30,11 @@ import {
|
||||
getLastSuccessfulScheme,
|
||||
setLastSuccessfulScheme,
|
||||
} from "../nostr/decryptionSchemeCache.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
const LOG_PREFIX = "[HashtagPreferences]";
|
||||
const HASHTAG_IDENTIFIER = "bitvid:tag-preferences";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
const DEFAULT_VERSION = 1;
|
||||
const DECRYPT_TIMEOUT_MS = 20000;
|
||||
// PERF: Reduced from 10s to 3s for faster recovery during login.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { devLogger } from "../utils/logger.js";
|
||||
import { relaySubscriptionService } from "./relaySubscriptionService.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
const DEFAULT_PROFILE_IMAGE = "assets/svg/default-profile.svg";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
const inFlight = new Map();
|
||||
|
||||
function normalizePubkey(pubkey) {
|
||||
|
||||
+2
-1
@@ -27,7 +27,7 @@ const URL_HEALTH_TIMEOUT_RETRY_MS = 5 * 60 * 1000; // 5 minutes
|
||||
export const URL_PROBE_TIMEOUT_MS = 8 * 1000; // 8 seconds
|
||||
const URL_PROBE_TIMEOUT_RETRY_MS = 15 * 1000; // 15 seconds
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
const MODERATION_OVERRIDE_STORAGE_KEY = "bitvid:moderationOverrides:v2";
|
||||
const LEGACY_MODERATION_OVERRIDE_STORAGE_KEY = "bitvid:moderationOverrides:v1";
|
||||
@@ -839,6 +839,7 @@ export function persistProfileCacheToStorage() {
|
||||
}
|
||||
|
||||
import { profileCache as unifiedProfileCache } from "./profileCache.js";
|
||||
import { HEX64_REGEX } from "../utils/hex.js";
|
||||
|
||||
export function getProfileCacheEntry(pubkey) {
|
||||
const profile = unifiedProfileCache.getProfile(pubkey);
|
||||
|
||||
@@ -12,10 +12,11 @@ import {
|
||||
normalizeVideoModerationContext,
|
||||
} from "../moderationUiHelpers.js";
|
||||
import { buildModerationBadgeText } from "../moderationCopy.js";
|
||||
import { HEX64_REGEX } from "../../utils/hex.js";
|
||||
|
||||
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
||||
const DEFAULT_PROFILE_AVATAR = "assets/svg/default-profile.svg";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
export class VideoCard {
|
||||
constructor({
|
||||
|
||||
@@ -46,8 +46,9 @@ import {
|
||||
isLinkPreviewDomainAllowed,
|
||||
subscribeToLinkPreviewSettings,
|
||||
} from "../../utils/linkPreviewSettings.js";
|
||||
import { HEX64_REGEX } from "../../utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
const SIMILAR_CONTENT_LIMIT = 10;
|
||||
|
||||
export class VideoModal {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
export function normalizeHexString(value) {
|
||||
if (typeof value !== "string") {
|
||||
return "";
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import { nostrClient } from "../nostrClientFacade.js";
|
||||
import { devLogger } from "./logger.js";
|
||||
import { fetchProfileMetadataBatch } from "../services/profileMetadataService.js";
|
||||
import { HEX64_REGEX } from "./hex.js";
|
||||
|
||||
const DEFAULT_PROFILE_IMAGE = "assets/svg/default-profile.svg";
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
|
||||
export async function batchFetchProfilesFromRelays({
|
||||
authorSet,
|
||||
|
||||
@@ -3,8 +3,9 @@ import assert from "node:assert/strict";
|
||||
|
||||
import { Application } from "../../js/app.js";
|
||||
import { nostrClient } from "../../js/nostrClientFacade.js";
|
||||
import { HEX64_REGEX } from "../../js/utils/hex.js";
|
||||
|
||||
|
||||
const HEX64_REGEX = /^[0-9a-f]{64}$/i;
|
||||
|
||||
function createTestApp(pubkey) {
|
||||
const app = {
|
||||
|
||||
Reference in new issue
Block a user