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

@hexdn/upload

v0.2.0

Published

Framework-neutral resumable uploads for HexDN.

Readme

@hexdn/upload

Framework-neutral HexDN uploads with no runtime dependencies. Media bytes go directly to storage; your backend owns authorization and creates the scoped upload capability. Never pass an environment API key to this package.

Register your application's upload origin in HexDN before browser uploads. Your endpoint checks whether the user may upload and returns the capability; the SDK handles the browser request and transfer.

import { createUploadEndpoint, uploadSource } from "@hexdn/upload";

const getUpload = createUploadEndpoint({ endpoint: "/api/uploads" });
const upload = await getUpload(file);

await uploadSource({
  upload,
  source: file,
  onProgress: ({ phase, uploadedBytes, totalBytes }) => {
    renderProgress(phase, uploadedBytes, totalBytes);
  },
});

The endpoint receives a JSON POST with filename, byteLength, and mimeType, plus an Idempotency-Key header. It authenticates the user, chooses outputs, and forwards the key to server SDK asset creation. Return { upload: { url, token } } or the capability directly. sdk.assets.createUpload(...) already returns the accepted upload field. The browser request uses same-origin credentials and bypasses caches; no environment API key is sent from the browser.

If your application already has the capability, pass it straight to uploadSource. React applications can use <Uploader uploadEndpoint="/api/uploads" /> from @hexdn/react/upload, which also manages selection, cancellation, and retry identity.

uploadSource inspects the upload, prepares its exact byte length, reconciles provider-recorded parts, uploads missing slices in bounded batches, and completes the upload. Completion confirms receipt of the source; processing outputs may still be waiting or processing.

Pass an AbortController's signal to getUpload(file, { signal }) and uploadSource({ upload, source: file, signal }) to stop local work. Aborting does not delete the upload or its asset. cancelUpload({ upload }) is the separate, destructive server cancellation operation and should only follow the user's cancellation decision.

To resume, call uploadSource again with the same capability and original file. The provider's part list is authoritative. Saved part fingerprints prevent a different same-size file from being combined with existing parts. Fingerprinting reads bounded chunks; the default fence uses browser storage when available and otherwise retains proofs for this page. Missing or mismatched proofs fail closed. Use createUploadResumeFence(storage) or implement UploadResumeFence to control proof persistence. Capabilities and part tickets still expire.

PUT retries are bounded and honor Retry-After, cancellation, and ticket expiry. An uncertain completion is checked against authoritative upload state. If it remains unresolved, the operation rejects without cancelling; retry the same upload rather than creating a replacement automatically. Progress is transfer progress, not a verified processing-readiness signal.

If capability creation loses its response, retry the same getUpload resolver with the same File; it retains its creation key until a valid response arrives. An application-owned workflow can pass its own idempotencyKey to getUpload(file, { idempotencyKey, signal }). The React uploader manages that key automatically. Custom request handling can replace getUpload entirely, or use the helper's optional fetch override.

Applications with an authenticated upload proxy can supply an UploadControlClient to uploadSource instead of calling HexDN control URLs directly. The proxy remains responsible for its authorization and safe control-request retries.

For an existing application that already manages upload creation, ticket issuance, and completion, use the smaller transfer boundary:

import { uploadMultipartSource } from "@hexdn/upload";

await uploadMultipartSource(
  {
    file,
    instructions, // Server-provided MultipartUploadPlan.
    issueParts: (partNumbers, signal) =>
      applicationUploadApi.issueParts({ partNumbers, signal }),
  },
  { signal, onProgress: ({ percent }) => renderPercent(percent) },
);

This lower-level function transfers the supplied multipart plan with continuous XHR progress where available, bounded concurrency, and fail-fast sibling aborts. It does not inspect prior provider parts, allocate resources, or complete/cancel an upload. onDelivery exposes safe retry/recovery facts without signed URLs, tokens, or filenames; route those through your application's observability.

Build and verify from the HexDN workspace:

pnpm --filter @hexdn/upload build
pnpm --filter @hexdn/upload typecheck
pnpm --filter @hexdn/upload test

The package publishes ESM JavaScript and TypeScript declarations from dist. It does not import React, the playback engine, analytics, or the server SDK.