mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
12 lines
327 B
TypeScript
12 lines
327 B
TypeScript
export function parseTotpEnabled(tokenValue: string | null) {
|
|
if (!tokenValue) return false;
|
|
try {
|
|
const payload = JSON.parse(atob(tokenValue.split('.')[1]));
|
|
const flag = payload?.totp_enabled;
|
|
if (typeof flag === 'string') return flag.toLowerCase() === 'true';
|
|
return Boolean(flag);
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|