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 🙏

© 2026 – Pkg Stats / Ryan Hefner

openrtc-file-transfer

v3.3.1

Published

Optional, transport-independent file transfer protocol for OpenRTC named channels.

Readme

openrtc-file-transfer

Optional file-transfer protocol for OpenRTC applications. OpenRTC remains the connection and route owner; this package supplies application framing.

import { createTransfer } from 'openrtc-file-transfer';

const room = await rtc.rooms.join('project-files', {
  access: 'authenticated',
  membership: 'ephemeral',
  auth,
});
const files = createTransfer(room);
const stop = files.onIncoming(({ file }) => saveBlob(file.blob, file.name));
await files.send(deviceId, selectedFile, { onProgress: console.log });

When the client exposes OpenRTC's application-message surface, the protocol uses bounded OFT2 segments. OpenRTC selects the best currently proven route for every segment, so an in-flight transfer can promote from relay to WebRTC, MoQ, LAN, or direct QUIC and can fall back again without restarting. The receiver ACKs its highest contiguous accepted offset; a missing ACK or route failure causes a bounded resume negotiation from that receiver-owned offset. The older named-stream framing remains the compatibility path for clients that do not expose application messages.

Ticket-scoped native/browser applications can select routing: 'segmented-stream' with their registered channel descriptor. This carries the same OFT2 protocol in bounded named-channel streams, resolving the current admitted route for every segment and reply. It preserves native capability dispatch without falling back to unscoped application messages. Both endpoints must select this mode; legacy routing: 'stream' uses different v1 framing and is not wire-compatible. Offers, data windows and completion replies have bounded protocol recovery; rejection and cancellation remain terminal. Resume and completion are keyed by the sending peer and transfer ID, and scoped ACKs must come from the intended receiver. A successful local write is never completion evidence.

The package owns reusable framing, bounded validation, acknowledgement, progress, cancellation, and optional SHA-256 verification. Applications own file pickers, destination paths, acceptance policy, persistent queues, history, billing, and notifications. Native applications should provide a streaming ReceiveSink, the wire-compatible Rust openrtc-file-transfer crate, or a host-side file adapter instead of buffering large files in the WebView. A custom sink receiving SHA-256-protected transfers must implement verifySha256; verification fails closed rather than silently accepting an unchecked native file. Resume uses a declared offset: the sender starts at that byte and the receiver accepts it only when its sink reports the exact application-verified resumeOffset.

The protocol accepts one already-active OpenRTC 2.0 capability handle. It never constructs a hidden client or activates a second avenue. It also never caches a transport, dials a peer, or promotes a route. The consumer keeps durable product intent pending until the receiver confirms the completed size and integrity.

Durable accepted sources

The routed sendAccepted(deviceId, { header, openSource }, options) source API accepts the product's persisted immutable header, including SHA-256. It first reconciles the offer with the authenticated receiver. A committed completion receipt returns without opening the local file; otherwise missing bytes cause one lazy source open and bounded, abort-aware revision verification before body transmission. The product owns source storage, authorization, queue state and receipt persistence. No connection or additional protocol handler is created. The legacy stream implementation rejects this API before sending bytes. Consumers of older published packages must detect API availability and retain their prior source-first path until qualified artifacts are adopted.

Receive pacing and deadline renewal

Routed message and segmented-stream receivers may use beforeReceiveBody to admit each authenticated body attempt into a product rate/quota controller. It receives transfer ID, remote node ID, offset, byte count and an abort signal. Duplicate body attempts consume policy bytes without advancing logical progress or writing the same prefix twice. Control frames bypass body policy. Payload attempts are application bytes, not an exact physical-network counter.

Receiver pacing requires the immutable offer metadata openrtc.receive-wait: "1". Fresh routed send offers advertise this capability; call withReceiverWaitCapability(header) before persisting a new accepted offer. sendAccepted preserves that exact persisted header, including metadata. A paced receiver rejects a legacy offer before allocating its sink or reading source bytes. A product-confirmed completion receipt still returns body-free, without running a body policy or requiring the legacy source to exist.

BULK_RECEIVE_FLOW_CONTROL_VERSION === 1 also supports per-sink bodyPolicy. Use its captured execution signal, beforeAttempt callback and requiresReceiverWait admission flag when product storage owns each job's policy/lease. The runtime callback still runs first; a sink cannot bypass it. A sink with requiresReceiverWait: false admits old offers without sending unsupported wait controls. Its callback must remain unpaced for such an offer or reject if a later policy requires waiting. Required waits reject before body acceptance and abort any prepared sink. Product receipts are checked first. Signal retirement aborts active policy work and releases idle receive sinks. Stream/v1 cannot host this body policy and rejects it before reading body data.

OFT2 kind 0x08 is a waiting control frame: transfer ID, big-endian u64 last checkpointed offset and big-endian u32 lease milliseconds (1–60,000). The receiver renews its configurable lease (default 10,000 ms) during body policy, sink IO/checkpointing and final verification/publication. The sender accepts renewal only from the expected authenticated peer, for the active transfer, within its current body window and only when the offer negotiated support. Waiting neither ACKs bytes nor confirms delivery. If renewal stops, the current lease expires and the normal bounded recovery applies. Application expiry and execution permission remain the product's responsibility.

Caller cancellation, receiver subscription stop/replacement and protocol disposal abort active policy work and stop renewal. Hooks must honor the abort signal; durable sinks must retain their product execution/commit fences. A sink that finishes creation after execution retirement is aborted rather than accepted. Legacy raw-stream framing rejects receive pacing; native consumers must qualify and implement the same negotiated deadline behavior before advertising the capability. Neither waiting nor body policy changes OpenRTC's connection, admission or route ownership.

Required capabilities and large-file admission

For routed message or segmented-stream transfers, send accepts requiredCapabilities: { durableResume?, completionReceipt?, extensions? }. Accepted jobs instead call withRequiredCapabilities(header, requirements) before persisting their immutable header; sendAccepted preserves that exact metadata. A requirement is encoded under openrtc.required-capabilities.v1 as a closed version-1 JSON document. Unknown fields, duplicate or invalid extension names, and unsupported versions fail closed. Extensions are consumer-owned names; they must describe real receiver authorization/storage behavior rather than silently changing generic delivery into a managed destination operation.

The sender probes before offering bytes whenever the header has requirements, exceeds the 256 MiB legacy buffered ceiling, or an accepted job exceeds its current sender size limit. An unsupported verdict rejects before opening an accepted source or allocating a receive sink. A legacy peer that ignores the probe produces an actionable error after the existing bounded protocol retries; OpenRTC still owns admission, routes and connection recovery. Explicit stream/v1 send and receive reject required-feature metadata before accepting a body.

The receiver derives its admitted maximum from maxFileBytes and the sink: without a custom streaming sink it never advertises above 256 MiB. With one, receiveCapabilities may declare durable resume and application extensions. A durable-resume claim requires a checkpointing sink; the application must make those checkpoints durable and verify reopened prefixes. completionReceipt support requires the product hasCompletionReceipt(header, authenticatedPeer) callback. When a job requires receipts, completion checks that callback after publication/commit and rejects success if the receipt is still missing. Neither the SDK's in-memory completed map nor a capability declaration is durable proof. An absent or aborted receive subscription advertises receiveAvailable: false, including for zero-byte files.

OFT2 kind 0x09 carries a capability request: transfer ID, big-endian u32 header length and optional immutable JSON header (zero length for a general query). Kind 0x0a carries a big-endian u32 JSON length and a closed version-1 response bounded to 4096 bytes: version, durableResume, completionReceipt, extensions, receiveAvailable, and maxFileBytes (a nonnegative safe integer). Header probes retain the configured header-byte bound but validate size against the JavaScript safe-integer ceiling, independently of current body admission.

Before returning capabilities, a header probe checks the authenticated product receipt. A matching receipt returns the existing Completed frame, even if receiving is disabled or current file limits have decreased. An accepted-source sender likewise reconciles that receipt before enforcing its current body limit, without reopening or resending the source. Immutable header conflicts fail closed; replies must match the intended authenticated peer and transfer ID. Native codec support does not by itself implement or advertise these execution, application extension, authorization, or persistence guarantees.

The staged BULK_JOB_FLOW_CONTROL_VERSION = 1 contract also accepts beforeSendBody on an individual send or sendAccepted call. The runtime callback and job callback both run before each body attempt, outside the ACK deadline; a job callback cannot override a runtime restriction. Product owners retain authorization, execution cancellation, durable counters and policy state. Persist BulkFlowController.snapshot() before allowing body work and restore it into a fresh controller when a durable execution owner changes. Publication and consumer capability checks are required before relying on these staged APIs.