new Totp(secret)
Construct Totp
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
secret |
String |
<optional> |
The secret to use for generating the one time password |
- Source:
Methods
-
generate(callback)
-
Combined method for all of the above, will start scanning when there is no secret and stores the secret afterwards. If there already is a secret stored it will generate a OTP based on the secret that was stored.
Parameters:
Name Type Description callbackcalled with the one time password - Source:
Example
var totp = new AeroGear.Totp(); totp.generate(function(result) { ... }); -
generateOTP(callback)
-
Generate a one time password based on provided secret.
Parameters:
Name Type Description callbackthe callback to execute when the generation is done - Source:
Example
// the secret key (statically defined here but in practice it's scanned) String secret = "B2374TNIQ3HKC446"; // initialize OTP var generator = new AeroGear.Totp(secret); // generate token generator.generateOTP(function(result) { ... }); -
readSecret(callback)
-
Read an existing secret
Parameters:
Name Type Description callbackcalled when the secret is retrieved with the secret or null when there was none - Source:
-
scanSecret(callback)
-
Scan a QR code that contains a url with the secret as a parameter
Parameters:
Name Type Description callbackcalled on success with the result - Source:
-
storeSecret(secret)
-
Store the secret so we can use it later
Parameters:
Name Type Description secretthe secret to store - Source: