index.d.ts raw
1 import { Event, Filter, VerifiedEvent } from 'nostr-tools'
2 import {
3 MEDIA_AUTO_LOAD_POLICY,
4 NOTIFICATION_LIST_STYLE,
5 NSFW_DISPLAY_POLICY,
6 POLL_TYPE
7 } from '../constants'
8
9 export type TSubRequestFilter = Omit<Filter, 'since' | 'until'> & { limit: number }
10
11 export type TFeedSubRequest = {
12 urls: string[]
13 filter: Omit<Filter, 'since' | 'until'>
14 }
15
16 export type TProfile = {
17 username: string
18 pubkey: string
19 npub: string
20 original_username?: string
21 banner?: string
22 avatar?: string
23 nip05?: string
24 about?: string
25 website?: string
26 lud06?: string
27 lud16?: string
28 lightningAddress?: string
29 created_at?: number
30 emojis?: TEmoji[]
31 }
32 export type TMailboxRelayScope = 'read' | 'write' | 'both'
33 export type TMailboxRelay = {
34 url: string
35 scope: TMailboxRelayScope
36 }
37 export type TRelayList = {
38 write: string[]
39 read: string[]
40 originalRelays: TMailboxRelay[]
41 }
42
43 export type TGraphQueryCapability = {
44 enabled: boolean
45 max_depth: number
46 max_results: number
47 methods: string[]
48 }
49
50 export type TRelayInfo = {
51 url: string
52 shortUrl: string
53 name?: string
54 description?: string
55 icon?: string
56 pubkey?: string
57 contact?: string
58 supported_nips?: number[]
59 software?: string
60 version?: string
61 tags?: string[]
62 payments_url?: string
63 limitation?: {
64 auth_required?: boolean
65 payment_required?: boolean
66 }
67 graph_query?: TGraphQueryCapability
68 }
69
70 export type TWebMetadata = {
71 title?: string | null
72 description?: string | null
73 image?: string | null
74 }
75
76 export type TRelaySet = {
77 id: string
78 aTag: string[]
79 name: string
80 relayUrls: string[]
81 }
82
83 export type TConfig = {
84 relayGroups: TRelaySet[]
85 theme: TThemeSetting
86 }
87
88 export type TThemeSetting = 'light' | 'dark' | 'system'
89 export type TTheme = 'light' | 'dark'
90
91 export type TDraftEvent = Pick<Event, 'content' | 'created_at' | 'kind' | 'tags'>
92
93 export type TNip07 = {
94 getPublicKey: () => Promise<string>
95 signEvent: (draftEvent: TDraftEvent) => Promise<VerifiedEvent>
96 nip04?: {
97 encrypt?: (pubkey: string, plainText: string) => Promise<string>
98 decrypt?: (pubkey: string, cipherText: string) => Promise<string>
99 }
100 nip44?: {
101 encrypt?: (pubkey: string, plainText: string) => Promise<string>
102 decrypt?: (pubkey: string, cipherText: string) => Promise<string>
103 }
104 }
105
106 export interface ISigner {
107 getPublicKey: () => Promise<string>
108 signEvent: (draftEvent: TDraftEvent) => Promise<VerifiedEvent>
109 nip04Encrypt: (pubkey: string, plainText: string) => Promise<string>
110 nip04Decrypt: (pubkey: string, cipherText: string) => Promise<string>
111 nip44Encrypt?: (pubkey: string, plainText: string) => Promise<string>
112 nip44Decrypt?: (pubkey: string, cipherText: string) => Promise<string>
113 }
114
115 export type TSignerType = 'nsec' | 'nip-07' | 'browser-nsec' | 'ncryptsec' | 'npub' | 'bunker'
116
117 export type TAccount = {
118 pubkey: string
119 signerType: TSignerType
120 ncryptsec?: string
121 nsec?: string
122 npub?: string
123 bunkerPubkey?: string
124 bunkerRelays?: string[]
125 bunkerSecret?: string
126 }
127
128 export type TAccountPointer = Pick<TAccount, 'pubkey' | 'signerType'>
129
130 export type TFeedType = 'following' | 'pinned' | 'relays' | 'relay'
131 export type TFeedInfo = { feedType: TFeedType; id?: string } | null
132
133 export type TLanguage = 'en' | 'zh' | 'pl'
134
135 export type TImetaInfo = {
136 url: string
137 sha256?: string
138 blurHash?: string
139 thumbHash?: Uint8Array
140 dim?: { width: number; height: number }
141 pubkey?: string
142 /** Variant name from kind 1063 binding event (thumb, mobile, desktop, original) */
143 variant?: string
144 }
145
146 export type TPublishOptions = {
147 specifiedRelayUrls?: string[]
148 additionalRelayUrls?: string[]
149 minPow?: number
150 }
151
152 export type TNoteListMode = 'posts' | 'postsAndReplies' | 'you'
153
154 export type TNotificationType = 'all' | 'mentions' | 'reactions' | 'zaps'
155
156 export type TPageRef = { scrollToTop: (behavior?: ScrollBehavior) => void }
157
158 export type TEmoji = {
159 shortcode: string
160 url: string
161 }
162
163 export type TMediaUploadServiceConfig =
164 | {
165 type: 'nip96'
166 service: string
167 }
168 | {
169 type: 'blossom'
170 }
171
172 export type TLlmConfig = {
173 apiKey: string
174 model: string
175 systemPrompt: string
176 autoRewrite: boolean
177 }
178
179 export type TPollType = (typeof POLL_TYPE)[keyof typeof POLL_TYPE]
180
181 export type TPollCreateData = {
182 isMultipleChoice: boolean
183 options: string[]
184 relays: string[]
185 endsAt?: number
186 }
187
188 export type TSearchType =
189 | 'profile'
190 | 'profiles'
191 | 'notes'
192 | 'note'
193 | 'hashtag'
194 | 'relay'
195 | 'externalContent'
196 | 'nak'
197
198 export type TSearchParams =
199 | {
200 type: Exclude<TSearchType, 'nak'>
201 search: string
202 input?: string
203 }
204 | {
205 type: 'nak'
206 search: string
207 request: TFeedSubRequest
208 input?: string
209 }
210
211 export type TNotificationStyle =
212 (typeof NOTIFICATION_LIST_STYLE)[keyof typeof NOTIFICATION_LIST_STYLE]
213
214 export type TAwesomeRelayCollection = {
215 id: string
216 name: string
217 relays: string[]
218 }
219
220 export type TMediaAutoLoadPolicy =
221 (typeof MEDIA_AUTO_LOAD_POLICY)[keyof typeof MEDIA_AUTO_LOAD_POLICY]
222
223 export type TNsfwDisplayPolicy = (typeof NSFW_DISPLAY_POLICY)[keyof typeof NSFW_DISPLAY_POLICY]
224
225 export type TSyncSettings = {
226 themeSetting?: TThemeSetting
227 primaryColor?: string
228 defaultZapSats?: number
229 defaultZapComment?: string
230 quickZap?: boolean
231 autoplay?: boolean
232 hideUntrustedInteractions?: boolean
233 hideUntrustedNotifications?: boolean
234 hideUntrustedNotes?: boolean
235 nsfwDisplayPolicy?: TNsfwDisplayPolicy
236 showKinds?: number[]
237 hideContentMentioningMutedUsers?: boolean
238 notificationListStyle?: TNotificationStyle
239 mediaAutoLoadPolicy?: TMediaAutoLoadPolicy
240 sidebarCollapse?: boolean
241 enableSingleColumnLayout?: boolean
242 faviconUrlTemplate?: string
243 filterOutOnionRelays?: boolean
244 quickReaction?: boolean
245 quickReactionEmoji?: string | TEmoji
246 noteListMode?: TNoteListMode
247 preferNip44?: boolean
248 nrcOnlyConfigSync?: boolean
249 autoInsertNewNotes?: boolean
250 addClientTag?: boolean
251 enableMarkdown?: boolean
252 verboseLogging?: boolean
253 fallbackRelayCount?: number
254 dmConversationFilter?: 'all' | 'follows'
255 graphQueriesEnabled?: boolean
256 socialGraphProximity?: number | null
257 socialGraphIncludeMode?: boolean
258 // Per-pubkey config (keyed by the logged-in pubkey at sync time)
259 llmConfig?: TLlmConfig | null
260 mediaUploadServiceConfig?: TMediaUploadServiceConfig
261 // Non-NIP relay configurations (application-specific)
262 searchRelays?: string[]
263 nrcRendezvousUrl?: string
264 outboxMode?: 'automatic' | 'managed'
265 relayStatsData?: string
266 }
267
268 // DM types
269 export type TDMEncryptionType = 'nip04' | 'nip17'
270
271 export interface TConversation {
272 partnerPubkey: string
273 lastMessageAt: number
274 lastMessagePreview: string
275 unreadCount: number
276 preferredEncryption: TDMEncryptionType | null
277 }
278
279 export interface TDirectMessage {
280 id: string
281 senderPubkey: string
282 recipientPubkey: string
283 content: string
284 createdAt: number
285 encryptionType: TDMEncryptionType
286 event: Event
287 decryptedContent?: string
288 seenOnRelays?: string[]
289 }
290
291 // Deleted messages state (stored in kind 30078 Application Specific Data)
292 export interface TDMDeletedState {
293 // Specific message IDs to ignore
294 deletedIds: string[]
295 // Timestamp ranges to ignore per conversation
296 deletedRanges: {
297 [partnerPubkey: string]: Array<{
298 start: number // timestamp
299 end: number // timestamp
300 }>
301 }
302 }
303