Skip to content

feat(sdk): sign preview generation requests - #14552

Open
rickyrombo wants to merge 1 commit into
feat/signed-audio-uploadsfrom
feat/signed-preview-generation
Open

feat(sdk): sign preview generation requests#14552
rickyrombo wants to merge 1 commit into
feat/signed-audio-uploadsfrom
feat/signed-preview-generation

Conversation

@rickyrombo

Copy link
Copy Markdown
Contributor

Stacked on #14550. Review that first — this branch contains only the commit on top of it.

Why previews need signing

generatePreview asks a storage node to slice new bytes out of a cid. The node attests the resulting cid on chain so it can be named as a track's preview_cid — and it will only do that for a user who already claims the source audio. So the request has to say who is asking.

Without that check the endpoint is a gating bypass. Previews stream publicly, and they are 30 seconds long, so an attacker could generate previews of a gated track at offsets 0/30/60/…, name each on a throwaway track of their own, and reassemble the full 320. Requiring a signature and refusing unless the caller owns the source kills that at the door.

What changed

generatePreview takes an optional userId and, when a wallet is configured, signs with signUpload from #14550 — the same EIP-712 payload audio uploads use, passed as signature/userId/timestamp query parameters. Reusing it rather than inventing a second scheme means both audio paths recover a signer through one code path on the node side too.

Both call sites in TracksApi pass the acting user: the uploadTrack fallback that generates a preview when the upload did not, and updateTrack with generatePreview: true. The second is the one that matters most — it has no audio upload at all, so this endpoint is its only route to a preview cid.

Unsigned still works

No wallet or no user id sends the request unsigned, matching uploadFile. Nodes accept those where content authorization is not enforced; the preview just never earns a claim, so it cannot be named on a track once enforcement is on. That makes this safe to land ahead of the gate but means it has to ship before the gate opens.

Testing

Typechecks clean. The SDK's vitest suites do not run in my environment — StorageNodeSelector.test.ts and signUpload.test.ts both fail at collection with TypeError: Object.defineProperty called on non-object, and they fail identically on a clean tree with none of these changes, so it is environmental rather than caused by this branch. These changes have not been exercised by a running test.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7c6f6d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@audius/sdk Minor
@audius/sdk-legacy Patch
@audius/protocol-dashboard Patch
@audius/sp-actions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

generatePreview asks a storage node to produce new bytes from a cid, and
the node now attests the resulting cid on chain so it can be named as a
track's preview. It will only do that for a user who already owns the
source audio, so the request has to say who is asking.

Reuses the upload request signature rather than inventing a second scheme,
so both audio paths recover a signer the same way.

Unsigned when there is no wallet or no user id, matching how uploadFile
behaves: nodes accept those where content authorization is not yet
enforced, and the preview simply never earns a claim.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rickyrombo
rickyrombo force-pushed the feat/signed-preview-generation branch from 033a340 to 7c6f6d9 Compare August 8, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant