Skip to content

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

Ignore unknown field types and add section type

Leendert de Borst3899bda93934
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/FieldType.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/FieldType.kt
index 2aa7b5589..98d3254ae 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/FieldType.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/FieldType.kt
@@ -53,10 +53,15 @@ object FieldType {
*/
const val TEXT_AREA = "TextArea"
+ /**
+ * Section field type.
+ */
+ const val SECTION = "Section"
+
/**
* All available field types.
*/
- val all = listOf(TEXT, PASSWORD, HIDDEN, EMAIL, U_R_L, DATE, NUMBER, PHONE, TEXT_AREA)
+ val all = listOf(TEXT, PASSWORD, HIDDEN, EMAIL, U_R_L, DATE, NUMBER, PHONE, TEXT_AREA, SECTION)
/**
* Checks if a string value is a valid field type.
diff --git a/apps/mobile-app/ios/VaultModels/FieldType.swift b/apps/mobile-app/ios/VaultModels/FieldType.swift
index 88ca2a977..8e7038234 100644
--- a/apps/mobile-app/ios/VaultModels/FieldType.swift
+++ b/apps/mobile-app/ios/VaultModels/FieldType.swift
@@ -33,8 +33,11 @@ public struct FieldType {
/// TextArea field type.
public static let textArea = "TextArea"
+ /// Section field type.
+ public static let section = "Section"
+
/// All available field types.
- public static let all = [text, password, hidden, email, uRL, date, number, phone, textArea]
+ public static let all = [text, password, hidden, email, uRL, date, number, phone, textArea, section]
/// Checks if a string value is a valid field type.
public static func isValid(_ value: String?) -> Bool {
diff --git a/core/client/src/database/mappers/FieldMapper.ts b/core/client/src/database/mappers/FieldMapper.ts
index 9d9c1f612..faba3bee4 100644
--- a/core/client/src/database/mappers/FieldMapper.ts
+++ b/core/client/src/database/mappers/FieldMapper.ts
@@ -1,4 +1,4 @@
-import { FieldTypes, getSystemField } from '@aliasvault/models/vault';
+import { FieldTypes, getSystemField, isSystemField } from '@aliasvault/models/vault';
import { scopedKey } from '../ItemRef';
@@ -42,6 +42,15 @@ export type ProcessedField = {
* Handles both system fields (with FieldKey) and custom fields (with FieldDefinitionId).
*/
export class FieldMapper {
+ /**
+ * Whether a row carries a system field key this build does not know (e.g. written by a newer client); these rows stay hidden and untouched.
+ * @param fieldKey - The row's FieldKey, null for a custom field
+ * @returns True for an unknown system field key
+ */
+ public static isUnknownSystemField(fieldKey: string | null | undefined): boolean {
+ return !!fieldKey && !isSystemField(fieldKey.toLowerCase());
+ }
+
/**
* Process raw field rows from database into a map of scoped item key -> ItemField[].
* Handles system vs custom fields and multi-value field grouping.
@@ -50,7 +59,7 @@ export class FieldMapper {
*/
public static processFieldRows(rows: FieldRow[]): Map<string, ItemField[]> {
// First, convert rows to processed fields with proper metadata
- const processedFields = rows.map(row => this.processFieldRow(row));
+ const processedFields = rows.filter(row => !this.isUnknownSystemField(row.FieldKey)).map(row => this.processFieldRow(row));
// Group by ItemId and FieldKey (to handle multi-value fields)
const fieldsByItem = new Map<string, ItemField[]>();
@@ -168,6 +177,10 @@ export class FieldMapper {
}>();
for (const row of rows) {
+ if (this.isUnknownSystemField(row.FieldKey)) {
+ continue;
+ }
+
const fieldKey = row.FieldKey || row.FieldDefinitionId || '';
// Accumulate values
diff --git a/core/client/src/database/repositories/ItemRepository.ts b/core/client/src/database/repositories/ItemRepository.ts
index 74203cc02..36d145953 100644
--- a/core/client/src/database/repositories/ItemRepository.ts
+++ b/core/client/src/database/repositories/ItemRepository.ts
@@ -952,9 +952,9 @@ export class ItemRepository extends BaseRepository {
}
}
- // Soft-delete every live row no value was kept on
+ // Soft-delete every live row no value was kept on, except fields this build does not know
for (const row of storedRows) {
- if (!row.IsDeleted && !keptIds.has(row.Id)) {
+ if (!row.IsDeleted && !keptIds.has(row.Id) && !FieldMapper.isUnknownSystemField(row.FieldKey)) {
yield* this.execute(FieldValueQueries.SOFT_DELETE, [currentDateTime, row.Id, manifestId]);
}
}
diff --git a/core/models/src/vault/Item.ts b/core/models/src/vault/Item.ts
index 567c402d0..49b58e869 100644
--- a/core/models/src/vault/Item.ts
+++ b/core/models/src/vault/Item.ts
@@ -116,6 +116,8 @@ export const FieldTypes = {
Number: 'Number',
Phone: 'Phone',
TextArea: 'TextArea',
+ // Custom field that starts a section: the custom fields after this field, by display order, are displayed as part of it.
+ Section: 'Section',
} as const;
/**
diff --git a/core/models/src/vault/ItemMethods.ts b/core/models/src/vault/ItemMethods.ts
index 07091fed1..f26340301 100644
--- a/core/models/src/vault/ItemMethods.ts
+++ b/core/models/src/vault/ItemMethods.ts
@@ -97,6 +97,32 @@ export function groupFieldsByCategory(item: Item): Record<string, ItemField[]> {
return groups;
}
+/**
+ * A run of custom fields under one section field; Section is null for the fields before the first section.
+ */
+export type CustomFieldSection = {
+ Section: ItemField | null;
+ Fields: ItemField[];
+};
+
+/**
+ * Group an item's custom fields, in display order, under the section field that precedes them.
+ */
+export function groupCustomFieldsBySection(item: Item): CustomFieldSection[] {
+ const customFields = item.Fields.filter(field => field.IsCustomField).sort((a, b) => (a.DisplayOrder ?? 0) - (b.DisplayOrder ?? 0));
+ const sections: CustomFieldSection[] = [{ Section: null, Fields: [] }];
+
+ for (const field of customFields) {
+ if (field.FieldType === FieldTypes.Section) {
+ sections.push({ Section: field, Fields: [] });
+ } else {
+ sections[sections.length - 1].Fields.push(field);
+ }
+ }
+
+ return sections[0].Fields.length === 0 ? sections.slice(1) : sections;
+}
+
/**
* Convert new Item model to legacy Credential model for backward compatibility.
* @deprecated Use Item model directly. This is a temporary compatibility layer.