{"id": "e0MigRw2kJ67Sjcx", "name": "TOTP VALIDATION (WITHOUT CREATING CREDENTIAL)", "nodes": [{"id": "56f102c4-5b84-4e30-955c-0ea1221c328f", "name": "When clicking ‘Test workflow’", "type": "n8n-nodes-base.manualTrigger", "position": [480, 680], "parameters": {}, "typeVersion": 1}, {"id": "4f562819-ee42-42ad-b821-aff2cbebbc0f", "name": "TOTP VALIDATION", "type": "n8n-nodes-base.code", "position": [920, 680], "parameters": {"language": "python", "pythonCode": "import hmac\nimport hashlib\nimport time\nimport base64\n\ndef base32_decode(key):\n \"\"\"Decodes a base32 key into bytes\"\"\"\n key += '=' * (-len(key) % 8) # Add necessary '=' for valid length\n return base64.b32decode(key.upper(), casefold=True)\n\ndef generate_totp(secret, interval=30, digits=6):\n \"\"\"Generates a TOTP code based on a secret key\"\"\"\n interval_count = int(time.time() // interval)\n interval_bytes = interval_count.to_bytes(8, byteorder='big')\n\n hmac_hash = hmac.new(secret, interval_bytes, hashlib.sha1).digest()\n \n offset = hmac_hash[-1] & 0x0F\n binary_code = ((hmac_hash[offset] & 0x7F) << 24