Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor cross-platform implementations to use same naming conventions
Leendert de Borstf69dcea8af00
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/ActiveSessionsSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/ActiveSessionsSettings.tsxindex 016d05fba..57696cab5 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/ActiveSessionsSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/ActiveSessionsSettings.tsx@@ -1,4 +1,4 @@-import { toLocalDisplayFormat } from '@aliasvault/client/utilities/DateFormatter';+import { toLocalDisplayFormat } from '@aliasvault/client/utilities/DateHelpers';import React, { useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsxindex 0b4e05458..3e2a4ce67 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx@@ -1,4 +1,4 @@-import { toLocalDisplayFormat } from '@aliasvault/client/utilities/DateFormatter';+import { toLocalDisplayFormat } from '@aliasvault/client/utilities/DateHelpers';import { authEventTypeName } from '@aliasvault/models/webapi';import React, { useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.ktindex b56fd379b..e2d5722a4 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyFormFragment.kt@@ -27,11 +27,11 @@ import net.aliasvault.app.exceptions.PasskeyOperationExceptionimport net.aliasvault.app.exceptions.VaultOperationExceptionimport net.aliasvault.app.utils.Helpersimport net.aliasvault.app.vaultstore.VaultStore+import net.aliasvault.app.vaultstore.mappers.PasskeyWithItemimport net.aliasvault.app.vaultstore.models.Passkeyimport net.aliasvault.app.vaultstore.passkey.PasskeyAuthenticatorimport net.aliasvault.app.vaultstore.passkey.PasskeyHelperimport net.aliasvault.app.vaultstore.repositories.ItemWithCredentialInfo-import net.aliasvault.app.vaultstore.repositories.PasskeyWithCredentialInfoimport net.aliasvault.app.webapi.WebApiServiceimport org.json.JSONObjectimport java.util.Date@@ -79,7 +79,7 @@ class PasskeyFormFragment : Fragment() {private var isReplace: Boolean = falseprivate var isMerge: Boolean = false- private var passkeyToReplace: PasskeyWithCredentialInfo? = null+ private var passkeyToReplace: PasskeyWithItem? = nullprivate var itemToMerge: ItemWithCredentialInfo? = null// UI elements@@ -455,7 +455,7 @@ class PasskeyFormFragment : Fragment() {/*** Replace an existing passkey flow.*/- private suspend fun replacePasskeyFlow(displayName: String, passkeyToReplace: PasskeyWithCredentialInfo) = withContext(Dispatchers.IO) {+ private suspend fun replacePasskeyFlow(displayName: String, passkeyToReplace: PasskeyWithItem) = withContext(Dispatchers.IO) {try {// Step 1: Sync vault before replacing passkey to ensure we have latest datawithContext(Dispatchers.Main) {diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/models/PasskeyRegistrationViewModel.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/models/PasskeyRegistrationViewModel.ktindex c7567ca77..07cc2bcca 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/models/PasskeyRegistrationViewModel.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/models/PasskeyRegistrationViewModel.kt@@ -1,8 +1,8 @@package net.aliasvault.app.credentialprovider.modelsimport androidx.lifecycle.ViewModel+import net.aliasvault.app.vaultstore.mappers.PasskeyWithItemimport net.aliasvault.app.vaultstore.repositories.ItemWithCredentialInfo-import net.aliasvault.app.vaultstore.repositories.PasskeyWithCredentialInfoimport java.util.UUID/**@@ -37,13 +37,13 @@ class PasskeyRegistrationViewModel : ViewModel() {var userId: ByteArray? = null/** List of existing passkeys for the relying party (can be replaced). */- var existingPasskeys: List<PasskeyWithCredentialInfo> = emptyList()+ var existingPasskeys: List<PasskeyWithItem> = emptyList()/** List of existing Items without passkeys (can have passkey merged into them). */var existingItemsWithoutPasskey: List<ItemWithCredentialInfo> = emptyList()/** The passkey selected to be replaced, if any. */- var selectedPasskeyToReplace: PasskeyWithCredentialInfo? = null+ var selectedPasskeyToReplace: PasskeyWithItem? = null/** The Item selected to add passkey to (merge), if any. */var selectedItemToMerge: ItemWithCredentialInfo? = null@@ -67,7 +67,7 @@ class PasskeyRegistrationViewModel : ViewModel() {/*** Called when the user selects to replace an existing passkey.*/- fun onReplaceSelected(passkeyInfo: PasskeyWithCredentialInfo) {+ fun onReplaceSelected(passkeyInfo: PasskeyWithItem) {isReplaceMode = trueisMergeMode = falseselectedPasskeyToReplace = passkeyInfo@@ -87,7 +87,7 @@ class PasskeyRegistrationViewModel : ViewModel() {/*** Get a passkey by its ID from the existing passkeys list.*/- fun getPasskeyById(id: UUID): PasskeyWithCredentialInfo? {+ fun getPasskeyById(id: UUID): PasskeyWithItem? {return existingPasskeys.firstOrNull { it.passkey.id == id }}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.ktindex 20ed14e86..96fd2f17f 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt@@ -38,6 +38,7 @@ import org.json.JSONObject* This class implements the NativeVaultManagerSpec React Native interface and then calls the* VaultStore class to perform the actual operations.*+ * Other platform implementations: NativeVaultManager.swift (iOS), spec in specs/NativeVaultManager.ts.* @param reactContext The React context*/@Suppress("TooManyFunctions") // Required by React Native TurboModule interface@@ -184,7 +185,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :@ReactMethodoverride fun getVaultMetadata(promise: Promise) {try {- val metadata = vaultStore.getMetadata()+ val metadata = vaultStore.getVaultMetadata()promise.resolve(metadata)} catch (e: Exception) {Log.e(TAG, "Error getting vault metadata", e)diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/DateHelpers.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/DateHelpers.ktindex cb46633f4..0d1148040 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/DateHelpers.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/DateHelpers.kt@@ -17,6 +17,7 @@ import java.util.TimeZone* - Consistent precision with milliseconds for accurate sorting/comparison* - Readable space separator instead of 'T'* - Lexicographic sorting works correctly+ * Other platform implementations: DateHelpers.ts (core/client), DateHelpers.swift (iOS).*/object DateHelpers {private const val TAG = "DateHelpers"@@ -26,11 +27,6 @@ object DateHelpers {*/private const val STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"- /**- * Birth date format (no milliseconds, time set to 00:00:00): "yyyy-MM-dd 00:00:00" (19 characters).- */- private const val BIRTH_DATE_FORMAT = "yyyy-MM-dd 00:00:00"-/*** Format a Date to the standard format string: "yyyy-MM-dd HH:mm:ss.SSS" (23 characters).*@@ -52,19 +48,6 @@ object DateHelpers {return toStandardFormat(Date())}- /**- * Format a Date to the birth date format (no milliseconds, time set to 00:00:00).- * Format: "yyyy-MM-dd 00:00:00" (19 characters).- *- * @param date The Date to format- * @return Formatted date string in format "yyyy-MM-dd 00:00:00"- */- fun toBirthDateFormat(date: Date): String {- val formatter = SimpleDateFormat(BIRTH_DATE_FORMAT, Locale.US)- formatter.timeZone = TimeZone.getTimeZone("UTC")- return formatter.format(date)- }-/*** Parse a date string to a Date object for use in queries.* Supports multiple formats for backward compatibility:diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpClipboard.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpClipboard.ktindex 6a58d54bc..d25aba4fc 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpClipboard.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpClipboard.kt@@ -41,7 +41,7 @@ object TotpClipboard {*/fun copyCodeForItem(context: Context, store: VaultStore, itemId: String, manifestId: String) {val totp = store.getTotpForItem(itemId, manifestId) ?: return- val code = TotpGenerator.generateCode(+ val code = TotpUtility.generateTotpCode(secret = totp.secretKey,period = totp.period,digits = totp.digits,diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpGenerator.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpUtility.ktsimilarity index 67%rename from apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpGenerator.ktrename to apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpUtility.ktindex 8fed8fdb6..e7239b7de 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpGenerator.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/utils/TotpUtility.kt@@ -1,11 +1,10 @@package net.aliasvault.app.utils-import uniffi.aliasvault_core.generateTotpCode-/*** Time-based One-Time Password (TOTP) codes, generated by the Rust core (`core/rust/src/totp`).+ * Other platform implementations: TotpUtility.ts (core/client), TotpUtility.swift (iOS).*/-object TotpGenerator {+object TotpUtility {private const val DEFAULT_PERIOD = 30private const val DEFAULT_DIGITS = 6private const val DEFAULT_ALGORITHM = "SHA1"@@ -14,11 +13,11 @@ object TotpGenerator {* Generate the TOTP code for a Base32-encoded secret.* Returns null when the secret is unusable.*/- fun generateCode(+ fun generateTotpCode(secret: String,timeSeconds: Long = System.currentTimeMillis() / 1000L,period: Int = DEFAULT_PERIOD,digits: Int = DEFAULT_DIGITS,algorithm: String = DEFAULT_ALGORITHM,- ): String? = generateTotpCode(secret, timeSeconds, algorithm, digits.coerceAtLeast(0).toUInt(), period.coerceAtLeast(0).toUInt())+ ): String? = uniffi.aliasvault_core.generateTotpCode(secret, timeSeconds, algorithm, digits.coerceAtLeast(0).toUInt(), period.coerceAtLeast(0).toUInt())}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/AppError.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/AppError.ktindex de50addd4..b37bc9d76 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/AppError.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/AppError.kt@@ -5,7 +5,7 @@ package net.aliasvault.app.vaultstore* These error codes are language-independent and can be properly handled by the client.** This is a Kotlin port of the iOS Swift implementation:- * - Reference: apps/mobile-app/ios/VaultStoreKit/Enums/AppErrorCodes.swift+ * - Reference: apps/mobile-app/ios/VaultStoreKit/Enums/AppError.swift** IMPORTANT: Keep all implementations synchronized. Changes to the public interface must be* reflected in all ports. Error types and codes should remain consistent.diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/LegacyKeyConversion.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/LegacyKeyConversion.ktindex 93a0306d7..ba606b1d6 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/LegacyKeyConversion.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/LegacyKeyConversion.kt@@ -21,7 +21,7 @@ internal object LegacyKeyConversion {/*** Re-encrypt the PIN with the Account Key when it still protected an unlock key.*/- fun convertPinKey(pin: VaultPin, pinValue: String, pinKey: String, accountKey: String) {+ fun convertLegacyPinKey(pin: VaultPin, pinValue: String, pinKey: String, accountKey: String) {if (accountKey == pinKey) {return}@@ -35,7 +35,7 @@ internal object LegacyKeyConversion {/*** Store the Account Key in the keystore when it still held an unlock key.*/- fun convertKeystoreKey(keystoreProvider: KeystoreProvider, keystoreKey: ByteArray, accountKey: ByteArray) {+ fun convertLegacyKeystoreKey(keystoreProvider: KeystoreProvider, keystoreKey: ByteArray, accountKey: ByteArray) {if (accountKey.contentEquals(keystoreKey)) {return}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultCrypto.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultCrypto.ktindex aefbdb385..069b20f67 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultCrypto.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultCrypto.kt@@ -298,7 +298,7 @@ class VaultCrypto(try {val keystoreKey = Base64.decode(result, Base64.NO_WRAP)openSession(keystoreKey)- accountKey?.let { LegacyKeyConversion.convertKeystoreKey(keystoreProvider, keystoreKey, it) }+ accountKey?.let { LegacyKeyConversion.convertLegacyKeystoreKey(keystoreProvider, keystoreKey, it) }callback.onSuccess(Base64.encodeToString(key(), Base64.NO_WRAP))} catch (e: AppError) {Log.e(TAG, "The Account Key from the keystore does not open the account key chain", e)diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultMetadataManager.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultMetadataManager.ktindex b63d00460..1a347afe4 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultMetadataManager.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultMetadataManager.kt@@ -30,7 +30,7 @@ class VaultMetadataManager(/*** Get the metadata from the storage provider.*/- fun getMetadata(): String {+ fun getVaultMetadata(): String {return storageProvider.getMetadata()}@@ -284,7 +284,7 @@ class VaultMetadataManager(* Get the vault metadata object.*/fun getVaultMetadataObject(): VaultMetadata? {- val metadataJson = getMetadata()+ val metadataJson = getVaultMetadata()if (metadataJson.isBlank()) {return null}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPasskey.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPasskey.ktindex 4799f34ef..293387f20 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPasskey.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPasskey.kt@@ -1,11 +1,11 @@package net.aliasvault.app.vaultstore+import net.aliasvault.app.vaultstore.mappers.PasskeyWithItemimport net.aliasvault.app.vaultstore.models.Itemimport net.aliasvault.app.vaultstore.models.Passkeyimport net.aliasvault.app.vaultstore.repositories.ItemWithCredentialInfo+import net.aliasvault.app.vaultstore.repositories.PasskeyAndItemimport net.aliasvault.app.vaultstore.repositories.PasskeyRepository-import net.aliasvault.app.vaultstore.repositories.PasskeyWithCredentialInfo-import net.aliasvault.app.vaultstore.repositories.PasskeyWithItemimport java.util.UUID/**@@ -33,14 +33,14 @@ class VaultPasskey(* Get all passkeys for an item.*/fun getPasskeysForItem(itemId: UUID, manifestId: String): List<Passkey> {- return passkeyRepository.getForItem(itemId, manifestId)+ return passkeyRepository.getByItemId(itemId, manifestId)}/*** Get all passkeys for a specific relying party identifier (RP ID).*/fun getPasskeysForRpId(rpId: String): List<Passkey> {- return passkeyRepository.getForRpId(rpId)+ return passkeyRepository.getByRpId(rpId)}/**@@ -51,8 +51,8 @@ class VaultPasskey(rpId: String,userName: String? = null,userId: ByteArray? = null,- ): List<PasskeyWithCredentialInfo> {- return passkeyRepository.getWithCredentialInfo(rpId, userName, userId)+ ): List<PasskeyWithItem> {+ return passkeyRepository.getWithItem(rpId, userName, userId)}/**@@ -77,7 +77,7 @@ class VaultPasskey(* This is much more efficient than calling getPasskeysForItem() for each item.* Uses a JOIN to get passkeys and their items in one database query.*/- fun getAllPasskeysWithItems(): List<PasskeyWithItem> {+ fun getAllPasskeysWithItems(): List<PasskeyAndItem> {return passkeyRepository.getAllWithItems()}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.ktindex db6e24ec9..7a4fab087 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultStore.kt@@ -565,8 +565,8 @@ class VaultStore(/*** Get the metadata.*/- fun getMetadata(): String {- return metadata.getMetadata()+ fun getVaultMetadata(): String {+ return metadata.getVaultMetadata()}/**@@ -821,14 +821,14 @@ class VaultStore(rpId: String,userName: String? = null,userId: ByteArray? = null,- ): List<net.aliasvault.app.vaultstore.repositories.PasskeyWithCredentialInfo> {+ ): List<net.aliasvault.app.vaultstore.mappers.PasskeyWithItem> {return passkey.getPasskeysWithCredentialInfo(rpId, userName, userId)}/*** Get all passkeys with their associated items in a single query.*/- fun getAllPasskeysWithItems(): List<net.aliasvault.app.vaultstore.repositories.PasskeyWithItem> {+ fun getAllPasskeysWithItems(): List<net.aliasvault.app.vaultstore.repositories.PasskeyAndItem> {return passkey.getAllPasskeysWithItems()}@@ -965,7 +965,7 @@ class VaultStore(val accountKey = crypto.openAccountKeyChain(android.util.Base64.decode(key, android.util.Base64.NO_WRAP)).accountKeyval accountKeyBase64 = android.util.Base64.encodeToString(accountKey, android.util.Base64.NO_WRAP)- LegacyKeyConversion.convertPinKey(pin, pinValue, key, accountKeyBase64)+ LegacyKeyConversion.convertLegacyPinKey(pin, pinValue, key, accountKeyBase64)return accountKeyBase64}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncEngine.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncEngine.ktindex a1f691a67..37c7f929d 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncEngine.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSyncEngine.kt@@ -20,6 +20,7 @@ import java.net.SocketTimeoutException* The engine owns the sync algorithm and emits commands (HTTP, state, SQLite, vault storage); this class carries* each one out and feeds the response back until the engine reports `done`. See the `vault_sync` module in* `core/rust` for the command and response contract.+ * Other platform implementations: VaultSyncEngine.ts (core/client), VaultSyncEngine.swift (iOS).*/class VaultSyncEngine(private val vaultStore: VaultStore,diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/FieldMapper.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/FieldMapper.ktnew file mode 100644index 000000000..6ad25aa20--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/FieldMapper.kt@@ -0,0 +1,128 @@+package net.aliasvault.app.vaultstore.mappers++import net.aliasvault.app.vaultstore.models.FieldKey+import net.aliasvault.app.vaultstore.models.FieldType+import net.aliasvault.app.vaultstore.models.ItemField+import net.aliasvault.app.vaultstore.repositories.scopedKey++/**+ * Raw field row from a database query.+ *+ * @property itemId The item the value belongs to.+ * @property manifestId The manifest the item lives in.+ * @property fieldKey The system field key, null for a custom field.+ * @property fieldDefinitionId The custom field definition, null for a system field.+ * @property customLabel The custom field's label.+ * @property customFieldType The custom field's type.+ * @property customIsHidden Whether the custom field is masked.+ * @property customEnableHistory Whether the custom field keeps a value history.+ * @property value The field value.+ * @property displayOrder The position of the field on the item.+ */+data class FieldRow(+ val itemId: String,+ val manifestId: String,+ val fieldKey: String?,+ val fieldDefinitionId: String?,+ val customLabel: String?,+ val customFieldType: String?,+ val customIsHidden: Boolean,+ val customEnableHistory: Boolean,+ val value: String,+ val displayOrder: Int,+) {+ companion object {+ /**+ * Read a row from a query result, or null when the item key is missing.+ */+ fun fromRow(row: Map<String, Any?>): FieldRow? {+ val itemId = row["ItemId"] as? String ?: return null+ val manifestId = row["ManifestId"] as? String ?: return null+ return FieldRow(+ itemId = itemId,+ manifestId = manifestId,+ fieldKey = row["FieldKey"] as? String,+ fieldDefinitionId = row["FieldDefinitionId"] as? String,+ customLabel = row["CustomLabel"] as? String,+ customFieldType = row["CustomFieldType"] as? String,+ customIsHidden = (row["CustomIsHidden"] as? Long) == 1L,+ customEnableHistory = (row["CustomEnableHistory"] as? Long) == 1L,+ value = row["Value"] as? String ?: "",+ displayOrder = (row["DisplayOrder"] as? Long)?.toInt() ?: 0,+ )+ }+ }+}++/**+ * Maps field rows to ItemField objects: system fields (FieldKey) get their metadata from the registry below,+ * custom fields (FieldDefinitionId) from the row.+ * Other platform implementations: FieldMapper.ts (core/client), FieldMapper.swift (iOS).+ */+object FieldMapper {+ /**+ * Resolved metadata of one field.+ */+ private data class FieldMetadata(+ val label: String,+ val fieldType: String,+ val isHidden: Boolean,+ val enableHistory: Boolean,+ )++ /**+ * Group field rows by scoped item key (see `scopedKey`). Multi-value fields keep one ItemField per row.+ */+ fun processFieldRows(rows: List<FieldRow>): Map<String, List<ItemField>> {+ val fieldsByItem = mutableMapOf<String, MutableList<ItemField>>()+ for (row in rows) {+ fieldsByItem.getOrPut(scopedKey(row.manifestId, row.itemId)) { mutableListOf() }.add(processFieldRow(row))+ }+ return fieldsByItem+ }++ private fun processFieldRow(row: FieldRow): ItemField {+ val isCustomField = row.fieldDefinitionId != null && row.fieldKey == null+ val fieldKey = row.fieldKey ?: row.fieldDefinitionId ?: ""+ val metadata = if (isCustomField) {+ FieldMetadata(row.customLabel ?: fieldKey, row.customFieldType ?: FieldType.TEXT, row.customIsHidden, row.customEnableHistory)+ } else {+ resolveSystemFieldMetadata(fieldKey)+ }+ return ItemField(+ fieldKey = fieldKey,+ label = metadata.label,+ fieldType = metadata.fieldType,+ value = row.value,+ isHidden = metadata.isHidden,+ displayOrder = row.displayOrder,+ isCustomField = isCustomField,+ enableHistory = metadata.enableHistory,+ )+ }++ /**+ * Metadata of a system field; an unknown key is shown as plain text under its own name.+ */+ @Suppress("CyclomaticComplexMethod")+ private fun resolveSystemFieldMetadata(fieldKey: String): FieldMetadata {+ return when (fieldKey) {+ FieldKey.LOGIN_USERNAME -> FieldMetadata("Username", FieldType.TEXT, false, false)+ FieldKey.LOGIN_PASSWORD -> FieldMetadata("Password", FieldType.PASSWORD, true, true)+ FieldKey.LOGIN_EMAIL -> FieldMetadata("Email", FieldType.EMAIL, false, false)+ FieldKey.LOGIN_URL -> FieldMetadata("URL", FieldType.U_R_L, false, false)+ FieldKey.CARD_NUMBER -> FieldMetadata("Card Number", FieldType.TEXT, true, false)+ FieldKey.CARD_CARDHOLDER_NAME -> FieldMetadata("Cardholder Name", FieldType.TEXT, false, false)+ FieldKey.CARD_EXPIRY_MONTH -> FieldMetadata("Expiry Month", FieldType.TEXT, false, false)+ FieldKey.CARD_EXPIRY_YEAR -> FieldMetadata("Expiry Year", FieldType.TEXT, false, false)+ FieldKey.CARD_CVV -> FieldMetadata("CVV", FieldType.PASSWORD, true, false)+ FieldKey.CARD_PIN -> FieldMetadata("PIN", FieldType.PASSWORD, true, false)+ FieldKey.ALIAS_FIRST_NAME -> FieldMetadata("First Name", FieldType.TEXT, false, false)+ FieldKey.ALIAS_LAST_NAME -> FieldMetadata("Last Name", FieldType.TEXT, false, false)+ FieldKey.ALIAS_GENDER -> FieldMetadata("Gender", FieldType.TEXT, false, false)+ FieldKey.ALIAS_BIRTHDATE -> FieldMetadata("Birth Date", FieldType.DATE, false, false)+ FieldKey.NOTES_CONTENT -> FieldMetadata("Notes", FieldType.TEXT_AREA, false, false)+ else -> FieldMetadata(fieldKey, FieldType.TEXT, false, false)+ }+ }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/ItemMapper.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/ItemMapper.ktnew file mode 100644index 000000000..056fce990--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/ItemMapper.kt@@ -0,0 +1,130 @@+package net.aliasvault.app.vaultstore.mappers++import net.aliasvault.app.utils.DateHelpers+import net.aliasvault.app.vaultstore.models.BuiltinLogos+import net.aliasvault.app.vaultstore.models.Item+import net.aliasvault.app.vaultstore.models.ItemField+import net.aliasvault.app.vaultstore.repositories.scopedKey+import java.util.Calendar+import java.util.Date+import java.util.TimeZone+import java.util.UUID++/**+ * Raw item row from a database query.+ *+ * @property id The item id.+ * @property manifestId The manifest the item lives in.+ * @property name The item name.+ * @property itemType The item type.+ * @property folderId The folder the item is in, if any.+ * @property logo The logo bytes, resolved from the built-in catalog when the logo is built in.+ * @property hasPasskey Whether the item has a live passkey.+ * @property hasAttachment Whether the item has a live attachment.+ * @property hasTotp Whether the item has a live TOTP code.+ * @property createdAt Creation timestamp text.+ * @property updatedAt Update timestamp text.+ */+data class ItemRow(+ val id: String,+ val manifestId: String,+ val name: String?,+ val itemType: String,+ val folderId: String?,+ val logo: ByteArray?,+ val hasPasskey: Boolean,+ val hasAttachment: Boolean,+ val hasTotp: Boolean,+ val createdAt: String,+ val updatedAt: String,+) {+ /**+ * The key this item's child rows are grouped under (see `scopedKey`).+ */+ val scopedItemKey: String+ get() = scopedKey(manifestId, id)++ companion object {+ private const val LOGO_KIND_BUILTIN = "builtin"++ /**+ * Read a row from a query result, or null when a required column is missing.+ */+ fun fromRow(row: Map<String, Any?>): ItemRow? {+ return ItemRow(+ id = row["Id"] as? String ?: return null,+ manifestId = row["ManifestId"] as? String ?: return null,+ name = row["Name"] as? String,+ itemType = row["ItemType"] as? String ?: return null,+ folderId = row["FolderId"] as? String,+ logo = resolveLogo(row),+ hasPasskey = (row["HasPasskey"] as? Long) == 1L,+ hasAttachment = (row["HasAttachment"] as? Long) == 1L,+ hasTotp = (row["HasTotp"] as? Long) == 1L,+ createdAt = row["CreatedAt"] as? String ?: "",+ updatedAt = row["UpdatedAt"] as? String ?: "",+ )+ }++ /**+ * The bytes an item's logo is drawn from. A built-in logo carries none: it is drawn from the shared catalog, keyed by its Source.+ */+ private fun resolveLogo(row: Map<String, Any?>): ByteArray? {+ if (row["LogoKind"] as? String == LOGO_KIND_BUILTIN) {+ return (row["LogoSource"] as? String)?.let { BuiltinLogos.svgFor(it) }?.toByteArray(Charsets.UTF_8)+ }+ return row["Logo"] as? ByteArray+ }+ }+}++/**+ * Maps item rows to Item objects.+ * Other platform implementations: ItemMapper.ts (core/client), ItemMapper.swift (iOS).+ */+object ItemMapper {+ /**+ * The date an unparseable timestamp falls back to.+ */+ val MIN_DATE: Date = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {+ set(Calendar.YEAR, 1)+ set(Calendar.MONTH, Calendar.JANUARY)+ set(Calendar.DAY_OF_MONTH, 1)+ set(Calendar.HOUR_OF_DAY, 0)+ set(Calendar.MINUTE, 0)+ set(Calendar.SECOND, 0)+ set(Calendar.MILLISECOND, 0)+ }.time++ /**+ * Map one item row to an Item with its fields and folder path.+ */+ fun mapRow(row: ItemRow, fields: List<ItemField> = emptyList(), folderPath: List<String>? = null): Item {+ return Item(+ id = UUID.fromString(row.id),+ manifestId = row.manifestId,+ name = row.name,+ itemType = row.itemType,+ logo = row.logo,+ folderId = row.folderId?.let { UUID.fromString(it) },+ folderPath = folderPath,+ fields = fields,+ hasPasskey = row.hasPasskey,+ hasAttachment = row.hasAttachment,+ hasTotp = row.hasTotp,+ createdAt = DateHelpers.parseDateString(row.createdAt) ?: MIN_DATE,+ updatedAt = DateHelpers.parseDateString(row.updatedAt) ?: MIN_DATE,+ )+ }++ /**+ * Map item rows to Items, joining the fields and folder paths by scoped key.+ */+ fun mapRows(rows: List<ItemRow>, fieldsByItem: Map<String, List<ItemField>>, folderPathsByFolderKey: Map<String, List<String>> = emptyMap()): List<Item> {+ return rows.map { row ->+ val fields = fieldsByItem[row.scopedItemKey] ?: emptyList()+ val folderPath = row.folderId?.let { folderPathsByFolderKey[scopedKey(row.manifestId, it)] }+ mapRow(row, fields, folderPath)+ }+ }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/PasskeyMapper.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/PasskeyMapper.ktnew file mode 100644index 000000000..16f784467--- /dev/null+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/mappers/PasskeyMapper.kt@@ -0,0 +1,160 @@+package net.aliasvault.app.vaultstore.mappers++import android.util.Log+import net.aliasvault.app.utils.DateHelpers+import net.aliasvault.app.vaultstore.models.Passkey+import java.util.UUID++/**+ * Raw passkey row from a database query.+ *+ * @property id The passkey id, also its WebAuthn credential id.+ * @property itemId The item the passkey belongs to.+ * @property manifestId The manifest the item lives in.+ * @property rpId The relying party id.+ * @property userHandle The WebAuthn user handle.+ * @property publicKey The public key as JWK text.+ * @property privateKey The private key as JWK text.+ * @property prfKey The PRF extension key.+ * @property displayName The display name.+ * @property additionalData Extra authenticator data.+ * @property createdAt Creation timestamp text.+ * @property updatedAt Update timestamp text.+ * @property isDeleted Whether the passkey is soft deleted.+ */+data class PasskeyRow(+ val id: String,+ val itemId: String,+ val manifestId: String,+ val rpId: String,+ val userHandle: ByteArray?,+ val publicKey: String,+ val privateKey: String,+ val prfKey: ByteArray?,+ val displayName: String,+ val additionalData: ByteArray?,+ val createdAt: String,+ val updatedAt: String,+ val isDeleted: Boolean,+) {+ companion object {+ /**+ * Read a row from a query result, or null when a required column is missing.+ */+ @Suppress("ReturnCount") // One early return per required column+ fun fromRow(row: Map<String, Any?>): PasskeyRow? {+ return PasskeyRow(+ id = row["Id"] as? String ?: return null,+ itemId = row["ItemId"] as? String ?: return null,+ manifestId = row["ManifestId"] as? String ?: return null,+ rpId = row["RpId"] as? String ?: return null,+ userHandle = row["UserHandle"] as? ByteArray,+ publicKey = row["PublicKey"] as? String ?: return null,+ privateKey = row["PrivateKey"] as? String ?: return null,+ prfKey = row["PrfKey"] as? ByteArray,+ displayName = row["DisplayName"] as? String ?: return null,+ additionalData = row["AdditionalData"] as? ByteArray,+ createdAt = row["CreatedAt"] as? String ?: return null,+ updatedAt = row["UpdatedAt"] as? String ?: return null,+ isDeleted = (row["IsDeleted"] as? Long) == 1L,+ )+ }+ }+}++/**+ * Passkey row joined with the display fields of its item.+ *+ * @property passkeyRow The passkey columns.+ * @property serviceName The item name.+ * @property username The item's login.username value.+ * @property email The item's login.email value.+ */+data class PasskeyWithItemRow(+ val passkeyRow: PasskeyRow,+ val serviceName: String?,+ val username: String?,+ val email: String?,+) {+ companion object {+ /**+ * Read a joined row from a query result, or null when the passkey columns are missing.+ */+ fun fromRow(row: Map<String, Any?>): PasskeyWithItemRow? {+ val passkeyRow = PasskeyRow.fromRow(row) ?: return null+ return PasskeyWithItemRow(passkeyRow, row["ServiceName"] as? String, row["Username"] as? String, row["Email"] as? String)+ }+ }+}++/**+ * A passkey with the display fields of its item.+ *+ * @property passkey The passkey.+ * @property serviceName The service name from the item.+ * @property username The username from the item.+ * @property email The email from the item, used as display fallback when there is no username.+ */+data class PasskeyWithItem(+ val passkey: Passkey,+ val serviceName: String?,+ val username: String?,+ val email: String? = null,+) {+ /** The account identifier to display: the username, or the email when no username is set. */+ val accountLabel: String?+ get() = username?.takeIf { it.isNotBlank() } ?: email?.takeIf { it.isNotBlank() }+}++/**+ * Maps passkey rows to Passkey objects.+ * Other platform implementations: PasskeyMapper.ts (core/client), PasskeyMapper.swift (iOS).+ */+object PasskeyMapper {+ private const val TAG = "PasskeyMapper"++ /**+ * Map one passkey row to a Passkey, or null when its ids are not valid UUIDs.+ */+ fun mapRow(row: PasskeyRow): Passkey? {+ return try {+ Passkey(+ id = UUID.fromString(row.id),+ parentItemId = UUID.fromString(row.itemId),+ manifestId = row.manifestId,+ rpId = row.rpId,+ userHandle = row.userHandle,+ userName = null,+ publicKey = row.publicKey.toByteArray(Charsets.UTF_8),+ privateKey = row.privateKey.toByteArray(Charsets.UTF_8),+ prfKey = row.prfKey,+ displayName = row.displayName,+ additionalData = row.additionalData,+ createdAt = DateHelpers.parseDateString(row.createdAt) ?: ItemMapper.MIN_DATE,+ updatedAt = DateHelpers.parseDateString(row.updatedAt) ?: ItemMapper.MIN_DATE,+ isDeleted = row.isDeleted,+ )+ } catch (e: IllegalArgumentException) {+ Log.e(TAG, "Invalid UUID in passkey row: id=${row.id}, itemId=${row.itemId}", e)+ null+ }+ }++ /**+ * Map passkey rows to Passkeys, skipping rows that do not map.+ */+ fun mapRows(rows: List<PasskeyRow>): List<Passkey> = rows.mapNotNull { mapRow(it) }++ /**+ * Map one joined row to a PasskeyWithItem.+ */+ fun mapRowWithItem(row: PasskeyWithItemRow): PasskeyWithItem? {+ val passkey = mapRow(row.passkeyRow) ?: return null+ return PasskeyWithItem(passkey, row.serviceName, row.username, row.email)+ }++ /**+ * Map joined rows to PasskeyWithItem objects, skipping rows that do not map.+ */+ fun mapRowsWithItem(rows: List<PasskeyWithItemRow>): List<PasskeyWithItem> = rows.mapNotNull { mapRowWithItem(it) }+}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/queries/ItemQueries.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/queries/ItemQueries.ktindex 295cfb3fc..112d7e5c6 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/queries/ItemQueries.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/queries/ItemQueries.kt@@ -80,13 +80,6 @@ object ItemQueries {WHERE ItemId = ? AND ManifestId = ? AND IsDeleted = 0"""- /**- * Get the database version from the __EFMigrationsHistory table.- */- const val GET_DATABASE_VERSION = """- SELECT MigrationId FROM __EFMigrationsHistory ORDER BY MigrationId DESC LIMIT 1- """-/*** Get folder data for building folder paths, one tree per manifest.*/diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/BaseRepository.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/BaseRepository.ktindex 18e63cf2e..57b9bf4a4 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/BaseRepository.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/BaseRepository.kt@@ -6,6 +6,13 @@ import net.aliasvault.app.vaultstore.VaultDatabaseimport net.aliasvault.app.vaultstore.models.VaultMutationScopeimport java.util.UUID+/**+ * The grouping key of a manifest-scoped row, for joining rows of one query to rows of another in memory.+ */+fun scopedKey(manifestId: String, id: String): String {+ return "${manifestId.lowercase()}${id.lowercase()}"+}+/*** Base repository class with common database operations.*/@@ -22,13 +29,6 @@ open class BaseRepository(return database.getPersonalManifestId() ?: throw AppError.ManifestNotRecorded()}- /**- * The grouping key of a manifest-scoped row, for joining rows of one query to rows of another in memory.- */- protected fun scopedKey(manifestId: String, id: String): String {- return "${manifestId.lowercase()}${id.lowercase()}"- }-// MARK: - Transaction Helpers/**diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/ItemRepository.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/ItemRepository.ktindex 1e7f5d5b3..4ca736454 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/ItemRepository.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/ItemRepository.kt@@ -1,52 +1,28 @@package net.aliasvault.app.vaultstore.repositoriesimport android.util.Log-import net.aliasvault.app.utils.DateHelpersimport net.aliasvault.app.vaultstore.VaultDatabase-import net.aliasvault.app.vaultstore.models.BuiltinLogos-import net.aliasvault.app.vaultstore.models.FieldKey-import net.aliasvault.app.vaultstore.models.FieldType+import net.aliasvault.app.vaultstore.mappers.FieldMapper+import net.aliasvault.app.vaultstore.mappers.FieldRow+import net.aliasvault.app.vaultstore.mappers.ItemMapper+import net.aliasvault.app.vaultstore.mappers.ItemRowimport net.aliasvault.app.vaultstore.models.Item-import net.aliasvault.app.vaultstore.models.ItemFieldimport net.aliasvault.app.vaultstore.models.TotpCodeimport net.aliasvault.app.vaultstore.queries.ItemQueriesimport net.aliasvault.app.vaultstore.utils.FolderUtils-import java.util.Calendar-import java.util.Date-import java.util.TimeZoneimport java.util.UUID/*** Repository for the item reads the autofill service needs.+ * Other platform implementations: ItemRepository.ts (core/client), ItemRepository.swift (iOS).*/class ItemRepository(database: VaultDatabase) : BaseRepository(database) {companion object {private const val TAG = "ItemRepository"- private const val LOGO_KIND_BUILTIN = "builtin"-- private val MIN_DATE: Date = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {- set(Calendar.YEAR, 1)- set(Calendar.MONTH, Calendar.JANUARY)- set(Calendar.DAY_OF_MONTH, 1)- set(Calendar.HOUR_OF_DAY, 0)- set(Calendar.MINUTE, 0)- set(Calendar.SECOND, 0)- set(Calendar.MILLISECOND, 0)- }.time}// MARK: - Read Operations- /**- * The bytes an item's logo is drawn from. A built-in logo carries none: it is drawn from the shared catalog, keyed by its Source.- */- private fun resolveLogo(row: Map<String, Any?>): ByteArray? {- if (row["LogoKind"] as? String == LOGO_KIND_BUILTIN) {- return (row["LogoSource"] as? String)?.let { BuiltinLogos.svgFor(it) }?.toByteArray(Charsets.UTF_8)- }- return row["Logo"] as? ByteArray- }-/*** Build folder paths for all folders, keyed by the folder's scoped key (manifest + id). The tree is walked* one manifest at a time: a parent link only ever resolves inside its own namespace.@@ -98,147 +74,19 @@ class ItemRepository(database: VaultDatabase) : BaseRepository(database) {** @return List of Item objects.*/- @Suppress("LongMethod", "NestedBlockDepth", "LoopWithTooManyJumpStatements")fun getAll(): List<Item> {- val items = mutableListOf<Item>()-- // Build folder paths- val folderPaths = buildFolderPaths()-- val itemResults = executeQuery(ItemQueries.GET_ALL_ACTIVE, emptyArray())- for (row in itemResults) {- try {- val idString = row["Id"] as? String ?: continue- val manifestId = row["ManifestId"] as? String ?: continue- val name = row["Name"] as? String- val itemType = row["ItemType"] as? String ?: continue- val folderId = row["FolderId"] as? String- val logo = resolveLogo(row)- val hasPasskey = (row["HasPasskey"] as? Long) == 1L- val hasAttachment = (row["HasAttachment"] as? Long) == 1L- val hasTotp = (row["HasTotp"] as? Long) == 1L- val createdAt = DateHelpers.parseDateString(row["CreatedAt"] as? String ?: "") ?: MIN_DATE- val updatedAt = DateHelpers.parseDateString(row["UpdatedAt"] as? String ?: "") ?: MIN_DATE-- // Get folder path if item is in a folder- val folderUuid = folderId?.let { UUID.fromString(it) }- val folderPath = folderId?.let { folderPaths[scopedKey(manifestId, it)] }-- items.add(- Item(- id = UUID.fromString(idString),- manifestId = manifestId,- name = name,- itemType = itemType,- logo = logo,- folderId = folderUuid,- folderPath = folderPath,- fields = emptyList(), // Will be populated below- hasPasskey = hasPasskey,- hasAttachment = hasAttachment,- hasTotp = hasTotp,- createdAt = createdAt,- updatedAt = updatedAt,- ),- )- } catch (e: Exception) {- Log.e(TAG, "Error parsing item row", e)- }- }-- // If no items, return empty list- if (items.isEmpty()) {+ val itemRows = executeQuery(ItemQueries.GET_ALL_ACTIVE, emptyArray()).mapNotNull { ItemRow.fromRow(it) }+ if (itemRows.isEmpty()) {return emptyList()}- // Get all field values for these items, matched on the whole (manifest, id) key- val fieldQuery = ItemQueries.getFieldValuesForItems(items.size)- val keyBindings = items.flatMap { listOf<Any?>(it.manifestId, it.id.toString().lowercase()) }.toTypedArray()-- // Build a map of scoped item key -> [ItemField]- val fieldsByItem = mutableMapOf<String, MutableList<ItemField>>()-- val fieldResults = executeQuery(fieldQuery, keyBindings)- for (row in fieldResults) {- try {- val itemIdString = row["ItemId"] as? String ?: continue- val manifestId = row["ManifestId"] as? String ?: continue- val fieldKey = row["FieldKey"] as? String- val fieldDefinitionId = row["FieldDefinitionId"] as? String- val customLabel = row["CustomLabel"] as? String- val customFieldType = row["CustomFieldType"] as? String- val customIsHidden = (row["CustomIsHidden"] as? Long) == 1L- val customEnableHistory = (row["CustomEnableHistory"] as? Long) == 1L- val value = row["Value"] as? String ?: ""- val displayOrder = (row["DisplayOrder"] as? Long)?.toInt() ?: 0-- // Determine if this is a custom field- val isCustomField = fieldDefinitionId != null && fieldKey == null-- // Resolve the effective field key- val effectiveFieldKey = fieldKey ?: fieldDefinitionId ?: ""-- // Resolve field metadata- val metadata = resolveFieldMetadata(- fieldKey = effectiveFieldKey,- customLabel = customLabel,- customFieldType = customFieldType,- customIsHidden = customIsHidden,- customEnableHistory = customEnableHistory,- isCustomField = isCustomField,- )-- val field = ItemField(- fieldKey = effectiveFieldKey,- label = metadata.label,- fieldType = metadata.fieldType,- value = value,- isHidden = metadata.isHidden,- displayOrder = displayOrder,- isCustomField = isCustomField,- enableHistory = metadata.enableHistory,- )-- fieldsByItem.getOrPut(scopedKey(manifestId, itemIdString)) { mutableListOf() }.add(field)- } catch (e: Exception) {- Log.e(TAG, "Error parsing field row", e)- }- }-- // Assign fields to items- return items.map { item ->- val fields = fieldsByItem[scopedKey(item.manifestId, item.id.toString())] ?: emptyList()- item.copy(fields = fields)- }- }-- /**- * Get the database version from the __EFMigrationsHistory table.- *- * @return Database version string (e.g., "1.0.0").- */- fun getDatabaseVersion(): String {- val results = executeQuery(ItemQueries.GET_DATABASE_VERSION, emptyArray())-- if (results.isEmpty()) {- Log.d(TAG, "No migrations found in database, returning default version")- return "0.0.0"- }-- val migrationId = results[0]["MigrationId"] as? String- if (migrationId == null) {- return "0.0.0"- }-- val versionRegex = Regex("_(\\d+\\.\\d+\\.\\d+)-")- val match = versionRegex.find(migrationId)+ // Fields are matched on the whole (ManifestId, Id) key, bound as one pair per item.+ val keyBindings = itemRows.flatMap { listOf<Any?>(it.manifestId, it.id.lowercase()) }.toTypedArray()+ val fieldRows = executeQuery(ItemQueries.getFieldValuesForItems(itemRows.size), keyBindings).mapNotNull { FieldRow.fromRow(it) }+ val fieldsByItem = FieldMapper.processFieldRows(fieldRows)+ val folderPaths = buildFolderPaths()- return if (match != null && match.groupValues.size > 1) {- match.groupValues[1]- } else {- Log.d(TAG, "Could not extract version from migration ID '$migrationId', returning default")- "0.0.0"- }+ return ItemMapper.mapRows(itemRows, fieldsByItem, folderPaths)}/**@@ -262,59 +110,4 @@ class ItemRepository(database: VaultDatabase) : BaseRepository(database) {period = (row["Period"] as? Long)?.toInt() ?: TotpCode.DEFAULT_PERIOD,)}-- // MARK: - Helper Methods-- /**- * Helper class to hold resolved field metadata.- */- private data class FieldMetadata(- val label: String,- val fieldType: String,- val isHidden: Boolean,- val enableHistory: Boolean,- )-- /**- * Resolve field metadata for system fields and custom fields.- */- @Suppress("CyclomaticComplexMethod", "LongParameterList")- // LongParameterList suppressed: All parameters are needed to determine field metadata- private fun resolveFieldMetadata(- fieldKey: String,- customLabel: String?,- customFieldType: String?,- customIsHidden: Boolean,- customEnableHistory: Boolean,- isCustomField: Boolean,- ): FieldMetadata {- if (isCustomField) {- return FieldMetadata(- label = customLabel ?: fieldKey,- fieldType = customFieldType ?: FieldType.TEXT,- isHidden = customIsHidden,- enableHistory = customEnableHistory,- )- }-- // System field metadata based on FieldKey constants- return when (fieldKey) {- FieldKey.LOGIN_USERNAME -> FieldMetadata("Username", FieldType.TEXT, false, false)- FieldKey.LOGIN_PASSWORD -> FieldMetadata("Password", FieldType.PASSWORD, true, true)- FieldKey.LOGIN_EMAIL -> FieldMetadata("Email", FieldType.EMAIL, false, false)- FieldKey.LOGIN_URL -> FieldMetadata("URL", FieldType.U_R_L, false, false)- FieldKey.CARD_NUMBER -> FieldMetadata("Card Number", FieldType.TEXT, true, false)- FieldKey.CARD_CARDHOLDER_NAME -> FieldMetadata("Cardholder Name", FieldType.TEXT, false, false)- FieldKey.CARD_EXPIRY_MONTH -> FieldMetadata("Expiry Month", FieldType.TEXT, false, false)- FieldKey.CARD_EXPIRY_YEAR -> FieldMetadata("Expiry Year", FieldType.TEXT, false, false)- FieldKey.CARD_CVV -> FieldMetadata("CVV", FieldType.PASSWORD, true, false)- FieldKey.CARD_PIN -> FieldMetadata("PIN", FieldType.PASSWORD, true, false)- FieldKey.ALIAS_FIRST_NAME -> FieldMetadata("First Name", FieldType.TEXT, false, false)- FieldKey.ALIAS_LAST_NAME -> FieldMetadata("Last Name", FieldType.TEXT, false, false)- FieldKey.ALIAS_GENDER -> FieldMetadata("Gender", FieldType.TEXT, false, false)- FieldKey.ALIAS_BIRTHDATE -> FieldMetadata("Birth Date", FieldType.DATE, false, false)- FieldKey.NOTES_CONTENT -> FieldMetadata("Notes", FieldType.TEXT_AREA, false, false)- else -> FieldMetadata(fieldKey, FieldType.TEXT, false, false)- }- }}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/PasskeyRepository.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/PasskeyRepository.ktindex 7c9404e43..28e515522 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/PasskeyRepository.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/repositories/PasskeyRepository.kt@@ -4,6 +4,11 @@ import android.util.Logimport net.aliasvault.app.autofill.utils.RustItemMatcherimport net.aliasvault.app.utils.DateHelpersimport net.aliasvault.app.vaultstore.VaultDatabase+import net.aliasvault.app.vaultstore.mappers.ItemMapper+import net.aliasvault.app.vaultstore.mappers.PasskeyMapper+import net.aliasvault.app.vaultstore.mappers.PasskeyRow+import net.aliasvault.app.vaultstore.mappers.PasskeyWithItem+import net.aliasvault.app.vaultstore.mappers.PasskeyWithItemRowimport net.aliasvault.app.vaultstore.models.FieldKeyimport net.aliasvault.app.vaultstore.models.Itemimport net.aliasvault.app.vaultstore.models.Passkey@@ -12,13 +17,12 @@ import net.aliasvault.app.vaultstore.queries.LogoQueriesimport net.aliasvault.app.vaultstore.queries.PasskeyQueriesimport uniffi.aliasvault_core.faviconSourceKeyimport uniffi.aliasvault_core.vaultCodecLogoIdFor-import java.util.Calendarimport java.util.Date-import java.util.TimeZoneimport java.util.UUID/*** Repository for Passkey operations on Items.+ * Other platform implementations: PasskeyRepository.ts (core/client), PasskeyRepository.swift (iOS).*/class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {companion object {@@ -32,16 +36,6 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {*/private const val LOGIN_URL_WEIGHT = 5private const val LOGIN_USERNAME_WEIGHT = 15-- private val MIN_DATE: Date = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {- set(Calendar.YEAR, 1)- set(Calendar.MONTH, Calendar.JANUARY)- set(Calendar.DAY_OF_MONTH, 1)- set(Calendar.HOUR_OF_DAY, 0)- set(Calendar.MINUTE, 0)- set(Calendar.SECOND, 0)- set(Calendar.MILLISECOND, 0)- }.time}/**@@ -74,7 +68,7 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {* @param manifestId The manifest the item belongs to* @return List of Passkey objects*/- fun getForItem(itemId: UUID, manifestId: String): List<Passkey> {+ fun getByItemId(itemId: UUID, manifestId: String): List<Passkey> {val results = executeQuery(PasskeyQueries.GET_BY_ITEM_ID, arrayOf(itemId.toString().lowercase(), manifestId))return results.mapNotNull { parsePasskeyRow(it) }}@@ -84,7 +78,7 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {* @param rpId The relying party identifier* @return List of Passkey objects*/- fun getForRpId(rpId: String): List<Passkey> {+ fun getByRpId(rpId: String): List<Passkey> {val results = executeQuery(PasskeyQueries.GET_BY_RP_ID, arrayOf(rpId))return results.mapNotNull { parsePasskeyRow(it) }}@@ -274,30 +268,21 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {* @param rpId The relying party identifier.* @param userName Optional username to filter by.* @param userId Optional user ID bytes to filter by.- * @return List of PasskeyWithCredentialInfo objects.+ * @return List of PasskeyAndItem objects.*/- fun getWithCredentialInfo(+ fun getWithItem(rpId: String,userName: String? = null,userId: ByteArray? = null,- ): List<PasskeyWithCredentialInfo> {+ ): List<PasskeyWithItem> {if (!database.isOpen()) return emptyList()- return executeQuery(PasskeyQueries.GET_BY_RP_ID, arrayOf(rpId)).mapNotNull { row ->- val passkey = parsePasskeyRow(row) ?: return@mapNotNull null- val itemUsername = row["Username"] as? String-+ val rows = executeQuery(PasskeyQueries.GET_BY_RP_ID, arrayOf(rpId)).mapNotNull { PasskeyWithItemRow.fromRow(it) }+ return PasskeyMapper.mapRowsWithItem(rows).filter { entry ->// Filter by username or userId if provided- val usernameMatches = userName == null || itemUsername == userName- val userIdMatches = userId == null || passkey.userHandle == null || userId.contentEquals(passkey.userHandle)- if (!usernameMatches || !userIdMatches) return@mapNotNull null-- PasskeyWithCredentialInfo(- passkey = passkey,- serviceName = row["ServiceName"] as? String,- username = itemUsername,- email = row["Email"] as? String,- )+ val usernameMatches = userName == null || entry.username == userName+ val userIdMatches = userId == null || entry.passkey.userHandle == null || userId.contentEquals(entry.passkey.userHandle)+ usernameMatches && userIdMatches}}@@ -322,8 +307,8 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {val manifestId = row["ManifestId"] as? Stringif (itemIdString == null || manifestId == null) continueval itemId = UUID.fromString(itemIdString)- val createdAt = DateHelpers.parseDateString(row["CreatedAt"] as? String ?: "") ?: MIN_DATE- val updatedAt = DateHelpers.parseDateString(row["UpdatedAt"] as? String ?: "") ?: MIN_DATE+ val createdAt = DateHelpers.parseDateString(row["CreatedAt"] as? String ?: "") ?: ItemMapper.MIN_DATE+ val updatedAt = DateHelpers.parseDateString(row["UpdatedAt"] as? String ?: "") ?: ItemMapper.MIN_DATEval urls = (row["Urls"] as? String)?.split(",")?.filter { it.isNotEmpty() } ?: emptyList()results.add(@@ -377,21 +362,21 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {/*** Get all passkeys with their associated items in a single query.- * This is much more efficient than calling getForItem() for each item.+ * This is much more efficient than calling getByItemId() for each item.*- * @return List of PasskeyWithItem objects.+ * @return List of PasskeyAndItem objects.*/- fun getAllWithItems(): List<PasskeyWithItem> {+ fun getAllWithItems(): List<PasskeyAndItem> {if (!database.isOpen()) return emptyList()- val results = mutableListOf<PasskeyWithItem>()+ val results = mutableListOf<PasskeyAndItem>()for (row in executeQuery(PasskeyQueries.GET_ALL_WITH_ITEMS, emptyArray())) {try {val passkey = parsePasskeyRow(row)val manifestId = passkey?.manifestIdif (passkey == null || manifestId == null) continue- val itemCreatedAt = DateHelpers.parseDateString(row["ItemCreatedAt"] as? String) ?: MIN_DATE- val itemUpdatedAt = DateHelpers.parseDateString(row["ItemUpdatedAt"] as? String) ?: MIN_DATE+ val itemCreatedAt = DateHelpers.parseDateString(row["ItemCreatedAt"] as? String) ?: ItemMapper.MIN_DATE+ val itemUpdatedAt = DateHelpers.parseDateString(row["ItemUpdatedAt"] as? String) ?: ItemMapper.MIN_DATE// Create a minimal Item object with the data we haveval item = Item(@@ -410,7 +395,7 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {updatedAt = itemUpdatedAt,)- results.add(PasskeyWithItem(passkey, item))+ results.add(PasskeyAndItem(passkey, item))} catch (e: Exception) {Log.e(TAG, "Error parsing passkey with item row", e)}@@ -520,74 +505,20 @@ class PasskeyRepository(database: VaultDatabase) : BaseRepository(database) {/*** Parse a passkey row from database query results.*/- @Suppress("ReturnCount") // Early returns improve readability for parsing logicprivate fun parsePasskeyRow(row: Map<String, Any?>): Passkey? {- return try {- val idString = row["Id"] as? String ?: return null- val itemIdString = row["ItemId"] as? String ?: return null- val manifestId = row["ManifestId"] as? String ?: return null- val rpId = row["RpId"] as? String ?: return null- val userHandle = row["UserHandle"] as? ByteArray- val publicKeyString = row["PublicKey"] as? String ?: return null- val privateKeyString = row["PrivateKey"] as? String ?: return null- val prfKey = row["PrfKey"] as? ByteArray- val displayName = row["DisplayName"] as? String ?: return null- val additionalData = row["AdditionalData"] as? ByteArray- val createdAtString = row["CreatedAt"] as? String ?: return null- val updatedAtString = row["UpdatedAt"] as? String ?: return null- val isDeleted = (row["IsDeleted"] as? Long) == 1L-- Passkey(- id = UUID.fromString(idString),- parentItemId = UUID.fromString(itemIdString),- manifestId = manifestId,- rpId = rpId,- userHandle = userHandle,- userName = null,- publicKey = publicKeyString.toByteArray(Charsets.UTF_8),- privateKey = privateKeyString.toByteArray(Charsets.UTF_8),- prfKey = prfKey,- displayName = displayName,- additionalData = additionalData,- createdAt = DateHelpers.parseDateString(createdAtString) ?: MIN_DATE,- updatedAt = DateHelpers.parseDateString(updatedAtString) ?: MIN_DATE,- isDeleted = isDeleted,- )- } catch (e: Exception) {- Log.e(TAG, "Error parsing passkey row", e)- null- }+ return PasskeyRow.fromRow(row)?.let { PasskeyMapper.mapRow(it) }}}// MARK: - Data Classes-/**- * Data class to hold passkey with item info.- *- * @property passkey The passkey.- * @property serviceName The service name from the item.- * @property username The username from the item.- * @property email The email from the item, used as display fallback when there is no username.- */-data class PasskeyWithCredentialInfo(- val passkey: Passkey,- val serviceName: String?,- val username: String?,- val email: String? = null,-) {- /** The account identifier to display: the username, or the email when no username is set. */- val accountLabel: String?- get() = username?.takeIf { it.isNotBlank() } ?: email?.takeIf { it.isNotBlank() }-}-/*** Data class to hold passkey with its associated item.** @property passkey The passkey.* @property item The item this passkey belongs to.*/-data class PasskeyWithItem(+data class PasskeyAndItem(val passkey: Passkey,val item: Item,)diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/utils/FolderUtils.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/utils/FolderUtils.ktindex 43c7f29cd..8e7439914 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/utils/FolderUtils.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/utils/FolderUtils.kt@@ -3,13 +3,12 @@ package net.aliasvault.app.vaultstore.utilsimport java.util.UUID/**- * Utilities for working with folder hierarchies and trees.+ * The folder path of an item, built from the flat folder list of one manifest.+ * Other platform implementations: FolderUtils.ts (core/client), FolderUtils.swift (iOS).*/object FolderUtils {/**- * Maximum allowed folder nesting depth.- * Structure: Root (0) > Level 1 (1) > Level 2 (2) > Level 3 (3) > Level 4 (4).- * Folders at depth 4 cannot have subfolders.+ * Maximum allowed folder nesting depth (root is 0, folders at depth 4 cannot have subfolders).*/const val MAX_FOLDER_DEPTH = 4@@ -26,37 +25,6 @@ object FolderUtils {val parentFolderId: UUID?,)- /**- * Get folder depth in the hierarchy.- * @param folderId The folder ID to check.- * @param folders Flat array of all folders.- * @return Depth (0 = root, 1 = one level deep, etc.) or null if folder not found.- */- @Suppress("LoopWithTooManyJumpStatements")- fun getFolderDepth(folderId: UUID, folders: List<Folder>): Int? {- val folder = folders.find { it.id == folderId } ?: return null-- var depth = 0- var currentId: UUID? = folderId-- // Traverse up to root, counting levels- while (currentId != null) {- val current = folders.find { it.id == currentId } ?: break- if (current.parentFolderId == null) {- break- }- depth++- currentId = current.parentFolderId-- // Prevent infinite loops- if (depth > MAX_FOLDER_DEPTH) {- break- }- }-- return depth- }-/*** Get the full path of folder names from root to the specified folder.* @param folderId The folder ID.@@ -82,85 +50,4 @@ object FolderUtils {return path}-- /**- * Get the full path of folder IDs from root to the specified folder.- * @param folderId The folder ID.- * @param folders Flat array of all folders.- * @return Array of folder IDs from root to current folder, or empty array if not found.- */- fun getFolderIdPath(folderId: UUID?, folders: List<Folder>): List<UUID> {- if (folderId == null) {- return emptyList()- }-- val path = mutableListOf<UUID>()- var currentId: UUID? = folderId- var iterations = 0-- // Build path by traversing up to root- while (currentId != null && iterations < MAX_FOLDER_DEPTH + 1) {- val folder = folders.find { it.id == currentId } ?: break- path.add(0, folder.id) // Add to beginning of array- currentId = folder.parentFolderId- iterations++- }-- return path- }-- /**- * Format folder path for display with separator.- * @param pathSegments Array of folder names.- * @param separator Separator string (default: " > ").- * @return Formatted folder path string.- */- fun formatFolderPath(pathSegments: List<String>, separator: String = " > "): String {- return pathSegments.joinToString(separator)- }-- /**- * Check if a folder can have subfolders (not at max depth).- * @param folderId The folder ID to check.- * @param folders Flat array of all folders.- * @return True if folder can have children, false otherwise.- */- fun canHaveSubfolders(folderId: UUID, folders: List<Folder>): Boolean {- val depth = getFolderDepth(folderId, folders)- return depth != null && depth < MAX_FOLDER_DEPTH- }-- /**- * Get all descendant folder IDs (children, grandchildren, etc.).- * @param folderId The parent folder ID.- * @param folders Flat array of all folders.- * @return Array of descendant folder IDs.- */- fun getDescendantFolderIds(folderId: UUID, folders: List<Folder>): List<UUID> {- val descendants = mutableListOf<UUID>()-- fun traverse(parentId: UUID) {- folders- .filter { it.parentFolderId == parentId }- .forEach { child ->- descendants.add(child.id)- traverse(child.id)- }- }-- traverse(folderId)- return descendants- }-- /**- * Get all direct child folder IDs.- * @param parentFolderId The parent folder ID (null for root).- * @param folders Flat array of all folders.- * @return Array of direct child folder IDs.- */- fun getDirectChildFolderIds(parentFolderId: UUID?, folders: List<Folder>): List<UUID> {- return folders- .filter { it.parentFolderId == parentFolderId }- .map { it.id }- }}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.ktindex 3ee6dda1d..24d7222cb 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/webapi/WebApiService.kt@@ -31,6 +31,7 @@ data class WebApiResponse(/*** Native Kotlin WebAPI service for making HTTP requests to the AliasVault server.* This service handles authentication, token refresh, and all HTTP operations.+ * Other platform implementations: WebApiService.ts (core/client), WebApiService.swift (iOS).*/class WebApiService(private val context: Context) {companion object {diff --git a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxprojindex 1f1285faa..8ffd478c2 100644--- a/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj+++ b/apps/mobile-app/ios/AliasVault.xcodeproj/project.pbxproj@@ -25,7 +25,7 @@B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };B2E3CEC9AABDA3497BFE65B7 /* libPods-VaultStoreKitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9AD944E3A0F270C797F5DD /* libPods-VaultStoreKitTests.a */; };BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };- CE26D68F2DA7FCD2006DC04D /* VaultManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE26D68C2DA7FCD2006DC04D /* VaultManager.swift */; };+ CE26D68F2DA7FCD2006DC04D /* NativeVaultManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE26D68C2DA7FCD2006DC04D /* NativeVaultManager.swift */; };CE3AE2B12DC7ACDE00E7745E /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = CE3AE2B02DC7ACD700E7745E /* .swiftlint.yml */; };CE48FCEC2DBE939A00E5E3D6 /* VaultModels.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEE482AA2DBE8EFE00F4A367 /* VaultModels.framework */; };CE48FD372DBE95EB00E5E3D6 /* VaultModels.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEE482AA2DBE8EFE00F4A367 /* VaultModels.framework */; };@@ -236,7 +236,7 @@C32D89DCBA51D7C8CDE51DD2 /* libPods-VaultUI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-VaultUI.a"; sourceTree = BUILT_PRODUCTS_DIR; };C87FA54AAFE121325F22CDDE /* Pods-PreviewHost.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PreviewHost.debug.xcconfig"; path = "Target Support Files/Pods-PreviewHost/Pods-PreviewHost.debug.xcconfig"; sourceTree = "<group>"; };C9F10947D429671B08FE934C /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };- CE26D68C2DA7FCD2006DC04D /* VaultManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaultManager.swift; sourceTree = "<group>"; };+ CE26D68C2DA7FCD2006DC04D /* NativeVaultManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeVaultManager.swift; sourceTree = "<group>"; };CE3AE2B02DC7ACD700E7745E /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };CE73B39F2DFC8A0C0081B6CB /* AliasVault.icon */ = {isa = PBXFileReference; lastKnownFileType = folder.iconcomposer.icon; path = AliasVault.icon; sourceTree = "<group>"; };CE77825D2EA1822400A75E6F /* VaultUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = VaultUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; };@@ -594,7 +594,7 @@CE9A58F92DBA97D500CB0A4C /* NativeVaultManager */ = {isa = PBXGroup;children = (- CE26D68C2DA7FCD2006DC04D /* VaultManager.swift */,+ CE26D68C2DA7FCD2006DC04D /* NativeVaultManager.swift */,CE9A58FA2DBA982100CB0A4C /* RCTNativeVaultManager.h */,CE9A58FB2DBA982100CB0A4C /* RCTNativeVaultManager.mm */,CE9A5B662DBAE42B00CB0A4C /* README.md */,@@ -1317,7 +1317,7 @@CED3AB3C2E70CF8700F3FDEB /* AppDelegate.swift in Sources */,CED3AB3E2E70CF8700F3FDED /* SceneDelegate.swift in Sources */,CE9A5A022DBAAE5000CB0A4C /* RCTNativeVaultManager.h in Sources */,- CE26D68F2DA7FCD2006DC04D /* VaultManager.swift in Sources */,+ CE26D68F2DA7FCD2006DC04D /* NativeVaultManager.swift in Sources */,CE9A58FC2DBA982100CB0A4C /* RCTNativeVaultManager.mm in Sources */,B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */,E8FD7000523F4549908941A2 /* noop-file.swift in Sources */,diff --git a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift b/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swiftsimilarity index 96%rename from apps/mobile-app/ios/NativeVaultManager/VaultManager.swiftrename to apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swiftindex 5c01db922..7d7804566 100644--- a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift+++ b/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swift@@ -14,9 +14,10 @@ import StoreKit* This class is used as a bridge to allow React Native to interact with the VaultStoreKit class.* The VaultStore class is implemented in Swift and used by both React Native and the native iOS* Autofill extension.+ * Other platform implementations: NativeVaultManager.kt (Android), spec in specs/NativeVaultManager.ts.*/-@objc(VaultManager)-public class VaultManager: NSObject {+@objc(NativeVaultManager)+public class NativeVaultManager: NSObject {private let vaultStore = VaultStore.sharedprivate let webApiService = WebApiService()@@ -446,7 +447,7 @@ public class VaultManager: NSObject {localOnly: Bool,resolver resolve: @escaping RCTPromiseResolveBlock,rejecter reject: @escaping RCTPromiseRejectBlock) {- NSLog("VaultManager: Copying to clipboard with expiration of %.0f seconds, localOnly: %@", expirationSeconds, localOnly ? "true" : "false")+ NSLog("NativeVaultManager: Copying to clipboard with expiration of %.0f seconds, localOnly: %@", expirationSeconds, localOnly ? "true" : "false")DispatchQueue.main.async {if expirationSeconds > 0 {@@ -466,11 +467,11 @@ public class VaultManager: NSObject {options: options)- NSLog("VaultManager: Text copied to clipboard with expiration at %@", expirationDate.description)+ NSLog("NativeVaultManager: Text copied to clipboard with expiration at %@", expirationDate.description)} else {// No expiration, just copy normallyUIPasteboard.general.string = text- NSLog("VaultManager: Text copied to clipboard without expiration")+ NSLog("NativeVaultManager: Text copied to clipboard without expiration")}resolve(nil)}@@ -491,7 +492,7 @@ public class VaultManager: NSObject {resolve(nil)}} catch {- print("VaultManager: Failed to register credential identities: \(error)")+ print("NativeVaultManager: Failed to register credential identities: \(error)")await MainActor.run {reject("CREDENTIAL_REGISTRATION_ERROR", "Failed to register credential identities: \(error.localizedDescription)", error)}@@ -504,14 +505,14 @@ public class VaultManager: NSObject {rejecter reject: @escaping RCTPromiseRejectBlock) {Task {do {- print("VaultManager: Removing all credential identities from iOS store")+ print("NativeVaultManager: Removing all credential identities from iOS store")try await CredentialIdentityStore.shared.removeAllCredentialIdentities()await MainActor.run {- print("VaultManager: Successfully removed all credential identities")+ print("NativeVaultManager: Successfully removed all credential identities")resolve(nil)}} catch {- print("VaultManager: Failed to remove credential identities: \(error)")+ print("NativeVaultManager: Failed to remove credential identities: \(error)")await MainActor.run {reject("CREDENTIAL_REMOVAL_ERROR", "Failed to remove credential identities: \(error.localizedDescription)", error)}@@ -909,19 +910,6 @@ public class VaultManager: NSObject {resolve(vaultStore.isBiometricAuthEnabled())}- @objc- func getPinFailedAttempts(_ resolve: @escaping RCTPromiseResolveBlock,- rejecter reject: @escaping RCTPromiseRejectBlock) {- resolve(vaultStore.getPinFailedAttempts())- }-- @objc- func resetPinFailedAttempts(_ resolve: @escaping RCTPromiseResolveBlock,- rejecter reject: @escaping RCTPromiseRejectBlock) {- vaultStore.resetPinFailedAttempts()- resolve(nil)- }-@objcfunc removeAndDisablePin(_ resolve: @escaping RCTPromiseResolveBlock,rejecter reject: @escaping RCTPromiseRejectBlock) {@@ -938,7 +926,7 @@ public class VaultManager: NSObject {rejecter reject: @escaping RCTPromiseRejectBlock) {DispatchQueue.main.async { [weak self] inguard let self = self else {- reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)+ reject("INTERNAL_ERROR", "NativeVaultManager instance deallocated", nil)return}@@ -953,7 +941,7 @@ public class VaultManager: NSObject {pinLength: self.vaultStore.getPinLength(),unlockHandler: { [weak self] pin inguard let self = self else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "NativeVaultManager instance deallocated"])}// Unlock vault with PIN@@ -1018,7 +1006,7 @@ public class VaultManager: NSObject {rejecter reject: @escaping RCTPromiseRejectBlock) {DispatchQueue.main.async { [weak self] inguard let self = self else {- reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)+ reject("INTERNAL_ERROR", "NativeVaultManager instance deallocated", nil)return}@@ -1038,12 +1026,12 @@ public class VaultManager: NSObject {customButtonText: customButtonText,unlockHandler: { [weak self] password inguard let self = self else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "NativeVaultManager instance deallocated"])}// Verify password and get the unlock keyguard let unlockKeyBase64 = self.vaultStore.verifyPassword(password) else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Incorrect password"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Incorrect password"])}// Open the session in memory only@@ -1075,7 +1063,7 @@ public class VaultManager: NSObject {}// Throw to stop further processing in ViewModel- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Max attempts reached"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Max attempts reached"])})@@ -1093,7 +1081,7 @@ public class VaultManager: NSObject {rejecter reject: @escaping RCTPromiseRejectBlock) {DispatchQueue.main.async { [weak self] inguard let self = self else {- reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)+ reject("INTERNAL_ERROR", "NativeVaultManager instance deallocated", nil)return}@@ -1107,7 +1095,7 @@ public class VaultManager: NSObject {let viewModel = PinSetupViewModel(setupHandler: { [weak self] pin inguard let self = self else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "NativeVaultManager instance deallocated"])}// Setup PIN (vault must be unlocked - encryption key is retrieved from memory)@@ -1271,7 +1259,7 @@ public class VaultManager: NSObject {DispatchQueue.main.async { [weak self] inguard let self = self else {- reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)+ reject("INTERNAL_ERROR", "NativeVaultManager instance deallocated", nil)semaphore.signal()return}@@ -1293,7 +1281,7 @@ public class VaultManager: NSObject {customSubtitle: customSubtitle,unlockHandler: { [weak self] pin inguard let self = self else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "NativeVaultManager instance deallocated"])}// Unlock vault with PIN (just validates, doesn't store in memory)@@ -1363,7 +1351,7 @@ public class VaultManager: NSObject {// Show password unlockDispatchQueue.main.async { [weak self] inguard let self = self else {- reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)+ reject("INTERNAL_ERROR", "NativeVaultManager instance deallocated", nil)return}@@ -1384,12 +1372,12 @@ public class VaultManager: NSObject {customButtonText: customButtonText,unlockHandler: { [weak self] password inguard let self = self else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "NativeVaultManager instance deallocated"])}// Verify password and get the unlock keyguard let unlockKeyBase64 = try self.vaultStore.verifyPassword(password) else {- throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Incorrect password"])+ throw NSError(domain: "NativeVaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "Incorrect password"])}try self.vaultStore.storeAccountKeyInMemory(base64Key: unlockKeyBase64)@@ -1450,7 +1438,7 @@ public class VaultManager: NSObject {@objcstatic func moduleName() -> String! {- return "VaultManager"+ return "NativeVaultManager"}// MARK: - Client core bridgediff --git a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mmindex fbcfddfe0..566864f5c 100644--- a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm+++ b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm@@ -7,7 +7,7 @@/*** This objective-c class is used as a bridge to allow React Native to interact with the underlying- * Swift VaultManager class and communicates with the VaultStore that is used by both React Native+ * Swift NativeVaultManager class and communicates with the VaultStore that is used by both React Native* and the native iOS Autofill extension.** This class should implement all methods defined in the specs/NativeVaultManager.ts TurboModule.@@ -15,7 +15,7 @@* update the spec which generates the interface this class implements.*/@implementation RCTNativeVaultManager {- VaultManager *vaultManager;+ NativeVaultManager *vaultManager;}+ (NSString *)moduleName {@@ -24,7 +24,7 @@- (id) init {if (self = [super init]) {- vaultManager = [VaultManager new];+ vaultManager = [NativeVaultManager new];}return self;}diff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/FieldMapper.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/FieldMapper.swiftindex 48dc291a9..0c53e298a 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/FieldMapper.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/FieldMapper.swift@@ -71,6 +71,7 @@ public struct ProcessedField {/// Mapper class for processing database field rows into ItemField objects./// Handles both system fields (with FieldKey) and custom fields (with FieldDefinitionId).+/// Other platform implementations: FieldMapper.ts (core/client), FieldMapper.kt (Android).public struct FieldMapper {/// Process raw field rows from database into a map of scoped item key (see `scopedKey`) -> [ItemField]./// Handles system vs custom fields. Multi-value fields (like URLs) create separate ItemField entriesdiff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/PasskeyMapper.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/PasskeyMapper.swiftindex 8a9ed9df6..36f40d2e9 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/PasskeyMapper.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Mappers/PasskeyMapper.swift@@ -66,7 +66,7 @@ public struct PasskeyRow {}/// Row structure for passkey with item info (joined query).-public struct PasskeyWithItemInfoRow {+public struct PasskeyWithItemRow {public let passkeyRow: PasskeyRowpublic let serviceName: String?public let username: String?@@ -86,7 +86,7 @@ public struct PasskeyWithItemInfoRow {}/// Result type for passkey with item info.-public struct PasskeyWithItemInfo {+public struct PasskeyWithItem {public let passkey: Passkeypublic let serviceName: String?public let username: String?@@ -152,15 +152,15 @@ public struct PasskeyMapper {return rows.compactMap { mapRow($0) }}- /// Map a passkey with item info row to PasskeyWithItemInfo.+ /// Map a passkey with item info row to PasskeyWithItem./// - Parameter row: The joined row from the database- /// - Returns: PasskeyWithItemInfo or nil if mapping fails- public static func mapRowWithItemInfo(_ row: PasskeyWithItemInfoRow) -> PasskeyWithItemInfo? {+ /// - Returns: PasskeyWithItem or nil if mapping fails+ public static func mapRowWithItem(_ row: PasskeyWithItemRow) -> PasskeyWithItem? {guard let passkey = mapRow(row.passkeyRow) else {return nil}- return PasskeyWithItemInfo(+ return PasskeyWithItem(passkey: passkey,serviceName: row.serviceName,username: row.username,@@ -168,10 +168,10 @@ public struct PasskeyMapper {)}- /// Map multiple joined rows to PasskeyWithItemInfo objects.+ /// Map multiple joined rows to PasskeyWithItem objects./// - Parameter rows: Array of joined rows- /// - Returns: Array of PasskeyWithItemInfo objects- public static func mapRowsWithItemInfo(_ rows: [PasskeyWithItemInfoRow]) -> [PasskeyWithItemInfo] {- return rows.compactMap { mapRowWithItemInfo($0) }+ /// - Returns: Array of PasskeyWithItem objects+ public static func mapRowsWithItem(_ rows: [PasskeyWithItemRow]) -> [PasskeyWithItem] {+ return rows.compactMap { mapRowWithItem($0) }}}diff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swiftindex 8cdf74be5..b6d0c1b15 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Queries/PasskeyQueries.swift@@ -63,7 +63,7 @@ public struct PasskeyQueries {"""/// Get passkeys with item info for a specific rpId.- public static let getWithItemInfoByRpId = """+ public static let getWithItemByRpId = """SELECT\(columns),i.Name as ServiceName,diff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/ItemRepository.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/ItemRepository.swiftindex d9cecbf26..ac10bb734 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/ItemRepository.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/ItemRepository.swift@@ -2,6 +2,7 @@ import Foundationimport VaultModels/// Repository for reading items and appending field values.+/// Other platform implementations: ItemRepository.ts (core/client), ItemRepository.kt (Android).public class ItemRepository: BaseRepository {// MARK: - Read Operationsdiff --git a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swiftindex dd54d78ed..7ae79a4d7 100644--- a/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Database/Repositories/PasskeyRepository.swift@@ -5,6 +5,7 @@ import VaultUtils/// Repository for Passkey CRUD operations./// Handles fetching, creating, updating, and deleting passkeys.+/// Other platform implementations: PasskeyRepository.ts (core/client), PasskeyRepository.kt (Android).public class PasskeyRepository: BaseRepository {// MARK: - Read Operations@@ -56,11 +57,11 @@ public class PasskeyRepository: BaseRepository {/// - rpId: The relying party identifier (domain)/// - userName: Optional username to filter by/// - userId: Optional user handle to filter by- /// - Returns: Array of PasskeyWithItemInfo objects- public func getWithItemInfo(forRpId rpId: String, userName: String? = nil, userId: Data? = nil) throws -> [PasskeyWithItemInfo] {- let results = try client.executeQuery(PasskeyQueries.getWithItemInfoByRpId, params: [rpId])- let rows = results.compactMap { PasskeyWithItemInfoRow(from: $0) }- var mappedResults = PasskeyMapper.mapRowsWithItemInfo(rows)+ /// - Returns: Array of PasskeyWithItem objects+ public func getWithItem(forRpId rpId: String, userName: String? = nil, userId: Data? = nil) throws -> [PasskeyWithItem] {+ let results = try client.executeQuery(PasskeyQueries.getWithItemByRpId, params: [rpId])+ let rows = results.compactMap { PasskeyWithItemRow(from: $0) }+ var mappedResults = PasskeyMapper.mapRowsWithItem(rows)// Apply optional filtersif let userName = userName {diff --git a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSyncEngine.swift b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSyncEngine.swiftindex 03017b624..a5d0e5a66 100644--- a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSyncEngine.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSyncEngine.swift@@ -8,6 +8,7 @@ import VaultUtils/// The engine owns the sync algorithm and emits commands (HTTP, state, SQLite, vault storage); this class/// carries each one out and feeds the response back until the engine reports `done`. See the `vault_sync`/// module in `core/rust` for the command and response contract.+/// Other platform implementations: VaultSyncEngine.ts (core/client), VaultSyncEngine.kt (Android).public final class VaultSyncEngine {/// Prefix of the UserDefaults keys the engine's persisted state lives under.private static let statePrefix = "aliasvault_sync_state:"diff --git a/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift b/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swiftindex f8dfe7f82..6c9a1b0f9 100644--- a/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Services/WebApiService.swift@@ -4,6 +4,7 @@ import VaultUtils/*** Native Swift WebAPI service for making HTTP requests to the AliasVault server.* This service handles authentication, token refresh, and all HTTP operations.+ * Other platform implementations: WebApiService.ts (core/client), WebApiService.kt (Android).*/public class WebApiService {private let vaultStore = VaultStore.shareddiff --git a/apps/mobile-app/ios/VaultStoreKit/Utils/FolderUtils.swift b/apps/mobile-app/ios/VaultStoreKit/Utils/FolderUtils.swiftindex 0fa702cef..ea58d386b 100644--- a/apps/mobile-app/ios/VaultStoreKit/Utils/FolderUtils.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Utils/FolderUtils.swift@@ -1,10 +1,9 @@import Foundation-/// Utilities for working with folder hierarchies and trees.+/// The folder path of an item, built from the flat folder list of one manifest.+/// Other platform implementations: FolderUtils.ts (core/client), FolderUtils.kt (Android).public enum FolderUtils {- /// Maximum allowed folder nesting depth.- /// Structure: Root (0) > Level 1 (1) > Level 2 (2) > Level 3 (3) > Level 4 (4).- /// Folders at depth 4 cannot have subfolders.+ /// Maximum allowed folder nesting depth (root is 0, folders at depth 4 cannot have subfolders).public static let maxFolderDepth = 4/// Simplified folder model for utility functions.@@ -20,39 +19,6 @@ public enum FolderUtils {}}- /// Get folder depth in the hierarchy.- /// - Parameters:- /// - folderId: The folder ID to check.- /// - folders: Flat array of all folders.- /// - Returns: Depth (0 = root, 1 = one level deep, etc.) or nil if folder not found.- public static func getFolderDepth(folderId: UUID, folders: [Folder]) -> Int? {- guard folders.contains(where: { $0.id == folderId }) else {- return nil- }-- var depth = 0- var currentId: UUID? = folderId-- // Traverse up to root, counting levels- while let id = currentId {- guard let current = folders.first(where: { $0.id == id }) else {- break- }- guard let parentId = current.parentFolderId else {- break- }- depth += 1- currentId = parentId-- // Prevent infinite loops- if depth > maxFolderDepth {- break- }- }-- return depth- }-/// Get the full path of folder names from root to the specified folder./// - Parameters:/// - folderId: The folder ID.@@ -79,83 +45,4 @@ public enum FolderUtils {return path}-- /// Get the full path of folder IDs from root to the specified folder.- /// - Parameters:- /// - folderId: The folder ID.- /// - folders: Flat array of all folders.- /// - Returns: Array of folder IDs from root to current folder, or empty array if not found.- public static func getFolderIdPath(folderId: UUID?, folders: [Folder]) -> [UUID] {- guard let folderId = folderId else {- return []- }-- var path: [UUID] = []- var currentId: UUID? = folderId- var iterations = 0-- // Build path by traversing up to root- while let id = currentId, iterations < maxFolderDepth + 1 {- guard let folder = folders.first(where: { $0.id == id }) else {- break- }- path.insert(folder.id, at: 0) // Add to beginning of array- currentId = folder.parentFolderId- iterations += 1- }-- return path- }-- /// Format folder path for display with separator.- /// - Parameters:- /// - pathSegments: Array of folder names.- /// - separator: Separator string (default: " > ").- /// - Returns: Formatted folder path string.- public static func formatFolderPath(pathSegments: [String], separator: String = " > ") -> String {- return pathSegments.joined(separator: separator)- }-- /// Check if a folder can have subfolders (not at max depth).- /// - Parameters:- /// - folderId: The folder ID to check.- /// - folders: Flat array of all folders.- /// - Returns: True if folder can have children, false otherwise.- public static func canHaveSubfolders(folderId: UUID, folders: [Folder]) -> Bool {- guard let depth = getFolderDepth(folderId: folderId, folders: folders) else {- return false- }- return depth < maxFolderDepth- }-- /// Get all descendant folder IDs (children, grandchildren, etc.).- /// - Parameters:- /// - folderId: The parent folder ID.- /// - folders: Flat array of all folders.- /// - Returns: Array of descendant folder IDs.- public static func getDescendantFolderIds(folderId: UUID, folders: [Folder]) -> [UUID] {- var descendants: [UUID] = []-- func traverse(parentId: UUID) {- let children = folders.filter { $0.parentFolderId == parentId }- for child in children {- descendants.append(child.id)- traverse(parentId: child.id)- }- }-- traverse(parentId: folderId)- return descendants- }-- /// Get all direct child folder IDs.- /// - Parameters:- /// - parentFolderId: The parent folder ID (nil for root).- /// - folders: Flat array of all folders.- /// - Returns: Array of direct child folder IDs.- public static func getDirectChildFolderIds(parentFolderId: UUID?, folders: [Folder]) -> [UUID] {- return folders- .filter { $0.parentFolderId == parentFolderId }- .map { $0.id }- }}diff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swiftindex a7d1340a3..00431377d 100644--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Passkey.swift@@ -41,8 +41,8 @@ extension VaultStore {* Get passkeys with item info for a specific rpId and optionally username* Used for finding existing passkeys that might be replaced during registration*/- public func getPasskeysWithCredentialInfo(forRpId rpId: String, userName: String? = nil, userId: Data? = nil) throws -> [PasskeyWithItemInfo] {- return try passkeyRepository.getWithItemInfo(forRpId: rpId, userName: userName, userId: userId)+ public func getPasskeysWithCredentialInfo(forRpId rpId: String, userName: String? = nil, userId: Data? = nil) throws -> [PasskeyWithItem] {+ return try passkeyRepository.getWithItem(forRpId: rpId, userName: userName, userId: userId)}/**diff --git a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swiftindex 95b299523..5446b9ab4 100644--- a/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/Components/CredentialCardView.swift@@ -107,7 +107,7 @@ public struct AutofillCredentialCard: View {if credential.hasTotp,let totp = credential.totp,- let code = TotpGenerator.generateCode(secret: totp.secretKey,+ let code = TotpUtility.generateTotpCode(secret: totp.secretKey,period: totp.period,digits: totp.digits,algorithm: totp.algorithm),diff --git a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swiftindex 1b6b14200..ee09979b5 100644--- a/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift+++ b/apps/mobile-app/ios/VaultUI/Selection/CredentialProviderView.swift@@ -250,7 +250,7 @@ private struct AutofillCredentialCardWithSelection: View {if isChoosingTextToInsert {// Generate TOTP code if availableif let totp = credential.totp {- totpCode = TotpGenerator.generateCode(secret: totp.secretKey,+ totpCode = TotpUtility.generateTotpCode(secret: totp.secretKey,period: totp.period,digits: totp.digits,algorithm: totp.algorithm)diff --git a/apps/mobile-app/ios/VaultUtils/DateHelpers.swift b/apps/mobile-app/ios/VaultUtils/DateHelpers.swiftindex e5fadee7a..fe0e358c6 100644--- a/apps/mobile-app/ios/VaultUtils/DateHelpers.swift+++ b/apps/mobile-app/ios/VaultUtils/DateHelpers.swift@@ -11,6 +11,7 @@ import Foundation* - Consistent precision with milliseconds for accurate sorting/comparison* - Readable space separator instead of 'T'* - Lexicographic sorting works correctly+ * Other platform implementations: DateHelpers.ts (core/client), DateHelpers.kt (Android).*/public class DateHelpers {/// Date formatter for a given pattern.@@ -24,7 +25,6 @@ public class DateHelpers {private static let standardFormatter = makeFormatter("yyyy-MM-dd HH:mm:ss.SSS")private static let withoutMillisFormatter = makeFormatter("yyyy-MM-dd HH:mm:ss")- private static let birthDateFormatter = makeFormatter("yyyy-MM-dd 00:00:00")private static let isoFormatter: ISO8601DateFormatter = {let formatter = ISO8601DateFormatter()formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]@@ -42,12 +42,6 @@ public class DateHelpers {return toStandardFormat(Date())}- /// Format a Date to the birth date format (no milliseconds, time set to 00:00:00).- /// Format: "yyyy-MM-dd 00:00:00" (19 characters).- public static func toBirthDateFormat(_ date: Date) -> String {- return birthDateFormatter.string(from: date)- }-/// Parse a date string to a Date object for use in queries./// Supports multiple formats:/// - "yyyy-MM-dd HH:mm:ss.SSS" (standard format with milliseconds)diff --git a/apps/mobile-app/ios/VaultUtils/TotpClipboard.swift b/apps/mobile-app/ios/VaultUtils/TotpClipboard.swiftindex ece7c88aa..7e9306556 100644--- a/apps/mobile-app/ios/VaultUtils/TotpClipboard.swift+++ b/apps/mobile-app/ios/VaultUtils/TotpClipboard.swift@@ -10,7 +10,7 @@ public enum TotpClipboard {public static func copyCodeIfEnabled(totp: TotpCode?) {guard AutofillSettings.shouldCopyTotpOnFill,let totp = totp, !totp.secretKey.isEmpty,- let code = TotpGenerator.generateCode(secret: totp.secretKey,+ let code = TotpUtility.generateTotpCode(secret: totp.secretKey,period: totp.period,digits: totp.digits,algorithm: totp.algorithm),diff --git a/apps/mobile-app/ios/VaultUtils/TotpGenerator.swift b/apps/mobile-app/ios/VaultUtils/TotpUtility.swiftsimilarity index 62%rename from apps/mobile-app/ios/VaultUtils/TotpGenerator.swiftrename to apps/mobile-app/ios/VaultUtils/TotpUtility.swiftindex 37289a594..093b36179 100644--- a/apps/mobile-app/ios/VaultUtils/TotpGenerator.swift+++ b/apps/mobile-app/ios/VaultUtils/TotpUtility.swift@@ -2,7 +2,8 @@ import Foundationimport RustCoreFramework/// Time-based One-Time Password (TOTP) codes, generated by the Rust core (`core/rust/src/totp`).-public class TotpGenerator {+/// Other platform implementations: TotpUtility.ts (core/client), TotpUtility.kt (Android).+public class TotpUtility {/// Generate a TOTP code from a secret key./// - Parameters:/// - secret: The Base32-encoded secret key@@ -11,7 +12,7 @@ public class TotpGenerator {/// - digits: Number of digits in the code (defaults to 6)/// - algorithm: The HMAC algorithm name: SHA1, SHA256 or SHA512 (defaults to SHA1)/// - Returns: The generated TOTP code, or nil if the secret is unusable- public static func generateCode(+ public static func generateTotpCode(secret: String,time: Date = Date(),period: Int = 30,@@ -26,15 +27,4 @@ public class TotpGenerator {period: UInt32(clamping: period))}-- /// Get the remaining seconds until the next TOTP code.- /// - Parameters:- /// - time: The current time (defaults to now)- /// - period: The time step in seconds (defaults to 30); outside 1 to 300 the Rust core uses 30, and so does this- /// - Returns: The number of seconds remaining- public static func getRemainingSeconds(time: Date = Date(), period: Int = 30) -> Int {- let step = (1...300).contains(period) ? period : 30- let elapsed = Int(time.timeIntervalSince1970) % step- return step - elapsed- }}diff --git a/apps/web/src/pages/items/RecentlyDeleted.tsx b/apps/web/src/pages/items/RecentlyDeleted.tsxindex 117349029..1ce956f1d 100644--- a/apps/web/src/pages/items/RecentlyDeleted.tsx+++ b/apps/web/src/pages/items/RecentlyDeleted.tsx@@ -1,5 +1,5 @@import { scopedKey } from '@aliasvault/client/database/ItemRef';-import { fromStandardFormat } from '@aliasvault/client/utilities/DateFormatter';+import { fromStandardFormat } from '@aliasvault/client/utilities/DateHelpers';import { TRASH_RETENTION_DEFAULT_DAYS } from '@aliasvault/models/vault';import React, { useCallback, useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';diff --git a/apps/web/src/pages/settings/StorageInsights.tsx b/apps/web/src/pages/settings/StorageInsights.tsxindex 36d7ce6ed..c08d06c39 100644--- a/apps/web/src/pages/settings/StorageInsights.tsx+++ b/apps/web/src/pages/settings/StorageInsights.tsx@@ -1,5 +1,5 @@import { BulkFaviconService } from '@aliasvault/client/items/BulkFaviconService';-import { fromStandardFormat } from '@aliasvault/client/utilities/DateFormatter';+import { fromStandardFormat } from '@aliasvault/client/utilities/DateHelpers';import { LogoKinds } from '@aliasvault/models/vault';import React, { useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';diff --git a/core/client/src/api/WebApiService.ts b/core/client/src/api/WebApiService.tsindex 5138215f2..f6e09f204 100644--- a/core/client/src/api/WebApiService.ts+++ b/core/client/src/api/WebApiService.ts@@ -86,6 +86,7 @@ export type EngineHttpResponse = {/*** Service class for interacting with the web API.+ * Other platform implementations: WebApiService.swift (iOS), WebApiService.kt (Android).*/export class WebApiService {/**diff --git a/core/client/src/database/BaseRepository.ts b/core/client/src/database/BaseRepository.tsindex cf4432a4e..faaf29ac0 100644--- a/core/client/src/database/BaseRepository.ts+++ b/core/client/src/database/BaseRepository.ts@@ -1,6 +1,6 @@import { multiManifestRendering } from '../sharing/MultiManifestRendering';import { DEFAULT_VAULT_MUTATION_SCOPE } from '../sync/VaultMutationScope';-import * as dateFormatter from '../utilities/DateFormatter';+import * as dateFormatter from '../utilities/DateHelpers';import { runAsync } from './DbOp';import { FolderQueries } from './queries/FolderQueries';diff --git a/core/client/src/database/mappers/FieldMapper.ts b/core/client/src/database/mappers/FieldMapper.tsindex faba3bee4..4d2ab8b18 100644--- a/core/client/src/database/mappers/FieldMapper.ts+++ b/core/client/src/database/mappers/FieldMapper.ts@@ -40,6 +40,7 @@ export type ProcessedField = {/*** Mapper class for processing database field rows into ItemField objects.* Handles both system fields (with FieldKey) and custom fields (with FieldDefinitionId).+ * Other platform implementations: FieldMapper.swift (iOS), FieldMapper.kt (Android).*/export class FieldMapper {/**diff --git a/core/client/src/database/repositories/ImportExportRepository.ts b/core/client/src/database/repositories/ImportExportRepository.tsindex 83ce329c3..3124e870f 100644--- a/core/client/src/database/repositories/ImportExportRepository.ts+++ b/core/client/src/database/repositories/ImportExportRepository.ts@@ -1,7 +1,7 @@import { LogoKinds, type ItemType, type LogoKind } from '@aliasvault/models/vault';import { AliasVaultCsvExportService } from '../../transfer/export/AliasVaultCsvExportService';-import { fromStandardFormat, toStandardFormat } from '../../utilities/DateFormatter';+import { fromStandardFormat, toStandardFormat } from '../../utilities/DateHelpers';import { BaseRepository } from '../BaseRepository';import { scopedKey } from '../ItemRef';import { AttachmentQueries, FieldDefinitionQueries, FieldHistoryQueries, FieldValueQueries, TotpCodeQueries } from '../queries/ItemQueries';diff --git a/core/client/src/database/repositories/ItemRepository.ts b/core/client/src/database/repositories/ItemRepository.tsindex c951961f3..e305dc768 100644--- a/core/client/src/database/repositories/ItemRepository.ts+++ b/core/client/src/database/repositories/ItemRepository.ts@@ -38,6 +38,7 @@ type StoredFieldValue = {/*** Repository for Item CRUD operations.* Handles items, field values, field definitions, and field history.+ * Other platform implementations: ItemRepository.swift (iOS), ItemRepository.kt (Android), reads only.*/export class ItemRepository extends BaseRepository {/**diff --git a/core/client/src/database/repositories/PasskeyRepository.ts b/core/client/src/database/repositories/PasskeyRepository.tsindex 9d926bb8e..6f71fb513 100644--- a/core/client/src/database/repositories/PasskeyRepository.ts+++ b/core/client/src/database/repositories/PasskeyRepository.ts@@ -8,6 +8,7 @@ import type { Passkey } from '@aliasvault/models/vault';/*** Repository for Passkey CRUD operations.+ * Other platform implementations: PasskeyRepository.swift (iOS), PasskeyRepository.kt (Android), which also write items.*/export class PasskeyRepository extends BaseRepository {/**diff --git a/core/client/src/items/FolderUtils.ts b/core/client/src/items/FolderUtils.tsindex 89fddce2b..0828d4844 100644--- a/core/client/src/items/FolderUtils.ts+++ b/core/client/src/items/FolderUtils.ts@@ -6,6 +6,7 @@ import type { Folder, FolderRef } from '../database/repositories/FolderRepositor* Maximum allowed folder nesting depth.* Structure: Root (0) > Level 1 (1) > Level 2 (2) > Level 3 (3) > Level 4 (4)* Folders at depth 4 cannot have subfolders.+ * Other platform implementations: FolderUtils.swift (iOS), FolderUtils.kt (Android).*/export const MAX_FOLDER_DEPTH = 4;diff --git a/core/client/src/items/TotpUtility.ts b/core/client/src/items/TotpUtility.tsindex eb9829609..6cdeb8da7 100644--- a/core/client/src/items/TotpUtility.ts+++ b/core/client/src/items/TotpUtility.ts@@ -5,6 +5,7 @@ import { logExpected } from '../utilities/Diagnostics';/*** The RFC 6238 parameters a TOTP code was created with, as stored on the vault row.+ * Other platform implementations: TotpUtility.swift (iOS), TotpUtility.kt (Android).*/export type TotpParameters = {/** HMAC algorithm: "SHA1", "SHA256" or "SHA512". */diff --git a/core/client/src/sync/VaultSyncEngine.ts b/core/client/src/sync/VaultSyncEngine.tsindex 6a482640e..5809d3704 100644--- a/core/client/src/sync/VaultSyncEngine.ts+++ b/core/client/src/sync/VaultSyncEngine.ts@@ -490,6 +490,7 @@ class EngineRun {/*** Run one engine operation.+ * Other platform implementations: VaultSyncEngine.swift (iOS), VaultSyncEngine.kt (Android).* @param host - the host* @param request - the request* @param webApi - the API the HTTP commands run ondiff --git a/core/client/src/utilities/DateFormatter.ts b/core/client/src/utilities/DateHelpers.tssimilarity index 96%rename from core/client/src/utilities/DateFormatter.tsrename to core/client/src/utilities/DateHelpers.tsindex 8bf911e47..e4713a833 100644--- a/core/client/src/utilities/DateFormatter.ts+++ b/core/client/src/utilities/DateHelpers.ts@@ -11,6 +11,7 @@/*** Formats a Date to the standard format string: "yyyy-MM-dd HH:mm:ss.fff" (23 characters).+ * Other platform implementations: DateHelpers.swift (iOS), DateHelpers.kt (Android).* @param date - The Date to format* @returns Formatted date-time string in format "yyyy-MM-dd HH:mm:ss.fff"*/diff --git a/docs/docs/contributing/development/mobile-apps/index.md b/docs/docs/contributing/development/mobile-apps/index.mdindex 5eba4d7fa..4b4e0c6a8 100644--- a/docs/docs/contributing/development/mobile-apps/index.md+++ b/docs/docs/contributing/development/mobile-apps/index.md@@ -8,9 +8,9 @@ React Native. Standard Expo workflow applies (`npx expo run:ios` /`run:android`); this section only covers the AliasVault-specific pieces. See alsothe platform notes for [Android](android.md) and [iOS](ios/index.md).-## Native Turbo Module: VaultManager+## Native Turbo Module: NativeVaultManager-The app implements its native `VaultManager` as a React Native+The app implements its native `NativeVaultManager` as a React Native[Turbo Module](https://reactnative.dev/docs/the-new-architecture/pillars-turbo-modules),so the vault and encryption key can be stored on the native side using low-levelsecure keychain storage.