Skip to content

utils: isomorphic Smart CDN URL signing and signParams (WebCrypto) - #477

Merged
kvz merged 1 commit into
mainfrom
utils-isomorphic-smartcdn
Aug 28, 2026
Merged

utils: isomorphic Smart CDN URL signing and signParams (WebCrypto)#477
kvz merged 1 commit into
mainfrom
utils-isomorphic-smartcdn

Conversation

@kvz

@kvz kvz commented Aug 28, 2026

Copy link
Copy Markdown
Member

What

  • @transloadit/utils root export gains an async, WebCrypto-based getSignedSmartCdnUrl that works in browsers (secure origins), edge runtimes and Node, producing byte-identical URLs to the synchronous signer in @transloadit/utils/node.
  • The URL assembly (path encoding, sorted query, auth_key/exp, sig=sha256:<hex>) moved to src/smartCdn.ts; both signers are thin wrappers over it, so they cannot drift apart. SmartCdnUrlOptions is unchanged and still exported from ./node.
  • signParams / verifyWebhookSignature accept sha512 in addition to sha1|sha256|sha384, matching what signParamsSync already allowed.
  • The "Web Crypto is required" error now says why it is missing (browsers only expose crypto.subtle on https:///localhost).

Why

Uppy's @uppy/transloadit-storage (transloadit/uppy#6506) and the Console File Library (transloadit/content#5810) each carry their own browser reimplementation of Smart CDN URL signing today. With this they can depend on @transloadit/utils instead of maintaining a third copy.

Verified

  • packages/utils/test/smartCdn.test.ts: hard-coded known-answer URL for both signers, HMAC-SHA256 of the documented string-to-sign, default one-hour expiry parity, validation parity, insecure-context error, and signParams vs signParamsSync parity for all four algorithms.
  • yarn verify (changesets, publish, deps, biome, tsc, transloadit-sync, all unit suites: utils 9, node 248, zod/types, notify-url-relay 22) and yarn knip clean.

🤖 Generated with Claude Code

…pto)

Move the Smart CDN URL assembly (encoding, sorted query, auth_key/exp,
sig=sha256:hex) into src/smartCdn.ts so the synchronous Node signer and
a new async WebCrypto getSignedSmartCdnUrl on the root export share it
and cannot drift. Uppy's @uppy/transloadit-storage and the Console each
carry a browser reimplementation today; this lets them depend on the
package instead. signParams/verifyWebhookSignature also accept sha512,
matching signParamsSync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kvz
kvz marked this pull request as ready for review August 28, 2026 15:23
@kvz
kvz merged commit a652ffa into main Aug 28, 2026
12 checks passed
@kvz
kvz deleted the utils-isomorphic-smartcdn branch August 28, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant