npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

http3-package

v1.0.1

Published

A package for handling HTTP/3 with TLS and UDP

Downloads

112

Readme

Here's the final README.md file you can use for your project:

# HTTP/3 Node.js Package

This package provides an implementation of HTTP/3 over UDP using Node.js. It allows you to create secure, encrypted
communication channels between clients and servers using the latest HTTP/3 protocol.

## Features

- **HTTP/3 over UDP**: Implements the latest HTTP/3 protocol with UDP.
- **TLS Encryption**: Secure communication using TLS.
- **Session Management**: Supports session handling with session IDs.
- **Chunked Messaging**: Efficient handling of large messages by sending them in chunks.
- **Rate Limiting**: Implements rate limiting to control the flow of requests.

## Installation

You can install this package using npm:

```bash
npm install http3-package

Usage

Server Example

const Http3Server = require('http3-package/src/core/http3server');

const server = new Http3Server('127.0.0.1', 4434, 'path/to/server-cert.pem', 'path/to/server-key.pem');

server.setRequestHandler(async (request) => {
    console.log('Received request:', request);

    // Handle request based on method
    let response;
    if (request.method === 'GET') {
        response = {body: 'Hello, HTTP/3 with UDP! (GET)'};
    } else if (request.method === 'POST') {
        response = {body: 'Data received and processed! (POST)', data: request.payload};
    }
    return response;
});

console.log('HTTP/3 server is running');

Client Example

const Http3Client = require('http3-package/src/core/http3client');

const client = new Http3Client('localhost', 4434, 'path/to/client-cert.pem', 'path/to/client-key.pem');

const sendRequest = async () => {
    await client.initializeSession();

    const method = 'POST';
    const path = '/example';
    const headers = {
        'Content-Type': 'application/json'
    };
    const body = {
        key: 'value'
    };

    await client.sendHttpRequest(method, path, headers, body);
    console.log('HTTP/3 request sent.');
};

sendRequest();

Configuration

Before starting the HTTP/3 server and client, you need to set up the stunnel configurations.

1. Environment Variables

You can set the following environment variables or you will be prompted to enter them during the setup:

  • SERVER_ACCEPT: The server's accept address (e.g., 127.0.0.1:5000).
  • SERVER_CONNECT: The server's connect address (e.g., 127.0.0.1:4434).
  • SERVER_CERT: Path to the server's certificate file (e.g., path/to/server-cert.pem).
  • SERVER_KEY: Path to the server's private key file (e.g., path/to/server-key.pem).
  • CLIENT_ACCEPT: The client's accept address (e.g., 127.0.0.1:5001).
  • CLIENT_CONNECT: The client's connect address (e.g., 127.0.0.1:5000).
  • CLIENT_CERT: Path to the client's certificate file (e.g., path/to/client-cert.pem).
  • CLIENT_KEY: Path to the client's private key file (e.g., path/to/client-key.pem).

2. Running the Setup Script

Run the following command to generate the stunnel configuration files:

node scripts/setupStunnel.js

This script will create the necessary stunnel configuration files based on your environment variables or inputs.

Running the Server and Client

After setting up the stunnel configuration, you can start the server and client as follows:

Starting the Server

node server-example.js

Starting the Client

node client-example.js

Security Considerations

  • Ensure that your TLS certificates are securely generated and stored.
  • Regularly update your dependencies to ensure that your implementation remains secure.

Contributing

If you'd like to contribute to this project, feel free to fork the repository and submit a pull request.

License

This project is licensed under the MIT License.