onTOTPGenerated

📩 onTOTPGenerated Event

🧭 Purpose

The onTOTPGenerated event is emitted by the REL-ID SDK after a TOTP has been successfully generated using the generateTOTP(userID) API.
This event provides the application with the one-time password and its validity duration.


🧾 Event Payload

FieldTypeDescription
userIDStringThe REL-ID user ID for whom the TOTP was generated
TOTPStringThe 6-digit time-based one-time password
expiryTimeInSecIntegerNumber of seconds before the TOTP expires
errorObjectContains error codes and messages, if any

✅ Example Payload

{
  "userID": "john.doe",
  "TOTP": "758192",
  "expiryTimeInSec": 30,
  "error": {
    "longErrorCode": 0,
    "shortErrorCode": 0,
    "errorString": "Success"
  }
}

🚨 Error Object Fields

FieldTypeDescription
longErrorCodeNumber0 on success; non-zero on failure
shortErrorCodeNumberSpecific error subtype if applicable
errorStringStringText description of the result

📤 Developer Actions

  • Use TOTP and expiryTimeInSec to display OTP and countdown timer
  • Check error.longErrorCode to handle success or failure

💻 Code Snippets

🧪 React Native

Pseudocode

let onTOTPGeneratedSubscription = rdnaEventRegistery.addListener(
  'onTOTPGenerated',
  this.onTOTPGenerated.bind(this)
);

Response Data
Contains: userName, TOTP, expiryTimeInSec, error

Sample Response
Not Applicable for React Native


🐦 Flutter

Pseudocode

rdnaClient.on(RdnaClient.onTOTPGenerated, onTOTPGenerated);

void onTOTPGenerated(RDNATotpGeneratedStatus response) {
  print("User: ${response.userID}");
  print("TOTP: ${response.TOTP}");
  print("Expires in: ${response.expiryTimeInSec} seconds");
}

Response Data
Returns RDNATotpGeneratedStatus object with fields: userName, TOTP, expiryTimeInSec, error

Sample Response
✅ Provided in sample above.


🔌 Cordova

Pseudocode

document.addEventListener('onTOTPGenerated', this.onTOTPGenerated.bind(this), false);

Response Data
Contains: userName, TOTP, expiryTimeInSec, error

Sample Response
Not Applicable for Cordova


🍏 Native iOS

Pseudocode

(void)onTOTPGenerated:(NSString *)userName
               TOTP:(NSString *)TOTP
   expiryTimeInSec:(int)expiryTimeInSec
             error:(RDNAError *)error;

Response Data Parameters

  • userName: User for whom TOTP is generated
  • TOTP: Generated OTP
  • expiryTimeInSec: Time in seconds before expiry
  • error: RDNAError object

Sample Response
Not Applicable for Native iOS


🤖 Native Android

Pseudocode

void onTOTPGenerated(String username, String TOTP, int expiryTimeInSec, RDNAError error)

Response Data Parameters

  • username: REL-ID User ID
  • TOTP: Generated OTP
  • expiryTimeInSec: Time in seconds before TOTP expires
  • error: RDNAError object with status

Sample Response
Not Applicable for Native Android