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