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