Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor all queries to include explicit manifestId in mobile app (#2159)
Leendert de Borst75a23c498a2c
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/AutofillDatasetBuilder.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/AutofillDatasetBuilder.ktindex 33839ba84..d0033be99 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/AutofillDatasetBuilder.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/AutofillDatasetBuilder.kt@@ -56,7 +56,7 @@ object AutofillDatasetBuilder {val bitmap = buildLogoBitmap(context, item, presentation)if (inlineSpec != null) {- val itemDeepLink = "aliasvault://items/${item.id.toString().lowercase()}"+ val itemDeepLink = "aliasvault://items/${item.manifestId}/${item.id.toString().lowercase()}"val attribIntent = InlinePresentationHelper.attributionPendingIntent(context = context,deepLinkUri = itemDeepLink,diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/InlinePresentationHelper.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/InlinePresentationHelper.ktindex 09ce59edb..a4aff6066 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/InlinePresentationHelper.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/InlinePresentationHelper.kt@@ -42,7 +42,7 @@ object InlinePresentationHelper {/*** Build a long-press attribution PendingIntent that opens the given- * deep link (e.g. `aliasvault://items/<id>`). [requestCode] should be+ * deep link (e.g. `aliasvault://items/<manifestId>/<id>`). [requestCode] should be* unique per destination so PendingIntent caching does not collapse* separate items onto the same intent.*/diff --git a/apps/mobile-app/app/(tabs)/emails/[id].tsx b/apps/mobile-app/app/(tabs)/emails/[id].tsxindex 34b88a603..560b54cbd 100644--- a/apps/mobile-app/app/(tabs)/emails/[id].tsx+++ b/apps/mobile-app/app/(tabs)/emails/[id].tsx@@ -15,6 +15,7 @@ import type { DisplayItem } from '@/utils/DisplayItem';import EncryptionUtility, { type DecryptedEmail } from '@/utils/EncryptionUtility';import emitter from '@/utils/EventEmitter';import { getFileForFilename } from '@/utils/FileUtility';+import { itemRoute } from '@/utils/ItemRoute';import { useAttachmentViewer } from '@/hooks/useAttachmentViewer';import { useColors } from '@/hooks/useColorScheme';@@ -92,8 +93,8 @@ export default function EmailDetailsScreen() : React.ReactNode {// Look up associated itemif (decryptedEmail.email.toLocal && decryptedEmail.email.toDomain) {const emailAddress = `${decryptedEmail.email.toLocal}@${decryptedEmail.email.toDomain}`;- const match = await dbContext.sqliteClient.items.findIdByEmail(emailAddress);- const item = match ? await dbContext.sqliteClient.items.getById(match.Id) : null;+ const match: { Id: string; ManifestId?: string } | null = await dbContext.sqliteClient.items.findIdByEmail(emailAddress);+ const item = match?.ManifestId ? await dbContext.sqliteClient.items.getById({ Id: match.Id, ManifestId: match.ManifestId }) : null;setAssociatedItem(item);}@@ -241,7 +242,7 @@ export default function EmailDetailsScreen() : React.ReactNode {*/const handleOpenItem = () : void => {if (associatedItem) {- router.push(`/(tabs)/items/${associatedItem.Id}`);+ router.push(itemRoute(associatedItem));}};diff --git a/apps/mobile-app/app/(tabs)/items/[id].tsx b/apps/mobile-app/app/(tabs)/items/[manifestId]/[id]/index.tsxsimilarity index 90%rename from apps/mobile-app/app/(tabs)/items/[id].tsxrename to apps/mobile-app/app/(tabs)/items/[manifestId]/[id]/index.tsxindex 03abcaa2d..1c193aed5 100644--- a/apps/mobile-app/app/(tabs)/items/[id].tsx+++ b/apps/mobile-app/app/(tabs)/items/[manifestId]/[id]/index.tsx@@ -1,3 +1,4 @@+import { scopedKey, type ItemRef } from '@aliasvault/client/database/ItemRef';import { FieldTypes, getFieldValue, FieldKey } from '@aliasvault/models/vault';import MaterialIcons from '@expo/vector-icons/MaterialIcons';import { useLocalSearchParams, useNavigation, useRouter } from 'expo-router';@@ -9,7 +10,8 @@ import Toast from 'react-native-toast-message';import { copyToClipboardWithExpiration } from '@/utils/ClipboardUtility';import type { DisplayItem } from '@/utils/DisplayItem';-import emitter from '@/utils/EventEmitter';+import emitter, { type ItemChangedEvent } from '@/utils/EventEmitter';+import { itemEditRoute } from '@/utils/ItemRoute';import { useColors } from '@/hooks/useColorScheme';import { useNavigationDebounce } from '@/hooks/useNavigationDebounce';@@ -40,7 +42,8 @@ import type { ContextMenuOnPressNativeEvent } from 'react-native-context-menu-vi* Item details screen.*/export default function ItemDetailsScreen() : React.ReactNode {- const { id } = useLocalSearchParams();+ const { id, manifestId } = useLocalSearchParams<{ manifestId: string; id: string }>();+ const [itemRef, setItemRef] = useState<ItemRef>({ Id: id, ManifestId: manifestId });const [item, setItem] = useState<DisplayItem | null>(null);const [isLoading, setIsLoading] = useState(true);const dbContext = useDb();@@ -54,8 +57,8 @@ export default function ItemDetailsScreen() : React.ReactNode {* Handle the edit button press.*/const handleEdit = useCallback(() : void => {- navigate(() => router.push(`/(tabs)/items/add-edit?id=${id}`));- }, [id, router, navigate]);+ navigate(() => router.push(itemEditRoute(itemRef)));+ }, [itemRef, router, navigate]);// Set header buttonsuseEffect(() => {@@ -96,12 +99,12 @@ export default function ItemDetailsScreen() : React.ReactNode {* Load the item.*/const loadItem = async () : Promise<void> => {- if (!dbContext.dbAvailable || !id) {+ if (!dbContext.dbAvailable) {return;}try {- const result = await dbContext.sqliteClient!.items.getById(id as string);+ const result = await dbContext.sqliteClient!.items.getById(itemRef);setItem(result);} catch (err) {console.error('Error loading item:', err);@@ -113,17 +116,23 @@ export default function ItemDetailsScreen() : React.ReactNode {loadItem();// Add listener for item changes- const itemChangedSub = emitter.addListener('credentialChanged', async (changedId: string) => {- if (changedId === id) {- await loadItem();+ const itemChangedSub = emitter.addListener('credentialChanged', async (change?: ItemChangedEvent) => {+ if (!change || scopedKey(change.previous.ManifestId, change.previous.Id) !== scopedKey(itemRef.ManifestId, itemRef.Id)) {+ return;+ }+ if (change.current && change.current.ManifestId !== itemRef.ManifestId) {+ // The edit moved the item to another manifest: follow it, which reloads.+ setItemRef(change.current);+ return;}+ await loadItem();});return () : void => {itemChangedSub.remove();Toast.hide();};- }, [id, dbContext.dbAvailable, dbContext.sqliteClient]);+ }, [itemRef, dbContext.dbAvailable, dbContext.sqliteClient]);if (isLoading) {return (@@ -284,7 +293,7 @@ export default function ItemDetailsScreen() : React.ReactNode {<ThemedContainer><ThemedScrollView>{/* Folder breadcrumb navigation */}- <FolderBreadcrumb folderId={item.FolderId} />+ <FolderBreadcrumb folder={item.FolderId ? { Id: item.FolderId, ManifestId: item.ManifestId } : null} /><ThemedView style={styles.header}><ItemIcon item={item} style={styles.logo} />diff --git a/apps/mobile-app/app/(tabs)/items/autofill-link-existing.tsx b/apps/mobile-app/app/(tabs)/items/autofill-link-existing.tsxindex 334d12a2e..b6b31b0d7 100644--- a/apps/mobile-app/app/(tabs)/items/autofill-link-existing.tsx+++ b/apps/mobile-app/app/(tabs)/items/autofill-link-existing.tsx@@ -1,3 +1,4 @@+import { scopedKey } from '@aliasvault/client/database/ItemRef';import {FieldKey,FieldTypes,@@ -179,7 +180,7 @@ export default function AutofillLinkExistingScreen(): React.ReactNode {};await executeVaultMutation(async () => {- await dbContext.sqliteClient!.items.update(itemToSave);+ await dbContext.sqliteClient!.items.update({ Id: item.Id, ManifestId: item.ManifestId }, itemToSave);});navigateToSuccess();@@ -369,7 +370,7 @@ export default function AutofillLinkExistingScreen(): React.ReactNode {<FlatListdata={filteredItems}- keyExtractor={item => item.Id}+ keyExtractor={item => scopedKey(item.ManifestId, item.Id)}renderItem={renderItem}contentContainerStyle={styles.listContent}keyboardShouldPersistTaps="handled"diff --git a/apps/mobile-app/app/(tabs)/items/deleted.tsx b/apps/mobile-app/app/(tabs)/items/deleted.tsxindex 189a0c351..6f1514c4f 100644--- a/apps/mobile-app/app/(tabs)/items/deleted.tsx+++ b/apps/mobile-app/app/(tabs)/items/deleted.tsx@@ -1,3 +1,4 @@+import { scopedKey, type ItemRef } from '@aliasvault/client/database/ItemRef';import { useFocusEffect } from 'expo-router';import { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -51,7 +52,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {const [items, setItems] = useState<DisplayItem<ItemWithDeletedAt>[]>([]);const [isLoadingItems, setIsLoadingItems] = useState(true);- const [selectedItemId, setSelectedItemId] = useState<string | null>(null);+ const [selectedItem, setSelectedItem] = useState<ItemRef | null>(null);const [showConfirmDelete, setShowConfirmDelete] = useState(false);const [showConfirmEmptyAll, setShowConfirmEmptyAll] = useState(false);@@ -89,13 +90,13 @@ export default function RecentlyDeletedScreen(): React.ReactNode {/*** Restore an item from Recently Deleted.*/- const handleRestore = useCallback(async (itemId: string): Promise<void> => {+ const handleRestore = useCallback(async (item: ItemRef): Promise<void> => {if (!dbContext.sqliteClient) {return;}await executeVaultMutation(async () => {- await dbContext.sqliteClient!.items.restore(itemId);+ await dbContext.sqliteClient!.items.restore(item);});await loadItems();@@ -111,24 +112,24 @@ export default function RecentlyDeletedScreen(): React.ReactNode {* Permanently delete an item.*/const handlePermanentDelete = useCallback(async (): Promise<void> => {- if (!dbContext.sqliteClient || !selectedItemId) {+ if (!dbContext.sqliteClient || !selectedItem) {return;}await executeVaultMutation(async () => {- await dbContext.sqliteClient!.items.permanentlyDelete(selectedItemId);+ await dbContext.sqliteClient!.items.permanentlyDelete(selectedItem);});await loadItems();emitter.emit('credentialChanged');setShowConfirmDelete(false);- setSelectedItemId(null);+ setSelectedItem(null);Toast.show({type: 'success',text1: t('items.recentlyDeleted.itemDeleted'),});- }, [dbContext.sqliteClient, executeVaultMutation, loadItems, selectedItemId, t]);+ }, [dbContext.sqliteClient, executeVaultMutation, loadItems, selectedItem, t]);/*** Empty all items from Recently Deleted (permanent delete all).@@ -140,7 +141,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {await executeVaultMutation(async () => {for (const item of items) {- await dbContext.sqliteClient!.items.permanentlyDelete(item.Id);+ await dbContext.sqliteClient!.items.permanentlyDelete(item);}});@@ -159,7 +160,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {*/const handleCloseDeleteModal = useCallback((): void => {setShowConfirmDelete(false);- setSelectedItemId(null);+ setSelectedItem(null);}, []);const styles = StyleSheet.create({@@ -274,7 +275,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {const daysRemaining = item.DeletedAt ? getDaysRemaining(item.DeletedAt) : TRASH_RETENTION_DAYS;return (- <View key={item.Id} style={styles.itemCard}>+ <View key={scopedKey(item.ManifestId, item.Id)} style={styles.itemCard}><View style={styles.itemContent}>{/* Item logo */}<ItemIcon item={item} style={styles.itemLogo} />@@ -298,7 +299,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {<View style={styles.itemActions}><TouchableOpacitystyle={styles.restoreButton}- onPress={() => handleRestore(item.Id)}+ onPress={() => handleRestore(item)}><Text style={styles.restoreButtonText}>{t('items.recentlyDeleted.restore')}@@ -307,7 +308,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {<TouchableOpacitystyle={styles.deleteButton}onPress={() => {- setSelectedItemId(item.Id);+ setSelectedItem({ Id: item.Id, ManifestId: item.ManifestId });setShowConfirmDelete(true);}}>@@ -365,7 +366,7 @@ export default function RecentlyDeletedScreen(): React.ReactNode {{/* Confirm Delete Modal */}<ConfirmDeleteModal- isOpen={showConfirmDelete && !!selectedItemId}+ isOpen={showConfirmDelete && !!selectedItem}onClose={handleCloseDeleteModal}onConfirm={handlePermanentDelete}title={t('items.recentlyDeleted.confirmDeleteTitle')}diff --git a/apps/mobile-app/app/(tabs)/settings/import-export.tsx b/apps/mobile-app/app/(tabs)/settings/import-export.tsxindex 12943660d..eccd669c8 100644--- a/apps/mobile-app/app/(tabs)/settings/import-export.tsx+++ b/apps/mobile-app/app/(tabs)/settings/import-export.tsx@@ -125,7 +125,7 @@ export default function ImportExportScreen(): React.ReactNode {*/for (const item of items) {// Get TOTP codes for this item- const totpCodes = await dbContext.sqliteClient?.items.getTotpCodesForItem(item.Id) ?? [];+ const totpCodes = await dbContext.sqliteClient?.items.getTotpCodesForItem(item) ?? [];const totpSecret = totpCodes.length > 0 ? totpCodes[0].SecretKey : '';/*diff --git a/apps/mobile-app/components/EmailCard.tsx b/apps/mobile-app/components/EmailCard.tsxindex 8b45b8c79..374324806 100644--- a/apps/mobile-app/components/EmailCard.tsx+++ b/apps/mobile-app/components/EmailCard.tsx@@ -43,8 +43,8 @@ export function EmailCard({ email }: EmailCardProps) : React.ReactNode {}const emailAddress = `${email.toLocal}@${email.toDomain}`;- const match = await dbContext.sqliteClient.items.findIdByEmail(emailAddress);- const item = match ? await dbContext.sqliteClient.items.getById(match.Id) : null;+ const match: { Id: string; ManifestId?: string } | null = await dbContext.sqliteClient.items.findIdByEmail(emailAddress);+ const item = match?.ManifestId ? await dbContext.sqliteClient.items.getById({ Id: match.Id, ManifestId: match.ManifestId }) : null;setAssociatedItem(item);};diff --git a/apps/mobile-app/components/folders/FolderBreadcrumb.tsx b/apps/mobile-app/components/folders/FolderBreadcrumb.tsxindex c9c180fbe..a419202e8 100644--- a/apps/mobile-app/components/folders/FolderBreadcrumb.tsx+++ b/apps/mobile-app/components/folders/FolderBreadcrumb.tsx@@ -7,8 +7,9 @@ import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';import { getFolderIdPath, getFolderPath } from '@aliasvault/client/items/FolderUtils';import { useColors } from '@/hooks/useColorScheme';import { useDb } from '@/context/DbContext';+import { folderRoute } from '@/utils/FolderRoute';-import type { Folder } from '@aliasvault/client/database/repositories/FolderRepository';+import type { Folder, FolderRef } from '@aliasvault/client/database/repositories/FolderRepository';type Breadcrumb = {name: string;@@ -17,10 +18,10 @@ type Breadcrumb = {type FolderBreadcrumbProps = {/**- * The ID of the current folder to show breadcrumbs for.+ * The current folder to show breadcrumbs for.* If null/undefined, no breadcrumbs are shown.*/- folderId: string | null | undefined;+ folder: FolderRef | null | undefined;/*** Optional root label for the first breadcrumb.* Defaults to 'items.title' translation key.@@ -44,7 +45,7 @@ type FolderBreadcrumbProps = {* Example: "Items > Work > Projects > Client A"*/export const FolderBreadcrumb: React.FC<FolderBreadcrumbProps> = ({- folderId,+ folder,rootLabel,excludeCurrentFolder = false,folders,@@ -54,6 +55,8 @@ export const FolderBreadcrumb: React.FC<FolderBreadcrumbProps> = ({const dbContext = useDb();const colors = useColors();const [loadedFolders, setLoadedFolders] = useState<Folder[]>([]);+ const folderId = folder?.Id ?? null;+ const manifestId = folder?.ManifestId ?? null;/*** Load the folders this trail is built from, unless the caller already passed them in.@@ -81,24 +84,27 @@ export const FolderBreadcrumb: React.FC<FolderBreadcrumbProps> = ({*/const breadcrumbs = useMemo((): Breadcrumb[] => {const allFolders = folders ?? loadedFolders;- if (!folderId || allFolders.length === 0) {+ if (!folderId || !manifestId || allFolders.length === 0) {return [];}- const folderNames = getFolderPath(folderId, allFolders);- const folderIds = getFolderIdPath(folderId, allFolders);+ const ref = { Id: folderId, ManifestId: manifestId };+ const folderNames = getFolderPath(ref, allFolders);+ const folderIds = getFolderIdPath(ref, allFolders);const fullPath = folderNames.map((name, index) => ({ name, id: folderIds[index] }));// If requested, exclude the current folder from breadcrumbsreturn excludeCurrentFolder ? fullPath.slice(0, -1) : fullPath;- }, [folders, loadedFolders, folderId, excludeCurrentFolder]);+ }, [folders, loadedFolders, folderId, manifestId, excludeCurrentFolder]);/**- * Handle breadcrumb navigation.+ * Handle breadcrumb navigation. Every folder on the trail shares the current folder's manifest.*/- const handleBreadcrumbClick = useCallback((folderId: string) => {- router.dismissTo(`/(tabs)/items/folder/${folderId}`);- }, [router]);+ const handleBreadcrumbClick = useCallback((crumbId: string) => {+ if (manifestId) {+ router.dismissTo(folderRoute({ Id: crumbId, ManifestId: manifestId }));+ }+ }, [router, manifestId]);/*** Handle root breadcrumb click (navigate to items list).@@ -109,7 +115,7 @@ export const FolderBreadcrumb: React.FC<FolderBreadcrumbProps> = ({/** Don't render anything if:- * 1. No folderId provided (item is at root level) - saves UI space+ * 1. No folder provided (item is at root level) - saves UI space*/if (!folderId) {return null;diff --git a/apps/mobile-app/components/folders/FolderPill.tsx b/apps/mobile-app/components/folders/FolderPill.tsxindex a2c70fbdf..1c21ae762 100644--- a/apps/mobile-app/components/folders/FolderPill.tsx+++ b/apps/mobile-app/components/folders/FolderPill.tsx@@ -9,6 +9,7 @@ import { useColors } from '@/hooks/useColorScheme';*/export type FolderWithCount = {id: string;+ manifestId: string;name: string;itemCount: number;isShared?: boolean;diff --git a/apps/mobile-app/components/form/ItemNameField.tsx b/apps/mobile-app/components/form/ItemNameField.tsxindex 4f8b77bea..3401f9889 100644--- a/apps/mobile-app/components/form/ItemNameField.tsx+++ b/apps/mobile-app/components/form/ItemNameField.tsx@@ -14,7 +14,7 @@ import { RobustPressable } from '@/components/ui/RobustPressable';import { useColors } from '@/hooks/useColorScheme';import { usePersonalManifestId } from '@/hooks/usePersonalManifestId';-import type { Folder } from '@aliasvault/client/database/repositories/FolderRepository';+import type { Folder, FolderRef } from '@aliasvault/client/database/repositories/FolderRepository';export interface ItemNameFieldRef {focus: () => void;@@ -24,8 +24,8 @@ interface IItemNameFieldProps {value: string;onChangeText: (text: string) => void;folders: Folder[];- selectedFolderId: string | null | undefined;- onFolderChange: (folderId: string | null) => void;+ selectedFolder: FolderRef | null | undefined;+ onFolderChange: (folder: FolderRef | null) => void;}/**@@ -39,7 +39,7 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((value,onChangeText,folders,- selectedFolderId,+ selectedFolder: selectedFolderRef,onFolderChange,}, ref) => {const { t } = useTranslation();@@ -58,7 +58,7 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((}));const hasFolders = folders.length > 0;- const selectedFolder = folders.find(f => f.Id === selectedFolderId);+ const selectedFolder = selectedFolderRef ? folders.find(f => f.Id === selectedFolderRef.Id && f.ManifestId === selectedFolderRef.ManifestId) : undefined;const styles = StyleSheet.create({container: {@@ -126,9 +126,9 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>((<FolderIconisShared={selectedFolder !== undefined && isSharedFolder(selectedFolder, personalManifestId)}size={18}- color={selectedFolderId ? colors.tint : colors.textMuted}+ color={selectedFolderRef ? colors.tint : colors.textMuted}/>- {selectedFolderId && selectedFolder && (+ {selectedFolder && (<Text style={styles.folderButtonText} numberOfLines={1}>{selectedFolder.Name}</Text>@@ -140,7 +140,7 @@ export const ItemNameField = forwardRef<ItemNameFieldRef, IItemNameFieldProps>(({/* Folder selector modal with tree view */}<FolderSelectorModalfolders={folders}- selectedFolderId={selectedFolderId}+ selectedFolder={selectedFolderRef}personalManifestId={personalManifestId}onFolderChange={onFolderChange}isOpen={showModal}diff --git a/apps/mobile-app/components/items/FieldHistoryModal.tsx b/apps/mobile-app/components/items/FieldHistoryModal.tsxindex e6533c4a7..9b88d7c0c 100644--- a/apps/mobile-app/components/items/FieldHistoryModal.tsx+++ b/apps/mobile-app/components/items/FieldHistoryModal.tsx@@ -10,6 +10,7 @@ import {} from 'react-native';import Toast from 'react-native-toast-message';+import type { ItemRef } from '@aliasvault/client/database/ItemRef';import type { FieldHistory, FieldType } from '@aliasvault/models/vault';import { FieldTypes } from '@aliasvault/models/vault';@@ -24,7 +25,7 @@ import { useDialog } from '@/context/DialogContext';type FieldHistoryModalProps = {isOpen: boolean;onClose: () => void;- itemId: string;+ item: ItemRef;fieldKey: string;fieldLabel: string;fieldType: FieldType;@@ -40,7 +41,7 @@ type FieldHistoryModalProps = {const FieldHistoryModal: React.FC<FieldHistoryModalProps> = ({isOpen,onClose,- itemId,+ item,fieldKey,fieldLabel,fieldType,@@ -63,14 +64,14 @@ const FieldHistoryModal: React.FC<FieldHistoryModalProps> = ({try {setLoading(true);- const historyRecords = await dbContext.sqliteClient.items.getFieldHistory(itemId, fieldKey);+ const historyRecords = await dbContext.sqliteClient.items.getFieldHistory({ Id: item.Id, ManifestId: item.ManifestId }, fieldKey);setHistory(historyRecords);} catch (error) {console.error('Error loading field history:', error);} finally {setLoading(false);}- }, [dbContext?.sqliteClient, itemId, fieldKey]);+ }, [dbContext?.sqliteClient, item.Id, item.ManifestId, fieldKey]);useEffect(() => {if (!isOpen) {@@ -119,7 +120,7 @@ const FieldHistoryModal: React.FC<FieldHistoryModalProps> = ({try {// Use vault mutation to delete and sync in backgroundawait executeVaultMutation(async () => {- await dbContext.sqliteClient!.items.deleteFieldHistory(historyId);+ await dbContext.sqliteClient!.items.deleteFieldHistory(historyId, item.ManifestId);});// Reload history after deletionawait loadHistory();diff --git a/apps/mobile-app/components/items/ItemCard.tsx b/apps/mobile-app/components/items/ItemCard.tsxindex 6aac271e8..1050c9d1c 100644--- a/apps/mobile-app/components/items/ItemCard.tsx+++ b/apps/mobile-app/components/items/ItemCard.tsx@@ -17,12 +17,14 @@ import { useColors } from '@/hooks/useColorScheme';import { useNavigationDebounce } from '@/hooks/useNavigationDebounce';import { copyToClipboardWithExpiration } from '@/utils/ClipboardUtility';import type { DisplayItem } from '@/utils/DisplayItem';+import { itemEditRoute, itemRoute } from '@/utils/ItemRoute';+import type { ItemRef } from '@aliasvault/client/database/ItemRef';import { getFieldValue, FieldKey } from '@aliasvault/models/vault';type ItemCardProps = {item: DisplayItem;- onItemDelete?: (itemId: string) => Promise<void>;- onItemDuplicate?: (itemId: string) => Promise<void>;+ onItemDelete?: (item: ItemRef) => Promise<void>;+ onItemDuplicate?: (item: ItemRef) => Promise<void>;showFolderPath?: boolean;isHighlighted?: boolean;};@@ -95,15 +97,12 @@ export function ItemCard({ item, onItemDelete, onItemDuplicate, showFolderPath =case t('items.contextMenu.edit'):navigate(() => {Keyboard.dismiss();- router.push({- pathname: '/(tabs)/items/add-edit',- params: { id: item.Id }- });+ router.push(itemEditRoute(item));});break;case t('items.contextMenu.duplicate'):if (onItemDuplicate) {- await onItemDuplicate(item.Id);+ await onItemDuplicate({ Id: item.Id, ManifestId: item.ManifestId });}break;case t('items.contextMenu.delete'):@@ -114,7 +113,7 @@ export function ItemCard({ item, onItemDelete, onItemDuplicate, showFolderPath =t('common.delete'),async () => {if (onItemDelete) {- await onItemDelete(item.Id);+ await onItemDelete({ Id: item.Id, ManifestId: item.ManifestId });}},{ confirmStyle: 'destructive' }@@ -169,7 +168,7 @@ export function ItemCard({ item, onItemDelete, onItemDuplicate, showFolderPath ={if (dbContext?.sqliteClient) {try {- const totpCodes = await dbContext.sqliteClient.items.getTotpCodesForItem(item.Id);+ const totpCodes = await dbContext.sqliteClient.items.getTotpCodesForItem(item);const activeTotp = totpCodes.find(tc => !tc.IsDeleted);if (activeTotp) {const code = await generateTotpCode(activeTotp.SecretKey, activeTotp);@@ -341,7 +340,7 @@ export function ItemCard({ item, onItemDelete, onItemDuplicate, showFolderPath =onPress={() => {navigate(() => {Keyboard.dismiss();- router.push(`/(tabs)/items/${item.Id}`);+ router.push(itemRoute(item));});}}onLongPress={() => {diff --git a/apps/mobile-app/components/items/details/AttachmentSection.tsx b/apps/mobile-app/components/items/details/AttachmentSection.tsxindex 7667d80a8..c111d02d2 100644--- a/apps/mobile-app/components/items/details/AttachmentSection.tsx+++ b/apps/mobile-app/components/items/details/AttachmentSection.tsx@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';import { View, StyleSheet, TouchableOpacity } from 'react-native';import type { Item, Attachment } from '@aliasvault/models/vault';-import emitter from '@/utils/EventEmitter';+import emitter, { type ItemChangedEvent } from '@/utils/EventEmitter';import { getFileForFilename } from '@/utils/FileUtility';import { useAttachmentViewer } from '@/hooks/useAttachmentViewer';@@ -71,19 +71,19 @@ export const AttachmentSection: React.FC<AttachmentSectionProps> = ({ item }): R}try {- const attachmentList = await dbContext.sqliteClient.items.getAttachmentsForItem(item.Id);+ const attachmentList = await dbContext.sqliteClient.items.getAttachmentsForItem({ Id: item.Id, ManifestId: item.ManifestId });blobsRef.current = new Map(attachmentList.map(attachment => [attachment.Id, attachment.Blob]));setAttachments(attachmentList.map(({ Blob: _blob, ...attachment }) => attachment));} catch (error) {console.error('Error loading attachments:', error);}- }, [item.Id, dbContext?.sqliteClient]);+ }, [item.Id, item.ManifestId, dbContext?.sqliteClient]);useEffect((): (() => void) => {loadAttachments();- const itemChangedSub = emitter.addListener('credentialChanged', async (changedId: string) => {- if (changedId === item.Id) {+ const itemChangedSub = emitter.addListener('credentialChanged', async (change?: ItemChangedEvent) => {+ if (change && change.previous.Id === item.Id && change.previous.ManifestId === item.ManifestId) {await loadAttachments();}});@@ -91,7 +91,7 @@ export const AttachmentSection: React.FC<AttachmentSectionProps> = ({ item }): Rreturn () => {itemChangedSub.remove();};- }, [item.Id, dbContext?.sqliteClient, loadAttachments]);+ }, [item.Id, item.ManifestId, dbContext?.sqliteClient, loadAttachments]);if (attachments.length === 0) {return null;diff --git a/apps/mobile-app/components/items/details/CardDetails.tsx b/apps/mobile-app/components/items/details/CardDetails.tsxindex 5d3fc5847..0e6152407 100644--- a/apps/mobile-app/components/items/details/CardDetails.tsx+++ b/apps/mobile-app/components/items/details/CardDetails.tsx@@ -40,7 +40,7 @@ export const CardDetails: React.FC<CardDetailsProps> = ({ item }): React.ReactNo<FieldBlockkey={field.FieldKey}field={field}- itemId={item.Id}+ item={item}/>))}</ThemedView>diff --git a/apps/mobile-app/components/items/details/CustomFieldsSection.tsx b/apps/mobile-app/components/items/details/CustomFieldsSection.tsxindex b7cb2068f..6fdab5e45 100644--- a/apps/mobile-app/components/items/details/CustomFieldsSection.tsx+++ b/apps/mobile-app/components/items/details/CustomFieldsSection.tsx@@ -26,7 +26,7 @@ export const CustomFieldsSection: React.FC<CustomFieldsSectionProps> = ({ item }<FieldBlockkey={field.FieldKey}field={field}- itemId={item.Id}+ item={item}/>))}</ThemedView>diff --git a/apps/mobile-app/components/items/details/FieldBlock.tsx b/apps/mobile-app/components/items/details/FieldBlock.tsxindex dd29958e7..63bb8061f 100644--- a/apps/mobile-app/components/items/details/FieldBlock.tsx+++ b/apps/mobile-app/components/items/details/FieldBlock.tsx@@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';import { View, Text, StyleSheet, TouchableOpacity, Linking } from 'react-native';+import type { ItemRef } from '@aliasvault/client/database/ItemRef';import type { ItemField } from '@aliasvault/models/vault';import { FieldTypes } from '@aliasvault/models/vault';@@ -14,7 +15,7 @@ import FieldHistoryModal from '@/components/items/FieldHistoryModal';type FieldBlockProps = {field: ItemField;- itemId?: string;+ item?: ItemRef;/** Whether to hide the label (useful when label is already shown as section header) */hideLabel?: boolean;}@@ -42,7 +43,9 @@ const extractUrls = (text: string): { url: string; start: number; end: number }[* Dynamic field block component that renders based on field type.* Supports all field types with automatic history tracking when enabled.*/-const FieldBlock: React.FC<FieldBlockProps> = ({ field, itemId, hideLabel = false }) => {+const FieldBlock: React.FC<FieldBlockProps> = ({ field, item, hideLabel = false }) => {+ const itemId = item?.Id;+ const itemManifestId = item?.ManifestId;const { t } = useTranslation();const colors = useColors();const dbContext = useDb();@@ -62,12 +65,12 @@ const FieldBlock: React.FC<FieldBlockProps> = ({ field, itemId, hideLabel = fals// 1. There are more than 1 history records, OR// 2. There is exactly 1 history record but its value differs from current valueuseEffect(() => {- if (hasHistoryEnabled && itemId && dbContext?.sqliteClient) {+ if (hasHistoryEnabled && itemId && itemManifestId && dbContext?.sqliteClient) {const checkHistory = async (): Promise<void> => {if (!dbContext.sqliteClient) return;try {- const history = await dbContext.sqliteClient.items.getFieldHistory(itemId, field.FieldKey);+ const history = await dbContext.sqliteClient.items.getFieldHistory({ Id: itemId, ManifestId: itemManifestId }, field.FieldKey);if (history.length > 1) {// Multiple history records - always show icon@@ -94,7 +97,7 @@ const FieldBlock: React.FC<FieldBlockProps> = ({ field, itemId, hideLabel = falsvoid checkHistory();}- }, [hasHistoryEnabled, itemId, field.FieldKey, field.Value, dbContext?.sqliteClient]);+ }, [hasHistoryEnabled, itemId, itemManifestId, field.FieldKey, field.Value, dbContext?.sqliteClient]);// Skip rendering if no valueif (!field.Value || (typeof field.Value === 'string' && field.Value.trim() === '')) {@@ -238,11 +241,11 @@ const FieldBlock: React.FC<FieldBlockProps> = ({ field, itemId, hideLabel = fals/*** Render history modal.*/- const HistoryModal = showHistoryModal && itemId ? (+ const HistoryModal = showHistoryModal && itemId && itemManifestId ? (<FieldHistoryModalisOpen={showHistoryModal}onClose={() => setShowHistoryModal(false)}- itemId={itemId}+ item={{ Id: itemId, ManifestId: itemManifestId }}fieldKey={field.FieldKey}fieldLabel={label}fieldType={field.FieldType}diff --git a/apps/mobile-app/components/items/details/LoginFields.tsx b/apps/mobile-app/components/items/details/LoginFields.tsxindex fbaaa318e..e72a9ae0a 100644--- a/apps/mobile-app/components/items/details/LoginFields.tsx+++ b/apps/mobile-app/components/items/details/LoginFields.tsx@@ -101,7 +101,7 @@ export const LoginFields: React.FC<LoginFieldsProps> = ({ item }) : React.ReactN<FieldBlockkey={field.FieldKey}field={field}- itemId={item.Id}+ item={item}/>))}diff --git a/apps/mobile-app/components/items/details/TotpSection.tsx b/apps/mobile-app/components/items/details/TotpSection.tsxindex 249585856..7a87515c3 100644--- a/apps/mobile-app/components/items/details/TotpSection.tsx+++ b/apps/mobile-app/components/items/details/TotpSection.tsx@@ -91,7 +91,7 @@ export const TotpSection: React.FC<TotpSectionProps> = ({ item }) : React.ReactN}try {- const codes = await dbContext.sqliteClient.items.getTotpCodesForItem(item.Id);+ const codes = await dbContext.sqliteClient.items.getTotpCodesForItem(item);setTotpCodes(codes);} catch (error) {console.error('Error loading TOTP codes:', error);diff --git a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swiftindex 9ce541e52..95b299523 100644--- a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift@@ -128,7 +128,7 @@ public struct AutofillCredentialCard: View {}Button(action: {- if let url = URL(string: "aliasvault://items/\(credential.id.uuidString.lowercased())") {+ if let url = URL(string: "aliasvault://items/\(credential.manifestId)/\(credential.id.uuidString.lowercased())") {UIApplication.shared.open(url)}}, label: {@@ -136,7 +136,7 @@ public struct AutofillCredentialCard: View {})Button(action: {- if let url = URL(string: "aliasvault://items/add-edit-page?id=\(credential.id.uuidString.lowercased())") {+ if let url = URL(string: "aliasvault://items/\(credential.manifestId)/\(credential.id.uuidString.lowercased())/edit-page") {UIApplication.shared.open(url)}}, label: {diff --git a/apps/mobile-app/utils/DeepLinkResolver.ts b/apps/mobile-app/utils/DeepLinkResolver.tsindex 74ecde00a..1b1da4a4f 100644--- a/apps/mobile-app/utils/DeepLinkResolver.ts+++ b/apps/mobile-app/utils/DeepLinkResolver.ts@@ -71,7 +71,7 @@ export function openActionRequiresVaultUnlock(actionSegments: string[]): boolean* Parse a deep-link URL and resolve into a post-unlock navigation target.** - `aliasvault://open/<action>/...` → `resolveOpenAction`- * - any other path (e.g. `aliasvault://items/abc`) → that route directly+ * - any other path (e.g. `aliasvault://items/<manifestId>/<id>`) → that route directly** Used by the root layout's cold-boot interceptor. The caller is responsible* for routing through /initialize before navigating to the returned target.diff --git a/apps/mobile-app/utils/DisplayItem.ts b/apps/mobile-app/utils/DisplayItem.tsindex b59e45844..a5d576062 100644--- a/apps/mobile-app/utils/DisplayItem.ts+++ b/apps/mobile-app/utils/DisplayItem.ts@@ -1,7 +1,9 @@import { Buffer } from 'buffer';import type { AsyncRepository } from '@aliasvault/client/database/DbOp';+import type { ItemRef } from '@aliasvault/client/database/ItemRef';import type { ItemWithArchivedAt, ItemWithDeletedAt } from '@aliasvault/client/database/mappers/ItemMapper';+import type { FolderRef } from '@aliasvault/client/database/repositories/FolderRepository';import type { ItemRepository } from '@aliasvault/client/database/repositories/ItemRepository';import type { Item } from '@aliasvault/models/vault';@@ -30,8 +32,8 @@ type ItemReads = 'getAll' | 'getByFolder' | 'getById' | 'getArchived' | 'getRece*/export type DisplayItemRepository = Omit<AsyncRepository<ItemRepository>, ItemReads> & {getAll(): Promise<DisplayItem[]>;- getByFolder(folderId: string, manifestId?: string): Promise<DisplayItem[]>;- getById(itemId: string, manifestId?: string): Promise<DisplayItem | null>;+ getByFolder(folder: FolderRef): Promise<DisplayItem[]>;+ getById(item: ItemRef): Promise<DisplayItem | null>;getArchived(): Promise<DisplayItem<ItemWithArchivedAt>[]>;getRecentlyDeleted(): Promise<DisplayItem<ItemWithDeletedAt>[]>;};@@ -42,9 +44,9 @@ export type DisplayItemRepository = Omit<AsyncRepository<ItemRepository>, ItemReexport function withDisplayItems(repository: AsyncRepository<ItemRepository>): DisplayItemRepository {const reads: Pick<DisplayItemRepository, ItemReads> = {getAll: async () => toDisplayItems(await repository.getAll()),- getByFolder: async (folderId, manifestId) => toDisplayItems(await repository.getByFolder(folderId, manifestId)),- getById: async (itemId, manifestId) => {- const item = await repository.getById(itemId, manifestId);+ getByFolder: async (folder) => toDisplayItems(await repository.getByFolder(folder)),+ getById: async (ref) => {+ const item = await repository.getById(ref);return item ? toDisplayItems([item])[0] : null;},getArchived: async () => toDisplayItems(await repository.getArchived()),diff --git a/apps/mobile-app/utils/PostUnlockNavigation.ts b/apps/mobile-app/utils/PostUnlockNavigation.tsindex 91a8f9013..6184acd2f 100644--- a/apps/mobile-app/utils/PostUnlockNavigation.ts+++ b/apps/mobile-app/utils/PostUnlockNavigation.ts@@ -102,7 +102,7 @@ export class PostUnlockNavigation {** Supports:* - Action-based URLs: aliasvault://open/mobile-unlock/[id]- * - Direct routes: aliasvault://items/[id], aliasvault://settings/[page]+ * - Direct routes: aliasvault://items/[manifestId]/[id], aliasvault://settings/[page]*/private static normalizeDeepLinkPath(urlOrPath: string): string {// Remove all URL schemes first