constants.js raw
1 // Default Nostr relays for searching
2 // Import from config module for dual-mode support (embedded vs standalone)
3 import { getRelayUrls } from './config.js';
4
5 // Dynamic relay list - call this function to get current relay(s)
6 // In embedded mode: returns same-origin relay
7 // In standalone mode: returns configured relay URL
8 export function getDefaultRelays() {
9 return getRelayUrls();
10 }
11
12 // Legacy export for backwards compatibility
13 // Components should migrate to getDefaultRelays() for dynamic behavior
14 const wsProtocol = window.location.protocol.startsWith('https') ? 'wss:' : 'ws:';
15 export const DEFAULT_RELAYS = [
16 `${wsProtocol}//${window.location.host}/`,
17 ];
18
19 // Fallback relays for profile lookups when local relay doesn't have the data
20 export const FALLBACK_RELAYS = [
21 'wss://relay.damus.io',
22 'wss://nos.lol',
23 'wss://relay.nostr.band',
24 'wss://purplepag.es',
25 ];
26
27 // Replaceable kinds for the recovery dropdown
28 // Based on NIP-01: kinds 0, 3, and 10000-19999 are replaceable
29 // kinds 30000-39999 are addressable (parameterized replaceable)
30 export const replaceableKinds = [
31 // Basic replaceable kinds (0, 3)
32 { value: 0, label: "User Metadata (0)" },
33 { value: 3, label: "Follows (3)" },
34
35 // Replaceable range 10000-19999
36 { value: 10000, label: "Mute list (10000)" },
37 { value: 10001, label: "Pin list (10001)" },
38 { value: 10002, label: "Relay List Metadata (10002)" },
39 { value: 10003, label: "Bookmark list (10003)" },
40 { value: 10004, label: "Communities list (10004)" },
41 { value: 10005, label: "Public chats list (10005)" },
42 { value: 10006, label: "Blocked relays list (10006)" },
43 { value: 10007, label: "Search relays list (10007)" },
44 { value: 10009, label: "User groups (10009)" },
45 { value: 10012, label: "Favorite relays list (10012)" },
46 { value: 10013, label: "Private event relay list (10013)" },
47 { value: 10015, label: "Interests list (10015)" },
48 { value: 10019, label: "Nutzap Mint Recommendation (10019)" },
49 { value: 10020, label: "Media follows (10020)" },
50 { value: 10030, label: "User emoji list (10030)" },
51 { value: 10050, label: "Relay list to receive DMs (10050)" },
52 { value: 10051, label: "KeyPackage Relays List (10051)" },
53 { value: 10063, label: "User server list (10063)" },
54 { value: 10096, label: "File storage server list (10096)" },
55 { value: 10166, label: "Relay Monitor Announcement (10166)" },
56 { value: 10312, label: "Room Presence (10312)" },
57 { value: 10377, label: "Proxy Announcement (10377)" },
58 { value: 11111, label: "Transport Method Announcement (11111)" },
59 { value: 13194, label: "Wallet Info (13194)" },
60 { value: 17375, label: "Cashu Wallet Event (17375)" },
61
62 // Addressable range 30000-39999 (parameterized replaceable)
63 { value: 30000, label: "Follow sets (30000)" },
64 { value: 30001, label: "Generic lists (30001)" },
65 { value: 30002, label: "Relay sets (30002)" },
66 { value: 30003, label: "Bookmark sets (30003)" },
67 { value: 30004, label: "Curation sets (30004)" },
68 { value: 30005, label: "Video sets (30005)" },
69 { value: 30007, label: "Kind mute sets (30007)" },
70 { value: 30008, label: "Profile Badges (30008)" },
71 { value: 30009, label: "Badge Definition (30009)" },
72 { value: 30015, label: "Interest sets (30015)" },
73 { value: 30017, label: "Create or update a stall (30017)" },
74 { value: 30018, label: "Create or update a product (30018)" },
75 { value: 30019, label: "Marketplace UI/UX (30019)" },
76 { value: 30020, label: "Product sold as an auction (30020)" },
77 { value: 30023, label: "Long-form Content (30023)" },
78 { value: 30024, label: "Draft Long-form Content (30024)" },
79 { value: 30030, label: "Emoji sets (30030)" },
80 { value: 30040, label: "Curated Publication Index (30040)" },
81 { value: 30041, label: "Curated Publication Content (30041)" },
82 { value: 30063, label: "Release artifact sets (30063)" },
83 { value: 30078, label: "Application-specific Data (30078)" },
84 { value: 30166, label: "Relay Discovery (30166)" },
85 { value: 30267, label: "App curation sets (30267)" },
86 { value: 30311, label: "Live Event (30311)" },
87 { value: 30312, label: "Interactive Room (30312)" },
88 { value: 30313, label: "Conference Event (30313)" },
89 { value: 30315, label: "User Statuses (30315)" },
90 { value: 30388, label: "Slide Set (30388)" },
91 { value: 30402, label: "Classified Listing (30402)" },
92 { value: 30403, label: "Draft Classified Listing (30403)" },
93 { value: 30617, label: "Repository announcements (30617)" },
94 { value: 30618, label: "Repository state announcements (30618)" },
95 { value: 30818, label: "Wiki article (30818)" },
96 { value: 30819, label: "Redirects (30819)" },
97 { value: 31234, label: "Draft Event (31234)" },
98 { value: 31388, label: "Link Set (31388)" },
99 { value: 31890, label: "Feed (31890)" },
100 { value: 31922, label: "Date-Based Calendar Event (31922)" },
101 { value: 31923, label: "Time-Based Calendar Event (31923)" },
102 { value: 31924, label: "Calendar (31924)" },
103 { value: 31925, label: "Calendar Event RSVP (31925)" },
104 { value: 31989, label: "Handler recommendation (31989)" },
105 { value: 31990, label: "Handler information (31990)" },
106 { value: 32267, label: "Software Application (32267)" },
107 { value: 34550, label: "Community Definition (34550)" },
108 { value: 37516, label: "Geocache listing (37516)" },
109 { value: 38172, label: "Cashu Mint Announcement (38172)" },
110 { value: 38173, label: "Fedimint Announcement (38173)" },
111 { value: 38383, label: "Peer-to-peer Order events (38383)" },
112 { value: 39089, label: "Starter packs (39089)" },
113 { value: 39092, label: "Media starter packs (39092)" },
114 { value: 39701, label: "Web bookmarks (39701)" },
115 ];
116
117 // Kind name mapping based on NIP specification
118 // Matches official Nostr event kinds from https://github.com/nostr-protocol/nips
119 export const kindNames = {
120 0: "User Metadata",
121 1: "Short Text Note",
122 2: "Recommend Relay",
123 3: "Follows",
124 4: "Encrypted Direct Messages",
125 5: "Event Deletion Request",
126 6: "Repost",
127 7: "Reaction",
128 8: "Badge Award",
129 9: "Chat Message",
130 10: "Group Chat Threaded Reply",
131 11: "Thread",
132 12: "Group Thread Reply",
133 13: "Seal",
134 14: "Direct Message",
135 15: "File Message",
136 16: "Generic Repost",
137 17: "Reaction to a website",
138 20: "Picture",
139 40: "Channel Creation",
140 41: "Channel Metadata",
141 42: "Channel Message",
142 43: "Channel Hide Message",
143 44: "Channel Mute User",
144 1021: "Bid",
145 1022: "Bid Confirmation",
146 1040: "OpenTimestamps",
147 1063: "File Metadata",
148 1311: "Live Chat Message",
149 1971: "Problem Tracker",
150 1984: "Reporting",
151 1985: "Label",
152 4550: "Community Post Approval",
153 5000: "Job Request",
154 5999: "Job Request",
155 6000: "Job Result",
156 6999: "Job Result",
157 7000: "Job Feedback",
158 9041: "Zap Goal",
159 9734: "Zap Request",
160 9735: "Zap",
161 9882: "Highlights",
162 10000: "Mute list",
163 10001: "Pin list",
164 10002: "Relay List Metadata",
165 10003: "Bookmarks list",
166 10004: "Communities list",
167 10005: "Public Chats list",
168 10006: "Blocked Relays list",
169 10007: "Search Relays list",
170 10015: "Interests",
171 10030: "User Emoji list",
172 10050: "DM relays",
173 10096: "File Storage Server List",
174 13194: "Wallet Service Info",
175 21000: "Lightning pub RPC",
176 22242: "Client Authentication",
177 23194: "Wallet Request",
178 23195: "Wallet Response",
179 23196: "Wallet Notification",
180 23197: "Wallet Notification",
181 24133: "Nostr Connect",
182 27235: "HTTP Auth",
183 30000: "Follow sets",
184 30001: "Generic lists",
185 30002: "Relay sets",
186 30003: "Bookmark sets",
187 30004: "Curation sets",
188 30008: "Profile Badges",
189 30009: "Badge Definition",
190 30015: "Interest sets",
191 30017: "Stall Definition",
192 30018: "Product Definition",
193 30019: "Marketplace UI/UX",
194 30020: "Product sold as an auction",
195 30023: "Long-form Content",
196 30024: "Draft Long-form Content",
197 30030: "Emoji sets",
198 30078: "Application-specific Data",
199 30311: "Live Event",
200 30315: "User Statuses",
201 30402: "Classified Listing",
202 30403: "Draft Classified Listing",
203 31922: "Date-Based Calendar Event",
204 31923: "Time-Based Calendar Event",
205 31924: "Calendar",
206 31925: "Calendar Event RSVP",
207 31989: "Handler recommendation",
208 31990: "Handler information",
209 34235: "Video Event Horizontal",
210 34236: "Video Event Vertical",
211 34550: "Community Definition",
212 };
213
214 // Cache configuration
215 export const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
216