Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nostr-tools

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nostr-tools

Tools for making a Nostr client.

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-1.32%
Maintainers
1
Weekly downloads
 
Created
Source

nostr-tools

Tools for developing Nostr clients.

Usage

import {relayPool} from 'nostr-tools'

const pool = relayPool()

pool.setPrivateKey('<hex>') // optional

pool.addRelay('ws://some.relay.com', {read: true, write: true})
pool.addRelay('ws://other.relay.cool', {read: true, write: true})

pool.onEvent((event, context, relay) => {
  console.log(`got a relay with context ${context} from ${relay.url} which is already validated.`, event)
})

// subscribing to users and requesting specific users or events:
pool.subKey('<hex>')
pool.subKey('<hex>')
pool.subKey('<hex>')
pool.reqFeed()
pool.reqEvent({id: '<hex>'})
pool.reqKey({key: '<hex>'})
// upon request the events will be received on .onEvent above

// publishing events:
pool.publish(<event object>)
// it will be signed automatically with the key supplied above
// or pass an already signed event to bypass this

// subscribing to a new relay
pool.addRelay('<url>')
// will automatically subscribe to the all the keys called with .subKey above

For other utils please read the source (for now).

Keywords

FAQs

Package last updated on 12 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc