Skip to content

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

Refactor groups so it supports multiple shared manifests (#2159)

Leendert de Borst17faa8b5a24a
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.ts
index 695eff7d0..ff4224b65 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, 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, handleGroupGrantAccess, handleGroupRevokeAccess, handleGroupRemoveMember, 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";
@@ -272,7 +272,8 @@ export default defineBackground({
onMessage('GET_VAULT_MIGRATION_STATUS', () => handleGetVaultMigrationStatus());
onMessage('MIGRATE_VAULT_MANIFEST', () => handleMigrateVaultManifest());
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_GRANT_ACCESS', ({ data, sender }) => isTrustedExtensionSender(sender) ? handleGroupGrantAccess(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());
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index 8eff2ad88..8ffc8ca16 100644
--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -2535,15 +2535,21 @@ export async function handleGetRecentlySelected(
}
/**
- * Create the shared vault of a group the user administers.
- * @param message - the group to create the vault for.
+ * Create another shared vault for a family, with this account as its first member.
+ *
+ * @param message - the family to create the vault for and the name to give it.
*/
-export async function handleGroupCreateVault(message: { groupId: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
+export async function handleGroupCreateVault(message: { groupId: string; name: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
const encryptionKey = await handleGetEncryptionKey();
if (!encryptionKey) {
return { success: false, error: formatErrorWithCode(await t('common.errors.vaultIsLocked'), AppErrorCode.VAULT_LOCKED) };
}
+ const name = message.name.trim();
+ if (name.length === 0) {
+ return { success: false, error: await t('sharing.family.errors.createVaultFailed') };
+ }
+
try {
const webApi = new WebApiService();
const overview = await SharingService.getOverview(webApi);
@@ -2560,20 +2566,14 @@ export async function handleGroupCreateVault(message: { groupId: string }): Prom
return { success: false, error: await t('sharing.family.errors.vaultUpgradeRequired') };
}
- if (group.manifestId) {
- // Already has a vault.
- devLog(`[Sharing] Group ${group.groupId} already has vault ${group.manifestId}; nothing to create.`);
- return { success: true };
- }
-
const sqliteClient = await createVaultSqliteClient();
if (await vaultRequiresManifestMigration(sqliteClient)) {
return { success: false, error: await t('sharing.family.errors.vaultUpgradeRequired') };
}
+ // The name stays on this device: it rides into the vault below, never into the create request.
const mapping = await SharingService.createSharedManifest(webApi, {
groupId: group.groupId,
- name: group.name,
selfPublicKey,
}, crypto.randomUUID().toUpperCase());
@@ -2583,25 +2583,20 @@ export async function handleGroupCreateVault(message: { groupId: string }): Prom
encryptionPublicKey: mapping.encryptionPublicKey,
algorithm: mapping.algorithm,
salt: mapping.salt,
- name: group.name,
+ name,
canAdminister: true,
});
await recordManifestRevisions({ [mapping.manifestId]: mapping.revision });
- await createAnchorFolder(sqliteClient, mapping.manifestId, group.name);
+ await createAnchorFolder(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);
await persistLocalVaultMutation(sqliteClient, encryptionKey);
- devLog(`[Sharing] Created shared vault ${mapping.manifestId} for group ${group.groupId}.`);
+ devLog(`[Sharing] Created shared vault ${mapping.manifestId} ("${name}") for group ${group.groupId}.`);
return { success: true };
} catch (error) {
- if (error instanceof ApiRequestError && error.apiErrorCode === 'GROUP_MANIFEST_EXISTS') {
- // Two administrators asked at the same moment; the other one's vault stands and arrives through its grant.
- return { success: true };
- }
-
console.error('Failed to create shared vault:', error);
if (error instanceof ApiRequestError && error.apiErrorCode) {
return { success: false, apiErrorCode: error.apiErrorCode };
@@ -2618,10 +2613,12 @@ export async function handleGroupCreateVault(message: { groupId: string }): Prom
}
/**
- * Invite somebody to a shared group, handing them the group's vault key.
- * @param message - the group to invite into and the username to invite.
+ * Give a member of a family access to one of its shared vaults, handing them the vault's key sealed for them.
+ *
+ * The recipient is picked off the family's own roster, so this never names an account outside the family.
+ * @param message - the family, the vault, and the member being let in.
*/
-export async function handleGroupInviteMember(message: { groupId: string; username: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
+export async function handleGroupGrantAccess(message: { groupId: string; manifestId: string; userId: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
const encryptionKey = await handleGetEncryptionKey();
if (!encryptionKey) {
return { success: false, error: formatErrorWithCode(await t('common.errors.vaultIsLocked'), AppErrorCode.VAULT_LOCKED) };
@@ -2631,13 +2628,19 @@ export async function handleGroupInviteMember(message: { groupId: string; userna
const webApi = new WebApiService();
const overview = await SharingService.getOverview(webApi);
const group = overview.groups.find(candidate => candidate.groupId.toLowerCase() === message.groupId.toLowerCase());
+ const manifest = group?.manifests.find(candidate => candidate.manifestId.toLowerCase() === message.manifestId.toLowerCase());
+ const member = group?.members.find(candidate => candidate.userId === message.userId);
- if (!group || group.role === 'Member' || !group.manifestId) {
+ if (!group || group.role === 'Member' || !manifest || !member) {
return { success: false, error: await t('sharing.family.errors.inviteFailed') };
}
- // Find the session's own grant on the vault.
- const record = Object.values(await SharingService.getSessionSharedManifests()).find(candidate => candidate.manifestId.toLowerCase() === group.manifestId!.toLowerCase());
+ if (!member.publicKey) {
+ return { success: false, apiErrorCode: 'INVITE_RECIPIENT_NOT_READY' };
+ }
+
+ // Find the session's own grant on the vault: a key that was never handed to this account cannot be passed on.
+ const record = Object.values(await SharingService.getSessionSharedManifests()).find(candidate => candidate.manifestId.toLowerCase() === manifest.manifestId.toLowerCase());
if (!record) {
return { success: false, error: await t('sharing.family.errors.inviteFailed') };
}
@@ -2647,28 +2650,55 @@ export async function handleGroupInviteMember(message: { groupId: string; userna
return { success: false, error: await t('sharing.family.errors.inviteFailed') };
}
- const recipient = await SharingService.resolveInvitationRecipient(webApi, group.groupId, message.username);
- const grant = await SharingService.encryptVekFor(manifestVek, recipient);
- await SharingService.invite(webApi, group.groupId, recipient.userId, grant, VaultKeyAlgorithm.RsaOaepSha256);
+ const grant = await SharingService.encryptVekFor(manifestVek, member);
+ if (!grant) {
+ return { success: false, apiErrorCode: 'INVITE_RECIPIENT_NOT_READY' };
+ }
+
+ await SharingService.grantAccess(webApi, group.groupId, manifest.manifestId, member.userId, grant, VaultKeyAlgorithm.RsaOaepSha256);
- devLog(`[Sharing] Invited ${recipient.userId} to group ${group.groupId} with the key to vault ${record.manifestId} encrypted for them.`);
+ devLog(`[Sharing] Offered ${member.userId} access to vault ${manifest.manifestId} with its key encrypted for them.`);
return { success: true };
} catch (error) {
if (error instanceof ApiRequestError && error.apiErrorCode) {
return { success: false, apiErrorCode: error.apiErrorCode };
}
- console.error('Failed to invite group member:', error);
+ console.error('Failed to grant shared vault access:', error);
return { success: false, error: await t('sharing.family.errors.inviteFailed') };
}
}
/**
- * Remove somebody from a shared group, or leave one by naming oneself.
+ * Take a member's access to one shared vault away, or give up one's own.
+ *
+ * @param message - the family, the vault, and the member losing access.
+ */
+export async function handleGroupRevokeAccess(message: { groupId: string; manifestId: string; userId: string }): Promise<{ success: boolean; error?: string; apiErrorCode?: string }> {
+ try {
+ const webApi = new WebApiService();
+ await SharingService.revokeAccess(webApi, message.groupId, message.manifestId, message.userId);
+
+ devLog(`[Sharing] Revoked ${message.userId}'s access to vault ${message.manifestId}; syncing to pick up whatever the server left for this client to finish.`);
+ void handleFullVaultSync().catch(error => console.error('Background sync after a vault access change failed:', error));
+
+ return { success: true };
+ } catch (error) {
+ if (error instanceof ApiRequestError && error.apiErrorCode) {
+ return { success: false, apiErrorCode: error.apiErrorCode };
+ }
+
+ 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 }> {
+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);
@@ -2678,6 +2708,10 @@ export async function handleGroupRemoveMember(message: { groupId: string; userId
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') };
}
diff --git a/apps/browser-extension/src/utils/SharingService.ts b/apps/browser-extension/src/utils/SharingService.ts
index 3bb3ba41f..755bdbbbb 100644
--- a/apps/browser-extension/src/utils/SharingService.ts
+++ b/apps/browser-extension/src/utils/SharingService.ts
@@ -2,7 +2,7 @@ import { storage } from 'wxt/utils/storage';
import { StorageKeys } from '@/utils/constants/storageKeys';
import { devWarn } from '@/utils/devLogger/DevLogger';
-import { VaultKeyAlgorithm, type CreateGroupInvitationRequest, type CreateGroupInvitationResponse, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type GrantRecipient, type GroupInvitationRecipientRequest, type GroupInvitationRecipientResponse, type GroupOverviewResponse, type ManifestGrant, type VaultKeyAlgorithmValue } from '@/utils/dist/core/models/webapi';
+import { VaultKeyAlgorithm, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type GrantManifestAccessRequest, type GrantManifestAccessResponse, type GroupMemberInfo, type GroupOverviewResponse, type ManifestGrant, type VaultKeyAlgorithmValue } from '@/utils/dist/core/models/webapi';
import { EncryptionUtility } from '@/utils/EncryptionUtility';
import { vaultCodecGenerateManifestSalt } from '@/utils/RustCore';
import type { SqliteClient } from '@/utils/SqliteClient';
@@ -15,13 +15,12 @@ import type { WebApiService } from '@/utils/WebApiService';
*/
/**
- * The group a new shared vault is being created for, with the creator's own public key: the VEK is encrypted for it and
- * for nothing else, because a vault is created before its group has a second member and everyone who joins afterwards
- * gets the key encrypted for them inside their invitation.
+ * A shared vault about to be created, with the creator's own public key: the VEK is encrypted for it and for nothing
+ * else, because a new vault starts out with one member and everybody who is let in afterwards gets the key encrypted
+ * for them inside the offer of access that lets them in.
*/
export type ShareTarget = {
groupId: string;
- name: string;
selfPublicKey: string;
};
@@ -45,16 +44,22 @@ export type SharedManifestMapping = ManifestVekGrant & { manifestId: string; sal
export type SessionSharedManifest = ManifestVekGrant & {
manifestId: string;
salt: string;
+ /** Read out of the encrypted manifest on pull; null until its first revision has been pushed. */
name?: string | null;
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.
*/
export class SharingService {
/**
- * The groups this user is in and the invitations awaiting their answer.
+ * The families this user belongs to, their shared vaults, and the offers of access awaiting an answer.
* @param webApi - API client to reuse.
*/
public static async getOverview(webApi: WebApiService): Promise<GroupOverviewResponse> {
@@ -71,9 +76,8 @@ export class SharingService {
const manifestVek = EncryptionUtility.generateVaultEncryptionKey();
const selfEncryptedVek = await EncryptionUtility.encryptWithPublicKey(manifestVek, group.selfPublicKey);
- const response = await webApi.post<CreateSharedManifestRequest, CreateSharedManifestResponse>(`Groups/${group.groupId}/manifest`, {
+ const response = await webApi.post<CreateSharedManifestRequest, CreateSharedManifestResponse>(`Groups/${group.groupId}/manifests`, {
manifestId,
- name: group.name,
selfEncryptedVek,
selfPublicKey: group.selfPublicKey,
algorithm: VaultKeyAlgorithm.RsaOaepSha256,
@@ -90,44 +94,48 @@ export class SharingService {
}
/**
- * Resolve the account behind a username together with the public key an invitation to it has to be encrypted for.
- * @param webApi - API client to reuse.
- * @param groupId - the group to invite into.
- * @param username - the account to look up.
+ * Encrypt a shared vault's VEK for one member of the group, with a public key of theirs.
+ * @param manifestVek - the shared vault's VEK.
+ * @param member - the member to encrypt it for.
*/
- public static async resolveInvitationRecipient(webApi: WebApiService, groupId: string, username: string): Promise<GrantRecipient> {
- const response = await webApi.post<GroupInvitationRecipientRequest, GroupInvitationRecipientResponse>(`Groups/${groupId}/invitations/recipient`, { username });
- return response.recipient;
- }
+ public static async encryptVekFor(manifestVek: string, member: GroupMemberInfo): Promise<ManifestGrant | null> {
+ if (!member.publicKey || !member.publicKeyId) {
+ return null;
+ }
- /**
- * Encrypt a shared manifest's VEK for one recipient, with that recipient's own public key, ready to travel inside
- * the invitation that offers them the vault.
- * @param manifestVek - the shared manifest's VEK.
- * @param recipient - who to encrypt it for.
- */
- public static async encryptVekFor(manifestVek: string, recipient: GrantRecipient): Promise<ManifestGrant> {
return {
- recipientUserId: recipient.userId,
- recipientPublicKeyId: recipient.publicKeyId,
- encryptedVek: await EncryptionUtility.encryptWithPublicKey(manifestVek, recipient.publicKey),
+ recipientUserId: member.userId,
+ recipientPublicKeyId: member.publicKeyId,
+ encryptedVek: await EncryptionUtility.encryptWithPublicKey(manifestVek, member.publicKey),
};
}
/**
- * Invite an account to a group.
+ * Offer a member of the group access to one of its shared vaults.
* @param webApi - API client to reuse.
- * @param groupId - the group to invite into.
- * @param userId - the account being invited, as resolved by {@link resolveInvitationRecipient}.
- * @param grant - the group's vault key, encrypted for that account's public key, as produced by {@link encryptVekFor}.
+ * @param groupId - the group the vault belongs to.
+ * @param manifestId - the shared vault to hand access to.
+ * @param userId - the member being let in.
+ * @param grant - the vault's key, encrypted for that member, as produced by {@link encryptVekFor}.
* @param algorithm - the algorithm the grant was encrypted with.
*/
- public static async invite(webApi: WebApiService, groupId: string, userId: string, grant: ManifestGrant, algorithm: VaultKeyAlgorithmValue): Promise<void> {
- await webApi.post<CreateGroupInvitationRequest, CreateGroupInvitationResponse>(`Groups/${groupId}/invitations`, { userId, grant, algorithm });
+ public static async grantAccess(webApi: WebApiService, groupId: string, manifestId: string, userId: string, grant: ManifestGrant, algorithm: VaultKeyAlgorithmValue): Promise<void> {
+ await webApi.post<GrantManifestAccessRequest, GrantManifestAccessResponse>(`Groups/${groupId}/manifests/${manifestId}/access`, { userId, grant, algorithm });
+ }
+
+ /**
+ * Take a member's access to one shared vault away, or give up one's own.
+ * @param webApi - API client to reuse.
+ * @param groupId - the group the vault belongs to.
+ * @param manifestId - the shared vault.
+ * @param userId - the member losing access.
+ */
+ public static async revokeAccess(webApi: WebApiService, groupId: string, manifestId: string, userId: string): Promise<void> {
+ await webApi.delete<void>(`Groups/${groupId}/manifests/${manifestId}/access/${userId}`);
}
/**
- * Withdraw an invitation this group sent that has not been answered yet.
+ * Withdraw an offer of access this group made that has not been answered yet.
* @param webApi - API client to reuse.
* @param invitationId - the invitation to withdraw.
*/
@@ -136,7 +144,7 @@ export class SharingService {
}
/**
- * Accept an invitation addressed to this user, joining the group.
+ * Accept an offer of access addressed to this user, opening the shared vault it names.
* @param webApi - API client to reuse.
* @param invitationId - the invitation to accept.
*/
@@ -145,7 +153,7 @@ export class SharingService {
}
/**
- * Decline an invitation addressed to this user.
+ * Decline an offer of access addressed to this user.
* @param webApi - API client to reuse.
* @param invitationId - the invitation to decline.
*/
@@ -182,7 +190,7 @@ export class SharingService {
continue;
}
- await createAnchorFolder(sqliteClient, record.manifestId, record.name ?? 'Shared');
+ 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;
}
@@ -296,7 +304,7 @@ export class SharingService {
* 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 group name, used as the folder name.
+ * @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();
diff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.ts
index 3a56d0ea8..128a8ec14 100644
--- a/apps/browser-extension/src/utils/VaultSyncService.ts
+++ b/apps/browser-extension/src/utils/VaultSyncService.ts
@@ -166,8 +166,6 @@ type ManifestDto = {
ciphertextHash?: string | null;
revision: number;
blobReferences?: BlobRefDto[];
- /** Plaintext display name of a shared manifest (null for the personal manifest). */
- name?: string | null;
/** Whether the caller may grant/revoke access to this manifest and publish its email delivery key. */
canAdminister?: boolean;
/** How the caller's access to this manifest's VEK is encrypted. */
@@ -272,7 +270,7 @@ type ManifestRecord = {
salt: string;
/** The key this manifest encrypts with; null for the personal manifest, whose content key the push supplies (it can be freshly minted). */
vek: string | null;
- /** Plaintext display name; null for the personal manifest. */
+ /** Display name, as read from (and written back into) the encrypted manifest; null for the personal manifest. */
name: string | null;
/** Whether the caller may publish this manifest's email delivery key. */
canAdminister: boolean;
@@ -434,7 +432,7 @@ export class VaultSyncService {
manifestId: dto.manifestId,
...contentlessGrant,
salt: await vaultCodecGenerateManifestSalt(),
- name: dto.name ?? null,
+ name: null,
canAdminister: dto.canAdminister ?? false,
};
contentlessRevisions[dto.manifestId] = dto.revision;
@@ -455,7 +453,7 @@ export class VaultSyncService {
}
resolved.push(entry);
- devLog(`[V2Pull] Manifest ${entry.manifestId} opened (content hash verified, ${isPersonal ? 'personal' : `shared "${entry.manifest.name ?? dto.name ?? 'unnamed'}"`}): tables: ${Object.entries(entry.manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`);
+ devLog(`[V2Pull] Manifest ${entry.manifestId} opened (content hash verified, ${isPersonal ? 'personal' : `shared "${entry.manifest.name ?? 'unnamed'}"`}): tables: ${Object.entries(entry.manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`);
if (isPersonal) {
/*
@@ -478,7 +476,7 @@ export class VaultSyncService {
manifestId: entry.manifestId,
...grant,
salt: entry.manifest.manifestSalt,
- name: entry.manifest.name ?? dto.name ?? null,
+ name: entry.manifest.name ?? null,
canAdminister: dto.canAdminister ?? false,
};
}
diff --git a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
index 1d21b6927..a15ffdc95 100644
--- a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
@@ -525,7 +525,7 @@ declare const VaultKeyAlgorithm: {
type VaultKeyAlgorithmValue = typeof VaultKeyAlgorithm[keyof typeof VaultKeyAlgorithm];
/**
- * The messages of the /v2/Groups API: the membership half of vault sharing.
+ * The messages of the /v2/Groups API: the sharing half of vault sharing.
*/
/**
* A member's role in a group.
@@ -538,25 +538,37 @@ type GroupMemberInfo = {
userId: string;
username: string;
role: GroupRole;
+ publicKeyId: string | null;
+ publicKey: string | null;
};
/**
- * An invitation sent from a group that is still awaiting an answer.
+ * An offer of access to a shared vault that is still awaiting the recipient's answer.
*/
-type SentGroupInvitation = {
+type SentManifestInvitation = {
id: string;
+ inviteeUserId: string;
inviteeUsername: string;
createdAt: string;
};
/**
- * An open invitation addressed to this user.
+ * An open offer of access to a shared vault, addressed to this user.
*/
-type ReceivedGroupInvitation = {
+type ReceivedManifestInvitation = {
id: string;
groupId: string;
groupName: string;
+ manifestId: string;
inviterUsername: string;
createdAt: string;
};
+/**
+ * One shared vault owned by a group, with the members who can open it.
+ */
+type SharedManifestInfo = {
+ manifestId: string;
+ memberUserIds: string[];
+ pendingInvitations: SentManifestInvitation[];
+};
/**
* One shared group this user belongs to.
*/
@@ -564,56 +576,34 @@ type GroupInfo = {
groupId: string;
name: string;
role: GroupRole;
- manifestId: string | null;
+ manifests: SharedManifestInfo[];
members: GroupMemberInfo[];
- pendingInvitations: SentGroupInvitation[];
};
/**
* Everything the sharing screen renders, as served by GET /v2/Groups.
*/
type GroupOverviewResponse = {
groups: GroupInfo[];
- receivedInvitations: ReceivedGroupInvitation[];
+ receivedInvitations: ReceivedManifestInvitation[];
};
/**
- * Create a shared group's vault.
+ * Create another shared vault for a group.
*/
type CreateSharedManifestRequest = {
manifestId: string;
- name: string;
selfEncryptedVek: string;
selfPublicKey: string;
algorithm: VaultKeyAlgorithmValue;
};
/**
- * The created manifest, as served by POST /v2/Groups/{groupId}/manifest.
+ * The created vault, as served by POST /v2/Groups/{groupId}/manifests.
*/
type CreateSharedManifestResponse = {
manifestId: string;
revisionNumber: number;
};
/**
- * Ask which account a username belongs to, and which public key an invitation to it must be encrypted for.
- */
-type GroupInvitationRecipientRequest = {
- username: string;
-};
-/**
- * A user a manifest VEK can be encrypted for, with the public key to encrypt it with.
- */
-type GrantRecipient = {
- userId: string;
- publicKeyId: string;
- publicKey: string;
-};
-/**
- * The resolved recipient, as served by POST /v2/Groups/{groupId}/invitations/recipient.
- */
-type GroupInvitationRecipientResponse = {
- recipient: GrantRecipient;
-};
-/**
- * One recipient's copy of a manifest VEK, encrypted for a public key of theirs.
+ * One recipient's copy of a shared vault's VEK, encrypted for a public key of theirs.
*/
type ManifestGrant = {
recipientUserId: string;
@@ -621,27 +611,23 @@ type ManifestGrant = {
encryptedVek: string;
};
/**
- * Invite an account to a group.
+ * Give a member of the group access to one of its shared vaults.
*/
-type CreateGroupInvitationRequest = {
+type GrantManifestAccessRequest = {
userId: string;
grant: ManifestGrant;
algorithm: VaultKeyAlgorithmValue;
};
/**
- * The sent invitation, as served by POST /v2/Groups/{groupId}/invitations.
+ * The created offer, as served by POST /v2/Groups/{groupId}/manifests/{manifestId}/access.
*/
-type CreateGroupInvitationResponse = {
+type GrantManifestAccessResponse = {
invitationId: string;
};
/**
* The capability keys the server resolves and hands to clients on the status response.
*
- * A key travels between the server and every client and is stored in rule rows, so renaming one means a
- * coordinated release across the API, the extension, the mobile app and the web client: name the capability,
- * never the screen or the marketing name it currently ships under.
- *
* Mirrored on the server side in AliasVault.Shared.Server/Capabilities/CapabilityKeys.cs.
*/
declare const CapabilityKeys: {
@@ -662,4 +648,4 @@ type CapabilityKey = typeof CapabilityKeys[keyof typeof CapabilityKeys];
*/
declare function isCapabilityEnabled(value: string | undefined): boolean;
-export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type CapabilityKey, CapabilityKeys, type CreateGroupInvitationRequest, type CreateGroupInvitationResponse, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type EmailDecryptionKey, type FaviconExtractModel, type GrantRecipient, type GroupInfo, type GroupInvitationRecipientRequest, type GroupInvitationRecipientResponse, type GroupMemberInfo, type GroupOverviewResponse, type GroupRole, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestGrant, ManifestKeyType, type ManifestKeyTypeValue, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type ReceivedGroupInvitation, type RefreshToken, type SentGroupInvitation, type StatusResponse, type StatusResponseV2, type TokenModel, UnlockMethodType, type UnlockMethodTypeValue, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, VaultKeyAlgorithm, type VaultKeyAlgorithmValue, type VaultKeyGetResponse, type VaultKeyResponse, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse, isCapabilityEnabled };
+export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type CapabilityKey, CapabilityKeys, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type EmailDecryptionKey, type FaviconExtractModel, type GrantManifestAccessRequest, type GrantManifestAccessResponse, type GroupInfo, type GroupMemberInfo, type GroupOverviewResponse, type GroupRole, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestGrant, ManifestKeyType, type ManifestKeyTypeValue, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type ReceivedManifestInvitation, type RefreshToken, type SentManifestInvitation, type SharedManifestInfo, type StatusResponse, type StatusResponseV2, type TokenModel, UnlockMethodType, type UnlockMethodTypeValue, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, VaultKeyAlgorithm, type VaultKeyAlgorithmValue, type VaultKeyGetResponse, type VaultKeyResponse, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse, isCapabilityEnabled };
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index 0a2609289..97e134787 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -89,9 +89,10 @@ export interface IExtensionMessageProtocol {
GET_VAULT(): VaultResponse;
GET_VAULT_MIGRATION_STATUS(): VaultMigrationStatus;
GET_WEBAUTHN_SETTINGS(data: any): WebAuthnSettingsResponse;
- GROUP_CREATE_VAULT(data: { groupId: string }): { success: boolean; error?: string; apiErrorCode?: string };
- GROUP_INVITE_MEMBER(data: { groupId: string; username: string }): { success: boolean; error?: string; apiErrorCode?: string };
- GROUP_REMOVE_MEMBER(data: { groupId: string; userId: string }): { success: boolean; error?: string };
+ GROUP_CREATE_VAULT(data: { groupId: string; name: string }): { success: boolean; error?: string; apiErrorCode?: string };
+ GROUP_GRANT_ACCESS(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/mobile-app/utils/dist/core/models/webapi/index.d.ts b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
index 1d21b6927..a15ffdc95 100644
--- a/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
@@ -525,7 +525,7 @@ declare const VaultKeyAlgorithm: {
type VaultKeyAlgorithmValue = typeof VaultKeyAlgorithm[keyof typeof VaultKeyAlgorithm];
/**
- * The messages of the /v2/Groups API: the membership half of vault sharing.
+ * The messages of the /v2/Groups API: the sharing half of vault sharing.
*/
/**
* A member's role in a group.
@@ -538,25 +538,37 @@ type GroupMemberInfo = {
userId: string;
username: string;
role: GroupRole;
+ publicKeyId: string | null;
+ publicKey: string | null;
};
/**
- * An invitation sent from a group that is still awaiting an answer.
+ * An offer of access to a shared vault that is still awaiting the recipient's answer.
*/
-type SentGroupInvitation = {
+type SentManifestInvitation = {
id: string;
+ inviteeUserId: string;
inviteeUsername: string;
createdAt: string;
};
/**
- * An open invitation addressed to this user.
+ * An open offer of access to a shared vault, addressed to this user.
*/
-type ReceivedGroupInvitation = {
+type ReceivedManifestInvitation = {
id: string;
groupId: string;
groupName: string;
+ manifestId: string;
inviterUsername: string;
createdAt: string;
};
+/**
+ * One shared vault owned by a group, with the members who can open it.
+ */
+type SharedManifestInfo = {
+ manifestId: string;
+ memberUserIds: string[];
+ pendingInvitations: SentManifestInvitation[];
+};
/**
* One shared group this user belongs to.
*/
@@ -564,56 +576,34 @@ type GroupInfo = {
groupId: string;
name: string;
role: GroupRole;
- manifestId: string | null;
+ manifests: SharedManifestInfo[];
members: GroupMemberInfo[];
- pendingInvitations: SentGroupInvitation[];
};
/**
* Everything the sharing screen renders, as served by GET /v2/Groups.
*/
type GroupOverviewResponse = {
groups: GroupInfo[];
- receivedInvitations: ReceivedGroupInvitation[];
+ receivedInvitations: ReceivedManifestInvitation[];
};
/**
- * Create a shared group's vault.
+ * Create another shared vault for a group.
*/
type CreateSharedManifestRequest = {
manifestId: string;
- name: string;
selfEncryptedVek: string;
selfPublicKey: string;
algorithm: VaultKeyAlgorithmValue;
};
/**
- * The created manifest, as served by POST /v2/Groups/{groupId}/manifest.
+ * The created vault, as served by POST /v2/Groups/{groupId}/manifests.
*/
type CreateSharedManifestResponse = {
manifestId: string;
revisionNumber: number;
};
/**
- * Ask which account a username belongs to, and which public key an invitation to it must be encrypted for.
- */
-type GroupInvitationRecipientRequest = {
- username: string;
-};
-/**
- * A user a manifest VEK can be encrypted for, with the public key to encrypt it with.
- */
-type GrantRecipient = {
- userId: string;
- publicKeyId: string;
- publicKey: string;
-};
-/**
- * The resolved recipient, as served by POST /v2/Groups/{groupId}/invitations/recipient.
- */
-type GroupInvitationRecipientResponse = {
- recipient: GrantRecipient;
-};
-/**
- * One recipient's copy of a manifest VEK, encrypted for a public key of theirs.
+ * One recipient's copy of a shared vault's VEK, encrypted for a public key of theirs.
*/
type ManifestGrant = {
recipientUserId: string;
@@ -621,27 +611,23 @@ type ManifestGrant = {
encryptedVek: string;
};
/**
- * Invite an account to a group.
+ * Give a member of the group access to one of its shared vaults.
*/
-type CreateGroupInvitationRequest = {
+type GrantManifestAccessRequest = {
userId: string;
grant: ManifestGrant;
algorithm: VaultKeyAlgorithmValue;
};
/**
- * The sent invitation, as served by POST /v2/Groups/{groupId}/invitations.
+ * The created offer, as served by POST /v2/Groups/{groupId}/manifests/{manifestId}/access.
*/
-type CreateGroupInvitationResponse = {
+type GrantManifestAccessResponse = {
invitationId: string;
};
/**
* The capability keys the server resolves and hands to clients on the status response.
*
- * A key travels between the server and every client and is stored in rule rows, so renaming one means a
- * coordinated release across the API, the extension, the mobile app and the web client: name the capability,
- * never the screen or the marketing name it currently ships under.
- *
* Mirrored on the server side in AliasVault.Shared.Server/Capabilities/CapabilityKeys.cs.
*/
declare const CapabilityKeys: {
@@ -662,4 +648,4 @@ type CapabilityKey = typeof CapabilityKeys[keyof typeof CapabilityKeys];
*/
declare function isCapabilityEnabled(value: string | undefined): boolean;
-export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type CapabilityKey, CapabilityKeys, type CreateGroupInvitationRequest, type CreateGroupInvitationResponse, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type EmailDecryptionKey, type FaviconExtractModel, type GrantRecipient, type GroupInfo, type GroupInvitationRecipientRequest, type GroupInvitationRecipientResponse, type GroupMemberInfo, type GroupOverviewResponse, type GroupRole, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestGrant, ManifestKeyType, type ManifestKeyTypeValue, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type ReceivedGroupInvitation, type RefreshToken, type SentGroupInvitation, type StatusResponse, type StatusResponseV2, type TokenModel, UnlockMethodType, type UnlockMethodTypeValue, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, VaultKeyAlgorithm, type VaultKeyAlgorithmValue, type VaultKeyGetResponse, type VaultKeyResponse, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse, isCapabilityEnabled };
+export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type CapabilityKey, CapabilityKeys, type CreateSharedManifestRequest, type CreateSharedManifestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type EmailDecryptionKey, type FaviconExtractModel, type GrantManifestAccessRequest, type GrantManifestAccessResponse, type GroupInfo, type GroupMemberInfo, type GroupOverviewResponse, type GroupRole, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestGrant, ManifestKeyType, type ManifestKeyTypeValue, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type ReceivedManifestInvitation, type RefreshToken, type SentManifestInvitation, type SharedManifestInfo, type StatusResponse, type StatusResponseV2, type TokenModel, UnlockMethodType, type UnlockMethodTypeValue, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, VaultKeyAlgorithm, type VaultKeyAlgorithmValue, type VaultKeyGetResponse, type VaultKeyResponse, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse, isCapabilityEnabled };
diff --git a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
index d0bc23cb6..10ace9cf8 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
@@ -22,13 +22,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
/// <summary>
-/// Groups controller which manages shared groups and their related manifests.
+/// Groups controller which manages the shared vaults of a group and who inside the group can open them.
/// </summary>
-/// <remarks>
-/// Note: the vault sharing capability gate sits on the endpoints that create or modify a shared vault or a membership,
-/// and deliberately not on the ones that read or leave one: an account that loses the capability keeps full access to
-/// what it already shares, and can still get out of it. TODO: review all capability gain vs loss states when this is gated behind account tiers.
-/// </remarks>
/// <param name="dbContextFactory">The database context factory.</param>
/// <param name="userManager">The user manager.</param>
/// <param name="timeProvider">Time provider.</param>
@@ -38,7 +33,12 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
private const string ManifestFormat = "manifest-v1";
/// <summary>
- /// Get the overview of the caller's shared groups and invitations.
+ /// How many shared vaults one group may hold. TODO: hardcoded for now; make this dynamic when needed.
+ /// </summary>
+ private const int MaxSharedVaults = 3;
+
+ /// <summary>
+ /// Get the overview of the caller's shared groups and the access offers awaiting their answer.
/// </summary>
/// <returns>The overview.</returns>
[HttpGet]
@@ -67,62 +67,70 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
var groupIds = memberships.ConvertAll(m => m.GroupId);
- var administeredGroupIds = memberships.Where(m => m.Role is GroupRole.Owner or GroupRole.Admin).Select(m => m.GroupId).ToList();
+ var administeredGroupIds = memberships.Where(m => m.Role is GroupRole.Owner or GroupRole.Admin).Select(m => m.GroupId).ToHashSet();
var allMembers = await context.GroupMembers
.Where(gm => groupIds.Contains(gm.GroupId))
.Select(gm => new { gm.GroupId, gm.UserId, gm.Role })
.ToListAsync();
- var manifestByGroup = await context.VaultManifests
+ var manifests = await context.VaultManifests
.Where(m => groupIds.Contains(m.OwnerGroupId))
- .ToDictionaryAsync(m => m.OwnerGroupId, m => m.ManifestId);
- var grantHolders = await GrantHelper.GetGrantHoldersByManifestAsync(context, [.. manifestByGroup.Values]);
+ .Select(m => new { m.ManifestId, m.OwnerGroupId, m.CreatedAt })
+ .ToListAsync();
+ var grantHolders = await GrantHelper.GetGrantHoldersByManifestAsync(context, manifests.ConvertAll(m => m.ManifestId));
var allMemberIds = allMembers.Select(m => m.UserId).Distinct(StringComparer.Ordinal).ToList();
var usernames = await context.AliasVaultUsers
.Where(u => allMemberIds.Contains(u.Id))
.ToDictionaryAsync(u => u.Id, u => u.UserName ?? string.Empty);
- // Open invitations are only shown to admins.
- var openInvitations = administeredGroupIds.Count > 0 ? await GetOpenInvitationsByGroupAsync(context, administeredGroupIds) : [];
+ // Only an admin can hand a vault key to somebody, so only an admin is served the keys to seal one with.
+ var administeredMemberIds = allMembers.Where(m => administeredGroupIds.Contains(m.GroupId)).Select(m => m.UserId);
+ var publicKeys = administeredGroupIds.Count > 0 ? await GrantHelper.GetPrimaryKeysAsync(context, administeredMemberIds) : [];
+
+ // Open offers are only shown to the admins who may withdraw them.
+ var openInvitations = administeredGroupIds.Count > 0 ? await GetOpenInvitationsByManifestAsync(context, [.. administeredGroupIds]) : [];
foreach (var membership in memberships)
{
- var canAdminister = membership.Role is GroupRole.Owner or GroupRole.Admin;
- var manifestId = manifestByGroup.TryGetValue(membership.GroupId, out var id) ? id : (Guid?)null;
+ var canAdminister = administeredGroupIds.Contains(membership.GroupId);
- var group = new GroupInfo
+ response.Groups.Add(new GroupInfo
{
GroupId = membership.GroupId,
Name = membership.Name,
Role = membership.Role.ToString(),
- ManifestId = manifestId,
+ Manifests = [.. manifests
+ .Where(m => m.OwnerGroupId == membership.GroupId)
+ .Select(m => new { Manifest = m, Holders = grantHolders.GetValueOrDefault(m.ManifestId) ?? [] })
+ .Where(m => canAdminister || m.Holders.Contains(me.Id))
+ .OrderBy(m => m.Manifest.CreatedAt)
+ .Select(m => new SharedManifestInfo
+ {
+ ManifestId = m.Manifest.ManifestId,
+ MemberUserIds = [.. m.Holders],
+ PendingInvitations = canAdminister ? openInvitations.GetValueOrDefault(m.Manifest.ManifestId) ?? [] : [],
+ })],
Members = [.. allMembers.Where(m => m.GroupId == membership.GroupId).Select(m => new GroupMemberInfo
{
UserId = m.UserId,
Username = usernames.GetValueOrDefault(m.UserId, string.Empty),
Role = m.Role.ToString(),
+ PublicKeyId = canAdminister ? publicKeys.GetValueOrDefault(m.UserId)?.PublicKeyId : null,
+ PublicKey = canAdminister ? publicKeys.GetValueOrDefault(m.UserId)?.PublicKey : null,
})],
- };
-
- // Only admins can see the group's open invitations.
- if (canAdminister)
- {
- group.PendingInvitations = openInvitations.TryGetValue(membership.GroupId, out var invitations) ? invitations : [];
- }
-
- response.Groups.Add(group);
+ });
}
return Ok(response);
}
/// <summary>
- /// Create the shared group's vault, together with the caller's own grant on it.
+ /// Create another shared vault for a group, together with the caller's own grant on it.
/// </summary>
/// <param name="groupId">The shared group ID.</param>
/// <param name="model">The create manifest request.</param>
/// <returns>The created manifest id and its revision.</returns>
- [HttpPost("{groupId:guid}/manifest")]
+ [HttpPost("{groupId:guid}/manifests")]
[RequireCapability(CapabilityKeys.VaultSharing)]
public async Task<IActionResult> CreateManifest(Guid groupId, [FromBody] CreateSharedManifestRequest model)
{
@@ -160,10 +168,10 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.RECIPIENT_KEY_NOT_FOUND, 404));
}
- // A group (currently) holds exactly one vault.
- if (await context.VaultManifests.AnyAsync(x => x.OwnerGroupId == groupId))
+ // A family holds a handful of vaults, enough to keep e.g. streaming and banking apart without growing without bound.
+ if (await context.VaultManifests.CountAsync(x => x.OwnerGroupId == groupId) >= MaxSharedVaults)
{
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_MANIFEST_EXISTS, 400));
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_MANIFEST_LIMIT_REACHED, 400));
}
// Create the empty manifest.
@@ -171,7 +179,6 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
{
ManifestId = model.ManifestId,
OwnerGroupId = groupId,
- Name = model.Name,
StorageFormat = ManifestFormat,
RevisionNumber = 0,
FileSize = 0,
@@ -196,14 +203,16 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Resolve the account behind a username, together with the public key an invitation to it must be sealed for.
+ /// Offer a member of the group access to one of its shared vaults, handing over the vault key sealed for them in
+ /// the same call. The offer becomes a grant once they accept it.
/// </summary>
- /// <param name="groupId">The group to invite into.</param>
- /// <param name="model">The username to look up.</param>
- /// <returns>The recipient and the key to seal for.</returns>
- [HttpPost("{groupId:guid}/invitations/recipient")]
+ /// <param name="groupId">The group ID.</param>
+ /// <param name="manifestId">The shared vault to give access to.</param>
+ /// <param name="model">The grant request.</param>
+ /// <returns>The created invitation id.</returns>
+ [HttpPost("{groupId:guid}/manifests/{manifestId:guid}/access")]
[RequireCapability(CapabilityKeys.VaultSharing)]
- public async Task<IActionResult> ResolveInvitationRecipient(Guid groupId, [FromBody] GroupInvitationRecipientRequest model)
+ public async Task<IActionResult> GrantAccess(Guid groupId, Guid manifestId, [FromBody] GrantManifestAccessRequest model)
{
await using var context = await dbContextFactory.CreateDbContextAsync();
var me = await GetCurrentUserAsync();
@@ -212,67 +221,57 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return Unauthorized();
}
- var (invitee, failure) = await ResolveInviteeAsync(context, groupId, me.Id, () => GetUserManager().FindByNameAsync(model.Username.Trim()));
- if (failure is not null)
+ if (!VaultKeyAlgorithms.TryParse(model.Algorithm, out var algorithm) || !VaultKeyAlgorithms.IsAsymmetric(algorithm))
{
- return failure;
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVALID_ALGORITHM, 400));
}
- var recipient = (await GrantHelper.GetPrimaryKeysAsync(context, [invitee!.Id])).GetValueOrDefault(invitee.Id);
- if (recipient is null)
+ if (!await GroupHelper.IsSharedGroupAdminAsync(context, groupId, me.Id))
{
- // The account has never published a keypair (which can happen if user is still on sqlite-blob legacy storage format), return error.
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITE_RECIPIENT_NOT_READY, 400));
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404));
}
- return Ok(new GroupInvitationRecipientResponse { Recipient = recipient });
- }
-
- /// <summary>
- /// Invite an account to join a shared group, handing over the group's vault key sealed for them in the same call.
- /// </summary>
- /// <param name="groupId">The group ID.</param>
- /// <param name="model">The create invitation request.</param>
- /// <returns>The created invitation id.</returns>
- [HttpPost("{groupId:guid}/invitations")]
- [RequireCapability(CapabilityKeys.VaultSharing)]
- public async Task<IActionResult> CreateInvitation(Guid groupId, [FromBody] CreateGroupInvitationRequest model)
- {
- await using var context = await dbContextFactory.CreateDbContextAsync();
- var me = await GetCurrentUserAsync();
- if (me == null)
+ if (!await context.VaultManifests.AnyAsync(m => m.ManifestId == manifestId && m.OwnerGroupId == groupId))
{
- return Unauthorized();
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
}
- if (!VaultKeyAlgorithms.TryParse(model.Algorithm, out var algorithm) || !VaultKeyAlgorithms.IsAsymmetric(algorithm))
+ /*
+ * Handing out a key is only meaningful for somebody who holds it: with several vaults per group, being an
+ * admin of the group no longer implies access to each one of them, and an admin who was left out of a vault
+ * cannot pass on what they cannot open.
+ */
+ if (!await context.VaultManifestAccessKeys.AnyAsync(k => k.VaultManifestId == manifestId && k.UserId == me.Id && k.Type == ManifestKeyType.GrantKey))
{
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVALID_ALGORITHM, 400));
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
}
- var (invitee, failure) = await ResolveInviteeAsync(context, groupId, me.Id, () => GetUserManager().FindByIdAsync(model.UserId));
- if (failure is not null)
+ // Access only ever goes to somebody already on the group's roster, which is administered outside the client.
+ if (!await GroupHelper.IsSharedGroupMemberAsync(context, groupId, model.UserId))
{
- return failure;
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.NOT_GROUP_MEMBER, 400));
}
- // The sealed key and the invitation have to be about the same person.
- if (!string.Equals(model.Grant.RecipientUserId, invitee!.Id, StringComparison.Ordinal))
+ // The sealed key and the offer have to be about the same person.
+ if (!string.Equals(model.Grant.RecipientUserId, model.UserId, StringComparison.Ordinal))
{
return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.RECIPIENT_KEY_NOT_FOUND, 400));
}
// The key it was sealed for must really be theirs.
- if (!await context.UserGrantKeys.AnyAsync(k => k.Id == model.Grant.RecipientPublicKeyId && k.UserId == invitee.Id))
+ if (!await context.UserGrantKeys.AnyAsync(k => k.Id == model.Grant.RecipientPublicKeyId && k.UserId == model.UserId))
{
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.RECIPIENT_KEY_NOT_FOUND, 404));
}
- var manifestId = await context.VaultManifests.Where(m => m.OwnerGroupId == groupId).Select(m => (Guid?)m.ManifestId).FirstOrDefaultAsync();
- if (manifestId is null)
+ if (await context.VaultManifestAccessKeys.AnyAsync(k => k.VaultManifestId == manifestId && k.UserId == model.UserId && k.Type == ManifestKeyType.GrantKey))
{
- // Nothing to seal, so there is nothing an accept could hand over.
- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_HAS_NO_VAULT, 400));
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.ACCESS_ALREADY_GRANTED, 400));
+ }
+
+ if (await context.GroupInvitations.AnyAsync(i => i.VaultManifestId == manifestId && i.InviteeUserId == model.UserId && i.State == GroupInvitationState.Pending))
+ {
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_ALREADY_EXISTS, 400));
}
var invitation = new GroupInvitation
@@ -280,7 +279,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
Id = Guid.NewGuid(),
GroupId = groupId,
InviterUserId = me.Id,
- InviteeUserId = invitee.Id,
+ InviteeUserId = model.UserId,
Role = GroupRole.Member,
State = GroupInvitationState.Pending,
VaultManifestId = manifestId,
@@ -301,11 +300,62 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_ALREADY_EXISTS, 400));
}
- return Ok(new CreateGroupInvitationResponse { InvitationId = invitation.Id });
+ return Ok(new GrantManifestAccessResponse { InvitationId = invitation.Id });
+ }
+
+ /// <summary>
+ /// Take a member's access to one shared vault away, without touching their membership of the group.
+ /// </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>
+ /// <returns>Ok on success.</returns>
+ [HttpDelete("{groupId:guid}/manifests/{manifestId:guid}/access/{userId}")]
+ public async Task<IActionResult> RevokeAccess(Guid groupId, Guid manifestId, string userId)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var isSelf = string.Equals(userId, me.Id, StringComparison.Ordinal);
+ if (!isSelf && !await GroupHelper.IsSharedGroupAdminAsync(context, groupId, me.Id))
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404));
+ }
+
+ if (!await context.VaultManifests.AnyAsync(m => m.ManifestId == manifestId && m.OwnerGroupId == groupId))
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
+ }
+
+ if (!isSelf && await GrantHelper.IsLastGrantHolderAsync(context, manifestId, userId))
+ {
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.LAST_MANIFEST_GRANT_HOLDER, 400));
+ }
+
+ await using var transaction = await context.Database.BeginTransactionAsync();
+
+ foreach (var invitation in await context.GroupInvitations.Where(i => i.VaultManifestId == manifestId && i.InviteeUserId == userId && i.State == GroupInvitationState.Pending).ToListAsync())
+ {
+ CloseInvitation(invitation, GroupInvitationState.Revoked);
+ }
+
+ 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>
- /// Accept an invitation addressed to the current user.
+ /// Accept an offer of access addressed to the current user.
/// </summary>
/// <param name="invitationId">The invitation ID.</param>
/// <returns>Ok on success.</returns>
@@ -326,6 +376,13 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_NOT_FOUND, 404));
}
+ // Accepting no longer joins anything: the roster decided that, and a member who was taken off it in the
+ // meantime has nothing left to accept.
+ if (!await GroupHelper.IsSharedGroupMemberAsync(context, invitation.GroupId, me.Id))
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_NOT_FOUND, 404));
+ }
+
if (!await PromoteSealedGrantAsync(context, invitation, me.Id))
{
return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_NOT_FOUND, 404));
@@ -335,20 +392,6 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
invitation.RespondedAt = timeProvider.UtcNow;
invitation.UpdatedAt = timeProvider.UtcNow;
- // Idempotent in the one way that matters: a membership added in the meantime (by an admin elsewhere) is kept.
- if (!await context.GroupMembers.AnyAsync(gm => gm.GroupId == invitation.GroupId && gm.UserId == me.Id))
- {
- context.GroupMembers.Add(new GroupMember
- {
- Id = Guid.NewGuid(),
- GroupId = invitation.GroupId,
- UserId = me.Id,
- Role = invitation.Role,
- CreatedAt = timeProvider.UtcNow,
- UpdatedAt = timeProvider.UtcNow,
- });
- }
-
// The sealed copy has become the grant, so it stops being a second copy of the key lying around.
invitation.EncryptedVek = null;
invitation.UserGrantKeyId = null;
@@ -358,7 +401,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Decline an invitation addressed to the current user.
+ /// Decline an offer of access addressed to the current user.
/// </summary>
/// <param name="invitationId">The invitation to decline.</param>
/// <returns>Ok on success.</returns>
@@ -385,7 +428,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Withdraw an invitation the current user's group sent but that has not been answered yet.
+ /// Withdraw an offer of access the caller's group made but that has not been answered yet.
/// </summary>
/// <param name="invitationId">The invitation ID.</param>
/// <returns>Ok on success.</returns>
@@ -412,7 +455,8 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Remove a member from a shared group.
+ /// 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>
@@ -445,20 +489,40 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
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));
+ }
+ }
+ }
+
// Start a transaction to ensure all operations are atomic.
await using var transaction = await context.Database.BeginTransactionAsync();
context.GroupMembers.Remove(membership);
- // Sanity check: revoke any open invitations of this user for this group.
+ // 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);
}
- var manifestId = await context.VaultManifests.Where(m => m.OwnerGroupId == groupId).Select(m => (Guid?)m.ManifestId).FirstOrDefaultAsync();
- if (manifestId is not null && await GrantHelper.RevokeAccessAsync(context, manifestId.Value, userId))
+ foreach (var manifestId in manifestIds)
{
- await ClientActionHelper.EnqueueForGroupAsync(context, ClientActionType.RotateManifestDeliveryKey, groupId, manifestId, timeProvider.UtcNow);
+ if (await GrantHelper.RevokeAccessAsync(context, manifestId, userId))
+ {
+ await ClientActionHelper.EnqueueForGroupAsync(context, ClientActionType.RotateManifestDeliveryKey, groupId, manifestId, timeProvider.UtcNow);
+ }
}
await context.SaveChangesAsync();
@@ -468,45 +532,72 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// The open invitations of each group, for the admins who may withdraw them.
+ /// The open offers of access to each shared vault, for the admins who may withdraw them.
/// </summary>
/// <param name="context">Database context.</param>
- /// <param name="groupIds">The groups to list invitations of.</param>
- /// <returns>Group id to its open invitations.</returns>
- private static async Task<Dictionary<Guid, List<SentGroupInvitation>>> GetOpenInvitationsByGroupAsync(AliasServerDbContext context, List<Guid> groupIds)
+ /// <param name="groupIds">The groups to list offers of.</param>
+ /// <returns>Manifest id to its open offers.</returns>
+ private static async Task<Dictionary<Guid, List<SentManifestInvitation>>> GetOpenInvitationsByManifestAsync(AliasServerDbContext context, List<Guid> groupIds)
{
return (await context.GroupInvitations
- .Where(i => groupIds.Contains(i.GroupId) && i.State == GroupInvitationState.Pending)
- .Select(i => new { i.GroupId, Invitation = new SentGroupInvitation { Id = i.Id, InviteeUsername = i.Invitee.UserName ?? string.Empty, CreatedAt = i.CreatedAt } })
+ .Where(i => groupIds.Contains(i.GroupId) && i.State == GroupInvitationState.Pending && i.VaultManifestId != null)
+ .Select(i => new
+ {
+ ManifestId = i.VaultManifestId!.Value,
+ Invitation = new SentManifestInvitation { Id = i.Id, InviteeUserId = i.InviteeUserId, InviteeUsername = i.Invitee.UserName ?? string.Empty, CreatedAt = i.CreatedAt },
+ })
.ToListAsync())
- .GroupBy(i => i.GroupId)
+ .GroupBy(i => i.ManifestId)
.ToDictionary(g => g.Key, g => g.Select(i => i.Invitation).ToList());
}
/// <summary>
- /// The open invitations addressed to one user.
+ /// The open offers of access addressed to one user.
/// </summary>
/// <param name="context">Database context.</param>
/// <param name="userId">The invitee.</param>
- /// <returns>Their open invitations.</returns>
- private static async Task<List<ReceivedGroupInvitation>> GetReceivedInvitationsAsync(AliasServerDbContext context, string userId)
+ /// <returns>Their open offers.</returns>
+ private static async Task<List<ReceivedManifestInvitation>> GetReceivedInvitationsAsync(AliasServerDbContext context, string userId)
{
- return await context.GroupInvitations
- .Where(i => i.InviteeUserId == userId && i.State == GroupInvitationState.Pending && i.Group.Type == GroupType.Shared)
+ var invitations = await context.GroupInvitations
+ .Where(i => i.InviteeUserId == userId && i.State == GroupInvitationState.Pending && i.Group.Type == GroupType.Shared && i.VaultManifestId != null)
.OrderBy(i => i.CreatedAt)
- .Select(i => new ReceivedGroupInvitation
+ .Select(i => new
{
- Id = i.Id,
- GroupId = i.GroupId,
+ i.Id,
+ i.GroupId,
GroupName = i.Group.Name,
+ ManifestId = i.VaultManifestId!.Value,
InviterUsername = i.Inviter.UserName ?? string.Empty,
- CreatedAt = i.CreatedAt,
+ i.CreatedAt,
})
.ToListAsync();
+
+ if (invitations.Count == 0)
+ {
+ return [];
+ }
+
+ var manifestIds = invitations.ConvertAll(i => i.ManifestId);
+ var existingManifestIds = (await context.VaultManifests
+ .Where(m => manifestIds.Contains(m.ManifestId))
+ .Select(m => m.ManifestId)
+ .ToListAsync()).ToHashSet();
+
+ // An offer whose vault is gone is not something the recipient can act on, so it is left out rather than shown.
+ return [.. invitations.Where(i => existingManifestIds.Contains(i.ManifestId)).Select(i => new ReceivedManifestInvitation
+ {
+ Id = i.Id,
+ GroupId = i.GroupId,
+ GroupName = i.GroupName,
+ ManifestId = i.ManifestId,
+ InviterUsername = i.InviterUsername,
+ CreatedAt = i.CreatedAt,
+ })];
}
/// <summary>
- /// Close an invitation, dropping the vault key sealed inside it.
+ /// Close an offer of access, dropping the vault key sealed inside it.
/// </summary>
/// <param name="invitation">The invitation to close.</param>
/// <param name="state">The state it ends in.</param>
@@ -520,12 +611,12 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
}
/// <summary>
- /// Turn the vault key sealed into an invitation into the accepting member's grant on the group's vault.
+ /// Turn the vault key sealed into an offer of access into the accepting member's grant on that vault.
/// </summary>
/// <param name="context">The database context.</param>
/// <param name="invitation">The invitation being accepted.</param>
/// <param name="userId">The accepting user.</param>
- /// <returns>Whether the accepting user ends up holding a grant on the group's vault.</returns>
+ /// <returns>Whether the accepting user ends up holding a grant on the vault.</returns>
private async Task<bool> PromoteSealedGrantAsync(AliasServerDbContext context, GroupInvitation invitation, string userId)
{
if (invitation.EncryptedVek is null || invitation.UserGrantKeyId is null || invitation.VaultManifestId is null)
@@ -533,56 +624,19 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
return false;
}
- var currentManifestId = await context.VaultManifests.Where(m => m.OwnerGroupId == invitation.GroupId).Select(m => (Guid?)m.ManifestId).FirstOrDefaultAsync();
- if (currentManifestId != invitation.VaultManifestId)
+ var manifestId = invitation.VaultManifestId.Value;
+ if (!await context.VaultManifests.AnyAsync(m => m.ManifestId == manifestId && m.OwnerGroupId == invitation.GroupId))
{
return false;
}
- if (await context.VaultManifestAccessKeys.AnyAsync(k => k.VaultManifestId == currentManifestId.Value && k.UserId == userId && k.Type == ManifestKeyType.GrantKey))
+ if (await context.VaultManifestAccessKeys.AnyAsync(k => k.VaultManifestId == manifestId && k.UserId == userId && k.Type == ManifestKeyType.GrantKey))
{
return true;
}
- context.VaultManifestAccessKeys.Add(GrantHelper.BuildGrant(currentManifestId.Value, userId, invitation.UserGrantKeyId.Value, invitation.EncryptedVek, invitation.Algorithm, timeProvider.UtcNow));
+ context.VaultManifestAccessKeys.Add(GrantHelper.BuildGrant(manifestId, userId, invitation.UserGrantKeyId.Value, invitation.EncryptedVek, invitation.Algorithm, timeProvider.UtcNow));
return true;
}
-
- /// <summary>
- /// Resolve who an invitation is for and whether it may be sent at all.
- /// </summary>
- /// <param name="context">The database context.</param>
- /// <param name="groupId">The group ID.</param>
- /// <param name="callerId">The inviting user.</param>
- /// <param name="findInvitee">How to look the invitee up.</param>
- /// <returns>The invitee, or the failure to return instead.</returns>
- private async Task<(AliasVaultUser? Invitee, IActionResult? Failure)> ResolveInviteeAsync(AliasServerDbContext context, Guid groupId, string callerId, Func<Task<AliasVaultUser?>> findInvitee)
- {
- var group = await context.Groups.FirstOrDefaultAsync(g => g.Id == groupId && g.Type == GroupType.Shared);
- if (group is null || !await GroupHelper.IsGroupAdminAsync(context, groupId, callerId))
- {
- return (null, NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.GROUP_NOT_FOUND, 404)));
- }
-
- var invitee = await findInvitee();
- if (invitee is null || invitee.Blocked)
- {
- return (null, NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITE_RECIPIENT_NOT_FOUND, 404)));
- }
-
- // Sanity check: the invitee must not already be a member of the group.
- if (await context.GroupMembers.AnyAsync(gm => gm.GroupId == groupId && gm.UserId == invitee.Id))
- {
- return (null, BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.ALREADY_GROUP_MEMBER, 400)));
- }
-
- // Sanity check: the invitee must not already have an open invitation for this group.
- if (await context.GroupInvitations.AnyAsync(i => i.GroupId == groupId && i.InviteeUserId == invitee.Id && i.State == GroupInvitationState.Pending))
- {
- return (null, BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVITATION_ALREADY_EXISTS, 400)));
- }
-
- return (invitee, null);
- }
}
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
index 11a992b32..ad8e11e46 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
@@ -91,7 +91,7 @@ public class VaultController(
// Every manifest the caller can open.
var latestManifests = await AccessibleManifests(context, user.Id)
- .Select(x => new { x.ManifestId, x.Name, x.ManifestBlob, x.ManifestCiphertextHash, x.RevisionNumber, x.OwnerGroupId, OwnerGroupType = x.OwnerGroup.Type })
+ .Select(x => new { x.ManifestId, x.ManifestBlob, x.ManifestCiphertextHash, x.RevisionNumber, x.OwnerGroupId, OwnerGroupType = x.OwnerGroup.Type })
.ToListAsync();
if (!latestManifests.Any(m => m.OwnerGroupId == user.PersonalGroupId))
@@ -137,9 +137,6 @@ public class VaultController(
var accessKeysByManifest = await GetAccessKeysAsync(context, user.Id, manifestIds);
var encryptionPublicKeys = await GetEncryptionPublicKeysAsync(context, accessKeysByManifest.Values.Where(g => g.UserGrantKeyId != null).Select(g => g.UserGrantKeyId!.Value));
-
- // Administering a manifest's shares follows group role, not owner identity: an admin of someone else's group
- // may manage it, and heading a group means managing the manifests filed under it (see GrantAccess).
var administeredGroupIds = await GroupHelper.GetAdministeredGroupIdsAsync(context, user.Id);
var manifests = latestManifests.Select(m =>
@@ -151,12 +148,11 @@ public class VaultController(
return new Manifest
{
ManifestId = m.ManifestId,
- Name = m.Name,
Blob = m.ManifestBlob != null ? Convert.ToBase64String(m.ManifestBlob) : null,
CiphertextHash = m.ManifestCiphertextHash,
Revision = m.RevisionNumber,
BlobReferences = refsByManifest.TryGetValue(m.ManifestId, out var refs) ? refs : [],
- CanAdminister = m.OwnerGroupType == GroupType.Shared && administeredGroupIds.Contains(m.OwnerGroupId),
+ CanAdminister = m.OwnerGroupType == GroupType.Shared && administeredGroupIds.Contains(m.OwnerGroupId) && grant != null,
KeyType = accessKey != null ? ManifestKeyTypes.ToToken(accessKey.Type) : null,
EncryptedVek = grant?.EncryptedVek,
Algorithm = grant != null ? VaultKeyAlgorithms.ToToken(grant.Algorithm) : null,
@@ -210,7 +206,6 @@ public class VaultController(
var manifest = new Manifest
{
ManifestId = latest.ManifestId,
- Name = latest.Name,
Blob = latest.ManifestBlob != null ? Convert.ToBase64String(latest.ManifestBlob) : null,
CiphertextHash = latest.ManifestCiphertextHash,
Revision = latest.RevisionNumber,
@@ -736,7 +731,8 @@ public class VaultController(
var administered = await GroupHelper.SharedManifests(context)
.Where(m => ids.Contains(m.ManifestId)
- && context.GroupMembers.Any(gm => gm.GroupId == m.OwnerGroupId && gm.UserId == userId && (gm.Role == GroupRole.Admin || gm.Role == GroupRole.Owner)))
+ && context.GroupMembers.Any(gm => gm.GroupId == m.OwnerGroupId && gm.UserId == userId && (gm.Role == GroupRole.Admin || gm.Role == GroupRole.Owner))
+ && context.VaultManifestAccessKeys.Any(k => k.VaultManifestId == m.ManifestId && k.UserId == userId && k.Type == ManifestKeyType.GrantKey))
.Select(m => m.ManifestId)
.ToListAsync();
diff --git a/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs b/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
index df7385e9f..0830f7bf5 100644
--- a/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
@@ -52,7 +52,7 @@ public static class ClientActionHelper
}
/// <summary>
- /// Record work for the admins of a group.
+ /// Record work for the admins of a group, without queueing the same thing twice.
/// </summary>
/// <param name="context">The database context.</param>
/// <param name="type">The work to be done.</param>
diff --git a/apps/server/AliasVault.Api/Helpers/GrantHelper.cs b/apps/server/AliasVault.Api/Helpers/GrantHelper.cs
index 97ff39c7d..4aefd800f 100644
--- a/apps/server/AliasVault.Api/Helpers/GrantHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/GrantHelper.cs
@@ -9,7 +9,6 @@ namespace AliasVault.Api.Helpers;
using AliasServerDb;
using AliasVault.Shared.Models.Enums;
-using AliasVault.Shared.Models.WebApi.V2.Groups;
using Microsoft.EntityFrameworkCore;
/// <summary>
@@ -64,8 +63,8 @@ public static class GrantHelper
/// </summary>
/// <param name="context">The database context.</param>
/// <param name="userIds">The user IDs to look up.</param>
- /// <returns>User ID to their grant recipient details.</returns>
- public static async Task<Dictionary<string, GrantRecipient>> GetPrimaryKeysAsync(AliasServerDbContext context, IEnumerable<string> userIds)
+ /// <returns>User ID to the public key a vault key is sealed for them with. Users without a keypair are absent.</returns>
+ public static async Task<Dictionary<string, MemberPublicKey>> GetPrimaryKeysAsync(AliasServerDbContext context, IEnumerable<string> userIds)
{
var ids = userIds.Distinct(StringComparer.Ordinal).ToList();
if (ids.Count == 0)
@@ -75,7 +74,7 @@ public static class GrantHelper
return await context.UserGrantKeys
.Where(k => ids.Contains(k.UserId) && k.IsPrimary)
- .ToDictionaryAsync(k => k.UserId, k => new GrantRecipient { UserId = k.UserId, PublicKeyId = k.Id, PublicKey = k.PublicKey });
+ .ToDictionaryAsync(k => k.UserId, k => new MemberPublicKey(k.Id, k.PublicKey));
}
/// <summary>
@@ -108,4 +107,22 @@ public static class GrantHelper
return true;
}
+
+ /// <summary>
+ /// Whether taking this user's access away would leave nobody able to open the manifest.
+ /// </summary>
+ /// <param name="context">Database context.</param>
+ /// <param name="manifestId">The shared manifest.</param>
+ /// <param name="userId">The user about to lose access.</param>
+ /// <returns>True when the user holds the only grant on it.</returns>
+ public static async Task<bool> IsLastGrantHolderAsync(AliasServerDbContext context, Guid manifestId, string userId)
+ {
+ var holders = await context.VaultManifestAccessKeys
+ .Where(k => k.VaultManifestId == manifestId && k.Type == ManifestKeyType.GrantKey)
+ .Select(k => k.UserId)
+ .Distinct()
+ .ToListAsync();
+
+ return holders.Count == 1 && holders.Contains(userId, StringComparer.Ordinal);
+ }
}
diff --git a/apps/server/AliasVault.Api/Helpers/GroupHelper.cs b/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
index 8fca269ce..fc31c37ac 100644
--- a/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/GroupHelper.cs
@@ -47,6 +47,29 @@ public static class GroupHelper
return group;
}
+ /// <summary>
+ /// Check whether a user is on a shared group's membership roster.
+ /// </summary>
+ /// <param name="context">Database context.</param>
+ /// <param name="groupId">The shared group ID.</param>
+ /// <param name="userId">The user ID.</param>
+ /// <returns>True when the user is a member of the group.</returns>
+ public static async Task<bool> IsSharedGroupMemberAsync(AliasServerDbContext context, Guid groupId, string userId)
+ {
+ 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/AliasVault.Api/Helpers/MemberPublicKey.cs b/apps/server/AliasVault.Api/Helpers/MemberPublicKey.cs
new file mode 100644
index 000000000..9cbfa38a3
--- /dev/null
+++ b/apps/server/AliasVault.Api/Helpers/MemberPublicKey.cs
@@ -0,0 +1,15 @@
+//-----------------------------------------------------------------------
+// <copyright file="MemberPublicKey.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Api.Helpers;
+
+/// <summary>
+/// The public key a shared vault's key is sealed for when it is handed to somebody.
+/// </summary>
+/// <param name="PublicKeyId">The id of the key row.</param>
+/// <param name="PublicKey">The public key itself (JWK).</param>
+public sealed record MemberPublicKey(Guid PublicKeyId, string PublicKey);
diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
index dc409c095..72b96d8f6 100644
--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs
@@ -355,8 +355,7 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon
.HasForeignKey(e => e.InviteeUserId)
.OnDelete(DeleteBehavior.Cascade);
- // At most one open invitation per (group, invitee).
- builder.HasIndex(e => new { e.GroupId, e.InviteeUserId }).IsUnique().HasFilter("\"State\" = 'Pending'").HasDatabaseName("UX_GroupInvitations_Group_Invitee_Pending");
+ builder.HasIndex(e => new { e.VaultManifestId, e.InviteeUserId }).IsUnique().HasFilter("\"State\" = 'Pending'").HasDatabaseName("UX_GroupInvitations_Manifest_Invitee_Pending");
builder.Property(e => e.State).HasConversion<string>().HasMaxLength(20);
builder.Property(e => e.Algorithm).HasConversion(v => VaultKeyAlgorithms.ToToken(v), v => VaultKeyAlgorithms.Parse(v));
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.Designer.cs
new file mode 100644
index 000000000..bc1ccdf02
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.Designer.cs
@@ -0,0 +1,1922 @@
+// <auto-generated />
+using System;
+using AliasServerDb;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ [DbContext(typeof(AliasServerDbContext))]
+ [Migration("20260821180325_DropVaultManifestName")]
+ partial class DropVaultManifestName
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.10")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true)
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AliasServerDb.AdminUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("LastPasswordChanged")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AdminUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<bool>("Blocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("BlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("LastActivityDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("PasswordChangedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<Guid>("PersonalGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("SrpIdentity")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PersonalGroupId")
+ .IsUnique()
+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");
+
+ b.ToTable("AliasVaultUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("DeviceIdentifier")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("ExpireDate")
+ .HasMaxLength(255)
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(45)
+ .HasColumnType("character varying(45)");
+
+ b.Property<string>("PreviousTokenValue")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AliasVaultUserRefreshTokens");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AuthLog", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("AdditionalInfo")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Browser")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Client")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Country")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DeviceType")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<int>("EventType")
+ .HasColumnType("integer");
+
+ b.Property<int?>("FailureReason")
+ .HasColumnType("integer");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<bool>("IsSuccess")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("IsSuspiciousActivity")
+ .HasColumnType("boolean");
+
+ b.Property<string>("OperatingSystem")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("RequestPath")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime>("Timestamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "EventType" }, "IX_EventType");
+
+ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");
+
+ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");
+
+ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")
+ .IsDescending(false, false, true);
+
+ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")
+ .IsDescending(false, true);
+
+ b.ToTable("AuthLogs");
+ });
+
+ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<bool>("BlockLogin")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockRegistration")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockShadow")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("IpRange")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Reason")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");
+
+ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")
+ .IsUnique();
+
+ b.ToTable("BlockedIpRanges");
+ });
+
+ modelBuilder.Entity("AliasServerDb.CapabilityRule", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("CapabilityKey")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("ClientName")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("EffectiveFrom")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime?>("EffectiveUntil")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<Guid?>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Kind")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<string>("Notes")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Tier")
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.HasIndex("Tier");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("CapabilityKey", "Enabled");
+
+ b.ToTable("CapabilityRules");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ClientAction", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Payload")
+ .HasColumnType("jsonb");
+
+ b.Property<Guid?>("TargetGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("TargetUserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TargetGroupId");
+
+ b.HasIndex("TargetUserId");
+
+ b.ToTable("ClientActions");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<int>("AttachmentCount")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("DateSystem")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("From")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageHtml")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePlain")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePreview")
+ .HasColumnType("text");
+
+ b.Property<string>("MessageSource")
+ .HasColumnType("text");
+
+ b.Property<byte[]>("MessageSourceBytes")
+ .HasColumnType("bytea");
+
+ b.Property<bool>("PushNotificationSent")
+ .HasColumnType("boolean");
+
+ b.Property<string>("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("To")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<bool>("Visible")
+ .HasColumnType("boolean");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Date");
+
+ b.HasIndex("DateSystem");
+
+ b.HasIndex("PushNotificationSent");
+
+ b.HasIndex("Visible");
+
+ b.HasIndex("To", "DateSystem");
+
+ b.ToTable("Emails");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<byte[]>("Bytes")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<string>("Filename")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("Filesize")
+ .HasColumnType("integer");
+
+ b.Property<string>("MimeType")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailId");
+
+ b.ToTable("EmailAttachments");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Address")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressDomain")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressLocal")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("AnonymizedSenderCounted")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Address")
+ .IsUnique();
+
+ b.ToTable("EmailClaims");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaimLink", b =>
+ {
+ b.Property<Guid>("EmailClaimId")
+ .HasColumnType("uuid");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("State")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.HasKey("EmailClaimId", "VaultManifestId");
+
+ b.HasIndex("EmailClaimId")
+ .HasDatabaseName("IX_EmailClaimLinks_EmailClaimId_Live")
+ .HasFilter("\"State\" <> 'Removed'");
+
+ b.HasIndex("VaultManifestId", "EmailClaimId");
+
+ b.ToTable("EmailClaimLinks");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>
+ {
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<Guid>("VaultManifestDeliveryKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("EncryptedSymmetricKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("EmailId", "VaultManifestDeliveryKeyId");
+
+ b.HasIndex("VaultManifestDeliveryKeyId", "EmailId");
+
+ b.ToTable("EmailDecryptionKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailPart", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<byte[]>("Bytes")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<int>("PartIndex")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailId", "PartIndex")
+ .IsUnique();
+
+ b.ToTable("EmailParts");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Group", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.PrimitiveCollection<int[]>("AnonymizedEmailAliasSenderCounts")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer[]")
+ .HasDefaultValueSql("array_fill(0, ARRAY[64])");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("EmailsReceived")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxEmailAgeDays")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxEmails")
+ .HasColumnType("integer");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("ShadowBlocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("ShadowBlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("Type")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.ToTable("Groups");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedVek")
+ .HasColumnType("text");
+
+ b.Property<Guid>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("InviteeUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("InviterUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("RespondedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("Role")
+ .HasColumnType("integer");
+
+ b.Property<string>("State")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("UserGrantKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<Guid?>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InviterUserId");
+
+ b.HasIndex("UserGrantKeyId");
+
+ b.HasIndex("GroupId", "InviteeUserId")
+ .IsUnique()
+ .HasDatabaseName("UX_GroupInvitations_Group_Invitee_Pending")
+ .HasFilter("\"State\" = 'Pending'");
+
+ b.HasIndex("InviteeUserId", "State");
+
+ b.ToTable("GroupInvitations");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupMember", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<int>("Role")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("GroupId", "UserId")
+ .IsUnique();
+
+ b.ToTable("GroupMembers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Log", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("Application")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Exception")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Level")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property<string>("LogEvent")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("LogEvent");
+
+ b.Property<string>("Message")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageTemplate")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Properties")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("SourceContext")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("TimeStamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Application");
+
+ b.HasIndex("TimeStamp");
+
+ b.ToTable("Logs", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("ClearedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ClientIpAddress")
+ .HasColumnType("text");
+
+ b.Property<string>("ClientPublicKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedDecryptionKey")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("FulfilledAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("MobileIpAddress")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("RetrievedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");
+
+ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");
+
+ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");
+
+ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");
+
+ b.HasIndex(new[] { "UserId" }, "IX_UserId");
+
+ b.ToTable("MobileLoginRequests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.RateLimit", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int?>("AppliesToAccountAgeMaxDays")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("EffectiveFrom")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime?>("EffectiveUntil")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<Guid?>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<int>("LimitType")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("Notes")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<int?>("Tier")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("WindowSeconds")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.HasIndex("Tier");
+
+ b.HasIndex("LimitType", "Enabled");
+
+ b.ToTable("RateLimits");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>
+ {
+ b.Property<string>("Key")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Value")
+ .HasColumnType("text");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSettings");
+ });
+
+ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<TimeOnly?>("EndTime")
+ .HasColumnType("time without time zone");
+
+ b.Property<string>("ErrorMessage")
+ .HasColumnType("text");
+
+ b.Property<bool>("IsOnDemand")
+ .HasColumnType("boolean");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("RunDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<TimeOnly>("StartTime")
+ .HasColumnType("time without time zone");
+
+ b.Property<int>("Status")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("TaskRunnerJobs");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedPrivateKey")
+ .IsRequired()
+ .HasMaxLength(4000)
+ .HasColumnType("character varying(4000)");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId")
+ .IsUnique()
+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")
+ .HasFilter("\"IsPrimary\"");
+
+ b.ToTable("UserGrantKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedAccountKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Label")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime?>("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Metadata")
+ .HasColumnType("jsonb");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "Type", "Label")
+ .IsUnique()
+ .HasDatabaseName("UX_UserUnlockKeys_UserId_Type_Label");
+
+ b.ToTable("UserUnlockKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.Property<string>("Hash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("OwnerUserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("LastReferencedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("SizeBytes")
+ .HasColumnType("integer");
+
+ b.HasKey("Hash", "OwnerUserId");
+
+ b.HasIndex("OwnerUserId", "Category");
+
+ b.ToTable("VaultBlobObjects");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("BlobHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");
+
+ b.ToTable("VaultBlobReferences");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Category")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("CiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("ManifestId", "Category");
+
+ b.ToTable("VaultDataBuckets");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Category")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("CiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("ManifestId", "Category", "RevisionNumber");
+
+ b.ToTable("VaultDataBucketsHistory");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Client")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("CredentialsCount")
+ .HasColumnType("integer");
+
+ b.Property<int>("EmailClaimsCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("EncryptionSettings")
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<byte[]>("ManifestBlob")
+ .HasColumnType("bytea");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<Guid>("OwnerGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("Salt")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId");
+
+ b.HasIndex("OwnerGroupId");
+
+ b.ToTable("VaultManifests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int?>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedVek")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime?>("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Metadata")
+ .HasColumnType("jsonb");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("UserGrantKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserGrantKeyId");
+
+ b.HasIndex("VaultManifestId")
+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");
+
+ b.HasIndex("UserId", "Type", "VaultManifestId", "KeyVersion")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest_Version");
+
+ b.ToTable("VaultManifestAccessKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VaultManifestId")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")
+ .HasFilter("\"IsPrimary\"");
+
+ b.HasIndex("VaultManifestId", "IsPrimary");
+
+ b.ToTable("VaultManifestDeliveryKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("Client")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("CredentialsCount")
+ .HasColumnType("integer");
+
+ b.Property<int>("EmailClaimsCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("EncryptionSettings")
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<byte[]>("ManifestBlob")
+ .HasColumnType("bytea");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("Salt")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId", "RevisionNumber");
+
+ b.ToTable("VaultManifestsHistory", (string)null);
+ });
+
+ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("CurrentStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DesiredStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("Heartbeat")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ServiceName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WorkerServiceStatuses");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("FriendlyName")
+ .HasColumnType("text");
+
+ b.Property<string>("Xml")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("DataProtectionKeys");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("text");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("UserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property<string>("Name")
+ .HasColumnType("text");
+
+ b.Property<string>("Value")
+ .HasColumnType("text");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("UserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "PersonalGroup")
+ .WithOne()
+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+
+ b.Navigation("PersonalGroup");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.CapabilityRule", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Group");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ClientAction", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "TargetGroup")
+ .WithMany()
+ .HasForeignKey("TargetGroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "TargetUser")
+ .WithMany()
+ .HasForeignKey("TargetUserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("TargetGroup");
+
+ b.Navigation("TargetUser");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("Attachments")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Email");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaimLink", b =>
+ {
+ b.HasOne("AliasServerDb.EmailClaim", "EmailClaim")
+ .WithMany("Links")
+ .HasForeignKey("EmailClaimId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("EmailClaim");
+
+ b.Navigation("VaultManifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("DecryptionKeys")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.VaultManifestDeliveryKey", "VaultManifestDeliveryKey")
+ .WithMany("DecryptionKeys")
+ .HasForeignKey("VaultManifestDeliveryKeyId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired()
+ .HasConstraintName("FK_EmailDecryptionKeys_VaultManifestDeliveryKeys_DeliveryKeyId");
+
+ b.Navigation("Email");
+
+ b.Navigation("VaultManifestDeliveryKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailPart", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("Parts")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Email");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "Invitee")
+ .WithMany()
+ .HasForeignKey("InviteeUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "Inviter")
+ .WithMany()
+ .HasForeignKey("InviterUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")
+ .WithMany()
+ .HasForeignKey("UserGrantKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.Navigation("Group");
+
+ b.Navigation("Invitee");
+
+ b.Navigation("Inviter");
+
+ b.Navigation("UserGrantKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupMember", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany("Members")
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Group");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.RateLimit", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Group");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("OwnerUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")
+ .WithMany()
+ .HasForeignKey("ManifestId", "Category")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Bucket");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "OwnerGroup")
+ .WithMany()
+ .HasForeignKey("OwnerGroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("OwnerGroup");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")
+ .WithMany()
+ .HasForeignKey("UserGrantKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("VaultManifestAccessKeys")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+
+ b.Navigation("UserGrantKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("VaultManifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Navigation("VaultManifestAccessKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Navigation("Attachments");
+
+ b.Navigation("DecryptionKeys");
+
+ b.Navigation("Parts");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>
+ {
+ b.Navigation("Links");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Group", b =>
+ {
+ b.Navigation("Members");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.Navigation("DecryptionKeys");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.cs b/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.cs
new file mode 100644
index 000000000..e863d5422
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260821180325_DropVaultManifestName.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class DropVaultManifestName : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Name",
+ table: "VaultManifests");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<string>(
+ name: "Name",
+ table: "VaultManifests",
+ type: "character varying(255)",
+ maxLength: 255,
+ nullable: true);
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.Designer.cs
new file mode 100644
index 000000000..f24803f52
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.Designer.cs
@@ -0,0 +1,1924 @@
+// <auto-generated />
+using System;
+using AliasServerDb;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ [DbContext(typeof(AliasServerDbContext))]
+ [Migration("20260821185744_ScopeGroupInvitationUniquenessToManifest")]
+ partial class ScopeGroupInvitationUniquenessToManifest
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.10")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true)
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AliasServerDb.AdminUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("LastPasswordChanged")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AdminUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<bool>("Blocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("BlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("LastActivityDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("PasswordChangedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<Guid>("PersonalGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("SrpIdentity")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PersonalGroupId")
+ .IsUnique()
+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");
+
+ b.ToTable("AliasVaultUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("DeviceIdentifier")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("ExpireDate")
+ .HasMaxLength(255)
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(45)
+ .HasColumnType("character varying(45)");
+
+ b.Property<string>("PreviousTokenValue")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AliasVaultUserRefreshTokens");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AuthLog", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("AdditionalInfo")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Browser")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Client")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Country")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DeviceType")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<int>("EventType")
+ .HasColumnType("integer");
+
+ b.Property<int?>("FailureReason")
+ .HasColumnType("integer");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<bool>("IsSuccess")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("IsSuspiciousActivity")
+ .HasColumnType("boolean");
+
+ b.Property<string>("OperatingSystem")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("RequestPath")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime>("Timestamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "EventType" }, "IX_EventType");
+
+ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");
+
+ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");
+
+ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")
+ .IsDescending(false, false, true);
+
+ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")
+ .IsDescending(false, true);
+
+ b.ToTable("AuthLogs");
+ });
+
+ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<bool>("BlockLogin")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockRegistration")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockShadow")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("IpRange")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Reason")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");
+
+ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")
+ .IsUnique();
+
+ b.ToTable("BlockedIpRanges");
+ });
+
+ modelBuilder.Entity("AliasServerDb.CapabilityRule", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("CapabilityKey")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("ClientName")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("EffectiveFrom")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime?>("EffectiveUntil")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<Guid?>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Kind")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<string>("Notes")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Tier")
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.HasIndex("Tier");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("CapabilityKey", "Enabled");
+
+ b.ToTable("CapabilityRules");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ClientAction", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Payload")
+ .HasColumnType("jsonb");
+
+ b.Property<Guid?>("TargetGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("TargetUserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TargetGroupId");
+
+ b.HasIndex("TargetUserId");
+
+ b.ToTable("ClientActions");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<int>("AttachmentCount")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("DateSystem")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("From")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageHtml")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePlain")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePreview")
+ .HasColumnType("text");
+
+ b.Property<string>("MessageSource")
+ .HasColumnType("text");
+
+ b.Property<byte[]>("MessageSourceBytes")
+ .HasColumnType("bytea");
+
+ b.Property<bool>("PushNotificationSent")
+ .HasColumnType("boolean");
+
+ b.Property<string>("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("To")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<bool>("Visible")
+ .HasColumnType("boolean");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Date");
+
+ b.HasIndex("DateSystem");
+
+ b.HasIndex("PushNotificationSent");
+
+ b.HasIndex("Visible");
+
+ b.HasIndex("To", "DateSystem");
+
+ b.ToTable("Emails");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<byte[]>("Bytes")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<string>("Filename")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("Filesize")
+ .HasColumnType("integer");
+
+ b.Property<string>("MimeType")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailId");
+
+ b.ToTable("EmailAttachments");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Address")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressDomain")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressLocal")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("AnonymizedSenderCounted")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Address")
+ .IsUnique();
+
+ b.ToTable("EmailClaims");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaimLink", b =>
+ {
+ b.Property<Guid>("EmailClaimId")
+ .HasColumnType("uuid");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("State")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.HasKey("EmailClaimId", "VaultManifestId");
+
+ b.HasIndex("EmailClaimId")
+ .HasDatabaseName("IX_EmailClaimLinks_EmailClaimId_Live")
+ .HasFilter("\"State\" <> 'Removed'");
+
+ b.HasIndex("VaultManifestId", "EmailClaimId");
+
+ b.ToTable("EmailClaimLinks");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>
+ {
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<Guid>("VaultManifestDeliveryKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("EncryptedSymmetricKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("EmailId", "VaultManifestDeliveryKeyId");
+
+ b.HasIndex("VaultManifestDeliveryKeyId", "EmailId");
+
+ b.ToTable("EmailDecryptionKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailPart", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<byte[]>("Bytes")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<int>("PartIndex")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailId", "PartIndex")
+ .IsUnique();
+
+ b.ToTable("EmailParts");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Group", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.PrimitiveCollection<int[]>("AnonymizedEmailAliasSenderCounts")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer[]")
+ .HasDefaultValueSql("array_fill(0, ARRAY[64])");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("EmailsReceived")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxEmailAgeDays")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxEmails")
+ .HasColumnType("integer");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("ShadowBlocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("ShadowBlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("Type")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.ToTable("Groups");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedVek")
+ .HasColumnType("text");
+
+ b.Property<Guid>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("InviteeUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("InviterUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("RespondedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("Role")
+ .HasColumnType("integer");
+
+ b.Property<string>("State")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("UserGrantKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<Guid?>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.HasIndex("InviterUserId");
+
+ b.HasIndex("UserGrantKeyId");
+
+ b.HasIndex("InviteeUserId", "State");
+
+ b.HasIndex("VaultManifestId", "InviteeUserId")
+ .IsUnique()
+ .HasDatabaseName("UX_GroupInvitations_Manifest_Invitee_Pending")
+ .HasFilter("\"State\" = 'Pending'");
+
+ b.ToTable("GroupInvitations");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupMember", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<int>("Role")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("GroupId", "UserId")
+ .IsUnique();
+
+ b.ToTable("GroupMembers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Log", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("Application")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Exception")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Level")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property<string>("LogEvent")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("LogEvent");
+
+ b.Property<string>("Message")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageTemplate")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Properties")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("SourceContext")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("TimeStamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Application");
+
+ b.HasIndex("TimeStamp");
+
+ b.ToTable("Logs", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("ClearedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ClientIpAddress")
+ .HasColumnType("text");
+
+ b.Property<string>("ClientPublicKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedDecryptionKey")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("FulfilledAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("MobileIpAddress")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("RetrievedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");
+
+ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");
+
+ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");
+
+ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");
+
+ b.HasIndex(new[] { "UserId" }, "IX_UserId");
+
+ b.ToTable("MobileLoginRequests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.RateLimit", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int?>("AppliesToAccountAgeMaxDays")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime?>("EffectiveFrom")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime?>("EffectiveUntil")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<Guid?>("GroupId")
+ .HasColumnType("uuid");
+
+ b.Property<int>("LimitType")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("Notes")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<int?>("Tier")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("WindowSeconds")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.HasIndex("Tier");
+
+ b.HasIndex("LimitType", "Enabled");
+
+ b.ToTable("RateLimits");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>
+ {
+ b.Property<string>("Key")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Value")
+ .HasColumnType("text");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSettings");
+ });
+
+ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<TimeOnly?>("EndTime")
+ .HasColumnType("time without time zone");
+
+ b.Property<string>("ErrorMessage")
+ .HasColumnType("text");
+
+ b.Property<bool>("IsOnDemand")
+ .HasColumnType("boolean");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("RunDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<TimeOnly>("StartTime")
+ .HasColumnType("time without time zone");
+
+ b.Property<int>("Status")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("TaskRunnerJobs");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedPrivateKey")
+ .IsRequired()
+ .HasMaxLength(4000)
+ .HasColumnType("character varying(4000)");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId")
+ .IsUnique()
+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")
+ .HasFilter("\"IsPrimary\"");
+
+ b.ToTable("UserGrantKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedAccountKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Label")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime?>("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Metadata")
+ .HasColumnType("jsonb");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "Type", "Label")
+ .IsUnique()
+ .HasDatabaseName("UX_UserUnlockKeys_UserId_Type_Label");
+
+ b.ToTable("UserUnlockKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.Property<string>("Hash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("OwnerUserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("LastReferencedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("SizeBytes")
+ .HasColumnType("integer");
+
+ b.HasKey("Hash", "OwnerUserId");
+
+ b.HasIndex("OwnerUserId", "Category");
+
+ b.ToTable("VaultBlobObjects");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("BlobHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");
+
+ b.ToTable("VaultBlobReferences");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Category")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("CiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("ManifestId", "Category");
+
+ b.ToTable("VaultDataBuckets");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Category")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("CiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("ManifestId", "Category", "RevisionNumber");
+
+ b.ToTable("VaultDataBucketsHistory");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Client")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("CredentialsCount")
+ .HasColumnType("integer");
+
+ b.Property<int>("EmailClaimsCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("EncryptionSettings")
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<byte[]>("ManifestBlob")
+ .HasColumnType("bytea");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<Guid>("OwnerGroupId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("Salt")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId");
+
+ b.HasIndex("OwnerGroupId");
+
+ b.ToTable("VaultManifests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<int?>("AccountKeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<string>("Algorithm")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedVek")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<DateTime?>("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Metadata")
+ .HasColumnType("jsonb");
+
+ b.Property<string>("Type")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid?>("UserGrantKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserGrantKeyId");
+
+ b.HasIndex("VaultManifestId")
+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");
+
+ b.HasIndex("UserId", "Type", "VaultManifestId", "KeyVersion")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest_Version");
+
+ b.ToTable("VaultManifestAccessKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VaultManifestId")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")
+ .HasFilter("\"IsPrimary\"");
+
+ b.HasIndex("VaultManifestId", "IsPrimary");
+
+ b.ToTable("VaultManifestDeliveryKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.Property<Guid>("ManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("Client")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("CredentialsCount")
+ .HasColumnType("integer");
+
+ b.Property<int>("EmailClaimsCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("EncryptionSettings")
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<int>("KeyVersion")
+ .HasColumnType("integer");
+
+ b.Property<byte[]>("ManifestBlob")
+ .HasColumnType("bytea");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("Salt")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId", "RevisionNumber");
+
+ b.ToTable("VaultManifestsHistory", (string)null);
+ });
+
+ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("CurrentStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DesiredStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("Heartbeat")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ServiceName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WorkerServiceStatuses");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("FriendlyName")
+ .HasColumnType("text");
+
+ b.Property<string>("Xml")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("DataProtectionKeys");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("text");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("UserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property<string>("Name")
+ .HasColumnType("text");
+
+ b.Property<string>("Value")
+ .HasColumnType("text");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("UserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "PersonalGroup")
+ .WithOne()
+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")
+ .OnDelete(DeleteBehavior.Restrict)
+ .IsRequired();
+
+ b.Navigation("PersonalGroup");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.CapabilityRule", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Group");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.ClientAction", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "TargetGroup")
+ .WithMany()
+ .HasForeignKey("TargetGroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "TargetUser")
+ .WithMany()
+ .HasForeignKey("TargetUserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("TargetGroup");
+
+ b.Navigation("TargetUser");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("Attachments")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Email");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaimLink", b =>
+ {
+ b.HasOne("AliasServerDb.EmailClaim", "EmailClaim")
+ .WithMany("Links")
+ .HasForeignKey("EmailClaimId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("EmailClaim");
+
+ b.Navigation("VaultManifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("DecryptionKeys")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.VaultManifestDeliveryKey", "VaultManifestDeliveryKey")
+ .WithMany("DecryptionKeys")
+ .HasForeignKey("VaultManifestDeliveryKeyId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired()
+ .HasConstraintName("FK_EmailDecryptionKeys_VaultManifestDeliveryKeys_DeliveryKeyId");
+
+ b.Navigation("Email");
+
+ b.Navigation("VaultManifestDeliveryKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailPart", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("Parts")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Email");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "Invitee")
+ .WithMany()
+ .HasForeignKey("InviteeUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "Inviter")
+ .WithMany()
+ .HasForeignKey("InviterUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")
+ .WithMany()
+ .HasForeignKey("UserGrantKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.Navigation("Group");
+
+ b.Navigation("Invitee");
+
+ b.Navigation("Inviter");
+
+ b.Navigation("UserGrantKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.GroupMember", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany("Members")
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Group");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.RateLimit", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "Group")
+ .WithMany()
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Group");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("OwnerUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")
+ .WithMany()
+ .HasForeignKey("ManifestId", "Category")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Bucket");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>
+ {
+ b.HasOne("AliasServerDb.Group", "OwnerGroup")
+ .WithMany()
+ .HasForeignKey("OwnerGroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("OwnerGroup");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")
+ .WithMany()
+ .HasForeignKey("UserGrantKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("VaultManifestAccessKeys")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+
+ b.Navigation("UserGrantKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("VaultManifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Navigation("VaultManifestAccessKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Navigation("Attachments");
+
+ b.Navigation("DecryptionKeys");
+
+ b.Navigation("Parts");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>
+ {
+ b.Navigation("Links");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Group", b =>
+ {
+ b.Navigation("Members");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.Navigation("DecryptionKeys");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.cs b/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.cs
new file mode 100644
index 000000000..b4961279a
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260821185744_ScopeGroupInvitationUniquenessToManifest.cs
@@ -0,0 +1,49 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class ScopeGroupInvitationUniquenessToManifest : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "UX_GroupInvitations_Group_Invitee_Pending",
+ table: "GroupInvitations");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GroupInvitations_GroupId",
+ table: "GroupInvitations",
+ column: "GroupId");
+
+ migrationBuilder.CreateIndex(
+ name: "UX_GroupInvitations_Manifest_Invitee_Pending",
+ table: "GroupInvitations",
+ columns: new[] { "VaultManifestId", "InviteeUserId" },
+ unique: true,
+ filter: "\"State\" = 'Pending'");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_GroupInvitations_GroupId",
+ table: "GroupInvitations");
+
+ migrationBuilder.DropIndex(
+ name: "UX_GroupInvitations_Manifest_Invitee_Pending",
+ table: "GroupInvitations");
+
+ migrationBuilder.CreateIndex(
+ name: "UX_GroupInvitations_Group_Invitee_Pending",
+ table: "GroupInvitations",
+ columns: new[] { "GroupId", "InviteeUserId" },
+ unique: true,
+ filter: "\"State\" = 'Pending'");
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
index 79e225595..f45059775 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
@@ -762,17 +762,19 @@ namespace AliasServerDb.Migrations
b.HasKey("Id");
+ b.HasIndex("GroupId");
+
b.HasIndex("InviterUserId");
b.HasIndex("UserGrantKeyId");
- b.HasIndex("GroupId", "InviteeUserId")
+ b.HasIndex("InviteeUserId", "State");
+
+ b.HasIndex("VaultManifestId", "InviteeUserId")
.IsUnique()
- .HasDatabaseName("UX_GroupInvitations_Group_Invitee_Pending")
+ .HasDatabaseName("UX_GroupInvitations_Manifest_Invitee_Pending")
.HasFilter("\"State\" = 'Pending'");
- b.HasIndex("InviteeUserId", "State");
-
b.ToTable("GroupInvitations");
});
@@ -1285,10 +1287,6 @@ namespace AliasServerDb.Migrations
.HasMaxLength(64)
.HasColumnType("character varying(64)");
- b.Property<string>("Name")
- .HasMaxLength(255)
- .HasColumnType("character varying(255)");
-
b.Property<Guid>("OwnerGroupId")
.HasColumnType("uuid");
diff --git a/apps/server/Databases/AliasServerDb/VaultManifest.cs b/apps/server/Databases/AliasServerDb/VaultManifest.cs
index 68c036635..f91924424 100644
--- a/apps/server/Databases/AliasServerDb/VaultManifest.cs
+++ b/apps/server/Databases/AliasServerDb/VaultManifest.cs
@@ -23,12 +23,6 @@ public class VaultManifest : VaultManifestBase
[Key]
public Guid ManifestId { get; set; }
- /// <summary>
- /// Gets or sets the optional display name of a manifest. Used in e.g. sharing UI.
- /// </summary>
- [StringLength(255)]
- public string? Name { get; set; }
-
/// <summary>
/// Gets or sets the group that owns this manifest.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared.Server/Capabilities/CapabilityRegistry.cs b/apps/server/Shared/AliasVault.Shared.Server/Capabilities/CapabilityRegistry.cs
index 9d9b14400..7f4abc9f9 100644
--- a/apps/server/Shared/AliasVault.Shared.Server/Capabilities/CapabilityRegistry.cs
+++ b/apps/server/Shared/AliasVault.Shared.Server/Capabilities/CapabilityRegistry.cs
@@ -22,7 +22,7 @@ public static class CapabilityRegistry
CapabilityKeys.VaultSharing,
CapabilityRuleKind.Entitlement,
CapabilityValue.Off,
- "Shared vaults: creating a shared vault, inviting people to it and accepting invitations. Currently in beta."),
+ "Shared vaults: creating a shared vault, giving family members access to it and accepting such access. Currently in beta."),
}.AsReadOnly();
private static readonly Dictionary<string, CapabilityDefinition> ByKey = Definitions.ToDictionary(d => d.Key, StringComparer.OrdinalIgnoreCase);
diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
index 25ba11b58..388d22191 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
@@ -195,9 +195,9 @@ public enum ApiErrorCode
GROUP_NOT_FOUND,
/// <summary>
- /// The group already holds a manifest, so the caller must use that one instead of creating another.
+ /// The group already holds as many shared vaults as it is entitled to, so no further one can be created.
/// </summary>
- GROUP_MANIFEST_EXISTS,
+ GROUP_MANIFEST_LIMIT_REACHED,
/// <summary>
/// The invitation does not exist, is not addressed to (or sent by) the caller, or was already answered.
@@ -205,19 +205,20 @@ public enum ApiErrorCode
INVITATION_NOT_FOUND,
/// <summary>
- /// There is already an open invitation for this user in this group.
+ /// There is already an open offer of access to this shared vault for this member.
/// </summary>
INVITATION_ALREADY_EXISTS,
/// <summary>
- /// No account can be invited under the given username, or it is the caller's own.
+ /// The account access was offered to is not on the group's membership roster. Who belongs to a group is decided
+ /// outside the client, so this cannot be resolved by the caller.
/// </summary>
- INVITE_RECIPIENT_NOT_FOUND,
+ NOT_GROUP_MEMBER,
/// <summary>
- /// The invited user is already a member of the group.
+ /// The member already holds access to this shared vault.
/// </summary>
- ALREADY_GROUP_MEMBER,
+ ACCESS_ALREADY_GRANTED,
/// <summary>
/// The group's owner cannot be removed from it; ownership has to be transferred first.
@@ -225,15 +226,16 @@ public enum ApiErrorCode
CANNOT_REMOVE_GROUP_OWNER,
/// <summary>
- /// The invited account has published no public key, so a shared vault key cannot be encrypted for it. The account
- /// has to finish upgrading its vault before it can be invited anywhere.
+ /// The member is the last one who can open one of the group's shared vaults, so taking their access away would
+ /// leave that vault unopenable. Somebody else has to be given access to it first.
/// </summary>
- INVITE_RECIPIENT_NOT_READY,
+ LAST_MANIFEST_GRANT_HOLDER,
/// <summary>
- /// The group has no shared vault yet, so there is no key to hand an invitee. One has to be created first.
+ /// The account access was offered to has published no public key, so a shared vault key cannot be encrypted for
+ /// it. That account has to finish upgrading its vault before it can be given access to anything.
/// </summary>
- GROUP_HAS_NO_VAULT,
+ INVITE_RECIPIENT_NOT_READY,
/// <summary>
/// The client action does not exist, or is not addressed to the caller.
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestRequest.cs
index ca6af9a84..a630242c7 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestRequest.cs
@@ -8,16 +8,13 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// Request for POST /v2/Groups/{groupId}/manifest.
+/// Request for POST /v2/Groups/{groupId}/manifests: create another shared vault for the group.
/// </summary>
public class CreateSharedManifestRequest
{
/// <summary>Gets or sets the client-minted id of the new manifest.</summary>
public required Guid ManifestId { get; set; }
- /// <summary>Gets or sets the plaintext display name of the manifest.</summary>
- public required string Name { get; set; }
-
/// <summary>Gets or sets the manifest VEK encrypted with the user's own public key (base64), decryptable only by the user.</summary>
public required string SelfEncryptedVek { get; set; }
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestResponse.cs
index fb77b220e..3970d0f97 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateSharedManifestResponse.cs
@@ -8,7 +8,7 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// Response for POST /v2/Groups/{groupId}/manifest. Identifies the newly created shared manifest.
+/// Response for POST /v2/Groups/{groupId}/manifests. Identifies the newly created shared vault.
/// </summary>
public class CreateSharedManifestResponse
{
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessRequest.cs
similarity index 56%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationRequest.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessRequest.cs
index 38c5c21e4..edf864de7 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessRequest.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="CreateGroupInvitationRequest.cs" company="aliasvault">
+// <copyright file="GrantManifestAccessRequest.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
@@ -8,15 +8,14 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// Request for POST /v2/Groups/{groupId}/invitations: invite an account to join the group, handing it the group's
-/// vault key sealed for that account in the same call.
+/// Request for POST /v2/Groups/{groupId}/manifests/{manifestId}/access.
/// </summary>
-public class CreateGroupInvitationRequest
+public class GrantManifestAccessRequest
{
- /// <summary>Gets or sets the account to invite, as resolved by the recipient lookup.</summary>
+ /// <summary>Gets or sets the member to give access to. Must already be a member of the group.</summary>
public required string UserId { get; set; }
- /// <summary>Gets or sets the group's vault key, encrypted for the invitee's public key.</summary>
+ /// <summary>Gets or sets the vault's key, encrypted for that member's public key.</summary>
public required ManifestGrant Grant { get; set; }
/// <summary>Gets or sets the algorithm the grant is encrypted with.</summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessResponse.cs
similarity index 59%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationResponse.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessResponse.cs
index bacd9a286..6829ea3c4 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/CreateGroupInvitationResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantManifestAccessResponse.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="CreateGroupInvitationResponse.cs" company="aliasvault">
+// <copyright file="GrantManifestAccessResponse.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
@@ -8,10 +8,10 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// Response for POST /v2/Groups/{groupId}/invitations.
+/// Response for POST /v2/Groups/{groupId}/manifests/{manifestId}/access.
/// </summary>
-public class CreateGroupInvitationResponse
+public class GrantManifestAccessResponse
{
- /// <summary>Gets or sets the id of the created invitation.</summary>
+ /// <summary>Gets or sets the id of the created invitation, which becomes a grant once the member accepts it.</summary>
public required Guid InvitationId { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantRecipient.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantRecipient.cs
deleted file mode 100644
index c2100cfba..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GrantRecipient.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GrantRecipient.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Shared.Models.WebApi.V2.Groups;
-
-/// <summary>
-/// A user a shared manifest's VEK can be encrypted for, with the public key to encrypt it with.
-/// </summary>
-public class GrantRecipient
-{
- /// <summary>Gets or sets the user id.</summary>
- public required string UserId { get; set; }
-
- /// <summary>Gets or sets the id of the user's primary public key.</summary>
- public required Guid PublicKeyId { get; set; }
-
- /// <summary>Gets or sets the public key itself (JWK).</summary>
- public required string PublicKey { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInfo.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInfo.cs
index ff4af9d7a..507c543df 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInfo.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInfo.cs
@@ -28,17 +28,12 @@ public class GroupInfo
public required string Role { get; set; }
/// <summary>
- /// Gets or sets the group's shared vault if it exists.
+ /// Gets or sets the group's shared vaults. A group holds any number of them.
/// </summary>
- public Guid? ManifestId { get; set; }
+ public List<SharedManifestInfo> Manifests { get; set; } = [];
/// <summary>
/// Gets or sets the group's members.
/// </summary>
public List<GroupMemberInfo> Members { get; set; } = [];
-
- /// <summary>
- /// Gets or sets the invitations sent from this group that are still awaiting an answer (only filled if caller has sufficient permissions).
- /// </summary>
- public List<SentGroupInvitation> PendingInvitations { get; set; } = [];
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientRequest.cs
deleted file mode 100644
index 75f0936d4..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientRequest.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GroupInvitationRecipientRequest.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Shared.Models.WebApi.V2.Groups;
-
-/// <summary>
-/// Request for POST /v2/Groups/{groupId}/invitations/recipient: who the caller means to invite.
-/// </summary>
-public class GroupInvitationRecipientRequest
-{
- /// <summary>Gets or sets the username typed by the inviting admin.</summary>
- public required string Username { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientResponse.cs
deleted file mode 100644
index aabddab0f..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupInvitationRecipientResponse.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="GroupInvitationRecipientResponse.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Shared.Models.WebApi.V2.Groups;
-
-/// <summary>
-/// Response for POST /v2/Groups/{groupId}/invitations/recipient: the account behind a username together with the
-/// public key an invitation to it has to be sealed for.
-/// </summary>
-public class GroupInvitationRecipientResponse
-{
- /// <summary>Gets or sets the resolved account and the key to seal the group's vault key for.</summary>
- public required GrantRecipient Recipient { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupMemberInfo.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupMemberInfo.cs
index 7eada2535..12c6c0916 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupMemberInfo.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupMemberInfo.cs
@@ -8,7 +8,7 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// One member of a shared group.
+/// One member of a shared group, as shown to the other members.
/// </summary>
public class GroupMemberInfo
{
@@ -20,4 +20,10 @@ public class GroupMemberInfo
/// <summary>Gets or sets their role in the group.</summary>
public required string Role { get; set; }
+
+ /// <summary>Gets or sets the id of the member's primary public key.</summary>
+ public Guid? PublicKeyId { get; set; }
+
+ /// <summary>Gets or sets that public key itself (JWK).</summary>
+ public string? PublicKey { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupOverviewResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupOverviewResponse.cs
index 7f2b93712..7c0a9b9c2 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupOverviewResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/GroupOverviewResponse.cs
@@ -18,7 +18,7 @@ public class GroupOverviewResponse
public List<GroupInfo> Groups { get; set; } = [];
/// <summary>
- /// Gets or sets the open invitations addressed to the caller, awaiting their accept or decline.
+ /// Gets or sets the offers of access to a shared vault addressed to the caller, awaiting their accept or decline.
/// </summary>
- public List<ReceivedGroupInvitation> ReceivedInvitations { get; set; } = [];
+ public List<ReceivedManifestInvitation> ReceivedInvitations { get; set; } = [];
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ManifestGrant.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ManifestGrant.cs
index f7620c039..1d144d86c 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ManifestGrant.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ManifestGrant.cs
@@ -15,7 +15,7 @@ public class ManifestGrant
/// <summary>Gets or sets the recipient this grant is for.</summary>
public required string RecipientUserId { get; set; }
- /// <summary>Gets or sets the id of the recipient public key used to encrypt (see <see cref="GrantRecipient"/>).</summary>
+ /// <summary>Gets or sets the id of the recipient public key used to encrypt (see <see cref="GroupMemberInfo.PublicKeyId"/>).</summary>
public required Guid RecipientPublicKeyId { get; set; }
/// <summary>Gets or sets the manifest VEK encrypted with that public key (base64), decryptable only by the recipient.</summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedGroupInvitation.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedManifestInvitation.cs
similarity index 71%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedGroupInvitation.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedManifestInvitation.cs
index 52a2b90b5..9befa0584 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedGroupInvitation.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/ReceivedManifestInvitation.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="ReceivedGroupInvitation.cs" company="aliasvault">
+// <copyright file="ReceivedManifestInvitation.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
@@ -8,19 +8,22 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// An open invitation addressed to the caller: an offer to join somebody else's group.
+/// An open offer of access to a shared vault, addressed to the caller.
/// </summary>
-public class ReceivedGroupInvitation
+public class ReceivedManifestInvitation
{
/// <summary>Gets or sets the invitation id, used to accept or decline it.</summary>
public required Guid Id { get; set; }
- /// <summary>Gets or sets the group being joined.</summary>
+ /// <summary>Gets or sets the group the vault belongs to.</summary>
public required Guid GroupId { get; set; }
/// <summary>Gets or sets the group's display name.</summary>
public required string GroupName { get; set; }
+ /// <summary>Gets or sets the vault being offered.</summary>
+ public required Guid ManifestId { get; set; }
+
/// <summary>Gets or sets the username of the member who sent it.</summary>
public required string InviterUsername { get; set; }
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentGroupInvitation.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentManifestInvitation.cs
similarity index 63%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentGroupInvitation.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentManifestInvitation.cs
index 955495655..1eb430df8 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentGroupInvitation.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SentManifestInvitation.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="SentGroupInvitation.cs" company="aliasvault">
+// <copyright file="SentManifestInvitation.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
@@ -8,14 +8,17 @@
namespace AliasVault.Shared.Models.WebApi.V2.Groups;
/// <summary>
-/// An invitation sent from a group that is still awaiting the invitee's answer.
+/// An offer of access to a shared vault that is still awaiting the recipient's answer.
/// </summary>
-public class SentGroupInvitation
+public class SentManifestInvitation
{
/// <summary>Gets or sets the invitation id, used to withdraw it.</summary>
public required Guid Id { get; set; }
- /// <summary>Gets or sets the username it was sent to.</summary>
+ /// <summary>Gets or sets the member it was sent to.</summary>
+ public required string InviteeUserId { get; set; }
+
+ /// <summary>Gets or sets the username of the member it was sent to.</summary>
public required string InviteeUsername { get; set; }
/// <summary>Gets or sets when it was sent.</summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SharedManifestInfo.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SharedManifestInfo.cs
new file mode 100644
index 000000000..f02b0ee99
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Groups/SharedManifestInfo.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="SharedManifestInfo.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Groups;
+
+/// <summary>
+/// One shared vault owned by a group. A group holds any number of these, each with its own key and its own set of
+/// members that were given access to it.
+/// </summary>
+public class SharedManifestInfo
+{
+ /// <summary>Gets or sets the manifest id.</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the members holding a grant on this vault, i.e. the ones who can open it.</summary>
+ public List<string> MemberUserIds { get; set; } = [];
+
+ /// <summary>Gets or sets the offers of access to this vault still awaiting an answer (filled for admins only).</summary>
+ public List<SentManifestInvitation> PendingInvitations { get; set; } = [];
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
index 3320984e9..c350e4032 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
@@ -30,9 +30,6 @@ public class Manifest
/// <summary>Gets or sets the blob references this manifest revision needs (so the client can detect cache misses).</summary>
public List<BlobReference> BlobReferences { get; set; } = [];
- /// <summary>Gets or sets the plaintext display name of a shared manifest. Null for the personal manifest.</summary>
- public string? Name { get; set; }
-
/// <summary>
/// Gets or sets a value indicating whether the caller may administer this manifest's sharing: grant and revoke
/// access and publish its email delivery key. True when the caller is an owner or admin of the group that owns
diff --git a/core/models/src/webapi/Groups.ts b/core/models/src/webapi/Groups.ts
index 2c2d8f5ad..e05c3f759 100644
--- a/core/models/src/webapi/Groups.ts
+++ b/core/models/src/webapi/Groups.ts
@@ -1,7 +1,7 @@
import { VaultKeyAlgorithmValue } from './VaultKeyAlgorithm';
/**
- * The messages of the /v2/Groups API: the membership half of vault sharing.
+ * The messages of the /v2/Groups API: the sharing half of vault sharing.
*/
/**
@@ -16,28 +16,41 @@ export type GroupMemberInfo = {
userId: string;
username: string;
role: GroupRole;
+ publicKeyId: string | null;
+ publicKey: string | null;
}
/**
- * An invitation sent from a group that is still awaiting an answer.
+ * An offer of access to a shared vault that is still awaiting the recipient's answer.
*/
-export type SentGroupInvitation = {
+export type SentManifestInvitation = {
id: string;
+ inviteeUserId: string;
inviteeUsername: string;
createdAt: string;
}
/**
- * An open invitation addressed to this user.
+ * An open offer of access to a shared vault, addressed to this user.
*/
-export type ReceivedGroupInvitation = {
+export type ReceivedManifestInvitation = {
id: string;
groupId: string;
groupName: string;
+ manifestId: string;
inviterUsername: string;
createdAt: string;
}
+/**
+ * One shared vault owned by a group, with the members who can open it.
+ */
+export type SharedManifestInfo = {
+ manifestId: string;
+ memberUserIds: string[];
+ pendingInvitations: SentManifestInvitation[];
+}
+
/**
* One shared group this user belongs to.
*/
@@ -45,9 +58,8 @@ export type GroupInfo = {
groupId: string;
name: string;
role: GroupRole;
- manifestId: string | null;
+ manifests: SharedManifestInfo[];
members: GroupMemberInfo[];
- pendingInvitations: SentGroupInvitation[];
}
/**
@@ -55,22 +67,21 @@ export type GroupInfo = {
*/
export type GroupOverviewResponse = {
groups: GroupInfo[];
- receivedInvitations: ReceivedGroupInvitation[];
+ receivedInvitations: ReceivedManifestInvitation[];
}
/**
- * Create a shared group's vault.
+ * Create another shared vault for a group.
*/
export type CreateSharedManifestRequest = {
manifestId: string;
- name: string;
selfEncryptedVek: string;
selfPublicKey: string;
algorithm: VaultKeyAlgorithmValue;
}
/**
- * The created manifest, as served by POST /v2/Groups/{groupId}/manifest.
+ * The created vault, as served by POST /v2/Groups/{groupId}/manifests.
*/
export type CreateSharedManifestResponse = {
manifestId: string;
@@ -78,30 +89,7 @@ export type CreateSharedManifestResponse = {
}
/**
- * Ask which account a username belongs to, and which public key an invitation to it must be encrypted for.
- */
-export type GroupInvitationRecipientRequest = {
- username: string;
-}
-
-/**
- * A user a manifest VEK can be encrypted for, with the public key to encrypt it with.
- */
-export type GrantRecipient = {
- userId: string;
- publicKeyId: string;
- publicKey: string;
-}
-
-/**
- * The resolved recipient, as served by POST /v2/Groups/{groupId}/invitations/recipient.
- */
-export type GroupInvitationRecipientResponse = {
- recipient: GrantRecipient;
-}
-
-/**
- * One recipient's copy of a manifest VEK, encrypted for a public key of theirs.
+ * One recipient's copy of a shared vault's VEK, encrypted for a public key of theirs.
*/
export type ManifestGrant = {
recipientUserId: string;
@@ -110,17 +98,17 @@ export type ManifestGrant = {
}
/**
- * Invite an account to a group.
+ * Give a member of the group access to one of its shared vaults.
*/
-export type CreateGroupInvitationRequest = {
+export type GrantManifestAccessRequest = {
userId: string;
grant: ManifestGrant;
algorithm: VaultKeyAlgorithmValue;
}
/**
- * The sent invitation, as served by POST /v2/Groups/{groupId}/invitations.
+ * The created offer, as served by POST /v2/Groups/{groupId}/manifests/{manifestId}/access.
*/
-export type CreateGroupInvitationResponse = {
+export type GrantManifestAccessResponse = {
invitationId: string;
}