onTOTPGenerated
📩 onTOTPGenerated Event
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
| Field | Type | Description |
|---|---|---|
userID | String | The REL-ID user ID for whom the TOTP was generated |
TOTP | String | The 6-digit time-based one-time password |
expiryTimeInSec | Integer | Number of seconds before the TOTP expires |
error | Object | Contains 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
| Field | Type | Description |
|---|---|---|
longErrorCode | Number | 0 on success; non-zero on failure |
shortErrorCode | Number | Specific error subtype if applicable |
errorString | String | Text description of the result |
📤 Developer Actions
- Use
TOTPandexpiryTimeInSecto display OTP and countdown timer - Check
error.longErrorCodeto 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 generatedTOTP: Generated OTPexpiryTimeInSec: Time in seconds before expiryerror:RDNAErrorobject
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 IDTOTP: Generated OTPexpiryTimeInSec: Time in seconds before TOTP expireserror: RDNAError object with status
Sample Response
Not Applicable for Native Android
Updated 6 months ago
