Skip to content

πŸ’ͺ🏻 Rust-based, cloud-native Nostr relay derived from nostr-rs-relay.

License

Notifications You must be signed in to change notification settings

boomcrypto/denostr

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

denostr logo

GitHub release GitHub issues GitHub stars GitHub top language GitHub forks GitHub license Coverage Status Build status

πŸ’ͺ🏻 Deno-based, cloud-native Nostr relay forked from nostream.

This is a nostr relay, written in Typescript.

This implementation is production-ready. See below for supported features.

The project main repository is available on GitHub.

Features

NIPs with a relay-specific implementation are listed here.

  • NIP-01: Basic protocol flow description
  • NIP-02: Contact list and petnames
  • NIP-04: Encrypted Direct Message
  • NIP-05: Mapping Nostr keys to DNS-based internet identifiers
  • NIP-09: Event deletion
  • NIP-11: Relay information document
  • NIP-12: Generic tag queries
  • NIP-13: Proof of Work
  • NIP-15: End of Stored Events Notice
  • NIP-16: Event Treatment
  • NIP-20: Command Results
  • NIP-22: Event created_at Limits
  • NIP-26: Delegated Event Signing
  • NIP-28: Public Chat
  • NIP-33: Parameterized Replaceable Events
  • NIP-38: Encrypted Group Chat with Megolm group ratchet (Draft)
  • NIP-40: Expiration Timestamp
  • NIP-42: Authentication of clients to relays
  • NIP-45: Event Counts

Architecture

Todo

Requirements

  • Deno v1.30.x or v1.31.x
  • Typescript
  • MongoDB 4.4, 5.0, 6.0
  • Redis (Standalone Optional, Cluster Required)

kubernetes setups

  • v1.18.8 or later

Full Guide

NOTE: If the payment is enabled, it is recommended to start another instance with WORKER_TYPE=maintenance following the "Quick Start" guide.

Accepting payments

  1. Before you begin

    • Complete one of the Quick Start guides in this document
    • Create a .env file
    • On .nostr/settings.yaml file make the following changes:
      • Set payments.enabled to true
      • Set payments.feeSchedules.admission.enabled to true
      • Set limits.event.pubkey.minBalance to the minimum balance in msats required to accept events (i.e. 1000000 to require a balance of 1000 sats)
    • Choose one of the following payment processors: lnbits, lnurl, zebedee
  2. LNbits

    • Complete the step "Before you begin"

    • Create a new wallet on you public LNbits instance

      • Demo server must not be used for production
      • Your instance must be accessible from the internet and have a valid SSL/TLS certificate
    • Get wallet "Invoice/read key" (in Api docs section of your wallet)

    • set LNBITS_API_KEY environment variable with the "Invoice/read key" Key above on your .env file

      LNBITS_API_KEY={YOUR_LNBITS_API_KEY_HERE}
      
    • On your .nostr/settings.yaml file make the following changes:

      • Set payments.processor to lnbits
      • set lnbits.baseURL to your LNbits instance URL (e.g. https://{YOUR_LNBITS_DOMAIN_HERE}/)
      • Set paymentsProcessors.lnbits.callbackBaseURL to match your callbcak URL (e.g. https://{YOUR_DOMAIN_HERE}/callbacks/lnbits)
    • Restart Denostr

  3. Alby or any LNURL Provider with LNURL-verify support

    • Complete the step "Before you begin"
    • Create a new account if you don't have an LNURL
    • On your .nostr/settings.yaml file make the following changes:
      • Set payments.processor to lnurl
      • Set lnurl.invoiceURL to your LNURL (e.g. https://getalby.com/lnurlp/your-username)
    • Restart Denostr
  4. ZEBEDEE

    ZEBEDEE_API_KEY={YOUR_ZEBEDEE_API_KEY_HERE}
    
    • Follow the required steps for all payments processors
    • On .nostr/settings.yaml file make the following changes:
      • payments.processor to zebedee
      • paymentsProcessors.zebedee.callbackBaseURL to match your callback URL (e.g. https://{YOUR_DOMAIN_HERE}/callbacks/zebedee)
    • Restart Denostr
  5. Ensure payments are required for your public key

    • Visit https://{YOUR-DOMAIN}/
    • You should be presented with a form requesting an admission fee to be paid
    • Fill out the form and take the necessary steps to pay the invoice
    • Wait until the screen indicates that payment was received
    • Add your relay URL to your favorite Nostr client (wss://{YOUR-DOMAIN}) and wait for it to connect
    • Send a couple notes to test
    • Go to https://websocketking.com/ and connect to your relay (wss://{YOUR_DOMAIN})
    • Convert your npub to hexadecimal using a Key Converter
    • Send the following JSON message: ["REQ", "payment-test", {"authors":["your-pubkey-in-hexadecimal"]}]
    • You should get back the few notes you sent earlier

Quick Start (Standalone)

Clone repository and enter directory:

git clone https://github.com/denostr-lab/denostr.git --depth 1 && cd denostr

Create .env file inside denostr project folder

Set the following environment variables:

WORKER_TYPE=worker
MONGO_URI=mongodb://user:pass@host:port/db?replicaSet=rs0&authSource=admin

Generate a long random secret and set SECRET:

You may want to use openssl rand -hex 128 to generate a secret.

SECRET=aaabbbccc...dddeeefff
# Secret shortened for brevity

In addition, if using API Key for payments, You must also use the API key of each payment service to set the.

Create .nostr folder inside denostr project folder and copy over the settings file:

mkdir .nostr
cp resources/default-settings.yaml .nostr/settings.yaml

To start in development mode:

deno task dev

Or, start in production mode:

deno task start

Apply for kubernetes

Please refer to this document

Tests

Unit tests

Run unit tests with:

deno task test:unit

Integration tests

Run integration tests with:

deno task test:integration

Configuration

You can change the default folder by setting the NOSTR_CONFIG_DIR environment variable to a different path.

Run denostr using one of the quick-start guides at least once and denostr/.nostr/settings.json will be created. Any changes made to the settings file will be read on the next start.

Default settings can be found under resources/default-settings.yaml. Feel free to copy it to denostr/.nostr/settings.yaml if you would like to have a settings file before running the relay first.

See CONFIGURATION.md for a detailed explanation of each environment variable and setting.

Dev Channel

For development discussions, please use the Nostr Typescript Relay Dev Group.

For discussions about the protocol, please feel free to use the Nostr Telegram Group.

License

This project is MIT licensed.

About

πŸ’ͺ🏻 Rust-based, cloud-native Nostr relay derived from nostr-rs-relay.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 94.8%
  • HTML 3.8%
  • Other 1.4%