{"id":13724842,"url":"https://github.com/subhendukundu/worker-auth-providers","last_synced_at":"2025-05-07T19:31:03.428Z","repository":{"id":42502393,"uuid":"390588936","full_name":"subhendukundu/worker-auth-providers","owner":"subhendukundu","description":"worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers. ","archived":false,"fork":false,"pushed_at":"2024-10-11T08:27:56.000Z","size":844,"stargazers_count":317,"open_issues_count":12,"forks_count":31,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-19T08:15:56.409Z","etag":null,"topics":["auth","authentication","aws-sns-login","cloudflare","cloudflare-workers","discord-login","facebook-login","github-login","github-login-with-worker","google-login","oauth2","spotify","worker-discord-login","worker-login","worker-twilio-otp"],"latest_commit_sha":null,"homepage":"https://authc1.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/subhendukundu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-29T03:30:29.000Z","updated_at":"2025-04-03T06:43:56.000Z","dependencies_parsed_at":"2023-02-09T04:01:26.921Z","dependency_job_id":"a1fc36c0-8c05-493e-92d6-8280a9e90b54","html_url":"https://github.com/subhendukundu/worker-auth-providers","commit_stats":{"total_commits":57,"total_committers":6,"mean_commits":9.5,"dds":"0.22807017543859653","last_synced_commit":"139ce35001ce0c51a4d6dfe1ed79904492b8ad33"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhendukundu%2Fworker-auth-providers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhendukundu%2Fworker-auth-providers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhendukundu%2Fworker-auth-providers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subhendukundu%2Fworker-auth-providers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subhendukundu","download_url":"https://codeload.github.com/subhendukundu/worker-auth-providers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252943642,"owners_count":21829281,"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":["auth","authentication","aws-sns-login","cloudflare","cloudflare-workers","discord-login","facebook-login","github-login","github-login-with-worker","google-login","oauth2","spotify","worker-discord-login","worker-login","worker-twilio-otp"],"created_at":"2024-08-03T01:02:04.351Z","updated_at":"2025-05-07T19:30:58.403Z","avatar_url":"https://github.com/subhendukundu.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","JavaScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"/logo.png\" alt=\"worker-auth-providers\" width=\"120px\"\u003e\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eworker-auth-providers\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\nAn open-source auth providers for \u003ca href=\"https://workers.cloudflare.com/\"\u003eCloudflare workers\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/github/repo-size/subhendukundu/worker-auth-providers?color=%23DA631D\u0026label=Repo%20Size\" alt=\"Repo Size\"\u003e\n\n\u003cimg src=\"https://img.shields.io/github/issues/subhendukundu/worker-auth-providers?color=%23DA631D\u0026label=Issues\" alt=\"Issues\"\u003e\n\n\u003cimg src=\"https://img.shields.io/github/issues-pr/subhendukundu/worker-auth-providers?color=%23DA631D\u0026label=Pull%20Requests\" alt=\"Pull Requests\"\u003e\n\n\u003cimg src=\"https://img.shields.io/github/last-commit/subhendukundu/worker-auth-providers?color=%23DA631D\u0026label=Last%20Commit\" alt=\"Last Commit\"\u003e\n\n\n\u003c/p\u003e\nworker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.\n\n## 🚀 Demo\n[Try now](https://worker-auth-providers.coolbio.workers.dev)\n\n## 🧐 Features\n- Open Source\n- Fast \u0026 Lightweight\n- Easy\n\n\n## 🛠️ Installation\n**Step 1**: Install the dependencies\n```bash\nnpm install worker-auth-providers\n```\n**Step 2**: Import the dependencies\n```javascript\nimport {\n  github, google,\n  twilio, facebook, discord,\n  spotify\n} from \"worker-auth-providers\";\n```\n**Step 3**: Redirect users\n```javascript\nconst githubLoginUrl = await github.redirect({\n    options: {\n        clientId,\n    },\n});\nreturn {\n    status: 302,\n    headers: {\n        location: githubLoginUrl,\n    },\n};\n\n// or send otp\n\nconst res = await awsSNS.send({\n  options: {\n    phone,\n    region: 'ap-south-1',\n    kvProvider: WORKER_AUTH_PROVIDERS_STORE,\n  },\n})\n```\n**Step 4**: Get user\n```javascript\nconst { user: providerUser, tokens } = await github.users({\n    options: { clientSecret, clientId },\n    request,\n});\nconsole.log(\"[providerUser]\", providerUser);\n\n// or verify otp\nconst res = await awsSNS.verify({\n  options: {\n    phone,\n    otp,\n    kvProvider: WORKER_AUTH_PROVIDERS_STORE,\n    secret: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjE2Mjc4MTE1MDEiLA0KICAibmFtZSI6ICJoYWFsLmluIiwNCiAgImlhdCI6ICIwMTA4MjAyMCINCn0.aNr18szvBz3Db3HAsJ-2KHYbnnHwHfK65CiZ_AWwpc0',\n  },\n})\n```\n\n## 📃 Documentation\nComing soon\n\n## 👩‍💻 Tech\n- [Cloudflare](https://www.cloudflare.com/)\n\n## 🍰 Contributing\nContributions are always welcome!\nSee [contributing.md](contributing.md) for ways to get started.\nPlease adhere to this project's [code of conduct](code-of-conduct.md).\n\n\n## Roadmap\n\n- [ ] Docs.\n- [x] Apple.\n- [ ] Azure (Microsoft)\n- [x] Google.\n- [x] Github\n- [x] OTP Twilio\n- [x] Mailgun Email\n- [x] Sendgrid Email\n- [x] Facebook\n- [x] Discord\n- [ ] Instagram\n- [ ] Amazon\n- [ ] Twitter\n- [x] Spotify\n- [ ] Auth0\n\n\n##FAQs\n\n#### How to persist login?\n\nUse cookie. Setting a cookie to indicate that they’re authorized for future requests\n\n```javascript\nconst cookieKey = \"worker-auth-providers\"\nconst persistAuth = async exchange =\u003e {\n    const date = new Date()  date.setDate(date.getDate() + 1)\n    const headers = { \n      Location: \"/\",\n      \"Set-cookie\": `${cookieKey}=${id}; Secure; HttpOnly; SameSite=Lax; Expires=${date.toUTCString()}`,\n    }\n    return { headers, status: 302 }\n}\n```\n\n#### How to logout?\n\nEasy, delete the cookie\n\n```javascript\nexport const logout = event =\u003e {\n  const cookieHeader = event.request.headers.get('Cookie')\n  if (cookieHeader \u0026\u0026 cookieHeader.includes(cookieKey)) {\n    return {\n      headers: {\n        'Set-cookie': `${cookieKey}=\"\"; HttpOnly; Secure; SameSite=Lax;`,\n      },\n    }\n  }\n  return {}\n}\n```\n\n## Feedback\n\nIf you have any feedback, please reach out to me at subhendukundu14@gmail.com\n\n\n## ✍️ Authors\n- [@subhendukundu](https://www.github.com/subhendukundu)\n\n## 💼 License\n[MIT](https://github.com/subhendukundu/worker-auth-providers/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhendukundu%2Fworker-auth-providers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubhendukundu%2Fworker-auth-providers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubhendukundu%2Fworker-auth-providers/lists"}