TOTP in Online Mode

🌐 REL-ID SDK: TOTP Flow (Online Mode)

πŸ”Ž Overview

In online mode, TOTP (Time-based One-Time Password) is used to provide secure, time-bound one-time codes after the user logs in. This flow involves SDK-driven registration and real-time TOTP generation.


πŸ” Flow Breakdown

flowchart TD
    A[πŸ‘€ User is Logged In] --> TOTPRegistration[βš™οΈ SDK performs TOTP Registration]
    TOTPRegistration --> A1[πŸ“₯ App calls fetchRegisteredTOTPUsers]
    A1 -->|βœ… User registered for TOTP| A2[πŸ†— App shows 'Generate TOTP' option]
    A2 --> B[πŸ‘‰ User Selects 'Generate TOTP']
    B --> C[πŸ“ž App calls generateTOTP]
    C --> F[πŸ“€ SDK emits onTOTPGenerated]
    F --> G[πŸ“² App Displays TOTP and Expiry Timer]

    %% Success Callback Styling
    style F fill:#d4fdd4,stroke:#228b22,stroke-width:2px
    
    %% App-Initiated Call Styling
    style A1 fill:#ffe4b3,stroke:#ff8c00,stroke-width:2px
    style C fill:#ffe4b3,stroke:#ff8c00,stroke-width:2px

🟩 Green - Callbacks issued by REL-ID SDK
🟧 Orange - APIs invoked by the Client App


🧩 Step-by-Step Explanation

βœ… 1. User Logs In

  • After successful login, the SDK automatically attempts to register the user for TOTP (if not already registered).

πŸ” 2. App Verifies Eligibility

  • App calls fetchRegisteredTOTPUsers() to check which users are eligible for TOTP.
  • If the user is registered, the app enables the "Generate TOTP" option.

πŸ‘‰ 3. User Requests TOTP

  • User taps on "Generate TOTP" in the app UI.

πŸ“ž 4. App Calls generateTOTP(userID)

  • This triggers the SDK to generate a new TOTP.
  • Depending on configuration, the SDK may require authentication (LDA or password).

πŸ“€ 5. SDK Emits onTOTPGenerated

  • SDK returns the one-time code and its expiration (in seconds) via the onTOTPGenerated event.

πŸ“² 6. App Displays Code

  • App displays the TOTP along with a countdown timer to indicate expiration.

πŸ“ Notes

  • TOTP can be used for step-up authentication or secure offline logins.
  • Ensure proper UI feedback for expiry and regeneration.

What’s Next