Upload to restricted data sets with `read: "restricted"`

Aperta
#1,197 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@JAG-UK ci sta già lavorando.

Dal 4/12/2026.

  • #1200 di @JAG-UK — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with the upload paths in sp/upload.ts and sp/upload-streaming.ts, then trace SDK store() and the default batched path in piece-batching.ts. Check the React hook use-upload-pieces.ts and secondary creation paths as well. Done means both upload paths honor the data set's read mode, restricted URLs and grants work, early validation covers both SDK paths, tests cover public and restricted modes, and the required Curio release is available.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

Since #1161, every upload sends read: "public" (sp/upload.ts:56, sp/upload-streaming.ts:263), and callers can't change it. A private upload, such as filecoin-pin's add --private, is therefore served on /public/{cid} until a restricted data set claims it. A piece that is never claimed stays there until Curio's PieceGC removes it, which takes at least 2 h and depends on Curio's config.

filecoin-project/curio#1662 (merged 2026-11-26) supports the private path. A read: "restricted" upload is stored for restricted access only and, before commit, served only on /download/{cid} to holders of a FOC grant. Curio refuses a restricted upload without an encryption envelope.

Neither #1662 nor #1643 is in a Curio release yet. The latest release is v1.29.3. On v1.29.3, read is ignored and every upload is public, there is no /download route, and pulls don't accept grants. This issue must not ship until approved providers run a release that includes both.

Proposed solution

  • Core.
    • upload() already loads the data set through getPdpDataSet (sp/upload.ts:152), metadata included. It derives the read mode from dataSet.metadata, with no extra RPC.
    • uploadPieces and createPieceBatcher take read: 'public' | 'restricted', defaulting to 'public'.
  • SDK (store()) has no read option. It takes the read mode from the data set's read metadata (context.dataSetMetadata):
    • absent or public means public, so existing data sets don't change;
    • restricted means restricted;
    • any other value, including one with surrounding whitespace, is rejected before upload. Curio trims and lowercases the upload hint but compares the create metadata without trimming, so the two could disagree.
  • synapse-react.
    • useUploadSimple gets the read mode from core upload() with no change of its own.
    • useUploadPieces passes the read mode from its PdpDataSet's metadata to SP.uploadPieces (use-upload-pieces.ts:121).
  • Secondaries. Create every secondary with read=restricted, including replacements, which reuse options.metadata. keysmith's dataSetMetadata() does not add read, so callers add it themselves.
  • Fail early. Run these checks in store() and on the SDK's default batched path, which calls SP.createPieceBatcher directly and skips store() (piece-batching.ts:190).
    • Reject restricted uploads with more than one copy and no getGrant, with a ValidationError, before anything is uploaded.
    • Reject withCDN for restricted data sets.
  • URLs. StorageContext.getPieceUrl uses the context's read mode, so retrievalUrl, getPieceStatus and pull sources follow from it. Pulls use #1196's /download URLs with getGrant.

Done criteria

  • Approved providers run a Curio release that includes filecoin-project/curio#1662 and #1643 (version to be confirmed)
  • A restricted data set sends read: "restricted" on both upload paths; a public one, or one with no read, still sends read: "public"
  • Core defaults to read: 'public', and existing callers see no change
  • An unknown or untrimmed read value, withCDN with restricted, and restricted multi-copy without getGrant are all rejected before upload
  • An upload without an envelope surfaces Curio's 400 through FinalizeUploadError and through store()
  • For a restricted data set, getPieceUrl, retrievalUrl and getPieceStatus return /download/{cid}, never /public/{cid}
  • Restricted secondaries, including replacements, are created with read=restricted, and their pulls use /download with grants
  • Core upload() derives the read mode from the data set it already loads; useUploadSimple and useUploadPieces both send it
  • The early rejections run on both store() and the default batched path
  • MSW upload mocks take the read mode as a parameter, and tests cover both modes
  • On devnet with the new Curio, a restricted piece returns 404 on /public, and a two-copy restricted upload ends with two copies

Trade-offs and risks

  • Curio dependency. On a v1.29.3 provider, a restricted upload is silently public, /download URLs return 404, and restricted secondary pulls fail permanently. Two-copy restricted uploads, which work over /public today, would break. The Curio release is a hard prerequisite, not a recommendation. Synapse does not check provider versions or capabilities; making sure providers support restricted uploads is up to Curio.
  • Downloads are out of scope. Restricted content is read by CID through IPNI, which #1193 covers. storage.download/context.download by PieceCID still resolve /public (piece/resolve-piece-url.ts, manager.ts:929) and fail for restricted pieces, with an error that says the piece is restricted. filecoin-pin's PieceCID retrieval (behind a flag) needs a follow-up once that path is wanted for restricted data.
  • Commit layout. Each commit stays scoped to one package (core, sdk, react), so per-package changelogs split correctly. Merge with rebase, or keep the squash title's scope accurate.

Notes

  • Part of #1088. Depends on #1196. Follows the "later, for restricted data sets" note in #1161.
  • Release blocker for encryption v2 (#1088): update its Curio line, since curio#1662 merged on 2026-11-26 but is not released yet.
  • Client: filecoin-project/filecoin-pin add --private (feat/encryption-v2) supplies getGrant from the session key's Grant for the group it writes under, or from the owner's own claim.
  • Docs: upload-pipeline.mdx; coordinate with #1085 (access-control.mdx).
Lingua principale
TypeScript
Stelle
27
Fork
36
Merge medio
2g 4h
PR unite (30g)
65

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FilOzone/synapse-sdk

Tutte le issue di FilOzone/synapse-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.