JSPM

  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q89851F
  • License MIT

nosdav server

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nosdav-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    nosdav-server

    nosdav-server

    Documentation


    GitHub license npm npm Github Stars

    Introduction

    NosDAV Server is a simple and secure file server implemented using Node.js, allowing clients to store and retrieve files over HTTPS. The server validates Nostr events in the authorization header and ensures that only authorized users can store and access files.

    Features

      ✓  HTTPS server
      ✓  PUT and GET requests for uploading and downloading files
      ✓  Nostr event validation using nostr-tools
      ✓  CORS handling
      ✓  Basic file validation
      ✓  Proper response headers

    Requirements

    • Node.js v12 or higher
    • HTTPS certificate and private key

    Installation

    Clone the repository and install:

    git clone https://github.com/nosdav/server.git && cd server
    npm install

    Setup

    To use this server, you need a valid private key (privkey.pem) and a certificate (fullchain.pem) for HTTPS. Place these files in the project directory or update the file paths in the options object when creating the server. An example way to generate these is below.

    openssl req -outform PEM -keyform PEM -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout ../privkey.pem -days 365 -out ../fullchain.pem

    Usage

    Start the server:

    node server.js private-key.pem fullchain.pem node [<your-port>]

    The server will listen for incoming requests at https://localhost:3008 if port is not set

    API Endpoints

    PUT /:nostrid/:filename

    Upload a file for the given Nostr.

    Header: Authorization: Nostr base64(NostrEvent)

    {
      "kind": 27235,
      "created_at": "Math.floor(http://Date.now() / 1000)",
      "tags": [["url", "path"]],
      "content": ""
    }

    Signed with the pubkey of the user.

    Content-Type can vary according to the file being uploaded.

    GET /:nostrid/:filename

    Download a file by its name for a specific Nostr.

    Contributing

    Feel free to create a pull request if you would like to contribute or suggest improvements to the project. Please follow the existing style and add comments for any changes you make.

    License

    • MIT