{"id":22213545,"url":"https://github.com/joaomirandas/headless2fa","last_synced_at":"2025-03-25T06:22:13.508Z","repository":{"id":47403505,"uuid":"254787285","full_name":"joaomirandas/headless2FA","owner":"joaomirandas","description":"That's an alternative to run headless tasks with 2FA authentication","archived":false,"fork":false,"pushed_at":"2021-09-01T18:28:55.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T05:42:38.393Z","etag":null,"topics":["2fa","2fa-headless","authentication","headless","puppeter"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joaomirandas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-11T03:44:26.000Z","updated_at":"2024-12-02T05:18:21.000Z","dependencies_parsed_at":"2022-09-22T19:21:36.875Z","dependency_job_id":null,"html_url":"https://github.com/joaomirandas/headless2FA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaomirandas%2Fheadless2FA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaomirandas%2Fheadless2FA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaomirandas%2Fheadless2FA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaomirandas%2Fheadless2FA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaomirandas","download_url":"https://codeload.github.com/joaomirandas/headless2FA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245408911,"owners_count":20610417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2fa","2fa-headless","authentication","headless","puppeter"],"created_at":"2024-12-02T21:10:04.796Z","updated_at":"2025-03-25T06:22:13.481Z","avatar_url":"https://github.com/joaomirandas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Headless 2FA\n\n- install modules using NPM `$ npm install`\n- run debug `$ node debug.js`\n- follow the instructions\n\n## Motivation\nSometimes you need to run headless tasks into some webservices or websites with 2FA authentication, like SMS or e-mail. Thus you feel stucked at some point how to run this routines into headless, this tiny snnipet allow you to do it.\n\nIf you are recurrent visitor on my repositories you will realize i always use TotalJS for structure my codes, and develop what i want as an module of this, that way it's easy to import on another project.\n\nCheck that routine into: \n```bash\n\u003e /modules/headless2FA.js\n```\n\n```node\n//EMBEDED LIBRARIES\nconst readline = require(\"readline\");\nconst puppeteer = require('puppeteer');\nconst rl = readline.createInterface({\n    input: process.stdin,\n    output: process.stdout\n});\n\n/*\nWaiting all TotalJS configurations be ready \n*/\nON('ready', function() { \n\n\t/*\n\tFunction to askToken from user\n\t*/\n\tfunction askToken(questionText) {\n\t\tconsole.log(\"[Token] - Asking token from user input\");\n\t  \treturn new Promise((resolve, reject) =\u003e {\n\t    \trl.question(\"\\nWhat is the token received?\", (input) =\u003e {\n\t    \t\trl.close();\n\t    \t\tresolve(input);\n\t    \t});\n\t  \t});\n\t}\n\n\t/*\n\tLauching Puppeter to get page and send Token\n\t*/\n\tpuppeteer.launch({headless : false}).then(async browser =\u003e {\n\t  \tconst page = await browser.newPage();\n\t\tconsole.log(\"[Browser] - Opening\");\n\t  \tawait page.goto('https://www.google.com');\n\t  \tawait page.setViewport({width: 800, height: 600});\n\t\tconsole.log(\"[Browser] - Page is open and start operations to take token\");\n\t  \tconst token = await askToken();\n\t\tconsole.log(\"\\n[Token] - configured token is: \"+token);\n\t\tconsole.log(\"[Browser] - KeepGoing with alredy configured token\");\n\t\t/*\n\t\t\tUSE HERE YOUR ALREDY CONFIGURED GLOBAL TOKEN TO CONTINUE\n\t\t\tYOUR CODE EXECUTION\n\t\t*/\n\t\tconsole.log(\"[Browser] - Closing\");\n\t  \tawait browser.close();\n\t});\n\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaomirandas%2Fheadless2fa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaomirandas%2Fheadless2fa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaomirandas%2Fheadless2fa/lists"}