Storage and transfer SDKs
Updated: 2026-12-05
Each SubApp owns its file index, ACL, Worker and private bucket. AuthCenter checks the App service credential and the user's audience. Billing handles storage policies, capacity reservations, commits and releases. Transfer bytes run between the client and the SubApp or storage provider.
Local install and versioning
Use @aryuki-dev/storage-sdk for the Worker, adapters and D1 migration, @aryuki-dev/transfer-client for browser transfers and @aryuki-dev/storage-vue for an optional upload queue. Install the matching Shared Types, Auth SDK and Billing SDK release. The current storage protocol version is 1.
From BillingCenter, run npm install, npm run build, npm test, npm run pack and npm run verify:install. Install the tarballs from artifacts/ in a test consumer. The owner selects the registry, version and publication scope. Review the packaged files and exact dependencies before manually publishing. A deployed App uses a new SDK after rebuilding and deploying the App with the updated lockfile.
SubApp integration
- Register the App and its exact callbacks in AuthCenter. Configure its V2 service credential, storage capability and Billing policy reference.
- Configure the corresponding Billing policy and account capacity. The examples cover a single PUT policy with a 20 MiB ceiling and a multipart policy with a 3 GiB ceiling and 16 MiB parts.
- Apply the SDK migration to the App's D1 database. Bind the App's private bucket and Auth/Billing Workers. Create the handler with an App session verifier and ACL. Browser access can use the App's own BFF Cookie and same-origin CSRF checks. Keep service credentials in Workers Secrets.
- Instantiate
TransferClientwith the App origin and optionalIndexedDbTransfers. Namespace persisted metadata by account. Restore it on page load and reselect the original file. The optional Vue uploader accepts the client as its controller. Import@aryuki-dev/storage-vue/style.css.
Development and recovery
Use the same idempotency key when retrying an unchanged operation. Check shared allowance when the service returns storage_quota_exceeded. Complete verifies actual object bytes and version before publication. Retry commit_pending with the same Billing operation. Schedule reconcilePrivateStorage to remove expired uploads and replacements. Review uncertain provider initialization and unfinished commits.
The R2 binding supports streaming proxy transfers and Range downloads. For S3 presigned operations, validate signed length, conditional writes and CORS on the specific provider. Keep bucket, key and upload ID pinned for each session. Test each enabled transfer path in the intended deployment environment.
Migrate existing objects against an inventory that preserves owner, object ID, version and existing access. Reconcile logical allocation once. Keep authorized reads and deletes available when disabling new uploads. AuthCenter exposes the most recent App integration check.