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

@huddle01/server-sdk

v2.5.2

Published

The Huddle01 Server SDK allows you to perform protected admin actions on your server side, like generating peer access tokens and starting and stopping meeting recordings and livestreams.

Downloads

396

Readme

Huddle01 Server SDK

https://huddle01-assets-frontend.s3.amazonaws.com/general/huddle01-logo-blue.svg

The Huddle01 Server SDK allows you to perform protected admin actions on your server side, like generating peer access tokens and starting and stopping meeting recordings and livestreams.

Installation

npm install @huddle01/server-sdk
bun add @huddle01/server-sdk
pnpm i @huddle01/server-sdk
bun install @huddle01/server-sdk

Auth

To enable client apps to establish connections with Huddle01 rooms, they require a token that is produced by your backend server. This guide will lead you through the process of configuring a server to create tokens for your clients.

import { AccessToken, Role } from "@huddle01/server-sdk/auth";

const accessToken = new AccessToken({
  apiKey: "YOUR_API_KEY",
  roomId: "YOUR_ROOM_ID",
  //available roles: Role.HOST, Role.CO_HOST, Role.SPEAKER, Role.LISTENER, Role.GUEST - depending on the privileges you want to give to the user
  role: Role.HOST,
  //custom permissions give you more flexibility in terms of the user privileges than a pre-defined role
  permissions: {
    admin: true,
    canConsume: true,
    canProduce: true,
    canProduceSources: {
      cam: true,
      mic: true,
      screen: true,
    },
    canRecvData: true,
    canSendData: true,
    canUpdateMetadata: true,
  },
  options: {
    metadata: {
      // you can add any custom attributes here which you want to associate with the user
      walletAddress: "mizanxali.eth",
    },
  },
});

const token = accessToken.toJwt();

Recording/ Livestreaming

Server side helpers to start/stop recording and livestreaming

import { Recorder } from "@huddle01/server-sdk/recorder";

const recorder = new Recorder("PROJECT_ID", "API_KEY");

1. Start recording

/**
 * @returns {
 *  msg: string,
 * }
 */
const { msg } = recorder.startRecording({
  roomId: "YOUR_ROOM_ID",
  token,
});

console.log({ msg });

2. Start Livestream

Start a livestream and we can stream it to multiple RTMP endpoints.

/**
 * @returns {
 *  msg: string,
 * }
 */
const { msg } = await recorder.startLivestream({
  roomId: "ROOM_ID",
  token: "TOKEN_FOR_RECORDER" ,
  rtmpUrls: ["rtmp://example.com/live"],
  recordLivestream: true; // false by default
});

console.log({ msg });

3. Stop recording/livestream

/**
 * @returns {
 *  msg: string,
 * }
 */
recorder.stop({
  roomId: "YOUR_ROOM_ID",
});

Webhooks

The WebhookReceiver is securely receiving and verifying Huddle01 webhooks. It provides functionality to validate webhook signatures, extract webhook data, and ensure timing-safe comparisons. The crypto libraries are environment independent allowing use across Node.JS, Cloudflare Worker etc

1. Initialization

First, import and initialize the WebhookReceiver with your API key:

import { WebhookReceiver } from "webhook-receiver";

const receiver = new WebhookReceiver({ apiKey: "YOUR_API_KEY" });

2. Receiving Webhooks

To receive and verify a webhook:

try {
  const webhookData = await receiver.receiveAsync(requestBody, signatureHeader);
  console.log("Verified webhook data:", webhookData);
} catch (error) {
  console.error("Webhook verification failed:", error.message);
}