forked from rust-nostr/nostr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
217 lines (215 loc) · 7.53 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/** Encrypt (NIP04) */
export function encrypt(sk: SecretKey, pk: PublicKey, text: string): string
/** Decrypt (NIP04) */
export function decrypt(sk: SecretKey, pk: PublicKey, encryptedContent: string): string
/** Verify NIP05 */
export function verifyNip05(publicKey: PublicKey, nip05: string): Promise<boolean>
/**
* Create a NIP-26 delegation tag (including the signature).
* See also validate_delegation_tag().
*/
export function createDelegationTag(delegatorKeys: Keys, delegateePubkey: PublicKey, conditions: string): string
/** Validate a NIP-26 delegation tag, check signature and conditions. */
export function validateDelegationTag(delegationTag: string, delegateePubkey: PublicKey, eventKind: bigint, createdAt: bigint): boolean
/** Sign delegation (NIP26) */
export function signDelegation(keys: Keys, delegateePk: PublicKey, conditions: string): string
/** Verify delegation signature (NIP26) */
export function verifyDelegationSignature(delegatorPublicKey: PublicKey, delegateePublicKey: PublicKey, conditions: string, signature: string): boolean
export type JsEventBuilder = EventBuilder
export class EventBuilder {
constructor(kind: bigint, content: string, tags: Array<Array<string>>)
toEvent(keys: JsKeys): JsEvent
toPowEvent(keys: JsKeys, difficulty: number): JsEvent
static setMetadata(metadata: JsMetadata): JsEventBuilder
static addRecommendedRelay(url: string): JsEventBuilder
static newTextNote(content: string, tags: Array<Array<string>>): JsEventBuilder
static setContactList(list: Array<JsContact>): JsEventBuilder
static newEncryptedDirectMsg(senderKeys: JsKeys, receiverPubkey: JsPublicKey, content: string): JsEventBuilder
static repost(eventId: JsEventId, publicKey: JsPublicKey): JsEventBuilder
static delete(ids: Array<JsEventId>, reason?: string | undefined | null): JsEventBuilder
static newReaction(eventId: JsEventId, publicKey: JsPublicKey, content: string): JsEventBuilder
static newChannel(metadata: JsMetadata): JsEventBuilder
static setChannelMetadata(channelId: JsChannelId, relayUrl: string | undefined | null, metadata: JsMetadata): JsEventBuilder
static newChannelMsg(channelId: JsChannelId, relayUrl: string, content: string): JsEventBuilder
static hideChannelMsg(messageId: JsEventId, reason?: string | undefined | null): JsEventBuilder
static muteChannelUser(pubkey: JsPublicKey, reason?: string | undefined | null): JsEventBuilder
static auth(challenge: string, relay: string): JsEventBuilder
}
export type JsEventId = EventId
export class EventId {
constructor(pubkey: JsPublicKey, createdAt: bigint, kind: bigint, tags: Array<Array<string>>, content: string)
static fromSlice(bytes: Array<number>): JsEventId
static fromHex(hex: string): JsEventId
static fromBech32(id: string): JsEventId
asBytes(): Array<number>
toHex(): string
toBech32(): string
}
export type JsEvent = Event
export class Event {
get id(): EventId
get pubkey(): JsPublicKey
get createdAt(): bigint
get kind(): bigint
get tags(): Array<Array<string>>
get content(): string
get signature(): string
verify(): boolean
static fromJson(json: string): JsEvent
asJson(): string
}
export type JsPublicKey = PublicKey
export class PublicKey {
static fromHex(hex: string): JsPublicKey
static fromBech32(pk: string): JsPublicKey
toHex(): string
toBech32(): string
}
export type JsSecretKey = SecretKey
export class SecretKey {
static fromHex(hex: string): JsSecretKey
static fromBech32(sk: string): JsSecretKey
toHex(): string
toBech32(): string
}
export type JsKeys = Keys
export class Keys {
/** Initialize from secret key. */
constructor(secretKey: SecretKey)
/** Initialize with public key only (no secret key). */
static fromPublicKey(publicKey: PublicKey): JsKeys
/** Init [`Keys`] from `hex` or `bech32` secret key string */
static fromSkStr(secretKey: string): JsKeys
/** Init [`Keys`] from `hex` or `bech32` public key string */
static fromPkStr(publicKey: string): JsKeys
/** Generate new random keys */
static generate(): JsKeys
/** Derive keys from BIP-39 mnemonics (ENGLISH wordlist). */
static fromMnemonic(mnemonic: string, passphrase?: string | undefined | null): JsKeys
/** Get public key */
publicKey(): PublicKey
/** Get secret key */
secretKey(): SecretKey
}
export type JsSubscriptionId = SubscriptionId
export class SubscriptionId {
constructor(id: string)
/** Generate new random [`SubscriptionId`] */
static generate(): JsSubscriptionId
get get(): string
}
export type JsFilter = Filter
export class Filter {
constructor()
/** Set subscription id */
id(id: string): Filter
/** Set subscription ids */
ids(ids: Array<string>): Filter
/** Set author */
author(author: PublicKey): Filter
/** Set authors */
authors(authors: Array<PublicKey>): Filter
/** Set kind */
kind(kind: bigint): Filter
/** Set kinds */
kinds(kinds: Array<bigint>): Filter
/** Set event */
event(id: EventId): Filter
/** Set events */
events(ids: Array<EventId>): Filter
/** Set pubkey */
pubkey(pubkey: PublicKey): Filter
/** Set pubkeys */
pubkeys(pubkeys: Array<PublicKey>): Filter
/**
* Set hashtag
*
* <https://github.com/nostr-protocol/nips/blob/master/12.md>
*/
hashtag(hashtag: string): Filter
/**
* Set hashtags
*
* <https://github.com/nostr-protocol/nips/blob/master/12.md>
*/
hashtags(hashtags: Array<string>): Filter
/**
* Set reference
*
* <https://github.com/nostr-protocol/nips/blob/master/12.md>
*/
reference(v: string): Filter
/**
* Set references
*
* <https://github.com/nostr-protocol/nips/blob/master/12.md>
*/
references(v: Array<string>): Filter
/** Set search field */
search(value: string): Filter
/** Set since unix timestamp */
since(since: bigint): Filter
/** Set until unix timestamp */
until(until: bigint): Filter
/** Set limit */
limit(limit: bigint): Filter
}
export type JsRelayInformationDocument = RelayInformationDocument
export class RelayInformationDocument {
constructor()
get name(): string | null
get description(): string | null
get pubkey(): string | null
get contact(): string | null
get supportedNips(): Array<number> | null
get software(): string | null
get version(): string | null
}
export type JsChannelId = ChannelId
/**
* Channel Id
*
* Kind 40 event id (32-bytes lowercase hex-encoded)
*
* https://github.com/nostr-protocol/nips/blob/master/19.md
*/
export class ChannelId {
/** New [`ChannelId`] */
constructor(eventId: EventId, relays: Array<string>)
/** [`ChannelId`] from bytes */
static fromSlice(sl: Array<number>): JsChannelId
/** [`ChannelId`] hex string */
static fromHex(hex: string): JsChannelId
/** [`ChannelId`] bech32 string */
static fromBech32(id: string): JsChannelId
/** Get as bytes */
get asBytes(): Array<number>
/** Get as hex string */
get toHex(): string
/** Get as bech32 string */
get toBech32(): string
/** Get relays */
get relays(): Array<string>
}
export type JsContact = Contact
export class Contact {
constructor(publicKey: PublicKey, relayUrl?: string | undefined | null, alias?: string | undefined | null)
}
export type JsMetadata = Metadata
export class Metadata {
constructor()
static fromJson(json: string): JsMetadata
asJson(): string
name(name: string): Metadata
displayName(displayName: string): Metadata
about(about: string): Metadata
website(url: string): this
picture(url: string): this
banner(url: string): this
nip05(nip05: string): Metadata
lud06(lud06: string): Metadata
lud16(lud16: string): Metadata
}