feat(desktop): share contract — id-based recipients, server request shape, dead-call sweep (#207) #212

Merged
amiryahaya merged 1 commit from feat/desk-share-contract into main 2026-11-16 20:36:27 +01:00
Owner

PR-D1b of the #207 align-then-adorn campaign — stacked on #211 (base is the D1a branch; retarget to main when #211 merges).

create_share speaks the live POST /api/shares contract: {resource_id, resource_type, shared_with_id, permission, encrypted_key, kem_algorithm, expires_at}. Recipients are user ids from the tenant member roster (the server has no user-search endpoint — /users/search never existed). Recipient key material comes from GET /users/{id}/public-key (the intentionally cross-tenant endpoint; PublicKeys JSON bundle parsed client-side).

Grant-key encapsulation: folder shares re-encapsulate the folder KEK; file shares unwrap the row's DEK with the parent folder key and encapsulate the DEK itself — one file, no folder over-grant. The hybrid wrap travels as base64(JSON{kem_ciphertext, wrapped_kek}) inside the server's single opaque encrypted_key field (relayed verbatim to recipients; byte-exact round trip verified).

folder_keys module (new): folder-KEK resolution extracted from file_service — shared by both services instead of a drifting near-copy.

Dead-call sweep: search_recipients + /users/search removed; recovery trustee setup now fails honestly up front (it depended on the same ghost search — was always a 404 in waiting; revisited with dev-plan 2.5); tauriService getFileMetadata/searchRecipients/encryptFile/decryptFile/decapsulateFolderKey/getFolderEncryptionMetadata removed (two invoked commands were never even registered); three orphaned Rust crypto commands removed; memberStore now parses ListMembers' bare-array response (was a phantom {members} envelope) and stops doubling /api in the URL.

ShareDialog recipient picker: member roster (loadMembers on open, client-side filter, selection by user_id); Admin permission option removed (server accepts read/write only — offering it guaranteed a 400).

Review: dual-pass done. Pass 2 found five Importants, all fixed in this PR: the phantom member shape (adapter from display_name/created_at + Array.isArray guard), the /api URL doubling, Admin dead-end, RecipientPublicKeys over-strict parsing (signing keys now tolerated-missing), and the explicit resource_type validation.

Tests: cargo 68 green; vitest 1306 green (shareStore 30, memberStore 13 with the real server projection, ShareDialog 18, tauri 56); tsc clean.

Legacy share LIST surfaces (my-shares/received/accept/decline, old Share model) are the next slice (dev-plan 7.3) — their shape mismatch is untouched by design.

Related: #207, #158, #211.

PR-D1b of the #207 align-then-adorn campaign — stacked on #211 (base is the D1a branch; retarget to main when #211 merges). **create_share speaks the live POST /api/shares contract**: {resource_id, resource_type, shared_with_id, permission, encrypted_key, kem_algorithm, expires_at}. Recipients are user ids from the tenant member roster (the server has no user-search endpoint — /users/search never existed). Recipient key material comes from GET /users/{id}/public-key (the intentionally cross-tenant endpoint; PublicKeys JSON bundle parsed client-side). **Grant-key encapsulation**: folder shares re-encapsulate the folder KEK; file shares unwrap the row's DEK with the parent folder key and encapsulate the DEK itself — one file, no folder over-grant. The hybrid wrap travels as base64(JSON{kem_ciphertext, wrapped_kek}) inside the server's single opaque encrypted_key field (relayed verbatim to recipients; byte-exact round trip verified). **folder_keys module** (new): folder-KEK resolution extracted from file_service — shared by both services instead of a drifting near-copy. **Dead-call sweep**: search_recipients + /users/search removed; recovery trustee setup now fails honestly up front (it depended on the same ghost search — was always a 404 in waiting; revisited with dev-plan 2.5); tauriService getFileMetadata/searchRecipients/encryptFile/decryptFile/decapsulateFolderKey/getFolderEncryptionMetadata removed (two invoked commands were never even registered); three orphaned Rust crypto commands removed; memberStore now parses ListMembers' bare-array response (was a phantom {members} envelope) and stops doubling /api in the URL. **ShareDialog recipient picker**: member roster (loadMembers on open, client-side filter, selection by user_id); Admin permission option removed (server accepts read/write only — offering it guaranteed a 400). **Review**: dual-pass done. Pass 2 found five Importants, all fixed in this PR: the phantom member shape (adapter from display_name/created_at + Array.isArray guard), the /api URL doubling, Admin dead-end, RecipientPublicKeys over-strict parsing (signing keys now tolerated-missing), and the explicit resource_type validation. **Tests**: cargo 68 green; vitest 1306 green (shareStore 30, memberStore 13 with the real server projection, ShareDialog 18, tauri 56); tsc clean. Legacy share LIST surfaces (my-shares/received/accept/decline, old Share model) are the next slice (dev-plan 7.3) — their shape mismatch is untouched by design. Related: #207, #158, #211.
feat(desktop): share contract — id-based recipients, server request shape, dead-call sweep (#207)
Some checks failed
Security CI / security-scan (pull_request) Failing after 1m3s
a0ac80b386
D1b of the #207 align-then-adorn campaign:

- create_share speaks the live POST /api/shares contract:
  {resource_id, resource_type, shared_with_id, permission, encrypted_key,
  kem_algorithm, expires_at}. Recipients are user ids (tenant members);
  recipient key material comes from GET /users/{id}/public-key (the
  intentionally cross-tenant endpoint — PublicKeys JSON bundle parsed
  client-side). GET /users/search and /users/keys?email= never existed.
- Grant-key encapsulation: folder shares re-encapsulate the folder KEK;
  file shares unwrap the row's DEK and encapsulate the DEK itself (one
  file, no folder over-grant). The hybrid wrap travels as
  base64(JSON{kem_ciphertext, wrapped_kek}) in the server's single
  opaque encrypted_key field (relayed verbatim to recipients).
- Folder-KEK resolution extracted to services/folder_keys.rs — shared by
  file_service and sharing_service (was a near-copy waiting to drift).
- search_recipients command + /users/search call removed. Recovery
  trustee setup now fails honestly up front: it depended on the same
  ghost search endpoint (always a 404 in waiting); revisited with
  dev-plan 2.5 key-provisioning.
- Dead-call sweep: tauriService getFileMetadata/searchRecipients/
  encryptFile/decryptFile/decapsulateFolderKey/getFolderEncryptionMetadata
  removed (two invoked commands that were never registered server-side);
  the three orphaned Rust crypto commands + registrations removed.
- memberStore parses ListMembers' bare-array response (was reading a
  {members} envelope the server never sent); ShareDialog recipient
  picker switched to the member roster (client-side filter) and passes
  resource_type + file DEK material from the listed row.
- TS: CreateShareRequest/tauri service updated; tauri/shareStore/
  memberStore/ShareDialog test suites updated (56/30/13/18 green).

Full desktop suite: 1306 passed, typecheck clean; cargo 68 passed.
amiryahaya force-pushed feat/desk-share-contract from a0ac80b386
Some checks failed
Security CI / security-scan (pull_request) Failing after 1m3s
to 0ce3743424
Some checks failed
Security CI / security-scan (pull_request) Failing after 20s
2026-11-16 16:54:56 +01:00
Compare
amiryahaya force-pushed feat/desk-share-contract from 0ce3743424
Some checks failed
Security CI / security-scan (pull_request) Failing after 20s
to b7cb3ecfad
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m28s
2026-11-16 18:17:40 +01:00
Compare
amiryahaya changed target branch from feat/desk-file-alignment to main 2026-11-16 19:29:07 +01:00
amiryahaya force-pushed feat/desk-share-contract from b7cb3ecfad
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m28s
to 63cf441da6
All checks were successful
Security CI / security-scan (pull_request) Successful in 3m51s
API CI / migrations (pull_request) Successful in 5m40s
API CI / build-and-test (pull_request) Successful in 12m22s
Desktop CI / lint-and-test (pull_request) Successful in 13m57s
2026-11-16 20:21:51 +01:00
Compare
Sign in to join this conversation.
No description provided.