Middleware for authenticating a user, using their secret and the token provided in the request.
Optional options: Partial<TotpApiOptions<U>>Options for the middleware.
Middleware for authenticating a user, using their secret and the token provided in the request.
Function for generating a QR code for a user from a given secret and username.
This returns a PNG image as a data URL.
The QR code as a data URL.
The username to use for generating the URL.
The secret to use for generating the URL.
Function for generating a QR code for a user from a given secret and username.
This writes the QR code directly to a file, which you can later use to serve to the user.
The username to use for generating the URL.
The secret to use for generating the URL.
The path of the file to write the QR image to.
Function for generating a QR code for a user from a given secret and username.
filename is provided, this writes the QR code directly to that path, which you can later use to serve to
the user.filename is omitted (or blank), this returns a PNG image as a data URL.The username to use for generating the URL.
The secret to use for generating the URL.
Optional filename: stringIf provided, will use as path of the file to write the QR image to.
Function for generating a secret URL for a user from a given secret and username.
The URL for the user.
The username to use for generating the URL.
The secret to use for generating the URL.
Verifies a given token against a given secret. If the provided token is equal to the generated token for given
secret, it returns true. Otherwise, it returns false.
true if the token is valid, false otherwise.
The secret key of the user.
The request token to verify against.
Returns the user, only if the token is valid. Otherwise, it returns undefined.
The user, or undefined if the token is invalid.
The request object.
Generated using TypeDoc
This object contains the
authenticate()function which is the main middleware, as well as additional functions for generating tokens and URLs.