{"_id":"@banolist/start-oauth","name":"@banolist/start-oauth","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@banolist/start-oauth","version":"1.0.1","description":"Lightweight and Secure OAuth2 for SolidStart","keywords":["api","oauth2","crypto","solidjs","solid-router","solidstart"],"homepage":"https://github.com/thomasbuilds/start-oauth#readme","bugs":{"url":"https://github.com/thomasbuilds/start-oauth/issues"},"repository":{"type":"git","url":"git+https://github.com/thomasbuilds/start-oauth.git"},"license":"MIT","author":{"name":"thomasbuilds"},"sideEffects":false,"type":"module","main":"src/index.ts","devDependencies":{"@types/node":"^24.6.2","prettier":"^3.6.2"},"peerDependencies":{"@solidjs/router":"^0.15.3","@solidjs/start":"^1.2.0"},"engines":{"node":">=22"},"scripts":{"format":"prettier --write . --trailing-comma none"},"_id":"@banolist/start-oauth@1.0.1","_integrity":"sha512-1ThR+sHrQ7afd2duFxz6XiITvqwnJDvkz+XTvsI+xG9A5NUsReo6wNpcFKWUpJdhw5DbPwIbKli6KZSGjmCG3g==","_resolved":"/tmp/0ad89656b019b48be97826387a59f967/banolist-start-oauth-1.0.1.tgz","_from":"file:banolist-start-oauth-1.0.1.tgz","_nodeVersion":"22.21.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-1ThR+sHrQ7afd2duFxz6XiITvqwnJDvkz+XTvsI+xG9A5NUsReo6wNpcFKWUpJdhw5DbPwIbKli6KZSGjmCG3g==","shasum":"457f4122861bda7fcb842e2d29f93c07faf08b91","tarball":"https://registry.npmjs.org/@banolist/start-oauth/-/start-oauth-1.0.1.tgz","fileCount":18,"unpackedSize":24807,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCgmGqjZs/5W4QnWzhSazkigVYaCGP/LLBGV0WD9DAyEgIhALnOCqOiylemZGhTJKmcUI60PHc0JTaBl4+uA6s9tySH"}]},"_npmUser":{"name":"banolist","email":"banolist@gmail.com"},"directories":{},"maintainers":[{"name":"banolist","email":"banolist@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/start-oauth_1.0.1_1761928645532_0.7740110783086664"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-31T16:37:25.472Z","1.0.1":"2025-10-31T16:37:25.746Z","modified":"2025-10-31T16:37:26.013Z"},"maintainers":[{"name":"banolist","email":"banolist@gmail.com"}],"description":"Lightweight and Secure OAuth2 for SolidStart","homepage":"https://github.com/thomasbuilds/start-oauth#readme","keywords":["api","oauth2","crypto","solidjs","solid-router","solidstart"],"repository":{"type":"git","url":"git+https://github.com/thomasbuilds/start-oauth.git"},"author":{"name":"thomasbuilds"},"bugs":{"url":"https://github.com/thomasbuilds/start-oauth/issues"},"license":"MIT","readme":"<div align=\"center\">\n\n[![Banner](https://assets.solidjs.com/banner?background=tiles&type=Start&project=oauth)](https://github.com/solidjs/solid-start)\n\n[![Version](https://img.shields.io/npm/v/start-oauth.svg?style=for-the-badge&color=blue&logo=npm)](https://www.npmjs.com/package/start-oauth)\n[![Downloads](https://img.shields.io/npm/dm/start-oauth.svg?style=for-the-badge&color=green&logo=npm)](https://www.npmjs.com/package/start-oauth)\n[![Stars](https://img.shields.io/github/stars/thomasbuilds/start-oauth.svg?style=for-the-badge&color=yellow&logo=github)](https://github.com/thomasbuilds/start-oauth)\n[![Discord](https://img.shields.io/discord/722131463138705510?label=join&style=for-the-badge&color=5865F2&logo=discord&logoColor=white)](https://discord.com/invite/solidjs)\n\n</div>\n\n**Lightweight and Secure OAuth2 for [SolidStart](https://start.solidjs.com)** — Access the `name`, `email`, and when available `image` of authenticated users.\nFor extended usage, the `provider` name and access `token` are included in the `oauth` object.\n\n**Supported Providers:** Amazon, Discord, GitHub, Google, LinkedIn, Microsoft, Spotify, X, and Yahoo\n\n## Installation\n\nAdd `start-oauth` as a dependency\n\n```bash\n# use preferred package manager\nnpm add start-oauth\n```\n\n## Configuration\n\nCreate a catch-all API route at `routes/api/oauth/[...oauth].ts`\n\n```ts\nimport OAuth from \"start-oauth\";\nimport { redirect } from \"@solidjs/router\";\n\nexport const GET = OAuth({\n  password: process.env.PASSWORD!, // openssl rand -hex 32\n  discord: {\n    id: process.env.DISCORD_ID!,\n    secret: process.env.DISCORD_SECRET!\n  },\n  google: {\n    id: process.env.GOOGLE_ID!,\n    secret: process.env.GOOGLE_SECRET!\n  },\n  async handler({ name, email, image, oauth }, redirectTo) {\n    // add your logic (e.g. database call, session creation)\n    // const session = await getSession();\n    // await session.update({ name, email, image });\n\n    return redirect(\n      // only allow internal redirects\n      redirectTo?.startsWith(\"/\") && !redirectTo.startsWith(\"//\")\n        ? redirectTo\n        : \"/defaultPage\"\n    );\n  }\n});\n```\n\nIn your OAuth provider's dashboard, set the redirect URIs\n\n- **Development**: `http://localhost:3000/api/oauth/[provider]`\n- **Production**: `https://your-domain.com/api/oauth/[provider]`\n\n## Usage\n\n```tsx\n// for example in routes/login.tsx\nimport { useOAuthLogin } from \"start-oauth\";\n\nexport default function Login() {\n  const login = useOAuthLogin();\n\n  return (\n    <div>\n      <a href={login(\"discord\")} rel=\"external\">\n        Sign in with Discord\n      </a>\n      <a href={login(\"google\")} rel=\"external\">\n        Sign in with Google\n      </a>\n    </div>\n  );\n}\n```\n\n- To specify a post-login destination, append `?redirect=/dashboard` to the login URL—this value is passed as the `redirectTo` parameter to your handler.\n- On authentication failure, users are redirected to the login page with `?error=<reason>` for custom error handling.\n\n## Example\n\nSee `start-oauth` in action with the SolidStart [with-auth](https://github.com/solidjs/templates/tree/main/solid-start/with-auth) example\n\n```bash\n# using npm\nnpm create solid@latest -- -st with-auth\n```\n\n```bash\n# using pnpm\npnpm create solid@latest -st with-auth\n```\n\n```bash\n# using bun\nbun create solid@latest --s --t with-auth\n```\n\n## Security Features\n\n- Stateless PKCE with SHA-256 code challenges\n- AES-256-GCM encryption for state parameters to prevent tampering\n- Timeout-protected HTTP requests to avoid hanging connections\n- Strict validation of fallback URLs to prevent open redirects\n","readmeFilename":"README.md","_rev":"1-fa7ebc086597c2d40dfcdbf7928fe69c"}