If the action state is CHALLENGE_REQUIRED, proceed with the TOTP challenge:
Copy
Ask AI
import { Authsignal } from '@authsignal/browser';const authsignal = new Authsignal({ tenantId: 'YOUR_TENANT_ID',});// Set the token from the track responseauthsignal.setToken(token);// For enrollment: Generate QR code and secret first// Only needed if user doesn't have TOTP set up yetconst enrollResponse = await authsignal.totp.enroll();if (enrollResponse.data) { const qrCodeUri = enrollResponse.data.uri; // Display as QR code const secret = enrollResponse.data.secret; // Fallback manual entry // Display QR code to user for them to scan with their authenticator app}// For both enrollment and re-authentication:// User enters the TOTP code from their authenticator appconst verifyResponse = await authsignal.totp.verify({ code: userEnteredCode});// Get the verification token to validate on your backendif (verifyResponse.data?.isVerified) { const verificationToken = verifyResponse.data.token;}
Copy
Ask AI
import { Authsignal } from '@authsignal/browser';const authsignal = new Authsignal({ tenantId: 'YOUR_TENANT_ID',});// Set the token from the track responseauthsignal.setToken(token);// For enrollment: Generate QR code and secret first// Only needed if user doesn't have TOTP set up yetconst enrollResponse = await authsignal.totp.enroll();if (enrollResponse.data) { const qrCodeUri = enrollResponse.data.uri; // Display as QR code const secret = enrollResponse.data.secret; // Fallback manual entry // Display QR code to user for them to scan with their authenticator app}// For both enrollment and re-authentication:// User enters the TOTP code from their authenticator appconst verifyResponse = await authsignal.totp.verify({ code: userEnteredCode});// Get the verification token to validate on your backendif (verifyResponse.data?.isVerified) { const verificationToken = verifyResponse.data.token;}
Copy
Ask AI
import { Authsignal } from '@authsignal/browser';const authsignal = new Authsignal({ tenantId: 'YOUR_TENANT_ID',});// Launch the prebuilt UI with the URL from the track responseconst result = await authsignal.launch(url, { mode: 'popup', popupOptions: { width: '400px', isClosable: true, }});// Get the verification token to validate on your backendif (result.token) { const verificationToken = result.token;}