Skip to content

utils: one storage-grant contract (claims, decode, HS256 mint/verify) - #483

Merged
kvz merged 2 commits into
mainfrom
storage-grant-codec
Aug 31, 2026
Merged

utils: one storage-grant contract (claims, decode, HS256 mint/verify)#483
kvz merged 2 commits into
mainfrom
storage-grant-codec

Conversation

@kvz

@kvz kvz commented Aug 31, 2026

Copy link
Copy Markdown
Member

One source of truth for the Transloadit Storage grant JWT that today exists as four hand-rolled copies (api2 StorageGrantManager, Companion's parseGrantClaims, @uppy/s3's decodeGrant, and the Console's grant route).

  • Root (browser-safe): StorageGrantClaims/StorageGrantScope types, parseStorageGrantClaims (strict shape validation, scope dedupe), decodeStorageGrant (unverified JWT payload decode, UTF-8 safe), normalizeStorageGrantPrefix (Companion's leading-slash strip + trailing-slash).
  • /node: signStorageGrant (deterministic HS256, byte-compatible with api2's StorageGrantManager) and verifyStorageGrant (timing-safe signature check, HS256-only header, strict claims, expiry).
  • Vectors: fixed-input golden token, mint→verify roundtrip, tamper/expiry/shape rejections, unicode prefixes, base64url padding, scope dedupe.

Once published, api2 #8844, uppy #6506 (Companion + @uppy/s3) and content #5810 consume this instead of their local copies (≈ −40…−70 lines across the repos, and the contract cannot drift).

🤖 Generated with Claude Code

The Transloadit Storage grant (the short-lived JWT Companion's S3
provider accepts) currently exists as four hand-rolled copies: minting
in api2 and in the Console's grant route, verification in Companion,
and unverified decoding in @uppy/s3. This module is the single wire
contract: browser-safe claim types + parsing + unverified decode at the
root, deterministic HS256 minting and verification under /node.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kvz
kvz merged commit 69e55d4 into main Aug 31, 2026
@kvz
kvz deleted the storage-grant-codec branch August 31, 2026 17:09
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