mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
Relay tab improvements so users can see which relays to remove:
- Per-relay status pill: Online (with ping) / Offline / Checking… / Blocked.
- Insecure remote ws:// relays (CSP-blocked) flagged immediately with a hint.
- Offline relays show a "consider removing" hint; their Remove button is
emphasized.
- Summary banner when relays are down (incl. the all-dead case explaining why
videos won't load), pointing at Restore defaults / healthy relays.
Also fixes a pre-existing decomposition bug (commit 7300977a): handleRelayOperation
called this.runRelayOperation, but that method lives on the main
ProfileModalController — so ALL relay ops (add/remove/mode/restore) threw
"this.runRelayOperation is not a function". Route via this.mainController.
Tests: relay-insecure-url (isInsecureRelayUrl), relay-operation-routing (routes to
mainController.runRelayOperation, guards no-pubkey). Both mutation-verified.
Build + lint + full unit suite green.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
// The relay-list UI flags relays that can never connect from the browser so the
|
|
// user knows to remove them. A cleartext ws:// relay that is NOT localhost is
|
|
// blocked by the app's CSP (connect-src allows wss: and ws://localhost only), so
|
|
// it must be reported as insecure/blocked; wss:// and local ws:// must not be.
|
|
|
|
import "./test-helpers/setup-localstorage.mjs";
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { ProfileRelayController } from "../js/ui/profileModal/ProfileRelayController.js";
|
|
|
|
const controller = Object.create(ProfileRelayController.prototype);
|
|
const isInsecure = (url) => controller.isInsecureRelayUrl(url);
|
|
|
|
test("flags remote cleartext ws:// relays as insecure (CSP-blocked)", () => {
|
|
assert.equal(isInsecure("ws://209.122.211.18:4848"), true);
|
|
assert.equal(isInsecure("ws://relay.example.com"), true);
|
|
assert.equal(isInsecure("WS://Relay.Example.com"), true, "case-insensitive");
|
|
});
|
|
|
|
test("does not flag secure or local relays", () => {
|
|
assert.equal(isInsecure("wss://relay.damus.io"), false);
|
|
assert.equal(isInsecure("wss://nos.lol"), false);
|
|
assert.equal(isInsecure("ws://localhost:8000"), false);
|
|
assert.equal(isInsecure("ws://127.0.0.1:4848"), false);
|
|
});
|
|
|
|
test("handles empty/invalid input safely", () => {
|
|
assert.equal(isInsecure(""), false);
|
|
assert.equal(isInsecure(null), false);
|
|
assert.equal(isInsecure(undefined), false);
|
|
assert.equal(isInsecure(12345), false);
|
|
});
|