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 โ
Two devices (or browser profiles):
- Device 1: Your main browser
- Device 2: Another browser, incognito window, or another physical device
Dev server running:
bashnpm run devFirebase DEV project configured (see ENVIRONMENT_SETUP.md)
Have these ready:
- Email address (e.g.,
test@example.com) - Strong passphrase (write it down!)
- Birth date (18+ years old)
- Email address (e.g.,
Test Steps โ
Device 1: Create Account โ
Open app:
http://localhost:5174Navigate to signup:
- Click "Get Started" or go to
#/signup
- Click "Get Started" or go to
Fill out signup form:
- Email:
test-sync@example.com - Birth date: Any date making you 18+
- Click "Continue"
- Email:
Create passphrase:
- Passphrase:
MyTestPassphrase123! - Confirm passphrase:
MyTestPassphrase123! - โ ๏ธ WRITE THIS DOWN - you'll need it on Device 2
- Click "Continue"
- Passphrase:
Agree to terms:
- Check the box confirming you understand passphrase recovery policy
- Click "Create My Account"
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" }
Set up profile (if redirected to profile creation):
- Add interests:
Coffee,Jazz,Late Night - Set mood:
Chatty - Click "Save"
- Add interests:
Go to Profile Settings:
- Navigate to
#/profile - Add more interests:
Books,Tech - Change mood to:
Exploring - Enable location tracking
- Click "Save Changes"
- Navigate to
Verify Firestore (optional):
- Go to Firebase Console โ Firestore Database
- Find
userscollection - 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)
Sign out:
- Click your profile โ "Sign Out" (if implemented)
- Or close the browser tab
Device 2: Log In โ
Open app on Device 2:
- Different browser, incognito, or another device
- Go to
http://localhost:5174
Navigate to login:
- Click "Sign In" or go to
#/login
- Click "Sign In" or go to
Enter credentials:
- Email:
test-sync@example.com - Passphrase:
MyTestPassphrase123! - Click "Sign In"
- Email:
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" }
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
- Navigate to
Verify encrypted data:
- Open DevTools โ Console
- Birth date should be decrypted (if you log user profile)
- Not visible in UI (privacy-first design)
Test profile update from Device 2:
- Add interest:
Photography - Change mood to:
Quiet Vibes - Disable location tracking
- Click "Save Changes"
- Add interest:
Device 1: Verify Sync โ
Refresh Device 1 (or sign in again):
- Go back to Device 1 browser
- Refresh page or navigate to
#/profile
Verify changes from Device 2:
- Interests should now include:
Photography - Mood:
Quiet Vibes - Location Tracking: Disabled
- Interests should now include:
โ 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 โ
| Action | Device 1 | Device 2 | Firestore |
|---|---|---|---|
| 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
encryptedBirthDatefield
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
userIdon 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 โ
- Go to https://console.firebase.google.com
- Select
lantern-app-devproject - Click "Firestore Database"
- Find your user document in
userscollection - Verify:
encryptedBirthDate: Gibberish (encrypted โ )salt: Random base64 stringinterests: Array of stringsmood: StringlocationTracking: BooleanupdatedAt: Recent timestamp
Authentication โ
- Click "Authentication" in Firebase Console
- Find your test user
- Verify:
- Email:
test-sync@example.com - UID matches
userIdin Firestore - Created: Recent timestamp
- Email:
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:
- โ Deploy Firestore security rules to DEV
- โ Test with real Firebase DEV project (not emulator)
- โ Audit security with Firestore Rules Playground
- โ Test on mobile devices (PWA)
- โ Deploy to production when ready
See also:
- DEPLOY_FIREBASE_RULES.md for deploying security rules
- ZERO_KNOWLEDGE_ENCRYPTION.md for encryption details
- ENVIRONMENT_SETUP.md for Firebase setup