SOURCE / PINNED RELEASE
Made of little things.
Drone Zone — deep field
- Release
- 578f277a8be1…
- Author-recorded commit
- a96742b428de…
- License
- LICENSE
- Author’s source reference
- nostr://npub1n8ga89w8h6tvwamxusfyzexw8gjy84yxu9rxgnmk955cxtml4ujswzxydd/wss%3A%2F%2Fgit.napplet.soy%2F/n-9753e6cf3ec
Archive hash verified: f7f3bf8ff3482551…. The source-to-build association is the author’s claim; it has not been independently rebuilt.
import type { NostrEvent } from '@napplet/sdk';
export const STATION_NADDR='naddr1qvzqqqr6q5pzqgg0xxmqr866uy7fjhyds0a2gxsjnuffdppwfse382u2f2asn5dzqqjrjd3sv43ryefe95crvvp395cnzefc94sk2wfh956nydf5xd3x2vp5vvurzhptutu';
export const STATION_PAGE=`https://wavefunc.live/station/${STATION_NADDR}`;
// Decoded from STATION_NADDR with NIP-19. Public data only; common can verify it at runtime.
export const STATION_ADDRESS={kind:31237,pubkey:'210f31b6019f5ae13c995c8d83faa41a129f1296842e4c3313ab8a4abb09d1a2',identifier:'960eb2e9-0601-11e8-ae97-52543be04c81'};
export const STATION_RELAYS=['wss://relay.wavefunc.live'];
export interface Station { name:string;url:string;mimeType:string;bitrate?:number;eventId:string }
function record(value:unknown):value is Record<string,unknown> {return typeof value==='object'&&value!==null&&!Array.isArray(value);}
/** Validate the address before using remote station metadata. Never render it as HTML. */
export function isStationEvent(event:NostrEvent):boolean {
return event.kind===STATION_ADDRESS.kind&&event.pubkey===STATION_ADDRESS.pubkey&&event.tags.some(t=>t[0]==='d'&&t[1]===STATION_ADDRESS.identifier);
}
export function parseStation(event:NostrEvent):Station {
if(!isStationEvent(event))throw new Error('Station address does not match');
let content:unknown;try{content=JSON.parse(event.content);}catch{throw new Error('Station metadata could not be read');}
if(!record(content)||!Array.isArray(content.streams))throw new Error('Station has no stream list');
const streams=content.streams.filter(record).filter(stream=>{
if(typeof stream.url!=='string')return false;
try{const url=new URL(stream.url);return ['https:','http:'].includes(url.protocol)&&!url.username&&!url.password;}catch{return false;}
});
// Prefer encrypted streams, then the publisher's primary flag.
streams.sort((a,b)=>Number(String(b.url).startsWith('https:'))-Number(String(a.url).startsWith('https:'))+Number(b.primary===true)*.1-Number(a.primary===true)*.1);
const stream=streams[0];if(!stream)throw new Error('Station has no usable audio stream');
const quality=record(stream.quality)?stream.quality:{};
return {name:(event.tags.find(t=>t[0]==='name')?.[1]||'Drone Zone').slice(0,100),url:String(stream.url),mimeType:typeof stream.format==='string'&&/^audio\/[\w.+-]+$/.test(stream.format)?stream.format:'audio/mpeg',bitrate:typeof quality.bitrate==='number'&&Number.isFinite(quality.bitrate)&&quality.bitrate>0?quality.bitrate:undefined,eventId:event.id};
}