Skip to content

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

Add web app new identity code and family sharing helpers (#2536)

Leendert de Borst49d37e35fc22
diff --git a/apps/web/src/vault/VaultStore.ts b/apps/web/src/vault/VaultStore.ts
index 358d39048..7f8365bfe 100644
--- a/apps/web/src/vault/VaultStore.ts
+++ b/apps/web/src/vault/VaultStore.ts
@@ -517,6 +517,42 @@ export const vaultStore = {
return vaultSync.inviteToSharedManifest(groupId, manifestId, userId);
},
+ /**
+ * Find the account behind an identity code and check the code against its key, without inviting it.
+ * @param groupId - the family
+ * @param identityCode - the identity code the other person gave outside AliasVault
+ */
+ lookupIdentityCode(groupId: string, identityCode: string): Promise<SharingOperationResult> {
+ return vaultSync.lookupIdentityCode(groupId, identityCode);
+ },
+
+ /**
+ * Invite the account with the given identity code to a family, certifying its key first.
+ * @param groupId - the family
+ * @param identityCode - the identity code the other person gave outside AliasVault
+ */
+ inviteToGroup(groupId: string, identityCode: string): Promise<SharingOperationResult> {
+ return vaultSync.inviteToGroup(groupId, identityCode);
+ },
+
+ /**
+ * Accept an invitation to join a family, certifying the inviter's key with their identity code when not done before.
+ * @param invitationId - the invitation
+ * @param identityCode - the inviter's identity code
+ */
+ acceptGroupInvitation(invitationId: string, identityCode?: string): Promise<SharingOperationResult> {
+ return vaultSync.acceptGroupInvitation(invitationId, identityCode);
+ },
+
+ /**
+ * Accept an invitation to a shared manifest, signing its grant as this account's own.
+ * @param invitationId - the invitation
+ * @param identityCode - the inviter's identity code, when they are not certified yet
+ */
+ acceptSharedManifestInvitation(invitationId: string, identityCode?: string): Promise<SharingOperationResult> {
+ return vaultSync.acceptSharedManifestInvitation(invitationId, identityCode);
+ },
+
/**
* Change the details of a shared manifest (group administrators only).
* @param groupId - the group
diff --git a/core/client/src/api/errors/AppErrorCodes.ts b/core/client/src/api/errors/AppErrorCodes.ts
index 6c8a96b93..334dae686 100644
--- a/core/client/src/api/errors/AppErrorCodes.ts
+++ b/core/client/src/api/errors/AppErrorCodes.ts
@@ -56,6 +56,7 @@ export enum AppErrorCode {
BIOMETRIC_NOT_AVAILABLE = 'E-214',
BIOMETRIC_NOT_ENROLLED = 'E-215',
BIOMETRIC_LOCKOUT = 'E-216', // Too many failed biometric attempts
+ ACCOUNT_KEY_MISMATCH = 'E-217', // The account public key the server serves does not belong to this account's private key
// Item/credential operations (E-3xx)
ITEM_CREATE_FAILED = 'E-301',
diff --git a/core/client/src/auth/VaultKeyService.ts b/core/client/src/auth/VaultKeyService.ts
index 84f366c16..a6e096456 100644
--- a/core/client/src/auth/VaultKeyService.ts
+++ b/core/client/src/auth/VaultKeyService.ts
@@ -181,6 +181,13 @@ export class VaultKeyService {
return (await getPlatform().storage.get(StorageKeys.ACCOUNT_PUBLIC_KEY)) as string | null;
}
+ /**
+ * The cached account signing private key, encrypted with the Account Key, or null when the account has no signing key yet.
+ */
+ public static async getEncryptedSigningPrivateKey(): Promise<string | null> {
+ return (await getPlatform().storage.get(StorageKeys.ENCRYPTED_SIGNING_PRIVATE_KEY)) as string | null;
+ }
+
/**
* Persist the new account key after a local password change. The session stores the Account Key, which the change
* leaves as it is.
diff --git a/core/client/src/rust/RustCoreBinding.ts b/core/client/src/rust/RustCoreBinding.ts
index 868fa848c..14e1ec947 100644
--- a/core/client/src/rust/RustCoreBinding.ts
+++ b/core/client/src/rust/RustCoreBinding.ts
@@ -49,6 +49,7 @@ export interface IRustCore {
symmetricDecryptBytes(encrypted: Uint8Array, keyBase64: string): Promise<Uint8Array>;
symmetricEncryptBytes(plaintext: Uint8Array, keyBase64: string): Promise<Uint8Array>;
rsaDecrypt(base64Ciphertext: string, privateKeyJwk: string): Promise<Uint8Array>;
+ accountSigningKeyFingerprint(encryptedSigningPrivateKey: string, accountKeyBase64: string): Promise<string>;
pinGenerateSalt(): Promise<Uint8Array>;
pinEncrypt(pin: string, salt: Uint8Array, secret: Uint8Array): Promise<Uint8Array>;
diff --git a/core/client/src/rust/WasmRustCore.ts b/core/client/src/rust/WasmRustCore.ts
index edf12e24a..a7c6085ac 100644
--- a/core/client/src/rust/WasmRustCore.ts
+++ b/core/client/src/rust/WasmRustCore.ts
@@ -74,6 +74,7 @@ export function createWasmRustCore(loadWasm: WasmLoader): IRustCore {
symmetricDecryptBytes: (encrypted, keyBase64): Promise<Uint8Array> => ready(() => core.symmetricDecryptBytes(encrypted, keyBase64)),
symmetricEncryptBytes: (plaintext, keyBase64): Promise<Uint8Array> => ready(() => core.symmetricEncryptBytes(plaintext, keyBase64)),
rsaDecrypt: (base64Ciphertext, privateKeyJwk): Promise<Uint8Array> => ready(() => core.rsaDecrypt(base64Ciphertext, privateKeyJwk)),
+ accountSigningKeyFingerprint: (encryptedSigningPrivateKey, accountKeyBase64): Promise<string> => ready(() => core.accountSigningKeyFingerprint(encryptedSigningPrivateKey, accountKeyBase64)),
/*
* Argon2 (also behind pinEncrypt and pinDecrypt) blocks the thread it runs on for up to a few seconds on slow
diff --git a/core/client/src/sharing/FamilySharingView.ts b/core/client/src/sharing/FamilySharingView.ts
index 233404929..60c44866a 100644
--- a/core/client/src/sharing/FamilySharingView.ts
+++ b/core/client/src/sharing/FamilySharingView.ts
@@ -114,13 +114,85 @@ export function canAdministerGroup(group: Pick<GroupInfo, 'role'>): boolean {
}
/**
- * The viewer's own user id in a group, found through the roster because the API does not name the caller.
+ * Whether this account can delete the group, which only its owner may do.
* @param group - the group as served by the API.
- * @param username - the viewer's username.
- * @returns The user id, or an empty string when the roster does not list the viewer.
*/
-export function ownUserIdIn(group: Pick<GroupInfo, 'members'>, username: string | null | undefined): string {
- return group.members.find(member => member.username === username)?.userId ?? '';
+export function canDeleteGroup(group: Pick<GroupInfo, 'role'>): boolean {
+ return group.role === 'owner';
+}
+
+/**
+ * Whether this account can leave the group. The owner cannot: they delete it once it is empty instead.
+ * @param group - the group as served by the API.
+ */
+export function canLeaveGroup(group: Pick<GroupInfo, 'role'>): boolean {
+ return !canDeleteGroup(group);
+}
+
+/**
+ * What the family sharing screen shows of an overview: the viewer's user id, the one family they are in (the one they
+ * own, else the one they joined; a user is in one family at a time for now), the invitations to join a family (only
+ * shown outside one, as joining a second family is not offered) and the invitations to shared manifests of families
+ * the overview does not list.
+ * @param overview - the overview as served by the API.
+ */
+export function familyView(overview: GroupOverviewResponse | null): { myUserId: string; group: GroupInfo | null; joinInvitations: ReceivedGroupInvitation[]; orphanInvitations: ReceivedManifestInvitation[] } {
+ const allGroups = overview?.groups ?? [];
+ const group = allGroups.find(candidate => candidate.role === 'owner') ?? allGroups[0] ?? null;
+ const receivedInvitations = overview?.receivedInvitations ?? [];
+ return {
+ myUserId: overview?.userId ?? '',
+ group,
+ joinInvitations: group ? [] : overview?.receivedGroupInvitations ?? [],
+ orphanInvitations: receivedInvitations.filter(invitation => !allGroups.some(candidate => candidate.groupId.toLowerCase() === invitation.groupId.toLowerCase())),
+ };
+}
+
+/**
+ * Whether this account certified the inviter's key before, so the invitation takes no code.
+ * @param invitation - the invitation as served by the API.
+ */
+export function isInviterVerified(invitation: Pick<ReceivedManifestInvitation, 'inviterCertification'>): boolean {
+ return invitation.inviterCertification !== null;
+}
+
+/**
+ * Why a member cannot be handed a manifest key yet, or null when they can: the admin has not certified their key with
+ * their family code, or their account has no keys yet.
+ * @param member - the member as served by the API to an admin.
+ */
+export function memberKeyProblem(member: Pick<GroupMemberInfo, 'accountPublicKey' | 'signingPublicKey' | 'keyCertification'>): string | null {
+ if (!member.accountPublicKey || !member.signingPublicKey) {
+ return familySharingText.errors.userNotReady;
+ }
+ return member.keyCertification ? null : familySharingText.errors.memberNotVerified;
+}
+
+/**
+ * The notice after inviting by family code: the account was invited, or was a member already and is now verified.
+ * @param result - what the invite operation reported.
+ */
+export function inviteByCodeNotice(result: { username?: string | null; alreadyMember?: boolean }): string {
+ const invitee = result.username ?? '';
+ return result.alreadyMember ? familySharingText.memberVerified(invitee) : familySharingText.familyInvitationSent(invitee);
+}
+
+/**
+ * Whether the group is empty enough to be deleted: no shared manifests left and no other members.
+ * @param group - the group as served by the API.
+ */
+export function isGroupDeletable(group: Pick<GroupInfo, 'manifests' | 'members'>): boolean {
+ return group.manifests.length === 0 && group.members.length === 1;
+}
+
+/**
+ * Whether the viewer may take a member out of the group: admins remove anyone but themselves and the owner.
+ * @param group - the group as served by the API.
+ * @param member - the member.
+ * @param ownUserId - the viewer's user id.
+ */
+export function canRemoveMember(group: Pick<GroupInfo, 'role'>, member: Pick<GroupMemberInfo, 'userId' | 'role'>, ownUserId: string): boolean {
+ return canAdministerGroup(group) && member.userId !== ownUserId && member.role !== 'owner';
}
/**
@@ -155,7 +227,7 @@ export function describeMemberAccess(group: GroupInfo, manifest: SharedManifestI
canRevoke: hasAccess && !isSelf && isAdmin,
canWithdraw: invitation !== null && !isSelf && isAdmin,
canInvite: !hasAccess && invitation === null && !isSelf && isAdmin && holdsManifestKey(manifest, ownUserId),
- isReadyForInvite: Boolean(member.accountPublicKey),
+ isReadyForInvite: memberKeyProblem(member) === null,
};
}
diff --git a/core/client/src/sharing/SharingService.ts b/core/client/src/sharing/SharingService.ts
index 4b094c80e..4604d91b8 100644
--- a/core/client/src/sharing/SharingService.ts
+++ b/core/client/src/sharing/SharingService.ts
@@ -1,8 +1,9 @@
-import { VaultKeyAlgorithm, type DeleteSharedManifestInitiateResponse, type DeleteSharedManifestRequest, type GroupOverviewResponse, type ReceivedManifestInvitation } from '@aliasvault/models/webapi';
+import { VaultKeyAlgorithm, type CreateGroupResponse, type GroupOverviewResponse, type PasswordConfirmationChallenge, type PasswordConfirmationRequest, type ReceivedManifestInvitation } from '@aliasvault/models/webapi';
import { VaultKeyService } from '../auth/VaultKeyService';
import { EncryptionUtility } from '../crypto/EncryptionUtility';
import { devWarn } from '../platform/Logger';
+import { rustCore } from '../rust/RustCore';
import type { WebApiService } from '../api/WebApiService';
@@ -19,7 +20,7 @@ export type SharingApi = Pick<WebApiService, 'get' | 'post' | 'delete'>;
/**
* Proves the caller's master password to the server by answering its SRP challenge.
*/
-export type SrpChallengeResponder = (challenge: DeleteSharedManifestInitiateResponse) => Promise<DeleteSharedManifestRequest>;
+export type SrpChallengeResponder = (challenge: PasswordConfirmationChallenge) => Promise<PasswordConfirmationRequest>;
/**
* Decrypts a vault name encrypted into an invitation for the given public key, or returns null when this session holds no key that opens it.
@@ -30,6 +31,53 @@ export type InvitationNameDecryptor = (encryptedName: string, recipientPublicKey
* Service with static helpers implementing the vault sharing flows.
*/
export class SharingService {
+ /**
+ * This account's own identity code, derived from its signing private key; null while the vault is locked or the account has no signing key yet.
+ */
+ public static async ownIdentityCode(): Promise<string | null> {
+ const [accountKey, encryptedSigningPrivateKey] = await Promise.all([VaultKeyService.getSessionAccountKey(), VaultKeyService.getEncryptedSigningPrivateKey()]);
+ if (!accountKey || !encryptedSigningPrivateKey) {
+ return null;
+ }
+
+ try {
+ return await rustCore().accountSigningKeyFingerprint(encryptedSigningPrivateKey, accountKey);
+ } catch (error) {
+ devWarn('[Sharing] The own signing key did not open, so no identity code can be shown.', error);
+ return null;
+ }
+ }
+
+ /**
+ * Create a family (shared group) owned by this user. The server allows one per user.
+ * @param webApi - API client to reuse.
+ * @returns The new group's id.
+ */
+ public static async createGroup(webApi: SharingApi): Promise<string> {
+ return (await webApi.post<object, CreateGroupResponse>('Groups', {})).groupId;
+ }
+
+ /**
+ * Leave a family, giving up access to all of its shared manifests. The server requires proof of the caller's master
+ * password and refuses this for the family's owner.
+ * @param webApi - API client to reuse.
+ * @param groupId - the family to leave.
+ * @param answerChallenge - proves the master password, which each host derives its own way.
+ */
+ public static async leaveGroup(webApi: SharingApi, groupId: string, answerChallenge: SrpChallengeResponder): Promise<void> {
+ const challenge = await webApi.post<object, PasswordConfirmationChallenge>(`Groups/${groupId}/leave/initiate`, {});
+ await webApi.post<PasswordConfirmationRequest, void>(`Groups/${groupId}/leave/confirm`, await answerChallenge(challenge), false);
+ }
+
+ /**
+ * Delete a family this user owns. The server refuses this while it still has shared manifests or other members.
+ * @param webApi - API client to reuse.
+ * @param groupId - the family to delete.
+ */
+ public static async deleteGroup(webApi: SharingApi, groupId: string): Promise<void> {
+ await webApi.delete<void>(`Groups/${groupId}`);
+ }
+
/**
* The families this user belongs to, their shared manifests, and the invitations awaiting an answer.
* @param webApi - API client to reuse.
@@ -74,14 +122,42 @@ export class SharingService {
}
/**
- * Take a member's access to one shared manifest away, or hand back one's own. The server refuses the latter for group admins.
+ * Take a member out of the family, and with it their access to every shared manifest of the family. The server
+ * requires proof of the caller's master password.
+ * @param webApi - API client to reuse.
+ * @param groupId - the family.
+ * @param userId - the member to remove.
+ * @param answerChallenge - proves the master password, which each host derives its own way.
+ */
+ public static async removeMember(webApi: SharingApi, groupId: string, userId: string, answerChallenge: SrpChallengeResponder): Promise<void> {
+ const challenge = await webApi.post<object, PasswordConfirmationChallenge>(`Groups/${groupId}/members/${userId}/remove/initiate`, {});
+ await webApi.post<PasswordConfirmationRequest, void>(`Groups/${groupId}/members/${userId}/remove/confirm`, await answerChallenge(challenge), false);
+ }
+
+ /**
+ * Take another member's access to one shared manifest away. The server requires proof of the caller's master password.
* @param webApi - API client to reuse.
* @param groupId - the group the manifest belongs to.
* @param manifestId - the shared manifest.
* @param userId - the member losing access.
+ * @param answerChallenge - proves the master password, which each host derives its own way.
+ */
+ public static async revokeAccess(webApi: SharingApi, groupId: string, manifestId: string, userId: string, answerChallenge: SrpChallengeResponder): Promise<void> {
+ const challenge = await webApi.post<object, PasswordConfirmationChallenge>(`Groups/${groupId}/manifests/${manifestId}/access/${userId}/revoke/initiate`, {});
+ await webApi.post<PasswordConfirmationRequest, void>(`Groups/${groupId}/manifests/${manifestId}/access/${userId}/revoke/confirm`, await answerChallenge(challenge), false);
+ }
+
+ /**
+ * Hand back one's own access to a shared manifest. The server requires proof of the caller's master password and
+ * refuses this for group admins.
+ * @param webApi - API client to reuse.
+ * @param groupId - the group the manifest belongs to.
+ * @param manifestId - the shared manifest.
+ * @param answerChallenge - proves the master password, which each host derives its own way.
*/
- public static async revokeAccess(webApi: SharingApi, groupId: string, manifestId: string, userId: string): Promise<void> {
- await webApi.delete<void>(`Groups/${groupId}/manifests/${manifestId}/access/${userId}`);
+ public static async leaveSharedManifest(webApi: SharingApi, groupId: string, manifestId: string, answerChallenge: SrpChallengeResponder): Promise<void> {
+ const challenge = await webApi.post<object, PasswordConfirmationChallenge>(`Groups/${groupId}/manifests/${manifestId}/leave/initiate`, {});
+ await webApi.post<PasswordConfirmationRequest, void>(`Groups/${groupId}/manifests/${manifestId}/leave/confirm`, await answerChallenge(challenge), false);
}
/**
@@ -93,8 +169,8 @@ export class SharingService {
* @param answerChallenge - proves the master password, which each host derives its own way.
*/
public static async deleteSharedManifest(webApi: SharingApi, groupId: string, manifestId: string, answerChallenge: SrpChallengeResponder): Promise<void> {
- const challenge = await webApi.post<object, DeleteSharedManifestInitiateResponse>(`Groups/${groupId}/manifests/${manifestId}/delete/initiate`, {});
- await webApi.post<DeleteSharedManifestRequest, void>(`Groups/${groupId}/manifests/${manifestId}/delete/confirm`, await answerChallenge(challenge), false);
+ const challenge = await webApi.post<object, PasswordConfirmationChallenge>(`Groups/${groupId}/manifests/${manifestId}/delete/initiate`, {});
+ await webApi.post<PasswordConfirmationRequest, void>(`Groups/${groupId}/manifests/${manifestId}/delete/confirm`, await answerChallenge(challenge), false);
}
/**
@@ -106,15 +182,6 @@ export class SharingService {
await webApi.delete<void>(`Groups/invitations/${invitationId}`);
}
- /**
- * Accept an invitation addressed to this user, opening the shared manifest it names.
- * @param webApi - API client to reuse.
- * @param invitationId - the invitation to accept.
- */
- public static async acceptInvitation(webApi: SharingApi, invitationId: string): Promise<void> {
- await webApi.post<object, void>(`Groups/invitations/${invitationId}/accept`, {}, false);
- }
-
/**
* Decline an invitation addressed to this user.
* @param webApi - API client to reuse.
diff --git a/core/client/src/sync/VaultSync.ts b/core/client/src/sync/VaultSync.ts
index 66ddbac05..8103587fe 100644
--- a/core/client/src/sync/VaultSync.ts
+++ b/core/client/src/sync/VaultSync.ts
@@ -20,7 +20,7 @@ import { devError, devLog, devWarn } from '../platform/Logger';
import { VaultMigrationKind } from './VaultManifestMigration';
import { buildVaultSyncRequest, runVaultSyncEngine } from './VaultSyncEngine';
-import type { IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncKeyRotationParams, VaultSyncKeyRotationRefusal, VaultSyncKeyRotationResult, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
+import type { IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncKeyRotationParams, VaultSyncKeyRotationRefusal, VaultSyncKeyRotationResult, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingOperation, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
import type { SqliteClient } from '../database/SqliteClient';
import type { TranslationKey } from '@aliasvault/i18n';
@@ -78,6 +78,12 @@ export type KeyRotationOperationResult = SyncErrorDetail & {
*/
export type SharingOperationResult = SyncErrorDetail & {
success: boolean;
+ /** The shared manifest the operation created or invited to. */
+ manifestId?: string;
+ /** The account an identity code belonged to. */
+ username?: string;
+ /** The account was already a member of the family, so only its key was certified. */
+ alreadyMember?: boolean;
/** The API error code the server refused with, which the sharing screen has words for. */
apiErrorCode?: string;
/** The vault (or the account's key hierarchy) has to finish upgrading before it can be shared. */
@@ -209,6 +215,46 @@ export class VaultSync {
return this.runSharingOperation('updateSharedManifest', { groupId, manifestId, ...details });
}
+ /**
+ * Find the account behind an identity code and check the code against its key, so the admin can confirm who they invite.
+ * Certifies and invites nothing. Never throws.
+ * @param groupId - the family
+ * @param identityCode - the identity code the other person gave outside AliasVault
+ */
+ public async lookupIdentityCode(groupId: string, identityCode: string): Promise<SharingOperationResult> {
+ return this.runSharingOperation('lookupIdentityCode', { groupId, identityCode });
+ }
+
+ /**
+ * Invite the account with the given identity code to a family. The engine checks the key the server returns against
+ * the code, certifies it, and invites; an account already in the family is only certified. Never throws.
+ * @param groupId - the family
+ * @param identityCode - the identity code the other person gave outside AliasVault
+ */
+ public async inviteToGroup(groupId: string, identityCode: string): Promise<SharingOperationResult> {
+ return this.runSharingOperation('inviteToGroup', { groupId, identityCode });
+ }
+
+ /**
+ * Accept an invitation to join a family. The inviter's key has to be certified: with their identity code now, or from
+ * an earlier certification. Never throws.
+ * @param invitationId - the invitation
+ * @param identityCode - the inviter's identity code, when they are not certified yet
+ */
+ public async acceptGroupInvitation(invitationId: string, identityCode?: string): Promise<SharingOperationResult> {
+ return this.runSharingOperation('acceptGroupInvitation', { invitationId, identityCode });
+ }
+
+ /**
+ * Accept an invitation to a shared manifest: the engine checks the certified inviter signed it and signs the grant as
+ * this account's own. Never throws.
+ * @param invitationId - the invitation
+ * @param identityCode - the inviter's identity code, when they are not certified yet
+ */
+ public async acceptSharedManifestInvitation(invitationId: string, identityCode?: string): Promise<SharingOperationResult> {
+ return this.runSharingOperation('acceptSharedManifestInvitation', { invitationId, identityCode });
+ }
+
/**
* Rotate the account's keys: the engine re-encrypts the personal vault and rewraps every grant under new keys, which
* the server applies in one transaction. On success the vault and the cached chain are stored under the new keys. Never throws.
@@ -230,10 +276,10 @@ export class VaultSync {
* @param operation - the operation
* @param sharing - what it acts on
*/
- private async runSharingOperation(operation: VaultSyncOperation, sharing: VaultSyncSharingParams): Promise<SharingOperationResult> {
+ private async runSharingOperation(operation: VaultSyncSharingOperation, sharing: VaultSyncSharingParams): Promise<SharingOperationResult> {
try {
const result = await this.run<VaultSyncSharingResult>(operation, {}, { sharing });
- return { success: result.success, apiErrorCode: result.apiErrorCode, vaultUpgradeRequired: result.vaultUpgradeRequired, ...VaultSync.syncError(result) };
+ return { success: result.success, manifestId: result.manifestId, username: result.username, alreadyMember: result.alreadyMember, apiErrorCode: result.apiErrorCode, vaultUpgradeRequired: result.vaultUpgradeRequired, ...VaultSync.syncError(result) };
} catch (error) {
const detail = VaultSync.driverError(error);
devError(`[Sharing] ${operation} failed (${detail.errorCode ?? 'no code'}): ${detail.error ?? 'no detail'}`);
diff --git a/core/client/src/sync/VaultSyncEngine.ts b/core/client/src/sync/VaultSyncEngine.ts
index 8c109f1ec..236dbe56b 100644
--- a/core/client/src/sync/VaultSyncEngine.ts
+++ b/core/client/src/sync/VaultSyncEngine.ts
@@ -20,7 +20,10 @@ import type { StorageKey } from '../platform/KeyValueStore';
import type { ISqliteDatabase, SqliteValue } from '../platform/SqliteEngine';
/** The operations the engine runs. */
-export type VaultSyncOperation = 'fullSync' | 'migrationStatus' | 'migrateManifest' | 'statusCheck' | 'resolveVaultKey' | 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest' | 'rotateAccountKeys';
+/** The sharing operations, which take `VaultSyncSharingParams`. */
+export type VaultSyncSharingOperation = 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest' | 'lookupIdentityCode' | 'inviteToGroup' | 'acceptGroupInvitation' | 'acceptSharedManifestInvitation';
+
+export type VaultSyncOperation = 'fullSync' | 'migrationStatus' | 'migrateManifest' | 'statusCheck' | 'resolveVaultKey' | VaultSyncSharingOperation | 'rotateAccountKeys';
/** What a key rotation works with (the Rust `KeyRotationParams`): the password proof and the new unlock method come from the host. */
export type VaultSyncKeyRotationParams = {
@@ -40,10 +43,12 @@ export type VaultSyncKeyRotationParams = {
/** What a sharing operation acts on (the Rust `SharingParams`). */
export type VaultSyncSharingParams = {
- groupId: string;
+ groupId?: string;
manifestId?: string;
userId?: string;
name?: string;
+ invitationId?: string;
+ identityCode?: string;
};
/** What the host hands the engine at session start (the Rust `SyncRequest`). */
@@ -135,6 +140,8 @@ export type VaultSyncKeyRotationResult = VaultSyncEngineResultBase & {
export type VaultSyncSharingResult = VaultSyncEngineResultBase & {
success: boolean;
manifestId?: string;
+ username?: string;
+ alreadyMember: boolean;
apiErrorCode?: string;
vaultUpgradeRequired: boolean;
error?: string;
diff --git a/core/models/src/webapi/Groups.ts b/core/models/src/webapi/Groups.ts
index f354f31df..a956dfbab 100644
--- a/core/models/src/webapi/Groups.ts
+++ b/core/models/src/webapi/Groups.ts
@@ -20,6 +20,8 @@ export type GroupMemberInfo = {
accountPublicKey: string | null;
accountPublicKeySignature: string | null;
signingPublicKey: string | null;
+ /** The caller's own certification of `signingPublicKey`, for admins; the client verifies it itself. */
+ keyCertification: string | null;
}
/**
@@ -42,11 +44,17 @@ export type ReceivedManifestInvitation = {
inviterUsername: string;
inviterUserId: string;
createdAt: string;
+ keyVersion: number;
+ /** The vault's key encrypted for `recipientAccountPublicKey`; the invitee signs it as their grant when accepting. */
+ encryptedVek: string | null;
+ grantSignature: string | null;
encryptedName: string | null;
encryptedNameSignature: string | null;
signerPublicKey: string | null;
recipientAccountPublicKey: string | null;
algorithm: string;
+ /** The invitee's own certification of `signerPublicKey`, when they certified the inviter before. */
+ inviterCertification: string | null;
}
/**
@@ -67,14 +75,40 @@ export type GroupInfo = {
role: GroupRole;
manifests: SharedManifestInfo[];
members: GroupMemberInfo[];
+ /** The open invitations to join this group, for admins. */
+ pendingJoinInvitations: SentManifestInvitation[];
+}
+
+/**
+ * An open invitation to join a group, addressed to this user.
+ */
+export type ReceivedGroupInvitation = {
+ id: string;
+ groupId: string;
+ inviterUserId: string;
+ inviterUsername: string;
+ createdAt: string;
+ inviterSigningPublicKey: string | null;
+ /** The invitee's own certification of `inviterSigningPublicKey`, when they certified the inviter before. */
+ inviterCertification: string | null;
}
/**
* Everything the sharing screen renders, as served by GET /v2/Groups.
*/
export type GroupOverviewResponse = {
+ /** The caller's own user id. */
+ userId: string;
groups: GroupInfo[];
receivedInvitations: ReceivedManifestInvitation[];
+ receivedGroupInvitations: ReceivedGroupInvitation[];
+}
+
+/**
+ * The created group, as served by POST /v2/Groups.
+ */
+export type CreateGroupResponse = {
+ groupId: string;
}
/**
@@ -135,9 +169,9 @@ export type GrantManifestAccessResponse = {
}
/**
- * The SRP handshake served by POST /v2/Groups/{groupId}/manifests/{manifestId}/delete/initiate.
+ * The SRP handshake served by the initiate endpoints of the sharing actions confirmed with the master password.
*/
-export type DeleteSharedManifestInitiateResponse = {
+export type PasswordConfirmationChallenge = {
salt: string;
serverEphemeral: string;
encryptionType: string;
@@ -146,9 +180,9 @@ export type DeleteSharedManifestInitiateResponse = {
}
/**
- * Delete a shared manifest for good, carrying the SRP proof of the caller's master password.
+ * The SRP proof of the caller's master password, for the matching confirm endpoint.
*/
-export type DeleteSharedManifestRequest = {
+export type PasswordConfirmationRequest = {
clientPublicEphemeral: string;
clientSessionProof: string;
}