Loading
Code Deb

Code Deb Media

Validated image inputs and bounded processing Content-addressed AVIF, WebP and JPEG/PNG variants TypeScript examples, API reference and installation guidance.

Technical documentation for 27 Code Deb JavaScript and TypeScript SDKs, Verify and MCP APIs and the developer platform. Browse API references, authentic implementation examples and provider boundaries. Check actual npm availability before installing.

Verified registry: @codedeb/media@0.2.1 was confirmed publicly (version metadata, latest dist-tag and tarball).

Public npm release: @codedeb/media@0.2.0 · Released: 20 November 2026 · ESM: JavaScript + TypeScript declarations.

npm install @codedeb/media

Read the integration reference or engineering guide. Code Deb's noncommercial SDK license applies to Code Deb-owned material; commercial use requires a separate agreement. Upstream notices are retained where applicable.

Automated image variants built on Code Deb's existing Sharp image optimization technology. The npm package is public; it does not include a hosted CDN, storage account or upload endpoint.

Supported workflow

The Node-only processMedia function decodes a bounded image buffer using Sharp, corrects orientation, generates selected WebP and AVIF variants plus a JPEG/PNG fallback, creates a tiny placeholder and stores immutable variants through an injected MediaStore adapter. Its manifest provides width, height, byte sizes, content hash and URLs.

The browser-safe responsiveMedia function builds srcSet, sizes, <picture> source values and loading hints. The caller remains responsible for accessible alternative text, LCP selection and valid destination origin.

TypeScript

import { processMedia } from '@codedeb/media/node';
import { responsiveMedia } from '@codedeb/media';

const manifest = await processMedia(imageBytes, {
  tenant: 'sample-shop',
  filename: 'product.jpg',
  alt: 'Handcrafted product',
  origin: 'https://assets.example.com',
  store: storageAdapter,
});
const image = responsiveMedia(manifest, { sizes: '(max-width: 768px) 100vw, 50vw' });

Storage interface

MediaStore.put(key, bytes, contentType, cacheControl): Promise<void> must be implemented on your trusted server using your own storage credentials. No public upload endpoint or Cloudflare R2 account is created by installing source files. Never put storage secrets into browser code.

Security and performance

Server deployments must add authenticated signed uploads, tenant policy, network egress controls and cost monitoring before accepting untrusted customer uploads. Images are processed with strict input byte and pixel limits. Blur-up and responsive formats can improve LCP but do not guarantee a Lighthouse score.

References

Image Studio | SDK directory | SDK overview

Working upload grants and storage

packages/sdk-media/src/upload.ts adds issueUploadGrant and verifyUploadGrant for signed, short-lived, tenant-scoped MIME/byte-limited upload claims. This is HMAC verification, not a hosted upload API. Integrators must authenticate the caller, enforce tenant ownership and record grant IDs exactly once in durable storage.

packages/sdk-media/src/filesystem.ts supplies createFileMediaStore(root) for server-side immutable storage and rejects path traversal or conflicting asset content. It does not manage R2 or Cloudflare accounts. mediaPreset('product'|'hero'|'avatar'|'article'|'thumbnail') returns validated sizes and quality profiles.

import {issueUploadGrant,verifyUploadGrant} from '@codedeb/media/upload';
import {mediaPreset} from '@codedeb/media/presets';
import {createFileMediaStore} from '@codedeb/media/filesystem';

const preset=mediaPreset('hero');
const store=createFileMediaStore('/srv/media');
const grant=issueUploadGrant({
  tenant:'store-1',mime:'image/jpeg',purpose:'catalog',maxBytes:5000000,
  secret:process.env.MEDIA_SIGNING_KEY!
});
// Verify the grant and a single-use ID before accepting upload bytes.

Security and production checklist

Use verified tenant membership and token replay protection; bound input bytes and pixel dimensions; protect storage paths; decide metadata and EXIF handling; benchmark image quality and Core Web Vitals. A local storage adapter is intentionally not a regional CDN.

Release history

  • 0.2.0 — 20 November 2026: First public Code Deb npm distribution. Independently packaged ESM exports and TypeScript declarations passed isolated consumer verification.

Production implementation walkthrough

  1. Verify signed upload grants and tenant ownership before reading bytes.
  2. Transform only on a trusted Node server with Sharp and bounded dimensions.
  3. Return responsive variant manifests and immutable cache headers.
  4. Connect storage and CDN through an explicitly authorized adapter.

Reproducible installation and compatibility

npm view @codedeb/media@0.2.1 version
npm install @codedeb/media@0.2.1

Pin the exact version in the application lockfile; review its exported ESM subpaths and bundled TypeScript declarations. A new package version does not retroactively update older immutable tarballs.

Integration acceptance checklist

  • Validate boundary inputs, invalid payloads and every caller-provided adapter before connecting customer data.
  • Type-check the actual package from a clean test application, not only from this monorepo's source paths.
  • Exercise authorization failures, missing configuration and relevant concurrency or retry paths.
  • Keep credential and sensitive data out of logs; store only necessary operational evidence.

Troubleshooting and version policy

Module not found: Check the exact import subpath and package version in node_modules and the lockfile. Unexpected result: Review the required application-owned credentials and adapters. npm 404: Verify the requested immutable version using the public registry; do not mistake a local tarball for a published release.

See og factory and catalog engine for complementary capabilities. Use the SDK directory and Developer resources for API references and engineering guides.

More from Code Deb

Read about our agency, explore available services, or contact the team for a project discussion.