CRITICAL story-encrypted-assignment-dispatch-peer-mentor-002 8 pts
8
Story Points
Critical
Priority
Encrypted Assignment Dispatch
Feature

User Story

As a Peer Mentor (Likeperson)
I want to open an assignment and have it automatically decrypted on my device so I can read the full sensitive details — including the contact's name, home address, and medical summary — without that information ever being visible to anyone other than me
So that So that I receive the information I need to carry out the peer support visit while the organization remains compliant with Norwegian privacy legislation

Acceptance Criteria

  • Given the peer mentor opens an assignment for the first time, when the detail screen loads, then the assignment payload is decrypted on-device using the private key from the secure enclave and the full sensitive details are displayed
  • Given the assignment is opened for the first time, when the screen renders, then a read receipt is written to assignment_read_receipts and the coordinator's status dashboard reflects the 'read' state
  • Given the peer mentor opens the same assignment a second time, when the detail screen loads, then no duplicate read receipt is created
  • Given the device's private key is unavailable (e.g., key not yet initialized), when the peer mentor attempts to open an assignment, then a clear error message instructs them to complete BankID identity verification to restore their key
  • Given the ciphertext in Supabase is tampered or corrupted, when decryption is attempted, then the authenticated encryption fails, a tamper warning is displayed, and no partial data is shown
  • Given the assignment detail screen is open, when the encryption status widget is visible, then it shows a confirmed padlock icon indicating the message was end-to-end encrypted
  • Given the peer mentor navigates back from the detail screen, when they return to the inbox, then the assignment is now marked as read

Business Value

This story is the core privacy-compliance mechanism of the feature. Norwegian law (Personopplysningsloven, GDPR Art. 32) requires technical measures to protect sensitive personal data in transit and at rest. End-to-end encryption with device-local private keys means Supabase never holds plaintext, satisfying this requirement.

The read receipt also eliminates the coordinator's uncertainty about whether sensitive information has been received, closing a major operational gap previously handled via phone calls.