Skip to content

QR Code Share Token — Generation Flow

Scope: Handles the generation of QR Codes or URLs for sharing contacts. Tokens have a 24-hour TTL and are limited to a single use (1-time use). All legacy client-side encryption logic has been removed; only Backend-generated Tokens are supported.

flowchart TD
    classDef client fill:#E0F2FE,stroke:#0284C7,color:#0369A1,stroke-width:2px;
    classDef server fill:#D1FAE5,stroke:#059669,color:#047857,stroke-width:2px;
    classDef state fill:#F3F4F6,stroke:#9CA3AF,color:#374151;

    subgraph Client ["iOS Client (My QR Code Screen)"]
        Start(["👤 User opens My QR Code tab"]):::client --> APICall("POST /app/api/share-token"):::client
    end

    subgraph Server ["Backend / Token Service"]
        APICall --> AuthCheck{"Verify Session"}:::server
        AuthCheck -->|Valid| GenString["Generate Random String<br/>32 bytes -> Base62 (43 chars)"]:::server
        GenString --> SaveDB[("Save to Database<br/>TTL: 24 hours<br/>Max Uses: 1")]:::server
        SaveDB --> Response(["{ token: a8KxR3m... }"]):::server
    end

    subgraph Present ["UI Display"]
        Response --> BuildDL["Create DeepLink URL<br/>https://domain/share/contact/{token}"]:::state
        BuildDL --> RenderQR["Render QR Code image from URL"]:::client
        BuildDL --> CopyBtn["Copy Link / Share Button"]:::client
    end