relays.ts (636B)
1 import type { RadrootsRelayDocument } from "@radroots/events-bindings"; 2 3 const NOSTR_RELAY_FORM_FIELD_RECORD: Record<keyof RadrootsRelayDocument, true> = { 4 name: true, 5 description: true, 6 pubkey: true, 7 contact: true, 8 supported_nips: true, 9 software: true, 10 version: true 11 }; 12 13 const is_nostr_relay_form_field = (value: string): value is keyof RadrootsRelayDocument => { 14 return value in NOSTR_RELAY_FORM_FIELD_RECORD; 15 }; 16 17 export const nostr_relay_parse_form_keys = (value: string): keyof RadrootsRelayDocument | "" => { 18 if (is_nostr_relay_form_field(value)) { 19 return value; 20 } 21 return ""; 22 };