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 language?: string
227 themeSetting?: TThemeSetting
228 primaryColor?: string
229 defaultZapSats?: number
230 defaultZapComment?: string
231 quickZap?: boolean
232 nsfwDisplayPolicy?: TNsfwDisplayPolicy
233 showKinds?: number[]
234 hideContentMentioningMutedUsers?: boolean
235 notificationListStyle?: TNotificationStyle
236 mediaAutoLoadPolicy?: TMediaAutoLoadPolicy
237 sidebarCollapse?: boolean
238 enableSingleColumnLayout?: boolean
239 faviconUrlTemplate?: string
240 filterOutOnionRelays?: boolean
241 quickReaction?: boolean
242 quickReactionEmoji?: string | TEmoji
243 noteListMode?: TNoteListMode
244 preferNip44?: boolean
245 nrcOnlyConfigSync?: boolean
246 autoInsertNewNotes?: boolean
247 addClientTag?: boolean
248 enableMarkdown?: boolean
249 verboseLogging?: boolean
250 fallbackRelayCount?: number
251 dmConversationFilter?: 'all' | 'follows'
252 graphQueriesEnabled?: boolean
253 socialGraphProximity?: number | null
254 socialGraphIncludeMode?: boolean
255 // Per-pubkey config (keyed by the logged-in pubkey at sync time)
256 llmConfig?: TLlmConfig | null
257 mediaUploadServiceConfig?: TMediaUploadServiceConfig
258 // Non-NIP relay configurations (application-specific)
259 searchRelays?: string[]
260 nrcRendezvousUrl?: string
261 outboxMode?: 'automatic' | 'managed'
262 relayStatsData?: string
263 }
264
265 // DM types
266 export type TDMEncryptionType = 'nip04' | 'nip17'
267
268 export interface TConversation {
269 partnerPubkey: string
270 lastMessageAt: number
271 lastMessagePreview: string
272 unreadCount: number
273 preferredEncryption: TDMEncryptionType | null
274 }
275
276 export interface TDirectMessage {
277 id: string
278 innerEventId?: string
279 senderPubkey: string
280 recipientPubkey: string
281 content: string
282 createdAt: number
283 encryptionType: TDMEncryptionType
284 event: Event
285 decryptedContent?: string
286 seenOnRelays?: string[]
287 }
288
289 // Deleted messages state (stored in kind 30078 Application Specific Data)
290 export interface TDMDeletedState {
291 // Specific message IDs to ignore
292 deletedIds: string[]
293 // Timestamp ranges to ignore per conversation
294 deletedRanges: {
295 [partnerPubkey: string]: Array<{
296 start: number // timestamp
297 end: number // timestamp
298 }>
299 }
300 }
301