{"_id":"@aid-on/auth-providers","name":"@aid-on/auth-providers","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@aid-on/auth-providers","version":"0.1.0","description":"Core authentication providers library by Aid-On (framework agnostic)","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.js","types":"./dist/index.d.ts"},"./line":{"import":"./dist/line/index.js","require":"./dist/line/index.js","types":"./dist/line/index.d.ts"}},"scripts":{"build":"tsc","dev":"tsc --watch","clean":"rm -rf dist","typecheck":"tsc --noEmit","prepublishOnly":"npm run clean && npm run build","test":"echo \"No tests configured yet\""},"repository":{"type":"git","url":"git+https://github.com/Aid-On/auth-providers-ts.git"},"bugs":{"url":"https://github.com/Aid-On/auth-providers-ts/issues"},"homepage":"https://github.com/Aid-On/auth-providers-ts#readme","keywords":["oauth","line","authentication","aid-on","cloud-functions","serverless"],"author":{"name":"Aid-On"},"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"@types/node":"^20.0.0","esbuild-register":"^3.5.0","typescript":"^5.0.0"},"_id":"@aid-on/auth-providers@0.1.0","gitHead":"1c9698203fbd8878fae08a429519ce85b4d78417","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-j+lYXiY5Nud/knSj5Ag63wZ1k471U0wu5La5m0JAXecRMX/DCIqLwbdBd3dw1IiZ/0ecAyWl+kcJHxGIaNf5rw==","shasum":"9008d7ec82b8ce397dfca9259fb7b01f01a49286","tarball":"https://registry.npmjs.org/@aid-on/auth-providers/-/auth-providers-0.1.0.tgz","fileCount":19,"unpackedSize":28975,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCNJdbhmcAz+LXgMdCErKWjygRyuhd91ZYCqR1ifZWnYgIgFsGR78NwHqgAiPikrZoDDZyLRTYKUtsQJ8HXC9txp9A="}]},"_npmUser":{"name":"aid-on","email":"hiromi.motodera@aid-on.org"},"directories":{},"maintainers":[{"name":"aid-on","email":"hiromi.motodera@aid-on.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/auth-providers_0.1.0_1755912077572_0.2849128236663452"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-23T01:21:17.435Z","0.1.0":"2025-08-23T01:21:17.771Z","modified":"2025-08-23T01:21:18.123Z"},"maintainers":[{"name":"aid-on","email":"hiromi.motodera@aid-on.org"}],"description":"Core authentication providers library by Aid-On (framework agnostic)","homepage":"https://github.com/Aid-On/auth-providers-ts#readme","keywords":["oauth","line","authentication","aid-on","cloud-functions","serverless"],"repository":{"type":"git","url":"git+https://github.com/Aid-On/auth-providers-ts.git"},"author":{"name":"Aid-On"},"bugs":{"url":"https://github.com/Aid-On/auth-providers-ts/issues"},"license":"MIT","readme":"# @aid-on/auth-providers\n\nFramework-agnostic OAuth 2.0 authentication providers by Aid-On.\n\nThis library can be used in:\n- Cloud Functions (GCP, AWS Lambda)\n- Edge Functions (Vercel, Cloudflare Workers)\n- Next.js API Routes\n- Express/Fastify servers\n- Client-side (with proper security measures)\n\n## Installation\n\n```bash\nnpm install @aid-on/auth-providers\n# or\nyarn add @aid-on/auth-providers\n```\n\n## Usage\n\n### Cloud Functions Example\n\n```typescript\nimport { createLineAuthHandler } from '@aid-on/auth-providers/line'\n\nconst lineAuth = createLineAuthHandler({\n  clientId: process.env.LINE_CLIENT_ID!,\n  clientSecret: process.env.LINE_CLIENT_SECRET!,\n  redirectUri: 'https://your-domain.com/api/auth/callback'\n})\n\n// Start authentication\nexport async function startAuth(req: Request) {\n  const { authUrl, state } = lineAuth.startAuth()\n  \n  // Save state to session/cookie for CSRF protection\n  const response = Response.redirect(authUrl)\n  response.headers.set('Set-Cookie', `auth_state=${state}; HttpOnly; Secure; SameSite=Lax`)\n  \n  return response\n}\n\n// Handle callback\nexport async function handleCallback(req: Request) {\n  const url = new URL(req.url)\n  const code = url.searchParams.get('code')!\n  const state = url.searchParams.get('state')!\n  \n  // Get expected state from cookie\n  const expectedState = getCookie(req, 'auth_state')\n  \n  const { user, tokens } = await lineAuth.handleCallback({\n    code,\n    state,\n    expectedState\n  })\n  \n  // Save user and tokens to your database\n  await saveUser(user)\n  await saveTokens(tokens)\n  \n  return Response.json({ success: true, user })\n}\n```\n\n### Direct Client Usage\n\n```typescript\nimport { LineAuthClient } from '@aid-on/auth-providers/line'\n\nconst client = new LineAuthClient({\n  clientId: 'YOUR_CLIENT_ID',\n  clientSecret: 'YOUR_CLIENT_SECRET',\n  redirectUri: 'https://your-domain.com/callback'\n})\n\n// Generate authorization URL\nconst state = client.generateState()\nconst authUrl = client.getAuthorizationUrl({ state })\n\n// Exchange code for tokens\nconst tokens = await client.getAccessToken(code)\n\n// Get user profile\nconst user = await client.getUserProfile(tokens.access_token)\n\n// Refresh token\nconst newTokens = await client.refreshAccessToken(tokens.refresh_token)\n\n// Revoke token\nawait client.revokeAccessToken(tokens.access_token)\n```\n\n## Available Providers\n\n### LINE\nFull OAuth 2.0 implementation for LINE Login\n\n- Authorization URL generation\n- Token exchange\n- User profile retrieval\n- Token refresh\n- Token revocation\n\n## Security Considerations\n\n1. **Never expose client secrets in client-side code**\n2. **Always validate state parameter for CSRF protection**\n3. **Store tokens securely (encrypted in database)**\n4. **Use HTTPS for all OAuth callbacks**\n5. **Implement proper session management**\n\n## License\n\nMIT","readmeFilename":"README.md","_rev":"1-54943a6984bbc934df4a941bdc3b8fba"}