Skip to content

Cross-Device Profile Sync Testing Guide โ€‹

Purpose: Verify that zero-knowledge encrypted profiles sync correctly across devices using Firebase Auth + Firestore.

Time: ~20 minutes


Test Scenario โ€‹

You'll create an account on Device 1, set up your profile, then log in on Device 2 and verify all data syncs correctly (including decryption).


Prerequisites โ€‹

  1. Two devices (or browser profiles):

    • Device 1: Your main browser
    • Device 2: Another browser, incognito window, or another physical device
  2. Dev server running:

    bash
    npm run dev
  3. Firebase DEV project configured (see ENVIRONMENT_SETUP.md)

  4. Have these ready:

    • Email address (e.g., test@example.com)
    • Strong passphrase (write it down!)
    • Birth date (18+ years old)

Test Steps โ€‹

Device 1: Create Account โ€‹

  1. Open app:

    http://localhost:5174
  2. Navigate to signup:

    • Click "Get Started" or go to #/signup
  3. Fill out signup form:

    • Email: test-sync@example.com
    • Birth date: Any date making you 18+
    • Click "Continue"
  4. Create passphrase:

    • Passphrase: MyTestPassphrase123!
    • Confirm passphrase: MyTestPassphrase123!
    • โš ๏ธ WRITE THIS DOWN - you'll need it on Device 2
    • Click "Continue"
  5. Agree to terms:

    • Check the box confirming you understand passphrase recovery policy
    • Click "Create My Account"
  6. Verify account creation:

    • Open browser DevTools โ†’ Console (F12)
    • Look for: โœ… Account created with zero-knowledge encryption
    • Should show:
      javascript
      {
        userId: "abc123...",
        lanternName: "Amber Beacon",
        email: "test-sync@example.com"
      }
  7. Set up profile (if redirected to profile creation):

    • Add interests: Coffee, Jazz, Late Night
    • Set mood: Chatty
    • Click "Save"
  8. Go to Profile Settings:

    • Navigate to #/profile
    • Add more interests: Books, Tech
    • Change mood to: Exploring
    • Enable location tracking
    • Click "Save Changes"
  9. Verify Firestore (optional):

    • Go to Firebase Console โ†’ Firestore Database
    • Find users collection
    • Open your user document
    • Verify fields:
      javascript
      {
        email: "test-sync@example.com",
        lanternName: "...",
        encryptedBirthDate: "k2j3n4lk5j6..." // gibberish
        salt: "p9o8i7u6y5...",  // random
        interests: ["Coffee", "Jazz", "Late Night", "Books", "Tech"],
        mood: "exploring",
        locationTracking: true,
        createdAt: "2025-01-...",
        updatedAt: "2025-01-..."
      }
    • โœ… Birth date is ENCRYPTED (unreadable gibberish)
  10. Sign out:

    • Click your profile โ†’ "Sign Out" (if implemented)
    • Or close the browser tab

Device 2: Log In โ€‹

  1. Open app on Device 2:

    • Different browser, incognito, or another device
    • Go to http://localhost:5174
  2. Navigate to login:

    • Click "Sign In" or go to #/login
  3. Enter credentials:

    • Email: test-sync@example.com
    • Passphrase: MyTestPassphrase123!
    • Click "Sign In"
  4. Verify login success:

    • Open DevTools โ†’ Console
    • Look for: โœ… Signed in successfully
    • Should show:
      javascript
      {
        userId: "abc123...",  // Same as Device 1
        lanternName: "Amber Beacon",
        email: "test-sync@example.com"
      }
  5. Go to Profile Settings:

    • Navigate to #/profile
    • Verify all data synced:
      • Lantern Name: Should match Device 1
      • Interests: Coffee, Jazz, Late Night, Books, Tech
      • Mood: Exploring
      • Location Tracking: Enabled
  6. Verify encrypted data:

    • Open DevTools โ†’ Console
    • Birth date should be decrypted (if you log user profile)
    • Not visible in UI (privacy-first design)
  7. Test profile update from Device 2:

    • Add interest: Photography
    • Change mood to: Quiet Vibes
    • Disable location tracking
    • Click "Save Changes"

Device 1: Verify Sync โ€‹

  1. Refresh Device 1 (or sign in again):

    • Go back to Device 1 browser
    • Refresh page or navigate to #/profile
  2. Verify changes from Device 2:

    • Interests should now include: Photography
    • Mood: Quiet Vibes
    • Location Tracking: Disabled
  3. โœ… SUCCESS: Changes from Device 2 are visible on Device 1!


What to Test โ€‹

โœ… Authentication โ€‹

  • [ ] Signup creates Firebase Auth user
  • [ ] Signup creates Firestore profile
  • [ ] Login authenticates with correct passphrase
  • [ ] Login fails with incorrect passphrase
  • [ ] Login unlocks encryption (key derived from passphrase)

โœ… Encryption โ€‹

  • [ ] Birth date is encrypted before storage
  • [ ] Birth date in Firestore is unreadable gibberish
  • [ ] Birth date can be decrypted with correct passphrase
  • [ ] Birth date cannot be decrypted without passphrase
  • [ ] Salt is stored publicly (visible in Firestore)

โœ… Profile Sync โ€‹

  • [ ] Profile data created on Device 1 appears on Device 2
  • [ ] Profile updates on Device 1 sync to Device 2
  • [ ] Profile updates on Device 2 sync to Device 1
  • [ ] Public fields (interests, mood) sync instantly
  • [ ] Encrypted fields (birth date) decrypt correctly on all devices

โœ… Security โ€‹

  • [ ] Passphrase never appears in Firestore
  • [ ] Encryption key never appears in Firestore
  • [ ] Encrypted birth date cannot be read without login
  • [ ] Security rules prevent reading other users' encrypted data

Expected Behavior โ€‹

ActionDevice 1Device 2Firestore
Create accountโœ… Account created-โœ… User document created with encrypted birth date
Add interestsโœ… Saved-โœ… interests array updated
Login-โœ… Authenticatedโœ… Salt fetched, key derived
View profile-โœ… All data syncedโœ… No changes
Update mood-โœ… Changed to "Quiet Vibes"โœ… mood updated, updatedAt changed
Refresh D1โœ… Sees "Quiet Vibes"-โœ… No changes

Debugging โ€‹

Issue: "Failed to load profile" โ€‹

Possible causes:

  • User not authenticated โ†’ check getCurrentUser()
  • Firestore security rules blocking read โ†’ check console for permission errors
  • Network issue โ†’ check DevTools โ†’ Network tab

Issue: "Failed to decrypt birth date" โ€‹

Possible causes:

  • Wrong passphrase entered โ†’ encryption key derivation failed
  • Encryption key not cached โ†’ user must re-enter passphrase
  • Corrupted encrypted data โ†’ check Firestore for encryptedBirthDate field

Issue: "Profile not syncing" โ€‹

Possible causes:

  • Firestore offline persistence not working โ†’ check browser console for warnings
  • Security rules blocking update โ†’ test with Rules Playground
  • Multiple accounts โ†’ verify same userId on both devices

Issue: "Passphrase rejected" โ€‹

Possible causes:

  • Typo in passphrase โ†’ case-sensitive, must match exactly
  • Wrong email โ†’ Firebase Auth rejects incorrect credentials
  • Account doesn't exist โ†’ check Firebase Console โ†’ Authentication

Verify in Firebase Console โ€‹

Firestore Database โ€‹

  1. Go to https://console.firebase.google.com
  2. Select lantern-app-dev project
  3. Click "Firestore Database"
  4. Find your user document in users collection
  5. Verify:
    • encryptedBirthDate: Gibberish (encrypted โœ…)
    • salt: Random base64 string
    • interests: Array of strings
    • mood: String
    • locationTracking: Boolean
    • updatedAt: Recent timestamp

Authentication โ€‹

  1. Click "Authentication" in Firebase Console
  2. Find your test user
  3. Verify:
    • Email: test-sync@example.com
    • UID matches userId in Firestore
    • Created: Recent timestamp

Success Criteria โ€‹

โœ… PASS if:

  • Account created on Device 1
  • Login works on Device 2 with same credentials
  • All profile data syncs correctly
  • Encrypted birth date is unreadable in Firestore
  • Encrypted birth date can be decrypted with passphrase
  • Profile updates on one device appear on the other
  • Security rules prevent unauthorized access

โŒ FAIL if:

  • Cannot create account
  • Cannot log in on Device 2
  • Profile data doesn't sync
  • Birth date is stored in plaintext
  • Birth date cannot be decrypted
  • Unauthorized users can read encrypted data

Next Steps โ€‹

After successful cross-device testing:

  1. โœ… Deploy Firestore security rules to DEV
  2. โœ… Test with real Firebase DEV project (not emulator)
  3. โœ… Audit security with Firestore Rules Playground
  4. โœ… Test on mobile devices (PWA)
  5. โœ… Deploy to production when ready

See also:

Built with VitePress