nostr-websocket-utils / Nip46Transport
Defined in: nips/nip-46.ts:61
A thin transport layer that bridges nostr-crypto-utils NIP-46 protocol with the WebSocket relay infrastructure in this library.
Usage:
const client = new NostrWSClient(['wss://relay.example.com']);
await client.connect();
const session = nip46.createSession(remotePubkey);
const transport = new Nip46Transport(client, session);
// Send a connect request
const connectReq = nip46.connectRequest(remotePubkey, secret);
const result = await transport.sendRequest(connectReq);
new Nip46Transport(
client,session,options?):Nip46Transport
Defined in: nips/nip-46.ts:66
Nip46Session
Nip46Transport
privateclient:NostrWSClient
Defined in: nips/nip-46.ts:62
privatesession:Nip46Session
Defined in: nips/nip-46.ts:63
privatetimeout:number
Defined in: nips/nip-46.ts:64
subscribe(
subscriptionId,since?):Promise<NostrWSMessage>
Defined in: nips/nip-46.ts:83
Subscribe for NIP-46 response events addressed to our ephemeral pubkey. This sends a REQ message to the relay with the appropriate filter.
string
Subscription ID for the REQ message
number
Optional since timestamp for the filter
Promise<NostrWSMessage>
The subscription message that was sent
publishRequest(
request):Promise<SignedNostrEvent>
Defined in: nips/nip-46.ts:99
Wrap and publish a NIP-46 request as a kind 24133 event.
Nip46Request
NIP-46 JSON-RPC request
Promise<SignedNostrEvent>
The signed kind 24133 event that was published
unwrapEvent(
event):Nip46Response|Nip46Request|null
Defined in: nips/nip-46.ts:118
Attempt to unwrap a kind 24133 event into a NIP-46 request or response. Returns null if the event is not kind 24133 or decryption fails.
SignedNostrEvent
A signed Nostr event
Nip46Response | Nip46Request | null
Decrypted NIP-46 payload, or null on failure
getResponseFilter(
since?):object
Defined in: nips/nip-46.ts:134
Get the NIP-46 response filter for this session. Useful for manual subscription management.
number
Optional since timestamp
object
Filter object for kind 24133 events tagged to our pubkey
kinds:
number[]
#p:
string[]
optionalsince:number
getSessionInfo():
object
Defined in: nips/nip-46.ts:142
Get the current session (read-only info).
object
The session’s client and remote pubkeys
clientPubkey:
string
remotePubkey:
string