feat: collaborative encrypted drives with ACT-based access control#71
Open
misaakidis wants to merge 3 commits into
Open
feat: collaborative encrypted drives with ACT-based access control#71misaakidis wants to merge 3 commits into
misaakidis wants to merge 3 commits into
Conversation
Implements the browser-side ACT shared drive stack on top of @nook/act-js: crypto/drive.ts: deriveWriteKey, driveFeedTopicHex, ECIES writeKey encrypt/decrypt helpers via @swarm-notify/sdk crypto module. api/driveFeed.ts: readLatestEntry / writeEntry for the driveFeed SOC (topic + writeKey-signed feed, JSON payload with historyRef + encryptedRef). hooks/useSharedDrives.ts: SharedDriveV2 type + useSharedDrivesV2 hook (nook-shared-drives-v2 localStorage key, legacy key untouched). hooks/useActiveDrive.ts: route-param → SharedDriveV2 + canWrite flag. api/createSharedDrive.ts: creates ACT + empty manifest + initial driveFeed entry; returns a SharedDriveV2 ready to persist. api/sharedDriveUpload.ts: decrypts manifest via ActClient.decryptRef, appends file, re-encrypts via reencryptRef, writes new feed entry. api/memberList.ts: creator-signed MemberListDoc (sign/verify/update/ fetch). hooks/useMemberList.ts: fetches + signature-verifies on mount. hooks/useInboxPolling.ts: extended to detect v2 drive-share messages (link contains driveId) and auto-add to nook-shared-drives-v2, with optional writeKey decryption (falls back to reader on failure). hooks/useSharedDrives.ts: parseShareLinkTyped (discriminated union v1/v2), buildV2ShareLink. components/AddSharedDriveModal.tsx: v2 branch decrypts writeKey and calls addDriveV2 / onAddV2 prop; legacy v1 path untouched. Both branches handle optional sender contact import. Dependencies: adds @nook/act-js from github:misaakidis/act-js.
- Add CreateCollaborativeDriveModal: name + stamp selector, calls createSharedDrive() API, saves to sharedDrivesV2 on success - Add "New collaborative" button in Shared tab header alongside existing "Add shared drive" button - Render ShareModalV2 when a v2 drive's Share button is clicked - Pass onAddV2 to AddSharedDriveModal so v2 share links import correctly into sharedDrivesV2 store - Drop unused creatingSharedDrive / createSharedError state - Import Bee from @ethersphere/bee-js for drive creation
Auto-fixed by eslint --fix: import reflows, blank lines, prettier multi-line formatting. No logic changes.
Author
Protocol diagramsRead-only ACT vs Read/Write ACTThe existing sharing model uses ACT tied to the Bee node's keypair, encrypts individual files, and has no write access concept. The new model lifts ACT into the browser, narrows it to encrypting the manifest (the file index), and adds a separate write-key layer for feed signing. What lives whereRead path (any grantee)Write path (writer uploads a file)Granting accessRevoking access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A new collaborative drive type that allows multiple users to read from and write to a shared encrypted drive on Swarm, with the creator managing who has access.
This is distinct from the existing shared drive flow, where a drive owner grants their Bee node's ACT key to specific readers. The new model is fully wallet-derived and works across any device — no Bee node key sharing involved.
How it works
Drive creation
When a user creates a collaborative drive, three things are set up on Swarm:
act-js, a browser-side ACT client. The creator's wallet-derived key is the initial grantee.keccak256("nook:drive:<creatorAddr>:<driveId>"). Each feed entry points to the current encrypted manifest (file list). The feed is signed by a write key rather than the wallet key directly.HMAC-SHA256(creatorSigningKey, "nook:write:<driveId>:v<N>"). This key controls who can push new entries to the drive feed.The manifest (a JSON file listing all drive files) is ACT-encrypted so only current grantees can read it. The feed entry stores the encrypted manifest reference alongside the ACT history ref needed to decrypt it.
Roles
Readers get ACT access to the encrypted manifest. Writers additionally receive the write key, encrypted with their wallet public key (ECIES via
@swarm-notify/sdk), so they can post new feed entries.Who pays for storage
Each participant uploads to their own postage stamp. Writers and readers select which of their own drives to use when uploading a file — they are not uploading onto the creator's stamp. The drive feed and ACT state live on the creator's stamp; file data lives on whoever uploaded it.
Granting and revoking access
The creator uses a new Share modal (
ShareModalV2) to manage members:ActClient.patchGrantees({ add: [writerPublicKey] })to extend ACT access, then sends the grantee a share link via Nook messaging. Writer links include the write key encrypted specifically for that recipient's wallet public key.Member state is tracked in a signed member list document (creator's secp256k1 signature over canonical JSON) uploaded to Swarm and referenced in the feed entry. This lets any member verify the current access state without trusting a centralised server.
Receiving a shared drive
Share links use the existing
nook://drive-sharescheme, extended with v2 params (driveId,role,writeKey). The presence ofdriveIddistinguishes v2 links from legacy ones.useInboxPolling(which already runs in the background at the Layout level) now also scans incoming messages for v2 drive-share links and auto-imports the drive into localStorage — no manual paste needed.New files
src/crypto/drive.tssrc/api/driveFeed.tssrc/api/createSharedDrive.tssrc/api/sharedDriveUpload.tssrc/api/memberList.tssrc/hooks/useSharedDrives.tsSharedDriveV2type,useSharedDrivesV2hook, v2 link parsing/buildingsrc/hooks/useActiveDrive.tscanWriteflagsrc/hooks/useMemberList.tssrc/components/ShareModalV2.tsxChanged files
src/components/AddSharedDriveModal.tsxsrc/hooks/useInboxPolling.tssrc/pages/Drive.tsxShareModalV2Dependency
Adds
@nook/act-js(github:misaakidis/act-js) — a browser-side ACT client that wraps Bee's ACT chunk operations. It exposesActClient.create(),patchGrantees(),encryptRef(),decryptRef(), andreencryptRef(). The package builds on install via itspreparescript.