Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Remove group member revoke from current implementation (#2159)

Leendert de Borst9bdc515d18a3
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.ts
index d3d2e5e03..98fff40d7 100644
--- a/apps/browser-extension/src/entrypoints/background.ts
+++ b/apps/browser-extension/src/entrypoints/background.ts
@@ -9,7 +9,7 @@ import { handleGetWebAuthnSettings, handleWebAuthnCreate, handleWebAuthnGet, han
import { handleOpenPopup, handlePopupWithItem, handleOpenPopupCreateCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';
import { handleStoreSavePromptState, handleGetSavePromptState, handleClearSavePromptState, handleStoreLastAutofilled, handleGetLastAutofilled, handleClearLastAutofilled } from '@/entrypoints/background/SavePromptStateHandler';
import { handleStoreTwoFactorState, handleGetTwoFactorState, handleClearTwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';
-import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGeneratePassword, handleGetPersistedFormValues, handleGetVault, handleGetVaultMigrationStatus, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVaultMetadata, handleSyncVault, handleUploadVault, handleGetEncryptedVault, handleStoreEncryptedVault, handleGetSyncState, handleMarkVaultClean, handleMigrateVaultManifest, handleFullVaultSync, handleGroupCreateVault, handleGroupInviteMember, handleGroupRevokeAccess, handleGroupRemoveMember, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleSetLoginSaveEnabled, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpSecrets, handleGenerateTotpCode, handleSetRecentlySelected, handleGetRecentlySelected, handleRecordItemUsage } from '@/entrypoints/background/VaultMessageHandler';
+import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGeneratePassword, handleGetPersistedFormValues, handleGetVault, handleGetVaultMigrationStatus, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVaultMetadata, handleSyncVault, handleUploadVault, handleGetEncryptedVault, handleStoreEncryptedVault, handleGetSyncState, handleMarkVaultClean, handleMigrateVaultManifest, handleFullVaultSync, handleGroupCreateVault, handleGroupInviteMember, handleGroupRevokeAccess, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleSetLoginSaveEnabled, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpSecrets, handleGenerateTotpCode, handleSetRecentlySelected, handleGetRecentlySelected, handleRecordItemUsage } from '@/entrypoints/background/VaultMessageHandler';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
import { onMessage, sendMessage } from "@/utils/messaging/ExtensionMessaging";
@@ -274,7 +274,6 @@ export default defineBackground({
onMessage('GROUP_CREATE_VAULT', ({ data, sender }) => isTrustedExtensionSender(sender) ? handleGroupCreateVault(data) : { success: false });
onMessage('GROUP_INVITE_MEMBER', ({ data, sender }) => isTrustedExtensionSender(sender) ? handleGroupInviteMember(data) : { success: false });
onMessage('GROUP_REVOKE_ACCESS', ({ data, sender }) => isTrustedExtensionSender(sender) ? handleGroupRevokeAccess(data) : { success: false });
- onMessage('GROUP_REMOVE_MEMBER', ({ data, sender }) => isTrustedExtensionSender(sender) ? handleGroupRemoveMember(data) : { success: false });
onMessage('LOCK_VAULT', () => handleLockVault());
onMessage('CLEAR_SESSION', () => handleClearSession());
onMessage('CLEAR_VAULT_DATA', () => handleClearVaultData());
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index fa0dc1301..786c304e8 100644
--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -16,11 +16,12 @@ import { requiresLegacyAccountKeyMigration } from '@/utils/legacy/LegacyStorageM
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
import { getManifestRevisions, getPersonalManifestId, manifestsRequiringPull, recordManifestRevisions, toManifestRevisionMap } from '@/utils/ManifestRevisions';
import { sendMessage, type TotpSecret } from '@/utils/messaging/ExtensionMessaging';
+import { multiManifestRendering } from '@/utils/MultiManifestRendering';
import { PendingActionProcessor } from '@/utils/PendingActionProcessor';
import { RecentlySelectedItemService } from '@/utils/RecentlySelectedItemService';
import { filterItems, AutofillMatchingMode, extractRootDomain, isUrlAlreadyLinked, generatePassword, vaultCodecExtractBuckets, vaultCodecBucketLayout, vaultCodecOverflowTable } from '@/utils/RustCore';
import { ServiceDetectionUtility } from '@/utils/serviceDetection/ServiceDetectionUtility';
-import { anchorFolderNames, createAnchorFolder, SharingService } from '@/utils/SharingService';
+import { SharingService } from '@/utils/SharingService';
import { SqliteClient } from '@/utils/SqliteClient';
import { getStorageItem } from '@/utils/StorageUtility';
import { generateTotpCode } from '@/utils/TotpUtility';
@@ -1722,8 +1723,8 @@ async function announceSyncPhase(needsPull: boolean, isDirty: boolean): Promise<
*/
async function applyServerDirectedChanges(webApi: WebApiService, statusResponse: StatusResponseV2, syncState: VaultSyncState, encryptionKey: string, needsPull: boolean): Promise<boolean> {
const pendingActions = PendingActionProcessor.pendingActions(statusResponse);
- const sharedManifestCount = Object.keys(await SharingService.getSharedManifestRecords()).length;
- if (pendingActions.length === 0 && sharedManifestCount === 0) {
+ const sharedManifests = Object.values(await SharingService.getSharedManifestRecords());
+ if (pendingActions.length === 0 && sharedManifests.length === 0) {
return false;
}
@@ -1731,7 +1732,7 @@ async function applyServerDirectedChanges(webApi: WebApiService, statusResponse:
// A vault with a migration still ahead of it is not on the current schema, so it cannot take the new rows yet.
const canReconcile = !await vaultRequiresManifestMigration(sqliteClient);
- let vaultChanged = canReconcile && await SharingService.ensureAnchorFolders(sqliteClient);
+ let vaultChanged = canReconcile && await multiManifestRendering.reconcile(sqliteClient, sharedManifests);
if (canReconcile && pendingActions.length > 0) {
vaultChanged = await PendingActionProcessor.process(webApi, pendingActions, sqliteClient) || vaultChanged;
}
@@ -1740,7 +1741,7 @@ async function applyServerDirectedChanges(webApi: WebApiService, statusResponse:
return false;
}
- // A rotated delivery key or a re-anchored folder is a normal local change, so it rides out on this very sync.
+ // A rotated delivery key or a re-rendered shared manifest is a normal local change, so it rides out on this very sync.
const reconciledVault = await EncryptionUtility.symmetricEncrypt(sqliteClient.exportToBase64(), encryptionKey);
const stored = await handleStoreEncryptedVault({ vaultBlob: reconciledVault, markDirty: true });
syncState.isDirty = true;
@@ -2628,7 +2629,7 @@ export async function handleGroupCreateVault(message: { groupId: string; name: s
}, encryptionKey);
await recordManifestRevisions({ [mapping.manifestId]: mapping.revision });
- await createAnchorFolder(sqliteClient, mapping.manifestId, name);
+ await multiManifestRendering.render(sqliteClient, mapping.manifestId, name);
// Mail to an alias in this vault is encrypted with the vault's own keypair, which is what makes it readable by every member.
await SharingService.rotateManifestEncryptionKey(sqliteClient, mapping.manifestId);
@@ -2715,7 +2716,7 @@ export async function handleGroupInviteMember(message: { groupId: string; manife
return failed('the key of the vault did not open');
}
- const vaultName = anchorFolderNames(sqliteClient)[manifest.manifestId.toLowerCase()] ?? record.name ?? null;
+ const vaultName = multiManifestRendering.displayNames(sqliteClient)[manifest.manifestId.toLowerCase()] ?? record.name ?? null;
const grant = await SharingService.encryptVekFor(manifestVek, member, vaultName);
if (!grant) {
return { success: false, apiErrorCode: 'INVITE_RECIPIENT_NOT_READY' };
@@ -2736,7 +2737,7 @@ export async function handleGroupInviteMember(message: { groupId: string; manife
}
/**
- * Take a member's access to one shared vault away, or give up one's own.
+ * Take a member's access to one shared vault away, or hand back one's own.
*
* @param message - the family, the vault, and the member losing access.
*/
@@ -2755,30 +2756,6 @@ export async function handleGroupRevokeAccess(message: { groupId: string; manife
}
console.error('Failed to revoke shared vault access:', error);
- return { success: false, error: await t('sharing.family.errors.removeMemberFailed') };
- }
-}
-
-/**
- * Remove somebody from a family, or leave one by naming oneself.
- *
- * @param message - the group and the member to remove.
- */
-export async function handleGroupRemoveMember(message: { groupId: string; userId: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
- try {
- const webApi = new WebApiService();
- await SharingService.removeMember(webApi, message.groupId, message.userId);
-
- devLog(`[Sharing] Removed ${message.userId} from group ${message.groupId}; syncing to pick up whatever the server left for this client to finish.`);
- void handleFullVaultSync().catch(error => console.error('Background sync after a group membership change failed:', error));
-
- return { success: true };
- } catch (error) {
- if (error instanceof ApiRequestError && error.apiErrorCode) {
- return { success: false, apiErrorCode: error.apiErrorCode };
- }
-
- console.error('Failed to remove group member:', error);
- return { success: false, error: await t('sharing.family.errors.removeMemberFailed') };
+ return { success: false, error: await t('sharing.family.errors.revokeAccessFailed') };
}
}
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
index 795df9dcc..6d27fded9 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemsList.tsx
@@ -5,7 +5,6 @@ import { useLocation, useNavigate, useParams, useSearchParams } from 'react-rout
import ConfirmDeleteModal from '@/entrypoints/popup/components/Dialogs/ConfirmDeleteModal';
import DeleteFolderModal from '@/entrypoints/popup/components/Folders/DeleteFolderModal';
import FolderBreadcrumb from '@/entrypoints/popup/components/Folders/FolderBreadcrumb';
-import FolderIcon from '@/entrypoints/popup/components/Folders/FolderIcon';
import FolderModal from '@/entrypoints/popup/components/Folders/FolderModal';
import HeaderButton from '@/entrypoints/popup/components/HeaderButton';
import { HeaderIconType } from '@/entrypoints/popup/components/Icons/HeaderIcons';
@@ -29,9 +28,10 @@ import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';
import type { Folder } from '@/utils/db/repositories/FolderRepository';
import type { CredentialSortOrder } from '@/utils/db/repositories/SettingsRepository';
import type { Item, ItemType } from '@/utils/dist/core/models/vault';
-import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, getRecursiveItemCount, isAnchorFolder, isSharedFolder } from '@/utils/FolderUtils';
+import { canHaveSubfolders, getDescendantFolderIds, getFolderPath, getRecursiveItemCount, isSharedFolder } from '@/utils/FolderUtils';
import { applyTypeFilter, isItemTypeFilter, parseItemFilterType, type ItemFilterType } from '@/utils/ItemFilters';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
+import { multiManifestRendering } from '@/utils/MultiManifestRendering';
import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
@@ -172,7 +172,7 @@ const ItemsList: React.FC = () => {
}, [currentFolderId, dbContext?.sqliteClient, folderRefreshKey]);
// Whether it is the folder a shared vault is rendered as: left or revoked in Family Sharing, never deleted here
- const currentFolderIsAnchor = currentFolder !== null && isAnchorFolder(currentFolder);
+ const currentFolderIsSharedVaultRoot = currentFolder !== null && multiManifestRendering.isManifestRoot(currentFolder);
// Get current folder's full path (for relative path computation in search results)
const currentFolderPath = useMemo(() => {
@@ -1195,7 +1195,7 @@ const ItemsList: React.FC = () => {
onDeleteFolderOnly={handleDeleteFolderOnly}
onDeleteFolderAndContents={handleDeleteFolderAndContents}
itemCount={totalItemCountInFolderTree}
- sharedVault={currentFolderIsAnchor}
+ sharedVault={currentFolderIsSharedVaultRoot}
/>
</div>
);
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/FamilySharingSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/FamilySharingSettings.tsx
index 582dfbd9b..5ddef942b 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/FamilySharingSettings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/FamilySharingSettings.tsx
@@ -12,15 +12,14 @@ import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';
import type { GroupInfo, GroupMemberInfo, GroupOverviewResponse, SharedManifestInfo } from '@/utils/dist/core/models/webapi';
import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
-import { anchorFolderNames, SharingService } from '@/utils/SharingService';
+import { multiManifestRendering } from '@/utils/MultiManifestRendering';
+import { SharingService } from '@/utils/SharingService';
import { ApiRequestError } from '@/utils/types/errors/ApiRequestError';
/**
- * What the confirmation dialog is about.
+ * The access removal the confirmation dialog is about.
*/
-type PendingRemoval =
- | { kind: 'member'; group: GroupInfo; member: GroupMemberInfo; isSelf: boolean }
- | { kind: 'access'; group: GroupInfo; manifest: SharedManifestInfo; member: GroupMemberInfo; isSelf: boolean };
+type PendingRemoval = { group: GroupInfo; manifest: SharedManifestInfo; member: GroupMemberInfo; isSelf: boolean };
/**
* A shared vault deletion in progress: first a plain warning, then the master password confirmation.
@@ -62,7 +61,7 @@ const FamilySharingSettings: React.FC = () => {
setInvitationNames(sqliteClient ? await SharingService.openInvitationNames(sqliteClient, loaded.receivedInvitations) : {});
const records = await SharingService.getSharedManifestRecords();
const names = Object.fromEntries(Object.values(records).filter(record => record.name).map(record => [record.manifestId.toLowerCase(), record.name as string]));
- setVaultNames({ ...names, ...(sqliteClient ? anchorFolderNames(sqliteClient) : {}) });
+ setVaultNames({ ...names, ...(sqliteClient ? multiManifestRendering.displayNames(sqliteClient) : {}) });
setError(null);
} catch {
setError(t('sharing.family.errors.loadFailed'));
@@ -181,7 +180,7 @@ const FamilySharingSettings: React.FC = () => {
}, t('sharing.family.errors.invitationGone'));
/**
- * Carry out whatever the confirmation dialog was about.
+ * Carry out the access removal the confirmation dialog was about.
*/
const confirmRemoval = (): Promise<void> => {
const removal = pendingRemoval;
@@ -190,16 +189,10 @@ const FamilySharingSettings: React.FC = () => {
return Promise.resolve();
}
- if (removal.kind === 'member') {
- return run(async () => {
- unwrap(await sendMessage('GROUP_REMOVE_MEMBER', { groupId: removal.group.groupId, userId: removal.member.userId }));
- }, t('sharing.family.errors.removeMemberFailed'));
- }
-
return run(async () => {
unwrap(await sendMessage('GROUP_REVOKE_ACCESS', { groupId: removal.group.groupId, manifestId: removal.manifest.manifestId, userId: removal.member.userId }));
await loadStoredDatabase();
- }, t('sharing.family.errors.removeMemberFailed'));
+ }, t('sharing.family.errors.revokeAccessFailed'));
};
/**
@@ -265,20 +258,20 @@ const FamilySharingSettings: React.FC = () => {
*/
const removalDialog = (): { title: string; message: string; confirmText: string } => {
if (!pendingRemoval) {
- return { title: '', message: '', confirmText: t('common.remove') };
+ return { title: '', message: '', confirmText: t('sharing.revoke') };
}
- if (pendingRemoval.kind === 'member') {
- return pendingRemoval.isSelf
- ? { title: t('sharing.family.leaveFamily'), message: t('sharing.family.leaveFamilyConfirm'), confirmText: t('sharing.family.leaveFamily') }
- : { title: t('common.remove'), message: t('sharing.family.removeMemberConfirm', { username: pendingRemoval.member.username }), confirmText: t('common.remove') };
+ if (pendingRemoval.isSelf) {
+ return {
+ title: t('sharing.family.leaveVault'),
+ message: t('sharing.family.leaveVaultConfirm', { vault: vaultLabel(pendingRemoval.manifest) }),
+ confirmText: t('sharing.family.leaveVault'),
+ };
}
return {
title: t('sharing.revoke'),
- message: pendingRemoval.isSelf
- ? t('sharing.family.leaveVaultConfirm', { vault: vaultLabel(pendingRemoval.manifest) })
- : t('sharing.family.revokeAccessConfirm', { username: pendingRemoval.member.username, vault: vaultLabel(pendingRemoval.manifest) }),
+ message: t('sharing.family.revokeAccessConfirm', { username: pendingRemoval.member.username, vault: vaultLabel(pendingRemoval.manifest) }),
confirmText: t('sharing.revoke'),
};
};
@@ -288,7 +281,7 @@ const FamilySharingSettings: React.FC = () => {
const dialog = removalDialog();
return (
- <div className="space-y-6">
+ <div className="space-y-4">
<ConfirmDeleteModal
isOpen={pendingRemoval !== null}
onClose={() => setPendingRemoval(null)}
@@ -331,10 +324,10 @@ const FamilySharingSettings: React.FC = () => {
{receivedInvitations.length > 0 && (
<section>
- <h3 className="text-md font-semibold text-gray-900 dark:text-white mb-3">{t('sharing.family.invitations')}</h3>
+ <h3 className="text-md font-semibold text-gray-900 dark:text-white mb-2">{t('sharing.family.invitations')}</h3>
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 divide-y divide-gray-200 dark:divide-gray-700">
{receivedInvitations.map(invitation => (
- <div key={invitation.id} className="p-4 space-y-3">
+ <div key={invitation.id} className="p-3 space-y-2">
<div>
<p className="font-medium text-gray-900 dark:text-white">{invitationNames[invitation.id] ?? t('sharing.family.unnamedVault')}</p>
<p className="text-sm text-gray-500 dark:text-gray-400">{t('sharing.family.invitedBy', { username: invitation.inviterUsername })}</p>
@@ -367,11 +360,12 @@ const FamilySharingSettings: React.FC = () => {
{groups.map(group => {
const canAdminister = group.role === 'Owner' || group.role === 'Admin';
+ const myUserId = group.members.find(member => member.username === app.username)?.userId ?? '';
return (
- <section key={group.groupId} className="space-y-4">
+ <section key={group.groupId} className="space-y-3">
{/* The family's members. */}
- <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-4">
+ <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-3">
<button onClick={() => toggleRoster(group.groupId)} className="flex items-center justify-between w-full text-left">
<span className="font-medium text-gray-900 dark:text-white">{t('sharing.members')} ({group.members.length})</span>
<svg className={`w-5 h-5 text-gray-500 transition-transform ${isRosterExpanded(group.groupId) ? 'rotate-180' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -380,115 +374,126 @@ const FamilySharingSettings: React.FC = () => {
</button>
{isRosterExpanded(group.groupId) && (
- <div className="mt-3 space-y-3">
- <ul className="space-y-2">
+ <div className="mt-2 space-y-2">
+ <ul className="divide-y divide-gray-100 dark:divide-gray-700">
{group.members.map(member => {
- const isSelf = member.username === app.username;
- const canRemove = member.role !== 'Owner' && (isSelf || canAdminister);
+ const isSelf = member.userId === myUserId;
return (
- <li key={member.userId} className="flex items-center justify-between gap-2">
+ <li key={member.userId} className="flex items-center justify-between gap-2 py-1.5 first:pt-0 last:pb-0">
<div className="min-w-0">
<p className="text-sm text-gray-900 dark:text-white truncate">
{member.username}{isSelf && ` (${t('sharing.family.you')})`}
</p>
<p className="text-xs text-gray-500 dark:text-gray-400">{roleLabel(member)}</p>
</div>
- {canRemove && (
- <button
- disabled={busy}
- onClick={() => setPendingRemoval({ kind: 'member', group, member, isSelf })}
- className="shrink-0 px-2 py-1 text-xs rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50"
- >
- {isSelf ? t('sharing.family.leaveFamily') : t('common.remove')}
- </button>
- )}
</li>
);
})}
</ul>
- <p className="text-xs text-gray-500 dark:text-gray-400">{t('sharing.family.rosterManagedElsewhere')}</p>
</div>
)}
</div>
- {/* One block per shared vault, each with the members who can open it. */}
- {group.manifests.map(manifest => (
- <div key={manifest.manifestId} className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-4 space-y-3">
- <div className="flex items-start justify-between gap-2">
- <div className="min-w-0">
- <p className="font-medium text-gray-900 dark:text-white">{vaultLabel(manifest)}</p>
- <p className="text-sm text-gray-600 dark:text-gray-400">{t('sharing.family.sharedVaultActive', { name: vaultLabel(manifest) })}</p>
- </div>
- {canAdminister && (
- <button
- disabled={busy}
- onClick={() => setPendingVaultDelete({ group, manifest, stage: 'confirm' })}
- className="shrink-0 px-2 py-1 text-xs rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50"
- >
- {t('common.delete')}
- </button>
- )}
- </div>
-
- <ul className="space-y-2">
- {group.members.map(member => {
- const isSelf = member.username === app.username;
- const hasAccess = manifest.memberUserIds.includes(member.userId);
- const isInvited = manifest.pendingInvitations.some(invitation => invitation.inviteeUserId === member.userId);
- const invitation = manifest.pendingInvitations.find(candidate => candidate.inviteeUserId === member.userId);
-
- return (
- <li key={member.userId} className="flex items-center justify-between gap-2">
- <div className="min-w-0">
- <p className="text-sm text-gray-900 dark:text-white truncate">
- {member.username}{isSelf && ` (${t('sharing.family.you')})`}
- </p>
- <p className="text-xs text-gray-500 dark:text-gray-400">
- {hasAccess ? t('sharing.family.hasAccess') : isInvited ? t('sharing.family.invited') : t('sharing.family.noAccess')}
- </p>
- </div>
-
- {hasAccess && (isSelf || canAdminister) && (
+ {/* One block per shared folder, each with the members who can open it. */}
+ {group.manifests.length > 0 && (
+ <div className="space-y-2">
+ <h3 className="text-md font-semibold text-gray-900 dark:text-white">{t('sharing.family.sharedFolders')}</h3>
+ {group.manifests.map(manifest => {
+ const iHoldKey = manifest.memberUserIds.includes(myUserId);
+
+ return (
+ <div key={manifest.manifestId} className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-3 space-y-2">
+ <div className="flex items-start justify-between gap-2">
+ <p className="font-medium text-gray-900 dark:text-white truncate">{vaultLabel(manifest)}</p>
+ {canAdminister && (
<button
disabled={busy}
- onClick={() => setPendingRemoval({ kind: 'access', group, manifest, member, isSelf })}
+ onClick={() => setPendingVaultDelete({ group, manifest, stage: 'confirm' })}
className="shrink-0 px-2 py-1 text-xs rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50"
>
- {t('sharing.revoke')}
- </button>
- )}
-
- {isInvited && canAdminister && invitation && (
- <button
- disabled={busy}
- onClick={() => run(() => SharingService.withdrawInvitation(webApi, invitation.id), t('sharing.family.errors.invitationGone'))}
- className="shrink-0 px-2 py-1 text-xs rounded-md text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50"
- >
- {t('sharing.family.withdraw')}
+ {t('common.delete')}
</button>
)}
-
- {!hasAccess && !isInvited && canAdminister && (
- <button
- disabled={busy || !member.publicKey}
- title={member.publicKey ? undefined : t('sharing.family.errors.userNotReady')}
- onClick={() => inviteMember(group, manifest, member)}
- className="shrink-0 px-2 py-1 text-xs rounded-md bg-primary-500 hover:bg-primary-600 disabled:opacity-50 text-white"
- >
- {t('sharing.family.invite')}
- </button>
- )}
- </li>
- );
- })}
- </ul>
+ </div>
+
+ {/* Inviting somebody seals this vault's key for them, which an admin who holds no grant on it cannot do. */}
+ {canAdminister && !iHoldKey && (
+ <p className="text-xs text-gray-500 dark:text-gray-400">{t('sharing.family.cannotInviteWithoutAccess')}</p>
+ )}
+
+ <ul className="divide-y divide-gray-100 dark:divide-gray-700">
+ {group.members.map(member => {
+ const isSelf = member.userId === myUserId;
+ const hasAccess = manifest.memberUserIds.includes(member.userId);
+ const isInvited = manifest.pendingInvitations.some(invitation => invitation.inviteeUserId === member.userId);
+ const invitation = manifest.pendingInvitations.find(candidate => candidate.inviteeUserId === member.userId);
+
+ return (
+ <li key={member.userId} className="flex items-center justify-between gap-2 py-1.5 first:pt-0 last:pb-0">
+ <div className="min-w-0">
+ <p className="text-sm text-gray-900 dark:text-white truncate">
+ {member.username}{isSelf && ` (${t('sharing.family.you')})`}
+ </p>
+ <p className="text-xs text-gray-500 dark:text-gray-400">
+ {hasAccess ? t('sharing.family.hasAccess') : isInvited ? t('sharing.family.invited') : t('sharing.family.noAccess')}
+ </p>
+ </div>
+
+ {/* An admin's own grant stays put: it is the only copy of the key their duties, inviting others among them, need. */}
+ {hasAccess && isSelf && !canAdminister && (
+ <button
+ disabled={busy}
+ onClick={() => setPendingRemoval({ group, manifest, member, isSelf })}
+ className="shrink-0 px-2 py-1 text-xs rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50"
+ >
+ {t('sharing.family.leaveVault')}
+ </button>
+ )}
+
+ {hasAccess && !isSelf && canAdminister && (
+ <button
+ disabled={busy}
+ onClick={() => setPendingRemoval({ group, manifest, member, isSelf })}
+ className="shrink-0 px-2 py-1 text-xs rounded-md text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50"
+ >
+ {t('sharing.revoke')}
+ </button>
+ )}
+
+ {isInvited && !isSelf && canAdminister && invitation && (
+ <button
+ disabled={busy}
+ onClick={() => run(() => SharingService.withdrawInvitation(webApi, invitation.id), t('sharing.family.errors.invitationGone'))}
+ className="shrink-0 px-2 py-1 text-xs rounded-md text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50"
+ >
+ {t('sharing.family.withdraw')}
+ </button>
+ )}
+
+ {!hasAccess && !isInvited && !isSelf && canAdminister && iHoldKey && (
+ <button
+ disabled={busy || !member.publicKey}
+ title={member.publicKey ? undefined : t('sharing.family.errors.userNotReady')}
+ onClick={() => inviteMember(group, manifest, member)}
+ className="shrink-0 px-2 py-1 text-xs rounded-md bg-primary-500 hover:bg-primary-600 disabled:opacity-50 text-white"
+ >
+ {t('sharing.family.invite')}
+ </button>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+ );
+ })}
</div>
- ))}
+ )}
- {/* Creating another shared vault. */}
+ {/* Creating another shared folder. */}
{(canAdminister || group.manifests.length === 0) && (
- <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-4 space-y-3">
+ <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-3 space-y-2">
{group.manifests.length === 0 && (
<p className="text-sm text-gray-600 dark:text-gray-400">
{canAdminister ? t('sharing.family.noSharedVaultAdmin') : t('sharing.family.noSharedVaultMember')}
diff --git a/apps/browser-extension/src/utils/SharingService.ts b/apps/browser-extension/src/utils/SharingService.ts
index d92a5ab88..cfe450bea 100644
--- a/apps/browser-extension/src/utils/SharingService.ts
+++ b/apps/browser-extension/src/utils/SharingService.ts
@@ -51,11 +51,6 @@ export type SharedManifestRecord = ManifestVekGrant & {
canAdminister?: boolean;
};
-/**
- * What a shared vault is called when this client has no name for it yet.
- */
-export const DEFAULT_SHARED_VAULT_NAME = 'Shared';
-
/**
* Service with static helpers implementing the vault sharing flows.
*/
@@ -158,7 +153,7 @@ export class SharingService {
}
/**
- * Take a member's access to one shared vault away, or give up one's own.
+ * Take a member's access to one shared vault away, or hand back one's own. The server refuses the latter for group admins.
* @param webApi - API client to reuse.
* @param groupId - the group the vault belongs to.
* @param manifestId - the shared vault.
@@ -210,43 +205,6 @@ export class SharingService {
await webApi.post<object, void>(`Groups/invitations/${invitationId}/decline`, {}, false);
}
- /**
- * Remove a member from a group, or leave one by naming oneself.
- * @param webApi - API client to reuse.
- * @param groupId - the group.
- * @param userId - the member to remove.
- */
- public static async removeMember(webApi: WebApiService, groupId: string, userId: string): Promise<void> {
- await webApi.delete<void>(`Groups/${groupId}/members/${userId}`);
- }
-
- /**
- * Make sure every shared vault this session administers is anchored at a local folder.
- * @param sqliteClient - the open local vault.
- * @returns Whether the vault was mutated.
- */
- public static async ensureAnchorFolders(sqliteClient: SqliteClient): Promise<boolean> {
- let mutated = false;
-
- for (const record of Object.values(await this.getSharedManifestRecords())) {
- if (!record.canAdminister) {
- // A member waiting for the administrator's first push has nothing to anchor yet.
- continue;
- }
-
- const anchored = sqliteClient.executeQuery<{ Id: string }>('SELECT Id FROM Folders WHERE ManifestId = ? AND IsDeleted = 0 AND ParentFolderId IS NULL', [record.manifestId]);
- if (anchored.length > 0) {
- continue;
- }
-
- await createAnchorFolder(sqliteClient, record.manifestId, record.name ?? DEFAULT_SHARED_VAULT_NAME);
- devWarn(`[Sharing] Shared vault ${record.manifestId} had no anchor folder; recreated it.`);
- mutated = true;
- }
-
- return mutated;
- }
-
/**
* Mint a fresh active keypair for a shared manifest.
* @param sqliteClient - the open local vault DB (caller must run this inside a vault mutation so it is saved)
@@ -376,25 +334,4 @@ export class SharingService {
}
-/**
- * What every shared manifest in this vault is called, keyed by lower-cased manifest id.
- * @param sqliteClient - the open local vault.
- */
-export function anchorFolderNames(sqliteClient: SqliteClient): Record<string, string> {
- const anchors = sqliteClient.executeQuery<{ ManifestId: string; Name: string }>('SELECT ManifestId, Name FROM Folders WHERE IsDeleted = 0 AND ManifestId IS NOT NULL AND UPPER(Id) = UPPER(ManifestId)');
- return Object.fromEntries(anchors.map(anchor => [anchor.ManifestId.toLowerCase(), anchor.Name]));
-}
-
-/**
- * Renders a shared manifest as a local folder.
- * @param sqliteClient - the open local vault.
- * @param manifestId - the shared vault to give a folder to.
- * @param name - the vault's own name, used as the folder name.
- */
-export async function createAnchorFolder(sqliteClient: SqliteClient, manifestId: string, name: string): Promise<void> {
- const folderId = manifestId.toUpperCase();
- await sqliteClient.folders.create(name, null, folderId);
- await sqliteClient.folders.restampSubtree(folderId, manifestId);
-}
-
export default SharingService;
diff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.ts
index 3e24d546d..6b95c1693 100644
--- a/apps/browser-extension/src/utils/VaultSyncService.ts
+++ b/apps/browser-extension/src/utils/VaultSyncService.ts
@@ -15,8 +15,9 @@ import { buildEmailRouting } from '@/utils/EmailRouting';
import { EncryptionUtility } from '@/utils/EncryptionUtility';
import { completeLegacyAccountKeyMigration, isLegacySqliteBlobSnapshot, legacyUnstampedRowAdoption, openLegacySqliteBlobSnapshot, prepareLegacyAccountKeyMigration, withOutdatedServerGuard, type LegacyAccountKeyMigration, type LegacySqliteBlobSnapshot } from '@/utils/legacy/LegacyStorageModelMigration';
import { getManifestRevisions, getPersonalManifestId, recordManifestRevisions, replaceManifestRevisions, toManifestRevisionMap } from '@/utils/ManifestRevisions';
+import { multiManifestRendering } from '@/utils/MultiManifestRendering';
import {vaultCodecComputeCiphertextHash, vaultCodecComputeContentFingerprint, vaultCodecCanonicalizeFromSqlite, vaultCodecExtractEncryptionKeyForPublicKey, vaultCodecGenerateManifestSalt, vaultCodecUnpackPayload, vaultCodecMaterializeAsSqlite, vaultCodecPackPayload, vaultCodecValidateManifest, vaultCodecValidateDataBucket, type CodecBlobEntry, type CodecCanonicalized, type CodecManifest, type CodecManifestSpec} from '@/utils/RustCore';
-import { anchorFolderNames, SharingService, type ManifestVekGrant, type SharedManifestRecord } from '@/utils/SharingService';
+import { SharingService, type ManifestVekGrant, type SharedManifestRecord } from '@/utils/SharingService';
import { SqliteClient } from '@/utils/SqliteClient';
import { getStorageItem } from '@/utils/StorageUtility';
import { VaultProcessingError } from '@/utils/types/errors/VaultProcessingError';
@@ -1170,8 +1171,8 @@ export class VaultSyncService {
}
/**
- * Canonicalize the local vault into the manifest-v1 format against every manifest this vault writes, splitting
- * each shared manifest's anchor subtree off into its own manifest.
+ * Canonicalize the local vault into the manifest-v1 format against every manifest this vault writes, routing each
+ * row into its own manifest by the ManifestId it carries.
* @param sqliteClient - the in-memory SQLite database to canonicalize
* @returns The canonicalized set plus the manifest records it was split against
*/
@@ -1362,7 +1363,7 @@ export class VaultSyncService {
const stampedManifestIds = VaultCodec.manifestIdsInVault(sqliteClient);
const sharedVeks = await SharingService.openSharedManifestVeks(sqliteClient);
- const folderNames = anchorFolderNames(sqliteClient);
+ const manifestNames = multiManifestRendering.displayNames(sqliteClient);
for (const record of Object.values(await SharingService.getSharedManifestRecords())) {
if (!stampedManifestIds.has(record.manifestId)) {
devLog(`[V2Push] Shared manifest ${record.manifestId} has no rows in this vault; leaving it out of the write rather than emptying it server-side.`);
@@ -1381,8 +1382,8 @@ export class VaultSyncService {
isPersonal: false,
salt: record.salt,
vek,
- // Read back off the anchor folder every push, so the name inside the manifest follows a rename instead of staying at whatever the vault was called when it was created.
- name: folderNames[record.manifestId.toLowerCase()] ?? record.name ?? null,
+ // Re-read how this client renders the manifest on every push, so the name inside it follows a rename instead of staying at whatever the vault was called when it was created.
+ name: manifestNames[record.manifestId.toLowerCase()] ?? record.name ?? null,
canAdminister: record.canAdminister === true,
});
}
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index 9bb0ff911..0403ca120 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -92,7 +92,6 @@ export interface IExtensionMessageProtocol {
GROUP_CREATE_VAULT(data: { groupId: string; name: string }): { success: boolean; error?: string; apiErrorCode?: string };
GROUP_INVITE_MEMBER(data: { groupId: string; manifestId: string; userId: string }): { success: boolean; error?: string; apiErrorCode?: string };
GROUP_REVOKE_ACCESS(data: { groupId: string; manifestId: string; userId: string }): { success: boolean; error?: string; apiErrorCode?: string };
- GROUP_REMOVE_MEMBER(data: { groupId: string; userId: string }): { success: boolean; error?: string; apiErrorCode?: string };
IS_URL_LINKED_TO_CREDENTIAL(data: { itemId: string; url: string }): { linked: boolean };
LOCK_VAULT(): BoolResponse;
MARK_VAULT_CLEAN(data: { mutationSeqAtStart: number }): { cleared: boolean; currentMutationSeq: number };
diff --git a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
index 588a03793..1eb08dc4b 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
@@ -312,11 +312,11 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Take a member's access to one shared vault away, without touching their membership of the group.
+ /// Revoke a member's access to a shared manifest.
/// </summary>
/// <param name="groupId">The group ID.</param>
- /// <param name="manifestId">The shared vault.</param>
- /// <param name="userId">The member losing access, or the caller themselves.</param>
+ /// <param name="manifestId">The shared manifest.</param>
+ /// <param name="userId">The member losing access.</param>
/// <returns>Ok on success.</returns>
[HttpDelete("{groupId:guid}/manifests/{manifestId:guid}/access/{userId}")]
public async Task<IActionResult> RevokeAccess(Guid groupId, Guid manifestId, string userId)
@@ -329,7 +329,15 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
var isSelf = string.Equals(userId, me.Id, StringComparison.Ordinal);
- if (!isSelf && !await GroupHelper.IsSharedGroupAdminAsync(context, groupId, me.Id))
+ var isAdmin = await GroupHelper.IsSharedGroupAdminAsync(context, groupId, me.Id);
+
+ if (isSelf && isAdmin)
+ {
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.CANNOT_REVOKE_OWN_ACCESS, 400));
+ }
+
+ var mayRevoke = isSelf ? await GroupHelper.IsSharedGroupMemberAsync(context, groupId, me.Id) : isAdmin;
+ if (!mayRevoke)
{
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404));
}
@@ -339,7 +347,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
}
- if (!isSelf && await GrantHelper.IsLastGrantHolderAsync(context, manifestId, userId))
+ if (await GrantHelper.IsLastGrantHolderAsync(context, manifestId, userId))
{
return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.LAST_MANIFEST_GRANT_HOLDER, 400));
}
@@ -581,87 +589,6 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return Ok();
}
- /// <summary>
- /// Remove a member from a shared group, taking their access to every one of its vaults with them. Adding somebody
- /// back is an operator action, so this is deliberately one-way from a client's point of view.
- /// </summary>
- /// <param name="groupId">The group ID.</param>
- /// <param name="userId">The user ID to remove.</param>
- /// <returns>Ok on success.</returns>
- [HttpDelete("{groupId:guid}/members/{userId}")]
- public async Task<IActionResult> RemoveMember(Guid groupId, string userId)
- {
- await using var context = await dbContextFactory.CreateDbContextAsync();
- var me = await GetCurrentUserAsync();
- if (me == null)
- {
- return Unauthorized();
- }
-
- var membership = await context.GroupMembers.FirstOrDefaultAsync(gm => gm.GroupId == groupId && gm.UserId == userId && gm.Group.Type == GroupType.Shared);
- if (membership is null)
- {
- return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404));
- }
-
- var isSelf = string.Equals(userId, me.Id, StringComparison.Ordinal);
- if (!isSelf && !await GroupHelper.IsGroupAdminAsync(context, groupId, me.Id))
- {
- return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404));
- }
-
- // The owner is the group's anchor: losing them would leave a group nobody can administer or delete.
- if (membership.Role == GroupRole.Owner)
- {
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.CANNOT_REMOVE_GROUP_OWNER, 400));
- }
-
- var manifestIds = await GroupHelper.GetManifestIdsOfGroupAsync(context, groupId);
-
- /*
- * Removing the only member who can open a vault would leave it unopenable, since the key exists nowhere else.
- * An admin has to hand that vault to somebody else first. Leaving of one's own accord is not blocked by it:
- * being unable to walk out of a family would be the worse failure, and the vault is the group's problem then.
- */
- if (!isSelf)
- {
- foreach (var manifestId in manifestIds)
- {
- if (await GrantHelper.IsLastGrantHolderAsync(context, manifestId, userId))
- {
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.LAST_MANIFEST_GRANT_HOLDER, 400));
- }
- }
- }
-
- // Create a transaction to ensure the membership and offers of access are closed together.
- var strategy = context.Database.CreateExecutionStrategy();
- await strategy.ExecuteAsync(async () =>
- {
- await using var transaction = await context.Database.BeginTransactionAsync();
- context.GroupMembers.Remove(membership);
-
- // An offer of access that outlived the membership it was made under would let them back in on accepting it.
- foreach (var invitation in await context.GroupInvitations.Where(i => i.GroupId == groupId && i.InviteeUserId == userId && i.State == GroupInvitationState.Pending).ToListAsync())
- {
- CloseInvitation(invitation, GroupInvitationState.Revoked);
- }
-
- foreach (var manifestId in manifestIds)
- {
- if (await GrantHelper.RevokeAccessAsync(context, manifestId, userId))
- {
- await ClientActionHelper.EnqueueForGroupAsync(context, ClientActionType.RotateManifestDeliveryKey, groupId, manifestId, timeProvider.UtcNow);
- }
- }
-
- await context.SaveChangesAsync();
- await transaction.CommitAsync();
- });
-
- return Ok();
- }
-
/// <summary>
/// The open offers of access to each shared vault, for the admins who may withdraw them.
/// </summary>
diff --git a/apps/server/AliasVault.Api/Helpers/GroupHelper.cs b/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
index fc31c37ac..fdb1c5932 100644
--- a/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
@@ -59,17 +59,6 @@ public static class GroupHelper
return await context.GroupMembers.AnyAsync(m => m.GroupId == groupId && m.UserId == userId && m.Group.Type == GroupType.Shared);
}
- /// <summary>
- /// Get the ids of every shared vault a group holds.
- /// </summary>
- /// <param name="context">Database context.</param>
- /// <param name="groupId">The group.</param>
- /// <returns>The manifest ids owned by the group.</returns>
- public static async Task<List<Guid>> GetManifestIdsOfGroupAsync(AliasServerDbContext context, Guid groupId)
- {
- return await context.VaultManifests.Where(m => m.OwnerGroupId == groupId).Select(m => m.ManifestId).ToListAsync();
- }
-
/// <summary>
/// Check whether the caller may administer a <see cref="GroupType.Shared"/> group.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
index 388d22191..ed433d730 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
@@ -221,9 +221,9 @@ public enum ApiErrorCode
ACCESS_ALREADY_GRANTED,
/// <summary>
- /// The group's owner cannot be removed from it; ownership has to be transferred first.
+ /// An admin of the group cannot take away their own access to a shared manifest.
/// </summary>
- CANNOT_REMOVE_GROUP_OWNER,
+ CANNOT_REVOKE_OWN_ACCESS,
/// <summary>
/// The member is the last one who can open one of the group's shared vaults, so taking their access away would