Commit Graph
5056 Commits
Author SHA1 Message Date
google-labs-jules[bot]andPR0M3TH3AN 67aa8ad2aa Optimize channel profile event lookup with author index
- Replaced `NostrClient.rawEvents` standard Map with `EventsMap`
- Implemented `EventsMap` to maintain an author-based index
- Updated `js/channelProfile.js` to use `getEventsByAuthor` for efficient lookup
- Added unit tests for `EventsMap`
- Added benchmark script verifying ~15x performance improvement (637ms -> 41ms for 1M events)

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:38:42 +00:00
thePR0M3TH3AN 566c2dbf89 Merge pull request #2204 from PR0M3TH3AN/test/video-pointer-tests-15855649223064850700
Add unit tests for videoPointer.js
2026-02-07 19:15:03 -05:00
thePR0M3TH3AN 6001b44c28 Merge pull request #2200 from PR0M3TH3AN/test/count-diagnostics-coverage-4678245393880204618
🧪 Add tests for count diagnostics
2026-02-07 19:12:41 -05:00
thePR0M3TH3AN 8108e3dcb7 Merge pull request #2198 from PR0M3TH3AN/unify-hashtag-preferences-key-9274648867585622352
Unify profile cache keys for hashtag preferences
2026-02-07 19:11:11 -05:00
thePR0M3TH3AN 329ce5d842 Merge pull request #2203 from PR0M3TH3AN/test/max-listener-diagnostics-11773877660411760257
test: add tests for max listener diagnostics logic
2026-02-07 19:10:02 -05:00
thePR0M3TH3AN 55986e8dd2 Merge pull request #2199 from PR0M3TH3AN/test-explore-data-service-16099170843852410119
Add unit tests for exploreDataService.js
2026-02-07 19:08:03 -05:00
google-labs-jules[bot]andPR0M3TH3AN 01005eacb9 test(utils): add unit tests for videoPointer.js resolution logic
Adds comprehensive unit tests for `resolveVideoPointer` in `js/utils/videoPointer.js`.
The new tests cover:
- Happy paths for address (a-tag) and event (e-tag) pointers.
- Priority logic (dTag > videoRootId > fallbackEventId).
- Input normalization (trimming, lowercasing).
- Relay inclusion in pointer arrays.
- Default kind handling (fallback to 30078).
- Edge cases and invalid inputs returning null.

This improves test coverage for core video pointer resolution utility.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-08 00:05:18 +00:00
thePR0M3TH3AN aabf59ffe9 Merge pull request #2201 from PR0M3TH3AN/fix-load-feed-videos-crash-18410919809900626137
Fix crash in feed loading by delegating loadFeedVideos
2026-02-07 19:05:04 -05:00
google-labs-jules[bot]andPR0M3TH3AN ab75153e0b test: add tests for max listener diagnostics logic
Exports `collectCandidateStrings` and `shouldSuppressWarning` from `js/nostr/maxListenerDiagnostics.js` to enable unit testing.
Adds `tests/nostr/maxListenerDiagnostics.test.mjs` to test the warning suppression logic and verify the `process.emitWarning` patch side effect.
Fixes missing `jsdom` dependency issue by running `npm install`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:57:14 +00:00
google-labs-jules[bot]andPR0M3TH3AN 9571e3aedb Fix crash in feed loading by delegating loadFeedVideos
The `loadFeedVideos` method was missing from the `Application` class in `js/app.js`, but was being called by `loadVideos` inside the feed coordinator (which is bound to the application instance). This caused a `TypeError: this.loadFeedVideos is not a function` at runtime.

This change adds the missing delegation method to `Application` in `js/app.js`, forwarding the call to `this._feed.loadFeedVideos`.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:55:17 +00:00
google-labs-jules[bot]andPR0M3TH3AN 549b184861 Add unit tests for count diagnostics module
Added a new test file `tests/nostr/countDiagnostics.test.mjs` to cover:
- `isVerboseDiagnosticsEnabled` configuration flag logic.
- Logging behavior for count failures (relay, timeout, rebroadcast, view).
- Throttling logic to ensure repeated warnings are suppressed.
- Error suppression for connection failures.

The tests use module reloading with cache busting to ensure isolation between test cases, as the module maintains internal state (`seenWarningKeys`).
Mocks `console.warn` to verify logging output without polluting stdout.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:51:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 24402792a8 test: add unit tests for exploreDataService.js
- Add `tests/services/exploreDataService.test.mjs` to test `buildWatchHistoryTagCounts`.
- Mock global `Worker` to simulate worker behavior.
- Mock `console.warn` to verify error logging and suppression.
- Use dynamic import to handle `devLogger` initialization dependent on global flags.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:51:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN 273cbfd9cc Refactor HashtagPreferencesService to use unified profile cache key
Replaced the legacy "interests" string literal with NOTE_TYPES.HASHTAG_PREFERENCES
in profileCache calls to unify key usage. Updated migration logic and comments.
Verified that the underlying storage key remains consistent for backward compatibility.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:50:18 +00:00
thePR0M3TH3AN a20d01a412 Merge pull request #2197 from PR0M3TH3AN/chore/refactor-remove-custom-bech32-2289762197289114271
🧹 Remove custom Bech32 implementation in nip46Client
2026-02-07 18:40:17 -05:00
google-labs-jules[bot]andPR0M3TH3AN a892d78c4e chore: remove custom bech32 implementation in nip46Client
Removes the custom `bech32Polymod` and related Bech32 decoding functions from `js/nostr/nip46Client.js` in favor of using `nostr-tools` library implementation via `nip19.decode`. This reduces code duplication and relies on the standard library for decoding npubs.

Breaking Changes:
- None. `decodeNpubToHex` now strictly requires `nostr-tools` to be available, which is consistent with the rest of the file's dependencies.

Tests:
- Verified with targeted unit tests (`tests/nostr/nip46Client.test.js`).
- Verified with a reproduction script (`tests/repro_issue.mjs`) ensuring `decodeNpubToHex` correctly decodes valid npubs and handles invalid inputs.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:25:08 +00:00
thePR0M3TH3AN e897bfe44b Merge pull request #2196 from PR0M3TH3AN/perf/channel-profile-render-loop-optimization-15025405161037801037
⚡ Remove dead code execution in channel profile render loop
2026-02-07 18:24:37 -05:00
thePR0M3TH3AN 9110f1762b Merge pull request #2195 from PR0M3TH3AN/tests/zap-helpers-coverage-11165774273391187280
test: add unit tests for zap helpers
2026-02-07 18:22:25 -05:00
thePR0M3TH3AN d6b606a6e3 Merge pull request #2185 from PR0M3TH3AN/refactor/remove-unused-import-nostrevent-schemas-1391210410040613476
🧹 Remove unused import WATCH_HISTORY_LIST_IDENTIFIER in nostrEventSchemas.js
2026-02-07 18:20:50 -05:00
google-labs-jules[bot]andPR0M3TH3AN 99d217e778 perf: remove dead code in channel profile render loop
Removes the call to `app.persistWatchHistoryMetadataForVideo` in `renderChannelVideosFromList` within `js/channelProfile.js`. This function was identified as a no-op (delegating to a deprecated empty method), adding unnecessary overhead to the rendering loop.

Benchmark results (100M iterations):
- With call: ~1278ms
- Without call: ~88ms
- Improvement: ~14x speedup in the tight loop simulation.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:20:39 +00:00
thePR0M3TH3AN 8ccf0dc8e1 Merge pull request #2187 from PR0M3TH3AN/test-improvement/comment-avatar-resolution-2019846885315383708
🧪 Add unit tests for comment avatar resolution
2026-02-07 18:20:08 -05:00
thePR0M3TH3AN b549069fc4 Merge pull request #2194 from PR0M3TH3AN/refactor/feed-coordinator-load-logic-7944534665779205819
🧹 Refactor feed loading logic into shared loadFeedVideos method
2026-02-07 18:19:51 -05:00
thePR0M3TH3AN 135841c851 Merge pull request #2193 from PR0M3TH3AN/security/fix-nip46-session-storage-10018068311908189559
🔒 Fix insecure storage of NIP-46 session keys
2026-02-07 18:19:43 -05:00
thePR0M3TH3AN 340e4cc50a Merge pull request #2191 from PR0M3TH3AN/ai/test-video-menu-renderers-13178145676174629231
🧪 Add tests for video menu renderers
2026-02-07 18:19:00 -05:00
thePR0M3TH3AN c290959a7e Merge pull request #2192 from PR0M3TH3AN/perf/batch-profile-refresh-14711465702211977594
⚡ Optimize profile refreshing with batch requests
2026-02-07 18:18:50 -05:00
thePR0M3TH3AN 619596d8e5 Merge pull request #2189 from PR0M3TH3AN/security/fix-login-modal-open-redirect-13235976572682331262
🔒 Fix Open Redirect and XSS via NIP-46 Authentication URL
2026-02-07 18:18:41 -05:00
google-labs-jules[bot]andPR0M3TH3AN 1fa72709d9 test: add unit tests for zap helpers
Add comprehensive unit tests for `js/ui/dm/zapHelpers.js` in `tests/ui/dm/zapHelpers.test.mjs`.

- Covers `formatZapAmount` for standard and compact notation.
- Covers `aggregateZapTotals` for aggregation logic and edge cases.
- Covers `normalizeZapReceipt` for input normalization.
- Ensures robust handling of invalid inputs (NaN, null, etc.).

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:18:40 +00:00
thePR0M3TH3AN 85b0c2640f Merge pull request #2190 from PR0M3TH3AN/test-dom-utils-8159522647333333512
test(utils): add unit tests for domUtils
2026-02-07 18:18:10 -05:00
thePR0M3TH3AN 6598bb3c86 Merge pull request #2186 from PR0M3TH3AN/ai/test-dm-decrypt-diagnostics-16550896764619201700
🧪 Add tests for DM decrypt diagnostics
2026-02-07 18:17:57 -05:00
thePR0M3TH3AN b7adb91e37 Merge pull request #2188 from PR0M3TH3AN/refactor/load-saved-profiles-18358852260091920961
🧹 Refactor loadSavedProfilesFromStorage complexity
2026-02-07 18:17:40 -05:00
google-labs-jules[bot]andPR0M3TH3AN afd64ba1ce Refactor feed loading logic into shared loadFeedVideos method
- Introduce `loadFeedVideos(feedType, forceFetch)` in `js/app/feedCoordinator.js` to consolidate video loading logic.
- Update `loadForYouVideos`, `loadKidsVideos`, `loadExploreVideos`, and `loadVideos` to use the shared method.
- Parameterize feed-specific configuration (telemetry context, tags, loading messages, relay health checks) based on feed type.
- Add `tests/app/feedCoordinator.test.mjs` to verify the new logic.

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:56 +00:00
google-labs-jules[bot]andPR0M3TH3AN 8a9dcab4e1 fix(security): encrypt NIP-46 session keys in localStorage
- Implement AES-GCM encryption for NIP-46 `clientPrivateKey` and `secret` using `js/nostr/sessionActor.js` primitives.
- Update `writeStoredNip46Session` to accept an optional `passphrase` and encrypt sensitive fields before storage.
- Update `readStoredNip46Session` to support encrypted session retrieval.
- Add `decryptNip46Session` helper to unlock session keys with a user-provided passphrase.
- Update `NostrClient` methods `connectRemoteSigner` and `useStoredRemoteSigner` to support the new encryption flow.
- Ensure plain text keys are never persisted to `localStorage` (default safe behavior maintained).

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:48 +00:00
google-labs-jules[bot]andPR0M3TH3AN aae2ea7d16 perf: use batch fetch for profile refresh
Replaces the sequential loop in `forceRefreshAllProfiles` with `batchFetchProfiles` to reduce network requests.
Updates `batchFetchProfilesFromRelays` to support `forceRefresh`, ensuring fresh data is requested while maintaining optimistic UI updates.
Adds unit tests for `forceRefresh` behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:13 +00:00
google-labs-jules[bot]andPR0M3TH3AN 4d93ed25ce 🧪 Add tests for video menu renderers
Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:15:02 +00:00
google-labs-jules[bot]andPR0M3TH3AN 06865e5f46 test(utils): add unit tests for domUtils
- Added `tests/utils/domUtils.test.mjs` to test `escapeHTML` and `removeTrackingScripts`.
- Verified tests pass with `node:test` and JSDOM.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:14:18 +00:00
google-labs-jules[bot]andPR0M3TH3AN 2f78bc6632 Fix Open Redirect and XSS via NIP-46 Authentication URL
- Validated `pendingAuthUrl` protocol to be `http:` or `https:` in `js/ui/loginModalController.js`.
- Logged warning if unsafe URL is encountered.

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:13:31 +00:00
google-labs-jules[bot]andPR0M3TH3AN 53d7bc7a59 Refactor loadSavedProfilesFromStorage for better maintainability
Extracted the complex parsing, validation, and migration logic for saved profiles into a new helper function `processSavedProfilesPayload`. This reduces the complexity of `loadSavedProfilesFromStorage` and improves readability.

Functionality is preserved, including handling of legacy formats, NIP-07 auth types, and active profile normalization.

Verified with targeted tests:
- tests/state/cache-saved-profiles.test.mjs
- tests/state/cache.test.mjs

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:13:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN e79998f7b5 test: add unit tests for comment avatar resolution
Added a new test file `tests/unit/comment-avatar.test.mjs` to comprehensively test the `commentAvatar.js` utility. The tests cover:
- `normalizeCommentAvatarKey`: Verifies input sanitization and normalization.
- `resolveCommentAvatarAsset`: Verifies avatar resolution logic including defaults, failure handling, and caching strategies.
- `registerCommentAvatarFailure`: Verifies failure registration and cache invalidation.

This ensures robust handling of user avatars in comments, including edge cases like missing or failed images and cache persistence.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:12:11 +00:00
google-labs-jules[bot]andPR0M3TH3AN aefd6308a2 🧪 Add tests for DM decrypt diagnostics
- Added unit tests for `summarizeDmEventForLog` covering null/invalid inputs, valid events, and edge cases.
- Added unit tests for `sanitizeDecryptError` covering null/invalid inputs, string errors, and error objects.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:11:47 +00:00
google-labs-jules[bot]andPR0M3TH3AN 28af2910de chore(code-health): remove unused WATCH_HISTORY_LIST_IDENTIFIER import from nostrEventSchemas.js
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 23:10:26 +00:00
thePR0M3TH3AN c539fef553 Merge pull request #2183 from PR0M3TH3AN/jules-fix-unused-import-appjs-3659969045676148831
chore(js): remove unused splitAndZap import in app.js
2026-02-07 17:40:17 -05:00
bitvid-agent 73093ae916 fix(ai): formatting (agent) suggested 2026-02-07 22:17:31 +00:00
google-labs-jules[bot]andPR0M3TH3AN 31dc297991 chore(js): remove unused splitAndZap import in app.js
Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 22:14:19 +00:00
thePR0M3TH3AN 2c5fb67985 Merge pull request #2182 from PR0M3TH3AN/refactor/feed-types-constants-7142050680573542479
🧹 Refactor hardcoded feed identifiers to constants
2026-02-07 17:03:10 -05:00
bitvid-agent 9f710c1f77 fix(ai): formatting (agent) suggested 2026-02-07 22:02:54 +00:00
google-labs-jules[bot]andPR0M3TH3AN a829cd95ca Refactor hardcoded feed identifiers to use constants
Introduced FEED_TYPES constants in js/constants.js and updated js/app/authSessionCoordinator.js, js/hashChangeHandler.js, js/viewManager.js, and js/app/feedCoordinator.js to use them. This improves maintainability and reduces the risk of typos in feed view names.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 21:59:37 +00:00
thePR0M3TH3AN 38f63e5851 Merge pull request #2181 from PR0M3TH3AN/refactor/deduplicate-hex64-regex-4819369490365472168
🧹 Refactor: Deduplicate HEX64_REGEX constant
2026-02-07 16:57:49 -05:00
bitvid-agent 955398d338 fix(ai): formatting (agent) suggested 2026-02-07 21:56:02 +00:00
google-labs-jules[bot]andPR0M3TH3AN a084bb59de refactor: deduplicate HEX64_REGEX to js/utils/hex.js
Moves the repeatedly defined HEX64_REGEX constant to a shared utility
module to improve maintainability and consistency. Updates all consumers
to import from the new location.

Signed-off-by: Jules <[email protected]>

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-07 21:52:51 +00:00
thePR0M3TH3AN 4c30228fad Merge pull request #2180 from PR0M3TH3AN/chore-remove-unused-nip46-constants-17069818061582667621
🧹 Remove unused NIP-46 constants exports
2026-02-07 16:49:29 -05:00
bitvid-agent ac96ef76ea fix(ai): formatting (agent) suggested 2026-02-07 21:48:59 +00:00