Wednesday, 14 May 2025

jamsend - a simplification

Lets use the Web Crypto API to verify the stream distributing through a p2p network.

But then, use ed25519 instead, because:

  • available Web Crypto seems to be End-Of-Life-ing at the end of this decade (5 years away)
  • the pubkeys are much shorter... Of course, you don't need to give out the whole pubkey in a URL, just enough to prevent hash collisions (pubkeys are derived unpredictably), so that someone in the room can claim to own the room, etc.

import * as ed from '@noble/ed25519';
import { sha512 } from '@noble/hashes/sha512';
ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m));
import QrCode from "svelte-qrcode"
import SvelteCopyUrlButton from 'svelte-copy-url-button';
import { untrack } from 'svelte';
import { Idento } from './Peer.svelte';

Explains a lot
A static page
    may have an identity to find in the URL

Or you take over!

And...

Then I start to gather peers, using Trystero (webrtc p2p party plumbing) with the bittorrent strategy seems flaky and slow, so it's mqtt during development -> needs crypto.subtle... -> needs TLS -> my public Caddy server (d) needs a new... port? to put this other app over?

Hoping to make MVP this week, I swap the idea of peer-sourced media for an app server with "demo music" on it via websocket. We can gradually swap in peer-sourcing and p2p-transit some time later.

Then, the vite dev server's other websocket connection to the client, which it uses to notify of code changes (hot module reload, HMR), is closing nearly a second after the page loads, which spurs a location.reload! So it's tailspinning.

And stays that way, until I swap bun for npm, then turns into a "idealTree already exists" error, while doing npm i.

What the hell does that mean? This is bad, in retrospect it could have complained about a lack of package.json before pretending to be all good, and I doubt idealTree already exists...

Well apparently, it'll be working in (aka WORKDIR) /, in the container's short-lived overlay filesystem (per run), whereas we want it working in /app, where we've got this mount... Anyway, the readme should say:

setup

First time,

docker compose build
docker run -v .:/app jamsend-jamsend-dev bash -c "cd /app && npm i"

Thence,

docker compose up

And this took all goddamn day!

Then!

// a unique song URI hash
export type urihash = String

// sometimes requests for more audio have specifics:
export type audioi = {
// identifies a track
id: urihash,
// position they're streaming towards
index: Number,
}
// the response of part|whole
type audiole = audioi & {
blob: Uint8Array,
// < last bit -> start another from the start
done?: Boolean
}

I don't know how it's going to go decoding these blobs that are just chopped pieces of music files.

They (decoders) tend to skip forward until some kind of frame, but how would it even know the format of the stream, which might vary... 

Tomorrow's trickiness!

More here soon.

But then the editor lost my write up! How can I be proud of my work on such a machine?














No comments:

Post a Comment