Skip to content

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

Refactor mobile app to use shared vault models (#900)

Leendert de Borstf8bf575ab5ef
diff --git a/apps/mobile-app/app/(tabs)/credentials/[id].tsx b/apps/mobile-app/app/(tabs)/credentials/[id].tsx
index 5c051f36f..a76317fbc 100644
--- a/apps/mobile-app/app/(tabs)/credentials/[id].tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/[id].tsx
@@ -5,7 +5,7 @@ import { ActivityIndicator, View, Text, StyleSheet, TouchableOpacity, Linking, P
import Toast from 'react-native-toast-message';
import emitter from '@/utils/EventEmitter';
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import { useColors } from '@/hooks/useColorScheme';
diff --git a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
index d6b5b7de3..f3c44dea6 100644
--- a/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/add-edit.tsx
@@ -10,9 +10,9 @@ import Toast from 'react-native-toast-message';
import emitter from '@/utils/EventEmitter';
import { CreateIdentityGenerator, IdentityHelperUtils, IdentityGenerator } from '@/utils/shared/identity-generator';
+import type { Credential } from '@/utils/shared/models/vault';
import type { FaviconExtractModel } from '@/utils/shared/models/webapi';
import { CreatePasswordGenerator, PasswordGenerator } from '@/utils/shared/password-generator';
-import { Credential } from '@/utils/types/Credential';
import { extractServiceNameFromUrl } from '@/utils/UrlUtility';
import { credentialSchema } from '@/utils/ValidationSchema';
diff --git a/apps/mobile-app/app/(tabs)/credentials/index.tsx b/apps/mobile-app/app/(tabs)/credentials/index.tsx
index d58ee23e7..c03099528 100644
--- a/apps/mobile-app/app/(tabs)/credentials/index.tsx
+++ b/apps/mobile-app/app/(tabs)/credentials/index.tsx
@@ -8,7 +8,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Toast from 'react-native-toast-message';
import emitter from '@/utils/EventEmitter';
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import { useColors } from '@/hooks/useColorScheme';
import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
diff --git a/apps/mobile-app/components/EmailCard.tsx b/apps/mobile-app/components/EmailCard.tsx
index e7478e0c7..cafa4c8c6 100644
--- a/apps/mobile-app/components/EmailCard.tsx
+++ b/apps/mobile-app/components/EmailCard.tsx
@@ -2,8 +2,8 @@ import { router } from 'expo-router';
import { useEffect, useState } from 'react';
import { StyleSheet, View, TouchableOpacity } from 'react-native';
+import type { Credential } from '@/utils/shared/models/vault';
import type { MailboxEmail } from '@/utils/shared/models/webapi';
-import { Credential } from '@/utils/types/Credential';
import { useColors } from '@/hooks/useColorScheme';
diff --git a/apps/mobile-app/components/credentials/CredentialCard.tsx b/apps/mobile-app/components/credentials/CredentialCard.tsx
index 8cc6a7f9f..71f582971 100644
--- a/apps/mobile-app/components/credentials/CredentialCard.tsx
+++ b/apps/mobile-app/components/credentials/CredentialCard.tsx
@@ -4,7 +4,7 @@ import { StyleSheet, View, Text, TouchableOpacity, Keyboard, Platform, Alert } f
import ContextMenu, { OnPressMenuItemEvent } from 'react-native-context-menu-view';
import Toast from 'react-native-toast-message';
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import { useColors } from '@/hooks/useColorScheme';
diff --git a/apps/mobile-app/components/credentials/details/AliasDetails.tsx b/apps/mobile-app/components/credentials/details/AliasDetails.tsx
index fa48d8c9e..b8582b626 100644
--- a/apps/mobile-app/components/credentials/details/AliasDetails.tsx
+++ b/apps/mobile-app/components/credentials/details/AliasDetails.tsx
@@ -1,5 +1,5 @@
import { IdentityHelperUtils } from '@/utils/shared/identity-generator';
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import FormInputCopyToClipboard from '@/components/form/FormInputCopyToClipboard';
import { ThemedText } from '@/components/themed/ThemedText';
diff --git a/apps/mobile-app/components/credentials/details/LoginCredentials.tsx b/apps/mobile-app/components/credentials/details/LoginCredentials.tsx
index 50f1bb939..d9baa1350 100644
--- a/apps/mobile-app/components/credentials/details/LoginCredentials.tsx
+++ b/apps/mobile-app/components/credentials/details/LoginCredentials.tsx
@@ -1,4 +1,4 @@
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import FormInputCopyToClipboard from '@/components/form/FormInputCopyToClipboard';
import { ThemedText } from '@/components/themed/ThemedText';
diff --git a/apps/mobile-app/components/credentials/details/NotesSection.tsx b/apps/mobile-app/components/credentials/details/NotesSection.tsx
index 9cd14c941..c03dd276c 100644
--- a/apps/mobile-app/components/credentials/details/NotesSection.tsx
+++ b/apps/mobile-app/components/credentials/details/NotesSection.tsx
@@ -1,6 +1,6 @@
import { View, Text, StyleSheet, Linking, Pressable } from 'react-native';
-import { Credential } from '@/utils/types/Credential';
+import type { Credential } from '@/utils/shared/models/vault';
import { useColors } from '@/hooks/useColorScheme';
diff --git a/apps/mobile-app/components/credentials/details/TotpSection.tsx b/apps/mobile-app/components/credentials/details/TotpSection.tsx
index 255400392..a8e4d3682 100644
--- a/apps/mobile-app/components/credentials/details/TotpSection.tsx
+++ b/apps/mobile-app/components/credentials/details/TotpSection.tsx
@@ -4,8 +4,7 @@ import React, { useState, useEffect } from 'react';
import { View, StyleSheet, TouchableOpacity, Platform } from 'react-native';
import Toast from 'react-native-toast-message';
-import { Credential } from '@/utils/types/Credential';
-import { TotpCode } from '@/utils/types/TotpCode';
+import type { Credential, TotpCode } from '@/utils/shared/models/vault';
import { useColors } from '@/hooks/useColorScheme';
diff --git a/apps/mobile-app/utils/EncryptionUtility.tsx b/apps/mobile-app/utils/EncryptionUtility.tsx
index 53308c3f4..1af50a9d0 100644
--- a/apps/mobile-app/utils/EncryptionUtility.tsx
+++ b/apps/mobile-app/utils/EncryptionUtility.tsx
@@ -3,10 +3,9 @@ import { Buffer } from 'buffer';
import AesGcmCrypto from 'react-native-aes-gcm-crypto';
import argon2 from 'react-native-argon2';
+import type { EncryptionKey } from '@/utils/shared/models/vault';
import type { Email, MailboxEmail } from '@/utils/shared/models/webapi';
-import { EncryptionKey } from './types/EncryptionKey';
-
/**
* Utility class for encryption operations including:
* - Argon2Id key derivation
diff --git a/apps/mobile-app/utils/SqliteClient.tsx b/apps/mobile-app/utils/SqliteClient.tsx
index 20e55abf5..a752f70f5 100644
--- a/apps/mobile-app/utils/SqliteClient.tsx
+++ b/apps/mobile-app/utils/SqliteClient.tsx
@@ -1,9 +1,6 @@
-import { Credential } from '@/utils/types/Credential';
-import { EncryptionKey } from '@/utils/types/EncryptionKey';
+import type { Credential, EncryptionKey, PasswordSettings, TotpCode } from '@/utils/shared/models/vault';
import { EncryptionKeyDerivationParams } from '@/utils/types/messaging/EncryptionKeyDerivationParams';
import { VaultMetadata } from '@/utils/types/messaging/VaultMetadata';
-import { PasswordSettings } from '@/utils/types/PasswordSettings';
-import { TotpCode } from '@/utils/types/TotpCode';
import NativeVaultManager from '@/specs/NativeVaultManager';
diff --git a/apps/mobile-app/utils/types/Credential.ts b/apps/mobile-app/utils/types/Credential.ts
deleted file mode 100644
index 21ac52bdc..000000000
--- a/apps/mobile-app/utils/types/Credential.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Gender } from "@/utils/shared/identity-generator";
-
-/**
- * Credential SQLite database type.
- */
-export type Credential = {
- Id: string;
- Username?: string;
- Password: string;
- ServiceName: string;
- ServiceUrl?: string;
- Logo?: Uint8Array | number[];
- Notes?: string;
- Alias: Alias;
-}
-
-/**
- * Alias SQLite database type.
- */
-export type Alias = {
- FirstName?: string;
- LastName?: string;
- NickName?: string;
- BirthDate: string;
- Gender?: Gender;
- Email?: string;
-}
\ No newline at end of file
diff --git a/apps/mobile-app/utils/types/EncryptionKey.ts b/apps/mobile-app/utils/types/EncryptionKey.ts
deleted file mode 100644
index 7dc64d603..000000000
--- a/apps/mobile-app/utils/types/EncryptionKey.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Encryption key SQLite database type.
- */
-export type EncryptionKey = {
- Id: string;
- PublicKey: string;
- PrivateKey: string;
- IsPrimary: boolean;
-}
diff --git a/apps/mobile-app/utils/types/PasswordSettings.ts b/apps/mobile-app/utils/types/PasswordSettings.ts
deleted file mode 100644
index 50719e895..000000000
--- a/apps/mobile-app/utils/types/PasswordSettings.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Settings for password generation stored in SQLite database settings table as string.
- */
-export type PasswordSettings = {
- /**
- * The length of the password.
- */
- Length: number;
-
- /**
- * Whether to use lowercase letters.
- */
- UseLowercase: boolean;
-
- /**
- * Whether to use uppercase letters.
- */
- UseUppercase: boolean;
-
- /**
- * Whether to use numbers.
- */
- UseNumbers: boolean;
-
- /**
- * Whether to use special characters.
- */
- UseSpecialChars: boolean;
-
- /**
- * Whether to use non-ambiguous characters.
- */
- UseNonAmbiguousChars: boolean;
-}
\ No newline at end of file
diff --git a/apps/mobile-app/utils/types/TotpCode.ts b/apps/mobile-app/utils/types/TotpCode.ts
deleted file mode 100644
index 0dc11bdb6..000000000
--- a/apps/mobile-app/utils/types/TotpCode.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * TotpCode SQLite database type.
- */
-export type TotpCode = {
- /** The ID of the TOTP code */
- Id: string;
-
- /** The name of the TOTP code */
- Name: string;
-
- /** The secret key for the TOTP code */
- SecretKey: string;
-
- /** The credential ID this TOTP code belongs to */
- CredentialId: string;
-};
\ No newline at end of file