diff --git a/src/app/components/NoteItem.svelte b/src/app/components/NoteItem.svelte index eb855f0a..799a065e 100644 --- a/src/app/components/NoteItem.svelte +++ b/src/app/components/NoteItem.svelte @@ -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}) diff --git a/src/app/relays.ts b/src/app/relays.ts index 53e57302..e1091460 100644 --- a/src/app/relays.ts +++ b/src/app/relays.ts @@ -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)