2026-03-13 02:37:59 +00:00
< template >
2026-03-14 17:12:41 +00:00
< div class = "pb-6" >
2026-06-17 19:21:42 -04:00
<!-- Header with back button — shared component so peer files match local
files ( CloudFolder ) on both desktop and mobile . -- >
2026-03-14 17:12:41 +00:00
< div class = "shrink-0 mb-4" >
2026-06-17 19:21:42 -04:00
< BackButton label = "Back to Cloud" @click ="goBack" / >
2026-03-14 17:12:41 +00:00
<!-- Peer Header -- >
< div class = "flex items-center gap-4" >
< div class = "flex-shrink-0 w-12 h-12 rounded-xl flex items-center justify-center bg-purple-500/15" >
< svg class = "w-7 h-7 text-purple-400" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2" / >
< / svg >
< / div >
< div class = "hidden md:block" >
2026-06-15 13:25:39 -04:00
< div class = "flex items-center gap-2" >
< h1 class = "text-2xl font-bold text-white" > { { peerDisplayName } } < / h1 >
< span
v - if = "transportPill"
: class = "transportPill.cls"
: title = "transportPill.title"
class = "text-xs px-2 py-0.5 rounded-full font-medium"
> { { transportPill . label } } < / span >
< / div >
2026-03-20 02:59:29 +00:00
< p v-if = "currentPeer?.did" class="text-sm text-white/50 font-mono truncate max-w-md" :title="currentPeer.did" > {{ currentPeer.did }} < / p >
< p v -else class = "text-sm text-white/50" > Peer files < / p >
2026-03-13 02:37:59 +00:00
< / div >
< / div >
2026-03-14 17:12:41 +00:00
< / div >
2026-03-13 02:37:59 +00:00
2026-03-14 17:12:41 +00:00
<!-- Loading -- >
2026-06-11 00:24:40 -04:00
< div v-if = "loading && catalogItems.length === 0" class="glass-card p-8 text-center" >
2026-03-14 17:12:41 +00:00
< svg class = "animate-spin h-6 w-6 text-purple-400 mx-auto mb-2" xmlns = "http://www.w3.org/2000/svg" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " > < / circle >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" > < / path >
< / svg >
2026-06-15 13:25:39 -04:00
< p class = "text-white/50 text-sm" > Connecting to peer … This may take a few seconds . < / p >
2026-03-14 17:12:41 +00:00
< / div >
2026-03-13 02:37:59 +00:00
2026-03-14 17:12:41 +00:00
<!-- Error -- >
2026-06-11 00:24:40 -04:00
< div v -else -if = " catalogError & & catalogItems.length = = = 0 " class = "glass-card p-6" >
security+feat: v1.3.0 — pentest remediation, container reliability, UI overhaul
Security (33 pentest findings addressed):
- CRITICAL: backend binds 127.0.0.1, path traversal in tor.rs/dwn fixed
- HIGH: federation requires signatures, XSS login redirect, RBAC viewer restricted
- HIGH: tar slip prevention, S3 SSRF validation, backup ID validation
- MEDIUM: remember-me random secret, TOTP session rotation, password re-auth
- LOW: CSP unsafe-inline removed, CORS dev-only, onion/webhook validation
Container reliability:
- Memory limits on all 37 containers (OOM prevention)
- Exited vs stopped state distinction with health-aware status badges
- Crash recovery coordination (no more restart cascade)
- User-stopped tracking survives reboots
- Tiered boot recovery (databases → core → services → apps)
UI:
- Wallet TransactionsModal, health-aware app status badges
- Restart button on containers, exited/crashed red state
- Mesh view overhaul, glass button updates, BaseModal/ToggleSwitch
- Apps sticky header removed, dev faucet, mutable mock wallet
Infrastructure:
- LND REST port 8080 exposed over Tor (LND Connect fix)
- Nginx cookie_session fix, deploy script Tor config updated
- Dev environment: podman auto-start, boot mode simulation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 12:44:31 +00:00
< div class = "alert-error mb-4" > { { catalogError } } < / div >
2026-03-14 17:12:41 +00:00
< button class = "glass-button px-4 py-2 rounded-lg text-sm" @click ="loadCatalog" > Retry < / button >
< / div >
2026-03-13 02:37:59 +00:00
2026-03-14 17:12:41 +00:00
<!-- Empty -- >
< div v -else -if = " catalogItems.length = = = 0 & & ! loading " class = "glass-card p-8 text-center" >
< p class = "text-white/50" > This peer has no shared files . < / p >
< / div >
2026-03-13 02:37:59 +00:00
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
<!-- Purchase error -- >
< div v-if = "purchaseError" class="glass-card p-3 mb-4 flex items-center gap-3 border border-red-500/30" >
< svg class = "w-4 h-4 text-red-400 flex-shrink-0" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" / >
< / svg >
< span class = "text-sm text-red-400 flex-1" > { { purchaseError } } < / span >
< button class = "text-xs text-white/50 hover:text-white" @ click = "purchaseError = null" > Dismiss < / button >
< / div >
2026-03-14 17:12:41 +00:00
<!-- File Grid -- >
2026-06-11 00:24:40 -04:00
< div v-if = "catalogItems.length > 0" class="space-y-3" >
< div v-if = "loading" class="p-2 text-center text-white/45 text-xs flex items-center justify-center gap-2" >
< svg class = "animate-spin h-3.5 w-3.5" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " > < / circle >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" > < / path >
< / svg >
Refreshing peer files ...
< / div >
< div v -else -if = " catalogError " class = "p-3 rounded-lg border border-red-400/20 bg-red-500/10 text-red-200/85 text-sm" >
{ { catalogError } }
< / div >
< div class = "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" >
< div
v - for = "item in catalogItems"
: key = "item.id"
2026-06-16 09:27:29 -04:00
class = "glass-card overflow-hidden flex flex-col h-full"
2026-06-11 00:24:40 -04:00
>
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
<!-- Media preview ( images / videos / audio ) -- >
< div
v - if = "isMediaMime(item.mime_type)"
class = "relative aspect-video overflow-hidden cursor-pointer group"
@ click = "isPlayable(item.mime_type) ? playMedia(item) : undefined"
>
< img
v - if = "item.mime_type.startsWith('image/') && previewUrls[item.id]"
: src = "previewUrls[item.id]"
: alt = "item.filename"
class = "w-full h-full object-cover"
: style = "isPaidItem(item.access) ? 'filter: blur(16px); transform: scale(1.15);' : ''"
/ >
< video
v - else - if = "item.mime_type.startsWith('video/') && previewUrls[item.id]"
: src = "previewUrls[item.id]"
2026-04-11 23:59:55 -04:00
class = "w-full h-full object-cover pointer-events-none"
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
muted
autoplay
loop
playsinline
/ >
<!-- Audio waveform placeholder -- >
< div v -else -if = " item.mime_type.startsWith ( ' audio / ' ) " class = "w-full h-full flex flex-col items-center justify-center bg-gradient-to-br from-orange-500/10 to-orange-600/5" >
< svg class = "w-12 h-12 text-orange-400" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3" / >
< / svg >
< p class = "mt-2 text-xs text-white/50 truncate max-w-[80%]" > { { item . filename . split ( '/' ) . pop ( ) } } < / p >
< / div >
< div v -else class = "w-full h-full flex items-center justify-center" :class = "fileIconBg(item.mime_type)" >
< svg class = "w-10 h-10" :class = "fileIconColor(item.mime_type)" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " :d = "fileIconPath(item.mime_type)" / >
< / svg >
< / div >
<!-- Play button overlay for video / audio -- >
< div
v - if = "isPlayable(item.mime_type)"
class = "absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/30 transition-colors"
2026-03-14 17:12:41 +00:00
>
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
< div class = "w-12 h-12 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity" >
< svg class = "w-6 h-6 text-white ml-0.5" fill = "currentColor" viewBox = "0 0 24 24" >
< path d = "M8 5v14l11-7L8 5z" / >
< / svg >
< / div >
< / div >
<!-- Paid badge ( top - right ) -- >
< div v-if = "isPaidItem(item.access)" class="absolute top-2 right-2 flex items-center gap-1.5 px-2 py-1 rounded-lg bg-black/60 backdrop-blur-sm" >
< svg class = "w-4 h-4 text-orange-400" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" / >
< / svg >
< span class = "text-xs font-medium text-orange-400" > { { getItemPrice ( item . access ) } } sats < / span >
< / div >
<!-- Preview badge for paid playable items -- >
< div v-if = "isPaidItem(item.access) && isPlayable(item.mime_type)" class="absolute bottom-2 left-2 px-2 py-0.5 rounded bg-black/60 backdrop-blur-sm" >
< span class = "text-xs text-white/70" > 10 % preview < / span >
< / div >
< / div >
2026-06-16 09:27:29 -04:00
<!-- Card body — pinned to the bottom so the filename + action buttons
line up across cards of differing preview heights . -- >
< div class = "p-4 flex items-center gap-4 mt-auto" >
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
< div v-if = "!isMediaMime(item.mime_type)" class="flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center" :class="fileIconBg(item.mime_type)" >
< svg class = "w-5 h-5" :class = "fileIconColor(item.mime_type)" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " :d = "fileIconPath(item.mime_type)" / >
< / svg >
< / div >
< div class = "flex-1 min-w-0" >
< p class = "text-sm font-medium text-white truncate" > { { item . filename } } < / p >
< p class = "text-xs text-white/40" > { { formatSize ( item . size _bytes ) } } < / p >
< / div >
< div class = "flex items-center gap-2" >
< span
v - if = "!isPaidItem(item.access)"
class = "text-xs px-2 py-0.5 rounded-full"
: class = "accessBadgeClass(item.access)"
>
{ { accessLabel ( item . access ) } }
< / span >
<!-- Play button for audio / video -- >
< button
v - if = "isPlayable(item.mime_type)"
class = "glass-button px-3 py-1.5 rounded-lg text-xs font-medium flex items-center gap-1.5"
: disabled = "playing === item.id"
@ click = "playMedia(item)"
>
< template v-if = "playing === item.id" >
< div class = "w-3 h-3 border-2 border-white/20 border-t-white/80 rounded-full animate-spin" > < / div >
< span > Loading ... < / span >
< / template >
< template v-else >
< svg class = "w-3.5 h-3.5" fill = "currentColor" viewBox = "0 0 24 24" >
< path d = "M8 5v14l11-7L8 5z" / >
< / svg >
< span > { { isPaidItem ( item . access ) ? 'Preview' : 'Play' } } < / span >
< / template >
< / button >
< button
class = "glass-button px-3 py-1.5 rounded-lg text-xs font-medium flex items-center gap-1.5"
: disabled = "downloading === item.id"
@ click = "downloadFile(item)"
>
< template v-if = "downloading === item.id" >
< div class = "w-3 h-3 border-2 border-white/20 border-t-white/80 rounded-full animate-spin" > < / div >
< span > { { isPaidItem ( item . access ) ? 'Paying...' : 'Loading...' } } < / span >
< / template >
< template v -else -if = " isPaidItem ( item.access ) " >
< svg class = "w-3.5 h-3.5 text-orange-400" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M13 10V3L4 14h7v7l9-11h-7z" / >
< / svg >
< span > Buy { { getItemPrice ( item . access ) } } sats < / span >
< / template >
< template v-else >
< svg class = "w-3.5 h-3.5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" / >
< / svg >
< span > Download < / span >
< / template >
< / button >
< / div >
2026-03-13 02:37:59 +00:00
< / div >
2026-06-11 00:24:40 -04:00
< / div >
2026-03-13 02:37:59 +00:00
< / div >
< / div >
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
<!-- Video player modal -- >
< Teleport to = "body" >
< Transition name = "fade" >
< div
v - if = "videoPlayerUrl && videoPlayerItem"
class = "fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm"
@ click . self = "closeVideoPlayer"
>
< div class = "relative w-full max-w-4xl mx-4" >
<!-- Close button -- >
< button
class = "absolute -top-10 right-0 text-white/60 hover:text-white transition-colors"
@ click = "closeVideoPlayer"
>
< svg class = "w-6 h-6" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M6 18L18 6M6 6l12 12" / >
< / svg >
< / button >
<!-- Video element -- >
2026-06-16 05:45:17 -04:00
< div class = "relative" >
< video
: src = "videoPlayerUrl"
class = "w-full rounded-xl bg-black"
controls
autoplay
@ playing = "videoLoading = false"
@ canplay = "videoLoading = false"
@ error = "videoLoading = false; videoError = true"
/ >
<!-- Loader while the stream connects over mesh / Tor -- >
< div v-if = "videoLoading && !videoError" class="absolute inset-0 flex flex-col items-center justify-center gap-3 rounded-xl bg-black/60 pointer-events-none" >
< svg class = "w-8 h-8 animate-spin text-white/80" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " / >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.4 0 0 5.4 0 12h4z" / >
< / svg >
< span class = "text-sm text-white/70" > Connecting to peer … < / span >
< / div >
<!-- Error state -- >
< div v-if = "videoError" class="absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-xl bg-black/70 text-center px-4" >
< p class = "text-sm text-white/80" > Couldn ' t play this video < / p >
< p class = "text-xs text-white/50" > The peer may be offline , or this preview can ' t be played . Try downloading it instead . < / p >
< / div >
< / div >
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
<!-- Info bar -- >
< div class = "mt-3 flex items-center justify-between" >
< div >
< p class = "text-sm font-medium text-white" > { { videoPlayerItem . filename . split ( '/' ) . pop ( ) } } < / p >
< p class = "text-xs text-white/40" > { { formatSize ( videoPlayerItem . size _bytes ) } } < / p >
< / div >
< div v-if = "videoPlayerPaid" class="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-orange-500/15" >
< svg class = "w-3.5 h-3.5 text-orange-400" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" / >
< / svg >
< span class = "text-xs text-orange-400" > 10 % preview - Buy to unlock full < / span >
< / div >
< / div >
< / div >
< / div >
< / Transition >
< / Teleport >
2026-06-17 19:21:42 -04:00
<!-- Payment method picker / Lightning invoice QR ( # 46 ) -- >
< Teleport to = "body" >
< Transition name = "fade" >
< div
v - if = "payItem"
class = "fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4"
@ click . self = "closePayModal"
>
< div class = "glass-card w-full max-w-md p-5 rounded-2xl relative" >
< button
class = "absolute top-3 right-3 text-white/50 hover:text-white transition-colors"
@ click = "closePayModal"
>
< svg class = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M6 18L18 6M6 6l12 12" / >
< / svg >
< / button >
< h3 class = "text-base font-semibold text-white mb-1" > Buy this file < / h3 >
< p class = "text-xs text-white/50 mb-4 truncate" >
{ { payItem . filename . split ( '/' ) . pop ( ) } } · { { getItemPrice ( payItem . access ) } } sats
< / p >
<!-- Step 1 : choose a payment method -- >
< div v-if = "payMode === 'choose'" class="space-y-3" >
< button
class = "w-full glass-button px-4 py-3 rounded-xl flex items-center justify-start gap-3 text-left"
: disabled = "downloading === payItem.id"
@ click = "payWithEcash"
>
< svg class = "w-6 h-6 text-green-400 shrink-0" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" / >
< / svg >
< span >
< span class = "block text-base text-white" > { { downloading === payItem . id ? 'Paying…' : 'Pay from this node’ s ecash wallet' } } < / span >
< span class = "block text-sm text-white/50" > Instant , using your ecash balance < / span >
< / span >
< / button >
< button
class = "w-full glass-button px-4 py-3 rounded-xl flex items-center justify-start gap-3 text-left"
: disabled = "lnPaying"
@ click = "payWithLightning"
>
< svg class = "w-6 h-6 text-yellow-400 shrink-0" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M13 10V3L4 14h7v7l9-11h-7z" / >
< / svg >
< span >
< span class = "block text-base text-white" > { { lnPaying ? 'Paying…' : 'Pay with my Lightning node' } } < / span >
< span class = "block text-sm text-white/50" > Pays the seller ’ s invoice from your node ’ s Lightning wallet < / span >
< / span >
< / button >
< button
class = "w-full glass-button px-4 py-3 rounded-xl flex items-center justify-start gap-3 text-left"
: disabled = "lnPaying || onchainPaying"
2026-06-19 05:03:18 -04:00
@ click = "openQrPay"
2026-06-17 19:21:42 -04:00
>
< svg class = "w-6 h-6 text-amber-400 shrink-0" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M10.5 1.5H8.25A2.25 2.25 0 006 3.75v16.5a2.25 2.25 0 002.25 2.25h7.5A2.25 2.25 0 0018 20.25V3.75a2.25 2.25 0 00-2.25-2.25H13.5m-3 0V3h3V1.5m-3 0h3m-3 18.75h3" / >
< / svg >
< span >
< span class = "block text-base text-white" > Pay from another wallet ( QR ) < / span >
2026-06-19 05:03:18 -04:00
< span class = "block text-sm text-white/50" > Scan an on - chain or Lightning QR with any wallet < / span >
2026-06-17 19:21:42 -04:00
< / span >
< / button >
< button
class = "w-full glass-button px-4 py-3 rounded-xl flex items-center justify-start gap-3 text-left"
: disabled = "lnPaying || onchainPaying"
@ click = "payOnchain"
>
< svg class = "w-6 h-6 text-orange-400 shrink-0" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
< path stroke -linecap = " round " stroke -linejoin = " round " stroke -width = " 2 " d = "M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" / >
< / svg >
< span >
< span class = "block text-base text-white" > { { onchainPaying ? 'Sending…' : 'Pay on-chain from my node' } } < / span >
< span class = "block text-sm text-white/50" > Sends Bitcoin on - chain from your node ’ s wallet ( slower ) < / span >
< / span >
< / button >
< p v-if = "lnError" class="text-xs text-red-400 px-1" > {{ lnError }} < / p >
< / div >
2026-06-19 05:03:18 -04:00
<!-- Step 2 : pay from another wallet — tabbed QR ( on - chain default ) -- >
< div v-else >
<!-- Method tabs , styled like the wallet Send / Receive modal -- >
< div class = "flex gap-1 mb-4 p-1 bg-white/5 rounded-lg" >
< button
v - for = "m in (['onchain', 'lightning'] as const)"
: key = "m"
@ click = "selectQrTab(m)"
class = "flex-1 px-2 py-1.5 rounded text-xs font-medium transition-colors"
: class = "qrTab === m ? 'bg-white/15 text-white' : 'text-white/50 hover:text-white/80'"
> { { m === 'onchain' ? 'On-chain' : 'Lightning' } } < / button >
2026-06-17 19:21:42 -04:00
< / div >
2026-06-19 05:03:18 -04:00
<!-- On - chain QR -- >
< div v-if = "qrTab === 'onchain'" class="text-center" >
< div v-if = "onchainWaiting && !onchainData" class="py-10 flex flex-col items-center gap-3" >
< svg class = "w-7 h-7 animate-spin text-white/80" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " / >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.4 0 0 5.4 0 12h4z" / >
< / svg >
< span class = "text-sm text-white/70" > Requesting an address from the seller … < / span >
< / div >
< div v -else -if = " onchainData " >
< div v-if = "onchainQr" class="bg-white rounded-xl p-3 inline-block mb-3" >
< img :src = "onchainQr" alt = "On-chain payment QR" class = "w-48 h-48" / >
< / div >
< p class = "text-sm text-white mb-1" > { { onchainData . amount _sats } } sats < / p >
< p class = "text-xs text-white/50 mb-3 flex items-center justify-center gap-2" >
< svg class = "w-3.5 h-3.5 animate-spin text-orange-400" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " / >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.4 0 0 5.4 0 12h4z" / >
< / svg >
Waiting for payment …
< / p >
< div class = "flex items-center gap-2 bg-black/40 rounded-lg px-2 py-1.5" >
< code class = "text-[10px] text-white/60 truncate flex-1 text-left" > { { onchainData . address } } < / code >
< button class = "text-xs text-white/60 hover:text-white shrink-0" @click ="copyOnchain" >
{ { onchainCopied ? 'Copied!' : 'Copy' } }
< / button >
< / div >
< p class = "text-[10px] text-white/40 mt-2" > Needs 1 confirmation before the file unlocks . < / p >
2026-06-17 19:21:42 -04:00
< / div >
2026-06-19 05:03:18 -04:00
< p v-if = "onchainError" class="text-sm text-red-400 mt-3" > {{ onchainError }} < / p >
< / div >
<!-- Lightning invoice QR -- >
< div v -else class = "text-center" >
< div v-if = "invoiceWaiting && !invoiceData" class="py-10 flex flex-col items-center gap-3" >
< svg class = "w-7 h-7 animate-spin text-white/80" fill = "none" viewBox = "0 0 24 24" >
2026-06-17 19:21:42 -04:00
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " / >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.4 0 0 5.4 0 12h4z" / >
< / svg >
2026-06-19 05:03:18 -04:00
< span class = "text-sm text-white/70" > Requesting invoice from seller … < / span >
< / div >
< div v -else -if = " invoiceData " >
< div v-if = "invoiceQr" class="bg-white rounded-xl p-3 inline-block mb-3" >
< img :src = "invoiceQr" alt = "Lightning invoice QR" class = "w-48 h-48" / >
< / div >
< p class = "text-sm text-white mb-1" > { { invoiceData . price _sats } } sats < / p >
< p class = "text-xs text-white/50 mb-3 flex items-center justify-center gap-2" >
< svg class = "w-3.5 h-3.5 animate-spin text-amber-400" fill = "none" viewBox = "0 0 24 24" >
< circle class = "opacity-25" cx = "12" cy = "12" r = "10" stroke = "currentColor" stroke -width = " 4 " / >
< path class = "opacity-75" fill = "currentColor" d = "M4 12a8 8 0 018-8V0C5.4 0 0 5.4 0 12h4z" / >
< / svg >
Waiting for payment …
< / p >
< div class = "flex items-center gap-2 bg-black/40 rounded-lg px-2 py-1.5" >
< code class = "text-[10px] text-white/60 truncate flex-1 text-left" > { { invoiceData . bolt11 } } < / code >
< button class = "text-xs text-white/60 hover:text-white shrink-0" @click ="copyInvoice" >
{ { invoiceCopied ? 'Copied!' : 'Copy' } }
< / button >
< / div >
2026-06-17 19:21:42 -04:00
< / div >
2026-06-19 05:03:18 -04:00
< p v-if = "invoiceError" class="text-sm text-red-400 mt-3" > {{ invoiceError }} < / p >
2026-06-17 19:21:42 -04:00
< / div >
< button
2026-06-19 05:03:18 -04:00
class = "glass-button px-4 py-2 rounded-lg text-sm mt-4 w-full"
2026-06-17 19:21:42 -04:00
@ click = "payMode = 'choose'"
>
Back
< / button >
< / div >
< / div >
< / div >
< / Transition >
< / Teleport >
2026-03-13 02:37:59 +00:00
< / div >
< / template >
< script setup lang = "ts" >
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
import { ref , computed , reactive , watch , onMounted } from 'vue'
2026-03-13 02:37:59 +00:00
import { useRouter } from 'vue-router'
2026-06-17 19:21:42 -04:00
import QRCode from 'qrcode'
2026-03-13 02:37:59 +00:00
import { rpcClient } from '@/api/rpc-client'
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
import { useAudioPlayer } from '@/composables/useAudioPlayer'
2026-06-17 19:21:42 -04:00
import BackButton from '@/components/BackButton.vue'
2026-03-13 02:37:59 +00:00
2026-03-14 17:12:41 +00:00
const props = defineProps < {
peerId ? : string
} > ( )
2026-03-13 02:37:59 +00:00
const router = useRouter ( )
interface PeerNode {
did : string
pubkey : string
onion : string
name ? : string
trust _level : string
}
interface CatalogItem {
id : string
filename : string
mime _type : string
size _bytes : number
description : string
access : string | { paid : { price _sats : number } }
}
const loading = ref ( true )
2026-03-14 17:12:41 +00:00
const currentPeer = ref < PeerNode | null > ( null )
2026-03-13 02:37:59 +00:00
const catalogError = ref ( '' )
const catalogItems = ref < CatalogItem [ ] > ( [ ] )
const downloading = ref < string | null > ( null )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
const playing = ref < string | null > ( null )
const purchaseError = ref < string | null > ( null )
2026-06-15 13:25:39 -04:00
// Transport actually used to reach this peer (returned by content.browse-peer)
// so we can show a FIPS/Tor pill instead of always assuming Tor (B21).
const transport = ref < string | null > ( null )
const transportPill = computed ( ( ) => {
switch ( transport . value ) {
case 'fips' :
return { label : 'FIPS' , cls : 'bg-green-500/20 text-green-300' , title : 'Connected over the fast encrypted mesh (FIPS)' }
case 'mesh' :
return { label : 'Mesh' , cls : 'bg-green-500/20 text-green-300' , title : 'Connected over the mesh' }
case 'lan' :
return { label : 'LAN' , cls : 'bg-blue-500/20 text-blue-300' , title : 'Connected over the local network' }
case 'tor' :
return { label : 'Tor' , cls : 'bg-amber-500/20 text-amber-300' , title : 'Connected over Tor (slower)' }
default :
return null
}
} )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
const previewUrls = reactive < Record < string , string > > ( { } )
const audioPlayer = useAudioPlayer ( )
2026-06-17 19:21:42 -04:00
// ─── Payment picker (#46) ────────────────────────────────────────────────
// When buying a paid item the user chooses how to pay: their local ecash
// wallet (instant), or a Lightning invoice drawn on the SELLER's node that
// they can pay from any external wallet by scanning a QR.
const payItem = ref < CatalogItem | null > ( null )
2026-06-19 05:03:18 -04:00
const payMode = ref < 'choose' | 'qr' > ( 'choose' )
// Pay-from-another-wallet QR view: tabbed like the wallet's Send/Receive modal,
// on-chain first (the default).
const qrTab = ref < 'onchain' | 'lightning' > ( 'onchain' )
2026-06-17 19:21:42 -04:00
const invoiceData = ref < { bolt11 : string ; payment _hash : string ; price _sats : number } | null > ( null )
const invoiceQr = ref ( '' )
const invoiceWaiting = ref ( false )
const invoiceError = ref ( '' )
const invoiceCopied = ref ( false )
2026-06-19 05:03:18 -04:00
// On-chain QR (pay the seller's address from any external wallet).
const onchainData = ref < { address : string ; amount _sats : number } | null > ( null )
const onchainQr = ref ( '' )
const onchainWaiting = ref ( false )
const onchainError = ref ( '' )
const onchainCopied = ref ( false )
2026-06-17 19:21:42 -04:00
const lnPaying = ref ( false )
const lnError = ref ( '' )
const onchainPaying = ref ( false )
let onchainPollTimer : ReturnType < typeof setTimeout > | null = null
let invoicePollTimer : ReturnType < typeof setTimeout > | null = null
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
// Video player modal state
const videoPlayerItem = ref < CatalogItem | null > ( null )
const videoPlayerUrl = ref < string | null > ( null )
const videoPlayerPaid = ref ( false )
2026-06-16 05:45:17 -04:00
// Streaming a peer's file connects over mesh/Tor before the first frame, so
// show a loader until the element can actually play (or errors).
const videoLoading = ref ( false )
const videoError = ref ( false )
2026-03-13 02:37:59 +00:00
2026-03-14 17:12:41 +00:00
const peerDisplayName = computed ( ( ) => {
if ( currentPeer . value ? . name ) return currentPeer . value . name
if ( currentPeer . value ? . did ) return truncateDid ( currentPeer . value . did )
return props . peerId ? truncateOnion ( props . peerId ) : 'Peer Files'
} )
function goBack ( ) {
router . push ( { name : 'cloud' } )
}
2026-03-13 02:37:59 +00:00
onMounted ( async ( ) => {
2026-03-14 17:12:41 +00:00
if ( props . peerId ) {
// Find the peer by onion address
try {
const result = await rpcClient . federationListNodes ( )
const peers = result ? . nodes ? ? [ ]
currentPeer . value = peers . find ( ( p : PeerNode ) => p . onion === props . peerId ) || null
} catch {
// Continue with just the onion address
}
await loadCatalog ( )
} else {
2026-03-13 02:37:59 +00:00
loading . value = false
}
} )
2026-03-14 17:12:41 +00:00
async function loadCatalog ( ) {
const onion = props . peerId || currentPeer . value ? . onion
if ( ! onion ) return
2026-06-11 00:24:40 -04:00
const hadItems = catalogItems . value . length > 0
2026-03-14 17:12:41 +00:00
loading . value = true
2026-03-13 02:37:59 +00:00
catalogError . value = ''
try {
2026-06-15 13:25:39 -04:00
const result = await rpcClient . call < { items ? : CatalogItem [ ] ; transport ? : string } > ( {
2026-03-14 17:12:41 +00:00
method : 'content.browse-peer' ,
params : { onion } ,
timeout : 30000 ,
} )
2026-03-13 02:37:59 +00:00
catalogItems . value = result ? . items ? ? [ ]
2026-06-15 13:25:39 -04:00
transport . value = result ? . transport ? ? null
2026-03-13 02:37:59 +00:00
} catch ( e : unknown ) {
catalogError . value = e instanceof Error ? e . message : 'Failed to connect to peer'
2026-06-11 00:24:40 -04:00
if ( ! hadItems ) catalogItems . value = [ ]
2026-03-13 02:37:59 +00:00
} finally {
2026-03-14 17:12:41 +00:00
loading . value = false
2026-03-13 02:37:59 +00:00
}
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
// Load visual previews for image and video items when catalog loads
// Audio files don't need visual thumbnails — they show a waveform icon
watch ( catalogItems , async ( items ) => {
const onion = props . peerId || currentPeer . value ? . onion
if ( ! onion ) return
for ( const item of items ) {
if ( ( item . mime _type . startsWith ( 'image/' ) || item . mime _type . startsWith ( 'video/' ) ) && ! previewUrls [ item . id ] ) {
loadPreview ( onion , item )
}
}
} )
async function loadPreview ( onion : string , item : CatalogItem ) {
try {
const result = await rpcClient . call < { data ? : string ; content _type ? : string } > ( {
method : 'content.preview-peer' ,
params : { onion , content _id : item . id } ,
timeout : 30000 ,
} )
if ( result ? . data ) {
const mime = result . content _type || item . mime _type
const bytes = Uint8Array . from ( atob ( result . data ) , c => c . charCodeAt ( 0 ) )
const blob = new Blob ( [ bytes ] , { type : mime } )
previewUrls [ item . id ] = URL . createObjectURL ( blob )
}
} catch {
// Preview not available — icon fallback is fine
}
}
2026-03-14 17:12:41 +00:00
function truncateDid ( did : string ) : string {
if ( did . length <= 24 ) return did
return did . slice ( 0 , 16 ) + '...' + did . slice ( - 8 )
}
function truncateOnion ( onion : string ) : string {
if ( onion . length <= 20 ) return onion
return onion . slice ( 0 , 12 ) + '...'
}
2026-03-13 02:37:59 +00:00
function formatSize ( bytes : number ) : string {
if ( bytes === 0 ) return '0 B'
const units = [ 'B' , 'KB' , 'MB' , 'GB' ]
const i = Math . floor ( Math . log ( bytes ) / Math . log ( 1024 ) )
return ( bytes / Math . pow ( 1024 , i ) ) . toFixed ( i > 0 ? 1 : 0 ) + ' ' + units [ i ]
}
function fileIconBg ( mime : string ) : string {
if ( mime . startsWith ( 'image/' ) ) return 'bg-blue-500/15'
if ( mime . startsWith ( 'audio/' ) ) return 'bg-orange-500/15'
if ( mime . startsWith ( 'video/' ) ) return 'bg-pink-500/15'
if ( mime . startsWith ( 'text/' ) ) return 'bg-green-500/15'
return 'bg-white/10'
}
function fileIconColor ( mime : string ) : string {
if ( mime . startsWith ( 'image/' ) ) return 'text-blue-400'
if ( mime . startsWith ( 'audio/' ) ) return 'text-orange-400'
if ( mime . startsWith ( 'video/' ) ) return 'text-pink-400'
if ( mime . startsWith ( 'text/' ) ) return 'text-green-400'
return 'text-white/60'
}
function fileIconPath ( mime : string ) : string {
if ( mime . startsWith ( 'image/' ) ) return 'M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'
if ( mime . startsWith ( 'audio/' ) ) return 'M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3'
if ( mime . startsWith ( 'video/' ) ) return 'M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z'
return 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'
}
function accessLabel ( access : CatalogItem [ 'access' ] ) : string {
if ( access === 'free' ) return 'Free'
if ( access === 'peersonly' ) return 'Peers Only'
if ( typeof access === 'object' && 'paid' in access ) return ` ${ access . paid . price _sats } sats `
return String ( access )
}
function accessBadgeClass ( access : CatalogItem [ 'access' ] ) : string {
if ( access === 'free' ) return 'bg-green-500/15 text-green-400'
if ( access === 'peersonly' ) return 'bg-blue-500/15 text-blue-400'
if ( typeof access === 'object' && 'paid' in access ) return 'bg-orange-500/15 text-orange-400'
return 'bg-white/10 text-white/50'
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
function isMediaMime ( mime : string ) : boolean {
return mime . startsWith ( 'image/' ) || mime . startsWith ( 'video/' ) || mime . startsWith ( 'audio/' )
}
function isPlayable ( mime : string ) : boolean {
return mime . startsWith ( 'video/' ) || mime . startsWith ( 'audio/' )
}
function isPaidItem ( access : CatalogItem [ 'access' ] ) : boolean {
return typeof access === 'object' && 'paid' in access
}
function getItemPrice ( access : CatalogItem [ 'access' ] ) : number {
if ( typeof access === 'object' && 'paid' in access ) return access . paid . price _sats
return 0
2026-03-13 02:37:59 +00:00
}
async function downloadFile ( item : CatalogItem ) {
2026-03-14 17:12:41 +00:00
const onion = props . peerId || currentPeer . value ? . onion
if ( ! onion ) return
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
purchaseError . value = null
2026-06-17 19:21:42 -04:00
const price = getItemPrice ( item . access )
if ( price > 0 ) {
// Let the buyer choose how to pay (local ecash vs external-wallet QR).
openPayModal ( item )
return
}
// Free / peers-only download: stream straight from the Range-capable proxy
// (B3) to disk instead of pulling the whole file as a base64 blob over RPC.
// The old base64-over-RPC path buffered the entire file in node memory AND
// the browser, which failed outright for large files (#38). A tiny probe
// first surfaces the real server error (peer unreachable on mesh and Tor)
// instead of a generic failure (#30).
downloading . value = item . id
2026-03-13 02:37:59 +00:00
try {
2026-06-17 19:21:42 -04:00
const streamUrl = ` /api/peer-content/ ${ encodeURIComponent ( onion ) } / ${ encodeURIComponent ( item . id ) } `
const probe = await probePeerContent ( streamUrl )
if ( probe !== true ) {
purchaseError . value = probe
return
}
streamDownload ( streamUrl , item )
} catch ( e : unknown ) {
purchaseError . value = e instanceof Error ? e . message : 'Download failed'
} finally {
downloading . value = null
}
}
function openPayModal ( item : CatalogItem ) {
payItem . value = item
payMode . value = 'choose'
2026-06-19 05:03:18 -04:00
qrTab . value = 'onchain'
2026-06-17 19:21:42 -04:00
invoiceData . value = null
invoiceQr . value = ''
invoiceWaiting . value = false
invoiceError . value = ''
invoiceCopied . value = false
2026-06-19 05:03:18 -04:00
onchainData . value = null
onchainQr . value = ''
onchainWaiting . value = false
onchainError . value = ''
onchainCopied . value = false
2026-06-17 19:21:42 -04:00
lnPaying . value = false
lnError . value = ''
onchainPaying . value = false
}
function closePayModal ( ) {
if ( invoicePollTimer ) { clearTimeout ( invoicePollTimer ) ; invoicePollTimer = null }
if ( onchainPollTimer ) { clearTimeout ( onchainPollTimer ) ; onchainPollTimer = null }
payItem . value = null
invoiceWaiting . value = false
2026-06-19 05:03:18 -04:00
onchainWaiting . value = false
2026-06-17 19:21:42 -04:00
onchainPaying . value = false
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
2026-06-19 05:03:18 -04:00
/ * *
* Open the "pay from another wallet" view : tabbed QR like the wallet ' s
* Send / Receive modal , defaulting to the on - chain tab ( so a QR is shown
* immediately for any external wallet ) .
* /
function openQrPay ( ) {
payMode . value = 'qr'
qrTab . value = 'onchain'
invoiceData . value = null
invoiceQr . value = ''
invoiceError . value = ''
invoiceWaiting . value = false
onchainData . value = null
onchainQr . value = ''
onchainError . value = ''
loadOnchainQr ( )
}
/ * * S w i t c h Q R t a b , l a z i l y l o a d i n g t h a t m e t h o d ' s Q R t h e f i r s t t i m e i t ' s s h o w n a n d
* resuming its payment poll if it was already loaded ( so switching back and
* forth doesn ' t silently stop watching for payment ) . * /
function selectQrTab ( tab : 'onchain' | 'lightning' ) {
if ( qrTab . value === tab ) return
qrTab . value = tab
if ( tab === 'onchain' ) {
if ( invoicePollTimer ) { clearTimeout ( invoicePollTimer ) ; invoicePollTimer = null }
if ( ! onchainData . value && ! onchainWaiting . value ) {
loadOnchainQr ( )
} else if ( onchainData . value && ! onchainPaying . value ) {
onchainPaying . value = true
pollOnchain ( onchainData . value . address )
}
} else {
if ( onchainPollTimer ) { clearTimeout ( onchainPollTimer ) ; onchainPollTimer = null }
onchainPaying . value = false
if ( ! invoiceData . value && ! invoiceWaiting . value ) {
payWithInvoice ( )
} else if ( invoiceData . value ) {
scheduleInvoicePoll ( )
}
}
}
/ * *
* On - chain QR : ask the seller for a fresh address + amount , render a
* ` bitcoin: ` QR for any external wallet , and poll the seller until the payment
* lands , then release the file ( the address is the gate token ) .
* /
async function loadOnchainQr ( ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion ) return
onchainError . value = ''
onchainData . value = null
onchainQr . value = ''
onchainWaiting . value = true
try {
const req = await rpcClient . call < { address ? : string ; amount _sats ? : number ; error ? : string } > ( {
method : 'content.request-onchain' ,
params : { onion , content _id : item . id } ,
timeout : 45000 ,
} )
if ( ! req ? . address || ! req ? . amount _sats ) {
onchainError . value = req ? . error || 'The seller could not provide an on-chain address.'
onchainWaiting . value = false
return
}
onchainData . value = { address : req . address , amount _sats : req . amount _sats }
const btc = ( req . amount _sats / 1 e8 ) . toFixed ( 8 )
try {
onchainQr . value = await QRCode . toDataURL ( ` bitcoin: ${ req . address } ?amount= ${ btc } ` , { margin : 1 , width : 240 } )
} catch {
onchainQr . value = '' // fall back to showing the raw address
}
onchainWaiting . value = false
onchainPaying . value = true // "waiting for payment" — drives the poll loop
pollOnchain ( req . address )
} catch ( e : unknown ) {
onchainError . value = e instanceof Error ? e . message : 'Could not request an on-chain address'
onchainWaiting . value = false
}
}
async function copyOnchain ( ) {
if ( ! onchainData . value ) return
try {
await navigator . clipboard . writeText ( onchainData . value . address )
onchainCopied . value = true
setTimeout ( ( ) => { onchainCopied . value = false } , 1500 )
} catch { /* clipboard denied */ }
}
2026-06-17 19:21:42 -04:00
/ * *
* Pay on - chain from THIS node ' s wallet : ask the seller for a fresh address +
* amount , broadcast with lnd . sendcoins , then poll the seller until it detects
* the payment and release the file ( address is the gate token ) . Slower than LN
* because the seller waits for the tx to appear / confirm .
* /
async function payOnchain ( ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion || onchainPaying . value ) return
onchainPaying . value = true
lnError . value = ''
try {
const req = await rpcClient . call < { address ? : string ; amount _sats ? : number ; error ? : string } > ( {
method : 'content.request-onchain' ,
params : { onion , content _id : item . id } ,
2026-06-19 05:03:18 -04:00
timeout : 45000 ,
2026-06-17 19:21:42 -04:00
} )
if ( ! req ? . address || ! req ? . amount _sats ) {
lnError . value = req ? . error || 'The seller could not provide an on-chain address.'
onchainPaying . value = false
return
}
const addr = req . address
const send = await rpcClient . call < { txid ? : string ; error ? : string } > ( {
method : 'lnd.sendcoins' ,
params : { addr , amount : req . amount _sats } ,
timeout : 60000 ,
} )
if ( ! send ? . txid ) {
lnError . value = send ? . error || 'On-chain send failed (insufficient on-chain balance?).'
onchainPaying . value = false
return
}
// Broadcast — now wait for the seller to see it and release.
pollOnchain ( addr )
} catch ( e : unknown ) {
lnError . value = e instanceof Error ? e . message : 'Could not pay on-chain'
onchainPaying . value = false
}
}
async function pollOnchain ( address : string ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion ) { onchainPaying . value = false ; return }
try {
const res = await rpcClient . call < { paid ? : boolean } > ( {
method : 'content.onchain-status' ,
params : { onion , content _id : item . id , address } ,
timeout : 30000 ,
} )
if ( res ? . paid ) {
const dl = await rpcClient . call < { data ? : string ; error ? : string } > ( {
method : 'content.download-peer-onchain' ,
params : { onion , content _id : item . id , address } ,
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
timeout : 120000 ,
} )
2026-06-17 19:21:42 -04:00
onchainPaying . value = false
if ( dl ? . data ) {
triggerDownload ( dl . data , item )
closePayModal ( )
} else {
lnError . value = dl ? . error || 'Paid, but the download failed. Try again shortly.'
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
}
2026-06-17 19:21:42 -04:00
return
}
} catch {
// transient — keep polling
}
if ( payItem . value && onchainPaying . value ) {
onchainPollTimer = setTimeout ( ( ) => pollOnchain ( address ) , 5000 )
}
}
/** Pay the open item from the local ecash wallet (mint token + download). */
async function payWithEcash ( ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion ) return
const price = getItemPrice ( item . access )
downloading . value = item . id
purchaseError . value = null
try {
2026-06-20 08:13:23 -04:00
// Check ecash balance first — across BOTH backends (Cashu + Fedimint), since
// the payment tries each in turn (#3). Fall back to the Cashu-only field for
// older backends that don't report `total_sats`.
2026-06-17 19:21:42 -04:00
try {
2026-06-20 08:13:23 -04:00
const balanceRes = await rpcClient . call < { total _sats ? : number ; balance _sats ? : number } > ( {
2026-06-17 19:21:42 -04:00
method : 'wallet.ecash-balance' ,
} )
2026-06-20 08:13:23 -04:00
const balance = balanceRes ? . total _sats ? ? balanceRes ? . balance _sats ? ? 0
2026-06-17 19:21:42 -04:00
if ( balance < price ) {
2026-06-20 08:13:23 -04:00
purchaseError . value = ` Insufficient ecash balance ( ${ balance } sats across Cashu + Fedimint). Need ${ price } sats. Fund either wallet, or pay from another wallet via QR. `
2026-06-17 19:21:42 -04:00
closePayModal ( )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
return
}
2026-06-17 19:21:42 -04:00
} catch {
// Balance check failed — try the purchase anyway
}
const result = await rpcClient . call < { data ? : string ; error ? : string } > ( {
method : 'content.download-peer-paid' ,
params : { onion , content _id : item . id , price _sats : price } ,
timeout : 120000 ,
} )
if ( result ? . data ) {
triggerDownload ( result . data , item )
closePayModal ( )
} else if ( result ? . error ) {
purchaseError . value = ` Payment failed: ${ result . error } `
closePayModal ( )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
}
} catch ( e : unknown ) {
purchaseError . value = e instanceof Error ? e . message : 'Download failed'
2026-06-17 19:21:42 -04:00
closePayModal ( )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
} finally {
downloading . value = null
}
}
2026-06-17 19:21:42 -04:00
/** Ask the seller for a Lightning invoice, render a QR, and poll for payment. */
async function payWithInvoice ( ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion ) return
2026-06-19 05:03:18 -04:00
payMode . value = 'qr'
2026-06-17 19:21:42 -04:00
invoiceError . value = ''
invoiceWaiting . value = true
try {
const res = await rpcClient . call < { bolt11 ? : string ; payment _hash ? : string ; price _sats ? : number ; error ? : string } > ( {
method : 'content.request-invoice' ,
params : { onion , content _id : item . id } ,
2026-06-19 05:03:18 -04:00
timeout : 45000 ,
2026-06-17 19:21:42 -04:00
} )
if ( ! res ? . bolt11 || ! res ? . payment _hash ) {
invoiceError . value = res ? . error || 'The seller could not create an invoice (is its Lightning node running?).'
invoiceWaiting . value = false
return
}
invoiceData . value = { bolt11 : res . bolt11 , payment _hash : res . payment _hash , price _sats : res . price _sats ? ? getItemPrice ( item . access ) }
try {
invoiceQr . value = await QRCode . toDataURL ( res . bolt11 . toUpperCase ( ) , { margin : 1 , width : 240 } )
} catch {
invoiceQr . value = '' // fall back to showing the raw invoice string
}
scheduleInvoicePoll ( )
} catch ( e : unknown ) {
invoiceError . value = e instanceof Error ? e . message : 'Could not request an invoice'
invoiceWaiting . value = false
}
}
/ * *
* Pay the seller 's invoice straight from THIS node' s Lightning wallet , then
* release the file . No QR / polling : lnd . payinvoice only returns once the payment
* settles , so the payment _hash is immediately valid as the download gate token .
* /
async function payWithLightning ( ) {
const item = payItem . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! onion || lnPaying . value ) return
lnPaying . value = true
lnError . value = ''
try {
// 1. Ask the seller to mint a bolt11 (also records the pending entitlement).
const inv = await rpcClient . call < { bolt11 ? : string ; payment _hash ? : string ; error ? : string } > ( {
method : 'content.request-invoice' ,
params : { onion , content _id : item . id } ,
2026-06-19 05:03:18 -04:00
timeout : 45000 ,
2026-06-17 19:21:42 -04:00
} )
if ( ! inv ? . bolt11 || ! inv ? . payment _hash ) {
lnError . value = inv ? . error || 'The seller could not create an invoice (is its Lightning node running?).'
return
}
// 2. Pay it from our own node. Returns only after settlement.
const pay = await rpcClient . call < { payment _hash ? : string ; payment _error ? : string } > ( {
method : 'lnd.payinvoice' ,
params : { payment _request : inv . bolt11 } ,
timeout : 120000 ,
} )
if ( pay ? . payment _error ) {
lnError . value = ` Payment failed: ${ pay . payment _error } `
return
}
// 3. Settled — pull the file using the payment hash as the gate token.
const dl = await rpcClient . call < { data ? : string ; error ? : string } > ( {
method : 'content.download-peer-invoice' ,
params : { onion , content _id : item . id , payment _hash : inv . payment _hash } ,
timeout : 120000 ,
} )
if ( dl ? . data ) {
triggerDownload ( dl . data , item )
closePayModal ( )
} else {
lnError . value = dl ? . error || 'Paid, but the download failed. Try again shortly.'
}
} catch ( e : unknown ) {
lnError . value = e instanceof Error ? e . message : 'Could not pay from your Lightning node'
} finally {
lnPaying . value = false
}
}
function scheduleInvoicePoll ( ) {
if ( invoicePollTimer ) clearTimeout ( invoicePollTimer )
invoicePollTimer = setTimeout ( pollInvoice , 3000 )
}
async function pollInvoice ( ) {
const item = payItem . value
const inv = invoiceData . value
const onion = props . peerId || currentPeer . value ? . onion
if ( ! item || ! inv || ! onion ) return
try {
const res = await rpcClient . call < { paid ? : boolean } > ( {
method : 'content.invoice-status' ,
params : { onion , content _id : item . id , payment _hash : inv . payment _hash } ,
timeout : 30000 ,
} )
if ( res ? . paid ) {
// Settled — pull the file using the payment hash as the gate token.
invoiceWaiting . value = false
const dl = await rpcClient . call < { data ? : string ; error ? : string } > ( {
method : 'content.download-peer-invoice' ,
params : { onion , content _id : item . id , payment _hash : inv . payment _hash } ,
timeout : 120000 ,
} )
if ( dl ? . data ) {
triggerDownload ( dl . data , item )
closePayModal ( )
} else {
invoiceError . value = dl ? . error || 'Paid, but the download failed. Try again shortly.'
}
return
}
} catch {
// Transient — keep polling.
}
if ( payItem . value && invoiceData . value ) scheduleInvoicePoll ( )
}
async function copyInvoice ( ) {
if ( ! invoiceData . value ) return
try {
await navigator . clipboard . writeText ( invoiceData . value . bolt11 )
invoiceCopied . value = true
setTimeout ( ( ) => { invoiceCopied . value = false } , 2000 )
} catch { /* clipboard blocked */ }
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
/** Play audio/video inline. For free items, downloads full file; for paid, uses the preview. */
async function playMedia ( item : CatalogItem ) {
const onion = props . peerId || currentPeer . value ? . onion
if ( ! onion ) return
const paid = isPaidItem ( item . access )
2026-06-15 13:46:51 -04:00
// Free content: stream via the Range-capable proxy (B3) so the player can
// seek and start instantly, instead of downloading the whole file as a
// base64 blob into a non-seekable Blob URL (which broke video/large audio).
if ( ! paid ) {
const streamUrl = ` /api/peer-content/ ${ encodeURIComponent ( onion ) } / ${ encodeURIComponent ( item . id ) } `
if ( item . mime _type . startsWith ( 'audio/' ) ) {
audioPlayer . play ( streamUrl , item . filename . split ( '/' ) . pop ( ) || item . filename )
} else if ( item . mime _type . startsWith ( 'video/' ) ) {
videoPlayerItem . value = item
videoPlayerUrl . value = streamUrl
videoPlayerPaid . value = false
}
return
}
// Paid content: use the preview/download flow below.
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
// If we already have a preview blob URL, use it
const existingUrl = previewUrls [ item . id ]
if ( existingUrl ) {
if ( item . mime _type . startsWith ( 'audio/' ) ) {
audioPlayer . play ( existingUrl , item . filename . split ( '/' ) . pop ( ) || item . filename )
} else if ( item . mime _type . startsWith ( 'video/' ) ) {
videoPlayerItem . value = item
videoPlayerUrl . value = existingUrl
videoPlayerPaid . value = paid
}
return
}
// Download the content (preview for paid, full for free)
playing . value = item . id
try {
const method = paid ? 'content.preview-peer' : 'content.download-peer'
const result = await rpcClient . call < { data ? : string ; content _type ? : string } > ( {
method ,
2026-03-14 17:12:41 +00:00
params : { onion , content _id : item . id } ,
2026-03-13 02:37:59 +00:00
timeout : 120000 ,
} )
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
2026-03-13 02:37:59 +00:00
if ( result ? . data ) {
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
const mime = result . content _type || item . mime _type
const bytes = Uint8Array . from ( atob ( result . data ) , c => c . charCodeAt ( 0 ) )
const blob = new Blob ( [ bytes ] , { type : mime } )
const blobUrl = URL . createObjectURL ( blob )
previewUrls [ item . id ] = blobUrl
if ( item . mime _type . startsWith ( 'audio/' ) ) {
audioPlayer . play ( blobUrl , item . filename . split ( '/' ) . pop ( ) || item . filename )
} else if ( item . mime _type . startsWith ( 'video/' ) ) {
videoPlayerItem . value = item
videoPlayerUrl . value = blobUrl
videoPlayerPaid . value = paid
}
2026-04-11 23:59:55 -04:00
} else {
purchaseError . value = 'No preview data returned — peer may be offline'
2026-03-13 02:37:59 +00:00
}
2026-04-11 23:59:55 -04:00
} catch ( e : unknown ) {
purchaseError . value = e instanceof Error ? e . message : 'Failed to load media — peer may be offline'
2026-03-13 02:37:59 +00:00
} finally {
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
playing . value = null
2026-03-13 02:37:59 +00:00
}
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
function closeVideoPlayer ( ) {
videoPlayerItem . value = null
videoPlayerUrl . value = null
videoPlayerPaid . value = false
2026-06-16 05:45:17 -04:00
videoLoading . value = false
videoError . value = false
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
}
2026-06-16 05:45:17 -04:00
// Show the loader the moment a video opens; the element's playing/canplay/error
// events clear it.
watch ( videoPlayerUrl , ( url ) => {
if ( url ) {
videoLoading . value = true
videoError . value = false
}
} )
2026-06-17 03:10:21 -04:00
/ * *
* Probe the streaming proxy with a 1 - byte Range request so we can report the
* real failure reason ( peer offline on both mesh and Tor ) before kicking off a
* browser - managed download that can ' t surface HTTP status . Returns ` true ` on
* success , or a human - readable error string . Aborts immediately on success so
* a large body is never drained .
* /
async function probePeerContent ( url : string ) : Promise < true | string > {
const controller = new AbortController ( )
try {
const res = await fetch ( url , {
headers : { Range : 'bytes=0-0' } ,
signal : controller . signal ,
} )
if ( res . ok || res . status === 206 ) {
controller . abort ( )
return true
}
let msg = ` Peer returned an error ( ${ res . status } ) `
try {
const body = await res . json ( )
if ( body ? . error ) msg = String ( body . error )
} catch {
// non-JSON error body — keep the status-based message
}
return msg
} catch ( e ) {
return e instanceof Error ? e . message : 'Could not reach the peer — it may be offline'
}
}
/ * *
* Stream a free file to disk via the Range - capable proxy . The browser manages
* the transfer with constant memory ( no base64 , no in - memory Blob ) , so large
* files download reliably ( # 38 ) . Same - origin , so the session cookie rides along .
* /
function streamDownload ( url : string , item : CatalogItem ) {
const a = document . createElement ( 'a' )
a . href = url
a . download = item . filename . split ( '/' ) . pop ( ) || item . filename
document . body . appendChild ( a )
a . click ( )
a . remove ( )
}
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
function triggerDownload ( base64Data : string , item : CatalogItem ) {
const blob = new Blob (
[ Uint8Array . from ( atob ( base64Data ) , c => c . charCodeAt ( 0 ) ) ] ,
{ type : item . mime _type } ,
)
const url = URL . createObjectURL ( blob )
const a = document . createElement ( 'a' )
a . href = url
a . download = item . filename . split ( '/' ) . pop ( ) || item . filename
a . click ( )
URL . revokeObjectURL ( url )
}
2026-06-11 00:24:40 -04:00
defineExpose ( { loadCatalog } )
2026-03-13 02:37:59 +00:00
< / script >
feat: streaming ecash payments + media playback overhaul
Cashu ecash protocol (BDHKE blind signatures, cashuA token format,
mint HTTP client) replacing the stub wallet. TollGate-inspired streaming
data payment system with step-based pricing (bytes/time/requests),
session management with incremental top-ups, usage metering, and
Nostr kind 10021 service advertisements.
13 new streaming.* RPC endpoints. Content server now verifies real
Cashu tokens. Profits tracking includes streaming revenue.
Frontend: GlobalAudioPlayer (persistent bottom bar across all pages),
video lightbox with full controls, audio in MediaLightbox, free file
previews (no blur), paid 10% audio/video previews, separated play
vs download buttons in PeerFiles.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 22:31:28 -04:00
< style scoped >
. fade - enter - active ,
. fade - leave - active {
transition : opacity 0.2 s ease ;
}
. fade - enter - from ,
. fade - leave - to {
opacity : 0 ;
}
< / style >