Fone MusicFlow companion lab: HTTP byte ranges for audio

Independent educational implementation. No product source, paid services,
copyrighted music, private keys, or production credentials are included.
Tested runtime: Node.js 24.0.1 on macOS. No npm dependencies.

Extract the ZIP into a new directory and open a terminal there.

1. node tone.mjs
   Creates tone.wav, 132344 bytes, three seconds of synthetic PCM tone.
   Refuses to overwrite an existing file. This is not AI-generated music.
2. node --test server.test.mjs
   Expected: 14 pass, 0 fail. Tests use temporary audio and ephemeral localhost
   ports. They do not depend on the tone.wav created in step 1.
3. node server.mjs tone.wav 8787
   Only listens on 127.0.0.1. Ctrl-C stops it. Change 8787 if occupied.
4. In a second terminal:
   curl -sS -D - -o /dev/null -H 'Range: bytes=44-143' http://127.0.0.1:8787/sample.wav
   Expected 206, Content-Length 100, Content-Range bytes 44-143/132344.
   curl -sS -I -H 'Range: bytes=0-9' http://127.0.0.1:8787/sample.wav
   Expected 200, full Content-Length 132344, no body or Content-Range.
   curl -sS -D - -o /dev/null http://127.0.0.1:8787/private.wav
   Expected 404 with no file metadata.
   curl -sS -D - -o /dev/null -H 'Authorization: Bearer demo-owner' -H 'Range: bytes=0-9' http://127.0.0.1:8787/private.wav
   Expected 206 with 10 bytes. demo-owner is a PUBLIC test token, not real auth.

Supported: one closed/open/suffix byte range, GET, HEAD, empty files.
Ignored: invalid range syntax, unsupported units, multipart ranges.
Valid but unsatisfiable: 416. HEAD ignores Range and returns full headers.
File is assumed immutable while serving. No TLS, actual user authentication,
customer license state, CDN, conditional If-Range support, or codec conversion.
No compatibility/production/security audit is claimed.

Streaming checks do not prove that every browser can seek every audio format.
The private path demonstrates access-check ordering only. Replace it with a
real authentication and authorization policy before any deployment.

Educational code copyright Fone, 2026. You may use and modify these original
teaching files with attribution. Provided as-is without a production guarantee.
