Stringify supported nips
This commit is contained in:
@@ -105,4 +105,4 @@ routerContext.getPubkeyRelays = getPubkeyRelays
|
||||
routerContext.getRelayQuality = getRelayQuality
|
||||
routerContext.getDefaultRelays = _relayGetter()
|
||||
routerContext.getIndexerRelays = _relayGetter()
|
||||
routerContext.getSearchRelays = _relayGetter(r => r?.supported_nips?.includes?.(50))
|
||||
routerContext.getSearchRelays = _relayGetter(r => r?.supported_nips?.includes?.("50"))
|
||||
|
||||
@@ -39,6 +39,12 @@ export const fetchRelay = async (url: string): Promise<Maybe<RelayProfile>> => {
|
||||
if (json) {
|
||||
const info = {...json, url}
|
||||
|
||||
if (!Array.isArray(info.supported_nips)) {
|
||||
info.supported_nips = []
|
||||
}
|
||||
|
||||
info.supported_nips = info.supported_nips.map(String)
|
||||
|
||||
relaysByUrl.update($relaysByUrl => {
|
||||
$relaysByUrl.set(url, info)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export const hasNegentropy = (url: string) => {
|
||||
const relay = getRelay(url)
|
||||
|
||||
if (relay?.negentropy) return true
|
||||
if (relay?.supported_nips?.includes?.(77)) return true
|
||||
if (relay?.supported_nips?.includes?.("77")) return true
|
||||
if (relay?.software?.includes?.("strfry") && !relay?.version?.match(/^0\./)) return true
|
||||
|
||||
return false
|
||||
|
||||
@@ -1390,6 +1390,7 @@ export const setJson = (k: string, v: any) => localStorage.setItem(k, JSON.strin
|
||||
/** Options for fetch requests */
|
||||
type FetchOpts = {
|
||||
method?: string
|
||||
signal?: AbortSignal
|
||||
headers?: Record<string, string | boolean>
|
||||
body?: string | FormData
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {SignedEvent, Filter} from "@welshman/util"
|
||||
// relay -> client
|
||||
|
||||
export enum RelayMessageType {
|
||||
Notice = "NOTICE",
|
||||
Auth = "AUTH",
|
||||
Closed = "CLOSED",
|
||||
Eose = "EOSE",
|
||||
@@ -14,6 +15,8 @@ export enum RelayMessageType {
|
||||
|
||||
export type RelayMessage = any[]
|
||||
|
||||
export type RelayNoticePayload = [string]
|
||||
|
||||
export type RelayAuthPayload = [string]
|
||||
|
||||
export type RelayClosedPayload = [string, string]
|
||||
@@ -28,6 +31,8 @@ export type RelayNegMsgPayload = [string, string]
|
||||
|
||||
export type RelayOkPayload = [string, boolean, string]
|
||||
|
||||
export type RelayNotice = [RelayMessageType.Notice, ...RelayNoticePayload]
|
||||
|
||||
export type RelayAuth = [RelayMessageType.Auth, ...RelayAuthPayload]
|
||||
|
||||
export type RelayClosed = [RelayMessageType.Closed, ...RelayClosedPayload]
|
||||
@@ -42,6 +47,8 @@ export type RelayNegMsg = [RelayMessageType.NegMsg, ...RelayNegMsgPayload]
|
||||
|
||||
export type RelayOk = [RelayMessageType.Ok, ...RelayOkPayload]
|
||||
|
||||
export const isRelayNotice = (m: RelayMessage): m is RelayNotice => m[0] === RelayMessageType.Notice
|
||||
|
||||
export const isRelayAuth = (m: RelayMessage): m is RelayAuth => m[0] === RelayMessageType.Auth
|
||||
|
||||
export const isRelayClosed = (m: RelayMessage): m is RelayClosed => m[0] === RelayMessageType.Closed
|
||||
|
||||
@@ -22,7 +22,7 @@ export type RelayProfile = {
|
||||
version?: string
|
||||
negentropy?: number
|
||||
description?: string
|
||||
supported_nips?: number[]
|
||||
supported_nips?: string[]
|
||||
privacy_policy?: string
|
||||
terms_of_service?: string
|
||||
limitation?: {
|
||||
|
||||
Reference in New Issue
Block a user