fix: only add protected tag on relays that advertise NIP-70 support

This commit is contained in:
2026-06-14 23:19:08 +05:30
parent 448854b3cd
commit 5f38211a5c
2 changed files with 13 additions and 9 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
const relays = url ? [url] : Router.get().Event(event).getUrls()
const shouldProtect = url ? canEnforceNip70(url) : Promise.resolve(false)
const shouldProtect = url ? canEnforceNip70(url) : false
const deleteReaction = async (event: TrustedEvent) =>
publishDelete({relays, event, protect: await shouldProtect})
+12 -8
View File
@@ -24,7 +24,14 @@ import {
uniq,
} from "@welshman/lib"
import {throttled} from "@welshman/store"
import {loadRelay, manageRelay, publishThunk, sign, waitForThunkError} from "@welshman/app"
import {
getRelay,
loadRelay,
manageRelay,
publishThunk,
sign,
waitForThunkError,
} from "@welshman/app"
import {checkRelayHasLivekit} from "$lib/livekit"
import {stripPrefix} from "@lib/util"
import {relaysMostlyRestricted} from "@app/policies"
@@ -35,6 +42,9 @@ export const hasNip29 = (relay?: RelayProfile) =>
export const hasNip50 = (relay?: RelayProfile) =>
Boolean(relay?.supported_nips?.map?.(String)?.includes?.("50"))
export const hasNip70 = (relay?: RelayProfile) =>
Boolean(relay?.supported_nips?.map?.(String)?.includes?.("70"))
export const encodeRelay = (url: string) =>
encodeURIComponent(
normalizeRelayUrl(url)
@@ -151,13 +161,7 @@ export const requestRelayClaims = async (urls: string[]) =>
fromPairs(await Promise.all(urls.map(async url => [url, await requestRelayClaim(url)]))),
)
export const canEnforceNip70 = async (url: string) => {
const socket = Pool.get().get(url)
await socket.auth.attemptAuth(sign)
return socket.auth.status !== AuthStatus.None
}
export const canEnforceNip70 = (url: string) => hasNip70(getRelay(url))
export const attemptRelayAccess = async (url: string, claim = "") => {
const socket = Pool.get().get(url)