{"_id":"@aneeshgusain/next-gen-auth","_rev":"13-aa7d0c01fa02eee5ec7db4c3f60615fa","name":"@aneeshgusain/next-gen-auth","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.3":{"name":"@aneeshgusain/next-gen-auth","version":"0.1.3","keywords":["oauth","oidc","openid-connect","pkce","authentication","auth"],"license":"MIT","_id":"@aneeshgusain/next-gen-auth@0.1.3","maintainers":[{"name":"aneeshgusain","email":"anishgusain432@gmail.com"}],"dist":{"shasum":"d61009073641ff693f3ac5c0ca547ea82f7930ad","tarball":"https://registry.npmjs.org/@aneeshgusain/next-gen-auth/-/next-gen-auth-0.1.3.tgz","fileCount":16,"integrity":"sha512-N6xLDidWkLdAiOHLdWgHOxuPTRR9WWDGVHFL1w6YiDjvG6ewInNiHXM5p349Ybyl6/yspgXUnxO7jNAK0Fkk5Q==","signatures":[{"sig":"MEYCIQDIxWbNaiI55EXqNP5/IsocQ0oMS7LV27cP5Wzrkw2M/gIhAJJSUb2rbPy3QmLqUlwNwf7ISHdFNxWvub4jnVixMNDO","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":85538},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"}},"scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"aneeshgusain","email":"anishgusain432@gmail.com"},"_npmVersion":"10.9.7","description":"Browser client SDK for Next-Gen Auth (OAuth 2.0 / OpenID Connect with PKCE)","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^18.2.0","typescript":"^5.4.0","@types/react":"^18.2.0"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/next-gen-auth_0.1.3_1783319661829_0.7328626227625856","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@aneeshgusain/next-gen-auth","version":"0.1.4","keywords":["oauth","oidc","openid-connect","pkce","authentication","auth"],"license":"MIT","_id":"@aneeshgusain/next-gen-auth@0.1.4","maintainers":[{"name":"aneeshgusain","email":"anishgusain432@gmail.com"}],"dist":{"shasum":"3f0997dcfd1bf8433457db687abe98e73cfb634f","tarball":"https://registry.npmjs.org/@aneeshgusain/next-gen-auth/-/next-gen-auth-0.1.4.tgz","fileCount":16,"integrity":"sha512-jKRoHEEmKyrSM8gSruCnvsFbhJQistVBLblYDmnl3rXa1fbQY826FM/GvrV1T9N03gGZtOL7+K8EhNAXljX8CA==","signatures":[{"sig":"MEUCIQDGH1BXPHSa978pWOYyOHC/UFNYnQAYBprDWJfnvpE4OwIgbwgSleJ9YZDg8QzEpaORvv3HYcACDhK6TgOrKr48hm8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116063},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"}},"scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"aneeshgusain","email":"anishgusain432@gmail.com"},"_npmVersion":"10.9.7","description":"Browser client SDK for Next-Gen Auth (OAuth 2.0 / OpenID Connect with PKCE)","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^18.2.0","typescript":"^5.4.0","@types/react":"^18.2.0"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/next-gen-auth_0.1.4_1783746111770_0.980333414138326","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@aneeshgusain/next-gen-auth","version":"0.1.5","keywords":["oauth","oidc","openid-connect","pkce","authentication","auth"],"license":"MIT","_id":"@aneeshgusain/next-gen-auth@0.1.5","maintainers":[{"name":"aneeshgusain","email":"anishgusain432@gmail.com"}],"dist":{"shasum":"ba7d6f883959a68e2f95f8b3286a1d8d6ce52a64","tarball":"https://registry.npmjs.org/@aneeshgusain/next-gen-auth/-/next-gen-auth-0.1.5.tgz","fileCount":16,"integrity":"sha512-FvqHNis9YGkKGaxw/ptydgsf/WyPjOAixlVlP4zUMrfOk5mHjd7OpJ5Hs55TUWRgl6gXf/XqZ9XOuqIhsMujPQ==","signatures":[{"sig":"MEQCID7ZBpaSSQyBkV9ZleSkPDD5Lqi3KvwPfbdWYgpqOnQdAiBzpmy1O8IcGRMhSRiXfU8Rm0dgbSgFCE4zpfPbgh7UnA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116063},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"}},"scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"aneeshgusain","email":"anishgusain432@gmail.com"},"_npmVersion":"10.9.7","description":"Browser client SDK for Next-Gen Auth (OAuth 2.0 / OpenID Connect with PKCE)","directories":{},"_nodeVersion":"22.22.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","react":"^18.2.0","typescript":"^5.4.0","@types/react":"^18.2.0"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/next-gen-auth_0.1.5_1783747662054_0.789577460799495","host":"s3://npm-registry-packages-npm-production"}},"0.1.7":{"name":"@aneeshgusain/next-gen-auth","version":"0.1.7","description":"Browser client SDK for Next-Gen Auth (OAuth 2.0 / OpenID Connect with PKCE)","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.js","require":"./dist/react.cjs"}},"scripts":{"build":"tsup","dev":"tsup --watch","prepublishOnly":"npm run build"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0","@types/react":"^18.2.0","react":"^18.2.0"},"keywords":["oauth","oidc","openid-connect","pkce","authentication","auth"],"license":"MIT","publishConfig":{"access":"public"},"_id":"@aneeshgusain/next-gen-auth@0.1.7","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-EsYWmt88Uy5lREtMdhZqNM7Rd3efvZxZSrjRmtuvtvgV04rdO7j63gSk9vTXgoQQ9iBnTCvplenNC/OnYMgMDA==","shasum":"9410f593afb920e6aaf236df6eb9264403f1d407","tarball":"https://registry.npmjs.org/@aneeshgusain/next-gen-auth/-/next-gen-auth-0.1.7.tgz","fileCount":16,"unpackedSize":121173,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDyAHIKei7ToUA/5N2tNoiJ5sLdQ0ahUiqtQ0Z0TkWx1AIgPAuycN5wchv49NHwUMRo73OmA4+5LbEalGDA8SAPhls="}]},"_npmUser":{"name":"aneeshgusain","email":"anishgusain432@gmail.com"},"directories":{},"maintainers":[{"name":"aneeshgusain","email":"anishgusain432@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/next-gen-auth_0.1.7_1783752687740_0.053391105343991496"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T06:34:21.660Z","modified":"2026-07-11T06:51:28.079Z","0.1.0":"2026-07-06T04:07:28.885Z","0.1.1":"2026-07-06T04:20:16.469Z","0.1.2":"2026-07-06T04:52:15.076Z","0.1.3":"2026-07-06T06:34:21.961Z","0.1.4":"2026-07-11T05:01:51.936Z","0.1.5":"2026-07-11T05:27:42.209Z","0.1.7":"2026-07-11T06:51:27.890Z"},"license":"MIT","keywords":["oauth","oidc","openid-connect","pkce","authentication","auth"],"description":"Browser client SDK for Next-Gen Auth (OAuth 2.0 / OpenID Connect with PKCE)","maintainers":[{"name":"aneeshgusain","email":"anishgusain432@gmail.com"}],"readme":"# @aneeshgusain/next-gen-auth\n\nBrowser SDK for **Next-Gen Auth** — an OAuth 2.0 / OpenID Connect provider with PKCE.\nHandles the entire authorization-code + PKCE flow so consuming apps only ever need\nto provide a `clientId` and `redirectUri`.\n\n## Install\n\n```bash\nnpm install @aneeshgusain/next-gen-auth\n```\n\n## Vanilla JS / any framework\n\n```javascript\nimport { createAuthClient } from \"@aneeshgusain/next-gen-auth\";\n\nconst auth = createAuthClient({\n  clientId: \"your-client-id\",\n  redirectUri: window.location.origin,\n  provider: \"https://next-gen-auth.onrender.com\",\n});\n\n// on app load\nconst claims = await auth.handleCallback(); // null if no code in the URL\nif (claims) console.log(\"Signed in as\", claims.email);\n\n// trigger login\ndocument.getElementById(\"login-btn\").addEventListener(\"click\", () => auth.login());\n\n// check auth state anywhere\nif (auth.isAuthenticated()) {\n  console.log(auth.getUser());\n}\n\n// sign out\nauth.logout();\n```\n\n## React\n\n```jsx\nimport { useAuth } from \"@aneeshgusain/next-gen-auth/react\";\n\nfunction App() {\n  const { user, loading, error, login, logout } = useAuth({\n    clientId: \"your-client-id\",\n    redirectUri: window.location.origin,\n    provider: \"https://next-gen-auth.onrender.com\",\n  });\n\n  if (loading) return <p>Loading…</p>;\n  if (error) return <p>Error: {error}</p>;\n\n  if (user) {\n    return (\n      <div>\n        <h1>Welcome, {user.given_name ?? user.sub}</h1>\n        <button onClick={logout}>Log out</button>\n      </div>\n    );\n  }\n\n  return <button onClick={login}>Continue with Next-Gen Auth</button>;\n}\n```\n\n## API\n\n### `createAuthClient(config)`\n\n| Option          | Required | Default                    | Description                                    |\n| --------------- | -------- | -------------------------- | ---------------------------------------------- |\n| `clientId`    | yes      | —                         | Client ID from registration                    |\n| `redirectUri` | yes      | —                         | Must exactly match the registered redirect URI |\n| `provider`    | yes      | —                         | Base URL of your Next-Gen Auth server          |\n| `scope`       | no       | `\"openid profile email\"` | Space-separated scopes                         |\n| `storage`     | no       | `sessionStorage`         | Where PKCE/session values are kept             |\n\nReturns an object with: `login()`, `handleCallback()`, `getUser()`, `getAccessToken()`,\n`refreshSession()`, `isAuthenticated()`, `logout()`, `fetchUserInfo()`.\n\n#### Refresh tokens\n\nAfter login, the SDK stores the provider's `refresh_token` alongside the access token.\n`getAccessToken()` and `fetchUserInfo()` refresh the access token automatically when it\nis close to expiring (within 60 seconds). You can also call `refreshSession()` explicitly.\n\nThe cached user claims from the initial `id_token` are kept for the life of the refresh\ntoken (up to 7 days), even after the `id_token` JWT itself expires.\n\n### `useAuth(config)` (from `/react` subpath)\n\nSame config shape. Returns `{ user, loading, error, login, logout, refreshSession }`.\n\n## Security notes\n\n- This client is designed for **public clients** (SPAs) using PKCE — no client secret\n  is required or supported here.\n- Tokens are kept in `sessionStorage` by default. If your app is vulnerable to XSS,\n  consider a backend-for-frontend (BFF) architecture instead, where token exchange\n  happens server-side and the browser only holds an httpOnly session cookie.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}