Download wp-calypso/packages/calypso-e2e/src/totp-client.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 568 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/totp-client.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/calypso-e2e/src/totp-client.ts
-
curl -L -o totp-client.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/calypso-e2e/src/totp-client.ts
568 Bytes
| import totp from 'totp-generator'; | |
| /** | |
| * Client to generate TOTP codes, used for 2FA on WordPress.com. | |
| */ | |
| export class TOTPClient { | |
| private secret: string; | |
| /** | |
| * Constructs an instance of the TOTP client. | |
| * | |
| * @param {string} secret Secret value used to generate TOTP codes. | |
| */ | |
| constructor( secret: string ) { | |
| this.secret = secret; | |
| } | |
| /** | |
| * Returns the TOTP code. | |
| * | |
| * @returns {string} TOTP code valid for the epoch for which it was generated. | |
| */ | |
| getToken(): string { | |
| return totp( this.secret, { timestamp: Date.now() } ).toString(); | |
| } | |
| } | |